diff options
author | Dong Aisheng <b29396@freescale.com> | 2013-06-05 10:49:38 +0800 |
---|---|---|
committer | Dong Aisheng <b29396@freescale.com> | 2013-06-06 18:14:45 +0800 |
commit | f36972b647fc5f0be3b5b7d8abfb619aabfadb3e (patch) | |
tree | 3d84e13cdc4ecf0fb1eedff399fbd188bb83c047 | |
parent | 7cb8bc367eadaa0283abc51638b55b4dcae743f8 (diff) |
ENGR00265643-5 imx6q: add max7310 support
Using i2c_board_init function to setup I2C3 signal steering and the max7310
reset(ideally they should be separated).
Current there's no proper place to put steer-gpios properly, it's a common
device tree issue, so i put it under i2c node temporaily to speed up the works.
One known issue is that gpio1(reset-gpio) does not work with uboot 2012,
i spent a lot time to debug it, however, still did not find the root cause.
After swtiching to uboot 2013, it can work well.
Signed-off-by: Dong Aisheng <b29396@freescale.com>
-rw-r--r-- | arch/arm/boot/dts/imx6dl-sabreauto.dts | 7 | ||||
-rw-r--r-- | arch/arm/boot/dts/imx6q-sabreauto.dts | 7 | ||||
-rw-r--r-- | arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 23 | ||||
-rw-r--r-- | arch/arm/mach-imx/mach-imx6q.c | 45 |
4 files changed, 82 insertions, 0 deletions
diff --git a/arch/arm/boot/dts/imx6dl-sabreauto.dts b/arch/arm/boot/dts/imx6dl-sabreauto.dts index 4e7eb8399346..b357d7d4e055 100644 --- a/arch/arm/boot/dts/imx6dl-sabreauto.dts +++ b/arch/arm/boot/dts/imx6dl-sabreauto.dts @@ -33,6 +33,13 @@ /* RGMII Phy Interrupt */ MX6DL_PAD_GPIO_19__GPIO4_IO05 0x80000000 MX6DL_PAD_EIM_EB0__GPIO2_IO28 0x80000000 + /* + * SABREAUTO_I2C3_STEER + * enable either EIM_D18 or i2c3_sda route path + */ + MX6DL_PAD_EIM_A24__GPIO5_IO04 0x80000000 + /* max7310 reset pin */ + MX6DL_PAD_SD2_DAT0__GPIO1_IO15 0x80000000 >; }; }; diff --git a/arch/arm/boot/dts/imx6q-sabreauto.dts b/arch/arm/boot/dts/imx6q-sabreauto.dts index cedd4e2b3292..1ea03d58ba8d 100644 --- a/arch/arm/boot/dts/imx6q-sabreauto.dts +++ b/arch/arm/boot/dts/imx6q-sabreauto.dts @@ -27,6 +27,13 @@ /*RGMII Phy Interrupt */ MX6Q_PAD_GPIO_19__GPIO4_IO05 0x80000000 MX6Q_PAD_EIM_EB0__GPIO2_IO28 0x80000000 + /* + * SABREAUTO_I2C3_STEER + * enable either EIM_D18 or i2c3_sda route path + */ + MX6Q_PAD_EIM_A24__GPIO5_IO04 0x80000000 + /* max7310 reset pin */ + MX6Q_PAD_SD2_DAT0__GPIO1_IO15 0x80000000 >; }; }; diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index b4757609e3f1..42169be5fb54 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -301,8 +301,31 @@ i2c@021a8000 { /* I2C3 */ clock-frequency = <100000>; pinctrl-names = "default"; + steer-gpios = <&gpio5 4 0>; + reset-gpios = <&gpio1 15 0>; pinctrl-0 = <&pinctrl_i2c3_4>; status = "okay"; + + max7310_1: gpio@30{ + compatible = "maxim,max7310"; + reg = <0x30>; + gpio-controller; + #gpio-cells = <2>; + }; + + max7310_2: gpio@32{ + compatible = "maxim,max7310"; + reg = <0x32>; + gpio-controller; + #gpio-cells = <2>; + }; + + max7310_3: gpio@34{ + compatible = "maxim,max7310"; + reg = <0x34>; + gpio-controller; + #gpio-cells = <2>; + }; }; }; diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index 90808db7f62f..6dbbdae9c884 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -47,6 +47,7 @@ #include <mach/common.h> #include <mach/cpuidle.h> #include <mach/hardware.h> +#include <mach/i2c.h> #include <mach/busfreq.h> #ifdef CONFIG_PCI_MSI #include "msi.h" @@ -877,12 +878,56 @@ static struct ahci_platform_data imx_sata_pdata = { .exit = imx_sata_exit, }; +static int i2c3_board_init(void) +{ + struct device_node *np; + int i2c3_steer_gpio; + int max7310_reset_gpio; + + np = of_find_node_by_path("/soc/aips-bus@02100000/i2c@021a8000"); + if (!np) + return -ENODEV; + + i2c3_steer_gpio = of_get_named_gpio(np, "steer-gpios", 0); + max7310_reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); + if (!gpio_is_valid(i2c3_steer_gpio) || !gpio_is_valid(max7310_reset_gpio)) { + pr_warn("unable to get i2c board setup gpios\n"); + return -ENODEV; + } + + if (gpio_request_one(i2c3_steer_gpio, GPIOF_DIR_OUT, + "i2c3 steer gpio")) + return -EINVAL; + + if (gpio_request_one(max7310_reset_gpio, GPIOF_DIR_OUT, + "max7310 reset gpio")) + return -EINVAL; + + /* enable either EIM_D18 or i2c3_sda route path */ + if (spinor_en || weim_nor) { + gpio_set_value(i2c3_steer_gpio , 0); + gpio_set_value(i2c3_steer_gpio , 0); + } else { + gpio_set_value(i2c3_steer_gpio , 1); + gpio_set_value(max7310_reset_gpio, 1); + } + + of_node_put(np); + + return 0; +} + +static struct imxi2c_platform_data i2c3_pdata = { + .board_init = i2c3_board_init, +}; + /* Add auxdata to pass platform data */ static const struct of_dev_auxdata imx6q_auxdata_lookup[] __initconst = { OF_DEV_AUXDATA("snps,imx-ahci", MX6Q_SATA_BASE_ADDR, "imx-ahci", &imx_sata_pdata), OF_DEV_AUXDATA("fsl,imx6q-flexcan", 0x02090000, NULL, &flexcan_pdata[0]), OF_DEV_AUXDATA("fsl,imx6q-flexcan", 0x02094000, NULL, &flexcan_pdata[1]), + OF_DEV_AUXDATA("fsl,imx6q-i2c", 0x021a8000, NULL, &i2c3_pdata), { /* sentinel */ } }; |