@@ -12,12 +12,38 @@
#include <asm/arch/clk.h>
#include <asm/arch/uart.h>
#include <asm/arch/mux.h>
+#include <asm/arch/i2c.h>
#include <asm/io.h>
static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
static struct uart_ctrl_regs *ctrl = (struct uart_ctrl_regs *)UART_CTRL_BASE;
static struct mux_regs *mux = (struct mux_regs *)MUX_BASE;
+#ifdef CONFIG_DM_I2C
+static const struct lpc32xx_i2c_dev lpc32xx_i2cs[] = {
+ {
+ .base = (struct lpc32xx_i2c_base *)I2C1_BASE,
+ .speed = CONFIG_SYS_I2C_LPC32XX_SPEED,
+ .index = I2C_0,
+ },
+ {
+ .base = (struct lpc32xx_i2c_base *)I2C2_BASE,
+ .speed = CONFIG_SYS_I2C_LPC32XX_SPEED,
+ .index = I2C_1,
+ },
+ {
+ .base = (struct lpc32xx_i2c_base *)(USB_BASE + 0x300),
+ .speed = 100000,
+ .index = I2C_2,
+ },
+};
+U_BOOT_DEVICES(lpc32xx_i2cs) = {
+ { "i2c_lpc32xx", &lpc32xx_i2cs[0] },
+ { "i2c_lpc32xx", &lpc32xx_i2cs[1] },
+ { "i2c_lpc32xx", &lpc32xx_i2cs[2] },
+};
+#endif /* CONFIG_DM_I2C */
+
void lpc32xx_uart_init(unsigned int uart_id)
{
if (uart_id < 1 || uart_id > 7)
@@ -110,19 +136,48 @@ void lpc32xx_slc_nand_init(void)
void lpc32xx_usb_init(void)
{
+#ifdef CONFIG_DM_I2C
+ struct udevice *dev;
+ int ret;
+#endif /* CONFIG_DM_I2C */
+
/* Do not route the UART 5 Tx/Rx pins to the USB D+ and USB D- pins. */
clrbits_le32(&ctrl->ctrl, UART_CTRL_UART5_USB_MODE);
+
+#ifdef CONFIG_DM_I2C
+ ret = uclass_get_device(UCLASS_I2C, I2C_2, &dev);
+ if (ret)
+ debug("I2C_2 init failed: %d\n", ret);
+#endif /* CONFIG_DM_I2C */
}
void lpc32xx_i2c_init(unsigned int devnum)
{
/* Enable I2C interface */
uint32_t ctrl = readl(&clk->i2cclk_ctrl);
+#ifdef CONFIG_DM_I2C
+ struct udevice *dev;
+ int ret;
+#endif /* CONFIG_DM_I2C */
+
if (devnum == 1)
ctrl |= CLK_I2C1_ENABLE;
if (devnum == 2)
ctrl |= CLK_I2C2_ENABLE;
writel(ctrl, &clk->i2cclk_ctrl);
+
+#ifdef CONFIG_DM_I2C
+ if (devnum == 1) {
+ ret = uclass_get_device(UCLASS_I2C, I2C_0, &dev);
+ if (ret)
+ debug("I2C_1 init failed: %d\n", ret);
+ }
+ if (devnum == 2) {
+ ret = uclass_get_device(UCLASS_I2C, I2C_1, &dev);
+ if (ret)
+ debug("I2C_2 init failed: %d\n", ret);
+ }
+#endif /* CONFIG_DM_I2C */
}
U_BOOT_DEVICE(lpc32xx_gpios) = {