]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: mx6: cm_fx6: add i2c support
authorNikita Kiryanov <nikita@compulab.co.il>
Wed, 20 Aug 2014 12:09:04 +0000 (15:09 +0300)
committerStefano Babic <sbabic@denx.de>
Tue, 9 Sep 2014 13:37:08 +0000 (15:37 +0200)
Add support for all 3 I2C busses on Compulab CM-FX6 CoM.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@ti.com>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
board/compulab/cm_fx6/cm_fx6.c
include/configs/cm_fx6.h

index 26f04171eed04c78e90f2753c6754448b0eff871..d21c561e66ae0e0495d122bfce65aa70ce4c485e 100644 (file)
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/iomux.h>
+#include <asm/imx-common/mxc_i2c.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include "common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SYS_I2C_MXC
+#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
+                       PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
+                       PAD_CTL_ODE | PAD_CTL_SRE_FAST)
+
+I2C_PADS(i2c0_pads,
+        PAD_EIM_D21__I2C1_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_EIM_D21__GPIO3_IO21 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(3, 21),
+        PAD_EIM_D28__I2C1_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_EIM_D28__GPIO3_IO28 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(3, 28));
+
+I2C_PADS(i2c1_pads,
+        PAD_KEY_COL3__I2C2_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_KEY_COL3__GPIO4_IO12 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(4, 12),
+        PAD_KEY_ROW3__I2C2_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_KEY_ROW3__GPIO4_IO13 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(4, 13));
+
+I2C_PADS(i2c2_pads,
+        PAD_GPIO_3__I2C3_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_GPIO_3__GPIO1_IO03 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(1, 3),
+        PAD_GPIO_6__I2C3_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        PAD_GPIO_6__GPIO1_IO06 | MUX_PAD_CTRL(I2C_PAD_CTRL),
+        IMX_GPIO_NR(1, 6));
+
+
+static void cm_fx6_setup_i2c(void)
+{
+       setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, I2C_PADS_INFO(i2c0_pads));
+       setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, I2C_PADS_INFO(i2c1_pads));
+       setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, I2C_PADS_INFO(i2c2_pads));
+}
+#else
+static void cm_fx6_setup_i2c(void) { }
+#endif
+
 #ifdef CONFIG_USB_EHCI_MX6
 #define WEAK_PULLDOWN  (PAD_CTL_PUS_100K_DOWN |                \
                        PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
@@ -259,6 +300,7 @@ int board_init(void)
 {
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
        cm_fx6_setup_gpmi_nand();
+       cm_fx6_setup_i2c();
 
        return 0;
 }
index 0c25dda39c1d879e13a0d4590d9c47e82723f7bd..e70259e0c85d6d4aa6c8426d29eeb42e54800a2b 100644 (file)
 #define CONFIG_USB_MAX_CONTROLLER_COUNT        2
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET       /* For OTG port */
 
+/* I2C */
+#define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MXC
+#define CONFIG_SYS_I2C_SPEED           100000
+#define CONFIG_SYS_MXC_I2C3_SPEED      400000
+
+#define CONFIG_SYS_I2C_EEPROM_ADDR     0x50
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
+#define CONFIG_SYS_I2C_EEPROM_BUS      2
+
 /* GPIO */
 #define CONFIG_MXC_GPIO