]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00209633-2 I2C mx6sl pfuze: add pfuze board support for mx6sl arm2
authorRobin Gong <B38343@freescale.com>
Thu, 17 May 2012 06:19:01 +0000 (14:19 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:39 +0000 (08:34 +0200)
1.add pmic board support file
2.add i2c support on board-mx6sl_arm2.c
3.update IOMUX setting for I2C pin for mx6sl arm2 board
Signed-off-by: Robin Gong <B38343@freescale.com>
arch/arm/mach-mx6/Makefile
arch/arm/mach-mx6/board-mx6sl_arm2.c
arch/arm/mach-mx6/board-mx6sl_arm2.h
arch/arm/mach-mx6/mx6sl_arm2_pmic_pfuze100.c [new file with mode: 0644]

index 469181d5923df5337bb3bfbaef25f87c963e86f3..3c367582544aa779a879f885026cb0d38b42941d 100644 (file)
@@ -9,7 +9,7 @@ mx6_mmdc.o mx6_ddr_freq.o
 
 obj-$(CONFIG_ARCH_MX6) += clock.o mx6q_suspend.o clock_mx6sl.o
 obj-$(CONFIG_MACH_MX6Q_ARM2) += board-mx6q_arm2.o
-obj-$(CONFIG_MACH_MX6SL_ARM2) += board-mx6sl_arm2.o
+obj-$(CONFIG_MACH_MX6SL_ARM2) += board-mx6sl_arm2.o mx6sl_arm2_pmic_pfuze100.o
 obj-$(CONFIG_MACH_MX6Q_SABRELITE) += board-mx6q_sabrelite.o
 obj-$(CONFIG_MACH_MX6Q_SABRESD) += board-mx6q_sabresd.o mx6q_sabresd_pmic_pfuze100.o
 obj-$(CONFIG_MACH_MX6Q_SABREAUTO) += board-mx6q_sabreauto.o mx6q_sabreauto_pmic_pfuze100.o
index 220ea3241f2480f080ccc394f5b103d4b129dd3f..fd1cb30b420223e6d22da44f8d5126dad3df0cc9 100755 (executable)
@@ -82,6 +82,7 @@
 #define MX6_ARM2_SD3_CD                IMX_GPIO_NR(3, 22)      /* REF_CLK_32K */
 #define MX6_ARM2_FEC_PWR_EN    IMX_GPIO_NR(4, 21)      /* FEC_TX_CLK */
 
+extern int __init mx6sl_arm2_init_pfuze100(u32 int_gpio);
 static const struct esdhc_platform_data mx6_arm2_sd1_data __initconst = {
        .cd_gpio                = MX6_ARM2_SD1_CD,
        .wp_gpio                = MX6_ARM2_SD1_WP,
@@ -103,6 +104,36 @@ static const struct esdhc_platform_data mx6_arm2_sd3_data __initconst = {
        .delay_line             = 0,
 };
 
+static struct imxi2c_platform_data mx6_arm2_i2c0_data = {
+       .bitrate = 100000,
+};
+
+static struct imxi2c_platform_data mx6_arm2_i2c1_data = {
+       .bitrate = 100000,
+};
+
+static struct imxi2c_platform_data mx6_arm2_i2c2_data = {
+       .bitrate = 400000,
+};
+
+static struct i2c_board_info mxc_i2c0_board_info[] __initdata = {
+       {
+               I2C_BOARD_INFO("max17135", 0x48),
+               /*.platform_data = &max17135_pdata,*/
+       },
+};
+
+static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {
+       {
+               I2C_BOARD_INFO("wm8962", 0x1a),
+               /*.platform_data = &wm8962_config_data,*/
+       },
+};
+
+static struct i2c_board_info mxc_i2c2_board_info[] __initdata = {
+       {
+       },
+};
 void __init early_console_setup(unsigned long base, struct clk *clk);
 
 static inline void mx6_arm2_init_uart(void)
@@ -165,6 +196,16 @@ static void __init mx6_arm2_init(void)
 {
        mxc_iomux_v3_setup_multiple_pads(mx6sl_arm2_pads, ARRAY_SIZE(mx6sl_arm2_pads));
 
+       imx6q_add_imx_i2c(0, &mx6_arm2_i2c0_data);
+       imx6q_add_imx_i2c(1, &mx6_arm2_i2c1_data);
+       i2c_register_board_info(0, mxc_i2c0_board_info,
+                       ARRAY_SIZE(mxc_i2c0_board_info));
+       i2c_register_board_info(1, mxc_i2c1_board_info,
+                       ARRAY_SIZE(mxc_i2c1_board_info));
+       imx6q_add_imx_i2c(2, &mx6_arm2_i2c2_data);
+       i2c_register_board_info(2, mxc_i2c2_board_info,
+                       ARRAY_SIZE(mxc_i2c2_board_info));
+       mx6sl_arm2_init_pfuze100(0);
        mx6_arm2_init_uart();
        /* get enet tx reference clk from FEC_REF_CLK pad.
         * GPR1[14] = 0, GPR1[18:17] = 00
index c363bf84bfc8816d8e46e4067d0ec4d336164508..9e4ea0a748b1e1378b3f2e22502baf121cf1c277 100755 (executable)
@@ -84,6 +84,12 @@ static iomux_v3_cfg_t mx6sl_arm2_pads[] = {
        MX6SL_PAD_FEC_TXD0__FEC_TDATA_0,
        MX6SL_PAD_FEC_TXD1__FEC_TDATA_1,
        MX6SL_PAD_FEC_TX_CLK__GPIO_4_21, /* Phy power enable */
+
+       /* I2C */
+       MX6SL_PAD_I2C1_SCL__I2C1_SCL,
+       MX6SL_PAD_I2C1_SDA__I2C1_SDA,
+       MX6SL_PAD_I2C2_SCL__I2C2_SCL,
+       MX6SL_PAD_I2C2_SDA__I2C2_SDA,
 };
 
 #endif
diff --git a/arch/arm/mach-mx6/mx6sl_arm2_pmic_pfuze100.c b/arch/arm/mach-mx6/mx6sl_arm2_pmic_pfuze100.c
new file mode 100644 (file)
index 0000000..0d5a37c
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/regulator/machine.h>
+#include <linux/mfd/pfuze.h>
+#include <mach/irqs.h>
+
+/*
+ * Convenience conversion.
+ * Here atm, maybe there is somewhere better for this.
+ */
+#define mV_to_uV(mV) (mV * 1000)
+#define uV_to_mV(uV) (uV / 1000)
+#define V_to_uV(V) (mV_to_uV(V * 1000))
+#define uV_to_V(uV) (uV_to_mV(uV) / 1000)
+
+#define PFUZE100_I2C_DEVICE_NAME  "pfuze100"
+/* 7-bit I2C bus slave address */
+#define PFUZE100_I2C_ADDR         (0x08)
+ /*SWBST*/
+#define PFUZE100_SW1ASTANDBY   33
+#define PFUZE100_SW1ASTANDBY_STBY_VAL  (0x16)
+#define PFUZE100_SW1ASTANDBY_STBY_M    (0x3f<<0)
+#define PFUZE100_SW1BSTANDBY   40
+#define PFUZE100_SW1BSTANDBY_STBY_VAL  (0x16)
+#define PFUZE100_SW1BSTANDBY_STBY_M    (0x3f<<0)
+#define PFUZE100_SW1CSTANDBY   47
+#define PFUZE100_SW1CSTANDBY_STBY_VAL  (0x16)
+#define PFUZE100_SW1CSTANDBY_STBY_M    (0x3f<<0)
+#define PFUZE100_SW2STANDBY     54
+#define PFUZE100_SW2STANDBY_STBY_VAL    0x0
+#define PFUZE100_SW2STANDBY_STBY_M      (0x3f<<0)
+#define PFUZE100_SW3ASTANDBY    61
+#define PFUZE100_SW3ASTANDBY_STBY_VAL   0x0
+#define PFUZE100_SW3ASTANDBY_STBY_M     (0x3f<<0)
+#define PFUZE100_SW3BSTANDBY    68
+#define PFUZE100_SW3BSTANDBY_STBY_VAL   0x0
+#define PFUZE100_SW3BSTANDBY_STBY_M     (0x3f<<0)
+#define PFUZE100_SW4STANDBY     75
+#define PFUZE100_SW4STANDBY_STBY_VAL    0
+#define PFUZE100_SW4STANDBY_STBY_M      (0x3f<<0)
+#define PFUZE100_SWBSTCON1     102
+#define PFUZE100_SWBSTCON1_SWBSTMOD_VAL        (0x1<<2)
+#define PFUZE100_SWBSTCON1_SWBSTMOD_M  (0x3<<2)
+
+
+static struct regulator_consumer_supply sw2_consumers[] = {
+       {
+               .supply         = "MICVDD",
+               .dev_name       = "1-001a",
+       },
+       {
+               .supply         = "DBVDD",
+               .dev_name       = "1-001a",
+       }
+
+};
+static struct regulator_consumer_supply sw4_consumers[] = {
+       {
+       .supply = "AUD_1V8",
+       }
+};
+static struct regulator_consumer_supply swbst_consumers[] = {
+       {
+       .supply = "SWBST_5V",
+       }
+};
+static struct regulator_consumer_supply vgen1_consumers[] = {
+       {
+       .supply = "VGEN1_1V5",
+       }
+};
+static struct regulator_consumer_supply vgen2_consumers[] = {
+       {
+       .supply = "VGEN2_1V5",
+       }
+};
+static struct regulator_consumer_supply vgen4_consumers[] = {
+       {
+               .supply    = "AVDD",
+               .dev_name       = "1-001a",
+       },
+       {
+               .supply    = "DCVDD",
+               .dev_name       = "1-001a",
+       },
+       {
+               .supply    = "CPVDD",
+               .dev_name       = "1-001a",
+       },
+       {
+               .supply    = "PLLVDD",
+               .dev_name       = "1-001a",
+       }
+};
+static struct regulator_consumer_supply vgen5_consumers[] = {
+       {
+       .supply = "VGEN5_2V8",
+       }
+};
+static struct regulator_consumer_supply vgen6_consumers[] = {
+       {
+       .supply = "VGEN6_3V3",
+       }
+};
+
+static struct regulator_init_data sw1a_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW1A",
+#ifdef PFUZE100_FIRST_VERSION
+                       .min_uV = 650000,
+                       .max_uV = 1437500,
+#else
+                       .min_uV = 300000,
+                       .max_uV = 1875000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .boot_on = 1,
+                       .always_on = 1,
+                       },
+};
+
+static struct regulator_init_data sw1b_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW1B",
+                       .min_uV = 300000,
+                       .max_uV = 1875000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data sw1c_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW1C",
+                       .min_uV = 300000,
+                       .max_uV = 1875000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data sw2_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW2",
+#if PFUZE100_SW2_VOL6
+                       .min_uV = 800000,
+                       .max_uV = 3950000,
+#else
+                       .min_uV = 400000,
+                       .max_uV = 1975000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(sw2_consumers),
+       .consumer_supplies = sw2_consumers,
+};
+
+static struct regulator_init_data sw3a_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW3A",
+#if PFUZE100_SW3_VOL6
+                       .min_uV = 800000,
+                       .max_uV = 3950000,
+#else
+                       .min_uV = 400000,
+                       .max_uV = 1975000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data sw3b_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW3B",
+#if PFUZE100_SW3_VOL6
+                       .min_uV = 800000,
+                       .max_uV = 3950000,
+#else
+                       .min_uV = 400000,
+                       .max_uV = 1975000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data sw4_init = {
+       .constraints = {
+                       .name = "PFUZE100_SW4",
+#if PFUZE100_SW4_VOL6
+                       .min_uV = 800000,
+                       .max_uV = 3950000,
+#else
+                       .min_uV = 400000,
+                       .max_uV = 1975000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(sw4_consumers),
+       .consumer_supplies = sw4_consumers,
+};
+
+static struct regulator_init_data swbst_init = {
+       .constraints = {
+                       .name = "PFUZE100_SWBST",
+                       .min_uV = 5000000,
+                       .max_uV = 5150000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(swbst_consumers),
+       .consumer_supplies = swbst_consumers,
+};
+
+static struct regulator_init_data vsnvs_init = {
+       .constraints = {
+                       .name = "PFUZE100_VSNVS",
+                       .min_uV = 1200000,
+                       .max_uV = 3000000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
+                       .valid_modes_mask = 0,
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data vrefddr_init = {
+       .constraints = {
+                       .name = "PFUZE100_VREFDDR",
+                       .always_on = 1,
+                       .boot_on = 1,
+                       },
+};
+
+static struct regulator_init_data vgen1_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN1",
+#ifdef PFUZE100_FIRST_VERSION
+                       .min_uV = 1200000,
+                       .max_uV = 1550000,
+#else
+                       .min_uV = 800000,
+                       .max_uV = 1550000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       .always_on = 0,
+                       .boot_on = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(vgen1_consumers),
+       .consumer_supplies = vgen1_consumers,
+};
+
+static struct regulator_init_data vgen2_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN2",
+#ifdef PFUZE100_FIRST_VERSION
+                       .min_uV = 1200000,
+                       .max_uV = 1550000,
+#else
+                       .min_uV = 800000,
+                       .max_uV = 1550000,
+#endif
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(vgen2_consumers),
+       .consumer_supplies = vgen2_consumers,
+
+};
+
+static struct regulator_init_data vgen3_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN3",
+                       .min_uV = 1800000,
+                       .max_uV = 3300000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       .always_on = 0,
+                       .boot_on = 0,
+                       },
+};
+
+static struct regulator_init_data vgen4_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN4",
+                       .min_uV = 1800000,
+                       .max_uV = 3300000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(vgen4_consumers),
+       .consumer_supplies = vgen4_consumers,
+};
+
+static struct regulator_init_data vgen5_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN5",
+                       .min_uV = 1800000,
+                       .max_uV = 3300000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(vgen5_consumers),
+       .consumer_supplies = vgen5_consumers,
+};
+
+static struct regulator_init_data vgen6_init = {
+       .constraints = {
+                       .name = "PFUZE100_VGEN6",
+                       .min_uV = 1800000,
+                       .max_uV = 3300000,
+                       .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+                       REGULATOR_CHANGE_STATUS,
+                       .valid_modes_mask = 0,
+                       },
+       .num_consumer_supplies = ARRAY_SIZE(vgen6_consumers),
+       .consumer_supplies = vgen6_consumers,
+};
+
+static int pfuze100_init(struct mc_pfuze *pfuze)
+{
+       int ret;
+       ret = pfuze_reg_rmw(pfuze, PFUZE100_SW1ASTANDBY,
+                           PFUZE100_SW1ASTANDBY_STBY_M,
+                           PFUZE100_SW1ASTANDBY_STBY_VAL);
+       if (ret)
+               goto err;
+       ret = pfuze_reg_rmw(pfuze, PFUZE100_SW1BSTANDBY,
+                           PFUZE100_SW1BSTANDBY_STBY_M,
+                           PFUZE100_SW1BSTANDBY_STBY_VAL);
+       if (ret)
+               goto err;
+       ret = pfuze_reg_rmw(pfuze, PFUZE100_SW1CSTANDBY,
+                           PFUZE100_SW1CSTANDBY_STBY_M,
+                           PFUZE100_SW1CSTANDBY_STBY_VAL);
+       if (ret)
+               goto err;
+       return 0;
+err:
+       printk(KERN_ERR "pfuze100 init error!\n");
+       return -1;
+}
+
+static struct pfuze_regulator_init_data mx6q_sabreauto_pfuze100_regulators[] = {
+       {.id = PFUZE100_SW1A,   .init_data = &sw1a_init},
+       {.id = PFUZE100_SW1B,   .init_data = &sw1b_init},
+       {.id = PFUZE100_SW1C,   .init_data = &sw1c_init},
+       {.id = PFUZE100_SW2,    .init_data = &sw2_init},
+       {.id = PFUZE100_SW3A,   .init_data = &sw3a_init},
+       {.id = PFUZE100_SW3B,   .init_data = &sw3b_init},
+       {.id = PFUZE100_SW4,    .init_data = &sw4_init},
+       {.id = PFUZE100_SWBST,  .init_data = &swbst_init},
+       {.id = PFUZE100_VSNVS,  .init_data = &vsnvs_init},
+       {.id = PFUZE100_VREFDDR,        .init_data = &vrefddr_init},
+       {.id = PFUZE100_VGEN1,  .init_data = &vgen1_init},
+       {.id = PFUZE100_VGEN2,  .init_data = &vgen2_init},
+       {.id = PFUZE100_VGEN3,  .init_data = &vgen3_init},
+       {.id = PFUZE100_VGEN4,  .init_data = &vgen4_init},
+       {.id = PFUZE100_VGEN5,  .init_data = &vgen5_init},
+       {.id = PFUZE100_VGEN6,  .init_data = &vgen6_init},
+};
+
+static struct pfuze_platform_data pfuze100_plat = {
+       .flags = PFUZE_USE_REGULATOR,
+       .num_regulators = ARRAY_SIZE(mx6q_sabreauto_pfuze100_regulators),
+       .regulators = mx6q_sabreauto_pfuze100_regulators,
+       .pfuze_init = pfuze100_init,
+};
+
+static struct i2c_board_info __initdata pfuze100_i2c_device = {
+       I2C_BOARD_INFO(PFUZE100_I2C_DEVICE_NAME, PFUZE100_I2C_ADDR),
+       .platform_data = &pfuze100_plat,
+};
+
+int __init mx6sl_arm2_init_pfuze100(u32 int_gpio)
+{
+       if (int_gpio)
+               pfuze100_i2c_device.irq = gpio_to_irq(int_gpio); /*update INT gpio */
+       return i2c_register_board_info(0, &pfuze100_i2c_device, 1);
+}