/******************************************************************************* * hwidev_add_uart * * See sys/hwinfo.h for interface description * * Returns: the offset in the hwinfo section of the added device or HWI_NULL_OFF * on error */ unsigned hwidev_add_uart(const char *device_name, hwiattr_uart_t *attr, unsigned bus_hwi_off) { /* we use the (unused) 'device.pnpid' as the device class identifier */ unsigned hwi_off = hwidev_add(device_name, hwi_devclass_UART, bus_hwi_off); if ((hwi_off != HWI_NULL_OFF) && (attr != NULL)) { unsigned i; hwitag_add_common(hwi_off, &attr->common); for (i=0; i<attr->num_clks; i++) hwitag_add_inputclk(hwi_off, 0, 1); // make divisor 1, just in case ;) } return hwi_off; }
/******************************************************************************* * hwibus_add_i2c * * See sys/hwinfo.h for interface description * * Returns: the offset in the hwinfo section of the added bus or HWI_NULL_OFF * on error */ unsigned hwibus_add_i2c(unsigned parent_hwi_off, hwiattr_i2c_t *attr) { unsigned hwi_off = hwibus_add(HWI_ITEM_BUS_I2C, parent_hwi_off); if ((hwi_off != HWI_NULL_OFF) && (attr != NULL)) { unsigned i; hwitag_add_common(hwi_off, &attr->common); for (i=0; i<attr->num_clks; i++) hwitag_add_inputclk(hwi_off, 0, 1); // make divisor 1, just in case ;) for (i=0; i<attr->num_busattr; i++) hwitag_add_busattr(hwi_off, NULL); // create empty busattr tags } return hwi_off; }
void hwi_imx51() { unsigned hwi_bus_internal = 0; /* add I2C (unless directed not to) */ { unsigned hwi_off; hwiattr_i2c_t attr = HWIATTR_I2C_T_INITIALIZER; HWIATTR_I2C_SET_NUM_IRQ(&attr, 1); /* create i2c0 and set the clock source */ HWIATTR_I2C_SET_LOCATION(&attr, MX51_I2C1_BASE, MX51_I2C_SIZE, 0, hwi_find_as(MX51_I2C1_BASE, 1)); hwi_off = hwibus_add_i2c(hwi_bus_internal, &attr); ASSERT(hwi_find_unit(hwi_off) == 0); hwitag_set_ivec(hwi_off, 0, MX51_I2C1_IRQ); /* create i2c1 and set the clock source */ HWIATTR_I2C_SET_LOCATION(&attr, MX51_I2C2_BASE, MX51_I2C_SIZE, 0, hwi_find_as(MX51_I2C2_BASE, 1)); hwi_off = hwibus_add_i2c(hwi_bus_internal, &attr); ASSERT(hwi_find_unit(hwi_off) == 1); hwitag_set_ivec(hwi_off, 0, MX51_I2C2_IRQ); } /* add UART */ { unsigned hwi_off; hwiattr_uart_t attr = HWIATTR_UART_T_INITIALIZER; struct hwi_inputclk clksrc = {.clk = uart_clock, .div = 16}; HWIATTR_UART_SET_NUM_IRQ(&attr, 1); HWIATTR_UART_SET_NUM_CLK(&attr, 1); /* create uart0 */ HWIATTR_UART_SET_LOCATION(&attr, MX51_UART1_BASE, MX51_UART_SIZE, 0, hwi_find_as(MX51_UART1_BASE, 1)); hwi_off = hwidev_add_uart(IMX51_HWI_UART, &attr, hwi_bus_internal); ASSERT(hwi_find_unit(hwi_off) == 0); hwitag_set_ivec(hwi_off, 0, MX51_UART1_INTR); hwitag_set_inputclk(hwi_off, 0, &clksrc); /* historically the UART's were called 'mxl' so add these synonyms */ hwi_add_synonym(hwi_find_device(IMX51_HWI_UART, 0), "sermxl"); } /*add the FEC */ { unsigned hwi_off; hwiattr_enet_t attr = HWIATTR_ENET_T_INITIALIZER; HWIATTR_USB_SET_NUM_IRQ(&attr, 1); /* create eTSEC0 and set the PHY address */ HWIATTR_ENET_SET_LOCATION(&attr, MX51_FEC_BASE, 0x4000, 0, hwi_find_as(MX51_FEC_BASE, 1)); hwi_off = hwidev_add_enet("fec", &attr, hwi_bus_internal); ASSERT(hwi_find_unit(hwi_off) == 0); hwitag_set_avail_ivec(hwi_off, 0, MX51_FEC_INTR); } /* add 1 USB controller */ { unsigned hwi_off; hwiattr_usb_t attr = HWIATTR_USB_T_INITIALIZER; HWIATTR_USB_SET_NUM_IRQ(&attr, 1); /* create usb0 */ HWIATTR_USB_SET_LOCATION(&attr, MX51_USBH1_BASE, MX51_USB_SIZE, 0, hwi_find_as(MX51_USBH1_BASE, 1)); hwi_off = hwibus_add_usb(hwi_bus_internal, &attr); ASSERT(hwi_off != HWI_NULL_OFF); hwitag_set_avail_ivec(hwi_off, 0, MX51_USB_INTR); } /* add 1 sdma controllers */ { unsigned hwi_off; hwiattr_dma_t attr = HWIATTR_DMA_T_INITIALIZER; HWIATTR_DMA_SET_NUM_IRQ(&attr, 1); /* create DMA controller 0 */ HWIATTR_USB_SET_LOCATION(&attr, MX51_SDMA_BASE, MX51_SDMA_SIZE, 0, hwi_find_as(MX51_SDMA_BASE, 1)); hwi_off = hwidev_add_dma(IMX51_HWI_DMA, &attr, hwi_bus_internal); ASSERT(hwi_find_unit(hwi_off) == 0); hwitag_set_avail_ivec(hwi_off, 0, MX51_SDMA_INTRU); } /* add the SSI device */ { unsigned hwi_off = hwidev_add("ssi", hwi_devclass_NONE, HWI_NULL_OFF); hwiattr_common_t attr = HWIATTR_COMMON_INITIALIZER; ASSERT(hwi_off != HWI_NULL_OFF); HWIATTR_SET_LOCATION(&attr, MX51_SSI1_BASE, MX51_SSI_SIZE, 0, hwi_find_as(MX51_SSI1_BASE, 1)); hwitag_add_common(hwi_off, &attr); } /*add the SDRAM */ { unsigned hwi_off = hwidev_add("sdram", hwi_devclass_NONE, HWI_NULL_OFF); hwiattr_common_t attr = HWIATTR_COMMON_INITIALIZER; ASSERT(hwi_off != HWI_NULL_OFF); HWIATTR_SET_LOCATION(&attr, MX51_SDRAM_BASE, MX51_SDRAM_SIZE, 0, hwi_find_as(MX51_SDRAM_BASE, 1)); hwitag_add_common(hwi_off, &attr); } /* add the WATCHDOG device */ { unsigned hwi_off; hwiattr_timer_t attr = HWIATTR_TIMER_T_INITIALIZER; const struct hwi_inputclk clksrc_kick = {.clk = 10, .div = 1}; HWIATTR_TIMER_SET_NUM_CLK(&attr, 1); HWIATTR_TIMER_SET_LOCATION(&attr, MX51_WDOG1_BASE, MX51_WDOG_SIZE, 0, hwi_find_as(MX51_WDOG1_BASE, 1)); hwi_off = hwidev_add_timer("wdog", &attr, HWI_NULL_OFF); ASSERT(hwi_off != HWI_NULL_OFF); hwitag_set_inputclk(hwi_off, 0, (struct hwi_inputclk *)&clksrc_kick); } } #if defined(__QNXNTO__) && defined(__USESRCVERSION) #include <sys/srcversion.h> __SRCVERSION("$URL: http://svn/product/branches/6.6.0/trunk/hardware/startup/lib/arm/hwi_imx51.c $ $Rev: 680332 $")