FreeBSD/sys/arm/freescale/imx/imx6_machdep.c
/*
 * Determine what flavor of imx6 we're running on.
 *
 * This code is based on the way u-boot does it.  Information found on the web
 * indicates that Freescale themselves were the original source of this logic,
 * including the strange check for number of CPUs in the SCU configuration
 * register, which is apparently needed on some revisions of the SOLO.
 *
 * According to the documentation, there is such a thing as an i.MX6 Dual
 * (non-lite flavor).  However, Freescale doesn't seem to have assigned it a
 * number or provided any logic to handle it in their detection code.
 *
 * Note that the ANALOG_DIGPROG and SCU configuration registers are not
 * documented in the chip reference manual.  (SCU configuration is mentioned,
 * but not mapped out in detail.)  I think the bottom two bits of the scu config
 * register may be ncpu-1.
 *
 * This hasn't been tested yet on a dual[-lite].
 *
 * On a solo:
 *      digprog    = 0x00610001
 *      hwsoc      = 0x00000062
 *      scu config = 0x00000500
 * On a quad:
 *      digprog    = 0x00630002
 *      hwsoc      = 0x00000063
 *      scu config = 0x00005503
 */
Determine what flavor of imx6 we're running on.
This code is based on the way u-boot does it.  Information found on the web
indicates that Freescale themselves were the original source of this logic,
including the strange check for number of CPUs in the SCU configuration
register, which is apparently needed on some revisions of the SOLO.

According to the documentation, there is such a thing as an i.MX6 Dual
(non-lite flavor).  However, Freescale doesn't seem to have assigned it a
number or provided any logic to handle it in their detection code.

Note that the ANALOG_DIGPROG and SCU configuration registers are not
documented in the chip reference manual.  (SCU configuration is mentioned,
but not mapped out in detail.)  I think the bottom two bits of the scu config
register may be ncpu-1.

This hasn't been tested yet on a dual[-lite].


Determine what flavor of imx6 we ' re running on . This code is based on the way u - boot does it . Information found on the web indicates that Freescale themselves were the original source of this logic including the strange check for number of CPUs in the SCU configuration register which is apparently needed on some revisions of the SOLO . According to the documentation there is such a thing as an i . MX6 Dual ( non - lite flavor ) . However Freescale doesn ' t seem to have assigned it a number or provided any logic to handle it in their detection code . Note that the ANALOG_DIGPROG and SCU configuration registers are not documented in the chip reference manual . ( SCU configuration is mentioned but not mapped out in detail . ) I think the bottom two bits of the scu config register may be ncpu - 1 . This hasn ' t been tested yet on a dual [ - lite ] .
u_int imx_soc_type()
{
	uint32_t digprog, hwsoc;
	uint32_t *pcr;
	static u_int soctype;
	const vm_offset_t SCU_CONFIG_PHYSADDR = 0x00a00004;
#define	HWSOC_MX6SL	0x60
#define	HWSOC_MX6DL	0x61
#define	HWSOC_MX6SOLO	0x62
#define	HWSOC_MX6Q	0x63
	if (soctype != 0)
		return (soctype);
	digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG_SL);
	hwsoc = (digprog >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT) & 
	    IMX6_ANALOG_DIGPROG_SOCTYPE_MASK;
	if (hwsoc != HWSOC_MX6SL) {
		digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG);
		hwsoc = (digprog & IMX6_ANALOG_DIGPROG_SOCTYPE_MASK) >>
		    IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT;
		if (hwsoc == HWSOC_MX6DL) {
			pcr = devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
			if (pcr != NULL) {
				if ((*pcr & 0x03) == 0) {
					hwsoc = HWSOC_MX6SOLO;
				}
			}
		}
	}
	switch (hwsoc) {
	case HWSOC_MX6SL:
		soctype = IMXSOC_6SL;
		break;
	case HWSOC_MX6SOLO:
		soctype = IMXSOC_6S;
		break;
	case HWSOC_MX6DL:
		soctype = IMXSOC_6DL;
		break;
	case HWSOC_MX6Q :
		soctype = IMXSOC_6Q;
		break;
	default:
		printf("imx_soc_type: Don't understand hwsoc 0x%02x, "
		    "digprog 0x%08x; assuming IMXSOC_6Q\n", hwsoc, digprog);
		soctype = IMXSOC_6Q;
		break;
	}
	return (soctype);
}
u_int imx_soc_type ( ) { uint32_t digprog , hwsoc ; uint32_t * pcr ; static u_int soctype ; const vm_offset_t SCU_CONFIG_PHYSADDR = 0x00a00004 ; #define HWSOC_MX6SL 	0x60 #define HWSOC_MX6DL 	0x61 #define HWSOC_MX6SOLO 	0x62 #define HWSOC_MX6Q 	0x63 if ( soctype != 0 ) return ( soctype ) ; digprog = imx6_anatop_read_4 ( IMX6_ANALOG_DIGPROG_SL ) ; hwsoc = ( digprog >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT ) & IMX6_ANALOG_DIGPROG_SOCTYPE_MASK ; if ( hwsoc != HWSOC_MX6SL ) { digprog = imx6_anatop_read_4 ( IMX6_ANALOG_DIGPROG ) ; hwsoc = ( digprog & IMX6_ANALOG_DIGPROG_SOCTYPE_MASK ) >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT ; if ( hwsoc == HWSOC_MX6DL ) { pcr = devmap_ptov ( SCU_CONFIG_PHYSADDR , 4 ) ; if ( pcr != NULL ) { if ( ( * pcr & 0x03 ) == 0 ) { hwsoc = HWSOC_MX6SOLO ; } } } } switch ( hwsoc ) { case HWSOC_MX6SL : soctype = IMXSOC_6SL ; break ; case HWSOC_MX6SOLO : soctype = IMXSOC_6S ; break ; case HWSOC_MX6DL : soctype = IMXSOC_6DL ; break ; case HWSOC_MX6Q : soctype = IMXSOC_6Q ; break ; default : printf ( " " " \n " , hwsoc , digprog ) ; soctype = IMXSOC_6Q ; break ; } return ( soctype ) ; }
Determine what flavor of imx6 we're running on.
Determine what flavor of imx6 we ' re running on .
/*printf("digprog = 0x%08x\n", digprog);*/ /*printf("scu config = 0x%08x\n", *pcr);*/ /* printf("hwsoc 0x%08x\n", hwsoc); */