aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBalaji Rao <balajirrao@openmoko.org>2008-11-20 19:46:50 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-20 19:46:50 +0000
commitf00ed35e0335f26e45405eb82776cef1d76ee5f3 (patch)
treedc925a8d462428122efdab66418def1bdc3c2f82 /drivers
parent1552c51b244b71d57b73edef14047682e70717ca (diff)
glamo_mci_use_regulator_api.patch
Changes the glamo-mci driver to use the regulator API.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/glamo/glamo-core.c28
-rw-r--r--drivers/mfd/glamo/glamo-core.h3
-rw-r--r--drivers/mfd/glamo/glamo-mci.c41
-rw-r--r--drivers/mfd/glamo/glamo-mci.h3
4 files changed, 55 insertions, 20 deletions
diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
index b7184a38c31..b4595a8202d 100644
--- a/drivers/mfd/glamo/glamo-core.c
+++ b/drivers/mfd/glamo/glamo-core.c
@@ -288,15 +288,9 @@ static struct resource glamo_mmc_resources[] = {
},
};
-static struct platform_device glamo_mmc_dev = {
- .name = "glamo-mci",
- .resource = glamo_mmc_resources,
- .num_resources = ARRAY_SIZE(glamo_mmc_resources),
-};
-
struct glamo_mci_pdata glamo_mci_def_pdata = {
.gpio_detect = 0,
- .glamo_set_mci_power = NULL, /* filled in from MFD platform data */
+ .glamo_can_set_mci_power = NULL, /* filled in from MFD platform data */
.ocr_avail = MMC_VDD_20_21 |
MMC_VDD_21_22 |
MMC_VDD_22_23 |
@@ -1153,6 +1147,7 @@ static int __init glamo_probe(struct platform_device *pdev)
{
int rc = 0, irq;
struct glamo_core *glamo;
+ struct platform_device *glamo_mmc_dev;
if (glamo_handle) {
dev_err(&pdev->dev,
@@ -1247,8 +1242,8 @@ static int __init glamo_probe(struct platform_device *pdev)
glamo_pll_rate(glamo, GLAMO_PLL2));
/* bring MCI specific stuff over from our MFD platform data */
- glamo_mci_def_pdata.glamo_set_mci_power =
- glamo->pdata->glamo_set_mci_power;
+ glamo_mci_def_pdata.glamo_can_set_mci_power =
+ glamo->pdata->glamo_can_set_mci_power;
glamo_mci_def_pdata.glamo_mci_use_slow =
glamo->pdata->glamo_mci_use_slow;
glamo_mci_def_pdata.glamo_irq_is_wired =
@@ -1288,12 +1283,17 @@ static int __init glamo_probe(struct platform_device *pdev)
glamo_spigpio_dev.dev.platform_data = glamo->pdata->spigpio_info;
platform_device_register(&glamo_spigpio_dev);
- glamo_mmc_dev.dev.parent = &pdev->dev;
+ glamo_mmc_dev = glamo->pdata->mmc_dev;
+ glamo_mmc_dev->name = "glamo-mci";
+ glamo_mmc_dev->dev.parent = &pdev->dev;
+ glamo_mmc_dev->resource = glamo_mmc_resources;
+ glamo_mmc_dev->num_resources = ARRAY_SIZE(glamo_mmc_resources);
+
/* we need it later to give to the engine enable and disable */
glamo_mci_def_pdata.pglamo = glamo;
- mangle_mem_resources(glamo_mmc_dev.resource,
- glamo_mmc_dev.num_resources, glamo->mem);
- platform_device_register(&glamo_mmc_dev);
+ mangle_mem_resources(glamo_mmc_dev->resource,
+ glamo_mmc_dev->num_resources, glamo->mem);
+ platform_device_register(glamo_mmc_dev);
/* only request the generic, hostbus and memory controller MMIO */
glamo->mem = request_mem_region(glamo->mem->start,
@@ -1338,7 +1338,7 @@ static int glamo_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
platform_device_unregister(&glamo_fb_dev);
- platform_device_unregister(&glamo_mmc_dev);
+ platform_device_unregister(glamo->pdata->mmc_dev);
iounmap(glamo->base);
release_mem_region(glamo->mem->start, GLAMO_REGOFS_VIDCAP);
glamo_handle = NULL;
diff --git a/drivers/mfd/glamo/glamo-core.h b/drivers/mfd/glamo/glamo-core.h
index 0705204c6bb..8e09564bc3f 100644
--- a/drivers/mfd/glamo/glamo-core.h
+++ b/drivers/mfd/glamo/glamo-core.h
@@ -68,8 +68,7 @@ struct glamo_mci_pdata {
unsigned int gpio_detect;
unsigned int gpio_wprotect;
unsigned long ocr_avail;
- void (*glamo_set_mci_power)(unsigned char power_mode,
- unsigned short vdd);
+ int (*glamo_can_set_mci_power)(void);
/* glamo-mci asking if it should use the slow clock to card */
int (*glamo_mci_use_slow)(void);
int (*glamo_irq_is_wired)(void);
diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
index 00e3c5c5ccd..5079796ba28 100644
--- a/drivers/mfd/glamo/glamo-mci.c
+++ b/drivers/mfd/glamo/glamo-mci.c
@@ -757,13 +757,24 @@ static void glamo_mci_reset(struct glamo_mci_host *host)
glamo_mci_def_pdata.pglamo->base + GLAMO_REG_CLOCK_MMC);
}
#endif
+static inline int glamo_mci_get_mv(int vdd)
+{
+ int mv = 1650;
+
+ if (vdd > 7)
+ mv += 350 + 100 * (vdd - 8);
+
+ return mv;
+}
static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct glamo_mci_host *host = mmc_priv(mmc);
+ struct regulator *regulator;
int n = 0;
int div;
int powering = 0;
+ int mv;
if (host->suspending) {
dev_err(&host->pdev->dev, "IGNORING glamo_mci_set_ios while "
@@ -771,10 +782,18 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
return;
}
+ regulator = host->regulator;
+
/* Set power */
switch(ios->power_mode) {
- case MMC_POWER_ON:
case MMC_POWER_UP:
+ if (host->pdata->glamo_can_set_mci_power()) {
+ mv = glamo_mci_get_mv(ios->vdd);
+ regulator_set_voltage(regulator, mv * 1000, mv * 1000);
+ regulator_enable(regulator);
+ }
+ break;
+ case MMC_POWER_ON:
/*
* we should use very slow clock until first bulk
* transfer completes OK
@@ -782,8 +801,11 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
host->force_slow_during_powerup = 1;
if (host->vdd_current != ios->vdd) {
- host->pdata->glamo_set_mci_power(ios->power_mode,
- ios->vdd);
+ if (host->pdata->glamo_can_set_mci_power()) {
+ mv = glamo_mci_get_mv(ios->vdd);
+ regulator_set_voltage(regulator, mv * 1000, mv * 1000);
+ printk(KERN_INFO "SD power -> %dmV\n", mv);
+ }
host->vdd_current = ios->vdd;
}
if (host->power_mode_current == MMC_POWER_OFF) {
@@ -802,7 +824,7 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
glamo_engine_disable(glamo_mci_def_pdata.pglamo,
GLAMO_ENGINE_MMC);
- host->pdata->glamo_set_mci_power(MMC_POWER_OFF, 0);
+ regulator_disable(regulator);
host->vdd_current = -1;
break;
}
@@ -907,6 +929,12 @@ static int glamo_mci_probe(struct platform_device *pdev)
goto probe_free_mem_region;
}
+ host->regulator = regulator_get(&pdev->dev, "SD_3V3");
+ if (!host->regulator) {
+ dev_err(&pdev->dev, "Cannot proceed without regulator.\n");
+ return -ENODEV;
+ }
+
/* set the handler for our bit of the shared chip irq register */
set_irq_handler(IRQ_GLAMO(GLAMO_IRQIDX_MMC), glamo_mci_irq);
/* stash host as our handler's private data */
@@ -994,6 +1022,7 @@ static int glamo_mci_remove(struct platform_device *pdev)
{
struct mmc_host *mmc = platform_get_drvdata(pdev);
struct glamo_mci_host *host = mmc_priv(mmc);
+ struct regulator *regulator;
mmc_remove_host(mmc);
/* stop using our handler, revert it to default */
@@ -1002,6 +1031,10 @@ static int glamo_mci_remove(struct platform_device *pdev)
iounmap(host->base_data);
release_mem_region(host->mem->start, RESSIZE(host->mem));
release_mem_region(host->mem_data->start, RESSIZE(host->mem_data));
+
+ regulator = host->regulator;
+ regulator_put(regulator);
+
mmc_free_host(mmc);
glamo_engine_disable(glamo_mci_def_pdata.pglamo, GLAMO_ENGINE_MMC);
diff --git a/drivers/mfd/glamo/glamo-mci.h b/drivers/mfd/glamo/glamo-mci.h
index 38f6376f438..bd62e9aa3c6 100644
--- a/drivers/mfd/glamo/glamo-mci.h
+++ b/drivers/mfd/glamo/glamo-mci.h
@@ -10,6 +10,7 @@
* published by the Free Software Foundation.
*/
+#include <linux/regulator/consumer.h>
enum glamo_mci_waitfor {
COMPLETION_NONE,
@@ -77,4 +78,6 @@ struct glamo_mci_host {
unsigned int ccnt, dcnt;
struct tasklet_struct pio_tasklet;
+
+ struct regulator *regulator;
};