diff options
author | Pritesh Raithatha <praithatha@nvidia.com> | 2012-03-13 17:17:46 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2012-03-14 16:39:19 -0700 |
commit | d0c816598ec8863297826f07a6b38b9d62f89e9c (patch) | |
tree | f599f45c74d7347a5f78ce19d67db665e527dd1b /arch | |
parent | ae63d1dc308dd20fc42c402185796c7d7d883cfc (diff) |
arm: tegra: ventana: use fixed regulator instead of direct gpio
Bug 925547
Change-Id: I81f87cef3a9767d9bd60b72e33a23620392ab5fc
Signed-off-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-on: http://git-master/r/89736
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-tegra/board-ventana-panel.c | 21 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-ventana-power.c | 69 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-ventana-sensors.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-ventana.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board.h | 32 |
5 files changed, 83 insertions, 46 deletions
diff --git a/arch/arm/mach-tegra/board-ventana-panel.c b/arch/arm/mach-tegra/board-ventana-panel.c index cad303de3db5..4cacd3dc4216 100644 --- a/arch/arm/mach-tegra/board-ventana-panel.c +++ b/arch/arm/mach-tegra/board-ventana-panel.c @@ -37,7 +37,6 @@ #include "gpio-names.h" #include "board.h" -#define ventana_pnl_pwr_enb TEGRA_GPIO_PC6 #define ventana_bl_enb TEGRA_GPIO_PD4 #define ventana_lvds_shutdown TEGRA_GPIO_PB2 #define ventana_hdmi_hpd TEGRA_GPIO_PN7 @@ -47,6 +46,8 @@ #define ventana_pnl_to_lvds_ms 0 #define ventana_lvds_to_bl_ms 200 +static struct regulator *pnl_pwr; + #ifdef CONFIG_TEGRA_DC static struct regulator *ventana_hdmi_reg = NULL; static struct regulator *ventana_hdmi_pll = NULL; @@ -112,7 +113,17 @@ static int ventana_panel_enable(void) regulator_put(reg); } - gpio_set_value(ventana_pnl_pwr_enb, 1); + if (pnl_pwr == NULL) { + pnl_pwr = regulator_get(NULL, "pnl_pwr"); + if (WARN_ON(IS_ERR(pnl_pwr))) + pr_err("%s: couldn't get regulator pnl_pwr: %ld\n", + __func__, PTR_ERR(pnl_pwr)); + else + regulator_enable(pnl_pwr); + } else { + regulator_enable(pnl_pwr); + } + mdelay(ventana_pnl_to_lvds_ms); gpio_set_value(ventana_lvds_shutdown, 1); mdelay(ventana_lvds_to_bl_ms); @@ -122,7 +133,7 @@ static int ventana_panel_enable(void) static int ventana_panel_disable(void) { gpio_set_value(ventana_lvds_shutdown, 0); - gpio_set_value(ventana_pnl_pwr_enb, 0); + regulator_disable(pnl_pwr); return 0; } @@ -384,10 +395,6 @@ int __init ventana_panel_init(void) int err; struct resource __maybe_unused *res; - gpio_request(ventana_pnl_pwr_enb, "pnl_pwr_enb"); - gpio_direction_output(ventana_pnl_pwr_enb, 1); - tegra_gpio_enable(ventana_pnl_pwr_enb); - gpio_request(ventana_lvds_shutdown, "lvds_shdn"); gpio_direction_output(ventana_lvds_shutdown, 1); tegra_gpio_enable(ventana_lvds_shutdown); diff --git a/arch/arm/mach-tegra/board-ventana-power.c b/arch/arm/mach-tegra/board-ventana-power.c index 7cdafcb3c05a..a106a2026ebe 100644 --- a/arch/arm/mach-tegra/board-ventana-power.c +++ b/arch/arm/mach-tegra/board-ventana-power.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 NVIDIA, Inc. + * Copyright (C) 2010-2012 NVIDIA, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -242,6 +242,31 @@ static struct tegra_suspend_platform_data ventana_suspend_data = { .board_resume = ventana_board_resume, }; +static struct regulator_consumer_supply pnl_pwr_consumer_supply[] = { + REGULATOR_SUPPLY("pnl_pwr", NULL), +}; + +FIXED_VOLTAGE_REG_INIT(2, pnl_pwr, 2800000, PANEL_POWER_EN_GPIO, + 0, 1, 0, REGULATOR_CHANGE_STATUS, 0); + +static struct platform_device *fixed_voltage_regulators[] __initdata = { + ADD_FIXED_VOLTAGE_REG(pnl_pwr), +}; + +int __init ventana_fixed_voltage_regulator_init(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(fixed_voltage_regulators); ++i) { + struct fixed_voltage_config *fixed_voltage_regulators_pdata = + fixed_voltage_regulators[i]->dev.platform_data; + if (fixed_voltage_regulators_pdata->gpio < TEGRA_NR_GPIOS) + tegra_gpio_enable(fixed_voltage_regulators_pdata->gpio); + } + return platform_add_devices(fixed_voltage_regulators, + ARRAY_SIZE(fixed_voltage_regulators)); +} + int __init ventana_regulator_init(void) { void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); @@ -265,6 +290,8 @@ int __init ventana_regulator_init(void) tegra_init_suspend(&ventana_suspend_data); + ventana_fixed_voltage_regulator_init(); + return 0; } @@ -319,38 +346,6 @@ fail: return ret; } -#define ADD_FIXED_VOLTAGE_REG(_name) (&_name##_fixed_voltage_device) - -/* Macro for defining fixed voltage regulator */ -#define FIXED_VOLTAGE_REG_INIT(_id, _name, _microvolts, _gpio, \ - _startup_delay, _enable_high, _enabled_at_boot, \ - _valid_ops_mask, _always_on) \ - static struct regulator_init_data _name##_initdata = { \ - .consumer_supplies = _name##_consumer_supply, \ - .num_consumer_supplies = \ - ARRAY_SIZE(_name##_consumer_supply), \ - .constraints = { \ - .valid_ops_mask = _valid_ops_mask , \ - .always_on = _always_on, \ - }, \ - }; \ - static struct fixed_voltage_config _name##_config = { \ - .supply_name = #_name, \ - .microvolts = _microvolts, \ - .gpio = _gpio, \ - .startup_delay = _startup_delay, \ - .enable_high = _enable_high, \ - .enabled_at_boot = _enabled_at_boot, \ - .init_data = &_name##_initdata, \ - }; \ - static struct platform_device _name##_fixed_voltage_device = { \ - .name = "reg-fixed-voltage", \ - .id = _id, \ - .dev = { \ - .platform_data = &_name##_config, \ - }, \ - } - static struct regulator_consumer_supply cam1_2v8_consumer_supply[] = { REGULATOR_SUPPLY("cam1_2v8", NULL), }; @@ -364,15 +359,15 @@ FIXED_VOLTAGE_REG_INIT(0, cam1_2v8, 2800000, CAM1_LDO_SHUTDN_L_GPIO, FIXED_VOLTAGE_REG_INIT(1, cam2_2v8, 2800000, CAM2_LDO_SHUTDN_L_GPIO, 0, 1, 0, REGULATOR_CHANGE_STATUS, 0); -static struct platform_device *fixed_voltage_regulators[] __initdata = { +static struct platform_device *cam_fixed_voltage_regulators[] __initdata = { ADD_FIXED_VOLTAGE_REG(cam1_2v8), ADD_FIXED_VOLTAGE_REG(cam2_2v8), }; -int __init ventana_gpio_fixed_voltage_regulator_init(void) +int __init ventana_cam_fixed_voltage_regulator_init(void) { - return platform_add_devices(fixed_voltage_regulators, - ARRAY_SIZE(fixed_voltage_regulators)); + return platform_add_devices(cam_fixed_voltage_regulators, + ARRAY_SIZE(cam_fixed_voltage_regulators)); } late_initcall(ventana_pcie_init); diff --git a/arch/arm/mach-tegra/board-ventana-sensors.c b/arch/arm/mach-tegra/board-ventana-sensors.c index 6a5549cba56b..81184d54599d 100644 --- a/arch/arm/mach-tegra/board-ventana-sensors.c +++ b/arch/arm/mach-tegra/board-ventana-sensors.c @@ -528,7 +528,7 @@ int __init ventana_camera_late_init(void) gpio_export(ventana_camera_gpio_keys[i].gpio, false); } - ventana_gpio_fixed_voltage_regulator_init(); + ventana_cam_fixed_voltage_regulator_init(); cam1_2v8 = regulator_get(NULL, "cam1_2v8"); if (WARN_ON(IS_ERR(cam1_2v8))) { diff --git a/arch/arm/mach-tegra/board-ventana.h b/arch/arm/mach-tegra/board-ventana.h index 443556213975..b8d8040d187b 100644 --- a/arch/arm/mach-tegra/board-ventana.h +++ b/arch/arm/mach-tegra/board-ventana.h @@ -2,6 +2,7 @@ * arch/arm/mach-tegra/board-ventana.h * * Copyright (C) 2011 Google, Inc. + * Copyright (C) 2012 NVIDIA Corporation. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -26,7 +27,7 @@ int ventana_sensors_init(void); int ventana_kbc_init(void); int ventana_emc_init(void); int ventana_charger_init(void); -int ventana_gpio_fixed_voltage_regulator_init(void); +int ventana_cam_fixed_voltage_regulator_init(void); /* PCA954x I2C bus expander bus addresses */ #define PCA954x_I2C_BUS_BASE 6 @@ -43,6 +44,8 @@ int ventana_gpio_fixed_voltage_regulator_init(void); #define CAMERA_CSI_MUX_SEL_GPIO TEGRA_GPIO_PBB4 #define CAMERA_FLASH_ACT_GPIO TEGRA_GPIO_PD2 +#define PANEL_POWER_EN_GPIO TEGRA_GPIO_PC6 + /* TPS6586X gpios */ #define TPS6586X_GPIO_BASE TEGRA_NR_GPIOS #define TPS6586X_GPIO(_x_) (TPS6586X_GPIO_BASE + (_x_)) diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h index 4b1779ab0324..7a4f418eabb8 100644 --- a/arch/arm/mach-tegra/board.h +++ b/arch/arm/mach-tegra/board.h @@ -25,6 +25,38 @@ #include <linux/types.h> #include <linux/power_supply.h> +#define ADD_FIXED_VOLTAGE_REG(_name) (&_name##_fixed_voltage_device) + +/* Macro for defining fixed voltage regulator */ +#define FIXED_VOLTAGE_REG_INIT(_id, _name, _microvolts, _gpio, \ + _startup_delay, _enable_high, _enabled_at_boot, \ + _valid_ops_mask, _always_on) \ + static struct regulator_init_data _name##_initdata = { \ + .consumer_supplies = _name##_consumer_supply, \ + .num_consumer_supplies = \ + ARRAY_SIZE(_name##_consumer_supply), \ + .constraints = { \ + .valid_ops_mask = _valid_ops_mask , \ + .always_on = _always_on, \ + }, \ + }; \ + static struct fixed_voltage_config _name##_config = { \ + .supply_name = #_name, \ + .microvolts = _microvolts, \ + .gpio = _gpio, \ + .startup_delay = _startup_delay, \ + .enable_high = _enable_high, \ + .enabled_at_boot = _enabled_at_boot, \ + .init_data = &_name##_initdata, \ + }; \ + static struct platform_device _name##_fixed_voltage_device = { \ + .name = "reg-fixed-voltage", \ + .id = _id, \ + .dev = { \ + .platform_data = &_name##_config, \ + }, \ + } + #if defined(CONFIG_TEGRA_NVMAP) #define NVMAP_HEAP_CARVEOUT_IRAM_INIT \ { .name = "iram", \ |