[arm] tegra: cardhu: Adding gpio power rails and supplies.
Laxman Dewangan [Mon, 24 Jan 2011 11:59:38 +0000 (16:59 +0530)]
Adding gpio controlled power rails and their consumers.
Also adding the details of gpio to control the rails
through gpios.

Original-Change-Id: I6f203978fc0c4c2a761132bc0074513cc2a34000
Reviewed-on: http://git-master/r/16728
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Original-Change-Id: Ifcbcd03fb4994e9b30a60cb272564bc3bb81b159

Rebase-Id: R1333066d9238b898335d3c625f7164af57837e73

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

index 3571e6f..1e47d53 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/gpio.h>
 #include <mach/suspend.h>
 #include <linux/io.h>
+#include <linux/gpio-switch-regulator.h>
 
 #include <mach/iomap.h>
 #include <mach/irqs.h>
@@ -52,9 +53,12 @@ static struct regulator_consumer_supply tps6591x_vdd2_supply[] = {
 
 static struct regulator_consumer_supply tps6591x_vddctrl_supply[] = {
        REGULATOR_SUPPLY("vdd_cpu_pmu", NULL),
+       REGULATOR_SUPPLY("vdd_cpu", NULL),
+       REGULATOR_SUPPLY("vdd_sys", NULL),
 };
 
 static struct regulator_consumer_supply tps6591x_vio_supply[] = {
+       REGULATOR_SUPPLY("vdd_gen1v8", NULL),
        REGULATOR_SUPPLY("avdd_hdmi_pll", NULL),
        REGULATOR_SUPPLY("avdd_usb_pll", NULL),
        REGULATOR_SUPPLY("avdd_osc", NULL),
@@ -228,6 +232,245 @@ int __init cardhu_regulator_init(void)
 }
 #endif
 
+#ifdef CONFIG_REGULATOR_GPIO_SWITCH
+
+/* EN_5V_CP from PMU GP0 */
+static struct regulator_consumer_supply gpio_switch_en_5v_cp_supply[] = {
+       REGULATOR_SUPPLY("vdd_5v0_sby", NULL),
+       REGULATOR_SUPPLY("vdd_hall", NULL),
+       REGULATOR_SUPPLY("vterm_ddr", NULL),
+       REGULATOR_SUPPLY("v2ref_ddr", NULL),
+};
+static int gpio_switch_en_5v_cp_voltages[] = { 5000};
+
+/* EN_5V0 From PMU GP2 */
+static struct regulator_consumer_supply gpio_switch_en_5v0_supply[] = {
+       REGULATOR_SUPPLY("vdd_5v0_sys", NULL),
+};
+static int gpio_switch_en_5v0_voltages[] = { 5000};
+
+/* EN_DDR From PMU GP6 */
+static struct regulator_consumer_supply gpio_switch_en_ddr_supply[] = {
+       REGULATOR_SUPPLY("mem_vddio_ddr", NULL),
+       REGULATOR_SUPPLY("t30_vddio_ddr", NULL),
+};
+static int gpio_switch_en_ddr_voltages[] = { 1500};
+
+/* EN_3V3_SYS From PMU GP7 */
+static struct regulator_consumer_supply gpio_switch_en_3v3_sys_supply[] = {
+       REGULATOR_SUPPLY("vdd_lvds", NULL),
+       REGULATOR_SUPPLY("vdd_pnl", NULL),
+       REGULATOR_SUPPLY("vcom_3v3", NULL),
+       REGULATOR_SUPPLY("vdd_3v3", NULL),
+       REGULATOR_SUPPLY("vcore_mmc", NULL),
+       REGULATOR_SUPPLY("vddo_pex_ctl", NULL),
+       REGULATOR_SUPPLY("hvdd_pex", NULL),
+       REGULATOR_SUPPLY("avdd_hdmi", NULL),
+       REGULATOR_SUPPLY("vpp_fuse", NULL),
+       REGULATOR_SUPPLY("avdd_usb", NULL),
+       REGULATOR_SUPPLY("vdd_ddr_rx", NULL),
+       REGULATOR_SUPPLY("vcore_nand", NULL),
+       REGULATOR_SUPPLY("hvdd_sata", NULL),
+       REGULATOR_SUPPLY("vddio_gmi_pmu", NULL),
+       REGULATOR_SUPPLY("avdd_cam1", NULL),
+       REGULATOR_SUPPLY("vdd_af", NULL),
+       REGULATOR_SUPPLY("avdd_cam2", NULL),
+       REGULATOR_SUPPLY("vdd_acc", NULL),
+       REGULATOR_SUPPLY("vdd_phtl", NULL),
+       REGULATOR_SUPPLY("vddio_tp", NULL),
+       REGULATOR_SUPPLY("vdd_led", NULL),
+       REGULATOR_SUPPLY("vddio_cec", NULL),
+       REGULATOR_SUPPLY("vdd_cmps", NULL),
+       REGULATOR_SUPPLY("vdd_temp", NULL),
+       REGULATOR_SUPPLY("vpp_kfuse", NULL),
+       REGULATOR_SUPPLY("vddio_ts", NULL),
+       REGULATOR_SUPPLY("vdd_ir_led", NULL),
+       REGULATOR_SUPPLY("vddio_1wire", NULL),
+       REGULATOR_SUPPLY("avddio_audio", NULL),
+       REGULATOR_SUPPLY("vdd_ec", NULL),
+       REGULATOR_SUPPLY("vcom_pa", NULL),
+       REGULATOR_SUPPLY("vdd_3v3_devices", NULL),
+       REGULATOR_SUPPLY("vdd_3v3_dock", NULL),
+       REGULATOR_SUPPLY("debug_cons", NULL),
+};
+static int gpio_switch_en_3v3_sys_voltages[] = { 3300};
+
+/* 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),
+};
+static int gpio_switch_en_vdd_bl_voltages[] = { 5000};
+
+/* EN_3V3_MODEM from AP GPIO VI_VSYNCH D06*/
+static struct regulator_consumer_supply gpio_switch_en_3v3_modem_supply[] = {
+       REGULATOR_SUPPLY("vdd_3v3_mini_card", NULL),
+       REGULATOR_SUPPLY("vdd_mini_card", NULL),
+};
+static int gpio_switch_en_3v3_modem_voltages[] = { 3300};
+
+/* EN_USB1_VBUS_OC from AP GPIO GMI_RST J06*/
+static struct regulator_consumer_supply gpio_switch_en_usb1_vbus_oc_supply[] = {
+       REGULATOR_SUPPLY("vdd_vbus_micro_usb", NULL),
+};
+static int gpio_switch_en_usb1_vbus_oc_voltages[] = { 5000};
+
+/*EN_USB3_VBUS_OC from AP GPIO GMI_AD15 H07*/
+static struct regulator_consumer_supply gpio_switch_en_usb3_vbus_oc_supply[] = {
+       REGULATOR_SUPPLY("vdd_vbus_typea_usb", NULL),
+};
+static int gpio_switch_en_usb3_vbus_oc_voltages[] = { 5000};
+
+/* EN_VDDIO_VID_OC from AP GPIO VI_PCLK T00*/
+static struct regulator_consumer_supply gpio_switch_en_vddio_vid_oc_supply[] = {
+       REGULATOR_SUPPLY("vdd_hdmi_con", NULL),
+};
+static int gpio_switch_en_vddio_vid_oc_voltages[] = { 5000};
+
+/* EN_VDD_PNL1 from AP GPIO VI_D6 L04*/
+static struct regulator_consumer_supply gpio_switch_en_vdd_pnl1_supply[] = {
+       REGULATOR_SUPPLY("vdd_lcd_panel", NULL),
+};
+static int gpio_switch_en_vdd_pnl1_voltages[] = { 3300};
+
+/* CAM3_LDO_EN from AP GPIO KB_ROW8 R00*/
+static struct regulator_consumer_supply gpio_switch_cam3_ldo_en_supply[] = {
+       REGULATOR_SUPPLY("vdd_cam3", NULL),
+};
+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),
+};
+static int gpio_switch_en_vdd_com_voltages[] = { 3300};
+
+/* EN_VDD_SDMMC1 from AP GPIO VI_HSYNC D07*/
+static struct regulator_consumer_supply gpio_switch_en_vdd_sdmmc1_supply[] = {
+       REGULATOR_SUPPLY("vddio_sd_slot", NULL),
+};
+static int gpio_switch_en_vdd_sdmmc1_voltages[] = { 3300};
+
+/* EN_3V3_EMMC from AP GPIO SDMMC4_DAT4 D01*/
+static struct regulator_consumer_supply gpio_switch_en_3v3_emmc_supply[] = {
+       REGULATOR_SUPPLY("vdd_emmc_core", NULL),
+};
+static int gpio_switch_en_3v3_emmc_voltages[] = { 3300};
+
+/* EN_3V3_PEX_HVDD from AP GPIO VI_D09 L07*/
+static struct regulator_consumer_supply gpio_switch_en_3v3_pex_hvdd_supply[] = {
+       REGULATOR_SUPPLY("hvdd_pex_3v3", NULL),
+};
+static int gpio_switch_en_3v3_pex_hvdd_voltages[] = { 3300};
+
+/* EN_3v3_FUSE from AP GPIO VI_D08 L06*/
+static struct regulator_consumer_supply gpio_switch_en_3v3_fuse_supply[] = {
+       REGULATOR_SUPPLY("vpp_fuse_pg", NULL),
+};
+static int gpio_switch_en_3v3_fuse_voltages[] = { 3300};
+
+/* EN_1V8_CAM from AP GPIO GPIO_PBB4 PBB04*/
+static struct regulator_consumer_supply gpio_switch_en_1v8_cam_supply[] = {
+       REGULATOR_SUPPLY("vdd_1v8_cam1", NULL),
+       REGULATOR_SUPPLY("vdd_1v8_cam2", NULL),
+       REGULATOR_SUPPLY("vdd_1v8_cam3", NULL),
+};
+static int gpio_switch_en_1v8_cam_voltages[] = { 1800};
+
+/* Macro for defining gpio switch regulator platform data and device */
+#define GPIO_REGULATOR_PINIT(_id, _name, _input_supply, _gpio_nr, _active_low) \
+       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,                             \
+               .active_low     = _active_low,                          \
+               .voltages       = gpio_switch_##_name##_voltages,       \
+               .n_voltages     = ARRAY_SIZE(gpio_switch_##_name##_voltages), \
+               .num_consumer_supplies =                                \
+                               ARRAY_SIZE(gpio_switch_##_name##_supply), \
+               .consumer_supplies = gpio_switch_##_name##_supply,      \
+               .constraints = {                                        \
+                       .valid_modes_mask = (REGULATOR_MODE_NORMAL |    \
+                                            REGULATOR_MODE_STANDBY),   \
+                       .valid_ops_mask = (REGULATOR_CHANGE_MODE |      \
+                                          REGULATOR_CHANGE_STATUS |    \
+                                          REGULATOR_CHANGE_VOLTAGE),   \
+               },                                                      \
+       };                                                              \
+                                                                       \
+       static struct platform_device gpio_switch_regulator_##_name = { \
+               .name = "gpio-switch-regulator",                        \
+               .id   = _id,                                            \
+               .dev  = {                                               \
+                    .platform_data = &gpio_switch_regulator_##_name##_pdata,\
+               },                                                      \
+       };
+
+/* Gpio switch regulator platform data */
+GPIO_REGULATOR_PINIT(0, en_5v_cp,   NULL, TPS6591X_GPIO_GP0, false)
+GPIO_REGULATOR_PINIT(1, en_5v0,     NULL, TPS6591X_GPIO_GP2, false)
+GPIO_REGULATOR_PINIT(2, en_ddr,     NULL, TPS6591X_GPIO_GP6, false)
+GPIO_REGULATOR_PINIT(3, en_3v3_sys, NULL, TPS6591X_GPIO_GP7, false)
+
+GPIO_REGULATOR_PINIT(4, en_vdd_bl,       NULL,          TEGRA_GPIO_PK3, false)
+GPIO_REGULATOR_PINIT(5, en_3v3_modem,    NULL,          TEGRA_GPIO_PD6, false)
+GPIO_REGULATOR_PINIT(6, en_usb1_vbus_oc, "vdd_5v0_sys", TEGRA_GPIO_PJ6, false)
+GPIO_REGULATOR_PINIT(7, en_usb3_vbus_oc, "vdd_5v0_sys", TEGRA_GPIO_PH7, false)
+GPIO_REGULATOR_PINIT(8, en_vddio_vid_oc, "vdd_5v0_sys", TEGRA_GPIO_PT0, false)
+
+GPIO_REGULATOR_PINIT(9, en_vdd_pnl1, "vdd_3v3_devices", TEGRA_GPIO_PL4, false)
+GPIO_REGULATOR_PINIT(10, cam3_ldo_en, "vdd_3v3_devices", TEGRA_GPIO_PR0, false)
+GPIO_REGULATOR_PINIT(11, en_vdd_com,  "vdd_3v3_devices", TEGRA_GPIO_PD0, false)
+GPIO_REGULATOR_PINIT(12, en_3v3_fuse, "vdd_3v3_devices", TEGRA_GPIO_PL6, false)
+GPIO_REGULATOR_PINIT(13, en_3v3_emmc, "vdd_3v3_devices", TEGRA_GPIO_PD1, false)
+GPIO_REGULATOR_PINIT(14, en_vdd_sdmmc1, "vdd_3v3_devices", TEGRA_GPIO_PD7, false)
+GPIO_REGULATOR_PINIT(15, en_3v3_pex_hvdd, "vdd_3v3_devices",
+                                                       TEGRA_GPIO_PL7, false)
+
+GPIO_REGULATOR_PINIT(16, en_1v8_cam,  "vdd_gen1v8", TEGRA_GPIO_PBB4, false)
+
+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_en_vdd_bl,
+       &gpio_switch_regulator_en_3v3_modem,
+       &gpio_switch_regulator_en_usb1_vbus_oc,
+       &gpio_switch_regulator_en_usb3_vbus_oc,
+       &gpio_switch_regulator_en_vddio_vid_oc,
+       &gpio_switch_regulator_en_vdd_pnl1,
+       &gpio_switch_regulator_cam3_ldo_en,
+       &gpio_switch_regulator_en_vdd_com,
+       &gpio_switch_regulator_en_3v3_fuse,
+       &gpio_switch_regulator_en_3v3_emmc,
+       &gpio_switch_regulator_en_vdd_sdmmc1,
+       &gpio_switch_regulator_en_3v3_pex_hvdd,
+       &gpio_switch_regulator_en_1v8_cam,
+};
+
+int __init cardhu_gpio_switch_regulator_init(void)
+{
+       int i;
+       struct gpio_switch_regulator_platform_data *pdata;
+       for (i = 0; i < ARRAY_SIZE(gpio_switch_regulator_devices); ++i) {
+               pdata = gpio_switch_regulator_devices[i]->dev.platform_data;
+               if (pdata->gpio_nr <= TEGRA_NR_GPIOS)
+                       tegra_gpio_enable(pdata->gpio_nr);
+       }
+
+       platform_add_devices(gpio_switch_regulator_devices,
+                               ARRAY_SIZE(gpio_switch_regulator_devices));
+       return 0;
+}
+#else
+int __init cardhu_gpio_switch_regulator_init(void)
+{
+       return 0;
+}
+#endif
+
 static struct tegra_suspend_platform_data cardhu_suspend_data = {
        .cpu_timer      = 2000,
        .cpu_off_timer  = 0,
@@ -247,4 +490,5 @@ int __init cardhu_suspend_init(void)
 {
        tegra_init_suspend(&cardhu_suspend_data);
        return 0;
+
 }
index e01372f..65daaa2 100644 (file)
@@ -365,6 +365,7 @@ static void __init tegra_cardhu_init(void)
        cardhu_sdhci_init();
        cardhu_i2c_init();
        cardhu_regulator_init();
+       cardhu_gpio_switch_regulator_init();
        cardhu_suspend_init();
        cardhu_touch_init();
 #if ENABLE_USB_HOST
index 8410751..d1c752d 100644 (file)
 #include <mach/gpio.h>
 
 #define TPS6591X_GPIO_BASE     TEGRA_NR_GPIOS
+#define TPS6591X_GPIO_GP0      (TPS6591X_GPIO_BASE + 0)
+#define TPS6591X_GPIO_GP1      (TPS6591X_GPIO_BASE + 1)
+#define TPS6591X_GPIO_GP2      (TPS6591X_GPIO_BASE + 2)
+#define TPS6591X_GPIO_GP3      (TPS6591X_GPIO_BASE + 3)
+#define TPS6591X_GPIO_GP4      (TPS6591X_GPIO_BASE + 4)
+#define TPS6591X_GPIO_GP5      (TPS6591X_GPIO_BASE + 5)
+#define TPS6591X_GPIO_GP6      (TPS6591X_GPIO_BASE + 6)
+#define TPS6591X_GPIO_GP7      (TPS6591X_GPIO_BASE + 7)
+#define TPS6591X_GPIO_GP8      (TPS6591X_GPIO_BASE + 8)
 
 /* PCA954x I2C bus expander bus addresses */
 #define PCA954x_I2C_BUS_BASE   6
@@ -42,5 +51,6 @@ int cardhu_sensors_init(void);
 int cardhu_kbc_init(void);
 int cardhu_scroll_init(void);
 int cardhu_keys_init(void);
+int cardhu_gpio_switch_regulator_init(void);
 
 #endif