* [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators
@ 2012-06-28 10:29 Guennadi Liakhovetski
2012-06-28 14:17 ` Paul Mundt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-06-28 10:29 UTC (permalink / raw)
To: linux-sh
Power on the CN11 and CN12 SD/MMC slots on ecovec is controlled by GPIOs,
which makes it possible to use the fixed voltage regulator driver to switch
card power on and off.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
On Thu, 28 Jun 2012, Paul Mundt wrote:
> This doesn't match what is in the tree, so I have no idea what tree you
> are working on. It fails to apply because of the down_pwr thing upstream
> which doesn't exist in your patchset, and I'm certainly not going to
> track it down.
v3: Right, sorry, there was one more ecovec patch, that I'd posted
earlier, but it's ok to wait with that one. Now rebased without it.
> Next time you send a patch series, make sure it actually applies to the
> dependencies that you have written out, instead of some hypothetical tree
> combination that needs to be reverse engineered.
Sure, was a glitch on my side, sorry.
> The rest are applied. At least now you can go back and make those changes
> to the patch while figuring out what tree you're working on.
Thanks!
Guennadi
arch/sh/boards/mach-ecovec24/setup.c | 117 +++++++++++++++++++++++++++++-----
1 files changed, 100 insertions(+), 17 deletions(-)
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 4158d70..a06c5c8 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -19,6 +19,8 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/delay.h>
+#include <linux/regulator/fixed.h>
+#include <linux/regulator/machine.h>
#include <linux/usb/r8a66597.h>
#include <linux/usb/renesas_usbhs.h>
#include <linux/i2c.h>
@@ -518,10 +520,86 @@ static struct i2c_board_info ts_i2c_clients = {
.irq = IRQ0,
};
+static struct regulator_consumer_supply cn12_power_consumers[] +{
+ REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
+ REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
+ REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
+ REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
+};
+
+static struct regulator_init_data cn12_power_init_data = {
+ .constraints = {
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers),
+ .consumer_supplies = cn12_power_consumers,
+};
+
+static struct fixed_voltage_config cn12_power_info = {
+ .supply_name = "CN12 SD/MMC Vdd",
+ .microvolts = 3300000,
+ .gpio = GPIO_PTB7,
+ .enable_high = 1,
+ .init_data = &cn12_power_init_data,
+};
+
+static struct platform_device cn12_power = {
+ .name = "reg-fixed-voltage",
+ .id = 0,
+ .dev = {
+ .platform_data = &cn12_power_info,
+ },
+};
+
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
/* SDHI0 */
+static struct regulator_consumer_supply sdhi0_power_consumers[] +{
+ REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
+ REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
+};
+
+static struct regulator_init_data sdhi0_power_init_data = {
+ .constraints = {
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers),
+ .consumer_supplies = sdhi0_power_consumers,
+};
+
+static struct fixed_voltage_config sdhi0_power_info = {
+ .supply_name = "CN11 SD/MMC Vdd",
+ .microvolts = 3300000,
+ .gpio = GPIO_PTB6,
+ .enable_high = 1,
+ .init_data = &sdhi0_power_init_data,
+};
+
+static struct platform_device sdhi0_power = {
+ .name = "reg-fixed-voltage",
+ .id = 1,
+ .dev = {
+ .platform_data = &sdhi0_power_info,
+ },
+};
+
static void sdhi0_set_pwr(struct platform_device *pdev, int state)
{
+ static int power_gpio = -EINVAL;
+
+ if (power_gpio < 0) {
+ int ret = gpio_request(GPIO_PTB6, NULL);
+ if (!ret) {
+ power_gpio = GPIO_PTB6;
+ gpio_direction_output(power_gpio, 0);
+ }
+ }
+
+ /*
+ * Toggle the GPIO regardless, whether we managed to grab it above or
+ * the fixed regulator driver did.
+ */
gpio_set_value(GPIO_PTB6, state);
}
@@ -562,13 +640,27 @@ static struct platform_device sdhi0_device = {
},
};
-#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
-/* SDHI1 */
-static void sdhi1_set_pwr(struct platform_device *pdev, int state)
+static void cn12_set_pwr(struct platform_device *pdev, int state)
{
+ static int power_gpio = -EINVAL;
+
+ if (power_gpio < 0) {
+ int ret = gpio_request(GPIO_PTB7, NULL);
+ if (!ret) {
+ power_gpio = GPIO_PTB7;
+ gpio_direction_output(power_gpio, 0);
+ }
+ }
+
+ /*
+ * Toggle the GPIO regardless, whether we managed to grab it above or
+ * the fixed regulator driver did.
+ */
gpio_set_value(GPIO_PTB7, state);
}
+#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+/* SDHI1 */
static int sdhi1_get_cd(struct platform_device *pdev)
{
return !gpio_get_value(GPIO_PTW7);
@@ -579,7 +671,7 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
.dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
.tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
MMC_CAP_NEEDS_POLL,
- .set_pwr = sdhi1_set_pwr,
+ .set_pwr = cn12_set_pwr,
.get_cd = sdhi1_get_cd,
};
@@ -899,14 +991,9 @@ static struct platform_device vou_device = {
#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
/* SH_MMCIF */
-static void mmcif_set_pwr(struct platform_device *pdev, int state)
-{
- gpio_set_value(GPIO_PTB7, state);
-}
-
static void mmcif_down_pwr(struct platform_device *pdev)
{
- gpio_set_value(GPIO_PTB7, 0);
+ cn12_set_pwr(pdev, 0);
}
static struct resource sh_mmcif_resources[] = {
@@ -929,7 +1016,7 @@ static struct resource sh_mmcif_resources[] = {
};
static struct sh_mmcif_plat_data sh_mmcif_plat = {
- .set_pwr = mmcif_set_pwr,
+ .set_pwr = cn12_set_pwr,
.down_pwr = mmcif_down_pwr,
.sup_pclk = 0, /* SH7724: Max Pclk/2 */
.caps = MMC_CAP_4_BIT_DATA |
@@ -960,7 +1047,9 @@ static struct platform_device *ecovec_devices[] __initdata = {
&ceu0_device,
&ceu1_device,
&keysc_device,
+ &cn12_power,
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
+ &sdhi0_power,
&sdhi0_device,
#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
&sdhi1_device,
@@ -1258,8 +1347,6 @@ static int __init arch_setup(void)
gpio_request(GPIO_FN_SDHI0D2, NULL);
gpio_request(GPIO_FN_SDHI0D1, NULL);
gpio_request(GPIO_FN_SDHI0D0, NULL);
- gpio_request(GPIO_PTB6, NULL);
- gpio_direction_output(GPIO_PTB6, 0);
#else
/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
@@ -1288,8 +1375,6 @@ static int __init arch_setup(void)
gpio_request(GPIO_FN_MMC_D0, NULL);
gpio_request(GPIO_FN_MMC_CLK, NULL);
gpio_request(GPIO_FN_MMC_CMD, NULL);
- gpio_request(GPIO_PTB7, NULL);
- gpio_direction_output(GPIO_PTB7, 0);
cn12_enabled = true;
#elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
@@ -1301,8 +1386,6 @@ static int __init arch_setup(void)
gpio_request(GPIO_FN_SDHI1D2, NULL);
gpio_request(GPIO_FN_SDHI1D1, NULL);
gpio_request(GPIO_FN_SDHI1D0, NULL);
- gpio_request(GPIO_PTB7, NULL);
- gpio_direction_output(GPIO_PTB7, 0);
/* Card-detect, used on CN12 with SDHI1 */
gpio_request(GPIO_PTW7, NULL);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators
2012-06-28 10:29 [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators Guennadi Liakhovetski
@ 2012-06-28 14:17 ` Paul Mundt
2012-06-28 14:28 ` Guennadi Liakhovetski
2012-06-28 14:52 ` Paul Mundt
2 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2012-06-28 14:17 UTC (permalink / raw)
To: linux-sh
On Thu, Jun 28, 2012 at 12:29:46PM +0200, Guennadi Liakhovetski wrote:
> Power on the CN11 and CN12 SD/MMC slots on ecovec is controlled by GPIOs,
> which makes it possible to use the fixed voltage regulator driver to switch
> card power on and off.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Applied now, though you still didn't make the dev_name() changes for
gpio_request().
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators
2012-06-28 10:29 [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators Guennadi Liakhovetski
2012-06-28 14:17 ` Paul Mundt
@ 2012-06-28 14:28 ` Guennadi Liakhovetski
2012-06-28 14:52 ` Paul Mundt
2 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-06-28 14:28 UTC (permalink / raw)
To: linux-sh
On Thu, 28 Jun 2012, Paul Mundt wrote:
> On Thu, Jun 28, 2012 at 12:29:46PM +0200, Guennadi Liakhovetski wrote:
> > Power on the CN11 and CN12 SD/MMC slots on ecovec is controlled by GPIOs,
> > which makes it possible to use the fixed voltage regulator driver to switch
> > card power on and off.
> >
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> Applied now,
Thanks
> though you still didn't make the dev_name() changes for
> gpio_request().
I can submit that as a separate patch, though, that doesn't change much -
those functions will disappear anyway as soon as the MMC drivers are
updated to use regulators.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators
2012-06-28 10:29 [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators Guennadi Liakhovetski
2012-06-28 14:17 ` Paul Mundt
2012-06-28 14:28 ` Guennadi Liakhovetski
@ 2012-06-28 14:52 ` Paul Mundt
2 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2012-06-28 14:52 UTC (permalink / raw)
To: linux-sh
On Thu, Jun 28, 2012 at 04:28:19PM +0200, Guennadi Liakhovetski wrote:
> On Thu, 28 Jun 2012, Paul Mundt wrote:
>
> > On Thu, Jun 28, 2012 at 12:29:46PM +0200, Guennadi Liakhovetski wrote:
> > > Power on the CN11 and CN12 SD/MMC slots on ecovec is controlled by GPIOs,
> > > which makes it possible to use the fixed voltage regulator driver to switch
> > > card power on and off.
> > >
> > > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> >
> > Applied now,
>
> Thanks
>
> > though you still didn't make the dev_name() changes for
> > gpio_request().
>
> I can submit that as a separate patch, though, that doesn't change much -
> those functions will disappear anyway as soon as the MMC drivers are
> updated to use regulators.
>
Ah, ok, then don't worry about it. Not much point if it's going away at
least.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-28 14:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 10:29 [PATCH 01/13 v3] sh: ecovec: switch MMC power control to regulators Guennadi Liakhovetski
2012-06-28 14:17 ` Paul Mundt
2012-06-28 14:28 ` Guennadi Liakhovetski
2012-06-28 14:52 ` Paul Mundt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.