msm: Port 7x30 vreg.c consumers to regulator API
Converts all users of vreg.c on 7x30 to use the regulator API.
vreg.c should now be considered DEPRECATED on 7x30.
Change-Id: Iae2a7e25810d17194bf231d9942378668a3ecb2e
Signed-off-by: Justin Paupore <jpaupore@codeaurora.org>
Signed-off-by: Pankaj Kumar <pakuma@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index eda29cd..d73f612 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -37,6 +37,7 @@
#include <linux/input/cy8c_ts.h>
#include <linux/msm_adc.h>
#include <linux/dma-mapping.h>
+#include <linux/regulator/consumer.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -331,56 +332,43 @@
};
static struct kobject *properties_kobj;
+static struct regulator_bulk_data cyttsp_regs[] = {
+ { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
+};
#define CYTTSP_TS_GPIO_IRQ 150
static int cyttsp_platform_init(struct i2c_client *client)
{
int rc = -EINVAL;
- struct vreg *vreg_ldo8, *vreg_ldo15;
- vreg_ldo8 = vreg_get(NULL, "gp7");
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
- if (!vreg_ldo8) {
- pr_err("%s: VREG L8 get failed\n", __func__);
- return rc;
- }
-
- rc = vreg_set_level(vreg_ldo8, 1800);
if (rc) {
- pr_err("%s: VREG L8 set failed\n", __func__);
- goto l8_put;
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto out;
}
- rc = vreg_enable(vreg_ldo8);
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
+
if (rc) {
- pr_err("%s: VREG L8 enable failed\n", __func__);
- goto l8_put;
+ pr_err("%s: could not set regulator voltages: %d\n", __func__,
+ rc);
+ goto regs_free;
}
- vreg_ldo15 = vreg_get(NULL, "gp6");
+ rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
- if (!vreg_ldo15) {
- pr_err("%s: VREG L15 get failed\n", __func__);
- goto l8_disable;
- }
-
- rc = vreg_set_level(vreg_ldo15, 3050);
if (rc) {
- pr_err("%s: VREG L15 set failed\n", __func__);
- goto l8_disable;
- }
-
- rc = vreg_enable(vreg_ldo15);
- if (rc) {
- pr_err("%s: VREG L15 enable failed\n", __func__);
- goto l8_disable;
+ pr_err("%s: could not enable regulators: %d\n", __func__, rc);
+ goto regs_free;
}
/* check this device active by reading first byte/register */
rc = i2c_smbus_read_byte_data(client, 0x01);
if (rc < 0) {
pr_err("%s: i2c sanity check failed\n", __func__);
- goto l8_disable;
+ goto regs_disable;
}
rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
@@ -388,7 +376,7 @@
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, CYTTSP_TS_GPIO_IRQ);
- goto l8_disable;
+ goto regs_disable;
}
/* virtual keys */
@@ -404,10 +392,11 @@
return CY_OK;
-l8_disable:
- vreg_disable(vreg_ldo8);
-l8_put:
- vreg_put(vreg_ldo8);
+regs_disable:
+ regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
+regs_free:
+ regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
+out:
return rc;
}
@@ -1371,58 +1360,54 @@
pr_info("%s: power off amplifier\n", __func__);
}
-static struct vreg *snddev_vreg_ncp, *snddev_vreg_gp4;
+static struct regulator_bulk_data snddev_regs[] = {
+ { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
+ { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
+};
-void msm_snddev_hsed_voltage_on(void)
+static int __init snddev_hsed_voltage_init(void)
{
int rc;
- snddev_vreg_gp4 = vreg_get(NULL, "gp4");
- if (IS_ERR(snddev_vreg_gp4)) {
- pr_err("%s: vreg_get(%s) failed (%ld)\n",
- __func__, "gp4", PTR_ERR(snddev_vreg_gp4));
- return;
- }
- rc = vreg_enable(snddev_vreg_gp4);
- if (rc)
- pr_err("%s: vreg_enable(gp4) failed (%d)\n", __func__, rc);
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
- snddev_vreg_ncp = vreg_get(NULL, "ncp");
- if (IS_ERR(snddev_vreg_ncp)) {
- pr_err("%s: vreg_get(%s) failed (%ld)\n",
- __func__, "ncp", PTR_ERR(snddev_vreg_ncp));
- return;
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto out;
}
- rc = vreg_enable(snddev_vreg_ncp);
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
+
+ if (rc) {
+ pr_err("%s: could not set regulator voltages: %d\n",
+ __func__, rc);
+ goto regs_free;
+ }
+
+ return 0;
+
+regs_free:
+ regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
+out:
+ return rc;
+}
+
+
+void msm_snddev_hsed_voltage_on(void)
+{
+ int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
+
if (rc)
- pr_err("%s: vreg_enable(ncp) failed (%d)\n", __func__, rc);
+ pr_err("%s: could not enable regulators: %d\n", __func__, rc);
}
void msm_snddev_hsed_voltage_off(void)
{
- int rc;
+ int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
- if (IS_ERR(snddev_vreg_ncp)) {
- pr_err("%s: vreg_get(%s) failed (%ld)\n",
- __func__, "ncp", PTR_ERR(snddev_vreg_ncp));
- return;
+ if (rc) {
+ pr_err("%s: could not disable regulators: %d\n", __func__, rc);
}
- rc = vreg_disable(snddev_vreg_ncp);
- if (rc)
- pr_err("%s: vreg_disable(ncp) failed (%d)\n", __func__, rc);
- vreg_put(snddev_vreg_ncp);
-
- if (IS_ERR(snddev_vreg_gp4)) {
- pr_err("%s: vreg_get(%s) failed (%ld)\n",
- __func__, "gp4", PTR_ERR(snddev_vreg_gp4));
- return;
- }
- rc = vreg_disable(snddev_vreg_gp4);
- if (rc)
- pr_err("%s: vreg_disable(gp4) failed (%d)\n", __func__, rc);
-
- vreg_put(snddev_vreg_gp4);
-
}
static unsigned aux_pcm_gpio_on[] = {
@@ -1605,10 +1590,9 @@
VER_UNSUPPORTED = 0xFF
};
-
-static struct vreg *vreg_marimba_1;
-static struct vreg *vreg_marimba_2;
-static struct vreg *vreg_marimba_3;
+static struct regulator *vreg_marimba_1;
+static struct regulator *vreg_marimba_2;
+static struct regulator *vreg_bahama;
static struct msm_gpio timpani_reset_gpio_cfg[] = {
{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
@@ -1666,34 +1650,33 @@
if (rc < 0)
goto out;
- rc = vreg_enable(vreg_marimba_1);
+ rc = regulator_enable(vreg_marimba_1);
if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d\n",
- __func__, rc);
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
goto out;
}
- rc = vreg_enable(vreg_marimba_2);
+
+ rc = regulator_enable(vreg_marimba_2);
if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d\n",
- __func__, rc);
- goto fail_disable_vreg_marimba_1;
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
+ goto disable_marimba_1;
}
rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
if (rc < 0) {
- printk(KERN_ERR
- "%s: gpio_direction_output failed (%d)\n",
+ pr_err("%s: gpio_direction_output failed (%d)\n",
__func__, rc);
msm_gpios_free(timpani_reset_gpio_cfg,
ARRAY_SIZE(timpani_reset_gpio_cfg));
- vreg_disable(vreg_marimba_2);
- } else
- goto out;
+ goto disable_marimba_2;
+ }
+ return 0;
-fail_disable_vreg_marimba_1:
- vreg_disable(vreg_marimba_1);
-
+disable_marimba_2:
+ regulator_disable(vreg_marimba_2);
+disable_marimba_1:
+ regulator_disable(vreg_marimba_1);
out:
return rc;
};
@@ -1702,23 +1685,18 @@
{
int rc;
- rc = vreg_disable(vreg_marimba_1);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d\n",
- __func__, rc);
- }
- rc = vreg_disable(vreg_marimba_2);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d\n",
- __func__, rc);
- }
+ rc = regulator_disable(vreg_marimba_2);
+ if (rc)
+ pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
+
+ rc = regulator_disable(vreg_marimba_1);
+ if (rc)
+ pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
- if (rc < 0) {
- printk(KERN_ERR
- "%s: gpio_direction_output failed (%d)\n",
+ if (rc < 0)
+ pr_err("%s: gpio_direction_output failed (%d)\n",
__func__, rc);
- }
msm_gpios_free(timpani_reset_gpio_cfg,
ARRAY_SIZE(timpani_reset_gpio_cfg));
@@ -1767,13 +1745,10 @@
static unsigned int msm_bahama_setup_power(void)
{
- int rc;
+ int rc = regulator_enable(vreg_bahama);
- rc = vreg_enable(vreg_marimba_3);
- if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d\n",
- __func__, rc);
- }
+ if (rc)
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
return rc;
};
@@ -1783,11 +1758,11 @@
int rc = 0;
if (value != BAHAMA_ID) {
- rc = vreg_disable(vreg_marimba_3);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d\n",
+ rc = regulator_disable(vreg_bahama);
+
+ if (rc)
+ pr_err("%s: regulator_disable failed (%d)\n",
__func__, rc);
- }
}
return rc;
@@ -1817,39 +1792,42 @@
{
int rc;
- rc = vreg_enable(vreg_marimba_1);
+ rc = regulator_enable(vreg_marimba_1);
if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d \n",
- __func__, rc);
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
goto out;
}
- rc = vreg_enable(vreg_marimba_2);
+
+ rc = regulator_enable(vreg_marimba_2);
if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d \n",
- __func__, rc);
- goto out;
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
+ goto disable_marimba_1;
}
if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
rc = msm_gpios_request_enable(marimba_svlte_config_clock,
ARRAY_SIZE(marimba_svlte_config_clock));
if (rc < 0) {
- printk(KERN_ERR
- "%s: msm_gpios_request_enable failed (%d)\n",
+ pr_err("%s: msm_gpios_request_enable failed (%d)\n",
__func__, rc);
- return rc;
+ goto disable_marimba_2;
}
rc = gpio_direction_output(GPIO_PIN
(marimba_svlte_config_clock->gpio_cfg), 0);
if (rc < 0) {
- printk(KERN_ERR
- "%s: gpio_direction_output failed (%d)\n",
+ pr_err("%s: gpio_direction_output failed (%d)\n",
__func__, rc);
- return rc;
+ goto disable_marimba_2;
}
}
+ return 0;
+
+disable_marimba_2:
+ regulator_disable(vreg_marimba_2);
+disable_marimba_1:
+ regulator_disable(vreg_marimba_1);
out:
return rc;
};
@@ -1858,16 +1836,13 @@
{
int rc;
- rc = vreg_disable(vreg_marimba_1);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d\n",
- __func__, rc);
- }
- rc = vreg_disable(vreg_marimba_2);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d \n",
- __func__, rc);
- }
+ rc = regulator_disable(vreg_marimba_2);
+ if (rc)
+ pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
+
+ rc = regulator_disable(vreg_marimba_1);
+ if (rc)
+ pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
};
static int bahama_present(void)
@@ -1888,81 +1863,89 @@
}
}
-struct vreg *fm_regulator;
+struct regulator *fm_regulator;
static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
{
- int rc;
+ int rc, voltage;
uint32_t irqcfg;
const char *id = "FMPW";
int bahama_not_marimba = bahama_present();
- if (bahama_not_marimba == -1) {
- printk(KERN_WARNING "%s: bahama_present: %d\n",
+ if (bahama_not_marimba < 0) {
+ pr_warn("%s: bahama_present: %d\n",
__func__, bahama_not_marimba);
- return -ENODEV;
+ rc = -ENODEV;
+ goto out;
}
- if (bahama_not_marimba)
- fm_regulator = vreg_get(NULL, "s3");
- else
- fm_regulator = vreg_get(NULL, "s2");
+ if (bahama_not_marimba) {
+ fm_regulator = regulator_get(NULL, "s3");
+ voltage = 1800000;
+ } else {
+ fm_regulator = regulator_get(NULL, "s2");
+ voltage = 1300000;
+ }
if (IS_ERR(fm_regulator)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(fm_regulator));
- return -1;
+ rc = PTR_ERR(fm_regulator);
+ pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
+ goto out;
}
- if (!bahama_not_marimba) {
- rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 1300);
+ rc = regulator_set_voltage(fm_regulator, voltage, voltage);
- if (rc < 0) {
- printk(KERN_ERR "%s: voltage level vote failed (%d)\n",
- __func__, rc);
- return rc;
- }
- }
- rc = vreg_enable(fm_regulator);
if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d\n",
- __func__, rc);
- return rc;
+ pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
+ goto regulator_free;
}
- rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
- PMAPP_CLOCK_VOTE_ON);
- if (rc < 0) {
- printk(KERN_ERR "%s: clock vote failed (%d)\n",
- __func__, rc);
- goto fm_clock_vote_fail;
+ rc = regulator_enable(fm_regulator);
+
+ if (rc) {
+ pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
+ goto regulator_free;
}
+
+ rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
+
+ if (rc < 0) {
+ pr_err("%s: clock vote failed (%d)\n", __func__, rc);
+ goto regulator_disable;
+ }
+
/*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
of svlte*/
- if (machine_is_msm8x55_svlte_surf() ||
- machine_is_msm8x55_svlte_ffa()) {
+ if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
rc = marimba_gpio_config(1);
- if (rc < 0)
- printk(KERN_ERR "%s: clock enable for svlte : %d\n",
- __func__, rc);
+ if (rc < 0) {
+ pr_err("%s: clock enable for svlte : %d\n",
+ __func__, rc);
+ goto clock_devote;
+ }
}
irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
GPIO_CFG_2MA);
rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
if (rc) {
- printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
- __func__, irqcfg, rc);
+ pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
rc = -EIO;
- goto fm_gpio_config_fail;
+ goto gpio_deconfig;
}
return 0;
-fm_gpio_config_fail:
- pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
- PMAPP_CLOCK_VOTE_OFF);
-fm_clock_vote_fail:
- vreg_disable(fm_regulator);
- return rc;
+gpio_deconfig:
+ if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
+ marimba_gpio_config(0);
+clock_devote:
+ pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
+regulator_disable:
+ regulator_disable(fm_regulator);
+regulator_free:
+ regulator_put(fm_regulator);
+ fm_regulator = NULL;
+out:
+ return rc;
};
static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
@@ -1974,48 +1957,36 @@
int bahama_not_marimba = bahama_present();
if (bahama_not_marimba == -1) {
- printk(KERN_WARNING "%s: bahama_present: %d\n",
- __func__, bahama_not_marimba);
+ pr_warn("%s: bahama_present: %d\n",
+ __func__, bahama_not_marimba);
return;
}
rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
if (rc) {
- printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
- __func__, irqcfg, rc);
+ pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
}
- if (fm_regulator != NULL) {
- rc = vreg_disable(fm_regulator);
+ if (!IS_ERR_OR_NULL(fm_regulator)) {
+ rc = regulator_disable(fm_regulator);
- if (rc) {
- printk(KERN_ERR "%s: return val: %d\n",
- __func__, rc);
- }
+ if (rc)
+ pr_err("%s: return val: %d\n", __func__, rc);
+
+ regulator_put(fm_regulator);
fm_regulator = NULL;
}
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
PMAPP_CLOCK_VOTE_OFF);
if (rc < 0)
- printk(KERN_ERR "%s: clock_vote return val: %d\n",
- __func__, rc);
+ pr_err("%s: clock_vote return val: %d\n", __func__, rc);
/*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
of svlte*/
- if (machine_is_msm8x55_svlte_surf() ||
- machine_is_msm8x55_svlte_ffa()) {
+ if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
rc = marimba_gpio_config(0);
if (rc < 0)
- printk(KERN_ERR "%s: clock disable for svlte : %d\n",
- __func__, rc);
- }
-
-
- if (!bahama_not_marimba) {
- rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 0);
-
- if (rc < 0)
- printk(KERN_ERR "%s: vreg level vote return val: %d\n",
- __func__, rc);
+ pr_err("%s: clock disable for svlte : %d\n",
+ __func__, rc);
}
}
@@ -2042,82 +2013,60 @@
#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
static const char *tsadc_id = "MADC";
-static const char *vregs_tsadc_name[] = {
- "gp12",
- "s2",
-};
-static struct vreg *vregs_tsadc[ARRAY_SIZE(vregs_tsadc_name)];
-static const char *vregs_timpani_tsadc_name[] = {
- "s3",
- "gp12",
- "gp16"
+static struct regulator_bulk_data regs_tsadc_marimba[] = {
+ { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
+ { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
};
-static struct vreg *vregs_timpani_tsadc[ARRAY_SIZE(vregs_timpani_tsadc_name)];
+
+static struct regulator_bulk_data regs_tsadc_timpani[] = {
+ { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
+ { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
+};
+
+static struct regulator_bulk_data *regs_tsadc;
+static int regs_tsadc_count;
static int marimba_tsadc_power(int vreg_on)
{
- int i, rc = 0;
+ int rc = 0;
int tsadc_adie_type = adie_get_detected_codec_type();
- if (tsadc_adie_type == TIMPANI_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
- if (!vregs_timpani_tsadc[i]) {
- pr_err("%s: vreg_get %s failed(%d)\n",
- __func__, vregs_timpani_tsadc_name[i], rc);
- goto vreg_fail;
- }
-
- rc = vreg_on ? vreg_enable(vregs_timpani_tsadc[i]) :
- vreg_disable(vregs_timpani_tsadc[i]);
- if (rc < 0) {
- pr_err("%s: vreg %s %s failed(%d)\n",
- __func__, vregs_timpani_tsadc_name[i],
- vreg_on ? "enable" : "disable", rc);
- goto vreg_fail;
- }
- }
- /* Vote for D0 and D1 buffer */
+ switch (tsadc_adie_type) {
+ case TIMPANI_ID:
rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
if (rc) {
pr_err("%s: unable to %svote for d1 clk\n",
__func__, vreg_on ? "" : "de-");
- goto do_vote_fail;
+ goto D1_vote_fail;
}
+
+ /* fall through */
+ case MARIMBA_ID:
rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
if (rc) {
pr_err("%s: unable to %svote for d1 clk\n",
__func__, vreg_on ? "" : "de-");
- goto do_vote_fail;
+ goto D0_vote_fail;
}
- } else if (tsadc_adie_type == MARIMBA_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
- if (!vregs_tsadc[i]) {
- pr_err("%s: vreg_get %s failed (%d)\n",
- __func__, vregs_tsadc_name[i], rc);
- goto vreg_fail;
- }
- rc = vreg_on ? vreg_enable(vregs_tsadc[i]) :
- vreg_disable(vregs_tsadc[i]);
- if (rc < 0) {
- pr_err("%s: vreg %s %s failed (%d)\n",
- __func__, vregs_tsadc_name[i],
- vreg_on ? "enable" : "disable", rc);
- goto vreg_fail;
- }
+ WARN_ON(regs_tsadc_count == 0);
+
+ rc = vreg_on ?
+ regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
+ regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
+
+ if (rc) {
+ pr_err("%s: regulator %sable failed: %d\n",
+ __func__, vreg_on ? "en" : "dis", rc);
+ goto regulator_switch_fail;
}
- /* If marimba vote for DO buffer */
- rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
- vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
- if (rc) {
- pr_err("%s: unable to %svote for d0 clk\n",
- __func__, vreg_on ? "" : "de-");
- goto do_vote_fail;
- }
- } else {
+
+ break;
+ default:
pr_err("%s:Adie %d not supported\n",
__func__, tsadc_adie_type);
return -ENODEV;
@@ -2127,112 +2076,69 @@
return 0;
-do_vote_fail:
-vreg_fail:
- while (i) {
- if (vreg_on) {
- if (tsadc_adie_type == TIMPANI_ID)
- vreg_disable(vregs_timpani_tsadc[--i]);
- else if (tsadc_adie_type == MARIMBA_ID)
- vreg_disable(vregs_tsadc[--i]);
- } else {
- if (tsadc_adie_type == TIMPANI_ID)
- vreg_enable(vregs_timpani_tsadc[--i]);
- else if (tsadc_adie_type == MARIMBA_ID)
- vreg_enable(vregs_tsadc[--i]);
- }
- }
-
- return rc;
-}
-
-static int marimba_tsadc_vote(int vote_on)
-{
- int rc = 0;
-
- if (adie_get_detected_codec_type() == MARIMBA_ID) {
- int level = vote_on ? 1300 : 0;
- rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, level);
- if (rc < 0)
- pr_err("%s: vreg level %s failed (%d)\n",
- __func__, vote_on ? "on" : "off", rc);
- }
-
+regulator_switch_fail:
+ pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
+ vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
+D0_vote_fail:
+ if (tsadc_adie_type == TIMPANI_ID)
+ pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
+ vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
+D1_vote_fail:
return rc;
}
static int marimba_tsadc_init(void)
{
- int i, rc = 0;
+ int rc = 0;
int tsadc_adie_type = adie_get_detected_codec_type();
- if (tsadc_adie_type == TIMPANI_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
- vregs_timpani_tsadc[i] = vreg_get(NULL,
- vregs_timpani_tsadc_name[i]);
- if (IS_ERR(vregs_timpani_tsadc[i])) {
- pr_err("%s: vreg get %s failed (%ld)\n",
- __func__, vregs_timpani_tsadc_name[i],
- PTR_ERR(vregs_timpani_tsadc[i]));
- rc = PTR_ERR(vregs_timpani_tsadc[i]);
- goto vreg_get_fail;
- }
- }
- } else if (tsadc_adie_type == MARIMBA_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
- vregs_tsadc[i] = vreg_get(NULL, vregs_tsadc_name[i]);
- if (IS_ERR(vregs_tsadc[i])) {
- pr_err("%s: vreg get %s failed (%ld)\n",
- __func__, vregs_tsadc_name[i],
- PTR_ERR(vregs_tsadc[i]));
- rc = PTR_ERR(vregs_tsadc[i]);
- goto vreg_get_fail;
- }
- }
- } else {
+ switch (tsadc_adie_type) {
+ case MARIMBA_ID:
+ regs_tsadc = regs_tsadc_marimba;
+ regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
+ break;
+ case TIMPANI_ID:
+ regs_tsadc = regs_tsadc_timpani;
+ regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
+ break;
+ default:
pr_err("%s:Adie %d not supported\n",
__func__, tsadc_adie_type);
- return -ENODEV;
+ rc = -ENODEV;
+ goto out;
+ }
+
+ rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n",
+ __func__, rc);
+ goto out;
+ }
+
+ rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
+ if (rc) {
+ pr_err("%s: could not set regulator voltages: %d\n",
+ __func__, rc);
+ goto vreg_free;
}
return 0;
-vreg_get_fail:
- while (i) {
- if (tsadc_adie_type == TIMPANI_ID)
- vreg_put(vregs_timpani_tsadc[--i]);
- else if (tsadc_adie_type == MARIMBA_ID)
- vreg_put(vregs_tsadc[--i]);
- }
+vreg_free:
+ regulator_bulk_free(regs_tsadc_count, regs_tsadc);
+out:
+ regs_tsadc = NULL;
+ regs_tsadc_count = 0;
return rc;
}
static int marimba_tsadc_exit(void)
{
- int i, rc = 0;
- int tsadc_adie_type = adie_get_detected_codec_type();
+ regulator_bulk_free(regs_tsadc_count, regs_tsadc);
+ regs_tsadc_count = 0;
+ regs_tsadc = NULL;
- if (tsadc_adie_type == TIMPANI_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
- if (vregs_tsadc[i])
- vreg_put(vregs_timpani_tsadc[i]);
- }
- } else if (tsadc_adie_type == MARIMBA_ID) {
- for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
- if (vregs_tsadc[i])
- vreg_put(vregs_tsadc[i]);
- }
- rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, 0);
- if (rc < 0)
- pr_err("%s: vreg level off failed (%d)\n",
- __func__, rc);
- } else {
- pr_err("%s:Adie %d not supported\n",
- __func__, tsadc_adie_type);
- rc = -ENODEV;
- }
-
- return rc;
+ return 0;
}
@@ -2252,7 +2158,6 @@
.marimba_tsadc_power = marimba_tsadc_power,
.init = marimba_tsadc_init,
.exit = marimba_tsadc_exit,
- .level_vote = marimba_tsadc_vote,
.tsadc_prechg_en = true,
.can_wakeup = false,
.setup = {
@@ -2271,39 +2176,47 @@
.tssc_data = &msm_ts_data,
};
-static struct vreg *vreg_codec_s4;
+static struct regulator_bulk_data codec_regs[] = {
+ { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
+};
+
+static int __init msm_marimba_codec_init(void)
+{
+ int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
+
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto out;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
+ if (rc) {
+ pr_err("%s: could not set regulator voltages: %d\n",
+ __func__, rc);
+ goto reg_free;
+ }
+
+ return rc;
+
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
+out:
+ return rc;
+}
+
static int msm_marimba_codec_power(int vreg_on)
{
- int rc = 0;
+ int rc = vreg_on ?
+ regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
+ regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
- if (!vreg_codec_s4) {
-
- vreg_codec_s4 = vreg_get(NULL, "s4");
-
- if (IS_ERR(vreg_codec_s4)) {
- printk(KERN_ERR "%s: vreg_get() failed (%ld)\n",
- __func__, PTR_ERR(vreg_codec_s4));
- rc = PTR_ERR(vreg_codec_s4);
- goto vreg_codec_s4_fail;
- }
+ if (rc) {
+ pr_err("%s: could not %sable regulators: %d",
+ __func__, vreg_on ? "en" : "dis", rc);
+ return rc;
}
- if (vreg_on) {
- rc = vreg_enable(vreg_codec_s4);
- if (rc)
- printk(KERN_ERR "%s: vreg_enable() = %d \n",
- __func__, rc);
- goto vreg_codec_s4_fail;
- } else {
- rc = vreg_disable(vreg_codec_s4);
- if (rc)
- printk(KERN_ERR "%s: vreg_disable() = %d \n",
- __func__, rc);
- goto vreg_codec_s4_fail;
- }
-
-vreg_codec_s4_fail:
- return rc;
+ return 0;
}
static struct marimba_codec_platform_data mariba_codec_pdata = {
@@ -2334,29 +2247,38 @@
{
int rc;
- vreg_marimba_1 = vreg_get(NULL, "s3");
- if (IS_ERR(vreg_marimba_1)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_marimba_1));
- return;
- }
- rc = vreg_set_level(vreg_marimba_1, 1800);
+ struct regulator_bulk_data regs[] = {
+ { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
+ { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
+ };
- vreg_marimba_2 = vreg_get(NULL, "gp16");
- if (IS_ERR(vreg_marimba_1)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_marimba_1));
- return;
- }
- rc = vreg_set_level(vreg_marimba_2, 1200);
+ rc = msm_marimba_codec_init();
- vreg_marimba_3 = vreg_get(NULL, "usb2");
- if (IS_ERR(vreg_marimba_3)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_marimba_3));
+ if (rc) {
+ pr_err("%s: msm_marimba_codec_init failed (%d)\n",
+ __func__, rc);
return;
}
- rc = vreg_set_level(vreg_marimba_3, 1800);
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
+
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ return;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
+
+ if (rc) {
+ pr_err("%s: could not set voltages: %d\n", __func__, rc);
+ regulator_bulk_free(ARRAY_SIZE(regs), regs);
+ return;
+ }
+
+ vreg_marimba_1 = regs[0].consumer;
+ vreg_marimba_2 = regs[1].consumer;
+ vreg_bahama = regs[2].consumer;
}
static struct marimba_codec_platform_data timpani_codec_pdata = {
@@ -2748,6 +2670,13 @@
"optnav_chip_select" },
};
+static struct regulator_bulk_data optnav_regulators[] = {
+ { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
+ { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
+};
+
static void __iomem *virtual_optnav;
static int optnav_gpio_setup(void)
@@ -2756,6 +2685,9 @@
rc = msm_gpios_request_enable(optnav_config_data,
ARRAY_SIZE(optnav_config_data));
+ if (rc)
+ return rc;
+
/* Configure the FPGA for GPIOs */
virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
if (!virtual_optnav) {
@@ -2767,6 +2699,22 @@
* normal, active(enabled), output(MSM to SURF)
*/
writew(0x311E, virtual_optnav);
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
+ optnav_regulators);
+ if (rc)
+ return rc;
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
+ optnav_regulators);
+
+ if (rc)
+ goto regulator_put;
+
+ return rc;
+
+regulator_put:
+ regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
return rc;
}
@@ -2775,13 +2723,9 @@
msm_gpios_disable_free(optnav_config_data,
ARRAY_SIZE(optnav_config_data));
iounmap(virtual_optnav);
+ regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
}
-static struct vreg *vreg_gp7;
-static struct vreg *vreg_gp4;
-static struct vreg *vreg_gp9;
-static struct vreg *vreg_usb3_3;
-
static int optnav_enable(void)
{
int rc;
@@ -2789,80 +2733,24 @@
* Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
* for I2C communication with keyboard.
*/
- vreg_gp7 = vreg_get(NULL, "gp7");
- rc = vreg_set_level(vreg_gp7, 1800);
- if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_gp7;
- }
- rc = vreg_enable(vreg_gp7);
- if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_gp7;
- }
+ rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
+ optnav_regulators);
- vreg_gp4 = vreg_get(NULL, "gp4");
- rc = vreg_set_level(vreg_gp4, 2600);
- if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_gp4;
- }
-
- rc = vreg_enable(vreg_gp4);
- if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_gp4;
- }
-
- vreg_gp9 = vreg_get(NULL, "gp9");
- rc = vreg_set_level(vreg_gp9, 1800);
- if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_gp9;
- }
-
- rc = vreg_enable(vreg_gp9);
- if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_gp9;
- }
-
- vreg_usb3_3 = vreg_get(NULL, "usb");
- rc = vreg_set_level(vreg_usb3_3, 3300);
- if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_3_3;
- }
-
- rc = vreg_enable(vreg_usb3_3);
- if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_3_3;
- }
+ if (rc)
+ return rc;
/* Enable the chip select GPIO */
gpio_set_value(OPTNAV_CHIP_SELECT, 1);
gpio_set_value(OPTNAV_CHIP_SELECT, 0);
return 0;
-
-fail_vreg_3_3:
- vreg_disable(vreg_gp9);
-fail_vreg_gp9:
- vreg_disable(vreg_gp4);
-fail_vreg_gp4:
- vreg_disable(vreg_gp7);
-fail_vreg_gp7:
- return rc;
}
static void optnav_disable(void)
{
- vreg_disable(vreg_usb3_3);
- vreg_disable(vreg_gp9);
- vreg_disable(vreg_gp4);
- vreg_disable(vreg_gp7);
+ regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
+ optnav_regulators);
gpio_set_value(OPTNAV_CHIP_SELECT, 1);
}
@@ -2907,74 +2795,61 @@
};
#ifdef CONFIG_BOSCH_BMA150
-static struct vreg *vreg_gp6;
-static int sensors_ldo_enable(void)
+
+static struct regulator_bulk_data sensors_ldo[] = {
+ { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
+};
+
+static int __init sensors_ldo_init(void)
{
int rc;
- /*
- * Enable the VREGs L8(gp7), L15(gp6)
- * for I2C communication with sensors.
- */
- pr_info("sensors_ldo_enable called!!\n");
- vreg_gp7 = vreg_get(NULL, "gp7");
- if (IS_ERR(vreg_gp7)) {
- pr_err("%s: vreg_get gp7 failed\n", __func__);
- rc = PTR_ERR(vreg_gp7);
- goto fail_gp7_get;
- }
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
- rc = vreg_set_level(vreg_gp7, 1800);
if (rc) {
- pr_err("%s: vreg_set_level gp7 failed\n", __func__);
- goto fail_gp7_level;
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto out;
}
- rc = vreg_enable(vreg_gp7);
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
+
if (rc) {
- pr_err("%s: vreg_enable gp7 failed\n", __func__);
- goto fail_gp7_level;
- }
-
- vreg_gp6 = vreg_get(NULL, "gp6");
- if (IS_ERR(vreg_gp6)) {
- pr_err("%s: vreg_get gp6 failed\n", __func__);
- rc = PTR_ERR(vreg_gp6);
- goto fail_gp6_get;
- }
-
- rc = vreg_set_level(vreg_gp6, 3050);
- if (rc) {
- pr_err("%s: vreg_set_level gp6 failed\n", __func__);
- goto fail_gp6_level;
- }
-
- rc = vreg_enable(vreg_gp6);
- if (rc) {
- pr_err("%s: vreg_enable gp6 failed\n", __func__);
- goto fail_gp6_level;
+ pr_err("%s: could not set voltages: %d\n", __func__, rc);
+ goto reg_free;
}
return 0;
-fail_gp6_level:
- vreg_put(vreg_gp6);
-fail_gp6_get:
- vreg_disable(vreg_gp7);
-fail_gp7_level:
- vreg_put(vreg_gp7);
-fail_gp7_get:
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
+out:
return rc;
}
+static int sensors_ldo_set(int on)
+{
+ int rc = on ?
+ regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
+ regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
+
+ if (rc)
+ pr_err("%s: could not %sable regulators: %d\n",
+ __func__, on ? "en" : "dis", rc);
+
+ return rc;
+}
+
+static int sensors_ldo_enable(void)
+{
+ return sensors_ldo_set(1);
+}
+
static void sensors_ldo_disable(void)
{
- pr_info("sensors_ldo_disable called!!\n");
- vreg_disable(vreg_gp6);
- vreg_put(vreg_gp6);
- vreg_disable(vreg_gp7);
- vreg_put(vreg_gp7);
+ sensors_ldo_set(0);
}
+
static struct bma150_platform_data bma150_data = {
.power_on = sensors_ldo_enable,
.power_off = sensors_ldo_disable,
@@ -3262,27 +3137,27 @@
#endif
#ifdef CONFIG_USB_MSM_OTG_72K
-static struct vreg *vreg_3p3;
+static struct regulator *vreg_3p3;
static int msm_hsusb_ldo_init(int init)
{
uint32_t version = 0;
- int def_vol = 3400;
+ int def_vol = 3400000;
version = socinfo_get_version();
if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
SOCINFO_VERSION_MINOR(version) >= 1) {
- def_vol = 3075;
+ def_vol = 3075000;
pr_debug("%s: default voltage:%d\n", __func__, def_vol);
}
if (init) {
- vreg_3p3 = vreg_get(NULL, "usb");
+ vreg_3p3 = regulator_get(NULL, "usb");
if (IS_ERR(vreg_3p3))
return PTR_ERR(vreg_3p3);
- vreg_set_level(vreg_3p3, def_vol);
+ regulator_set_voltage(vreg_3p3, def_vol, def_vol);
} else
- vreg_put(vreg_3p3);
+ regulator_put(vreg_3p3);
return 0;
}
@@ -3300,14 +3175,14 @@
ldo_status = enable;
if (enable)
- return vreg_enable(vreg_3p3);
-
- return vreg_disable(vreg_3p3);
+ return regulator_enable(vreg_3p3);
+ else
+ return regulator_disable(vreg_3p3);
}
static int msm_hsusb_ldo_set_voltage(int mV)
{
- static int cur_voltage = 3400;
+ static int cur_voltage;
if (!vreg_3p3 || IS_ERR(vreg_3p3))
return -ENODEV;
@@ -3319,7 +3194,7 @@
pr_debug("%s: (%d)\n", __func__, mV);
- return vreg_set_level(vreg_3p3, mV);
+ return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
}
#endif
@@ -3500,35 +3375,163 @@
GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
#endif
-static int gpio_set(const char *label, const char *name, int level, int on)
+static struct regulator_bulk_data hdmi_core_regs[] = {
+ { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
+};
+
+static struct regulator_bulk_data hdmi_comm_regs[] = {
+ { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
+};
+
+static struct regulator_bulk_data hdmi_cec_regs[] = {
+ { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
+};
+
+static int __init hdmi_init_regs(void)
{
- struct vreg *vreg = vreg_get(NULL, label);
int rc;
- if (IS_ERR(vreg)) {
- rc = PTR_ERR(vreg);
- pr_err("%s: vreg %s get failed (%d)\n",
- __func__, name, rc);
- return rc;
- }
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
+ hdmi_core_regs);
- rc = vreg_set_level(vreg, level);
if (rc) {
- pr_err("%s: vreg %s set level failed (%d)\n",
- __func__, name, rc);
- return rc;
+ pr_err("%s: could not get %s regulators: %d\n",
+ __func__, "core", rc);
+ goto out;
}
- if (on)
- rc = vreg_enable(vreg);
- else
- rc = vreg_disable(vreg);
- if (rc)
- pr_err("%s: vreg %s enable failed (%d)\n",
- __func__, name, rc);
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
+ hdmi_core_regs);
+
+ if (rc) {
+ pr_err("%s: could not set %s voltages: %d\n",
+ __func__, "core", rc);
+ goto free_core;
+ }
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
+ hdmi_comm_regs);
+
+ if (rc) {
+ pr_err("%s: could not get %s regulators: %d\n",
+ __func__, "comm", rc);
+ goto free_core;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
+ hdmi_comm_regs);
+
+ if (rc) {
+ pr_err("%s: could not set %s voltages: %d\n",
+ __func__, "comm", rc);
+ goto free_comm;
+ }
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
+ hdmi_cec_regs);
+
+ if (rc) {
+ pr_err("%s: could not get %s regulators: %d\n",
+ __func__, "cec", rc);
+ goto free_comm;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
+ hdmi_cec_regs);
+
+ if (rc) {
+ pr_err("%s: could not set %s voltages: %d\n",
+ __func__, "cec", rc);
+ goto free_cec;
+ }
+
+ return 0;
+
+free_cec:
+ regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
+free_comm:
+ regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
+free_core:
+ regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
+out:
return rc;
}
+static int hdmi_init_irq(void)
+{
+ int rc = msm_gpios_enable(dtv_panel_irq_gpios,
+ ARRAY_SIZE(dtv_panel_irq_gpios));
+ if (rc < 0) {
+ pr_err("%s: gpio enable failed: %d\n", __func__, rc);
+ return rc;
+ }
+ pr_info("%s\n", __func__);
+
+ return 0;
+}
+
+static int hdmi_enable_5v(int on)
+{
+ int pmic_gpio_hdmi_5v_en ;
+
+ if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
+ machine_is_msm7x30_fluid())
+ pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
+ else
+ pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
+
+ pr_info("%s: %d\n", __func__, on);
+ if (on) {
+ int rc;
+ rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
+ "hdmi_5V_en");
+ if (rc) {
+ pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
+ __func__);
+ return rc;
+ }
+ gpio_set_value_cansleep(
+ PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
+ } else {
+ gpio_set_value_cansleep(
+ PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
+ gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
+ }
+ return 0;
+}
+
+static int hdmi_comm_power(int on, int show)
+{
+ if (show)
+ pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
+ return on ?
+ regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
+ hdmi_comm_regs) :
+ regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
+ hdmi_comm_regs);
+}
+
+static int hdmi_core_power(int on, int show)
+{
+ if (show)
+ pr_info("%s: %d <LDO8>\n", __func__, on);
+ return on ?
+ regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
+ hdmi_core_regs) :
+ regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
+ hdmi_core_regs);
+}
+
+static int hdmi_cec_power(int on)
+{
+ pr_info("%s: %d <LDO17>\n", __func__, on);
+ return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
+ hdmi_cec_regs) :
+ regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
+ hdmi_cec_regs);
+}
+
#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
/* there is an i2c address conflict between adv7520 and bma150 sensor after
* power up on fluid. As a solution, the default address of adv7520's packet
@@ -3541,7 +3544,6 @@
struct i2c_msg msgs[3];
int res;
int rc = -EINVAL;
- struct vreg *vreg_ldo8;
struct i2c_adapter *adapter;
if (machine_is_msm7x30_fluid()) {
@@ -3552,24 +3554,13 @@
}
/* turn on LDO8 */
- vreg_ldo8 = vreg_get(NULL, "gp7");
- if (!vreg_ldo8) {
- pr_err("%s: VREG L8 get failed\n", __func__);
+ rc = hdmi_core_power(1, 0);
+ if (rc) {
+ pr_err("%s: could not enable hdmi core regs: %d",
+ __func__, rc);
goto adapter_put;
}
- rc = vreg_set_level(vreg_ldo8, 1800);
- if (rc) {
- pr_err("%s: VREG L8 set failed\n", __func__);
- goto ldo8_put;
- }
-
- rc = vreg_enable(vreg_ldo8);
- if (rc) {
- pr_err("%s: VREG L8 enable failed\n", __func__);
- goto ldo8_put;
- }
-
/* change packet memory address to 0x74 */
wBuff[0] = 0x45;
wBuff[1] = 0x74;
@@ -3627,9 +3618,7 @@
return 0;
ldo8_disable:
- vreg_disable(vreg_ldo8);
-ldo8_put:
- vreg_put(vreg_ldo8);
+ hdmi_core_power(0, 0);
adapter_put:
i2c_put_adapter(adapter);
return rc;
@@ -3637,77 +3626,6 @@
fs_initcall_sync(fluid_i2c_address_fixup);
#endif
-static int hdmi_comm_power(int on, int show)
-{
- int rc = gpio_set("gp7", "LDO8", 1800, on);
- if (rc) {
- pr_warning("hdmi_comm_power: LDO8 gpio failed: rc=%d\n", rc);
- return rc;
- }
- rc = gpio_set("gp4", "LDO10", 2600, on);
- if (rc)
- pr_warning("hdmi_comm_power: LDO10 gpio failed: rc=%d\n", rc);
- if (show)
- pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
- return rc;
-}
-
-static int hdmi_init_irq(void)
-{
- int rc = msm_gpios_enable(dtv_panel_irq_gpios,
- ARRAY_SIZE(dtv_panel_irq_gpios));
- if (rc < 0) {
- pr_err("%s: gpio enable failed: %d\n", __func__, rc);
- return rc;
- }
- pr_info("%s\n", __func__);
-
- return 0;
-}
-
-static int hdmi_enable_5v(int on)
-{
- int pmic_gpio_hdmi_5v_en ;
-
- if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
- machine_is_msm7x30_fluid())
- pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
- else
- pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
-
- pr_info("%s: %d\n", __func__, on);
- if (on) {
- int rc;
- rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
- "hdmi_5V_en");
- if (rc) {
- pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
- __func__);
- return rc;
- }
- gpio_set_value_cansleep(
- PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
- } else {
- gpio_set_value_cansleep(
- PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
- gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
- }
- return 0;
-}
-
-static int hdmi_core_power(int on, int show)
-{
- if (show)
- pr_info("%s: %d <LDO8>\n", __func__, on);
- return gpio_set("gp7", "LDO8", 1800, on);
-}
-
-static int hdmi_cec_power(int on)
-{
- pr_info("%s: %d <LDO17>\n", __func__, on);
- return gpio_set("gp11", "LDO17", 2600, on);
-}
-
static bool hdmi_check_hdcp_hw_support(void)
{
if (machine_is_msm7x30_fluid())
@@ -4024,18 +3942,86 @@
},
};
+static struct regulator *mddi_ldo20;
+static struct regulator *mddi_ldo12;
+static struct regulator *mddi_ldo16;
+static struct regulator *mddi_ldo6;
+static struct regulator *mddi_lcd;
+
+static int display_common_init(void)
+{
+ struct regulator_bulk_data regs[5] = {
+ { .supply = "ldo20", /* voltage set in display_common_power */},
+ { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
+ { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
+ { .supply = NULL, /* mddi_lcd, initialized below */ },
+ };
+
+ int rc = 0;
+
+ if (machine_is_msm7x30_fluid()) {
+ /* lcd: LDO8 @1.8V */
+ regs[4].supply = "ldo8";
+ regs[4].min_uV = 1800000;
+ regs[4].max_uV = 1800000;
+ } else {
+ /* lcd: LDO15 @3.1V */
+ regs[4].supply = "ldo15";
+ regs[4].min_uV = 3100000;
+ regs[4].max_uV = 3100000;
+ }
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
+ if (rc) {
+ pr_err("%s: regulator_bulk_get failed: %d\n",
+ __func__, rc);
+ goto bail;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
+ if (rc) {
+ pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
+ __func__, rc);
+ goto put_regs;
+ }
+
+ mddi_ldo20 = regs[0].consumer;
+ mddi_ldo12 = regs[1].consumer;
+ mddi_ldo6 = regs[2].consumer;
+ mddi_ldo16 = regs[3].consumer;
+ mddi_lcd = regs[4].consumer;
+
+ return rc;
+
+put_regs:
+ regulator_bulk_free(ARRAY_SIZE(regs), regs);
+bail:
+ return rc;
+}
+
static int display_common_power(int on)
{
int rc = 0, flag_on = !!on;
static int display_common_power_save_on;
- struct vreg *vreg_ldo12, *vreg_ldo15 = NULL, *vreg_ldo6;
- struct vreg *vreg_ldo20, *vreg_ldo16, *vreg_ldo8 = NULL;
+ static bool display_regs_initialized;
if (display_common_power_save_on == flag_on)
return 0;
display_common_power_save_on = flag_on;
+ if (unlikely(!display_regs_initialized)) {
+ rc = display_common_init();
+ if (rc) {
+ pr_err("%s: regulator init failed: %d\n",
+ __func__, rc);
+ return rc;
+ }
+ display_regs_initialized = true;
+ }
+
+
if (on) {
/* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
@@ -4075,172 +4061,57 @@
}
}
- /* Toshiba WeGA power -- has 3 power source */
- /* 1.5V -- LDO20*/
- vreg_ldo20 = vreg_get(NULL, "gp13");
-
- if (IS_ERR(vreg_ldo20)) {
- rc = PTR_ERR(vreg_ldo20);
- pr_err("%s: gp13 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- /* 1.8V -- LDO12 */
- vreg_ldo12 = vreg_get(NULL, "gp9");
-
- if (IS_ERR(vreg_ldo12)) {
- rc = PTR_ERR(vreg_ldo12);
- pr_err("%s: gp9 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- /* 2.6V -- LDO16 */
- vreg_ldo16 = vreg_get(NULL, "gp10");
-
- if (IS_ERR(vreg_ldo16)) {
- rc = PTR_ERR(vreg_ldo16);
- pr_err("%s: gp10 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- /* 3.075V -- LDO6 */
- vreg_ldo6 = vreg_get(NULL, "usb");
-
- if (IS_ERR(vreg_ldo6)) {
- rc = PTR_ERR(vreg_ldo6);
- pr_err("%s: usb vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- if (machine_is_msm7x30_fluid()) {
- /* 1.8V -- LDO8 */
- vreg_ldo8 = vreg_get(NULL, "gp7");
-
- if (IS_ERR(vreg_ldo8)) {
- rc = PTR_ERR(vreg_ldo8);
- pr_err("%s: gp7 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
- } else {
- /* lcd panel power */
- /* 3.1V -- LDO15 */
- vreg_ldo15 = vreg_get(NULL, "gp6");
-
- if (IS_ERR(vreg_ldo15)) {
- rc = PTR_ERR(vreg_ldo15);
- pr_err("%s: gp6 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
- }
-
- /* For QuickLogic chip, LDO20 requires 1.8V */
- /* Toshiba chip requires 1.5V, but can tolerate 1.8V since max is 3V */
if (quickvx_mddi_client)
- rc = vreg_set_level(vreg_ldo20, 1800);
+ rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
else
- rc = vreg_set_level(vreg_ldo20, 1500);
+ rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
+
if (rc) {
- pr_err("%s: vreg LDO20 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- rc = vreg_set_level(vreg_ldo12, 1800);
- if (rc) {
- pr_err("%s: vreg LDO12 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- if (other_mddi_client) {
- rc = vreg_set_level(vreg_ldo16, 2600);
- if (rc) {
- pr_err("%s: vreg LDO16 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
- }
-
- if (quickvx_mddi_client) {
- rc = vreg_set_level(vreg_ldo6, 3075);
- if (rc) {
- pr_err("%s: vreg LDO6 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
- }
-
- if (machine_is_msm7x30_fluid()) {
- rc = vreg_set_level(vreg_ldo8, 1800);
- if (rc) {
- pr_err("%s: vreg LDO8 set level failed (%d)\n",
+ pr_err("%s: could not set voltage for ldo20: %d\n",
__func__, rc);
- return rc;
- }
- } else {
- rc = vreg_set_level(vreg_ldo15, 3100);
- if (rc) {
- pr_err("%s: vreg LDO15 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
+ return rc;
}
if (on) {
- rc = vreg_enable(vreg_ldo20);
+ rc = regulator_enable(mddi_ldo20);
if (rc) {
- pr_err("%s: LDO20 vreg enable failed (%d)\n",
+ pr_err("%s: LDO20 regulator enable failed (%d)\n",
__func__, rc);
return rc;
}
- rc = vreg_enable(vreg_ldo12);
+ rc = regulator_enable(mddi_ldo12);
if (rc) {
- pr_err("%s: LDO12 vreg enable failed (%d)\n",
+ pr_err("%s: LDO12 regulator enable failed (%d)\n",
__func__, rc);
return rc;
}
if (other_mddi_client) {
- rc = vreg_enable(vreg_ldo16);
+ rc = regulator_enable(mddi_ldo16);
if (rc) {
- pr_err("%s: LDO16 vreg enable failed (%d)\n",
+ pr_err("%s: LDO16 regulator enable failed (%d)\n",
__func__, rc);
return rc;
}
}
- if (quickvx_mddi_client && quickvx_ldo_enabled) {
+ if (quickvx_ldo_enabled) {
/* Disable LDO6 during display ON */
- rc = vreg_disable(vreg_ldo6);
+ rc = regulator_disable(mddi_ldo6);
if (rc) {
- pr_err("%s: LDO6 vreg disable failed (%d)\n",
+ pr_err("%s: LDO6 regulator disable failed (%d)\n",
__func__, rc);
return rc;
}
quickvx_ldo_enabled = 0;
}
- if (machine_is_msm7x30_fluid()) {
- rc = vreg_enable(vreg_ldo8);
- if (rc) {
- pr_err("%s: LDO8 vreg enable failed (%d)\n",
- __func__, rc);
- return rc;
- }
- } else {
- rc = vreg_enable(vreg_ldo15);
- if (rc) {
- pr_err("%s: LDO15 vreg enable failed (%d)\n",
- __func__, rc);
- return rc;
- }
+ rc = regulator_enable(mddi_lcd);
+ if (rc) {
+ pr_err("%s: LCD regulator enable failed (%d)\n",
+ __func__, rc);
+ return rc;
}
mdelay(5); /* ensure power is stable */
@@ -4279,18 +4150,18 @@
}
} else {
- rc = vreg_disable(vreg_ldo20);
+ rc = regulator_disable(mddi_ldo20);
if (rc) {
- pr_err("%s: LDO20 vreg disable failed (%d)\n",
+ pr_err("%s: LDO20 regulator disable failed (%d)\n",
__func__, rc);
return rc;
}
if (other_mddi_client) {
- rc = vreg_disable(vreg_ldo16);
+ rc = regulator_disable(mddi_ldo16);
if (rc) {
- pr_err("%s: LDO16 vreg disable failed (%d)\n",
+ pr_err("%s: LDO16 regulator disable failed (%d)\n",
__func__, rc);
return rc;
}
@@ -4299,9 +4170,9 @@
if (quickvx_mddi_client && !quickvx_ldo_enabled) {
/* Enable LDO6 during display OFF for
Quicklogic chip to sleep with data retention */
- rc = vreg_enable(vreg_ldo6);
+ rc = regulator_enable(mddi_ldo6);
if (rc) {
- pr_err("%s: LDO6 vreg enable failed (%d)\n",
+ pr_err("%s: LDO6 regulator enable failed (%d)\n",
__func__, rc);
return rc;
}
@@ -4316,27 +4187,18 @@
PMIC_GPIO_QUICKVX_CLK), 0);
}
- if (machine_is_msm7x30_fluid()) {
- rc = vreg_disable(vreg_ldo8);
- if (rc) {
- pr_err("%s: LDO8 vreg disable failed (%d)\n",
- __func__, rc);
- return rc;
- }
- } else {
- rc = vreg_disable(vreg_ldo15);
- if (rc) {
- pr_err("%s: LDO15 vreg disable failed (%d)\n",
- __func__, rc);
- return rc;
- }
+ rc = regulator_disable(mddi_lcd);
+ if (rc) {
+ pr_err("%s: LCD regulator disable failed (%d)\n",
+ __func__, rc);
+ return rc;
}
mdelay(5); /* ensure power is stable */
- rc = vreg_disable(vreg_ldo12);
+ rc = regulator_disable(mddi_ldo12);
if (rc) {
- pr_err("%s: LDO12 vreg disable failed (%d)\n",
+ pr_err("%s: LDO12 regulator disable failed (%d)\n",
__func__, rc);
return rc;
}
@@ -4365,51 +4227,19 @@
static int msm_fb_mddi_client_power(u32 client_id)
{
- struct vreg *vreg_ldo20, *vreg_ldo16;
- int rc;
-
printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
/* Check if it is Quicklogic client */
if (client_id == 0xc5835800) {
printk(KERN_NOTICE "\n Quicklogic MDDI client");
other_mddi_client = 0;
- vreg_ldo16 = vreg_get(NULL, "gp10");
-
- if (IS_ERR(vreg_ldo16)) {
- rc = PTR_ERR(vreg_ldo16);
- pr_err("%s: gp10 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
-
- rc = vreg_disable(vreg_ldo16);
- if (rc) {
- pr_err("%s: LDO16 vreg enable failed (%d)\n",
- __func__, rc);
- return rc;
- }
} else {
printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
quickvx_mddi_client = 0;
gpio_set_value(97, 0);
gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
PMIC_GPIO_QUICKVX_CLK), 0);
-
- vreg_ldo20 = vreg_get(NULL, "gp13");
-
- if (IS_ERR(vreg_ldo20)) {
- rc = PTR_ERR(vreg_ldo20);
- pr_err("%s: gp13 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
- rc = vreg_set_level(vreg_ldo20, 1500);
- if (rc) {
- pr_err("%s: vreg LDO20 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
}
+
return 0;
}
@@ -4574,13 +4404,18 @@
static int lcdc_panel_power(int on)
{
int flag_on = !!on;
- static int lcdc_power_save_on;
+ static int lcdc_power_save_on, lcdc_power_initialized;
if (lcdc_power_save_on == flag_on)
return 0;
lcdc_power_save_on = flag_on;
- quickvx_mddi_client = 0;
+
+ if (unlikely(!lcdc_power_initialized)) {
+ quickvx_mddi_client = 0;
+ display_common_init();
+ lcdc_power_initialized = 1;
+ }
if (machine_is_msm7x30_fluid())
return lcdc_sharp_panel_power(on);
@@ -4592,47 +4427,64 @@
.lcdc_power_save = lcdc_panel_power,
};
+static struct regulator *atv_s4, *atv_ldo9;
+
+static int __init atv_dac_power_init(void)
+{
+ int rc;
+ struct regulator_bulk_data regs[] = {
+ { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
+ { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
+ };
+
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
+
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto bail;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
+
+ if (rc) {
+ pr_err("%s: could not set voltages: %d\n", __func__, rc);
+ goto reg_free;
+ }
+
+ atv_s4 = regs[0].consumer;
+ atv_ldo9 = regs[1].consumer;
+
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(regs), regs);
+bail:
+ return rc;
+}
+
static int atv_dac_power(int on)
{
int rc = 0;
- struct vreg *vreg_s4, *vreg_ldo9;
-
- vreg_s4 = vreg_get(NULL, "s4");
- if (IS_ERR(vreg_s4)) {
- rc = PTR_ERR(vreg_s4);
- pr_err("%s: s4 vreg get failed (%d)\n",
- __func__, rc);
- return -1;
- }
- vreg_ldo9 = vreg_get(NULL, "gp1");
- if (IS_ERR(vreg_ldo9)) {
- rc = PTR_ERR(vreg_ldo9);
- pr_err("%s: ldo9 vreg get failed (%d)\n",
- __func__, rc);
- return rc;
- }
if (on) {
- rc = vreg_enable(vreg_s4);
+ rc = regulator_enable(atv_s4);
if (rc) {
pr_err("%s: s4 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
- rc = vreg_enable(vreg_ldo9);
+ rc = regulator_enable(atv_ldo9);
if (rc) {
pr_err("%s: ldo9 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
} else {
- rc = vreg_disable(vreg_ldo9);
+ rc = regulator_disable(atv_ldo9);
if (rc) {
pr_err("%s: ldo9 vreg disable failed (%d)\n",
__func__, rc);
return rc;
}
- rc = vreg_disable(vreg_s4);
+ rc = regulator_disable(atv_s4);
if (rc) {
pr_err("%s: s4 vreg disable failed (%d)\n",
__func__, rc);
@@ -4707,24 +4559,31 @@
"UART1DM_Tx" }
};
-static const char *vregs_bt_marimba_name[] = {
- "s3",
- "s2",
- "gp16",
- "wlan"
-};
-static struct vreg *vregs_bt_marimba[ARRAY_SIZE(vregs_bt_marimba_name)];
-
-static const char *vregs_bt_bahama_name[] = {
- "s3",
- "usb2",
- "s2",
- "wlan"
-};
-static struct vreg *vregs_bt_bahama[ARRAY_SIZE(vregs_bt_bahama_name)];
-
static u8 bahama_version;
+static struct regulator_bulk_data regs_bt_marimba[] = {
+ { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
+ { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
+ { .supply = "ldo13", .min_uV = 2900000, .max_uV = 2900000 },
+};
+
+static struct regulator_bulk_data regs_bt_bahama_v1[] = {
+ { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
+ { .supply = "ldo13", .min_uV = 2900000, .max_uV = 2900000 },
+};
+
+static struct regulator_bulk_data regs_bt_bahama_v2[] = {
+ { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "ldo13", .min_uV = 2900000, .max_uV = 2900000 },
+};
+
+static struct regulator_bulk_data *regs_bt;
+static int regs_bt_count;
+
static int marimba_bt(int on)
{
int rc;
@@ -4946,15 +4805,6 @@
on = on ? 1 : 0;
- bahama_version = read_bahama_ver();
-
- if (((int)bahama_version) < 0 ||
- bahama_version == VER_UNSUPPORTED) {
- dev_err(&msm_bt_power_device.dev,
- "%s: i2c failure or unsupported version: %d\n",
- __func__, bahama_version);
- return -EIO;
- }
if (bahama_version == VER_2_0) {
if (marimba_get_fm_status(&config))
@@ -4990,69 +4840,62 @@
else
marimba_set_bt_status(&config, false);
- if (bahama_version == VER_2_0 && on) { /* variant of bahama v2 */
- /* Disable s2 as bahama v2 uses internal LDO regulator */
- for (i = 0; i < ARRAY_SIZE(vregs_bt_bahama_name); i++) {
- if (!strcmp(vregs_bt_bahama_name[i], "s2")) {
- rc = vreg_disable(vregs_bt_bahama[i]);
- if (rc < 0) {
- printk(KERN_ERR
- "%s: vreg %s disable "
- "failed (%d)\n",
- __func__,
- vregs_bt_bahama_name[i], rc);
- return -EIO;
- }
- rc = pmapp_vreg_level_vote("BTPW",
- PMAPP_VREG_S2,
- 0);
- if (rc < 0) {
- printk(KERN_ERR "%s: vreg "
- "level off failed (%d)\n",
- __func__, rc);
- return -EIO;
- }
- printk(KERN_INFO "%s: vreg disable & "
- "level off successful (%d)\n",
- __func__, rc);
- }
- }
- }
-
return 0;
}
-static int bluetooth_power_regulators(int on, int bahama_not_marimba)
+static int bluetooth_regs_init(int bahama_not_marimba)
{
- int i, rc;
- const char **vregs_name;
- struct vreg **vregs;
- int vregs_size;
+ int rc = 0;
+ struct device *const dev = &msm_bt_power_device.dev;
if (bahama_not_marimba) {
- vregs_name = vregs_bt_bahama_name;
- vregs = vregs_bt_bahama;
- vregs_size = ARRAY_SIZE(vregs_bt_bahama_name);
+ bahama_version = read_bahama_ver();
+
+ switch (bahama_version) {
+ case VER_1_0:
+ regs_bt = regs_bt_bahama_v1;
+ regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
+ break;
+ case VER_2_0:
+ regs_bt = regs_bt_bahama_v2;
+ regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
+ break;
+ case VER_UNSUPPORTED:
+ default:
+ dev_err(dev,
+ "%s: i2c failure or unsupported version: %d\n",
+ __func__, bahama_version);
+ rc = -EIO;
+ goto out;
+ }
} else {
- vregs_name = vregs_bt_marimba_name;
- vregs = vregs_bt_marimba;
- vregs_size = ARRAY_SIZE(vregs_bt_marimba_name);
+ regs_bt = regs_bt_marimba;
+ regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
}
- for (i = 0; i < vregs_size; i++) {
- if (bahama_not_marimba && (bahama_version == VER_2_0) &&
- !on && !strcmp(vregs_bt_bahama_name[i], "s2"))
- continue;
- rc = on ? vreg_enable(vregs[i]) :
- vreg_disable(vregs[i]);
- if (rc < 0) {
- printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
- __func__, vregs_name[i],
- on ? "enable" : "disable", rc);
- return -EIO;
- }
+ rc = regulator_bulk_get(&msm_bt_power_device.dev,
+ regs_bt_count, regs_bt);
+ if (rc) {
+ dev_err(dev, "%s: could not get regulators: %d\n",
+ __func__, rc);
+ goto out;
}
+
+ rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
+ if (rc) {
+ dev_err(dev, "%s: could not set voltages: %d\n",
+ __func__, rc);
+ goto reg_free;
+ }
+
return 0;
+
+reg_free:
+ regulator_bulk_free(regs_bt_count, regs_bt);
+out:
+ regs_bt_count = 0;
+ regs_bt = NULL;
+ return rc;
}
static int bluetooth_power(int on)
@@ -5068,17 +4911,16 @@
return -ENODEV;
}
- if (on) {
- rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 1300);
- if (rc < 0) {
- printk(KERN_ERR "%s: vreg level on failed (%d)\n",
- __func__, rc);
+ if (unlikely(regs_bt_count == 0)) {
+ rc = bluetooth_regs_init(bahama_not_marimba);
+ if (rc)
return rc;
- }
+ }
- rc = bluetooth_power_regulators(on, bahama_not_marimba);
- if (rc < 0)
- return -EIO;
+ if (on) {
+ rc = regulator_bulk_enable(regs_bt_count, regs_bt);
+ if (rc)
+ return rc;
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
PMAPP_CLOCK_VOTE_ON);
@@ -5135,18 +4977,10 @@
if (rc < 0)
return -EIO;
- rc = bluetooth_power_regulators(on, bahama_not_marimba);
- if (rc < 0)
- return -EIO;
+ rc = regulator_bulk_disable(regs_bt_count, regs_bt);
+ if (rc)
+ return rc;
- if (bahama_version == VER_1_0) {
- rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 0);
- if (rc < 0) {
- printk(KERN_ERR "%s: vreg level off failed "
- "(%d)\n", __func__, rc);
- return -EIO;
- }
- }
}
out:
@@ -5157,29 +4991,7 @@
static void __init bt_power_init(void)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(vregs_bt_marimba_name); i++) {
- vregs_bt_marimba[i] = vreg_get(NULL, vregs_bt_marimba_name[i]);
- if (IS_ERR(vregs_bt_marimba[i])) {
- printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
- __func__, vregs_bt_marimba_name[i],
- PTR_ERR(vregs_bt_marimba[i]));
- return;
- }
- }
-
- for (i = 0; i < ARRAY_SIZE(vregs_bt_bahama_name); i++) {
- vregs_bt_bahama[i] = vreg_get(NULL, vregs_bt_bahama_name[i]);
- if (IS_ERR(vregs_bt_bahama[i])) {
- printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
- __func__, vregs_bt_bahama_name[i],
- PTR_ERR(vregs_bt_bahama[i]));
- return;
- }
- }
-
- msm_bt_power_device.dev.platform_data = &bluetooth_power;
+ msm_bt_power_device.dev.platform_data = &bluetooth_power;
}
#else
#define bt_power_init(x) do {} while (0)
@@ -5415,7 +5227,7 @@
}
/*This needs to be enabled only for OEMS*/
#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
-static struct vreg *qup_vreg;
+static struct regulator *qup_vreg;
#endif
static void
qup_i2c_gpio_config(int adap_id, int config_type)
@@ -5434,15 +5246,10 @@
printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
/*This needs to be enabled only for OEMS*/
#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
- if (qup_vreg) {
- int rc = vreg_set_level(qup_vreg, 1800);
+ if (!IS_ERR_OR_NULL(qup_vreg)) {
+ rc = regulator_enable(qup_vreg);
if (rc) {
- pr_err("%s: vreg LVS1 set level failed (%d)\n",
- __func__, rc);
- }
- rc = vreg_enable(qup_vreg);
- if (rc) {
- pr_err("%s: vreg_enable() = %d \n",
+ pr_err("%s: regulator_enable failed: %d\n",
__func__, rc);
}
}
@@ -5491,9 +5298,10 @@
qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
/*This needs to be enabled only for OEMS*/
#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
- qup_vreg = vreg_get(NULL, "lvsw1");
+ qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
if (IS_ERR(qup_vreg)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
+ dev_err(&qup_device_i2c.dev,
+ "%s: regulator_get failed: %ld\n",
__func__, PTR_ERR(qup_vreg));
}
#endif
@@ -5516,9 +5324,6 @@
{GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
};
-struct vreg *vreg_s3;
-struct vreg *vreg_mmc;
-
#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
|| defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
|| defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
@@ -5615,12 +5420,7 @@
},
};
-struct sdcc_vreg {
- struct vreg *vreg_data;
- unsigned level;
-};
-
-static struct sdcc_vreg sdcc_vreg_data[4];
+static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
static unsigned long vreg_sts, gpio_sts;
@@ -5656,37 +5456,36 @@
static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
{
int rc = 0;
- struct sdcc_vreg *curr;
+ struct regulator *curr = sdcc_vreg_data[dev_id - 1];
static int enabled_once[] = {0, 0, 0, 0};
- curr = &sdcc_vreg_data[dev_id - 1];
-
- if (!(test_bit(dev_id, &vreg_sts)^enable))
+ if (test_bit(dev_id, &vreg_sts) == enable)
return rc;
if (!enable || enabled_once[dev_id - 1])
return 0;
+ if (!curr)
+ return -ENODEV;
+
+ if (IS_ERR(curr))
+ return PTR_ERR(curr);
+
if (enable) {
set_bit(dev_id, &vreg_sts);
- rc = vreg_set_level(curr->vreg_data, curr->level);
- if (rc) {
- printk(KERN_ERR "%s: vreg_set_level() = %d \n",
+
+ rc = regulator_enable(curr);
+ if (rc)
+ pr_err("%s: could not enable regulator: %d\n",
__func__, rc);
- }
- rc = vreg_enable(curr->vreg_data);
- if (rc) {
- printk(KERN_ERR "%s: vreg_enable() = %d \n",
- __func__, rc);
- }
enabled_once[dev_id - 1] = 1;
} else {
clear_bit(dev_id, &vreg_sts);
- rc = vreg_disable(curr->vreg_data);
- if (rc) {
- printk(KERN_ERR "%s: vreg_disable() = %d \n",
+
+ rc = regulator_disable(curr);
+ if (rc)
+ pr_err("%s: could not disable regulator: %d\n",
__func__, rc);
- }
}
return rc;
}
@@ -5757,109 +5556,76 @@
return rc;
}
-static int mbp_setup_rf_vregs(int state)
+static struct regulator_bulk_data mbp_regs_io[2];
+static struct regulator_bulk_data mbp_regs_rf[2];
+static struct regulator_bulk_data mbp_regs_adc[1];
+static struct regulator_bulk_data mbp_regs_core[1];
+
+static int mbp_init_regs(struct device *dev)
{
- struct vreg *vreg_rf = NULL;
- struct vreg *vreg_rf_switch = NULL;
+ struct regulator_bulk_data regs[] = {
+ /* Analog and I/O regs */
+ { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
+ { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
+ /* RF regs */
+ { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
+ { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
+ /* ADC regs */
+ { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
+ /* Core regs */
+ { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
+ };
+
+ struct regulator_bulk_data *regptr = regs;
int rc;
- vreg_rf = vreg_get(NULL, "s2");
- if (IS_ERR(vreg_rf)) {
- pr_err("%s: s2 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_rf));
- return -EFAULT;
- }
- vreg_rf_switch = vreg_get(NULL, "rf");
- if (IS_ERR(vreg_rf_switch)) {
- pr_err("%s: rf vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_rf_switch));
- return -EFAULT;
+ rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
+
+ if (rc) {
+ dev_err(dev, "%s: could not get regulators: %d\n",
+ __func__, rc);
+ goto out;
}
- if (state) {
- rc = vreg_set_level(vreg_rf, 1300);
- if (rc) {
- pr_err("%s: vreg s2 set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
- rc = vreg_enable(vreg_rf);
- if (rc) {
- printk(KERN_ERR "%s: vreg_enable(s2) = %d\n",
- __func__, rc);
- }
-
- rc = vreg_set_level(vreg_rf_switch, 2600);
- if (rc) {
- pr_err("%s: vreg rf switch set level failed (%d)\n",
- __func__, rc);
- return rc;
- }
- rc = vreg_enable(vreg_rf_switch);
- if (rc) {
- printk(KERN_ERR "%s: vreg_enable(rf) = %d\n",
- __func__, rc);
- }
- } else {
- (void) vreg_disable(vreg_rf);
- (void) vreg_disable(vreg_rf_switch);
+ if (rc) {
+ dev_err(dev, "%s: could not set voltages: %d\n",
+ __func__, rc);
+ goto reg_free;
}
+
+ memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
+ regptr += ARRAY_SIZE(mbp_regs_io);
+
+ memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
+ regptr += ARRAY_SIZE(mbp_regs_rf);
+
+ memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
+ regptr += ARRAY_SIZE(mbp_regs_adc);
+
+ memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
+
return 0;
+
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(regs), regs);
+out:
+ return rc;
+}
+
+static int mbp_setup_rf_vregs(int state)
+{
+ return state ?
+ regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
+ regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
}
static int mbp_setup_vregs(int state)
{
- struct vreg *vreg_analog = NULL;
- struct vreg *vreg_io = NULL;
- int rc;
-
- vreg_analog = vreg_get(NULL, "gp4");
- if (IS_ERR(vreg_analog)) {
- pr_err("%s: gp4 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_analog));
- return -EFAULT;
- }
- vreg_io = vreg_get(NULL, "s3");
- if (IS_ERR(vreg_io)) {
- pr_err("%s: s3 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_io));
- return -EFAULT;
- }
- if (state) {
- rc = vreg_set_level(vreg_analog, 2600);
- if (rc) {
- pr_err("%s: vreg_set_level failed (%d)",
- __func__, rc);
- }
- rc = vreg_enable(vreg_analog);
- if (rc) {
- pr_err("%s: analog vreg enable failed (%d)",
- __func__, rc);
- }
- rc = vreg_set_level(vreg_io, 1800);
- if (rc) {
- pr_err("%s: vreg_set_level failed (%d)",
- __func__, rc);
- }
- rc = vreg_enable(vreg_io);
- if (rc) {
- pr_err("%s: io vreg enable failed (%d)",
- __func__, rc);
- }
- } else {
- rc = vreg_disable(vreg_analog);
- if (rc) {
- pr_err("%s: analog vreg disable failed (%d)",
- __func__, rc);
- }
- rc = vreg_disable(vreg_io);
- if (rc) {
- pr_err("%s: io vreg disable failed (%d)",
- __func__, rc);
- }
- }
- return rc;
+ return state ?
+ regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
+ regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
}
static int mbp_set_tcxo_en(int enable)
@@ -5875,16 +5641,6 @@
__func__, enable ? "" : "de-");
return -EIO;
}
- if (!enable) {
- vreg_analog = vreg_get(NULL, "gp4");
- if (IS_ERR(vreg_analog)) {
- pr_err("%s: gp4 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_analog));
- return -EFAULT;
- }
-
- (void) vreg_disable(vreg_analog);
- }
return rc;
}
@@ -5898,28 +5654,20 @@
static int mbp_set_core_voltage_en(int enable)
{
- int rc;
- struct vreg *vreg_core1p2 = NULL;
+ static bool is_enabled;
+ int rc = 0;
- vreg_core1p2 = vreg_get(NULL, "gp16");
- if (IS_ERR(vreg_core1p2)) {
- pr_err("%s: gp16 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_core1p2));
- return -EFAULT;
- }
- if (enable) {
- rc = vreg_set_level(vreg_core1p2, 1200);
+ if (enable && !is_enabled) {
+ rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
+ mbp_regs_core);
if (rc) {
- pr_err("%s: vreg_set_level failed (%d)",
+ pr_err("%s: could not enable regulators: %d\n",
__func__, rc);
+ } else {
+ is_enabled = true;
}
- (void) vreg_enable(vreg_core1p2);
-
- return 80;
- } else {
- gpio_set_value(85, 1);
- return 0;
}
+
return rc;
}
@@ -5950,34 +5698,9 @@
static int mbp_setup_adc_vregs(int state)
{
- struct vreg *vreg_adc = NULL;
- int rc;
-
- vreg_adc = vreg_get(NULL, "s4");
- if (IS_ERR(vreg_adc)) {
- pr_err("%s: s4 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_adc));
- return -EFAULT;
- }
- if (state) {
- rc = vreg_set_level(vreg_adc, 2200);
- if (rc) {
- pr_err("%s: vreg_set_level failed (%d)",
- __func__, rc);
- }
- rc = vreg_enable(vreg_adc);
- if (rc) {
- pr_err("%s: enable vreg adc failed (%d)",
- __func__, rc);
- }
- } else {
- rc = vreg_disable(vreg_adc);
- if (rc) {
- pr_err("%s: disable vreg adc failed (%d)",
- __func__, rc);
- }
- }
- return rc;
+ return state ?
+ regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
+ regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
}
static int mbp_power_up(void)
@@ -6042,14 +5765,6 @@
static int mbp_power_down(void)
{
int rc;
- struct vreg *vreg_adc = NULL;
-
- vreg_adc = vreg_get(NULL, "s4");
- if (IS_ERR(vreg_adc)) {
- pr_err("%s: s4 vreg get failed (%ld)",
- __func__, PTR_ERR(vreg_adc));
- return -EFAULT;
- }
mbp_set_reset(MBP_ON);
pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
@@ -6079,13 +5794,16 @@
goto exit;
pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
- gpio_set_value(85, 1);
-
rc = mbp_set_tcxo_en(MBP_OFF);
if (rc)
goto exit;
pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
+ rc = mbp_setup_vregs(MBP_OFF);
+ if (rc)
+ goto exit;
+ pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
+
rc = mbp_config_gpios_pre_init(MBP_OFF);
if (rc)
goto exit;
@@ -6147,6 +5865,12 @@
goto out;
}
if (!mbp_power_init_done) {
+ rc = mbp_init_regs(dv);
+ if (rc) {
+ dev_err(dv, "%s: regulator init failed: %d\n",
+ __func__, rc);
+ goto out;
+ }
mbp_setup_power(dv, 1);
mbp_setup_power(dv, 0);
mbp_power_init_done = 1;
@@ -6285,18 +6009,32 @@
#endif
#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
-static void msm_sdc1_lvlshft_enable(void)
+static int msm_sdc1_lvlshft_enable(void)
{
+ static struct regulator *ldo5;
int rc;
/* Enable LDO5, an input to the FET that powers slot 1 */
- rc = vreg_set_level(vreg_mmc, 2850);
- if (rc)
- printk(KERN_ERR "%s: vreg_set_level() = %d \n", __func__, rc);
- rc = vreg_enable(vreg_mmc);
- if (rc)
- printk(KERN_ERR "%s: vreg_enable() = %d \n", __func__, rc);
+ ldo5 = regulator_get(NULL, "ldo5");
+
+ if (IS_ERR(ldo5)) {
+ rc = PTR_ERR(ldo5);
+ pr_err("%s: could not get ldo5: %d\n", __func__, rc);
+ goto out;
+ }
+
+ rc = regulator_set_voltage(ldo5, 2850000, 2850000);
+ if (rc) {
+ pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
+ goto ldo5_free;
+ }
+
+ rc = regulator_enable(ldo5);
+ if (rc) {
+ pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
+ goto ldo5_free;
+ }
/* Enable GPIO 35, to turn on the FET that powers slot 1 */
rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
@@ -6308,35 +6046,72 @@
1);
if (rc)
printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
+
+ return 0;
+
+ldo5_free:
+ regulator_put(ldo5);
+out:
+ ldo5 = NULL;
+ return rc;
}
#endif
+static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
+{
+ int rc;
+
+ BUG_ON(sdcc_no < 1 || sdcc_no > 4);
+
+ sdcc_no--;
+
+ sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
+
+ if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
+ rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
+ pr_err("%s: could not get regulator \"%s\": %d\n",
+ __func__, supply, rc);
+ goto out;
+ }
+
+ rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
+
+ if (rc) {
+ pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
+ __func__, supply, uV, rc);
+ goto reg_free;
+ }
+
+ return rc;
+
+reg_free:
+ regulator_put(sdcc_vreg_data[sdcc_no]);
+out:
+ sdcc_vreg_data[sdcc_no] = NULL;
+ return rc;
+}
+
static void __init msm7x30_init_mmc(void)
{
- vreg_s3 = vreg_get(NULL, "s3");
- if (IS_ERR(vreg_s3)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_s3));
- return;
- }
-
- vreg_mmc = vreg_get(NULL, "mmc");
- if (IS_ERR(vreg_mmc)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_mmc));
- return;
- }
-
#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
+ if (mmc_regulator_init(1, "s3", 1800000))
+ goto out1;
+
if (machine_is_msm7x30_fluid()) {
msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
- msm_sdc1_lvlshft_enable();
+ if (msm_sdc1_lvlshft_enable()) {
+ pr_err("%s: could not enable level shift\n");
+ goto out1;
+ }
}
- sdcc_vreg_data[0].vreg_data = vreg_s3;
- sdcc_vreg_data[0].level = 1800;
+
msm_add_sdcc(1, &msm7x30_sdc1_data);
+out1:
#endif
#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
+ if (mmc_regulator_init(2, "s3", 1800000))
+ goto out2;
+
if (machine_is_msm8x55_svlte_surf())
msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
if (machine_is_msm8x55_svlte_surf() ||
@@ -6344,19 +6119,22 @@
msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
msm7x30_sdc2_data.is_sdio_al_client = 1;
}
- sdcc_vreg_data[1].vreg_data = vreg_s3;
- sdcc_vreg_data[1].level = 1800;
+
msm_add_sdcc(2, &msm7x30_sdc2_data);
+out2:
#endif
#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
- sdcc_vreg_data[2].vreg_data = vreg_s3;
- sdcc_vreg_data[2].level = 1800;
+ if (mmc_regulator_init(3, "s3", 1800000))
+ goto out3;
+
msm_sdcc_setup_gpio(3, 1);
msm_add_sdcc(3, &msm7x30_sdc3_data);
+out3:
#endif
#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
- sdcc_vreg_data[3].vreg_data = vreg_mmc;
- sdcc_vreg_data[3].level = 2850;
+ if (mmc_regulator_init(4, "mmc", 2850000))
+ return;
+
msm_add_sdcc(4, &msm7x30_sdc4_data);
#endif
@@ -6468,68 +6246,50 @@
"tsc2007_irq" },
};
-static struct vreg *vreg_tsc_s3;
-static struct vreg *vreg_tsc_s2;
+static struct regulator_bulk_data tsc2007_regs[] = {
+ { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
+};
static int tsc2007_init(void)
{
int rc;
- vreg_tsc_s3 = vreg_get(NULL, "s3");
- if (IS_ERR(vreg_tsc_s3)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_tsc_s3));
- return -ENODEV;
- }
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
- rc = vreg_set_level(vreg_tsc_s3, 1800);
if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_set_level;
+ pr_err("%s: could not get regulators: %d\n", __func__, rc);
+ goto out;
}
- rc = vreg_enable(vreg_tsc_s3);
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
+
if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_set_level;
+ pr_err("%s: could not set voltages: %d\n", __func__, rc);
+ goto reg_free;
}
- vreg_tsc_s2 = vreg_get(NULL, "s2");
- if (IS_ERR(vreg_tsc_s2)) {
- printk(KERN_ERR "%s: vreg get failed (%ld)\n",
- __func__, PTR_ERR(vreg_tsc_s2));
- goto fail_vreg_get;
- }
+ rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
- rc = vreg_set_level(vreg_tsc_s2, 1300);
if (rc) {
- pr_err("%s: vreg_set_level failed \n", __func__);
- goto fail_vreg_s2_level;
- }
-
- rc = vreg_enable(vreg_tsc_s2);
- if (rc) {
- pr_err("%s: vreg_enable failed \n", __func__);
- goto fail_vreg_s2_level;
+ pr_err("%s: could not enable regulators: %d\n", __func__, rc);
+ goto reg_free;
}
rc = msm_gpios_request_enable(tsc2007_config_data,
ARRAY_SIZE(tsc2007_config_data));
if (rc) {
pr_err("%s: Unable to request gpios\n", __func__);
- goto fail_gpio_req;
+ goto reg_disable;
}
return 0;
-fail_gpio_req:
- vreg_disable(vreg_tsc_s2);
-fail_vreg_s2_level:
- vreg_put(vreg_tsc_s2);
-fail_vreg_get:
- vreg_disable(vreg_tsc_s3);
-fail_vreg_set_level:
- vreg_put(vreg_tsc_s3);
+reg_disable:
+ regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
+out:
return rc;
}
@@ -6549,10 +6309,9 @@
static void tsc2007_exit(void)
{
- vreg_disable(vreg_tsc_s3);
- vreg_put(vreg_tsc_s3);
- vreg_disable(vreg_tsc_s2);
- vreg_put(vreg_tsc_s2);
+
+ regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
+ regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
msm_gpios_disable_free(tsc2007_config_data,
ARRAY_SIZE(tsc2007_config_data));
@@ -6562,35 +6321,20 @@
{
int rc;
- if (enable == false) {
- rc = vreg_enable(vreg_tsc_s2);
- if (rc) {
- pr_err("%s: vreg_enable failed\n", __func__);
- return rc;
- }
- rc = vreg_enable(vreg_tsc_s3);
- if (rc) {
- pr_err("%s: vreg_enable failed\n", __func__);
- vreg_disable(vreg_tsc_s2);
- return rc;
- }
- /* Voltage settling delay */
- msleep(20);
- } else {
- rc = vreg_disable(vreg_tsc_s2);
- if (rc) {
- pr_err("%s: vreg_disable failed\n", __func__);
- return rc;
- }
- rc = vreg_disable(vreg_tsc_s3);
- if (rc) {
- pr_err("%s: vreg_disable failed\n", __func__);
- vreg_enable(vreg_tsc_s2);
- return rc;
- }
+ rc = (enable == false) ?
+ regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
+ regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
+
+ if (rc) {
+ pr_err("%s: could not %sable regulators: %d\n",
+ __func__, enable ? "dis" : "en", rc);
+ return rc;
}
- return rc;
+ if (enable == false)
+ msleep(20);
+
+ return 0;
}
static struct tsc2007_platform_data tsc2007_ts_data = {
@@ -6617,36 +6361,23 @@
};
#endif
-static const char *vregs_isa1200_name[] = {
- "gp7",
- "gp10",
+static struct regulator_bulk_data regs_isa1200[] = {
+ { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
+ { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
};
-static const int vregs_isa1200_val[] = {
- 1800,
- 2600,
-};
-static struct vreg *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
-
static int isa1200_power(int vreg_on)
{
- int i, rc = 0;
+ int rc = 0;
- for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
- if (!vregs_isa1200[i]) {
- pr_err("%s: vreg_get %s failed (%d)\n",
- __func__, vregs_isa1200_name[i], rc);
- goto vreg_fail;
- }
+ rc = vreg_on ?
+ regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
+ regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
- rc = vreg_on ? vreg_enable(vregs_isa1200[i]) :
- vreg_disable(vregs_isa1200[i]);
- if (rc < 0) {
- pr_err("%s: vreg %s %s failed (%d)\n",
- __func__, vregs_isa1200_name[i],
- vreg_on ? "enable" : "disable", rc);
- goto vreg_fail;
- }
+ if (rc) {
+ pr_err("%s: could not %sable regulators: %d\n",
+ __func__, vreg_on ? "en" : "dis", rc);
+ goto out;
}
/* vote for DO buffer */
@@ -6661,33 +6392,34 @@
return 0;
vreg_fail:
- while (i)
- vreg_disable(vregs_isa1200[--i]);
+ if (vreg_on)
+ regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
+ else
+ regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
+out:
return rc;
}
static int isa1200_dev_setup(bool enable)
{
- int i, rc;
+ int rc;
if (enable == true) {
- for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
- vregs_isa1200[i] = vreg_get(NULL,
- vregs_isa1200_name[i]);
- if (IS_ERR(vregs_isa1200[i])) {
- pr_err("%s: vreg get %s failed (%ld)\n",
- __func__, vregs_isa1200_name[i],
- PTR_ERR(vregs_isa1200[i]));
- rc = PTR_ERR(vregs_isa1200[i]);
- goto vreg_get_fail;
- }
- rc = vreg_set_level(vregs_isa1200[i],
- vregs_isa1200_val[i]);
- if (rc) {
- pr_err("%s: vreg_set_level() = %d\n",
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
+ regs_isa1200);
+
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n",
__func__, rc);
- goto vreg_get_fail;
- }
+ goto out;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
+ regs_isa1200);
+ if (rc) {
+ pr_err("%s: could not set voltages: %d\n",
+ __func__, rc);
+ goto reg_free;
}
rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
@@ -6696,28 +6428,27 @@
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, HAP_LVL_SHFT_MSM_GPIO);
- goto vreg_get_fail;
+ goto reg_free;
}
rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, HAP_LVL_SHFT_MSM_GPIO, rc);
- goto vreg_get_fail;
+ goto reg_free;
}
gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
} else {
- for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
- vreg_put(vregs_isa1200[i]);
-
+ regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
gpio_free(HAP_LVL_SHFT_MSM_GPIO);
}
return 0;
-vreg_get_fail:
- while (i)
- vreg_put(vregs_isa1200[--i]);
+
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
+out:
return rc;
}
static struct isa1200_platform_data isa1200_1_pdata = {
@@ -6777,69 +6508,48 @@
}
};
-static const char *vregs_tma300_name[] = {
- "gp6",
- "gp7",
+static struct regulator_bulk_data regs_tma300[] = {
+ { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
+ { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
};
-static const int vregs_tma300_val[] = {
- 3050,
- 1800,
-};
-static struct vreg *vregs_tma300[ARRAY_SIZE(vregs_tma300_name)];
-
static int tma300_power(int vreg_on)
{
- int i, rc = -EINVAL;
+ int rc;
- for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
- /* Never disable gp6 for fluid as lcd has a problem with it */
- if (!i && !vreg_on)
- continue;
- if (!vregs_tma300[i]) {
- printk(KERN_ERR "%s: vreg_get %s failed (%d)\n",
- __func__, vregs_tma300_name[i], rc);
- return rc;
- }
+ rc = vreg_on ?
+ regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
+ regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
- rc = vreg_on ? vreg_enable(vregs_tma300[i]) :
- vreg_disable(vregs_tma300[i]);
- if (rc < 0) {
- printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
- __func__, vregs_tma300_name[i],
- vreg_on ? "enable" : "disable", rc);
- return rc;
- }
- }
-
- return 0;
+ if (rc)
+ pr_err("%s: could not %sable regulators: %d\n",
+ __func__, vreg_on ? "en" : "dis", rc);
+ return rc;
}
#define TS_GPIO_IRQ 150
static int tma300_dev_setup(bool enable)
{
- int i, rc;
+ int rc;
if (enable) {
- /* get voltage sources */
- for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
- vregs_tma300[i] = vreg_get(NULL, vregs_tma300_name[i]);
- if (IS_ERR(vregs_tma300[i])) {
- pr_err("%s: vreg get %s failed (%ld)\n",
- __func__, vregs_tma300_name[i],
- PTR_ERR(vregs_tma300[i]));
- rc = PTR_ERR(vregs_tma300[i]);
- goto vreg_get_fail;
- }
- rc = vreg_set_level(vregs_tma300[i],
- vregs_tma300_val[i]);
- if (rc) {
- pr_err("%s: vreg_set_level() = %d\n",
+ rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
+ regs_tma300);
+
+ if (rc) {
+ pr_err("%s: could not get regulators: %d\n",
__func__, rc);
- i++;
- goto vreg_get_fail;
- }
+ goto out;
+ }
+
+ rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
+ regs_tma300);
+
+ if (rc) {
+ pr_err("%s: could not set voltages: %d\n",
+ __func__, rc);
+ goto reg_free;
}
/* enable interrupt gpio */
@@ -6848,7 +6558,7 @@
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, TS_GPIO_IRQ);
- goto vreg_get_fail;
+ goto reg_free;
}
/* virtual keys */
@@ -6856,23 +6566,20 @@
properties_kobj = kobject_create_and_add("board_properties",
NULL);
if (!properties_kobj) {
- pr_err("%s: failed to create a kobject"
- "for board_properites\n", __func__);
+ pr_err("%s: failed to create a kobject "
+ "for board_properties\n", __func__);
rc = -ENOMEM;
- goto vreg_get_fail;
+ goto reg_free;
}
rc = sysfs_create_group(properties_kobj,
&tma300_properties_attr_group);
if (rc) {
pr_err("%s: failed to create a sysfs entry %s\n",
__func__, tma300_vkeys_attr.attr.name);
- kobject_put(properties_kobj);
- goto vreg_get_fail;
+ goto kobj_free;
}
} else {
- /* put voltage sources */
- for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++)
- vreg_put(vregs_tma300[i]);
+ regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
/* destroy virtual keys */
if (properties_kobj) {
sysfs_remove_group(properties_kobj,
@@ -6882,9 +6589,12 @@
}
return 0;
-vreg_get_fail:
- while (i)
- vreg_put(vregs_tma300[--i]);
+kobj_free:
+ kobject_put(properties_kobj);
+ properties_kobj = NULL;
+reg_free:
+ regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
+out:
return rc;
}
@@ -6995,6 +6705,9 @@
ARRAY_SIZE(lcdc_toshiba_spi_board_info));
#endif
+ atv_dac_power_init();
+ sensors_ldo_init();
+ hdmi_init_regs();
msm_fb_add_devices();
msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
BUG_ON(msm_pm_boot_init(MSM_PM_BOOT_CONFIG_RESET_VECTOR,
@@ -7005,6 +6718,7 @@
msm7x30_init_marimba();
#ifdef CONFIG_MSM7KV2_AUDIO
snddev_poweramp_gpio_init();
+ snddev_hsed_voltage_init();
aux_pcm_gpio_init();
#endif