arm: regulator: gpio_switch: enable/disable of rail through board apis
Laxman Dewangan [Mon, 31 Jan 2011 09:00:25 +0000 (14:00 +0530)]
Supporting the enabling/disabling of rail through board supplied
function. This is require if rail control is done through special
sequence.

Original-Change-Id: Iec7de658fe427a2098705a5363733887f87f6c1d
Reviewed-on: http://git-master/r/17658
Reviewed-by: Hanumanth Venkateswa Moganty <vmoganty@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Ramachandrudu Kandhala <rkandhala@nvidia.com>
Original-Change-Id: Ibe3d6e9e15e92a9ac5f381ac26666fb4f69635db

Rebase-Id: Ra380c6458cde054c770f565317fa9964c70a1718

arch/arm/mach-tegra/board-cardhu-pinmux.c
arch/arm/mach-tegra/board-cardhu-power.c

index a4aa2f7..a9858ed 100755 (executable)
@@ -142,12 +142,12 @@ static __initdata struct tegra_pingroup_config cardhu_pinmux[] = {
        DEFAULT_PINMUX(GEN2_I2C_SDA,    I2C2,            NORMAL,    NORMAL,     INPUT),
 
        /* I2C3 pinmux */
-       I2C_PINMUX(CAM_I2C_SCL,     I2C3,            PULL_UP,    NORMAL,     INPUT,     DISABLE,        DISABLE),
-       I2C_PINMUX(CAM_I2C_SDA,     I2C3,            PULL_UP,    NORMAL,     INPUT,     DISABLE,        DISABLE),
+       I2C_PINMUX(CAM_I2C_SCL,         I2C3,           PULL_UP,        NORMAL, INPUT,  DISABLE,        DISABLE),
+       I2C_PINMUX(CAM_I2C_SDA,         I2C3,           PULL_UP,        NORMAL, INPUT,  DISABLE,        DISABLE),
 
        /* I2C4 pinmux */
-       DEFAULT_PINMUX(DDC_SCL,         I2C4,            NORMAL,    NORMAL,     INPUT),
-       DEFAULT_PINMUX(DDC_SDA,         I2C4,            NORMAL,    NORMAL,     INPUT),
+       I2C_PINMUX(DDC_SCL,             I2C4,           PULL_UP,        NORMAL, INPUT,  DISABLE,        DISABLE),
+       I2C_PINMUX(DDC_SDA,             I2C4,           PULL_UP,        NORMAL, INPUT,  DISABLE,        DISABLE),
 
        /* Power I2C pinmux */
        DEFAULT_PINMUX(PWR_I2C_SCL,     I2CPWR,          NORMAL,    NORMAL,     INPUT),
@@ -327,7 +327,6 @@ static __initdata struct tegra_pingroup_config cardhu_pinmux[] = {
        DEFAULT_PINMUX(SPI2_MOSI,       SPI6,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SPI2_MISO,       SPI6,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SPI2_CS0_N,      SPI6,            NORMAL,    NORMAL,     INPUT),
-       DEFAULT_PINMUX(SPI2_SCK,        GMI,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SPI1_MOSI,       SPI1,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SPI1_SCK,        SPI1,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SPI1_CS0_N,      SPI1,            NORMAL,    NORMAL,     INPUT),
@@ -354,19 +353,20 @@ static __initdata struct tegra_pingroup_config cardhu_pinmux[] = {
 
 
        /* Power rails GPIO */
+       DEFAULT_PINMUX(SPI2_SCK,        GMI,             NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(GMI_CS2_N,       NAND,            NORMAL,    NORMAL,     OUTPUT),
-       DEFAULT_PINMUX(GMI_RST_N,       RSVD3,           NORMAL,    NORMAL,     INPUT),
-       DEFAULT_PINMUX(GMI_AD15,        NAND,            NORMAL,    NORMAL,     INPUT),
+       DEFAULT_PINMUX(GMI_RST_N,       RSVD3,           PULL_UP,   TRISTATE,   INPUT),
+       DEFAULT_PINMUX(GMI_AD15,        NAND,            PULL_UP,   TRISTATE,   INPUT),
        DEFAULT_PINMUX(GPIO_PBB4,       VGP4,            NORMAL,    NORMAL,     INPUT),
        DEFAULT_PINMUX(KB_ROW8,         KBC,             PULL_UP,   NORMAL,     INPUT),
        DEFAULT_PINMUX(SDMMC3_DAT5,     SDMMC3,          PULL_UP,    NORMAL,     INPUT),
        DEFAULT_PINMUX(SDMMC3_DAT4,     SDMMC3,          PULL_UP,    NORMAL,     INPUT),
        VI_PINMUX(VI_D6,           VI,              NORMAL,    NORMAL,     OUTPUT, DISABLE, DISABLE),
-       VI_PINMUX(VI_D8,           SDMMC2,          NORMAL,    NORMAL,     INPUT, DISABLE, DISABLE),
-       VI_PINMUX(VI_D9,           SDMMC2,          NORMAL,    NORMAL,     INPUT, DISABLE, DISABLE),
-       VI_PINMUX(VI_PCLK,         SDMMC2,          NORMAL,    NORMAL,     INPUT, DISABLE, DISABLE),
-       VI_PINMUX(VI_HSYNC,        RSVD1,           NORMAL,    NORMAL,     INPUT, DISABLE, DISABLE),
-       VI_PINMUX(VI_VSYNC,        RSVD1,           NORMAL,    NORMAL,     INPUT, DISABLE, DISABLE),
+       VI_PINMUX(VI_D8,           SDMMC2,          NORMAL,    NORMAL,     INPUT,  DISABLE, DISABLE),
+       VI_PINMUX(VI_D9,           SDMMC2,          NORMAL,    NORMAL,     INPUT,  DISABLE, DISABLE),
+       VI_PINMUX(VI_PCLK,         RSVD1,           PULL_UP,   TRISTATE,   INPUT,  DISABLE, ENABLE),
+       VI_PINMUX(VI_HSYNC,        RSVD1,           NORMAL,    NORMAL,     INPUT,  DISABLE, DISABLE),
+       VI_PINMUX(VI_VSYNC,        RSVD1,           NORMAL,    NORMAL,     INPUT,  DISABLE, DISABLE),
 };
 
 void __init cardhu_pinmux_init(void)
index bcd3a17..9a01634 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <mach/iomap.h>
 #include <mach/irqs.h>
+#include <mach/pinmux.h>
 
 #include "gpio-names.h"
 #include "board-cardhu.h"
@@ -295,6 +296,12 @@ static struct regulator_consumer_supply gpio_switch_en_3v3_sys_supply[] = {
 };
 static int gpio_switch_en_3v3_sys_voltages[] = { 3300};
 
+/* DIS_5V_SWITCH from AP SPI2_SCK X02 */
+static struct regulator_consumer_supply gpio_switch_dis_5v_switch_supply[] = {
+       REGULATOR_SUPPLY("master_5v_switch", NULL),
+};
+static int gpio_switch_dis_5v_switch_voltages[] = { 5000};
+
 /* EN_VDD_BL from AP GPIO GMI_CS2  K03 */
 static struct regulator_consumer_supply gpio_switch_en_vdd_bl_supply[] = {
        REGULATOR_SUPPLY("vdd_backlight", NULL),
@@ -340,7 +347,7 @@ static int gpio_switch_cam3_ldo_en_voltages[] = { 3300};
 
 /* EN_VDD_COM from AP GPIO SDMMC3_DAT5 D00*/
 static struct regulator_consumer_supply gpio_switch_en_vdd_com_supply[] = {
-       REGULATOR_SUPPLY("vdd_cwcom_bd", NULL),
+       REGULATOR_SUPPLY("vdd_com_bd", NULL),
 };
 static int gpio_switch_en_vdd_com_voltages[] = { 3300};
 
@@ -376,14 +383,45 @@ static struct regulator_consumer_supply gpio_switch_en_1v8_cam_supply[] = {
 };
 static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
 
+static int enable_load_switch_rail(
+               struct gpio_switch_regulator_platform_data *pdata)
+{
+       int ret;
+
+       if (pdata->pin_group <= 0)
+               return -EINVAL;
+
+       /* Tristate and make pin as input*/
+       ret = tegra_pinmux_set_tristate(pdata->pin_group, TEGRA_TRI_TRISTATE);
+       if (ret < 0)
+               return ret;
+       return gpio_direction_input(pdata->gpio_nr);
+}
+
+static int disable_load_switch_rail(
+               struct gpio_switch_regulator_platform_data *pdata)
+{
+       int ret;
+
+       if (pdata->pin_group <= 0)
+               return -EINVAL;
+
+       /* Un-tristate and driver low */
+       ret = tegra_pinmux_set_tristate(pdata->pin_group, TEGRA_TRI_NORMAL);
+       if (ret < 0)
+               return ret;
+       return gpio_direction_output(pdata->gpio_nr, 0);
+}
+
 /* Macro for defining gpio switch regulator platform data and device */
-#define GPIO_REGULATOR_PINIT(_id, _name, _input_supply, _gpio_nr, _active_low, _init_state) \
+#define GPIO_REGULATOR_PINIT(_id, _name, _input_supply, _gpio_nr, _active_low, _init_state, _pg, _enable, _disable) \
        static struct gpio_switch_regulator_platform_data               \
                                gpio_switch_regulator_##_name##_pdata = { \
                .regulator_name = "gpio-switch-"#_name,                 \
                .input_supply   = _input_supply,                        \
                .id             = _id,                                  \
                .gpio_nr        = _gpio_nr,                             \
+               .pin_group      = _pg,                                  \
                .active_low     = _active_low,                          \
                .init_state     = _init_state,                          \
                .voltages       = gpio_switch_##_name##_voltages,       \
@@ -398,6 +436,8 @@ static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
                                           REGULATOR_CHANGE_STATUS |    \
                                           REGULATOR_CHANGE_VOLTAGE),   \
                },                                                      \
+               .enable_rail = _enable,                                 \
+               .disable_rail = _disable,                               \
        };                                                              \
                                                                        \
        static struct platform_device gpio_switch_regulator_##_name = { \
@@ -409,33 +449,51 @@ static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
        };
 
 /* Gpio switch regulator platform data */
-GPIO_REGULATOR_PINIT(0, en_5v_cp,   NULL, TPS6591X_GPIO_GP0, false, 0)
-GPIO_REGULATOR_PINIT(1, en_5v0,     NULL, TPS6591X_GPIO_GP2, false, 0)
-GPIO_REGULATOR_PINIT(2, en_ddr,     NULL, TPS6591X_GPIO_GP6, false, 0)
-GPIO_REGULATOR_PINIT(3, en_3v3_sys, NULL, TPS6591X_GPIO_GP7, false, 0)
-
-GPIO_REGULATOR_PINIT(4, en_vdd_bl,       NULL,          TEGRA_GPIO_PK3, false, 1)
-GPIO_REGULATOR_PINIT(5, en_3v3_modem,    NULL,          TEGRA_GPIO_PD6, false, 0)
-GPIO_REGULATOR_PINIT(6, en_usb1_vbus_oc, "vdd_5v0_sys", TEGRA_GPIO_PI4, false, 0)
-GPIO_REGULATOR_PINIT(7, en_usb3_vbus_oc, "vdd_5v0_sys", TEGRA_GPIO_PH7, false, 0)
-GPIO_REGULATOR_PINIT(8, en_vddio_vid_oc, "vdd_5v0_sys", TEGRA_GPIO_PT0, false, 0)
-
-GPIO_REGULATOR_PINIT(9, en_vdd_pnl1, "vdd_3v3_devices", TEGRA_GPIO_PL4, false, 1)
-GPIO_REGULATOR_PINIT(10, cam3_ldo_en, "vdd_3v3_devices", TEGRA_GPIO_PS0, false, 0)
-GPIO_REGULATOR_PINIT(11, en_vdd_com,  "vdd_3v3_devices", TEGRA_GPIO_PD0, false, 0)
-GPIO_REGULATOR_PINIT(12, en_3v3_fuse, "vdd_3v3_devices", TEGRA_GPIO_PL6, false, 0)
-GPIO_REGULATOR_PINIT(13, en_3v3_emmc, "vdd_3v3_devices", TEGRA_GPIO_PD1, false, 1)
-GPIO_REGULATOR_PINIT(14, en_vdd_sdmmc1, "vdd_3v3_devices", TEGRA_GPIO_PD7, false, 1)
-GPIO_REGULATOR_PINIT(15, en_3v3_pex_hvdd, "vdd_3v3_devices",
-                                                       TEGRA_GPIO_PL7, false, 0)
-
-GPIO_REGULATOR_PINIT(16, en_1v8_cam,  "vdd_gen1v8", TEGRA_GPIO_PBB4, false, 0)
+GPIO_REGULATOR_PINIT(0, en_5v_cp,   NULL, TPS6591X_GPIO_GP0, false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(1, en_5v0,     NULL, TPS6591X_GPIO_GP2, false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(2, en_ddr,     NULL, TPS6591X_GPIO_GP6, false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(3, en_3v3_sys, NULL, TPS6591X_GPIO_GP7, false, 0, 0, 0, 0)
+
+GPIO_REGULATOR_PINIT(4, dis_5v_switch,   "vdd_5v0_sys", TEGRA_GPIO_PX2,
+                       true, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(5, en_vdd_bl,       NULL,          TEGRA_GPIO_PK3,
+                       false, 1, 0, 0, 0)
+GPIO_REGULATOR_PINIT(6, en_3v3_modem,    NULL,          TEGRA_GPIO_PD6,
+                       false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(7, en_usb1_vbus_oc, "master_5v_switch", TEGRA_GPIO_PI4,
+                       false, 0, TEGRA_PINGROUP_GMI_RST_N,
+                       enable_load_switch_rail, disable_load_switch_rail)
+GPIO_REGULATOR_PINIT(8, en_usb3_vbus_oc, "master_5v_switch", TEGRA_GPIO_PH7,
+                       false, 0, TEGRA_PINGROUP_GMI_AD15,
+                       enable_load_switch_rail, disable_load_switch_rail)
+GPIO_REGULATOR_PINIT(9, en_vddio_vid_oc, "master_5v_switch", TEGRA_GPIO_PT0,
+                       false, 0, TEGRA_PINGROUP_VI_PCLK,
+                       enable_load_switch_rail, disable_load_switch_rail)
+
+GPIO_REGULATOR_PINIT(10, en_vdd_pnl1, "vdd_3v3_devices", TEGRA_GPIO_PL4,
+                       false, 1, 0, 0, 0)
+GPIO_REGULATOR_PINIT(11, cam3_ldo_en, "vdd_3v3_devices", TEGRA_GPIO_PS0,
+                       false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(12, en_vdd_com,  "vdd_3v3_devices", TEGRA_GPIO_PD0,
+                       false, 1, 0, 0, 0)
+GPIO_REGULATOR_PINIT(13, en_3v3_fuse, "vdd_3v3_devices", TEGRA_GPIO_PL6,
+                       false, 0, 0, 0, 0)
+GPIO_REGULATOR_PINIT(14, en_3v3_emmc, "vdd_3v3_devices", TEGRA_GPIO_PD1,
+                       false, 1, 0, 0, 0)
+GPIO_REGULATOR_PINIT(15, en_vdd_sdmmc1, "vdd_3v3_devices", TEGRA_GPIO_PD7,
+                       false, 1, 0, 0, 0)
+GPIO_REGULATOR_PINIT(16, en_3v3_pex_hvdd, "vdd_3v3_devices", TEGRA_GPIO_PL7,
+                       false, 0, 0, 0, 0)
+
+GPIO_REGULATOR_PINIT(17, en_1v8_cam,  "vdd_gen1v8", TEGRA_GPIO_PBB4,
+                       false, 0, 0, 0, 0)
 
 static struct platform_device *gpio_switch_regulator_devices[] __initdata = {
        &gpio_switch_regulator_en_5v_cp,
        &gpio_switch_regulator_en_5v0,
        &gpio_switch_regulator_en_ddr,
        &gpio_switch_regulator_en_3v3_sys,
+       &gpio_switch_regulator_dis_5v_switch,
        &gpio_switch_regulator_en_vdd_bl,
        &gpio_switch_regulator_en_3v3_modem,
        &gpio_switch_regulator_en_usb1_vbus_oc,