FreeBSD/sys/arm/ti/omap4/pandaboard/pandaboard.c
/**
 *	usb_hub_init - initialises and resets the external USB hub
 *	
 *	The USB hub needs to be held in reset while the power is being applied
 *	and the reference clock is enabled at 19.2MHz.  The following is the
 *	layout of the USB hub taken from the Pandaboard reference manual.
 *
 *
 *	   .-------------.         .--------------.         .----------------.
 *	   |  OMAP4430   |         |   USB3320C   |         |    LAN9514     |
 *	   |             |         |              |         | USB Hub / Eth  |
 *	   |         CLK | <------ | CLKOUT       |         |                |
 *	   |         STP | ------> | STP          |         |                |
 *	   |         DIR | <------ | DIR          |         |                |
 *	   |         NXT | <------ | NXT          |         |                |
 *	   |        DAT0 | <-----> | DAT0         |         |                |
 *	   |        DAT1 | <-----> | DAT1      DP | <-----> | DP             |
 *	   |        DAT2 | <-----> | DAT2      DM | <-----> | DM             |
 *	   |        DAT3 | <-----> | DAT3         |         |                |
 *	   |        DAT4 | <-----> | DAT4         |         |                |
 *	   |        DAT5 | <-----> | DAT5         |  +----> | N_RESET        |
 *	   |        DAT6 | <-----> | DAT6         |  |      |                |
 *	   |        DAT7 | <-----> | DAT7         |  |      |                |
 *	   |             |         |              |  |  +-> | VDD33IO        |
 *	   |    AUX_CLK3 | ------> | REFCLK       |  |  +-> | VDD33A         |
 *	   |             |         |              |  |  |   |                |
 *	   |     GPIO_62 | --+---> | RESET        |  |  |   |                |
 *	   |             |   |     |              |  |  |   |                |
 *	   |             |   |     '--------------'  |  |   '----------------'
 *	   |             |   |     .--------------.  |  |
 *	   |             |   '---->| VOLT CONVERT |--'  |
 *	   |             |         '--------------'     |
 *	   |             |                              |
 *	   |             |         .--------------.     |
 *	   |      GPIO_1 | ------> |   TPS73633   |-----'
 *	   |             |         '--------------'
 *	   '-------------'
 *	
 *
 *	RETURNS:
 *	nothing.
 */
initialises and resets the external USB hub

The USB hub needs to be held in reset while the power is being applied
and the reference clock is enabled at 19.2MHz.  The following is the
layout of the USB hub taken from the Pandaboard reference manual.



nothing.
initialises and resets the external USB hub The USB hub needs to be held in reset while the power is being applied and the reference clock is enabled at 19 . 2MHz . The following is the layout of the USB hub taken from the Pandaboard reference manual . nothing .
static void
usb_hub_init(void)
{
	bus_space_handle_t scrm_addr, gpio1_addr, gpio2_addr, scm_addr;
	if (bus_space_map(fdtbus_bs_tag, OMAP44XX_SCRM_HWBASE,
	    OMAP44XX_SCRM_SIZE, 0, &scrm_addr) != 0)
		panic("Couldn't map SCRM registers");
	if (bus_space_map(fdtbus_bs_tag, OMAP44XX_GPIO1_HWBASE, 
	    OMAP44XX_GPIO1_SIZE, 0, &gpio1_addr) != 0)
		panic("Couldn't map GPIO1 registers");
	if (bus_space_map(fdtbus_bs_tag, OMAP44XX_GPIO2_HWBASE,
	    OMAP44XX_GPIO2_SIZE, 0, &gpio2_addr) != 0)
		panic("Couldn't map GPIO2 registers");
	if (bus_space_map(fdtbus_bs_tag, OMAP44XX_SCM_PADCONF_HWBASE,
	    OMAP44XX_SCM_PADCONF_SIZE, 0, &scm_addr) != 0)
		panic("Couldn't map SCM Padconf registers");
	REG_WRITE32(scrm_addr + SCRM_AUXCLK3, (1 << 16) |    
	                          (0 << 1) |     
	                          (1 << 8));     
	REG_WRITE16(scm_addr + CONTROL_WKUP_PAD0_FREF_CLK3_OUT, 0x0000);
	REG_WRITE32(gpio1_addr + GPIO1_OE, REG_READ32(gpio1_addr + 
	    GPIO1_OE) & ~(1UL << 1));
	REG_WRITE32(gpio1_addr + GPIO1_CLEARDATAOUT, (1UL << 1));
	REG_WRITE16(scm_addr + CONTROL_CORE_PAD1_KPD_COL2, 0x0003);
	REG_WRITE32(gpio2_addr + GPIO2_OE, 
	    REG_READ32(gpio2_addr + GPIO2_OE) & ~(1UL << 30));
	REG_WRITE32(gpio2_addr + GPIO2_CLEARDATAOUT, (1UL << 30));
	REG_WRITE16(scm_addr + CONTROL_CORE_PAD0_GPMC_WAIT1, 0x0003);
	DELAY(10);
	REG_WRITE32(gpio2_addr + GPIO2_SETDATAOUT, (1UL << 30));
	REG_WRITE32(gpio1_addr + GPIO1_SETDATAOUT, (1UL << 1));
	bus_space_unmap(fdtbus_bs_tag, scrm_addr, OMAP44XX_SCRM_SIZE);
	bus_space_unmap(fdtbus_bs_tag, gpio1_addr, OMAP44XX_GPIO1_SIZE);
	bus_space_unmap(fdtbus_bs_tag, gpio2_addr, OMAP44XX_GPIO2_SIZE);
	bus_space_unmap(fdtbus_bs_tag, scm_addr, OMAP44XX_SCM_PADCONF_SIZE);
}
static void usb_hub_init ( void ) { bus_space_handle_t scrm_addr , gpio1_addr , gpio2_addr , scm_addr ; if ( bus_space_map ( fdtbus_bs_tag , OMAP44XX_SCRM_HWBASE , OMAP44XX_SCRM_SIZE , 0 , & scrm_addr ) != 0 ) panic ( " " ) ; if ( bus_space_map ( fdtbus_bs_tag , OMAP44XX_GPIO1_HWBASE , OMAP44XX_GPIO1_SIZE , 0 , & gpio1_addr ) != 0 ) panic ( " " ) ; if ( bus_space_map ( fdtbus_bs_tag , OMAP44XX_GPIO2_HWBASE , OMAP44XX_GPIO2_SIZE , 0 , & gpio2_addr ) != 0 ) panic ( " " ) ; if ( bus_space_map ( fdtbus_bs_tag , OMAP44XX_SCM_PADCONF_HWBASE , OMAP44XX_SCM_PADCONF_SIZE , 0 , & scm_addr ) != 0 ) panic ( " " ) ; REG_WRITE32 ( scrm_addr + SCRM_AUXCLK3 , ( 1 << 16 ) | ( 0 << 1 ) | ( 1 << 8 ) ) ; REG_WRITE16 ( scm_addr + CONTROL_WKUP_PAD0_FREF_CLK3_OUT , 0x0000 ) ; REG_WRITE32 ( gpio1_addr + GPIO1_OE , REG_READ32 ( gpio1_addr + GPIO1_OE ) & ~ ( 1UL << 1 ) ) ; REG_WRITE32 ( gpio1_addr + GPIO1_CLEARDATAOUT , ( 1UL << 1 ) ) ; REG_WRITE16 ( scm_addr + CONTROL_CORE_PAD1_KPD_COL2 , 0x0003 ) ; REG_WRITE32 ( gpio2_addr + GPIO2_OE , REG_READ32 ( gpio2_addr + GPIO2_OE ) & ~ ( 1UL << 30 ) ) ; REG_WRITE32 ( gpio2_addr + GPIO2_CLEARDATAOUT , ( 1UL << 30 ) ) ; REG_WRITE16 ( scm_addr + CONTROL_CORE_PAD0_GPMC_WAIT1 , 0x0003 ) ; DELAY ( 10 ) ; REG_WRITE32 ( gpio2_addr + GPIO2_SETDATAOUT , ( 1UL << 30 ) ) ; REG_WRITE32 ( gpio1_addr + GPIO1_SETDATAOUT , ( 1UL << 1 ) ) ; bus_space_unmap ( fdtbus_bs_tag , scrm_addr , OMAP44XX_SCRM_SIZE ) ; bus_space_unmap ( fdtbus_bs_tag , gpio1_addr , OMAP44XX_GPIO1_SIZE ) ; bus_space_unmap ( fdtbus_bs_tag , gpio2_addr , OMAP44XX_GPIO2_SIZE ) ; bus_space_unmap ( fdtbus_bs_tag , scm_addr , OMAP44XX_SCM_PADCONF_SIZE ) ; }
usb_hub_init - initialises and resets the external USB hub
usb_hub_init - initialises and resets the external USB hub
/* Need to set FREF_CLK3_OUT to 19.2 MHz and pump it out on pin GPIO_WK31.
	 * We know the SYS_CLK is 38.4Mhz and therefore to get the needed 19.2Mhz,
	 * just use a 2x divider and ensure the SYS_CLK is used as the source.
	 */ /* Divider of 2 */ /* Use the SYS_CLK as the source */ /* Enable the clock */ /* Enable the clock out to the pin (GPIO_WK31). 
	 *   muxmode=fref_clk3_out, pullup/down=disabled, input buffer=disabled,
	 *   wakeup=disabled.
	 */ /* Disable the power to the USB hub, drive GPIO1 low */ /* Reset the USB PHY and Hub using GPIO_62 */ /* Enable power to the hub (GPIO_1) */