linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch
@ 2013-04-30 14:03 Balaji T K
  2013-04-30 14:03 ` [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
                   ` (12 more replies)
  0 siblings, 13 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

This patch series adds omap-hsmmc-control driver to handle omap control module
mmc registers for devicetree boot.
These control module registers are needed for mmc pbias i/o, speed mode
configuration of mmc1 and loopback clock configuration of mmc2.

With voltage switch support (pbias i/o) added for dt, enhance regulator
deferred probe handling by adding needs_vmmc and needs_vmmc_aux to indicate
whether regulator is applicable so that omap_hsmmc can handle regulator
deferred probe error properly.
Remove the assumption that vmmc_aux regulator to be present only if vmmc is
available. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
in such cases vmmc regulator needed not be specified in board file.

Add omap-hsmmc-control data to omap dts files.

Balaji T K (13):
  ARM: OMAP2+: add needs_vmmc to hsmmc_info
  mmc: omap_hsmmc: make vcc and vcc_aux independent
  mmc: omap_hsmmc: use needs_vmmc
  mmc: omap_hsmmc: update needs_vmmc for dt
  mmc: omap_hsmmc: remove use_reg
  mmc: omap_hsmmc: add dt pbias and control mmc support
  mmc: omap_hsmmc: remove dt pbias workaround
  Documentation: dt: mmc: omap hsmmc
  ARM: dts: omap3: Add omap control mmc data
  ARM: dts: omap36xx: Add omap control mmc data
  ARM: dts: omap4: Add omap control mmc data
  ARM: dts: omap5: Add omap control mmc data
  ARM: dts: am3517: add omap_control_mmc

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |   34 ++
 arch/arm/boot/dts/am3517-evm.dts                   |   20 +
 arch/arm/boot/dts/am3517_mt_ventoux.dts            |   20 +
 arch/arm/boot/dts/omap3.dtsi                       |   17 +
 arch/arm/boot/dts/omap36xx.dtsi                    |    7 +
 arch/arm/boot/dts/omap4.dtsi                       |    9 +
 arch/arm/boot/dts/omap5.dtsi                       |    8 +
 arch/arm/mach-omap2/board-2430sdp.c                |    1 +
 arch/arm/mach-omap2/board-3430sdp.c                |    3 +
 arch/arm/mach-omap2/board-4430sdp.c                |    3 +
 arch/arm/mach-omap2/board-cm-t35.c                 |    2 +
 arch/arm/mach-omap2/board-devkit8000.c             |    1 +
 arch/arm/mach-omap2/board-igep0020.c               |    3 +
 arch/arm/mach-omap2/board-ldp.c                    |    1 +
 arch/arm/mach-omap2/board-omap3beagle.c            |    2 +
 arch/arm/mach-omap2/board-omap3evm.c               |    3 +
 arch/arm/mach-omap2/board-omap3logic.c             |    1 +
 arch/arm/mach-omap2/board-omap3pandora.c           |    3 +
 arch/arm/mach-omap2/board-omap3stalker.c           |    2 +
 arch/arm/mach-omap2/board-omap3touchbook.c         |    2 +
 arch/arm/mach-omap2/board-omap4panda.c             |    2 +
 arch/arm/mach-omap2/board-overo.c                  |    1 +
 arch/arm/mach-omap2/board-rm680.c                  |    1 +
 arch/arm/mach-omap2/board-rx51-peripherals.c       |    3 +
 arch/arm/mach-omap2/board-zoom-peripherals.c       |    4 +
 arch/arm/mach-omap2/hsmmc.c                        |    2 +
 arch/arm/mach-omap2/hsmmc.h                        |    2 +
 drivers/mmc/host/Makefile                          |    2 +-
 drivers/mmc/host/omap_hsmmc.c                      |  138 ++++---
 drivers/mmc/host/omap_hsmmc_control.c              |  466 ++++++++++++++++++++
 include/linux/platform_data/mmc-omap.h             |   20 +
 31 files changed, 729 insertions(+), 54 deletions(-)
 create mode 100644 drivers/mmc/host/omap_hsmmc_control.c

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 02/13] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add needs_vmmc and needs_vmmc_aux to indicate whether regulator is
applicable so that omap_hsmmc can handle regulator deferred probe error
properly.
Remove the assumption that vmmc_aux regulator to be available only if vmmc is
present. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
in such cases regulator needed not be specified in board file.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/mach-omap2/board-2430sdp.c          |    1 +
 arch/arm/mach-omap2/board-3430sdp.c          |    3 +++
 arch/arm/mach-omap2/board-4430sdp.c          |    3 +++
 arch/arm/mach-omap2/board-cm-t35.c           |    2 ++
 arch/arm/mach-omap2/board-devkit8000.c       |    1 +
 arch/arm/mach-omap2/board-igep0020.c         |    3 +++
 arch/arm/mach-omap2/board-ldp.c              |    1 +
 arch/arm/mach-omap2/board-omap3beagle.c      |    2 ++
 arch/arm/mach-omap2/board-omap3evm.c         |    3 +++
 arch/arm/mach-omap2/board-omap3logic.c       |    1 +
 arch/arm/mach-omap2/board-omap3pandora.c     |    3 +++
 arch/arm/mach-omap2/board-omap3stalker.c     |    2 ++
 arch/arm/mach-omap2/board-omap3touchbook.c   |    2 ++
 arch/arm/mach-omap2/board-omap4panda.c       |    2 ++
 arch/arm/mach-omap2/board-overo.c            |    1 +
 arch/arm/mach-omap2/board-rm680.c            |    1 +
 arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +++
 arch/arm/mach-omap2/board-zoom-peripherals.c |    4 ++++
 arch/arm/mach-omap2/hsmmc.c                  |    2 ++
 arch/arm/mach-omap2/hsmmc.h                  |    2 ++
 include/linux/platform_data/mmc-omap.h       |    2 ++
 21 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index a3e0aaa..538dd55 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -242,6 +242,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.ext_clock	= 1,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index ce812de..6432227 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -201,12 +201,15 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 4,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.mmc		= 2,
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 7,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 35f3ad0..c28ce4e 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -461,12 +461,14 @@ static struct omap2_hsmmc_info mmc[] = {
 		.nonremovable   = true,
 		.ocr_mask	= MMC_VDD_29_30,
 		.no_off_init	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 1,
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 5,
@@ -476,6 +478,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.ocr_mask	= MMC_VDD_165_195,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index af2bb21..f616961 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -407,6 +407,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.mmc		= 2,
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 53056c3..fc02ab1 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -100,6 +100,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 29,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index bf92678..0c71f90 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -284,6 +284,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
 	{
@@ -291,6 +292,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 #endif
 	{}      /* Terminator */
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index b12fe96..770f5bc 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -358,6 +358,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index c3558f9..a81087c 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -263,6 +263,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 48789e0..6eb29c2 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -309,6 +309,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= 63,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 #ifdef CONFIG_WILINK_PLATFORM_DATA
 	{
@@ -318,6 +320,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.gpio_cd	= -EINVAL,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 #endif
 	{}	/* Terminator */
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index bab51e6..ff00c81 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -104,6 +104,7 @@ static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{}      /* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 2bba362..4c1d646 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -278,6 +278,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.gpio_wp	= 126,
 		.ext_clock	= 0,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 2,
@@ -287,6 +288,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.ext_clock	= 1,
 		.transceiver	= true,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 3,
@@ -294,6 +296,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.init_card	= pandora_wl1251_init_card,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index 95c10b3..b445a1a 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -184,6 +184,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= 23,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	 },
 	{}			/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index bcd44fb..d8a1ca3 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -103,6 +103,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 29,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index b02c2f0..f9eaa7b 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -199,6 +199,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= -EINVAL,
 		.gpio_cd	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{
 		.name		= "wl1271",
@@ -208,6 +209,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.ocr_mask	= MMC_VDD_165_195,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 86bab51..b5874e9 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -285,6 +285,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 2,
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 345e8c4..9d4bcc1 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -106,6 +106,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{ /* Terminator */ }
 };
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 3a077df..ef36a5e 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -496,6 +496,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.gpio_cd	= 160,
 		.gpio_wp	= -EINVAL,
 		.power_saving	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.name		= "internal",
@@ -507,6 +508,8 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.nonremovable	= true,
 		.power_saving	= true,
 		.remux		= rx51_mmc2_remux,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index cdc0c10..deab49c 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -205,6 +205,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.power_saving	= true,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.name		= "internal",
@@ -214,6 +216,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.nonremovable	= true,
 		.power_saving	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.name		= "wl1271",
@@ -222,6 +225,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.gpio_cd	= -EINVAL,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 	{}      /* Terminator */
 };
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 2ef1f87..9e8b02c 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -313,6 +313,8 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
 								c->mmc, 1);
 	mmc->slots[0].name = hc_name;
 	mmc->nr_slots = 1;
+	mmc->needs_vmmc = c->needs_vmmc;
+	mmc->needs_vmmc_aux = c->needs_vmmc_aux;
 	mmc->slots[0].caps = c->caps;
 	mmc->slots[0].pm_caps = c->pm_caps;
 	mmc->slots[0].internal_clock = !c->ext_clock;
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index 7f2e790..9bc71ee 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -33,6 +33,8 @@ struct omap2_hsmmc_info {
 	void (*remux)(struct device *dev, int slot, int power_on);
 	/* init some special card */
 	void (*init_card)(struct mmc_card *card);
+	unsigned needs_vmmc:1;
+	unsigned needs_vmmc_aux:1;
 };
 
 #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
index 2bf1b30..11583a6 100644
--- a/include/linux/platform_data/mmc-omap.h
+++ b/include/linux/platform_data/mmc-omap.h
@@ -66,6 +66,8 @@ struct omap_mmc_platform_data {
 
 	/* Register offset deviation */
 	u16 reg_offset;
+	unsigned needs_vmmc:1;
+	unsigned needs_vmmc_aux:1;
 
 	struct omap_mmc_slot_data {
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 02/13] mmc: omap_hsmmc: make vcc and vcc_aux independent
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
  2013-04-30 14:03 ` [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc Balaji T K
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

handle vcc and vcc_aux independently

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index bc58078..7e122a9 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -252,7 +252,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * If we don't see a Vcc regulator, assume it's a fixed
 	 * voltage always-on regulator.
 	 */
-	if (!host->vcc)
+	if (!host->vcc && !host->vcc_aux)
 		return 0;
 	/*
 	 * With DT, never turn OFF the regulator. This is because
@@ -279,11 +279,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * chips/cards need an interface voltage rail too.
 	 */
 	if (power_on) {
-		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		if (host->vcc)
+			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
 		/* Enable interface voltage rail, if needed */
 		if (ret == 0 && host->vcc_aux) {
 			ret = regulator_enable(host->vcc_aux);
-			if (ret < 0)
+			if (ret < 0 && host->vcc)
 				ret = mmc_regulator_set_ocr(host->mmc,
 							host->vcc, 0);
 		}
@@ -291,7 +292,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		/* Shut down the rail */
 		if (host->vcc_aux)
 			ret = regulator_disable(host->vcc_aux);
-		if (!ret) {
+		if (host->vcc) {
 			/* Then proceed to shut down the local regulator */
 			ret = mmc_regulator_set_ocr(host->mmc,
 						host->vcc, 0);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
  2013-04-30 14:03 ` [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
  2013-04-30 14:03 ` [PATCH 02/13] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 04/13] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Use needs_vmmc/needs_vmmc_aux to check whether
regulator is mandatory and handle regulator errors
like EPROBE_DEFER properly

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   65 ++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 7e122a9..4f7ca7a 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -183,6 +183,8 @@ struct omap_hsmmc_host {
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
+	int needs_vmmc:1;
+	int needs_vmmc_aux:1;
 };
 
 static int omap_hsmmc_card_detect(struct device *dev, int slot)
@@ -311,11 +313,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	int ocr_value = 0;
 
 	reg = regulator_get(host->dev, "vmmc");
-	if (IS_ERR(reg)) {
-		dev_err(host->dev, "vmmc regulator missing\n");
+	if (IS_ERR(reg) && host->needs_vmmc) {
+		dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+			PTR_ERR(reg));
 		return PTR_ERR(reg);
-	} else {
-		mmc_slot(host).set_power = omap_hsmmc_set_power;
+	}
+	mmc_slot(host).set_power = omap_hsmmc_set_power;
+	if (!IS_ERR(reg)) {
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {
@@ -328,31 +332,33 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 				return -EINVAL;
 			}
 		}
+	}
 
-		/* Allow an aux regulator */
-		reg = regulator_get(host->dev, "vmmc_aux");
-		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
-
-		/* For eMMC do not power off when not in sleep state */
-		if (mmc_slot(host).no_regulator_off_init)
-			return 0;
-		/*
-		* UGLY HACK:  workaround regulator framework bugs.
-		* When the bootloader leaves a supply active, it's
-		* initialized with zero usecount ... and we can't
-		* disable it without first enabling it.  Until the
-		* framework is fixed, we need a workaround like this
-		* (which is safe for MMC, but not in general).
-		*/
-		if (regulator_is_enabled(host->vcc) > 0 ||
-		    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
-			int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+	/* Allow an aux regulator */
+	reg = regulator_get(host->dev, "vmmc_aux");
+	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
+	if (IS_ERR(reg) && host->needs_vmmc_aux) {
+		dev_err(host->dev, "unable to get vmmc_aux regulator %ld\n",
+			PTR_ERR(reg));
+		return PTR_ERR(reg);
+	}
 
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 1, vdd);
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 0, 0);
-		}
+	/* For eMMC do not power off when not in sleep state */
+	if (mmc_slot(host).no_regulator_off_init ||
+	    (!host->needs_vmmc && !host->needs_vmmc_aux))
+		return 0;
+	/*
+	 * To disable boot_on regulator, enable regulator
+	 * to increase usecount and then disable it.
+	 */
+	if (regulator_is_enabled(host->vcc) > 0 ||
+	    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
+		int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+
+		mmc_slot(host).set_power(host->dev, host->slot_id,
+					 1, vdd);
+		mmc_slot(host).set_power(host->dev, host->slot_id,
+					 0, 0);
 	}
 
 	return 0;
@@ -1822,6 +1828,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
+	host->needs_vmmc = pdata->needs_vmmc;
+	host->needs_vmmc_aux = pdata->needs_vmmc_aux;
 
 	platform_set_drvdata(pdev, host);
 
@@ -1949,7 +1957,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) {
 		ret = omap_hsmmc_reg_get(host);
 		if (ret)
-			goto err_reg;
+			goto err_irq_cd;
 		host->use_reg = 1;
 	}
 
@@ -2006,7 +2014,6 @@ err_slot_name:
 err_irq_cd:
 	if (host->use_reg)
 		omap_hsmmc_reg_put(host);
-err_reg:
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 err_irq_cd_init:
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 04/13] mmc: omap_hsmmc: update needs_vmmc for dt
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (2 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 05/13] mmc: omap_hsmmc: remove use_reg Balaji T K
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

update needs_vmmc, needs_vmmc_aux for dt boot

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 4f7ca7a..5fd78b2 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1756,6 +1756,9 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
 	if (of_find_property(np, "ti,needs-special-hs-handling", NULL))
 		pdata->slots[0].features |= HSMMC_HAS_HSPE_SUPPORT;
 
+	pdata->needs_vmmc = of_property_read_bool(np, "vmmc-supply");
+	pdata->needs_vmmc_aux = of_property_read_bool(np, "vmmc_aux-supply");
+
 	return pdata;
 }
 #else
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 05/13] mmc: omap_hsmmc: remove use_reg
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (3 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 04/13] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support Balaji T K
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Since regulator_put can handle NULL / IS_ERR(regulator)
use_reg can be removed, so that regulator_put in omap_hsmmc_reg_put
can be reused for vmmc_aux regulator error scenario.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 5fd78b2..6616621 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -178,7 +178,6 @@ struct omap_hsmmc_host {
 	int			context_loss;
 	int			protect_card;
 	int			reqs_blocked;
-	int			use_reg;
 	int			req_in_progress;
 	struct omap_hsmmc_next	next_data;
 
@@ -1961,7 +1960,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		ret = omap_hsmmc_reg_get(host);
 		if (ret)
 			goto err_irq_cd;
-		host->use_reg = 1;
 	}
 
 	mmc->ocr_avail = mmc_slot(host).ocr_mask;
@@ -2015,8 +2013,7 @@ err_slot_name:
 	mmc_remove_host(mmc);
 	free_irq(mmc_slot(host).card_detect_irq, host);
 err_irq_cd:
-	if (host->use_reg)
-		omap_hsmmc_reg_put(host);
+	omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 err_irq_cd_init:
@@ -2053,8 +2050,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
 	pm_runtime_get_sync(host->dev);
 	mmc_remove_host(host->mmc);
-	if (host->use_reg)
-		omap_hsmmc_reg_put(host);
+	omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 	free_irq(host->irq, host);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (4 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 05/13] mmc: omap_hsmmc: remove use_reg Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-05-16 16:16   ` Tony Lindgren
  2013-04-30 14:03 ` [PATCH 07/13] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap_hsmmc_control to support pbias, high speed mode configuration for mmc1,
loopback clock configuration (when external transceiver is used) for mmc2

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/Makefile              |    2 +-
 drivers/mmc/host/omap_hsmmc.c          |   38 +++
 drivers/mmc/host/omap_hsmmc_control.c  |  466 ++++++++++++++++++++++++++++++++
 include/linux/platform_data/mmc-omap.h |   18 ++
 4 files changed, 523 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/host/omap_hsmmc_control.c

diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index c380e3c..5512a05 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -17,7 +17,7 @@ obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
 obj-$(CONFIG_MMC_AU1X)		+= au1xmmc.o
 obj-$(CONFIG_MMC_OMAP)		+= omap.o
-obj-$(CONFIG_MMC_OMAP_HS)	+= omap_hsmmc.o
+obj-$(CONFIG_MMC_OMAP_HS)	+= omap_hsmmc.o omap_hsmmc_control.o
 obj-$(CONFIG_MMC_ATMELMCI)	+= atmel-mci.o
 obj-$(CONFIG_MMC_TIFM_SD)	+= tifm_sd.o
 obj-$(CONFIG_MMC_MSM)		+= msm_sdcc.o
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 6616621..217c063 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -182,6 +182,7 @@ struct omap_hsmmc_host {
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
+	struct omap_hsmmc_control	*ctrl_mmc;
 	int needs_vmmc:1;
 	int needs_vmmc_aux:1;
 };
@@ -265,6 +266,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
+	if (host->ctrl_mmc && host->ctrl_mmc->before)
+		host->ctrl_mmc->before(host->ctrl_mmc->dev, power_on, vdd);
 
 	/*
 	 * Assume Vcc regulator is used only to power the card ... OMAP
@@ -302,6 +305,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 
 	if (mmc_slot(host).after_set_reg)
 		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
+	if (host->ctrl_mmc && host->ctrl_mmc->after)
+		host->ctrl_mmc->after(host->ctrl_mmc->dev, power_on, vdd);
 
 	return ret;
 }
@@ -1760,6 +1765,33 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
 
 	return pdata;
 }
+
+static int omap_hsmmc_get_ctrl_mmc(struct omap_hsmmc_host *host)
+{
+	struct device_node *np = host->dev->of_node;
+	struct device_node *ctrl_np;
+	struct platform_device *ctrl_mmc_pdev;
+	struct omap_hsmmc_control *ctl_mmc;
+
+	ctrl_np = of_parse_phandle(np, "ctrl-module", 0);
+	if (!ctrl_np)
+		return 0;
+
+	ctrl_mmc_pdev = of_find_device_by_node(ctrl_np);
+	if (ctrl_mmc_pdev) {
+		ctl_mmc = platform_get_drvdata(ctrl_mmc_pdev);
+		if (ctl_mmc &&
+		    try_module_get(ctrl_mmc_pdev->dev.driver->owner)) {
+			host->ctrl_mmc = ctl_mmc;
+		} else {
+			dev_err(mmc_dev(host->mmc),
+				"defer probe for omap-hsmmc-control\n");
+			return -EPROBE_DEFER;
+		}
+	}
+
+	return 0;
+}
 #else
 static inline struct omap_mmc_platform_data
 			*of_get_hsmmc_pdata(struct device *dev)
@@ -1834,6 +1866,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->needs_vmmc_aux = pdata->needs_vmmc_aux;
 
 	platform_set_drvdata(pdev, host);
+	ret = omap_hsmmc_get_ctrl_mmc(host);
+	if (ret)
+		goto err_alloc;
 
 	mmc->ops	= &omap_hsmmc_ops;
 
@@ -1956,6 +1991,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (host->ctrl_mmc && host->ctrl_mmc->init)
+		host->ctrl_mmc->init(host->ctrl_mmc->dev);
+
 	if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) {
 		ret = omap_hsmmc_reg_get(host);
 		if (ret)
diff --git a/drivers/mmc/host/omap_hsmmc_control.c b/drivers/mmc/host/omap_hsmmc_control.c
new file mode 100644
index 0000000..0d0ae4d
--- /dev/null
+++ b/drivers/mmc/host/omap_hsmmc_control.c
@@ -0,0 +1,466 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/mmc/host.h>
+#include <linux/platform_data/mmc-omap.h>
+
+#define DRIVER_NAME		"omap-hsmmc-control"
+/* CONTROL_DEVCONF1 bits */
+#define OMAP243X_MMC1_ACTIVE_OVERWRITE	(1 << 31)
+#define OMAP2_MMCSDIO2ADPCLKISEL	(1 << 6) /* MMC2 loop back clock */
+/* CONTROL_DEVCONF0 bits */
+#define OMAP2_MMCSDIO1ADPCLKISEL	(1 << 24) /* MMC1 loop back clock */
+/* CONTROL_PBIAS_LITE bits */
+#define OMAP2_PBIASSPEEDCTRL0		(1 << 2)
+#define OMAP2_PBIASLITEPWRDNZ0		(1 << 1)
+#define OMAP2_PBIASLITEVMODE0		(1 << 0)
+/* CONTROL_PROG_IO1 bits */
+#define OMAP3630_PRG_SDMMC1_SPEEDCTRL	(1 << 20)
+/* OMAP4: CONTROL_PBIASLITE */
+#define OMAP4_MMC1_PWRDNZ_MASK			(1 << 26)
+#define OMAP4_MMC1_PBIASLITE_HIZ_MODE_MASK	(1 << 25)
+#define OMAP4_MMC1_PBIASLITE_SUPPLY_HI_OUT_MASK	(1 << 24)
+#define OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK	(1 << 23)
+#define OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK	(1 << 22)
+#define OMAP4_MMC1_PBIASLITE_VMODE_MASK		(1 << 21)
+/* OMAP4: CONTROL_MMC1 */
+#define OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK	(1 << 31)
+#define OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK	(1 << 30)
+#define OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK	(1 << 29)
+#define OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK	(1 << 28)
+#define OMAP4_SDMMC1_DR0_SPEEDCTRL_MASK		(1 << 27)
+#define OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK		(1 << 26)
+#define OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK		(1 << 25)
+/* OMAP5: CONTROL_PBIAS */
+#define OMAP5_SDCARD_IO_PWRRDNZ		(1 << 26)
+#define OMAP5_SDCARD_BIAS_PWRDNZ	(1 << 27)
+
+#define CTRL_NONE		0
+#define CTRL_MMC1_2430		1
+#define CTRL_MMC2		2
+#define CTRL_MMC1_3430		3
+#define CTRL_MMC1_3630		4
+#define CTRL_MMC1_4430		5
+#define CTRL_MMC2_4430		6
+#define CTRL_MMC1_5430		7
+
+static void omap_control_mmc_writel(u32 reg, u32 *base2)
+{
+	if (base2)
+		__raw_writel(reg, base2);
+	return;
+}
+
+static u32 omap_control_mmc_readl(u32 *base2)
+{
+	u32 pbias_reg = 0;
+
+	if (base2)
+		pbias_reg = __raw_readl(base2);
+	return pbias_reg;
+}
+
+static void omap2430_mmc1_active_overwrite(u32 __iomem *devconf1, int vdd)
+{
+	u32 reg;
+
+	reg = omap_control_mmc_readl(devconf1);
+	if ((1 << vdd) >= MMC_VDD_30_31)
+		reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
+	else
+		reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
+	omap_control_mmc_writel(reg, devconf1);
+}
+/* pbias configuration for omap2430, omap3 */
+static void omap_hsmmc1_before_set_reg(struct device *dev,
+				  int power_on, int vdd)
+{
+	u32 reg;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	if (ctl_mmc->devconf1)
+		omap2430_mmc1_active_overwrite(ctl_mmc->devconf1, vdd);
+
+	reg = omap_control_mmc_readl(ctl_mmc->pbias);
+	reg &= ~OMAP2_PBIASLITEPWRDNZ0;
+	omap_control_mmc_writel(reg, ctl_mmc->pbias);
+}
+
+static void omap_hsmmc1_after_set_reg(struct device *dev,
+				 int power_on, int vdd)
+{
+	u32 reg;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	/* 100ms delay required for PBIAS configuration */
+	msleep(100);
+
+	if (power_on) {
+		reg = omap_control_mmc_readl(ctl_mmc->pbias);
+		reg |= OMAP2_PBIASLITEPWRDNZ0;
+		if ((1 << vdd) <= MMC_VDD_165_195)
+			reg &= ~OMAP2_PBIASLITEVMODE0;
+		else
+			reg |= OMAP2_PBIASLITEVMODE0;
+		omap_control_mmc_writel(reg, ctl_mmc->pbias);
+	} else {
+		reg = omap_control_mmc_readl(ctl_mmc->pbias);
+		reg |= (OMAP2_PBIASLITEPWRDNZ0 |
+			OMAP2_PBIASLITEVMODE0);
+		omap_control_mmc_writel(reg, ctl_mmc->pbias);
+	}
+}
+
+static void omap4_hsmmc1_before_set_reg(struct device *dev,
+				  int power_on, int vdd)
+{
+	u32 reg;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	reg = omap_control_mmc_readl(ctl_mmc->pbias);
+	reg &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
+		OMAP4_MMC1_PWRDNZ_MASK |
+		OMAP4_MMC1_PBIASLITE_VMODE_MASK);
+	omap_control_mmc_writel(reg, ctl_mmc->pbias);
+}
+
+static void omap4_hsmmc1_after_set_reg(struct device *dev,
+				 int power_on, int vdd)
+{
+	u32 reg;
+	unsigned long timeout;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	if (power_on) {
+		reg = omap_control_mmc_readl(ctl_mmc->pbias);
+		reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK;
+		if ((1 << vdd) <= MMC_VDD_165_195)
+			reg &= ~OMAP4_MMC1_PBIASLITE_VMODE_MASK;
+		else
+			reg |= OMAP4_MMC1_PBIASLITE_VMODE_MASK;
+		reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
+			OMAP4_MMC1_PWRDNZ_MASK);
+		omap_control_mmc_writel(reg, ctl_mmc->pbias);
+
+		timeout = jiffies + msecs_to_jiffies(5);
+		do {
+			reg = omap_control_mmc_readl(ctl_mmc->pbias);
+			if (!(reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK))
+				break;
+			usleep_range(100, 200);
+		} while (!time_after(jiffies, timeout));
+
+		if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK) {
+			dev_err(dev, "Pbias Voltage is not same as LDO\n");
+			/* Caution : On VMODE_ERROR Power Down MMC IO */
+			reg &= ~(OMAP4_MMC1_PWRDNZ_MASK);
+			omap_control_mmc_writel(reg, ctl_mmc->pbias);
+		}
+	}
+}
+
+/* OMAP5 PBIAS configuration */
+static void omap5_before_set_reg(struct device *dev,
+					int power_on, int vdd)
+{
+	u32 reg;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	reg = omap_control_mmc_readl(ctl_mmc->pbias);
+	reg &= ~(OMAP5_SDCARD_IO_PWRRDNZ);
+	omap_control_mmc_writel(reg, ctl_mmc->pbias);
+	usleep_range(10, 20);
+	reg &= ~(OMAP5_SDCARD_BIAS_PWRDNZ);
+	omap_control_mmc_writel(reg, ctl_mmc->pbias);
+}
+
+static void omap5_after_set_reg(struct device *dev,
+				 int power_on, int vdd)
+{
+	u32 reg;
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	if (power_on) {
+		reg = omap_control_mmc_readl(ctl_mmc->pbias);
+		reg |= OMAP5_SDCARD_BIAS_PWRDNZ;
+		omap_control_mmc_writel(reg, ctl_mmc->pbias);
+		usleep_range(150, 200);
+		reg |= OMAP5_SDCARD_IO_PWRRDNZ;
+		omap_control_mmc_writel(reg, ctl_mmc->pbias);
+		usleep_range(150, 200);
+	}
+}
+
+static void omap2_mmc1_enable_loopback_clock(struct device *dev)
+{
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+	u32 reg;
+
+	reg = omap_control_mmc_readl(ctl_mmc->devconf0);
+	if (ctl_mmc->external_clock)
+		reg &= ~OMAP2_MMCSDIO1ADPCLKISEL;
+	else
+		reg |= OMAP2_MMCSDIO1ADPCLKISEL;
+	omap_control_mmc_writel(reg, ctl_mmc->devconf0);
+}
+
+static void omap2_mmc1_high_speed_enable(u32 __iomem *pbias)
+{
+	u32 reg;
+
+	reg = omap_control_mmc_readl(pbias);
+	reg |= OMAP2_PBIASSPEEDCTRL0;
+	omap_control_mmc_writel(reg, pbias);
+}
+
+static void omap3630_mmc1_high_speed_enable(u32 __iomem *prog_io1)
+{
+	u32 prog_io;
+
+	prog_io = omap_control_mmc_readl(prog_io1);
+	prog_io |= OMAP3630_PRG_SDMMC1_SPEEDCTRL;
+	omap_control_mmc_writel(prog_io, prog_io1);
+}
+
+static void omap2_mmc1_init(struct device *dev)
+{
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+
+	if (ctl_mmc->devconf0)
+		omap2_mmc1_enable_loopback_clock(dev);
+
+	if (ctl_mmc->prog_io1)
+		omap3630_mmc1_high_speed_enable(ctl_mmc->prog_io1);
+	else if (ctl_mmc->pbias)
+		omap2_mmc1_high_speed_enable(ctl_mmc->pbias);
+}
+
+static void omap4_mmc1_init(struct device *dev)
+{
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+	u32 reg;
+
+	reg = omap_control_mmc_readl(ctl_mmc->ctrl_mmc1);
+	reg |= (OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK |
+		OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK);
+	reg &= ~(OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK |
+		OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK);
+	reg |= (OMAP4_SDMMC1_DR0_SPEEDCTRL_MASK |
+		OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK |
+		OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK);
+	omap_control_mmc_writel(reg, ctl_mmc->ctrl_mmc1);
+}
+
+static void omap_mmc2_enable_loopback_clock(struct device *dev)
+{
+	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
+	u32 reg;
+
+	reg = omap_control_mmc_readl(ctl_mmc->devconf1);
+	if (ctl_mmc->external_clock)
+		reg &= ~OMAP2_MMCSDIO2ADPCLKISEL;
+	else
+		reg |= OMAP2_MMCSDIO2ADPCLKISEL;
+	omap_control_mmc_writel(reg, ctl_mmc->devconf1);
+}
+
+static inline int has_pbias(int ctrl_type)
+{
+	if ((ctrl_type == CTRL_MMC1_2430) || (ctrl_type == CTRL_MMC1_3430) ||
+	    (ctrl_type == CTRL_MMC1_3630) || (ctrl_type == CTRL_MMC1_4430) ||
+	    (ctrl_type == CTRL_MMC1_5430))
+		return 1;
+
+	return  0;
+}
+
+static inline int has_devconf0(int ctrl_type)
+{
+	if ((ctrl_type == CTRL_MMC1_2430) || (ctrl_type == CTRL_MMC1_3430))
+		return 1;
+
+	return  0;
+}
+
+static inline int has_devconf1(int ctrl_type)
+{
+	if ((ctrl_type == CTRL_MMC1_2430) || (ctrl_type == CTRL_MMC2))
+		return 1;
+
+	return  0;
+}
+
+static inline int has_prog_io1(int ctrl_type)
+{
+	if (ctrl_type == CTRL_MMC1_3630)
+		return 1;
+
+	return  0;
+}
+
+static inline int has_ctrl_mmc1(int ctrl_type)
+{
+	if (ctrl_type == CTRL_MMC1_4430)
+		return 1;
+
+	return  0;
+}
+
+static int omap_hsmmc_control_probe(struct platform_device *pdev)
+{
+	struct resource	*res;
+	struct device_node *np = pdev->dev.of_node;
+	static struct omap_hsmmc_control *control_mmc;
+	int ctrl_type = 0;
+
+	control_mmc = devm_kzalloc(&pdev->dev, sizeof(*control_mmc),
+		GFP_KERNEL);
+	if (!control_mmc) {
+		dev_err(&pdev->dev, "unable to alloc memory for control mmc\n");
+		return -ENOMEM;
+	}
+
+	control_mmc->dev	= &pdev->dev;
+
+	control_mmc->external_clock = of_property_read_bool(np, "external_clk");
+
+	if (of_find_property(np, "ctrl-type", NULL))
+		of_property_read_u32(np, "ctrl-type", &ctrl_type);
+	control_mmc->ctrl_type = ctrl_type;
+
+	if (has_pbias(ctrl_type)) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+			"pbias");
+		if (res)
+			control_mmc->pbias = devm_ioremap(&pdev->dev,
+						res->start, resource_size(res));
+		else
+			dev_err(&pdev->dev, "Failed to get mmc1 pbias resource\n");
+		if (!control_mmc->pbias)
+			dev_err(&pdev->dev, "Failed to get mmc1 pbias memory\n");
+	}
+
+	if (control_mmc->pbias) {
+		switch (ctrl_type) {
+		case CTRL_MMC1_2430:
+		case CTRL_MMC1_3430:
+		case CTRL_MMC1_3630:
+			control_mmc->before = omap_hsmmc1_before_set_reg;
+			control_mmc->after = omap_hsmmc1_after_set_reg;
+			break;
+		case CTRL_MMC1_4430:
+			control_mmc->before = omap4_hsmmc1_before_set_reg;
+			control_mmc->after = omap4_hsmmc1_after_set_reg;
+			break;
+		case CTRL_MMC1_5430:
+			control_mmc->before = omap5_before_set_reg;
+			control_mmc->after = omap5_after_set_reg;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (has_ctrl_mmc1(ctrl_type)) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+			"mmc1");
+		if (res)
+			control_mmc->ctrl_mmc1 = devm_ioremap(&pdev->dev,
+						res->start, resource_size(res));
+		else
+			dev_err(&pdev->dev, "Failed to get mmc1 resource\n");
+		if (!control_mmc->ctrl_mmc1)
+			dev_err(&pdev->dev, "Failed to get mmc1 memory\n");
+	}
+
+	if (has_devconf0(ctrl_type)) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+			"devconf0");
+		if (res)
+			control_mmc->devconf0 = devm_ioremap(&pdev->dev,
+						res->start, resource_size(res));
+		else
+			dev_err(&pdev->dev, "Failed to get devconf0 resource\n");
+		if (!control_mmc->devconf0)
+			dev_err(&pdev->dev, "Failed to get devconf0 memory\n");
+	}
+
+	if (has_devconf1(ctrl_type)) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+			"devconf1");
+		if (res)
+			control_mmc->devconf1 = devm_ioremap(&pdev->dev,
+						res->start, resource_size(res));
+		else
+			dev_err(&pdev->dev, "Failed to get devconf1 resource\n");
+
+		if (!control_mmc->devconf1)
+			dev_err(&pdev->dev, "Failed to get devconf1 memory\n");
+	}
+
+	if (has_prog_io1(ctrl_type)) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+			"prog_io1");
+		if (res)
+			control_mmc->prog_io1 = devm_ioremap(&pdev->dev,
+						res->start, resource_size(res));
+		else
+			dev_err(&pdev->dev, "Failed to get prog io1 resource\n");
+		if (!control_mmc->prog_io1)
+			dev_err(&pdev->dev, "Failed to get prog io1 memory\n");
+	}
+
+	switch (ctrl_type) {
+	case CTRL_MMC2:
+		control_mmc->init = omap_mmc2_enable_loopback_clock;
+		break;
+	case CTRL_MMC1_2430:
+	case CTRL_MMC1_3430:
+	case CTRL_MMC1_3630:
+		control_mmc->init = omap2_mmc1_init;
+		break;
+	case CTRL_MMC1_4430:
+		control_mmc->init = omap4_mmc1_init;
+		break;
+	default:
+		break;
+	}
+	dev_set_drvdata(control_mmc->dev, control_mmc);
+
+	return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id omap_hsmmc_control_id_table[] = {
+	{
+		.compatible = "ti,omap-hsmmc-control",
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(of, omap_hsmmc_control_id_table);
+#endif
+
+static struct platform_driver omap_hsmmc_control_driver = {
+	.probe		= omap_hsmmc_control_probe,
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(omap_hsmmc_control_id_table),
+	},
+};
+
+module_platform_driver(omap_hsmmc_control_driver);
+MODULE_ALIAS("platform: DRIVER_NAME");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_DESCRIPTION("OMAP Control Module MMC Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
index 11583a6..d5195ae 100644
--- a/include/linux/platform_data/mmc-omap.h
+++ b/include/linux/platform_data/mmc-omap.h
@@ -35,6 +35,24 @@ struct omap_mmc_dev_attr {
 	u8 flags;
 };
 
+struct omap_hsmmc_control {
+	struct device *dev;
+
+	u32 __iomem *pbias;
+	u32 __iomem *prog_io1;
+	u32 __iomem *devconf0;
+	u32 __iomem *devconf1;
+	u32 __iomem *ctrl_mmc1;
+
+	unsigned external_clock:1;
+	u32 ctrl_type;
+
+	void (*before)(struct device *dev, int power_on, int vdd);
+	void (*after) (struct device *dev, int power_on, int vdd);
+	void (*init) (struct device *dev);
+	void (*exit) (struct device *dev);
+};
+
 struct omap_mmc_platform_data {
 	/* back-link to device */
 	struct device *dev;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 07/13] mmc: omap_hsmmc: remove dt pbias workaround
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (5 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 08/13] Documentation: dt: mmc: omap hsmmc Balaji T K
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

With pbias control support in place remove dt workaround for pbias

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   15 +--------------
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 217c063..c84d2ad 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -256,13 +256,6 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 */
 	if (!host->vcc && !host->vcc_aux)
 		return 0;
-	/*
-	 * With DT, never turn OFF the regulator. This is because
-	 * the pbias cell programming support is still missing when
-	 * booting with Device tree
-	 */
-	if (dev->of_node && !vdd)
-		return 0;
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
@@ -1528,13 +1521,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * of external transceiver; but they all handle 1.8V.
 		 */
 		if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
-			(ios->vdd == DUAL_VOLT_OCR_BIT) &&
-			/*
-			 * With pbias cell programming missing, this
-			 * can't be allowed when booting with device
-			 * tree.
-			 */
-			!host->dev->of_node) {
+			(ios->vdd == DUAL_VOLT_OCR_BIT)) {
 				/*
 				 * The mmc_select_voltage fn of the core does
 				 * not seem to set the power_mode to
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 08/13] Documentation: dt: mmc: omap hsmmc
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (6 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 07/13] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 09/13] ARM: dts: omap3: Add omap control mmc data Balaji T K
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Update ti-omap-hsmmc devicetree documentation with omap-hsmmc-control binding
information for MMC1/MMC2 in different OMAP SoCs.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |   34 ++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
index ed271fc..f0468e8 100644
--- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
+++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
@@ -31,3 +31,37 @@ Example:
 		vmmc-supply = <&vmmc>; /* phandle to regulator node */
 		ti,non-removable;
 	};
+
+OMAP HSMMC CONTROL
+
+Required properties:
+- compatible: Should be "ti,omap-hsmmc-control"
+- reg : Address and length of the register set for the device. It contains
+ the address of "pbias" and/or "prog_io1" and/or "ctrl_mmc1" and/or "devconf1"
+ and/or "devconf0"
+- reg-names: The names of the register addresses corresponding to the registers
+ filled in "reg".
+- ti,ctrl-type: This is used to differentiate mmc1, mmc2 on different
+ omap SOCs like 2430, omap3, omap3630, omap4, omap5.
+ MMC1 pbias programming is same for omap2430 and omap3 but differs across
+ omap3,4,5.
+ Should be "0" for no control mmc module configuration
+ Should be "1" for MMC1 on OMAP2430 for MMC1 pbias, loopback
+  and speed mode configuration
+ Should be "2" for MMC2 on OMAP2430, OMAP3 for loopback clock configuration
+ Should be "3" for MMC1 on OMAP3430 for MMC1 pbias, loopback
+  and speed mode configuration
+ Should be "4" for MMC1 on OMAP3630 for MMC1 pbias, loopback
+  and speed mode configuration
+ Should be "5" for MMC1 on OMAP4 for MMC1 pbias configuration
+ Should be "6" for MMC2 on OMAP4 for loopback clock configuration
+ Should be "7" for MMC1 on OMAP5 for MMC1 pbias configuration
+
+Example:
+omap_control_mmc1: omap-hsmmc-control@4A100600 {
+	compatible = "ti,omap-hsmmc-control";
+	reg = <0x4A100600 0x4>,
+	      <0x4A100628 0x4>;
+	reg-names = "pbias", "mmc1";
+	ctrl-type = <5>;
+};
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 09/13] ARM: dts: omap3: Add omap control mmc data
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (7 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 08/13] Documentation: dt: mmc: omap hsmmc Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 10/13] ARM: dts: omap36xx: " Balaji T K
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap-hsmmc-control data to omap3.
Update with pbias and devconf0 register address for mmc1.
Update with devconf1 register address for mmc2

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap3.dtsi |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 1acc261..c5c7d17 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -218,15 +218,32 @@
 			ti,spi-num-cs = <1>;
 		};
 
+		omap_control_mmc1: omap-hsmmc-control@48002520 {
+			compatible = "ti,omap-hsmmc-control";
+			reg = <0x48002520 0x4>,
+			      <0x48002274 0x4>;
+			reg-names = "pbias", "devconf0";
+			ctrl-type = <3>;
+		};
+
 		mmc1: mmc@4809c000 {
 			compatible = "ti,omap3-hsmmc";
 			ti,hwmods = "mmc1";
 			ti,dual-volt;
+			ctrl-module = <&omap_control_mmc1>;
+		};
+
+		omap_control_mmc2: omap-hsmmc-control@480022D8 {
+			compatible = "ti,omap-hsmmc-control";
+			reg = <0x480022D8 0x4>;
+			reg-names = "devconf1";
+			ctrl-type = <2>;
 		};
 
 		mmc2: mmc@480b4000 {
 			compatible = "ti,omap3-hsmmc";
 			ti,hwmods = "mmc2";
+			ctrl-module = <&omap_control_mmc2>;
 		};
 
 		mmc3: mmc@480ad000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 10/13] ARM: dts: omap36xx: Add omap control mmc data
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (8 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 09/13] ARM: dts: omap3: Add omap control mmc data Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 11/13] ARM: dts: omap4: " Balaji T K
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap-hsmmc-control data to omap630.
Update with pbias and prog_io1 register address.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap36xx.dtsi |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap36xx.dtsi b/arch/arm/boot/dts/omap36xx.dtsi
index 96bf028..9e396c4 100644
--- a/arch/arm/boot/dts/omap36xx.dtsi
+++ b/arch/arm/boot/dts/omap36xx.dtsi
@@ -23,3 +23,10 @@
 		};
 	};
 };
+&omap_control_mmc1 {
+	compatible = "ti,omap-hsmmc-control";
+	reg = <0x48002520 0x4>,
+	      <0x48002448 0x4>;
+	reg-names = "pbias", "prog_io1";
+	ctrl-type = <4>;
+};
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 11/13] ARM: dts: omap4: Add omap control mmc data
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (9 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 10/13] ARM: dts: omap36xx: " Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 12/13] ARM: dts: omap5: " Balaji T K
  2013-04-30 14:03 ` [PATCH 13/13] ARM: dts: am3517: add omap_control_mmc Balaji T K
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap-hsmmc-control data to omap4.
Update with pbias register address for configuration of pbias dual volt
i/o cells in mmc1 and control_mmc1 register address for i/o strength
configuration

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap4.dtsi |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 739bb79..7f1d0c1 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -292,6 +292,14 @@
 			ti,spi-num-cs = <1>;
 		};
 
+		omap_control_mmc1: omap-hsmmc-control@4A100600 {
+			compatible = "ti,omap-hsmmc-control";
+			reg = <0x4A100600 0x4>,
+			      <0x4A100628 0x4>;
+			reg-names = "pbias", "mmc1";
+			ctrl-type = <5>;
+		};
+
 		mmc1: mmc@4809c000 {
 			compatible = "ti,omap4-hsmmc";
 			reg = <0x4809c000 0x400>;
@@ -299,6 +307,7 @@
 			ti,hwmods = "mmc1";
 			ti,dual-volt;
 			ti,needs-special-reset;
+			ctrl-module = <&omap_control_mmc1>;
 		};
 
 		mmc2: mmc@480b4000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 12/13] ARM: dts: omap5: Add omap control mmc data
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (10 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 11/13] ARM: dts: omap4: " Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  2013-04-30 14:03 ` [PATCH 13/13] ARM: dts: am3517: add omap_control_mmc Balaji T K
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap-hsmmc-control data to omap5.
Update with pbias register address, used for pbias dual volt i/o cells
in mmc1.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap5.dtsi |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 790bb2a..d480b9f 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -289,6 +289,13 @@
 			clock-frequency = <48000000>;
 		};
 
+		omap_control_mmc1: omap-hsmmc-control@4a002E00 {
+			compatible = "ti,omap-hsmmc-control";
+			reg = <0x4a002E00 0x4>;
+			reg-names = "pbias";
+			ctrl-type = <7>;
+		};
+
 		mmc1: mmc@4809c000 {
 			compatible = "ti,omap4-hsmmc";
 			reg = <0x4809c000 0x400>;
@@ -296,6 +303,7 @@
 			ti,hwmods = "mmc1";
 			ti,dual-volt;
 			ti,needs-special-reset;
+			ctrl-module = <&omap_control_mmc1>;
 		};
 
 		mmc2: mmc@480b4000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH 13/13] ARM: dts: am3517: add omap_control_mmc
  2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                   ` (11 preceding siblings ...)
  2013-04-30 14:03 ` [PATCH 12/13] ARM: dts: omap5: " Balaji T K
@ 2013-04-30 14:03 ` Balaji T K
  12 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-04-30 14:03 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson; +Cc: Balaji T K

Add omap-hsmmc-control data to am3517 board.
Update with devconf1 register address, used for loopback clock configuration
in mmc2.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/am3517-evm.dts        |   20 ++++++++++++++++++++
 arch/arm/boot/dts/am3517_mt_ventoux.dts |   20 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am3517-evm.dts b/arch/arm/boot/dts/am3517-evm.dts
index 474f760..2775c51 100644
--- a/arch/arm/boot/dts/am3517-evm.dts
+++ b/arch/arm/boot/dts/am3517-evm.dts
@@ -30,3 +30,23 @@
 &i2c3 {
 	clock-frequency = <400000>;
 };
+
+&omap_control_mmc1 {
+	compatible = "ti,omap-hsmmc-control";
+	ctrl-type = <0>;
+};
+
+omap_control_mmc2: omap-hsmmc-control@480022D8 {
+	compatible = "ti,omap-hsmmc-control";
+	reg = <0x480022D8 0x4>;
+	reg-names = "devconf1";
+	ctrl-type = <2>;
+};
+
+&mmc1 {
+	bus-width = <8>;
+};
+
+&mmc2 {
+	status = "disabled";
+};
diff --git a/arch/arm/boot/dts/am3517_mt_ventoux.dts b/arch/arm/boot/dts/am3517_mt_ventoux.dts
index 5eb26d7..2a15345 100644
--- a/arch/arm/boot/dts/am3517_mt_ventoux.dts
+++ b/arch/arm/boot/dts/am3517_mt_ventoux.dts
@@ -25,3 +25,23 @@
 		};
 	};
 };
+
+&omap_control_mmc1 {
+	compatible = "ti,omap-hsmmc-control";
+	ctrl-type = <0>;
+};
+
+omap_control_mmc2: omap-hsmmc-control@480022D8 {
+	compatible = "ti,omap-hsmmc-control";
+	reg = <0x480022D8 0x4>;
+	reg-names = "devconf1";
+	ctrl-type = <2>;
+};
+
+&mmc1 {
+	bus-width = <8>;
+};
+
+&mmc2 {
+	status = "disabled";
+};
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* Re: [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support
  2013-04-30 14:03 ` [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support Balaji T K
@ 2013-05-16 16:16   ` Tony Lindgren
  2013-05-23 16:07     ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-05-16 16:16 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson

Hi,

* Balaji T K <balajitk@ti.com> [130430 07:09]:
> Add omap_hsmmc_control to support pbias, high speed mode configuration for mmc1,
> loopback clock configuration (when external transceiver is used) for mmc2

Thanks for working on this, few suggestions inlined below.
 
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -182,6 +182,7 @@ struct omap_hsmmc_host {
>  	struct omap_hsmmc_next	next_data;
>  
>  	struct	omap_mmc_platform_data	*pdata;
> +	struct omap_hsmmc_control	*ctrl_mmc;
>  	int needs_vmmc:1;
>  	int needs_vmmc_aux:1;
>  };
> @@ -265,6 +266,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  
>  	if (mmc_slot(host).before_set_reg)
>  		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
> +	if (host->ctrl_mmc && host->ctrl_mmc->before)
> +		host->ctrl_mmc->before(host->ctrl_mmc->dev, power_on, vdd);
>  
>  	/*
>  	 * Assume Vcc regulator is used only to power the card ... OMAP
> @@ -302,6 +305,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  
>  	if (mmc_slot(host).after_set_reg)
>  		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
> +	if (host->ctrl_mmc && host->ctrl_mmc->after)
> +		host->ctrl_mmc->after(host->ctrl_mmc->dev, power_on, vdd);
>  
>  	return ret;
>  }

These before and after functions should be first converted to just usual
regulator_set_voltage() eventually. In the PBIAS case it's really a mux
plus a comparator, but we can set it up as a regulator. And on some boards
it can be an external regulator like we have the legacy callbacks for in
mach-omap2/hsmmc.c.

> +++ b/drivers/mmc/host/omap_hsmmc_control.c
> @@ -0,0 +1,466 @@
> +static void omap_control_mmc_writel(u32 reg, u32 *base2)
> +{
> +	if (base2)
> +		__raw_writel(reg, base2);
> +	return;
> +}
> +
> +static u32 omap_control_mmc_readl(u32 *base2)
> +{
> +	u32 pbias_reg = 0;
> +
> +	if (base2)
> +		pbias_reg = __raw_readl(base2);
> +	return pbias_reg;
> +}
> +
> +static void omap2430_mmc1_active_overwrite(u32 __iomem *devconf1, int vdd)
> +{
> +	u32 reg;
> +
> +	reg = omap_control_mmc_readl(devconf1);
> +	if ((1 << vdd) >= MMC_VDD_30_31)
> +		reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
> +	else
> +		reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
> +	omap_control_mmc_writel(reg, devconf1);
> +}
> +/* pbias configuration for omap2430, omap3 */
> +static void omap_hsmmc1_before_set_reg(struct device *dev,
> +				  int power_on, int vdd)
> +{
> +	u32 reg;
> +	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
> +
> +	if (ctl_mmc->devconf1)
> +		omap2430_mmc1_active_overwrite(ctl_mmc->devconf1, vdd);
> +
> +	reg = omap_control_mmc_readl(ctl_mmc->pbias);
> +	reg &= ~OMAP2_PBIASLITEPWRDNZ0;
> +	omap_control_mmc_writel(reg, ctl_mmc->pbias);
> +}
> +
> +static void omap_hsmmc1_after_set_reg(struct device *dev,
> +				 int power_on, int vdd)
> +{
> +	u32 reg;
> +	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
> +
> +	/* 100ms delay required for PBIAS configuration */
> +	msleep(100);
> +
> +	if (power_on) {
> +		reg = omap_control_mmc_readl(ctl_mmc->pbias);
> +		reg |= OMAP2_PBIASLITEPWRDNZ0;
> +		if ((1 << vdd) <= MMC_VDD_165_195)
> +			reg &= ~OMAP2_PBIASLITEVMODE0;
> +		else
> +			reg |= OMAP2_PBIASLITEVMODE0;
> +		omap_control_mmc_writel(reg, ctl_mmc->pbias);
> +	} else {
> +		reg = omap_control_mmc_readl(ctl_mmc->pbias);
> +		reg |= (OMAP2_PBIASLITEPWRDNZ0 |
> +			OMAP2_PBIASLITEVMODE0);
> +		omap_control_mmc_writel(reg, ctl_mmc->pbias);
> +	}
> +}
...

This all we can simplify quite a bit by defining the PBIAS register
as pinctrl-single,bits with two different named modes. One for
1.8V and for 3.3V. This way the PBIAS register is abstracted for
various omaps in the .dts file as the register is different.

Then this file should just define a new regulator that requests the
defined pinctrl named mode with pinctrl_select_state().

Now the only thing missing AFAIK is getting the comparator value
for checks with the generic pinconf framework. But you can already
get the raw register value with pin_config_get() and add the
checking to this driver until pinconf allows us to do that.

BTW, the same can then be done for the USB transceivers if we
figure out a way to properly deal with comparators with generic
pinconf.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support
  2013-05-16 16:16   ` Tony Lindgren
@ 2013-05-23 16:07     ` Balaji T K
  2013-05-23 18:40       ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-05-23 16:07 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-mmc, cjb, b-cousson

On Thursday 16 May 2013 09:46 PM, Tony Lindgren wrote:
> Hi,
>
> * Balaji T K <balajitk@ti.com> [130430 07:09]:
>> Add omap_hsmmc_control to support pbias, high speed mode configuration for mmc1,
>> loopback clock configuration (when external transceiver is used) for mmc2
>
> Thanks for working on this, few suggestions inlined below.

Thanks again for reviewing

>
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -182,6 +182,7 @@ struct omap_hsmmc_host {
>>   	struct omap_hsmmc_next	next_data;
>>
>>   	struct	omap_mmc_platform_data	*pdata;
>> +	struct omap_hsmmc_control	*ctrl_mmc;
>>   	int needs_vmmc:1;
>>   	int needs_vmmc_aux:1;
>>   };
>> @@ -265,6 +266,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>
>>   	if (mmc_slot(host).before_set_reg)
>>   		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
>> +	if (host->ctrl_mmc && host->ctrl_mmc->before)
>> +		host->ctrl_mmc->before(host->ctrl_mmc->dev, power_on, vdd);
>>
>>   	/*
>>   	 * Assume Vcc regulator is used only to power the card ... OMAP
>> @@ -302,6 +305,8 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>
>>   	if (mmc_slot(host).after_set_reg)
>>   		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
>> +	if (host->ctrl_mmc && host->ctrl_mmc->after)
>> +		host->ctrl_mmc->after(host->ctrl_mmc->dev, power_on, vdd);
>>
>>   	return ret;
>>   }
>
> These before and after functions should be first converted to just usual
> regulator_set_voltage() eventually. In the PBIAS case it's really a mux
> plus a comparator, but we can set it up as a regulator. And on some boards
> it can be an external regulator like we have the legacy callbacks for in
> mach-omap2/hsmmc.c.

Agree these .before, .after functions are for dual volt pbias i/o cell programming
based on regulator voltage, but modeling pbias register programming via
regulator might be overdo

>
>> +++ b/drivers/mmc/host/omap_hsmmc_control.c
>> @@ -0,0 +1,466 @@
>> +static void omap_control_mmc_writel(u32 reg, u32 *base2)
>> +{
>> +	if (base2)
>> +		__raw_writel(reg, base2);
>> +	return;
>> +}
>> +
>> +static u32 omap_control_mmc_readl(u32 *base2)
>> +{
>> +	u32 pbias_reg = 0;
>> +
>> +	if (base2)
>> +		pbias_reg = __raw_readl(base2);
>> +	return pbias_reg;
>> +}
>> +
>> +static void omap2430_mmc1_active_overwrite(u32 __iomem *devconf1, int vdd)
>> +{
>> +	u32 reg;
>> +
>> +	reg = omap_control_mmc_readl(devconf1);
>> +	if ((1 << vdd) >= MMC_VDD_30_31)
>> +		reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
>> +	else
>> +		reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
>> +	omap_control_mmc_writel(reg, devconf1);
>> +}
>> +/* pbias configuration for omap2430, omap3 */
>> +static void omap_hsmmc1_before_set_reg(struct device *dev,
>> +				  int power_on, int vdd)
>> +{
>> +	u32 reg;
>> +	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
>> +
>> +	if (ctl_mmc->devconf1)
>> +		omap2430_mmc1_active_overwrite(ctl_mmc->devconf1, vdd);
>> +
>> +	reg = omap_control_mmc_readl(ctl_mmc->pbias);
>> +	reg &= ~OMAP2_PBIASLITEPWRDNZ0;
>> +	omap_control_mmc_writel(reg, ctl_mmc->pbias);
>> +}
>> +
>> +static void omap_hsmmc1_after_set_reg(struct device *dev,
>> +				 int power_on, int vdd)
>> +{
>> +	u32 reg;
>> +	struct omap_hsmmc_control *ctl_mmc = dev_get_drvdata(dev);
>> +
>> +	/* 100ms delay required for PBIAS configuration */
>> +	msleep(100);
>> +
>> +	if (power_on) {
>> +		reg = omap_control_mmc_readl(ctl_mmc->pbias);
>> +		reg |= OMAP2_PBIASLITEPWRDNZ0;
>> +		if ((1 << vdd) <= MMC_VDD_165_195)
>> +			reg &= ~OMAP2_PBIASLITEVMODE0;
>> +		else
>> +			reg |= OMAP2_PBIASLITEVMODE0;
>> +		omap_control_mmc_writel(reg, ctl_mmc->pbias);
>> +	} else {
>> +		reg = omap_control_mmc_readl(ctl_mmc->pbias);
>> +		reg |= (OMAP2_PBIASLITEPWRDNZ0 |
>> +			OMAP2_PBIASLITEVMODE0);
>> +		omap_control_mmc_writel(reg, ctl_mmc->pbias);
>> +	}
>> +}
> ...
>
> This all we can simplify quite a bit by defining the PBIAS register
> as pinctrl-single,bits with two different named modes. One for
> 1.8V and for 3.3V. This way the PBIAS register is abstracted for
> various omaps in the .dts file as the register is different.
>

Sometimes pbias register (like in omap3) has bits fields other than mmc1 pbias bits,
in which case it will be difficult to abstract via pinctrl-single
with mask bits for non-mmc1 pbias bits.

> Then this file should just define a new regulator that requests the
> defined pinctrl named mode with pinctrl_select_state().
>
> Now the only thing missing AFAIK is getting the comparator value
> for checks with the generic pinconf framework. But you can already
> get the raw register value with pin_config_get() and add the
> checking to this driver until pinconf allows us to do that.
>
> BTW, the same can then be done for the USB transceivers if we
> figure out a way to properly deal with comparators with generic
> pinconf.
>
> Regards,
>
> Tony
>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support
  2013-05-23 16:07     ` Balaji T K
@ 2013-05-23 18:40       ` Tony Lindgren
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-05-23 18:40 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson

* Balaji T K <balajitk@ti.com> [130523 09:13]:
> On Thursday 16 May 2013 09:46 PM, Tony Lindgren wrote:
> >
> >These before and after functions should be first converted to just usual
> >regulator_set_voltage() eventually. In the PBIAS case it's really a mux
> >plus a comparator, but we can set it up as a regulator. And on some boards
> >it can be an external regulator like we have the legacy callbacks for in
> >mach-omap2/hsmmc.c.
> 
> Agree these .before, .after functions are for dual volt pbias i/o cell programming
> based on regulator voltage, but modeling pbias register programming via
> regulator might be overdo

Probably not as then you don't need to export any custom functions
from the pbias code. 

> >This all we can simplify quite a bit by defining the PBIAS register
> >as pinctrl-single,bits with two different named modes. One for
> >1.8V and for 3.3V. This way the PBIAS register is abstracted for
> >various omaps in the .dts file as the register is different.
> >
> 
> Sometimes pbias register (like in omap3) has bits fields other than mmc1 pbias bits,
> in which case it will be difficult to abstract via pinctrl-single
> with mask bits for non-mmc1 pbias bits.

Yes exactly, that's what you can totally define with pinconf-single,bits
in omap3.dtsi and omap4.dtsi files. Then from the pbias handling regulator
code you just request named pinctrl states which are now the same
from pbias driver point of view.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch
  2013-05-23 18:40       ` Tony Lindgren
@ 2013-06-06 19:14         ` Balaji T K
  2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
                             ` (9 more replies)
  0 siblings, 10 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

This patch series adds support for configuring pbias register needed for
switching (ON/OFF, voltage scaling 3V, 1.8V) vmmc regulator suppling
OMAP mmc/sd1 i/o pads for device tree boot.
The control module registers are needed for mmc pbias i/o, speed mode
configuration of mmc1 and loopback clock configuration of mmc2.

With voltage switch support (pbias i/o) added for dt, enhance regulator
deferred probe handling by adding needs_vmmc and needs_vmmc_aux to indicate
whether regulator is applicable so that omap_hsmmc can handle regulator
deferred probe error properly.

Remove the assumption that vmmc_aux regulator to be present only if vmmc is
available. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
in such cases vmmc regulator needed not be specified in board file.

Balaji T K (10):
  ARM: OMAP2+: add needs_vmmc to hsmmc_info
  mmc: omap_hsmmc: make vcc and vcc_aux independent
  mmc: omap_hsmmc: use needs_vmmc
  mmc: omap_hsmmc: update needs_vmmc for dt
  mmc: omap_hsmmc: remove use_reg
  mmc: omap_hsmmc: add support for pbias configuration in dt
  mmc: omap_hsmmc: remove dt pbias workaround
  ARM: dts: omap3: split omap3_pmx_core
  ARM: dts: omap3: add pbias and mmc_init pinctrl states
  ARM: dts: omap4: add pbias and mmc_init pinctrl states

 arch/arm/boot/dts/omap3-beagle-xm.dts        |   42 ++++++
 arch/arm/boot/dts/omap3-beagle.dts           |   70 +++++++++-
 arch/arm/boot/dts/omap3.dtsi                 |   21 +++-
 arch/arm/boot/dts/omap4-panda-common.dtsi    |   34 +++++
 arch/arm/boot/dts/omap4-sdp.dts              |   34 +++++
 arch/arm/boot/dts/omap4.dtsi                 |   11 ++
 arch/arm/mach-omap2/board-2430sdp.c          |    1 +
 arch/arm/mach-omap2/board-3430sdp.c          |    3 +
 arch/arm/mach-omap2/board-cm-t35.c           |    2 +
 arch/arm/mach-omap2/board-devkit8000.c       |    1 +
 arch/arm/mach-omap2/board-igep0020.c         |    3 +
 arch/arm/mach-omap2/board-ldp.c              |    1 +
 arch/arm/mach-omap2/board-omap3beagle.c      |    2 +
 arch/arm/mach-omap2/board-omap3evm.c         |    3 +
 arch/arm/mach-omap2/board-omap3logic.c       |    1 +
 arch/arm/mach-omap2/board-omap3pandora.c     |    3 +
 arch/arm/mach-omap2/board-omap3stalker.c     |    2 +
 arch/arm/mach-omap2/board-omap3touchbook.c   |    2 +
 arch/arm/mach-omap2/board-overo.c            |    1 +
 arch/arm/mach-omap2/board-rm680.c            |    1 +
 arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +
 arch/arm/mach-omap2/board-zoom-peripherals.c |    4 +
 arch/arm/mach-omap2/hsmmc.c                  |    2 +
 arch/arm/mach-omap2/hsmmc.h                  |    2 +
 drivers/mmc/host/omap_hsmmc.c                |  188 +++++++++++++++++---------
 include/linux/platform_data/mmc-omap.h       |    2 +
 26 files changed, 367 insertions(+), 72 deletions(-)

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-12 14:24             ` Tony Lindgren
  2013-06-06 19:14           ` [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
                             ` (8 subsequent siblings)
  9 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

Add needs_vmmc and needs_vmmc_aux to indicate whether regulator is
applicable so that omap_hsmmc can handle deferred probe error
properly for regulators.
Remove the assumption that vmmc_aux regulator to be available only if vmmc is
present. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
in such cases regulator needed not be specified in board file.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/mach-omap2/board-2430sdp.c          |    1 +
 arch/arm/mach-omap2/board-3430sdp.c          |    3 +++
 arch/arm/mach-omap2/board-cm-t35.c           |    2 ++
 arch/arm/mach-omap2/board-devkit8000.c       |    1 +
 arch/arm/mach-omap2/board-igep0020.c         |    3 +++
 arch/arm/mach-omap2/board-ldp.c              |    1 +
 arch/arm/mach-omap2/board-omap3beagle.c      |    2 ++
 arch/arm/mach-omap2/board-omap3evm.c         |    3 +++
 arch/arm/mach-omap2/board-omap3logic.c       |    1 +
 arch/arm/mach-omap2/board-omap3pandora.c     |    3 +++
 arch/arm/mach-omap2/board-omap3stalker.c     |    2 ++
 arch/arm/mach-omap2/board-omap3touchbook.c   |    2 ++
 arch/arm/mach-omap2/board-overo.c            |    1 +
 arch/arm/mach-omap2/board-rm680.c            |    1 +
 arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +++
 arch/arm/mach-omap2/board-zoom-peripherals.c |    4 ++++
 arch/arm/mach-omap2/hsmmc.c                  |    2 ++
 arch/arm/mach-omap2/hsmmc.h                  |    2 ++
 include/linux/platform_data/mmc-omap.h       |    2 ++
 19 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 244d8a5..eba8593 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -211,6 +211,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.ext_clock	= 1,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 23b004a..9438c54 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -184,12 +184,15 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 4,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.mmc		= 2,
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 7,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index ee6218c..207ea13 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -364,6 +364,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.mmc		= 2,
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 5764205..63fd8827 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -99,6 +99,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 29,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index b54562d..a2a8a80 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -284,6 +284,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
 	{
@@ -291,6 +292,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 #endif
 	{}      /* Terminator */
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index d0d17bc..62c1a2d 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -315,6 +315,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 04c1165..5063ac3 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -264,6 +264,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_wp	= -EINVAL,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index f76d0de..a9a7507 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -279,6 +279,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= 63,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 #ifdef CONFIG_WILINK_PLATFORM_DATA
 	{
@@ -288,6 +290,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.gpio_cd	= -EINVAL,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 #endif
 	{}	/* Terminator */
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index bab51e6..ff00c81 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -104,6 +104,7 @@ static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{}      /* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 28133d5..c22cf74 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -283,6 +283,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.gpio_wp	= 126,
 		.ext_clock	= 0,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 2,
@@ -292,6 +293,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.ext_clock	= 1,
 		.transceiver	= true,
 		.deferred	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 3,
@@ -299,6 +301,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
 		.init_card	= pandora_wl1251_init_card,
+		.needs_vmmc	= 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index d37e6b1..cc1b374 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -172,6 +172,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= 23,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	 },
 	{}			/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 7da48bc..1087b71 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -103,6 +103,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
 		.gpio_wp	= 29,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 4ca6b68..77d1ffc 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -255,6 +255,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.caps		= MMC_CAP_4_BIT_DATA,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{
 		.mmc		= 2,
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 345e8c4..9d4bcc1 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -106,6 +106,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED,
 		.gpio_cd	= -EINVAL,
 		.gpio_wp	= -EINVAL,
+		.needs_vmmc	= 1,
 	},
 	{ /* Terminator */ }
 };
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 18ca61e..4f4aad5 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -496,6 +496,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.gpio_cd	= 160,
 		.gpio_wp	= -EINVAL,
 		.power_saving	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.name		= "internal",
@@ -507,6 +508,8 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 		.nonremovable	= true,
 		.power_saving	= true,
 		.remux		= rx51_mmc2_remux,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{}	/* Terminator */
 };
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index a90375d..b6a49c3 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -255,6 +255,8 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.power_saving	= true,
 		.deferred	= true,
+		.needs_vmmc	= 1,
+		.needs_vmmc_aux = 1,
 	},
 	{
 		.name		= "internal",
@@ -264,6 +266,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.nonremovable	= true,
 		.power_saving	= true,
+		.needs_vmmc	= 1,
 	},
 	{
 		.name		= "wl1271",
@@ -272,6 +275,7 @@ static struct omap2_hsmmc_info mmc[] = {
 		.gpio_wp	= -EINVAL,
 		.gpio_cd	= -EINVAL,
 		.nonremovable	= true,
+		.needs_vmmc	= 1,
 	},
 	{}      /* Terminator */
 };
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 2ef1f87..9e8b02c 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -313,6 +313,8 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
 								c->mmc, 1);
 	mmc->slots[0].name = hc_name;
 	mmc->nr_slots = 1;
+	mmc->needs_vmmc = c->needs_vmmc;
+	mmc->needs_vmmc_aux = c->needs_vmmc_aux;
 	mmc->slots[0].caps = c->caps;
 	mmc->slots[0].pm_caps = c->pm_caps;
 	mmc->slots[0].internal_clock = !c->ext_clock;
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index 7f2e790..9bc71ee 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -33,6 +33,8 @@ struct omap2_hsmmc_info {
 	void (*remux)(struct device *dev, int slot, int power_on);
 	/* init some special card */
 	void (*init_card)(struct mmc_card *card);
+	unsigned needs_vmmc:1;
+	unsigned needs_vmmc_aux:1;
 };
 
 #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
index 2bf1b30..11583a6 100644
--- a/include/linux/platform_data/mmc-omap.h
+++ b/include/linux/platform_data/mmc-omap.h
@@ -66,6 +66,8 @@ struct omap_mmc_platform_data {
 
 	/* Register offset deviation */
 	u16 reg_offset;
+	unsigned needs_vmmc:1;
+	unsigned needs_vmmc_aux:1;
 
 	struct omap_mmc_slot_data {
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
  2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-12 14:25             ` Tony Lindgren
  2013-06-06 19:14           ` [PATCH v2 03/10] mmc: omap_hsmmc: use needs_vmmc Balaji T K
                             ` (7 subsequent siblings)
  9 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

handle vcc and vcc_aux independently

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1865321..bda1a42 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -253,7 +253,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * If we don't see a Vcc regulator, assume it's a fixed
 	 * voltage always-on regulator.
 	 */
-	if (!host->vcc)
+	if (!host->vcc && !host->vcc_aux)
 		return 0;
 	/*
 	 * With DT, never turn OFF the regulator for MMC1. This is because
@@ -280,11 +280,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * chips/cards need an interface voltage rail too.
 	 */
 	if (power_on) {
-		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		if (host->vcc)
+			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
 		/* Enable interface voltage rail, if needed */
 		if (ret == 0 && host->vcc_aux) {
 			ret = regulator_enable(host->vcc_aux);
-			if (ret < 0)
+			if (ret < 0 && host->vcc)
 				ret = mmc_regulator_set_ocr(host->mmc,
 							host->vcc, 0);
 		}
@@ -292,7 +293,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		/* Shut down the rail */
 		if (host->vcc_aux)
 			ret = regulator_disable(host->vcc_aux);
-		if (!ret) {
+		if (host->vcc) {
 			/* Then proceed to shut down the local regulator */
 			ret = mmc_regulator_set_ocr(host->mmc,
 						host->vcc, 0);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 03/10] mmc: omap_hsmmc: use needs_vmmc
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
  2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
  2013-06-06 19:14           ` [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-06 19:14           ` [PATCH v2 04/10] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
                             ` (6 subsequent siblings)
  9 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

Update needs_vmmc with info passed from board file via platform
data pdata->needs_vmmc.
Use needs_vmmc/needs_vmmc_aux to check whether
regulator is mandatory and handle regulator errors
like EPROBE_DEFER properly

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   65 ++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index bda1a42..21fc152 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -184,6 +184,8 @@ struct omap_hsmmc_host {
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
+	int needs_vmmc:1;
+	int needs_vmmc_aux:1;
 };
 
 static int omap_hsmmc_card_detect(struct device *dev, int slot)
@@ -312,11 +314,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	int ocr_value = 0;
 
 	reg = regulator_get(host->dev, "vmmc");
-	if (IS_ERR(reg)) {
-		dev_err(host->dev, "vmmc regulator missing\n");
+	if (IS_ERR(reg) && host->needs_vmmc) {
+		dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+			PTR_ERR(reg));
 		return PTR_ERR(reg);
-	} else {
-		mmc_slot(host).set_power = omap_hsmmc_set_power;
+	}
+	mmc_slot(host).set_power = omap_hsmmc_set_power;
+	if (!IS_ERR(reg)) {
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {
@@ -329,31 +333,33 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 				return -EINVAL;
 			}
 		}
+	}
 
-		/* Allow an aux regulator */
-		reg = regulator_get(host->dev, "vmmc_aux");
-		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
-
-		/* For eMMC do not power off when not in sleep state */
-		if (mmc_slot(host).no_regulator_off_init)
-			return 0;
-		/*
-		* UGLY HACK:  workaround regulator framework bugs.
-		* When the bootloader leaves a supply active, it's
-		* initialized with zero usecount ... and we can't
-		* disable it without first enabling it.  Until the
-		* framework is fixed, we need a workaround like this
-		* (which is safe for MMC, but not in general).
-		*/
-		if (regulator_is_enabled(host->vcc) > 0 ||
-		    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
-			int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+	/* Allow an aux regulator */
+	reg = regulator_get(host->dev, "vmmc_aux");
+	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
+	if (IS_ERR(reg) && host->needs_vmmc_aux) {
+		dev_err(host->dev, "unable to get vmmc_aux regulator %ld\n",
+			PTR_ERR(reg));
+		return PTR_ERR(reg);
+	}
 
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 1, vdd);
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 0, 0);
-		}
+	/* For eMMC do not power off when not in sleep state */
+	if (mmc_slot(host).no_regulator_off_init ||
+	    (!host->needs_vmmc && !host->needs_vmmc_aux))
+		return 0;
+	/*
+	 * To disable boot_on regulator, enable regulator
+	 * to increase usecount and then disable it.
+	 */
+	if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
+	    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
+		int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+
+		mmc_slot(host).set_power(host->dev, host->slot_id,
+					 1, vdd);
+		mmc_slot(host).set_power(host->dev, host->slot_id,
+					 0, 0);
 	}
 
 	return 0;
@@ -1833,6 +1839,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
+	host->needs_vmmc = pdata->needs_vmmc;
+	host->needs_vmmc_aux = pdata->needs_vmmc_aux;
 
 	platform_set_drvdata(pdev, host);
 
@@ -1972,7 +1980,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) {
 		ret = omap_hsmmc_reg_get(host);
 		if (ret)
-			goto err_reg;
+			goto err_irq_cd;
 		host->use_reg = 1;
 	}
 
@@ -2029,7 +2037,6 @@ err_slot_name:
 err_irq_cd:
 	if (host->use_reg)
 		omap_hsmmc_reg_put(host);
-err_reg:
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 err_irq_cd_init:
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 04/10] mmc: omap_hsmmc: update needs_vmmc for dt
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (2 preceding siblings ...)
  2013-06-06 19:14           ` [PATCH v2 03/10] mmc: omap_hsmmc: use needs_vmmc Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-06 19:14           ` [PATCH v2 05/10] mmc: omap_hsmmc: remove use_reg Balaji T K
                             ` (5 subsequent siblings)
  9 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

update needs_vmmc, needs_vmmc_aux for dt boot

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 21fc152..08f4ca7 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1763,6 +1763,9 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
 	if (of_find_property(np, "ti,needs-special-hs-handling", NULL))
 		pdata->slots[0].features |= HSMMC_HAS_HSPE_SUPPORT;
 
+	pdata->needs_vmmc = of_property_read_bool(np, "vmmc-supply");
+	pdata->needs_vmmc_aux = of_property_read_bool(np, "vmmc_aux-supply");
+
 	return pdata;
 }
 #else
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 05/10] mmc: omap_hsmmc: remove use_reg
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (3 preceding siblings ...)
  2013-06-06 19:14           ` [PATCH v2 04/10] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
                             ` (4 subsequent siblings)
  9 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

Since regulator_put can handle NULL / IS_ERR(regulator)
use_reg can be removed, so that regulator_put in omap_hsmmc_reg_put
can be reused for vmmc_aux regulator error scenario.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 08f4ca7..533ced2 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -179,7 +179,6 @@ struct omap_hsmmc_host {
 	int			context_loss;
 	int			protect_card;
 	int			reqs_blocked;
-	int			use_reg;
 	int			req_in_progress;
 	struct omap_hsmmc_next	next_data;
 
@@ -1984,7 +1983,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		ret = omap_hsmmc_reg_get(host);
 		if (ret)
 			goto err_irq_cd;
-		host->use_reg = 1;
 	}
 
 	mmc->ocr_avail = mmc_slot(host).ocr_mask;
@@ -2038,8 +2036,7 @@ err_slot_name:
 	mmc_remove_host(mmc);
 	free_irq(mmc_slot(host).card_detect_irq, host);
 err_irq_cd:
-	if (host->use_reg)
-		omap_hsmmc_reg_put(host);
+	omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 err_irq_cd_init:
@@ -2075,8 +2072,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
 	pm_runtime_get_sync(host->dev);
 	mmc_remove_host(host->mmc);
-	if (host->use_reg)
-		omap_hsmmc_reg_put(host);
+	omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
 	free_irq(host->irq, host);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (4 preceding siblings ...)
  2013-06-06 19:14           ` [PATCH v2 05/10] mmc: omap_hsmmc: remove use_reg Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-12 14:37             ` Tony Lindgren
  2013-06-13  9:37             ` Linus Walleij
  2013-06-06 19:14           ` [PATCH v2 07/10] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
                             ` (3 subsequent siblings)
  9 siblings, 2 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

PBIAS register configuration is based on the regulator voltage
which supplies these pbias cells, sd i/o pads.
With PBIAS register address and bit definitions different across
omap[3,4,5], Simplify PBIAS configuration under three different
regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
are defined as pbias_off, pbias_1v8, pbias_3v.

pinctrl state mmc_init is used for configuring speed mode, loopback clock
(in devconf0/devconf1/prog_io1 register for omap3) and pull strength
configuration (in control_mmc1 for omap4)

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   83 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 533ced2..8dd1cd3 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -182,6 +182,9 @@ struct omap_hsmmc_host {
 	int			req_in_progress;
 	struct omap_hsmmc_next	next_data;
 
+	struct pinctrl		*pinctrl;
+	struct pinctrl_state	*pbias_off, *pbias_1v8, *pbias_3v, *mmc_init;
+
 	struct	omap_mmc_platform_data	*pdata;
 	int needs_vmmc:1;
 	int needs_vmmc_aux:1;
@@ -267,6 +270,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
 
+	if (host->pinctrl && host->pbias_off) {
+		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
+		if (ret < 0)
+			dev_err(host->dev, "pinctrl pbias_off select error\n");
+	}
+
 	/*
 	 * Assume Vcc regulator is used only to power the card ... OMAP
 	 * VDDS is used to power the pins, optionally with a transceiver to
@@ -304,6 +313,25 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	if (mmc_slot(host).after_set_reg)
 		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
 
+	/* 100ms delay required for PBIAS configuration */
+	msleep(100);
+	if (!vdd && host->pinctrl && host->pbias_off) {
+		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
+		if (ret < 0)
+			dev_err(host->dev, "pinctrl pbias_off select error\n");
+	} else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
+			host->pbias_1v8) {
+		ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
+		if (ret < 0)
+			dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
+	} else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
+			host->pbias_3v) {
+		ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
+		if (ret < 0)
+			dev_err(host->dev, "pinctrl pbias_3v select error\n");
+	}
+	usleep_range(350, 400);
+
 	return ret;
 }
 
@@ -1775,6 +1803,52 @@ static inline struct omap_mmc_platform_data
 }
 #endif
 
+static int omap_hsmmc_pinctrl_init(struct omap_hsmmc_host *host)
+{
+	int ret = 0;
+
+	host->pinctrl = devm_pinctrl_get(host->dev);
+	if (IS_ERR(host->pinctrl)) {
+		host->pinctrl = NULL;
+		dev_warn(host->dev,
+			 "pins are not configured from the driver\n");
+		return 0;
+	}
+
+	host->mmc_init = pinctrl_lookup_state(host->pinctrl, "mmc_init");
+	if (IS_ERR(host->mmc_init)) {
+		dev_vdbg(host->dev, "optional: mmc_init lookup error");
+		host->mmc_init = NULL;
+	} else {
+		ret = pinctrl_select_state(host->pinctrl, host->mmc_init);
+		if (ret < 0) {
+			dev_err(host->dev, "pinctrl mmc_init select error\n");
+			goto err_pinctrl;
+		}
+	}
+
+	host->pbias_off = pinctrl_lookup_state(host->pinctrl, "pbias_off");
+	if (IS_ERR(host->pbias_off)) {
+		dev_vdbg(host->dev, "optional: pbias_off lookup error");
+		host->pbias_off = NULL;
+	}
+
+	host->pbias_1v8 = pinctrl_lookup_state(host->pinctrl, "pbias_1v8");
+	if (IS_ERR(host->pbias_1v8)) {
+		dev_vdbg(host->dev, "optional: pbias_1v8 lookup error");
+		host->pbias_1v8 = NULL;
+	}
+
+	host->pbias_3v = pinctrl_lookup_state(host->pinctrl, "pbias_3v");
+	if (IS_ERR(host->pbias_3v)) {
+		dev_vdbg(host->dev, "optional: pbias_3v lookup error");
+		host->pbias_3v = NULL;
+	}
+
+err_pinctrl:
+	return ret;
+}
+
 static int omap_hsmmc_probe(struct platform_device *pdev)
 {
 	struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
@@ -1785,7 +1859,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	const struct of_device_id *match;
 	dma_cap_mask_t mask;
 	unsigned tx_req, rx_req;
-	struct pinctrl *pinctrl;
 
 	match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
 	if (match) {
@@ -2005,10 +2078,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_disable_irq(host);
 
-	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
-	if (IS_ERR(pinctrl))
-		dev_warn(&pdev->dev,
-			"pins are not configured from the driver\n");
+	ret = omap_hsmmc_pinctrl_init(host);
+	if (ret)
+		goto err_pinctrl_state;
 
 	omap_hsmmc_protect_card(host);
 
@@ -2034,6 +2106,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 err_slot_name:
 	mmc_remove_host(mmc);
+err_pinctrl_state:
 	free_irq(mmc_slot(host).card_detect_irq, host);
 err_irq_cd:
 	omap_hsmmc_reg_put(host);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 07/10] mmc: omap_hsmmc: remove dt pbias workaround
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (5 preceding siblings ...)
  2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
       [not found]           ` <1370546059-24181-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
                             ` (2 subsequent siblings)
  9 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

With pbias support in place remove dt workaround for pbias

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 8dd1cd3..f2e3d1a 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -161,7 +161,6 @@ struct omap_hsmmc_host {
 	 */
 	struct	regulator	*vcc;
 	struct	regulator	*vcc_aux;
-	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
 	spinlock_t		irq_lock; /* Prevent races with irq handler */
@@ -259,13 +258,6 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 */
 	if (!host->vcc && !host->vcc_aux)
 		return 0;
-	/*
-	 * With DT, never turn OFF the regulator for MMC1. This is because
-	 * the pbias cell programming support is still missing when
-	 * booting with Device tree
-	 */
-	if (host->pbias_disable && !vdd)
-		return 0;
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
@@ -1552,13 +1544,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * of external transceiver; but they all handle 1.8V.
 		 */
 		if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
-			(ios->vdd == DUAL_VOLT_OCR_BIT) &&
-			/*
-			 * With pbias cell programming missing, this
-			 * can't be allowed on MMC1 when booting with device
-			 * tree.
-			 */
-			!host->pbias_disable) {
+			(ios->vdd == DUAL_VOLT_OCR_BIT)) {
 				/*
 				 * The mmc_select_voltage fn of the core does
 				 * not seem to set the power_mode to
@@ -1956,10 +1942,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_context_save(host);
 
-	/* This can be removed once we support PBIAS with DT */
-	if (host->dev->of_node && host->mapbase == 0x4809c000)
-		host->pbias_disable = 1;
-
 	host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
 	/*
 	 * MMC can still work without debounce clock.
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core
       [not found]           ` <1370546059-24181-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-06-06 19:14             ` Balaji T K
  2013-06-12 14:35               ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, cjb-2X9k7bc8m7Mdnm+yROfE0A,
	tony-4v6yS6AI5VpBDgjK7y7TUQ, b-cousson-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: Balaji T K

omap3_pmx_core: padconf register are in two banks 0x48003000 to 0x48002268
and 0x480025c0 to 0x480025f8.

split omap3_pmx_core into 2 banks as register between 0x48002270 and 0x48002564
belongs to type pinctrl-single,bit-per-mux with access to certain bit
fields with bit field mask.

Signed-off-by: Balaji T K <balajitk-l0cyMroinI0@public.gmane.org>
---
 arch/arm/boot/dts/omap3-beagle.dts |   28 ++++++++++++++++++++--------
 arch/arm/boot/dts/omap3.dtsi       |   11 ++++++++++-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index 6eec699..7da9979 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -76,17 +76,11 @@
 &omap3_pmx_core {
 	pinctrl-names = "default";
 	pinctrl-0 = <
-			&hsusbb2_pins
+			&hsusbb2_pins1
 	>;
 
-	hsusbb2_pins: pinmux_hsusbb2_pins {
+	hsusbb2_pins1: pinmux_hsusbb2_pins1 {
 		pinctrl-single,pins = <
-			0x5c0 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
-			0x5c2 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
-			0x5c4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
-			0x5c6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
-			0x5c8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
-			0x5cA 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
 			0x1a4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
 			0x1a6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
 			0x1a8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
@@ -97,6 +91,24 @@
 	};
 };
 
+&omap3_pmx_core2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <
+			&hsusbb2_pins2
+	>;
+
+	hsusbb2_pins2: pinmux_hsusbb2_pins2 {
+		pinctrl-single,pins = <
+			0x50 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
+			0x52 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
+			0x54 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
+			0x56 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
+			0x58 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
+			0x5A 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
+		>;
+	};
+};
+
 &i2c1 {
 	clock-frequency = <2600000>;
 
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 82a404d..caaa708 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -95,7 +95,16 @@
 
 		omap3_pmx_core: pinmux@48002030 {
 			compatible = "ti,omap3-padconf", "pinctrl-single";
-			reg = <0x48002030 0x05cc>;
+			reg = <0x48002030 0x238>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			pinctrl-single,register-width = <16>;
+			pinctrl-single,function-mask = <0x7f1f>;
+		};
+
+		omap3_pmx_core2: pinmux@480025a0 {
+			compatible = "ti,omap3-padconf", "pinctrl-single";
+			reg = <0x480025a0 0x5c>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 			pinctrl-single,register-width = <16>;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (7 preceding siblings ...)
       [not found]           ` <1370546059-24181-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-12 14:35             ` Tony Lindgren
  2013-06-06 19:14           ` [PATCH v2 10/10] ARM: dts: omap4: " Balaji T K
  9 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

add pbias states for pbias 0, 1.8V, 3V
add omap3 sd/mmc2 loop back clock config for devconf1 in mmc2_init pinctrl state
add OMAP3430 sd/mmc1 loop back clock config for devconf0 in mmc1_init pinctrl state
add OMAP3630 sd/mmc1 speed mode config for prog_io1 in mmc1_init pinctrl state

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap3-beagle-xm.dts |   42 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/omap3-beagle.dts    |   42 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/omap3.dtsi          |   10 ++++++++
 3 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts
index 3046d1f..45d1642 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -59,6 +59,40 @@
 	};
 };
 
+&omap3_pmx_general {
+	pinctrl-names = "default";
+	pinctrl-0 = <>;
+	pbias_off: pinmux_pbias_off {
+		pinctrl-single,bits = <
+			0x2b0 0x1 0x3	/* pbias */
+		>;
+	};
+
+	pbias_1v8: pinmux_pbias_1v8 {
+		pinctrl-single,bits = <
+			0x2b0 0x2 0x3	/* pbias */
+		>;
+	};
+
+	pbias_3v: pinmux_pbias_3v {
+		pinctrl-single,bits = <
+			0x2b0 0x3 0x3	/* pbias */
+		>;
+	};
+
+	mmc1_init: pinmux_mmc1_init {
+		pinctrl-single,bits = <
+			0x1d8 0x100000 0x100000	/* prog_io1 */
+		>;
+	};
+
+	mmc2_init: pinmux_mmc2_init {
+		pinctrl-single,bits = <
+			0x68 0x40 0x40	/* devconf1 */
+		>;
+	};
+};
+
 &i2c1 {
 	clock-frequency = <2600000>;
 
@@ -95,12 +129,20 @@
 };
 
 &mmc1 {
+	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
+	pinctrl-0 = <>;
+	pinctrl-1 = <&mmc1_init>;
+	pinctrl-2 = <&pbias_off>;
+	pinctrl-3 = <&pbias_1v8>;
+	pinctrl-4 = <&pbias_3v>;
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
 	bus-width = <8>;
 };
 
 &mmc2 {
+	pinctrl-names = "mmc_init";
+	pinctrl-1 = <&mmc2_init>;
 	status = "disabled";
 };
 
diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index 7da9979..14e251f 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -109,6 +109,40 @@
 	};
 };
 
+&omap3_pmx_general {
+	pinctrl-names = "default";
+	pinctrl-0 = <>;
+	pbias_off: pinmux_pbias_off {
+		pinctrl-single,bits = <
+			0x2b0 0x5 0x7	/* pbias */
+		>;
+	};
+
+	pbias_1v8: pinmux_pbias_1v8 {
+		pinctrl-single,bits = <
+			0x2b0 0x6 0x7	/* pbias */
+		>;
+	};
+
+	pbias_3v: pinmux_pbias_3v {
+		pinctrl-single,bits = <
+			0x2b0 0x7 0x7	/* pbias */
+		>;
+	};
+
+	mmc1_init: pinmux_mmc1_init {
+		pinctrl-single,bits = <
+			0x4 0x01000000 0x01000000	/* devconf0 */
+		>;
+	};
+
+	mmc2_init: pinmux_mmc2_init {
+		pinctrl-single,bits = <
+			0x68 0x40 0x40	/* devconf1 */
+		>;
+	};
+};
+
 &i2c1 {
 	clock-frequency = <2600000>;
 
@@ -122,12 +156,20 @@
 /include/ "twl4030.dtsi"
 
 &mmc1 {
+	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
+	pinctrl-0 = <>;
+	pinctrl-1 = <&mmc1_init>;
+	pinctrl-2 = <&pbias_off>;
+	pinctrl-3 = <&pbias_1v8>;
+	pinctrl-4 = <&pbias_3v>;
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
 	bus-width = <8>;
 };
 
 &mmc2 {
+	pinctrl-names = "mmc_init";
+	pinctrl-1 = <&mmc2_init>;
 	status = "disabled";
 };
 
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index caaa708..de2940d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -111,6 +111,16 @@
 			pinctrl-single,function-mask = <0x7f1f>;
 		};
 
+		omap3_pmx_general: pinmux@48002270 {
+			compatible = "ti,omap3-padconf", "pinctrl-single";
+			reg = <0x48002270 0x2f4>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			pinctrl-single,bit-per-mux;
+			pinctrl-single,register-width = <32>;
+			pinctrl-single,function-mask = <0xffffffff>;
+		};
+
 		omap3_pmx_wkup: pinmux@0x48002a00 {
 			compatible = "ti,omap3-padconf", "pinctrl-single";
 			reg = <0x48002a00 0x5c>;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v2 10/10] ARM: dts: omap4: add pbias and mmc_init pinctrl states
  2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
                             ` (8 preceding siblings ...)
  2013-06-06 19:14           ` [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states Balaji T K
@ 2013-06-06 19:14           ` Balaji T K
  2013-06-12 14:36             ` Tony Lindgren
  9 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-06 19:14 UTC (permalink / raw)
  To: linux-omap, linux-mmc, cjb, tony, b-cousson, devicetree-discuss
  Cc: Balaji T K

add pbias states for pbias 0, 1.8V, 3V
add sd/mmc1 pull strength values for control_mmc1 in mmc_init pinctrl state

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/omap4-panda-common.dtsi |   34 +++++++++++++++++++++++++++++
 arch/arm/boot/dts/omap4-sdp.dts           |   34 +++++++++++++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi              |   11 +++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4-panda-common.dtsi b/arch/arm/boot/dts/omap4-panda-common.dtsi
index 03bd60d..d6ffbb1 100644
--- a/arch/arm/boot/dts/omap4-panda-common.dtsi
+++ b/arch/arm/boot/dts/omap4-panda-common.dtsi
@@ -137,6 +137,34 @@
 	};
 };
 
+&omap4_padconf_global {
+	pinctrl-names = "default";
+	pinctrl-0 = <>;
+	pbias_off: pinmux_pbias_off {
+		pinctrl-single,bits = <
+			0x60 0x00000000 0x07e00000	/* pbias */
+		>;
+	};
+
+	pbias_1v8: pinmux_pbias_1v8 {
+		pinctrl-single,bits = <
+			0x60 0x04400000 0x07e00000	/* pbias */
+		>;
+	};
+
+	pbias_3v: pinmux_pbias_3v {
+		pinctrl-single,bits = <
+			0x60 0x04600000 0x07e00000	/* pbias */
+		>;
+	};
+
+	mmc1_init: pinmux_mmc1_init {
+		pinctrl-single,bits = <
+			0x88 0xce000000 0xfe000000	/* control_mmc1 */
+		>;
+	};
+};
+
 &i2c1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c1_pins>;
@@ -197,6 +225,12 @@
 };
 
 &mmc1 {
+	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
+	pinctrl-0 = <>;
+	pinctrl-1 = <&mmc1_init>;
+	pinctrl-2 = <&pbias_off>;
+	pinctrl-3 = <&pbias_1v8>;
+	pinctrl-4 = <&pbias_3v>;
 	vmmc-supply = <&vmmc>;
 	bus-width = <8>;
 };
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index a35d9cd..b1c0e86 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -142,6 +142,34 @@
 	};
 };
 
+&omap4_padconf_global {
+	pinctrl-names = "default";
+	pinctrl-0 = <>;
+	pbias_off: pinmux_pbias_off {
+		pinctrl-single,bits = <
+			0x60 0x00000000 0x07e00000	/* pbias */
+		>;
+	};
+
+	pbias_1v8: pinmux_pbias_1v8 {
+		pinctrl-single,bits = <
+			0x60 0x04400000 0x07e00000	/* pbias */
+		>;
+	};
+
+	pbias_3v: pinmux_pbias_3v {
+		pinctrl-single,bits = <
+			0x60 0x04600000 0x07e00000	/* pbias */
+		>;
+	};
+
+	mmc1_init: pinmux_mmc1_init {
+		pinctrl-single,bits = <
+			0x88 0xce000000 0xfe000000	/* control_mmc1 */
+		>;
+	};
+};
+
 &omap4_pmx_core {
 	pinctrl-names = "default";
 	pinctrl-0 = <
@@ -381,6 +409,12 @@
 };
 
 &mmc1 {
+	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
+	pinctrl-0 = <>;
+	pinctrl-1 = <&mmc1_init>;
+	pinctrl-2 = <&pbias_off>;
+	pinctrl-3 = <&pbias_1v8>;
+	pinctrl-4 = <&pbias_3v>;
 	vmmc-supply = <&vmmc>;
 	bus-width = <8>;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 2a56428..41f575d 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -114,6 +114,17 @@
 			pinctrl-single,register-width = <16>;
 			pinctrl-single,function-mask = <0x7fff>;
 		};
+
+		omap4_padconf_global: pinmux@4a100600 {
+			compatible = "ti,omap4-padconf", "pinctrl-single";
+			reg = <0x4a1005a0 0x170>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			pinctrl-single,bit-per-mux;
+			pinctrl-single,register-width = <32>;
+			pinctrl-single,function-mask = <0xffffffff>;
+		};
+
 		omap4_pmx_wkup: pinmux@4a31e040 {
 			compatible = "ti,omap4-padconf", "pinctrl-single";
 			reg = <0x4a31e040 0x0038>;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info
  2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
@ 2013-06-12 14:24             ` Tony Lindgren
       [not found]               ` <20130612142409.GW8164-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:24 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> Add needs_vmmc and needs_vmmc_aux to indicate whether regulator is
> applicable so that omap_hsmmc can handle deferred probe error
> properly for regulators.
> Remove the assumption that vmmc_aux regulator to be available only if vmmc is
> present. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
> in such cases regulator needed not be specified in board file.

Looks good to me, I suggest you resend this again a bit later once the
other changes are merged so we can avoid a dependency between arch/arm/mach-omap2
and MMC changes.

Regards,

Tony
 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  arch/arm/mach-omap2/board-2430sdp.c          |    1 +
>  arch/arm/mach-omap2/board-3430sdp.c          |    3 +++
>  arch/arm/mach-omap2/board-cm-t35.c           |    2 ++
>  arch/arm/mach-omap2/board-devkit8000.c       |    1 +
>  arch/arm/mach-omap2/board-igep0020.c         |    3 +++
>  arch/arm/mach-omap2/board-ldp.c              |    1 +
>  arch/arm/mach-omap2/board-omap3beagle.c      |    2 ++
>  arch/arm/mach-omap2/board-omap3evm.c         |    3 +++
>  arch/arm/mach-omap2/board-omap3logic.c       |    1 +
>  arch/arm/mach-omap2/board-omap3pandora.c     |    3 +++
>  arch/arm/mach-omap2/board-omap3stalker.c     |    2 ++
>  arch/arm/mach-omap2/board-omap3touchbook.c   |    2 ++
>  arch/arm/mach-omap2/board-overo.c            |    1 +
>  arch/arm/mach-omap2/board-rm680.c            |    1 +
>  arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +++
>  arch/arm/mach-omap2/board-zoom-peripherals.c |    4 ++++
>  arch/arm/mach-omap2/hsmmc.c                  |    2 ++
>  arch/arm/mach-omap2/hsmmc.h                  |    2 ++
>  include/linux/platform_data/mmc-omap.h       |    2 ++
>  19 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
> index 244d8a5..eba8593 100644
> --- a/arch/arm/mach-omap2/board-2430sdp.c
> +++ b/arch/arm/mach-omap2/board-2430sdp.c
> @@ -211,6 +211,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
>  		.ext_clock	= 1,
> +		.needs_vmmc	= 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
> index 23b004a..9438c54 100644
> --- a/arch/arm/mach-omap2/board-3430sdp.c
> +++ b/arch/arm/mach-omap2/board-3430sdp.c
> @@ -184,12 +184,15 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
>  		.gpio_wp	= 4,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{
>  		.mmc		= 2,
>  		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
>  		.gpio_wp	= 7,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
> index ee6218c..207ea13 100644
> --- a/arch/arm/mach-omap2/board-cm-t35.c
> +++ b/arch/arm/mach-omap2/board-cm-t35.c
> @@ -364,6 +364,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{
>  		.mmc		= 2,
> diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
> index 5764205..63fd8827 100644
> --- a/arch/arm/mach-omap2/board-devkit8000.c
> +++ b/arch/arm/mach-omap2/board-devkit8000.c
> @@ -99,6 +99,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
>  		.gpio_wp	= 29,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
> index b54562d..a2a8a80 100644
> --- a/arch/arm/mach-omap2/board-igep0020.c
> +++ b/arch/arm/mach-omap2/board-igep0020.c
> @@ -284,6 +284,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
>  	},
>  #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
>  	{
> @@ -291,6 +292,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA,
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  #endif
>  	{}      /* Terminator */
> diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
> index d0d17bc..62c1a2d 100644
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -315,6 +315,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
>  		.caps		= MMC_CAP_4_BIT_DATA,
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
> +		.needs_vmmc	= 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index 04c1165..5063ac3 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -264,6 +264,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA,
>  		.gpio_wp	= -EINVAL,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
> index f76d0de..a9a7507 100644
> --- a/arch/arm/mach-omap2/board-omap3evm.c
> +++ b/arch/arm/mach-omap2/board-omap3evm.c
> @@ -279,6 +279,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= 63,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  #ifdef CONFIG_WILINK_PLATFORM_DATA
>  	{
> @@ -288,6 +290,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_wp	= -EINVAL,
>  		.gpio_cd	= -EINVAL,
>  		.nonremovable	= true,
> +		.needs_vmmc	= 1,
>  	},
>  #endif
>  	{}	/* Terminator */
> diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
> index bab51e6..ff00c81 100644
> --- a/arch/arm/mach-omap2/board-omap3logic.c
> +++ b/arch/arm/mach-omap2/board-omap3logic.c
> @@ -104,6 +104,7 @@ static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA,
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
> +		.needs_vmmc	= 1,
>  	},
>  	{}      /* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
> index 28133d5..c22cf74 100644
> --- a/arch/arm/mach-omap2/board-omap3pandora.c
> +++ b/arch/arm/mach-omap2/board-omap3pandora.c
> @@ -283,6 +283,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
>  		.gpio_wp	= 126,
>  		.ext_clock	= 0,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{
>  		.mmc		= 2,
> @@ -292,6 +293,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
>  		.ext_clock	= 1,
>  		.transceiver	= true,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{
>  		.mmc		= 3,
> @@ -299,6 +301,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
>  		.init_card	= pandora_wl1251_init_card,
> +		.needs_vmmc	= 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
> index d37e6b1..cc1b374 100644
> --- a/arch/arm/mach-omap2/board-omap3stalker.c
> +++ b/arch/arm/mach-omap2/board-omap3stalker.c
> @@ -172,6 +172,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= 23,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	 },
>  	{}			/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
> index 7da48bc..1087b71 100644
> --- a/arch/arm/mach-omap2/board-omap3touchbook.c
> +++ b/arch/arm/mach-omap2/board-omap3touchbook.c
> @@ -103,6 +103,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
>  		.gpio_wp	= 29,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
> index 4ca6b68..77d1ffc 100644
> --- a/arch/arm/mach-omap2/board-overo.c
> +++ b/arch/arm/mach-omap2/board-overo.c
> @@ -255,6 +255,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.caps		= MMC_CAP_4_BIT_DATA,
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
> +		.needs_vmmc	= 1,
>  	},
>  	{
>  		.mmc		= 2,
> diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
> index 345e8c4..9d4bcc1 100644
> --- a/arch/arm/mach-omap2/board-rm680.c
> +++ b/arch/arm/mach-omap2/board-rm680.c
> @@ -106,6 +106,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
>  		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED,
>  		.gpio_cd	= -EINVAL,
>  		.gpio_wp	= -EINVAL,
> +		.needs_vmmc	= 1,
>  	},
>  	{ /* Terminator */ }
>  };
> diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
> index 18ca61e..4f4aad5 100644
> --- a/arch/arm/mach-omap2/board-rx51-peripherals.c
> +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
> @@ -496,6 +496,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
>  		.gpio_cd	= 160,
>  		.gpio_wp	= -EINVAL,
>  		.power_saving	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{
>  		.name		= "internal",
> @@ -507,6 +508,8 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
>  		.nonremovable	= true,
>  		.power_saving	= true,
>  		.remux		= rx51_mmc2_remux,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{}	/* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
> index a90375d..b6a49c3 100644
> --- a/arch/arm/mach-omap2/board-zoom-peripherals.c
> +++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
> @@ -255,6 +255,8 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_wp	= -EINVAL,
>  		.power_saving	= true,
>  		.deferred	= true,
> +		.needs_vmmc	= 1,
> +		.needs_vmmc_aux = 1,
>  	},
>  	{
>  		.name		= "internal",
> @@ -264,6 +266,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_wp	= -EINVAL,
>  		.nonremovable	= true,
>  		.power_saving	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{
>  		.name		= "wl1271",
> @@ -272,6 +275,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  		.gpio_wp	= -EINVAL,
>  		.gpio_cd	= -EINVAL,
>  		.nonremovable	= true,
> +		.needs_vmmc	= 1,
>  	},
>  	{}      /* Terminator */
>  };
> diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
> index 2ef1f87..9e8b02c 100644
> --- a/arch/arm/mach-omap2/hsmmc.c
> +++ b/arch/arm/mach-omap2/hsmmc.c
> @@ -313,6 +313,8 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
>  								c->mmc, 1);
>  	mmc->slots[0].name = hc_name;
>  	mmc->nr_slots = 1;
> +	mmc->needs_vmmc = c->needs_vmmc;
> +	mmc->needs_vmmc_aux = c->needs_vmmc_aux;
>  	mmc->slots[0].caps = c->caps;
>  	mmc->slots[0].pm_caps = c->pm_caps;
>  	mmc->slots[0].internal_clock = !c->ext_clock;
> diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
> index 7f2e790..9bc71ee 100644
> --- a/arch/arm/mach-omap2/hsmmc.h
> +++ b/arch/arm/mach-omap2/hsmmc.h
> @@ -33,6 +33,8 @@ struct omap2_hsmmc_info {
>  	void (*remux)(struct device *dev, int slot, int power_on);
>  	/* init some special card */
>  	void (*init_card)(struct mmc_card *card);
> +	unsigned needs_vmmc:1;
> +	unsigned needs_vmmc_aux:1;
>  };
>  
>  #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
> diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
> index 2bf1b30..11583a6 100644
> --- a/include/linux/platform_data/mmc-omap.h
> +++ b/include/linux/platform_data/mmc-omap.h
> @@ -66,6 +66,8 @@ struct omap_mmc_platform_data {
>  
>  	/* Register offset deviation */
>  	u16 reg_offset;
> +	unsigned needs_vmmc:1;
> +	unsigned needs_vmmc_aux:1;
>  
>  	struct omap_mmc_slot_data {
>  
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent
  2013-06-06 19:14           ` [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
@ 2013-06-12 14:25             ` Tony Lindgren
  2013-06-12 14:33               ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:25 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> handle vcc and vcc_aux independently
> 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 1865321..bda1a42 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -253,7 +253,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  	 * If we don't see a Vcc regulator, assume it's a fixed
>  	 * voltage always-on regulator.
>  	 */
> -	if (!host->vcc)
> +	if (!host->vcc && !host->vcc_aux)
>  		return 0;
>  	/*
>  	 * With DT, never turn OFF the regulator for MMC1. This is because

Doesn't the above change break MMC for most boards that only pass
one regulator and no aux regulator?

Regards,

Tony

> @@ -280,11 +280,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  	 * chips/cards need an interface voltage rail too.
>  	 */
>  	if (power_on) {
> -		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
> +		if (host->vcc)
> +			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>  		/* Enable interface voltage rail, if needed */
>  		if (ret == 0 && host->vcc_aux) {
>  			ret = regulator_enable(host->vcc_aux);
> -			if (ret < 0)
> +			if (ret < 0 && host->vcc)
>  				ret = mmc_regulator_set_ocr(host->mmc,
>  							host->vcc, 0);
>  		}
> @@ -292,7 +293,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  		/* Shut down the rail */
>  		if (host->vcc_aux)
>  			ret = regulator_disable(host->vcc_aux);
> -		if (!ret) {
> +		if (host->vcc) {
>  			/* Then proceed to shut down the local regulator */
>  			ret = mmc_regulator_set_ocr(host->mmc,
>  						host->vcc, 0);
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent
  2013-06-12 14:25             ` Tony Lindgren
@ 2013-06-12 14:33               ` Balaji T K
  2013-06-12 14:38                 ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-12 14:33 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

On Wednesday 12 June 2013 07:55 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [130606 12:20]:
>> handle vcc and vcc_aux independently
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   drivers/mmc/host/omap_hsmmc.c |    9 +++++----
>>   1 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index 1865321..bda1a42 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -253,7 +253,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>   	 * If we don't see a Vcc regulator, assume it's a fixed
>>   	 * voltage always-on regulator.
>>   	 */
>> -	if (!host->vcc)
>> +	if (!host->vcc && !host->vcc_aux)
>>   		return 0;
>>   	/*
>>   	 * With DT, never turn OFF the regulator for MMC1. This is because
>
> Doesn't the above change break MMC for most boards that only pass
> one regulator and no aux regulator?
>

No, I want to skip regulator operation in set_power function iff both
regulator are not present.

Earlier vcc was assumed/mandatory if vcc_aux is present.
Now, regulator operation will be handled if either one of vcc/vcc_aux is present,

> Regards,
>
> Tony
>
>> @@ -280,11 +280,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>   	 * chips/cards need an interface voltage rail too.
>>   	 */
>>   	if (power_on) {
>> -		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>> +		if (host->vcc)
>> +			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>>   		/* Enable interface voltage rail, if needed */
>>   		if (ret == 0 && host->vcc_aux) {
>>   			ret = regulator_enable(host->vcc_aux);
>> -			if (ret < 0)
>> +			if (ret < 0 && host->vcc)
>>   				ret = mmc_regulator_set_ocr(host->mmc,
>>   							host->vcc, 0);
>>   		}
>> @@ -292,7 +293,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>   		/* Shut down the rail */
>>   		if (host->vcc_aux)
>>   			ret = regulator_disable(host->vcc_aux);
>> -		if (!ret) {
>> +		if (host->vcc) {
>>   			/* Then proceed to shut down the local regulator */
>>   			ret = mmc_regulator_set_ocr(host->mmc,
>>   						host->vcc, 0);
>> --
>> 1.7.5.4
>>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core
  2013-06-06 19:14             ` [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core Balaji T K
@ 2013-06-12 14:35               ` Tony Lindgren
  2013-06-12 17:08                 ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:35 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> omap3_pmx_core: padconf register are in two banks 0x48003000 to 0x48002268
> and 0x480025c0 to 0x480025f8.
> 
> split omap3_pmx_core into 2 banks as register between 0x48002270 and 0x48002564
> belongs to type pinctrl-single,bit-per-mux with access to certain bit
> fields with bit field mask.

Is this the right patch for the description? THe patch seems to deal with
USB pins.

Also, let's not hog any pins under the pinmux controllers, those make
unloading pinctrl-single impossible which is not nice for distros and
development.

Instead, the pins should be under mmc1 in omap[345].dtsi files.

Regards,

Tony
 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  arch/arm/boot/dts/omap3-beagle.dts |   28 ++++++++++++++++++++--------
>  arch/arm/boot/dts/omap3.dtsi       |   11 ++++++++++-
>  2 files changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
> index 6eec699..7da9979 100644
> --- a/arch/arm/boot/dts/omap3-beagle.dts
> +++ b/arch/arm/boot/dts/omap3-beagle.dts
> @@ -76,17 +76,11 @@
>  &omap3_pmx_core {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <
> -			&hsusbb2_pins
> +			&hsusbb2_pins1
>  	>;
>  
> -	hsusbb2_pins: pinmux_hsusbb2_pins {
> +	hsusbb2_pins1: pinmux_hsusbb2_pins1 {
>  		pinctrl-single,pins = <
> -			0x5c0 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
> -			0x5c2 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
> -			0x5c4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
> -			0x5c6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
> -			0x5c8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
> -			0x5cA 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
>  			0x1a4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
>  			0x1a6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
>  			0x1a8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
> @@ -97,6 +91,24 @@
>  	};
>  };
>  
> +&omap3_pmx_core2 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <
> +			&hsusbb2_pins2
> +	>;
> +
> +	hsusbb2_pins2: pinmux_hsusbb2_pins2 {
> +		pinctrl-single,pins = <
> +			0x50 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
> +			0x52 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
> +			0x54 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
> +			0x56 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
> +			0x58 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
> +			0x5A 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
> +		>;
> +	};
> +};
> +
>  &i2c1 {
>  	clock-frequency = <2600000>;
>  
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 82a404d..caaa708 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -95,7 +95,16 @@
>  
>  		omap3_pmx_core: pinmux@48002030 {
>  			compatible = "ti,omap3-padconf", "pinctrl-single";
> -			reg = <0x48002030 0x05cc>;
> +			reg = <0x48002030 0x238>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +			pinctrl-single,register-width = <16>;
> +			pinctrl-single,function-mask = <0x7f1f>;
> +		};
> +
> +		omap3_pmx_core2: pinmux@480025a0 {
> +			compatible = "ti,omap3-padconf", "pinctrl-single";
> +			reg = <0x480025a0 0x5c>;
>  			#address-cells = <1>;
>  			#size-cells = <0>;
>  			pinctrl-single,register-width = <16>;
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states
  2013-06-06 19:14           ` [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states Balaji T K
@ 2013-06-12 14:35             ` Tony Lindgren
  2013-06-12 17:43               ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:35 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> add pbias states for pbias 0, 1.8V, 3V
> add omap3 sd/mmc2 loop back clock config for devconf1 in mmc2_init pinctrl state
> add OMAP3430 sd/mmc1 loop back clock config for devconf0 in mmc1_init pinctrl state
> add OMAP3630 sd/mmc1 speed mode config for prog_io1 in mmc1_init pinctrl state

Looks OK to me, except these should be under mmc1 for omap[345].dtsi files.

Regards,

Tony
 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  arch/arm/boot/dts/omap3-beagle-xm.dts |   42 +++++++++++++++++++++++++++++++++
>  arch/arm/boot/dts/omap3-beagle.dts    |   42 +++++++++++++++++++++++++++++++++
>  arch/arm/boot/dts/omap3.dtsi          |   10 ++++++++
>  3 files changed, 94 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts
> index 3046d1f..45d1642 100644
> --- a/arch/arm/boot/dts/omap3-beagle-xm.dts
> +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
> @@ -59,6 +59,40 @@
>  	};
>  };
>  
> +&omap3_pmx_general {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <>;
> +	pbias_off: pinmux_pbias_off {
> +		pinctrl-single,bits = <
> +			0x2b0 0x1 0x3	/* pbias */
> +		>;
> +	};
> +
> +	pbias_1v8: pinmux_pbias_1v8 {
> +		pinctrl-single,bits = <
> +			0x2b0 0x2 0x3	/* pbias */
> +		>;
> +	};
> +
> +	pbias_3v: pinmux_pbias_3v {
> +		pinctrl-single,bits = <
> +			0x2b0 0x3 0x3	/* pbias */
> +		>;
> +	};
> +
> +	mmc1_init: pinmux_mmc1_init {
> +		pinctrl-single,bits = <
> +			0x1d8 0x100000 0x100000	/* prog_io1 */
> +		>;
> +	};
> +
> +	mmc2_init: pinmux_mmc2_init {
> +		pinctrl-single,bits = <
> +			0x68 0x40 0x40	/* devconf1 */
> +		>;
> +	};
> +};
> +
>  &i2c1 {
>  	clock-frequency = <2600000>;
>  
> @@ -95,12 +129,20 @@
>  };
>  
>  &mmc1 {
> +	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
> +	pinctrl-0 = <>;
> +	pinctrl-1 = <&mmc1_init>;
> +	pinctrl-2 = <&pbias_off>;
> +	pinctrl-3 = <&pbias_1v8>;
> +	pinctrl-4 = <&pbias_3v>;
>  	vmmc-supply = <&vmmc1>;
>  	vmmc_aux-supply = <&vsim>;
>  	bus-width = <8>;
>  };
>  
>  &mmc2 {
> +	pinctrl-names = "mmc_init";
> +	pinctrl-1 = <&mmc2_init>;
>  	status = "disabled";
>  };
>  
> diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
> index 7da9979..14e251f 100644
> --- a/arch/arm/boot/dts/omap3-beagle.dts
> +++ b/arch/arm/boot/dts/omap3-beagle.dts
> @@ -109,6 +109,40 @@
>  	};
>  };
>  
> +&omap3_pmx_general {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <>;
> +	pbias_off: pinmux_pbias_off {
> +		pinctrl-single,bits = <
> +			0x2b0 0x5 0x7	/* pbias */
> +		>;
> +	};
> +
> +	pbias_1v8: pinmux_pbias_1v8 {
> +		pinctrl-single,bits = <
> +			0x2b0 0x6 0x7	/* pbias */
> +		>;
> +	};
> +
> +	pbias_3v: pinmux_pbias_3v {
> +		pinctrl-single,bits = <
> +			0x2b0 0x7 0x7	/* pbias */
> +		>;
> +	};
> +
> +	mmc1_init: pinmux_mmc1_init {
> +		pinctrl-single,bits = <
> +			0x4 0x01000000 0x01000000	/* devconf0 */
> +		>;
> +	};
> +
> +	mmc2_init: pinmux_mmc2_init {
> +		pinctrl-single,bits = <
> +			0x68 0x40 0x40	/* devconf1 */
> +		>;
> +	};
> +};
> +
>  &i2c1 {
>  	clock-frequency = <2600000>;
>  
> @@ -122,12 +156,20 @@
>  /include/ "twl4030.dtsi"
>  
>  &mmc1 {
> +	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
> +	pinctrl-0 = <>;
> +	pinctrl-1 = <&mmc1_init>;
> +	pinctrl-2 = <&pbias_off>;
> +	pinctrl-3 = <&pbias_1v8>;
> +	pinctrl-4 = <&pbias_3v>;
>  	vmmc-supply = <&vmmc1>;
>  	vmmc_aux-supply = <&vsim>;
>  	bus-width = <8>;
>  };
>  
>  &mmc2 {
> +	pinctrl-names = "mmc_init";
> +	pinctrl-1 = <&mmc2_init>;
>  	status = "disabled";
>  };
>  
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index caaa708..de2940d 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -111,6 +111,16 @@
>  			pinctrl-single,function-mask = <0x7f1f>;
>  		};
>  
> +		omap3_pmx_general: pinmux@48002270 {
> +			compatible = "ti,omap3-padconf", "pinctrl-single";
> +			reg = <0x48002270 0x2f4>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +			pinctrl-single,bit-per-mux;
> +			pinctrl-single,register-width = <32>;
> +			pinctrl-single,function-mask = <0xffffffff>;
> +		};
> +
>  		omap3_pmx_wkup: pinmux@0x48002a00 {
>  			compatible = "ti,omap3-padconf", "pinctrl-single";
>  			reg = <0x48002a00 0x5c>;
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 10/10] ARM: dts: omap4: add pbias and mmc_init pinctrl states
  2013-06-06 19:14           ` [PATCH v2 10/10] ARM: dts: omap4: " Balaji T K
@ 2013-06-12 14:36             ` Tony Lindgren
  0 siblings, 0 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:36 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> add pbias states for pbias 0, 1.8V, 3V
> add sd/mmc1 pull strength values for control_mmc1 in mmc_init pinctrl state

This too should be under mmc1 in the omap4.dtsi file.

Tony
 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  arch/arm/boot/dts/omap4-panda-common.dtsi |   34 +++++++++++++++++++++++++++++
>  arch/arm/boot/dts/omap4-sdp.dts           |   34 +++++++++++++++++++++++++++++
>  arch/arm/boot/dts/omap4.dtsi              |   11 +++++++++
>  3 files changed, 79 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/omap4-panda-common.dtsi b/arch/arm/boot/dts/omap4-panda-common.dtsi
> index 03bd60d..d6ffbb1 100644
> --- a/arch/arm/boot/dts/omap4-panda-common.dtsi
> +++ b/arch/arm/boot/dts/omap4-panda-common.dtsi
> @@ -137,6 +137,34 @@
>  	};
>  };
>  
> +&omap4_padconf_global {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <>;
> +	pbias_off: pinmux_pbias_off {
> +		pinctrl-single,bits = <
> +			0x60 0x00000000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	pbias_1v8: pinmux_pbias_1v8 {
> +		pinctrl-single,bits = <
> +			0x60 0x04400000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	pbias_3v: pinmux_pbias_3v {
> +		pinctrl-single,bits = <
> +			0x60 0x04600000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	mmc1_init: pinmux_mmc1_init {
> +		pinctrl-single,bits = <
> +			0x88 0xce000000 0xfe000000	/* control_mmc1 */
> +		>;
> +	};
> +};
> +
>  &i2c1 {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&i2c1_pins>;
> @@ -197,6 +225,12 @@
>  };
>  
>  &mmc1 {
> +	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
> +	pinctrl-0 = <>;
> +	pinctrl-1 = <&mmc1_init>;
> +	pinctrl-2 = <&pbias_off>;
> +	pinctrl-3 = <&pbias_1v8>;
> +	pinctrl-4 = <&pbias_3v>;
>  	vmmc-supply = <&vmmc>;
>  	bus-width = <8>;
>  };
> diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
> index a35d9cd..b1c0e86 100644
> --- a/arch/arm/boot/dts/omap4-sdp.dts
> +++ b/arch/arm/boot/dts/omap4-sdp.dts
> @@ -142,6 +142,34 @@
>  	};
>  };
>  
> +&omap4_padconf_global {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <>;
> +	pbias_off: pinmux_pbias_off {
> +		pinctrl-single,bits = <
> +			0x60 0x00000000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	pbias_1v8: pinmux_pbias_1v8 {
> +		pinctrl-single,bits = <
> +			0x60 0x04400000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	pbias_3v: pinmux_pbias_3v {
> +		pinctrl-single,bits = <
> +			0x60 0x04600000 0x07e00000	/* pbias */
> +		>;
> +	};
> +
> +	mmc1_init: pinmux_mmc1_init {
> +		pinctrl-single,bits = <
> +			0x88 0xce000000 0xfe000000	/* control_mmc1 */
> +		>;
> +	};
> +};
> +
>  &omap4_pmx_core {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <
> @@ -381,6 +409,12 @@
>  };
>  
>  &mmc1 {
> +	pinctrl-names = "default", "mmc_init", "pbias_off", "pbias_1v8", "pbias_3v";
> +	pinctrl-0 = <>;
> +	pinctrl-1 = <&mmc1_init>;
> +	pinctrl-2 = <&pbias_off>;
> +	pinctrl-3 = <&pbias_1v8>;
> +	pinctrl-4 = <&pbias_3v>;
>  	vmmc-supply = <&vmmc>;
>  	bus-width = <8>;
>  };
> diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> index 2a56428..41f575d 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -114,6 +114,17 @@
>  			pinctrl-single,register-width = <16>;
>  			pinctrl-single,function-mask = <0x7fff>;
>  		};
> +
> +		omap4_padconf_global: pinmux@4a100600 {
> +			compatible = "ti,omap4-padconf", "pinctrl-single";
> +			reg = <0x4a1005a0 0x170>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +			pinctrl-single,bit-per-mux;
> +			pinctrl-single,register-width = <32>;
> +			pinctrl-single,function-mask = <0xffffffff>;
> +		};
> +
>  		omap4_pmx_wkup: pinmux@4a31e040 {
>  			compatible = "ti,omap4-padconf", "pinctrl-single";
>  			reg = <0x4a31e040 0x0038>;
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
@ 2013-06-12 14:37             ` Tony Lindgren
  2013-06-12 17:46               ` Balaji T K
  2013-06-13  9:38               ` Linus Walleij
  2013-06-13  9:37             ` Linus Walleij
  1 sibling, 2 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:37 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss, Linus Walleij

* Balaji T K <balajitk@ti.com> [130606 12:20]:
> PBIAS register configuration is based on the regulator voltage
> which supplies these pbias cells, sd i/o pads.
> With PBIAS register address and bit definitions different across
> omap[3,4,5], Simplify PBIAS configuration under three different
> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> are defined as pbias_off, pbias_1v8, pbias_3v.
> 
> pinctrl state mmc_init is used for configuring speed mode, loopback clock
> (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
> configuration (in control_mmc1 for omap4)
> 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |   83 ++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 78 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 533ced2..8dd1cd3 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -182,6 +182,9 @@ struct omap_hsmmc_host {
>  	int			req_in_progress;
>  	struct omap_hsmmc_next	next_data;
>  
> +	struct pinctrl		*pinctrl;
> +	struct pinctrl_state	*pbias_off, *pbias_1v8, *pbias_3v, *mmc_init;
> +
>  	struct	omap_mmc_platform_data	*pdata;
>  	int needs_vmmc:1;
>  	int needs_vmmc_aux:1;
> @@ -267,6 +270,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  	if (mmc_slot(host).before_set_reg)
>  		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
>  
> +	if (host->pinctrl && host->pbias_off) {
> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
> +		if (ret < 0)
> +			dev_err(host->dev, "pinctrl pbias_off select error\n");
> +	}
> +
>  	/*
>  	 * Assume Vcc regulator is used only to power the card ... OMAP
>  	 * VDDS is used to power the pins, optionally with a transceiver to
> @@ -304,6 +313,25 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>  	if (mmc_slot(host).after_set_reg)
>  		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
>  
> +	/* 100ms delay required for PBIAS configuration */
> +	msleep(100);

Hmm, why is the delay needed before the configuration? Is this something
you could avoid by reading the pinconf state maybe?

> +	if (!vdd && host->pinctrl && host->pbias_off) {
> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
> +		if (ret < 0)
> +			dev_err(host->dev, "pinctrl pbias_off select error\n");
> +	} else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
> +			host->pbias_1v8) {
> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
> +		if (ret < 0)
> +			dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
> +	} else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
> +			host->pbias_3v) {
> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
> +		if (ret < 0)
> +			dev_err(host->dev, "pinctrl pbias_3v select error\n");
> +	}
> +	usleep_range(350, 400);
> +
>  	return ret;
>  }

Maybe add some macro for doing the if (((1 << vdd) <= MMC_VDD_165_195)... tests?

> @@ -1775,6 +1803,52 @@ static inline struct omap_mmc_platform_data
>  }
>  #endif
>  
> +static int omap_hsmmc_pinctrl_init(struct omap_hsmmc_host *host)
> +{
> +	int ret = 0;
> +
> +	host->pinctrl = devm_pinctrl_get(host->dev);
> +	if (IS_ERR(host->pinctrl)) {
> +		host->pinctrl = NULL;
> +		dev_warn(host->dev,
> +			 "pins are not configured from the driver\n");
> +		return 0;
> +	}
> +
> +	host->mmc_init = pinctrl_lookup_state(host->pinctrl, "mmc_init");
> +	if (IS_ERR(host->mmc_init)) {
> +		dev_vdbg(host->dev, "optional: mmc_init lookup error");
> +		host->mmc_init = NULL;
> +	} else {
> +		ret = pinctrl_select_state(host->pinctrl, host->mmc_init);
> +		if (ret < 0) {
> +			dev_err(host->dev, "pinctrl mmc_init select error\n");
> +			goto err_pinctrl;
> +		}
> +	}
> +
> +	host->pbias_off = pinctrl_lookup_state(host->pinctrl, "pbias_off");
> +	if (IS_ERR(host->pbias_off)) {
> +		dev_vdbg(host->dev, "optional: pbias_off lookup error");
> +		host->pbias_off = NULL;
> +	}
> +
> +	host->pbias_1v8 = pinctrl_lookup_state(host->pinctrl, "pbias_1v8");
> +	if (IS_ERR(host->pbias_1v8)) {
> +		dev_vdbg(host->dev, "optional: pbias_1v8 lookup error");
> +		host->pbias_1v8 = NULL;
> +	}
> +
> +	host->pbias_3v = pinctrl_lookup_state(host->pinctrl, "pbias_3v");
> +	if (IS_ERR(host->pbias_3v)) {
> +		dev_vdbg(host->dev, "optional: pbias_3v lookup error");
> +		host->pbias_3v = NULL;
> +	}
> +
> +err_pinctrl:
> +	return ret;
> +}

Linus W may have some comments on this, although this is not the standard
muxing stuff. The "mmc_init" state pins should be added to just the regular
default state? Note that you can have phandles to however many sets of
pins there.

>  static int omap_hsmmc_probe(struct platform_device *pdev)
>  {
>  	struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
> @@ -1785,7 +1859,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>  	const struct of_device_id *match;
>  	dma_cap_mask_t mask;
>  	unsigned tx_req, rx_req;
> -	struct pinctrl *pinctrl;
>  
>  	match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
>  	if (match) {
> @@ -2005,10 +2078,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>  
>  	omap_hsmmc_disable_irq(host);
>  
> -	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> -	if (IS_ERR(pinctrl))
> -		dev_warn(&pdev->dev,
> -			"pins are not configured from the driver\n");
> +	ret = omap_hsmmc_pinctrl_init(host);
> +	if (ret)
> +		goto err_pinctrl_state;
>  
>  	omap_hsmmc_protect_card(host);
>  
> @@ -2034,6 +2106,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>  
>  err_slot_name:
>  	mmc_remove_host(mmc);
> +err_pinctrl_state:
>  	free_irq(mmc_slot(host).card_detect_irq, host);
>  err_irq_cd:
>  	omap_hsmmc_reg_put(host);

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent
  2013-06-12 14:33               ` Balaji T K
@ 2013-06-12 14:38                 ` Tony Lindgren
  0 siblings, 0 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 14:38 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130612 07:39]:
> On Wednesday 12 June 2013 07:55 PM, Tony Lindgren wrote:
> >* Balaji T K <balajitk@ti.com> [130606 12:20]:
> >>handle vcc and vcc_aux independently
> >>
> >>Signed-off-by: Balaji T K <balajitk@ti.com>
> >>---
> >>  drivers/mmc/host/omap_hsmmc.c |    9 +++++----
> >>  1 files changed, 5 insertions(+), 4 deletions(-)
> >>
> >>diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> >>index 1865321..bda1a42 100644
> >>--- a/drivers/mmc/host/omap_hsmmc.c
> >>+++ b/drivers/mmc/host/omap_hsmmc.c
> >>@@ -253,7 +253,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
> >>  	 * If we don't see a Vcc regulator, assume it's a fixed
> >>  	 * voltage always-on regulator.
> >>  	 */
> >>-	if (!host->vcc)
> >>+	if (!host->vcc && !host->vcc_aux)
> >>  		return 0;
> >>  	/*
> >>  	 * With DT, never turn OFF the regulator for MMC1. This is because
> >
> >Doesn't the above change break MMC for most boards that only pass
> >one regulator and no aux regulator?
> >
> 
> No, I want to skip regulator operation in set_power function iff both
> regulator are not present.
> 
> Earlier vcc was assumed/mandatory if vcc_aux is present.
> Now, regulator operation will be handled if either one of vcc/vcc_aux is present,

Ah OK yes sorry I misread your patch.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info
       [not found]               ` <20130612142409.GW8164-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2013-06-12 17:00                 ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-12 17:00 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, cjb-2X9k7bc8m7Mdnm+yROfE0A

On Wednesday 12 June 2013 07:54 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk-l0cyMroinI0@public.gmane.org> [130606 12:20]:
>> Add needs_vmmc and needs_vmmc_aux to indicate whether regulator is
>> applicable so that omap_hsmmc can handle deferred probe error
>> properly for regulators.
>> Remove the assumption that vmmc_aux regulator to be available only if vmmc is
>> present. Platforms can have fixed-always-ON regulator for vmmc and/or vmmc_aux
>> in such cases regulator needed not be specified in board file.
>
> Looks good to me, I suggest you resend this again a bit later once the
> other changes are merged so we can avoid a dependency between arch/arm/mach-omap2
> and MMC changes.
>

Ok, will separate the board changes and send the rest via mmc tree

> Regards,
>
> Tony
>
>> Signed-off-by: Balaji T K <balajitk-l0cyMroinI0@public.gmane.org>
>> ---
>>   arch/arm/mach-omap2/board-2430sdp.c          |    1 +
>>   arch/arm/mach-omap2/board-3430sdp.c          |    3 +++
>>   arch/arm/mach-omap2/board-cm-t35.c           |    2 ++
>>   arch/arm/mach-omap2/board-devkit8000.c       |    1 +
>>   arch/arm/mach-omap2/board-igep0020.c         |    3 +++
>>   arch/arm/mach-omap2/board-ldp.c              |    1 +
>>   arch/arm/mach-omap2/board-omap3beagle.c      |    2 ++
>>   arch/arm/mach-omap2/board-omap3evm.c         |    3 +++
>>   arch/arm/mach-omap2/board-omap3logic.c       |    1 +
>>   arch/arm/mach-omap2/board-omap3pandora.c     |    3 +++
>>   arch/arm/mach-omap2/board-omap3stalker.c     |    2 ++
>>   arch/arm/mach-omap2/board-omap3touchbook.c   |    2 ++
>>   arch/arm/mach-omap2/board-overo.c            |    1 +
>>   arch/arm/mach-omap2/board-rm680.c            |    1 +
>>   arch/arm/mach-omap2/board-rx51-peripherals.c |    3 +++
>>   arch/arm/mach-omap2/board-zoom-peripherals.c |    4 ++++
>>   arch/arm/mach-omap2/hsmmc.c                  |    2 ++
>>   arch/arm/mach-omap2/hsmmc.h                  |    2 ++
>>   include/linux/platform_data/mmc-omap.h       |    2 ++
>>   19 files changed, 39 insertions(+), 0 deletions(-)
>>

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core
  2013-06-12 14:35               ` Tony Lindgren
@ 2013-06-12 17:08                 ` Balaji T K
  2013-06-12 17:54                   ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-12 17:08 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

On Wednesday 12 June 2013 08:05 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [130606 12:20]:
>> omap3_pmx_core: padconf register are in two banks 0x48003000 to 0x48002268
>> and 0x480025c0 to 0x480025f8.
>>
>> split omap3_pmx_core into 2 banks as register between 0x48002270 and 0x48002564
>> belongs to type pinctrl-single,bit-per-mux with access to certain bit
>> fields with bit field mask.
>
> Is this the right patch for the description? THe patch seems to deal with
> USB pins.
>
> Also, let's not hog any pins under the pinmux controllers, those make
> unloading pinctrl-single impossible which is not nice for distros and
> development.

omap3_pmx_core is not continuous, so had to split into two and
updated the only user in second bank (omap3_pmx_core2) which happened to be usb,
CC Roger for USB dynamic pin mux selection.

>
> Instead, the pins should be under mmc1 in omap[345].dtsi files.
>
> Regards,
>
> Tony
>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   arch/arm/boot/dts/omap3-beagle.dts |   28 ++++++++++++++++++++--------
>>   arch/arm/boot/dts/omap3.dtsi       |   11 ++++++++++-
>>   2 files changed, 30 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
>> index 6eec699..7da9979 100644
>> --- a/arch/arm/boot/dts/omap3-beagle.dts
>> +++ b/arch/arm/boot/dts/omap3-beagle.dts
>> @@ -76,17 +76,11 @@
>>   &omap3_pmx_core {
>>   	pinctrl-names = "default";
>>   	pinctrl-0 = <
>> -			&hsusbb2_pins
>> +			&hsusbb2_pins1
>>   	>;
>>
>> -	hsusbb2_pins: pinmux_hsusbb2_pins {
>> +	hsusbb2_pins1: pinmux_hsusbb2_pins1 {
>>   		pinctrl-single,pins = <
>> -			0x5c0 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
>> -			0x5c2 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
>> -			0x5c4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
>> -			0x5c6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
>> -			0x5c8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
>> -			0x5cA 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
>>   			0x1a4 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
>>   			0x1a6 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
>>   			0x1a8 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
>> @@ -97,6 +91,24 @@
>>   	};
>>   };
>>
>> +&omap3_pmx_core2 {
>> +	pinctrl-names = "default";
>> +	pinctrl-0 = <
>> +			&hsusbb2_pins2
>> +	>;
>> +
>> +	hsusbb2_pins2: pinmux_hsusbb2_pins2 {
>> +		pinctrl-single,pins = <
>> +			0x50 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
>> +			0x52 0x3  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
>> +			0x54 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
>> +			0x56 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
>> +			0x58 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
>> +			0x5A 0x10b  /* USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
>> +		>;
>> +	};
>> +};
>> +
>>   &i2c1 {
>>   	clock-frequency = <2600000>;
>>
>> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
>> index 82a404d..caaa708 100644
>> --- a/arch/arm/boot/dts/omap3.dtsi
>> +++ b/arch/arm/boot/dts/omap3.dtsi
>> @@ -95,7 +95,16 @@
>>
>>   		omap3_pmx_core: pinmux@48002030 {
>>   			compatible = "ti,omap3-padconf", "pinctrl-single";
>> -			reg = <0x48002030 0x05cc>;
>> +			reg = <0x48002030 0x238>;
>> +			#address-cells = <1>;
>> +			#size-cells = <0>;
>> +			pinctrl-single,register-width = <16>;
>> +			pinctrl-single,function-mask = <0x7f1f>;
>> +		};
>> +
>> +		omap3_pmx_core2: pinmux@480025a0 {
>> +			compatible = "ti,omap3-padconf", "pinctrl-single";
>> +			reg = <0x480025a0 0x5c>;
>>   			#address-cells = <1>;
>>   			#size-cells = <0>;
>>   			pinctrl-single,register-width = <16>;
>> --
>> 1.7.5.4
>>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states
  2013-06-12 14:35             ` Tony Lindgren
@ 2013-06-12 17:43               ` Balaji T K
  2013-06-12 17:50                 ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-12 17:43 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

On Wednesday 12 June 2013 08:05 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [130606 12:20]:
>> add pbias states for pbias 0, 1.8V, 3V
>> add omap3 sd/mmc2 loop back clock config for devconf1 in mmc2_init pinctrl state
>> add OMAP3430 sd/mmc1 loop back clock config for devconf0 in mmc1_init pinctrl state
>> add OMAP3630 sd/mmc1 speed mode config for prog_io1 in mmc1_init pinctrl state
>
> Looks OK to me, except these should be under mmc1 for omap[345].dtsi files.
>

I think I can move &omap3_pmx_general to omap3.dtsi and override
&pbias_1v8, &pbias_3v in omap36xx.dtsi, but I doubt pinctrl-[0,1,2,3,4]
since pull up setting can vary between boards.

> Regards,
>
> Tony
>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   arch/arm/boot/dts/omap3-beagle-xm.dts |   42 +++++++++++++++++++++++++++++++++
>>   arch/arm/boot/dts/omap3-beagle.dts    |   42 +++++++++++++++++++++++++++++++++
>>   arch/arm/boot/dts/omap3.dtsi          |   10 ++++++++
>>   3 files changed, 94 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts
>> index 3046d1f..45d1642 100644
>> --- a/arch/arm/boot/dts/omap3-beagle-xm.dts
>> +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
>> @@ -59,6 +59,40 @@
>>   	};
>>   };
>>
>> +&omap3_pmx_general {
>> +	pinctrl-names = "default";
>> +	pinctrl-0 = <>;
>> +	pbias_off: pinmux_pbias_off {
>> +		pinctrl-single,bits = <
>> +			0x2b0 0x1 0x3	/* pbias */
>> +		>;
>> +	};
>> +
>> +	pbias_1v8: pinmux_pbias_1v8 {
>> +		pinctrl-single,bits = <
>> +			0x2b0 0x2 0x3	/* pbias */
>> +		>;
>> +	};
>> +
>> +	pbias_3v: pinmux_pbias_3v {
>> +		pinctrl-single,bits = <
>> +			0x2b0 0x3 0x3	/* pbias */
>> +		>;
>> +	};
>> +
>> +	mmc1_init: pinmux_mmc1_init {
>> +		pinctrl-single,bits = <
>> +			0x1d8 0x100000 0x100000	/* prog_io1 */
>> +		>;
>> +	};
>> +
>> +	mmc2_init: pinmux_mmc2_init {
>> +		pinctrl-single,bits = <
>> +			0x68 0x40 0x40	/* devconf1 */
>> +		>;
>> +	};
>> +};
>> +
>>   &i2c1 {
>>   	clock-frequency = <2600000>;
>>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-12 14:37             ` Tony Lindgren
@ 2013-06-12 17:46               ` Balaji T K
  2013-06-13  9:38               ` Linus Walleij
  1 sibling, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-06-12 17:46 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss, Linus Walleij

On Wednesday 12 June 2013 08:07 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [130606 12:20]:
>> PBIAS register configuration is based on the regulator voltage
>> which supplies these pbias cells, sd i/o pads.
>> With PBIAS register address and bit definitions different across
>> omap[3,4,5], Simplify PBIAS configuration under three different
>> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
>> are defined as pbias_off, pbias_1v8, pbias_3v.
>>
>> pinctrl state mmc_init is used for configuring speed mode, loopback clock
>> (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
>> configuration (in control_mmc1 for omap4)
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   drivers/mmc/host/omap_hsmmc.c |   83 ++++++++++++++++++++++++++++++++++++++--
>>   1 files changed, 78 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index 533ced2..8dd1cd3 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -182,6 +182,9 @@ struct omap_hsmmc_host {
>>   	int			req_in_progress;
>>   	struct omap_hsmmc_next	next_data;
>>
>> +	struct pinctrl		*pinctrl;
>> +	struct pinctrl_state	*pbias_off, *pbias_1v8, *pbias_3v, *mmc_init;
>> +
>>   	struct	omap_mmc_platform_data	*pdata;
>>   	int needs_vmmc:1;
>>   	int needs_vmmc_aux:1;
>> @@ -267,6 +270,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>   	if (mmc_slot(host).before_set_reg)
>>   		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
>>
>> +	if (host->pinctrl && host->pbias_off) {
>> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
>> +		if (ret < 0)
>> +			dev_err(host->dev, "pinctrl pbias_off select error\n");
>> +	}
>> +
>>   	/*
>>   	 * Assume Vcc regulator is used only to power the card ... OMAP
>>   	 * VDDS is used to power the pins, optionally with a transceiver to
>> @@ -304,6 +313,25 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>   	if (mmc_slot(host).after_set_reg)
>>   		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
>>
>> +	/* 100ms delay required for PBIAS configuration */
>> +	msleep(100);
>
> Hmm, why is the delay needed before the configuration? Is this something
> you could avoid by reading the pinconf state maybe?

This delay is needed for regulator voltage to stabilize.

>
>> +	if (!vdd && host->pinctrl && host->pbias_off) {
>> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
>> +		if (ret < 0)
>> +			dev_err(host->dev, "pinctrl pbias_off select error\n");
>> +	} else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
>> +			host->pbias_1v8) {
>> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
>> +		if (ret < 0)
>> +			dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
>> +	} else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
>> +			host->pbias_3v) {
>> +		ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
>> +		if (ret < 0)
>> +			dev_err(host->dev, "pinctrl pbias_3v select error\n");
>> +	}
>> +	usleep_range(350, 400);
>> +
>>   	return ret;
>>   }
>
> Maybe add some macro for doing the if (((1 << vdd) <= MMC_VDD_165_195)... tests?

OK

>
>> @@ -1775,6 +1803,52 @@ static inline struct omap_mmc_platform_data
>>   }
>>   #endif
>>
>> +static int omap_hsmmc_pinctrl_init(struct omap_hsmmc_host *host)
>> +{
>> +	int ret = 0;
>> +
>> +	host->pinctrl = devm_pinctrl_get(host->dev);
>> +	if (IS_ERR(host->pinctrl)) {
>> +		host->pinctrl = NULL;
>> +		dev_warn(host->dev,
>> +			 "pins are not configured from the driver\n");
>> +		return 0;
>> +	}
>> +
>> +	host->mmc_init = pinctrl_lookup_state(host->pinctrl, "mmc_init");
>> +	if (IS_ERR(host->mmc_init)) {
>> +		dev_vdbg(host->dev, "optional: mmc_init lookup error");
>> +		host->mmc_init = NULL;
>> +	} else {
>> +		ret = pinctrl_select_state(host->pinctrl, host->mmc_init);
>> +		if (ret < 0) {
>> +			dev_err(host->dev, "pinctrl mmc_init select error\n");
>> +			goto err_pinctrl;
>> +		}
>> +	}
>> +
>> +	host->pbias_off = pinctrl_lookup_state(host->pinctrl, "pbias_off");
>> +	if (IS_ERR(host->pbias_off)) {
>> +		dev_vdbg(host->dev, "optional: pbias_off lookup error");
>> +		host->pbias_off = NULL;
>> +	}
>> +
>> +	host->pbias_1v8 = pinctrl_lookup_state(host->pinctrl, "pbias_1v8");
>> +	if (IS_ERR(host->pbias_1v8)) {
>> +		dev_vdbg(host->dev, "optional: pbias_1v8 lookup error");
>> +		host->pbias_1v8 = NULL;
>> +	}
>> +
>> +	host->pbias_3v = pinctrl_lookup_state(host->pinctrl, "pbias_3v");
>> +	if (IS_ERR(host->pbias_3v)) {
>> +		dev_vdbg(host->dev, "optional: pbias_3v lookup error");
>> +		host->pbias_3v = NULL;
>> +	}
>> +
>> +err_pinctrl:
>> +	return ret;
>> +}
>
> Linus W may have some comments on this, although this is not the standard
> muxing stuff. The "mmc_init" state pins should be added to just the regular
> default state? Note that you can have phandles to however many sets of
> pins there.

Yes, can add &mmc_init pin config to default state.

>
>>   static int omap_hsmmc_probe(struct platform_device *pdev)
>>   {
>>   	struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
>> @@ -1785,7 +1859,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>>   	const struct of_device_id *match;
>>   	dma_cap_mask_t mask;
>>   	unsigned tx_req, rx_req;
>> -	struct pinctrl *pinctrl;
>>
>>   	match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
>>   	if (match) {
>> @@ -2005,10 +2078,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>>
>>   	omap_hsmmc_disable_irq(host);
>>
>> -	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>> -	if (IS_ERR(pinctrl))
>> -		dev_warn(&pdev->dev,
>> -			"pins are not configured from the driver\n");
>> +	ret = omap_hsmmc_pinctrl_init(host);
>> +	if (ret)
>> +		goto err_pinctrl_state;
>>
>>   	omap_hsmmc_protect_card(host);
>>
>> @@ -2034,6 +2106,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
>>
>>   err_slot_name:
>>   	mmc_remove_host(mmc);
>> +err_pinctrl_state:
>>   	free_irq(mmc_slot(host).card_detect_irq, host);
>>   err_irq_cd:
>>   	omap_hsmmc_reg_put(host);
>
> Regards,
>
> Tony
>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states
  2013-06-12 17:43               ` Balaji T K
@ 2013-06-12 17:50                 ` Tony Lindgren
  0 siblings, 0 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 17:50 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130612 10:50]:
> On Wednesday 12 June 2013 08:05 PM, Tony Lindgren wrote:
> >* Balaji T K <balajitk@ti.com> [130606 12:20]:
> >>add pbias states for pbias 0, 1.8V, 3V
> >>add omap3 sd/mmc2 loop back clock config for devconf1 in mmc2_init pinctrl state
> >>add OMAP3430 sd/mmc1 loop back clock config for devconf0 in mmc1_init pinctrl state
> >>add OMAP3630 sd/mmc1 speed mode config for prog_io1 in mmc1_init pinctrl state
> >
> >Looks OK to me, except these should be under mmc1 for omap[345].dtsi files.
> >
> 
> I think I can move &omap3_pmx_general to omap3.dtsi and override
> &pbias_1v8, &pbias_3v in omap36xx.dtsi, but I doubt pinctrl-[0,1,2,3,4]
> since pull up setting can vary between boards.

OK makes sense to me if it's board specific.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core
  2013-06-12 17:08                 ` Balaji T K
@ 2013-06-12 17:54                   ` Tony Lindgren
  0 siblings, 0 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-12 17:54 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, linux-mmc, cjb, b-cousson, devicetree-discuss

* Balaji T K <balajitk@ti.com> [130612 10:14]:
> On Wednesday 12 June 2013 08:05 PM, Tony Lindgren wrote:
> >* Balaji T K <balajitk@ti.com> [130606 12:20]:
> >>omap3_pmx_core: padconf register are in two banks 0x48003000 to 0x48002268
> >>and 0x480025c0 to 0x480025f8.
> >>
> >>split omap3_pmx_core into 2 banks as register between 0x48002270 and 0x48002564
> >>belongs to type pinctrl-single,bit-per-mux with access to certain bit
> >>fields with bit field mask.
> >
> >Is this the right patch for the description? THe patch seems to deal with
> >USB pins.
> >
> >Also, let's not hog any pins under the pinmux controllers, those make
> >unloading pinctrl-single impossible which is not nice for distros and
> >development.
> 
> omap3_pmx_core is not continuous, so had to split into two and
> updated the only user in second bank (omap3_pmx_core2) which happened to be usb,
> CC Roger for USB dynamic pin mux selection.

I see. OK yes we can split it as that saves memory too for the unused
registers. While at it, please move remove the hogs from the pmx
entries and move the pins to the drivers claiming them.

Regards,

TOny

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
  2013-06-12 14:37             ` Tony Lindgren
@ 2013-06-13  9:37             ` Linus Walleij
  2013-06-13  9:53               ` Tony Lindgren
  2013-06-13 10:47               ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Lee Jones
  1 sibling, 2 replies; 112+ messages in thread
From: Linus Walleij @ 2013-06-13  9:37 UTC (permalink / raw)
  To: Balaji T K, Lee Jones, Laurent Pinchart
  Cc: Linux-OMAP, linux-mmc, Chris Ball, ext Tony Lindgren, Cousson,
	Benoit, devicetree-discuss, Mark Brown, Ulf Hansson

On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:

> PBIAS register configuration is based on the regulator voltage
> which supplies these pbias cells, sd i/o pads.
> With PBIAS register address and bit definitions different across
> omap[3,4,5], Simplify PBIAS configuration under three different
> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> are defined as pbias_off, pbias_1v8, pbias_3v.
>
> pinctrl state mmc_init is used for configuring speed mode, loopback clock
> (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
> configuration (in control_mmc1 for omap4)
>
> Signed-off-by: Balaji T K <balajitk@ti.com>

You *need* Lee Jones and Mark Brown to review this.
Maybe Laurent has something to add too.

Ux500 had the very same thing, and there this was solved using
a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
Laurent doing something similar with the SH stuff.

> +       /* 100ms delay required for PBIAS configuration */
> +       msleep(100);
> +       if (!vdd && host->pinctrl && host->pbias_off) {
> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
> +               if (ret < 0)
> +                       dev_err(host->dev, "pinctrl pbias_off select error\n");
> +       } else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
> +                       host->pbias_1v8) {
> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
> +               if (ret < 0)
> +                       dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
> +       } else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
> +                       host->pbias_3v) {
> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
> +               if (ret < 0)
> +                       dev_err(host->dev, "pinctrl pbias_3v select error\n");
> +       }

So why does the pin control API control bias voltage?

This seem so intuitively wrong as it can possibly get, clearly this
is regulator territory.

This also looks strange from an MMC point of view.

It just seems these bits in these registers should be poked at
by the regulator world, not the pinctrl world. That the bits are
in the middle of pinctrl things does not really matter.

> +       usleep_range(350, 400);

And the regulator framework supports power-on delays.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-12 14:37             ` Tony Lindgren
  2013-06-12 17:46               ` Balaji T K
@ 2013-06-13  9:38               ` Linus Walleij
  1 sibling, 0 replies; 112+ messages in thread
From: Linus Walleij @ 2013-06-13  9:38 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Balaji T K, Linux-OMAP, linux-mmc, Chris Ball, Cousson, Benoit,
	devicetree-discuss

On Wed, Jun 12, 2013 at 4:37 PM, Tony Lindgren <tony@atomide.com> wrote:

> Linus W may have some comments on this, although this is not the standard
> muxing stuff.

It's in the wrong subsystem and needs to be rewritten IMO.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13  9:37             ` Linus Walleij
@ 2013-06-13  9:53               ` Tony Lindgren
  2013-06-13 10:02                 ` Laurent Pinchart
                                   ` (2 more replies)
  2013-06-13 10:47               ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Lee Jones
  1 sibling, 3 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-06-13  9:53 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Balaji T K, Lee Jones, Laurent Pinchart, Linux-OMAP, linux-mmc,
	Chris Ball, Cousson, Benoit, devicetree-discuss, Mark Brown,
	Ulf Hansson

* Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
> 
> > PBIAS register configuration is based on the regulator voltage
> > which supplies these pbias cells, sd i/o pads.
> > With PBIAS register address and bit definitions different across
> > omap[3,4,5], Simplify PBIAS configuration under three different
> > regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> > are defined as pbias_off, pbias_1v8, pbias_3v.
> >
> > pinctrl state mmc_init is used for configuring speed mode, loopback clock
> > (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
> > configuration (in control_mmc1 for omap4)
> >
> > Signed-off-by: Balaji T K <balajitk@ti.com>
> 
> You *need* Lee Jones and Mark Brown to review this.
> Maybe Laurent has something to add too.
> 
> Ux500 had the very same thing, and there this was solved using
> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
> Laurent doing something similar with the SH stuff.
> 
> > +       /* 100ms delay required for PBIAS configuration */
> > +       msleep(100);
> > +       if (!vdd && host->pinctrl && host->pbias_off) {
> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
> > +               if (ret < 0)
> > +                       dev_err(host->dev, "pinctrl pbias_off select error\n");
> > +       } else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
> > +                       host->pbias_1v8) {
> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
> > +               if (ret < 0)
> > +                       dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
> > +       } else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
> > +                       host->pbias_3v) {
> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
> > +               if (ret < 0)
> > +                       dev_err(host->dev, "pinctrl pbias_3v select error\n");
> > +       }
> 
> So why does the pin control API control bias voltage?

I agree, it should be a regulator for the MMC driver and that's what I
already suggested earlier. Having it as a regulator allows us to get
rid of all the non-standard before and after calls in the omap_hsmmc.c.
This way the omap_hsmmc.c code can handle the internal and external
voltages the same way.
 
> This seem so intuitively wrong as it can possibly get, clearly this
> is regulator territory.

The PBIAS for MMC1 is a mux + comparator for the MMC pin, so it makes
sense for the regulator driver to access the register via pinctrl API.
I think the reason why we have registers like this and the USB comparators
in the omap SCM (System Control Module) as the all seem to relate to
pin states.
 
> This also looks strange from an MMC point of view.

Yes I agree, it should be a regulator for MMC. Doing it this way just
adds yet more code that's usable for only one of the omap MMC
controllers.
 
> It just seems these bits in these registers should be poked at
> by the regulator world, not the pinctrl world. That the bits are
> in the middle of pinctrl things does not really matter.
> 
> > +       usleep_range(350, 400);
> 
> And the regulator framework supports power-on delays.

Yes. And it seems that the delays should not be needed, but instead
the comparator bits should be checked.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13  9:53               ` Tony Lindgren
@ 2013-06-13 10:02                 ` Laurent Pinchart
  2013-06-13 14:52                   ` Balaji T K
  2013-06-13 12:39                 ` Linus Walleij
  2013-06-13 14:41                 ` Balaji T K
  2 siblings, 1 reply; 112+ messages in thread
From: Laurent Pinchart @ 2013-06-13 10:02 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Linus Walleij, Balaji T K, Lee Jones, Laurent Pinchart,
	Linux-OMAP, linux-mmc, Chris Ball, Cousson, Benoit,
	devicetree-discuss, Mark Brown, Ulf Hansson

On Thursday 13 June 2013 02:53:54 Tony Lindgren wrote:
> * Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
> > On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
> > > PBIAS register configuration is based on the regulator voltage
> > > which supplies these pbias cells, sd i/o pads.
> > > With PBIAS register address and bit definitions different across
> > > omap[3,4,5], Simplify PBIAS configuration under three different
> > > regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> > > are defined as pbias_off, pbias_1v8, pbias_3v.
> > > 
> > > pinctrl state mmc_init is used for configuring speed mode, loopback
> > > clock (in devconf0/devconf1/prog_io1 register for omap3) and pull
> > > strength configuration (in control_mmc1 for omap4)
> > > 
> > > Signed-off-by: Balaji T K <balajitk@ti.com>
> > 
> > You *need* Lee Jones and Mark Brown to review this.
> > Maybe Laurent has something to add too.
> > 
> > Ux500 had the very same thing, and there this was solved using
> > a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
> > Laurent doing something similar with the SH stuff.

The SH pinctrl driver registers an MMC regulator. The code is available at 
git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git. Look at 
drivers/pinctrl/sh-pfc/pfc-sh73a0.c in tags/renesas-next-20130611v2.

> > > +       /* 100ms delay required for PBIAS configuration */
> > > +       msleep(100);
> > > +       if (!vdd && host->pinctrl && host->pbias_off) {
> > > +               ret = pinctrl_select_state(host->pinctrl,
> > > host->pbias_off);
> > > +               if (ret < 0)
> > > +                       dev_err(host->dev, "pinctrl pbias_off select
> > > error\n"); +       } else if (((1 << vdd) <= MMC_VDD_165_195) &&
> > > host->pinctrl && +                       host->pbias_1v8) {
> > > +               ret = pinctrl_select_state(host->pinctrl,
> > > host->pbias_1v8);
> > > +               if (ret < 0)
> > > +                       dev_err(host->dev, "pinctrl pbias_1v8 select
> > > error\n"); +       } else if (((1 << vdd) > MMC_VDD_165_195) &&
> > > host->pinctrl && +                       host->pbias_3v) {
> > > +               ret = pinctrl_select_state(host->pinctrl,
> > > host->pbias_3v);
> > > +               if (ret < 0)
> > > +                       dev_err(host->dev, "pinctrl pbias_3v select
> > > error\n"); +       }
> > 
> > So why does the pin control API control bias voltage?
> 
> I agree, it should be a regulator for the MMC driver and that's what I
> already suggested earlier. Having it as a regulator allows us to get
> rid of all the non-standard before and after calls in the omap_hsmmc.c.
> This way the omap_hsmmc.c code can handle the internal and external
> voltages the same way.
> 
> > This seem so intuitively wrong as it can possibly get, clearly this
> > is regulator territory.
> 
> The PBIAS for MMC1 is a mux + comparator for the MMC pin, so it makes
> sense for the regulator driver to access the register via pinctrl API.
> I think the reason why we have registers like this and the USB comparators
> in the omap SCM (System Control Module) as the all seem to relate to
> pin states.
> 
> > This also looks strange from an MMC point of view.
> 
> Yes I agree, it should be a regulator for MMC. Doing it this way just
> adds yet more code that's usable for only one of the omap MMC
> controllers.
> 
> > It just seems these bits in these registers should be poked at
> > by the regulator world, not the pinctrl world. That the bits are
> > in the middle of pinctrl things does not really matter.
> > 
> > > +       usleep_range(350, 400);
> > 
> > And the regulator framework supports power-on delays.
> 
> Yes. And it seems that the delays should not be needed, but instead
> the comparator bits should be checked.

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13  9:37             ` Linus Walleij
  2013-06-13  9:53               ` Tony Lindgren
@ 2013-06-13 10:47               ` Lee Jones
  2013-06-13 15:01                 ` Balaji T K
  1 sibling, 1 reply; 112+ messages in thread
From: Lee Jones @ 2013-06-13 10:47 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Balaji T K, Laurent Pinchart, Linux-OMAP, linux-mmc, Chris Ball,
	ext Tony Lindgren, Cousson, Benoit, devicetree-discuss,
	Mark Brown, Ulf Hansson

On Thu, 13 Jun 2013, Linus Walleij wrote:

> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
> 
> > PBIAS register configuration is based on the regulator voltage
> > which supplies these pbias cells, sd i/o pads.
> > With PBIAS register address and bit definitions different across
> > omap[3,4,5], Simplify PBIAS configuration under three different
> > regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> > are defined as pbias_off, pbias_1v8, pbias_3v.
> >
> > pinctrl state mmc_init is used for configuring speed mode, loopback clock
> > (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
> > configuration (in control_mmc1 for omap4)
> >
> > Signed-off-by: Balaji T K <balajitk@ti.com>
> 
> You *need* Lee Jones and Mark Brown to review this.
> Maybe Laurent has something to add too.
> 
> Ux500 had the very same thing, and there this was solved using
> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
> Laurent doing something similar with the SH stuff.

I haven't seem much of this patch-set, but this certainly looks like
it should be handled by a GPIO regulator instead of pinctrl. States
are easily declared in a 'struct gpio_regulator_state', which the
framework then uses to set the correct pins for the required voltage.

And yes, 'vqmmc' is a good place to store the this regulator.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13  9:53               ` Tony Lindgren
  2013-06-13 10:02                 ` Laurent Pinchart
@ 2013-06-13 12:39                 ` Linus Walleij
  2013-06-13 14:41                 ` Balaji T K
  2 siblings, 0 replies; 112+ messages in thread
From: Linus Walleij @ 2013-06-13 12:39 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Balaji T K, Lee Jones, Laurent Pinchart, Linux-OMAP, linux-mmc,
	Chris Ball, Cousson, Benoit, devicetree-discuss, Mark Brown,
	Ulf Hansson

On Thu, Jun 13, 2013 at 11:53 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
>> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
>> > +       /* 100ms delay required for PBIAS configuration */
>> > +       msleep(100);
>> > +       if (!vdd && host->pinctrl && host->pbias_off) {
>> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
>> > +               if (ret < 0)
>> > +                       dev_err(host->dev, "pinctrl pbias_off select error\n");
>> > +       } else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
>> > +                       host->pbias_1v8) {
>> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
>> > +               if (ret < 0)
>> > +                       dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
>> > +       } else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
>> > +                       host->pbias_3v) {
>> > +               ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
>> > +               if (ret < 0)
>> > +                       dev_err(host->dev, "pinctrl pbias_3v select error\n");
>> > +       }
>>
>> So why does the pin control API control bias voltage?
>
> I agree, it should be a regulator for the MMC driver and that's what I
> already suggested earlier. Having it as a regulator allows us to get
> rid of all the non-standard before and after calls in the omap_hsmmc.c.
> This way the omap_hsmmc.c code can handle the internal and external
> voltages the same way.

So someone is not taking the OMAP maintainers word for it and
instead trying to push this past the pinctrl maintainer?

Grrr.... OK I'll assume good faith and I therefore conclude that
this must have been just some kind of mistake in the act.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13  9:53               ` Tony Lindgren
  2013-06-13 10:02                 ` Laurent Pinchart
  2013-06-13 12:39                 ` Linus Walleij
@ 2013-06-13 14:41                 ` Balaji T K
  2013-06-13 15:29                   ` Linus Walleij
  2 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-13 14:41 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Linus Walleij, Lee Jones, Laurent Pinchart, Linux-OMAP,
	linux-mmc, Chris Ball, Cousson, Benoit, devicetree-discuss,
	Mark Brown, Ulf Hansson

On Thursday 13 June 2013 03:23 PM, Tony Lindgren wrote:
> * Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
>> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
>>
>>> PBIAS register configuration is based on the regulator voltage
>>> which supplies these pbias cells, sd i/o pads.
>>> With PBIAS register address and bit definitions different across
>>> omap[3,4,5], Simplify PBIAS configuration under three different
>>> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
>>> are defined as pbias_off, pbias_1v8, pbias_3v.
>>>
>>> pinctrl state mmc_init is used for configuring speed mode, loopback clock
>>> (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
>>> configuration (in control_mmc1 for omap4)
>>>
>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>
>> You *need* Lee Jones and Mark Brown to review this.
>> Maybe Laurent has something to add too.
>>
>> Ux500 had the very same thing, and there this was solved using
>> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
>> Laurent doing something similar with the SH stuff.
>>
>>> +       /* 100ms delay required for PBIAS configuration */
>>> +       msleep(100);
>>> +       if (!vdd && host->pinctrl && host->pbias_off) {
>>> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_off);
>>> +               if (ret < 0)
>>> +                       dev_err(host->dev, "pinctrl pbias_off select error\n");
>>> +       } else if (((1 << vdd) <= MMC_VDD_165_195) && host->pinctrl &&
>>> +                       host->pbias_1v8) {
>>> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_1v8);
>>> +               if (ret < 0)
>>> +                       dev_err(host->dev, "pinctrl pbias_1v8 select error\n");
>>> +       } else if (((1 << vdd) > MMC_VDD_165_195) && host->pinctrl &&
>>> +                       host->pbias_3v) {
>>> +               ret = pinctrl_select_state(host->pinctrl, host->pbias_3v);
>>> +               if (ret < 0)
>>> +                       dev_err(host->dev, "pinctrl pbias_3v select error\n");
>>> +       }
>>
>> So why does the pin control API control bias voltage?
>
> I agree, it should be a regulator for the MMC driver and that's what I
> already suggested earlier. Having it as a regulator allows us to get
> rid of all the non-standard before and after calls in the omap_hsmmc.c.
> This way the omap_hsmmc.c code can handle the internal and external
> voltages the same way.
>
>> This seem so intuitively wrong as it can possibly get, clearly this
>> is regulator territory.
>

It is not really a regulator, CONTROL_PBIAS_LITE is just a register
in control module which configures pad/pin on SOC. In this case PBIAS cells
are powered down before any voltage changes and after the external voltage
supplied to VDDS_MMC of OMAP stabilizes pbias cells  is powered ON again
with specific Voltage which is given to OMAP for MMC io pins

For OMAP2430, OMAP3430 It additionally has a bit for speed mode control
which are set always (static config)

I am quoting pbias register field description from TRM for reference

BIT2 PBIASSPEEDCTRL0 Speed Control for MMC I/O
0b0 => 26 MHz I/O max speed
0b1 => 52 MHz I/O max speed

BIT26 MMC1_PWRDNZ PWRDNZ control to MMC1 IO
This bit is used to protect the MMC1 I/O cell when
SDMMC1_VDDS is not stable.
0x0: Software must clear this bit when SDMMC1_VDDS
changes.
0x1: Software must set this bit only when
SDMMC1_VDDS is stable.

BIT25 MMC1_PBIASLITE_HIZ_MODE HIZ_MODE from MMC1 PBIASLITE
0x0: PBIAS in normal operation mode
0x1: PBIAS output is in high impedence state

BIT24 MMC1_PBIASLITE_SUPPLY_HI SUPPLY_HI_OUT from MMC1 PBIASLITE
_OUT Read 0x0: SDMMC1_VDDS = 1.8V
Read 0x1: SDMMC1_VDDS = 3V

BIT23 MMC1_PBIASLITE_VMODE_ER VMODE ERROR from MMC1 PBIASLITE
ROR Read 0x0: VMODE level is same as SUPPLY_HI_OUT
Read 0x1: VMODE level is not same as
SUPPLY_HI_OUT

BIT22 MMC1_PBIASLITE_PWRDNZ PWRDNZ control to MMC1 PBIASLITE
This bit is used to protect the MMC1_PBIAS cell (MMC1
I/O cell associated) when SDMMC1_VDDS is not stable.
0x0: Software must clear this bit when SDMMC1_VDDS
changes.
0x1: Software must set this bit only when
SDMMC1_VDDS is stable.

BIT21 MMC1_PBIASLITE_VMODE VMODE control to MMC1 PBIASLITE
0x0: SDMMC1_VDDS = 1.8V
0x1: SDMMC1_VDDS = 3V

> The PBIAS for MMC1 is a mux + comparator for the MMC pin, so it makes
> sense for the regulator driver to access the register via pinctrl API.
> I think the reason why we have registers like this and the USB comparators
> in the omap SCM (System Control Module) as the all seem to relate to
> pin states.
>
>> This also looks strange from an MMC point of view.
>
> Yes I agree, it should be a regulator for MMC. Doing it this way just
> adds yet more code that's usable for only one of the omap MMC
> controllers.
>

the only other user for pbias which I can find is USB pin configuration in
arch/arm/mach-omap2/board-omap3logic.c where it is statically programmed for 3V
which can be modeled as well as  default pinctrl state.


>> It just seems these bits in these registers should be poked at
>> by the regulator world, not the pinctrl world.


You mean regulator via pinctrl APIs, I think It will just move the code
from omap_hsmmc to a new regulator file with it own init data for pinctrl.

Not sure if Regulator maintainer will agree to it.

Moreover what I needs is three different states 0V, 0 to 1.8V, 3 V to 3.3V
not 0, 1.8V, 3V. plus pbias register fields got moved around between omap3, omap4
and omap5, That was one of the reason for moving to pinctrl states.


 >> That the bits are
>> in the middle of pinctrl things does not really matter.

It thought pinctrl-single,bits in pinctrl-single.c is introduced
precisely for such misc control register which has bit configuration
affecting different module i/o pads.

>>
>>> +       usleep_range(350, 400);
>>
>> And the regulator framework supports power-on delays.
>
> Yes. And it seems that the delays should not be needed, but instead
> the comparator bits should be checked.

But, Not all OMAP has such support to read comparator bits.

>
> Regards,
>
> Tony
>

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 10:02                 ` Laurent Pinchart
@ 2013-06-13 14:52                   ` Balaji T K
  2013-06-13 14:53                     ` Laurent Pinchart
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-13 14:52 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tony Lindgren, Linus Walleij, Lee Jones, Laurent Pinchart,
	Linux-OMAP, linux-mmc, Chris Ball, Cousson, Benoit,
	devicetree-discuss, Mark Brown, Ulf Hansson

On Thursday 13 June 2013 03:32 PM, Laurent Pinchart wrote:
> On Thursday 13 June 2013 02:53:54 Tony Lindgren wrote:
>> * Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
>>> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
>>>> PBIAS register configuration is based on the regulator voltage
>>>> which supplies these pbias cells, sd i/o pads.
>>>> With PBIAS register address and bit definitions different across
>>>> omap[3,4,5], Simplify PBIAS configuration under three different
>>>> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
>>>> are defined as pbias_off, pbias_1v8, pbias_3v.
>>>>
>>>> pinctrl state mmc_init is used for configuring speed mode, loopback
>>>> clock (in devconf0/devconf1/prog_io1 register for omap3) and pull
>>>> strength configuration (in control_mmc1 for omap4)
>>>>
>>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>>
>>> You *need* Lee Jones and Mark Brown to review this.
>>> Maybe Laurent has something to add too.
>>>
>>> Ux500 had the very same thing, and there this was solved using
>>> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
>>> Laurent doing something similar with the SH stuff.
>
> The SH pinctrl driver registers an MMC regulator. The code is available at
> git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git. Look at
> drivers/pinctrl/sh-pfc/pfc-sh73a0.c in tags/renesas-next-20130611v2.
>

Hi,

Thanks for the link, I think I need some time to understand
where pfc->window[1].virt is coming from.

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 14:52                   ` Balaji T K
@ 2013-06-13 14:53                     ` Laurent Pinchart
  0 siblings, 0 replies; 112+ messages in thread
From: Laurent Pinchart @ 2013-06-13 14:53 UTC (permalink / raw)
  To: Balaji T K
  Cc: Tony Lindgren, Linus Walleij, Lee Jones, Laurent Pinchart,
	Linux-OMAP, linux-mmc, Chris Ball, Cousson, Benoit,
	devicetree-discuss, Mark Brown, Ulf Hansson

Hi,

On Thursday 13 June 2013 20:22:42 Balaji T K wrote:
> On Thursday 13 June 2013 03:32 PM, Laurent Pinchart wrote:
> > On Thursday 13 June 2013 02:53:54 Tony Lindgren wrote:
> >> * Linus Walleij <linus.walleij@linaro.org> [130613 02:42]:
> >>> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
> >>>> PBIAS register configuration is based on the regulator voltage
> >>>> which supplies these pbias cells, sd i/o pads.
> >>>> With PBIAS register address and bit definitions different across
> >>>> omap[3,4,5], Simplify PBIAS configuration under three different
> >>>> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl
> >>>> states
> >>>> are defined as pbias_off, pbias_1v8, pbias_3v.
> >>>> 
> >>>> pinctrl state mmc_init is used for configuring speed mode, loopback
> >>>> clock (in devconf0/devconf1/prog_io1 register for omap3) and pull
> >>>> strength configuration (in control_mmc1 for omap4)
> >>>> 
> >>>> Signed-off-by: Balaji T K <balajitk@ti.com>
> >>> 
> >>> You *need* Lee Jones and Mark Brown to review this.
> >>> Maybe Laurent has something to add too.
> >>> 
> >>> Ux500 had the very same thing, and there this was solved using
> >>> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
> >>> Laurent doing something similar with the SH stuff.
> > 
> > The SH pinctrl driver registers an MMC regulator. The code is available at
> > git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git. Look at
> > drivers/pinctrl/sh-pfc/pfc-sh73a0.c in tags/renesas-next-20130611v2.
> 
> Thanks for the link, I think I need some time to understand
> where pfc->window[1].virt is coming from.

That's just the ioremapped pinctrl device address spaced.

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 10:47               ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Lee Jones
@ 2013-06-13 15:01                 ` Balaji T K
  2013-06-13 16:17                   ` Lee Jones
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-06-13 15:01 UTC (permalink / raw)
  To: Lee Jones
  Cc: Linus Walleij, Laurent Pinchart, Linux-OMAP, linux-mmc,
	Chris Ball, ext Tony Lindgren, Cousson, Benoit,
	devicetree-discuss, Mark Brown, Ulf Hansson

On Thursday 13 June 2013 04:17 PM, Lee Jones wrote:
> On Thu, 13 Jun 2013, Linus Walleij wrote:
>
>> On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
>>
>>> PBIAS register configuration is based on the regulator voltage
>>> which supplies these pbias cells, sd i/o pads.
>>> With PBIAS register address and bit definitions different across
>>> omap[3,4,5], Simplify PBIAS configuration under three different
>>> regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
>>> are defined as pbias_off, pbias_1v8, pbias_3v.
>>>
>>> pinctrl state mmc_init is used for configuring speed mode, loopback clock
>>> (in devconf0/devconf1/prog_io1 register for omap3) and pull strength
>>> configuration (in control_mmc1 for omap4)
>>>
>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>
>> You *need* Lee Jones and Mark Brown to review this.
>> Maybe Laurent has something to add too.
>>
>> Ux500 had the very same thing, and there this was solved using
>> a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
>> Laurent doing something similar with the SH stuff.
>
> I haven't seem much of this patch-set, but this certainly looks like
> it should be handled by a GPIO regulator instead of pinctrl. States
> are easily declared in a 'struct gpio_regulator_state', which the
> framework then uses to set the correct pins for the required voltage.
>

Thanks for the pointer, but wondering why is it named as gpio-regulator
and how it is different from fixed-regulator.
After going through git log description, I understand that voltage/current level
for a particular regulator is controlled by a set of pad/pin on the POWER IC
and pad/pin may be usually connected to gpio pins if it is needs to be
configurable and ground/pulled for constant voltage.

Collection of gpios logic level are modeled as state for particular voltage.
But gpio is not used in my case.

> And yes, 'vqmmc' is a good place to store the this regulator.
>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 14:41                 ` Balaji T K
@ 2013-06-13 15:29                   ` Linus Walleij
       [not found]                     ` <CACRpkdY6cZ+bT-C9Go3sZVw6ErQqTm0m9__uKQrkg4eUU1thHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 112+ messages in thread
From: Linus Walleij @ 2013-06-13 15:29 UTC (permalink / raw)
  To: Balaji T K, Mark Brown
  Cc: Tony Lindgren, Lee Jones, Laurent Pinchart, Linux-OMAP,
	linux-mmc, Chris Ball, Cousson, Benoit, devicetree-discuss,
	Ulf Hansson

On Thu, Jun 13, 2013 at 4:41 PM, Balaji T K <balajitk@ti.com> wrote:

>[Me]
>>> This seem so intuitively wrong as it can possibly get, clearly this
>>> is regulator territory.
>
> It is not really a regulator, CONTROL_PBIAS_LITE is just a register
> in control module which configures pad/pin on SOC. In this case PBIAS cells
> are powered down before any voltage changes and after the external voltage
> supplied to VDDS_MMC of OMAP stabilizes pbias cells  is powered ON again
> with specific Voltage which is given to OMAP for MMC io pins

So there is some external actual regulator supplying the voltage
and then that is looped back in to the pads. (I understand this is
quite a common construction.)

Anyway since it is obviously removing and applying voltage to
the pins, I think this is more of a cascaded regulator.
We use regulators for simple light-switches and things you know.

We have generic pinconf options for things like current but not
voltage really. It's because in the case of pin current configuration
it's basically about how many driver stages (totempoles) you connect
to the output, which is very different from the voltages we're dealing
with here.

So I think these bits go into a regulator driver:

> BIT26 MMC1_PWRDNZ PWRDNZ control to MMC1 IO
> This bit is used to protect the MMC1 I/O cell when
> SDMMC1_VDDS is not stable.
> 0x0: Software must clear this bit when SDMMC1_VDDS
> changes.
> 0x1: Software must set this bit only when
> SDMMC1_VDDS is stable.
>
> BIT24 MMC1_PBIASLITE_SUPPLY_HI SUPPLY_HI_OUT from MMC1 PBIASLITE
> _OUT Read 0x0: SDMMC1_VDDS = 1.8V
> Read 0x1: SDMMC1_VDDS = 3V
>
> BIT23 MMC1_PBIASLITE_VMODE_ER VMODE ERROR from MMC1 PBIASLITE
> ROR Read 0x0: VMODE level is same as SUPPLY_HI_OUT
> Read 0x1: VMODE level is not same as
> SUPPLY_HI_OUT
>
> BIT22 MMC1_PBIASLITE_PWRDNZ PWRDNZ control to MMC1 PBIASLITE
> This bit is used to protect the MMC1_PBIAS cell (MMC1
> I/O cell associated) when SDMMC1_VDDS is not stable.
> 0x0: Software must clear this bit when SDMMC1_VDDS
> changes.
> 0x1: Software must set this bit only when
> SDMMC1_VDDS is stable.
>
> BIT21 MMC1_PBIASLITE_VMODE VMODE control to MMC1 PBIASLITE
> 0x0: SDMMC1_VDDS = 1.8V
> 0x1: SDMMC1_VDDS = 3V

This looks much more cascaded regulator control than
anything else to me.

> For OMAP2430, OMAP3430 It additionally has a bit for speed mode control
> which are set always (static config)

I guess you mean this:

> BIT2 PBIASSPEEDCTRL0 Speed Control for MMC I/O
> 0b0 => 26 MHz I/O max speed
> 0b1 => 52 MHz I/O max speed

This seems to belong to the MMC host driver.

It is common that registers contain indiviual bits that end up in
different subsystems. Speed mode seems to belong in the MMC
driver.

The infrastructure used to spread out responsibility across different
drivers from a common register range or even for certain bits in a
certain register, is regmap. Check for example mfd/syscon.c.

> BIT25 MMC1_PBIASLITE_HIZ_MODE HIZ_MODE from MMC1 PBIASLITE
> 0x0: PBIAS in normal operation mode
> 0x1: PBIAS output is in high impedence state

This is actually pin config. But if it makes sense it should also be
part of the MMC regulator driver.

> You mean regulator via pinctrl APIs, I think It will just move the code
> from omap_hsmmc to a new regulator file with it own init data for pinctrl.

No I'm not saying you should use pinctrl as a "back-end" for this.
I mean you shall instantiate a regulator and let the callback ops
vtable for that regulator poke these bits.

> Not sure if Regulator maintainer will agree to it.

I will respect Marks judgement on this for sure.

> Moreover what I needs is three different states 0V, 0 to 1.8V, 3 V to 3.3V
> not 0, 1.8V, 3V. plus pbias register fields got moved around between omap3,
> omap4
> and omap5, That was one of the reason for moving to pinctrl states.

The regulator framework supports selector tables just
like this.

Where the register fields are located does not matter.

>>> That the bits are
>>> in the middle of pinctrl things does not really matter.
>
> It thought pinctrl-single,bits in pinctrl-single.c is introduced
> precisely for such misc control register which has bit configuration
> affecting different module i/o pads.

No. If we go down that road *anything* that is connected to a
pad becomes part of the pinctrl subsystem, then pinctrl-single
becomes some kind of hardware abstraction or BIOS, and that
is *not* the intent. It is only supposed to deal with the bits
there that are 100% related to what pinctrl does, nothing else.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 15:01                 ` Balaji T K
@ 2013-06-13 16:17                   ` Lee Jones
  0 siblings, 0 replies; 112+ messages in thread
From: Lee Jones @ 2013-06-13 16:17 UTC (permalink / raw)
  To: Balaji T K
  Cc: Linus Walleij, Laurent Pinchart, Linux-OMAP, linux-mmc,
	Chris Ball, ext Tony Lindgren, Cousson, Benoit,
	devicetree-discuss, Mark Brown, Ulf Hansson

On Thu, 13 Jun 2013, Balaji T K wrote:

> On Thursday 13 June 2013 04:17 PM, Lee Jones wrote:
> >On Thu, 13 Jun 2013, Linus Walleij wrote:
> >
> >>On Thu, Jun 6, 2013 at 9:14 PM, Balaji T K <balajitk@ti.com> wrote:
> >>
> >>>PBIAS register configuration is based on the regulator voltage
> >>>which supplies these pbias cells, sd i/o pads.
> >>>With PBIAS register address and bit definitions different across
> >>>omap[3,4,5], Simplify PBIAS configuration under three different
> >>>regulator voltage levels - O V, 1.8 V, 3 V. Corresponding pinctrl states
> >>>are defined as pbias_off, pbias_1v8, pbias_3v.
> >>>
> >>>pinctrl state mmc_init is used for configuring speed mode, loopback clock
> >>>(in devconf0/devconf1/prog_io1 register for omap3) and pull strength
> >>>configuration (in control_mmc1 for omap4)
> >>>
> >>>Signed-off-by: Balaji T K <balajitk@ti.com>
> >>
> >>You *need* Lee Jones and Mark Brown to review this.
> >>Maybe Laurent has something to add too.
> >>
> >>Ux500 had the very same thing, and there this was solved using
> >>a GPIO regulator for "vqmmc" a level-shifter. I vaguely remember
> >>Laurent doing something similar with the SH stuff.
> >
> >I haven't seem much of this patch-set, but this certainly looks like
> >it should be handled by a GPIO regulator instead of pinctrl. States
> >are easily declared in a 'struct gpio_regulator_state', which the
> >framework then uses to set the correct pins for the required voltage.
> >
> 
> Thanks for the pointer, but wondering why is it named as gpio-regulator
> and how it is different from fixed-regulator.
> After going through git log description, I understand that voltage/current level
> for a particular regulator is controlled by a set of pad/pin on the POWER IC
> and pad/pin may be usually connected to gpio pins if it is needs to be
> configurable and ground/pulled for constant voltage.
> 
> Collection of gpios logic level are modeled as state for particular voltage.
> But gpio is not used in my case.
> 
> >And yes, 'vqmmc' is a good place to store the this regulator.

As I say, I didn't see much of the code, only parts which looked
similar a voltage level-shifter.

The difference between fixed and gpio regulators, is that the former
is exactly that, 'fixed'. You can turn voltage on and off using a gpio
pin, but you can't shift the voltage. Something which is required of
your use-case. The latter switches between voltgages via a set of gpio
pins, for instance, your use-case could look somelike like:

static struct gpio_regulator_state sdi0_reg_states[] = {
        { .value = 3300000, .gpios = (1 << 0) },
        { .value = 1800000, .gpios = (0 << 0) },
};

But if there aren't any gpio pins involved, then this isn't what you
want either.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
       [not found]                     ` <CACRpkdY6cZ+bT-C9Go3sZVw6ErQqTm0m9__uKQrkg4eUU1thHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-06-13 16:29                       ` Tony Lindgren
  2013-06-13 17:45                         ` Mark Brown
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-06-13 16:29 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Ulf Hansson, Laurent Pinchart, Balaji T K,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, Mark Brown, Chris Ball,
	Linux-OMAP, Lee Jones

* Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> [130613 08:35]:
> On Thu, Jun 13, 2013 at 4:41 PM, Balaji T K <balajitk-l0cyMroinI0@public.gmane.org> wrote:
> 
> > You mean regulator via pinctrl APIs, I think It will just move the code
> > from omap_hsmmc to a new regulator file with it own init data for pinctrl.
> 
> No I'm not saying you should use pinctrl as a "back-end" for this.
> I mean you shall instantiate a regulator and let the callback ops
> vtable for that regulator poke these bits.

The interface to omap_hsmmc.c should be the regulator framework. This
is because it allows us to clean up all the messed up before and after
functions that really implement various GPIO regulators etc.

> > It thought pinctrl-single,bits in pinctrl-single.c is introduced
> > precisely for such misc control register which has bit configuration
> > affecting different module i/o pads.
> 
> No. If we go down that road *anything* that is connected to a
> pad becomes part of the pinctrl subsystem, then pinctrl-single
> becomes some kind of hardware abstraction or BIOS, and that
> is *not* the intent. It is only supposed to deal with the bits
> there that are 100% related to what pinctrl does, nothing else.

Sounds like the way to go is to do a standalone regulator driver that
optionally uses pinctrl-single,bits. But only for the bits in the PBIAS
register that are 100% related to pinctrl.

In any case the PBIAS regulator driver should be a separate driver
as it may need to be a child of the SCM driver for PM needs in the
future.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt
  2013-06-13 16:29                       ` Tony Lindgren
@ 2013-06-13 17:45                         ` Mark Brown
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Mark Brown @ 2013-06-13 17:45 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Linus Walleij, Balaji T K, Lee Jones, Laurent Pinchart,
	Linux-OMAP, linux-mmc, Chris Ball, Cousson, Benoit,
	devicetree-discuss, Ulf Hansson

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

On Thu, Jun 13, 2013 at 09:29:38AM -0700, Tony Lindgren wrote:
> * Linus Walleij <linus.walleij@linaro.org> [130613 08:35]:

> > No. If we go down that road *anything* that is connected to a
> > pad becomes part of the pinctrl subsystem, then pinctrl-single
> > becomes some kind of hardware abstraction or BIOS, and that
> > is *not* the intent. It is only supposed to deal with the bits
> > there that are 100% related to what pinctrl does, nothing else.

> Sounds like the way to go is to do a standalone regulator driver that
> optionally uses pinctrl-single,bits. But only for the bits in the PBIAS
> register that are 100% related to pinctrl.

> In any case the PBIAS regulator driver should be a separate driver
> as it may need to be a child of the SCM driver for PM needs in the
> future.

This all seems sensible to me.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup
  2013-06-13 17:45                         ` Mark Brown
@ 2013-11-21 14:20                           ` Balaji T K
  2013-11-21 14:20                             ` [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API Balaji T K
                                               ` (8 more replies)
  0 siblings, 9 replies; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Few cleanups to reduce code indent,
Add pbias_regulator support and adapt omap_hsmmc to use pbias regulator
to configure required voltage on mmc1 pad(SD card) i/o rails on OMAP SoCs.

Balaji T K (8):
  mmc: omap_hsmmc: use devm_regulator API
  mmc: omap_hsmmc: handle vcc and vcc_aux independently
  regulator: add pbias regulator support
  mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  ARM: dts: add pbias dt node
  ARM: dts: add pbias-supply
  ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  mmc: omap_hsmmc: remove pbias workaround

 .../bindings/regulator/pbias-regulator.txt         |   21 ++
 arch/arm/boot/dts/dra7-evm.dts                     |    1 +
 arch/arm/boot/dts/dra7.dtsi                        |   12 +
 arch/arm/boot/dts/omap2430.dtsi                    |   12 +
 arch/arm/boot/dts/omap3-beagle-xm.dts              |    1 +
 arch/arm/boot/dts/omap3-beagle.dts                 |    1 +
 arch/arm/boot/dts/omap3-devkit8000.dts             |    1 +
 arch/arm/boot/dts/omap3-evm-common.dtsi            |    1 +
 arch/arm/boot/dts/omap3-gta04.dts                  |    1 +
 arch/arm/boot/dts/omap3-igep.dtsi                  |    1 +
 arch/arm/boot/dts/omap3-n900.dts                   |    1 +
 arch/arm/boot/dts/omap3-overo.dtsi                 |    1 +
 arch/arm/boot/dts/omap3-zoom3.dts                  |    1 +
 arch/arm/boot/dts/omap3.dtsi                       |   12 +
 arch/arm/boot/dts/omap3430-sdp.dts                 |    1 +
 arch/arm/boot/dts/omap4-panda-common.dtsi          |    1 +
 arch/arm/boot/dts/omap4-sdp.dts                    |    1 +
 arch/arm/boot/dts/omap4-var-som.dts                |    1 +
 arch/arm/boot/dts/omap4.dtsi                       |   12 +
 arch/arm/boot/dts/omap5-uevm.dts                   |    1 +
 arch/arm/boot/dts/omap5.dtsi                       |   12 +
 arch/arm/configs/omap2plus_defconfig               |    2 +
 drivers/mmc/host/omap_hsmmc.c                      |  113 +++++----
 drivers/regulator/Kconfig                          |    7 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  264 ++++++++++++++++++++
 26 files changed, 434 insertions(+), 49 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-11-21 15:08                               ` Ulf Hansson
  2013-11-21 14:20                             ` [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
                                               ` (7 subsequent siblings)
  8 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Use devm_regulator API, while at it use
devm_regulator_get_optional for optional vmmc_aux supply

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index dbd32ad..1eb4350 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -316,7 +316,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	struct regulator *reg;
 	int ocr_value = 0;
 
-	reg = regulator_get(host->dev, "vmmc");
+	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
 		dev_err(host->dev, "vmmc regulator missing\n");
 		return PTR_ERR(reg);
@@ -336,7 +336,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 		}
 
 		/* Allow an aux regulator */
-		reg = regulator_get(host->dev, "vmmc_aux");
+		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
 		/* For eMMC do not power off when not in sleep state */
@@ -366,8 +366,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
 {
-	regulator_put(host->vcc);
-	regulator_put(host->vcc_aux);
 	mmc_slot(host).set_power = NULL;
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  2013-11-21 14:20                             ` [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-12-10 11:09                               ` Ulf Hansson
       [not found]                             ` <1385043627-30439-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
                                               ` (6 subsequent siblings)
  8 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

handle vcc and vcc_aux independently to reduce indent.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   54 +++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1eb4350..342be25 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * chips/cards need an interface voltage rail too.
 	 */
 	if (power_on) {
-		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		if (host->vcc)
+			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
 		/* Enable interface voltage rail, if needed */
 		if (ret == 0 && host->vcc_aux) {
 			ret = regulator_enable(host->vcc_aux);
-			if (ret < 0)
+			if (ret < 0 && host->vcc)
 				ret = mmc_regulator_set_ocr(host->mmc,
 							host->vcc, 0);
 		}
@@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		/* Shut down the rail */
 		if (host->vcc_aux)
 			ret = regulator_disable(host->vcc_aux);
-		if (!ret) {
+		if (host->vcc) {
 			/* Then proceed to shut down the local regulator */
 			ret = mmc_regulator_set_ocr(host->mmc,
 						host->vcc, 0);
@@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
-		dev_err(host->dev, "vmmc regulator missing\n");
+		dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+			PTR_ERR(reg));
 		return PTR_ERR(reg);
 	} else {
-		mmc_slot(host).set_power = omap_hsmmc_set_power;
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {
@@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 				return -EINVAL;
 			}
 		}
+	}
+	mmc_slot(host).set_power = omap_hsmmc_set_power;
 
-		/* Allow an aux regulator */
-		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
-		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
+	/* Allow an aux regulator */
+	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
+	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
-		/* For eMMC do not power off when not in sleep state */
-		if (mmc_slot(host).no_regulator_off_init)
-			return 0;
-		/*
-		* UGLY HACK:  workaround regulator framework bugs.
-		* When the bootloader leaves a supply active, it's
-		* initialized with zero usecount ... and we can't
-		* disable it without first enabling it.  Until the
-		* framework is fixed, we need a workaround like this
-		* (which is safe for MMC, but not in general).
-		*/
-		if (regulator_is_enabled(host->vcc) > 0 ||
-		    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
-			int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+	/* For eMMC do not power off when not in sleep state */
+	if (mmc_slot(host).no_regulator_off_init)
+		return 0;
+	/*
+	 * To disable boot_on regulator, enable regulator
+	 * to increase usecount and then disable it.
+	 */
+	if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
+	    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
+		int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
 
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 1, vdd);
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 0, 0);
-		}
+		mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
+		mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
 	}
 
 	return 0;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 3/8] regulator: add pbias regulator support
       [not found]                             ` <1385043627-30439-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-11-21 14:20                               ` Balaji T K
  2013-11-21 14:46                                 ` Mark Brown
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	bcousson-rdvid1DuHRBWk0Htik3J/w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, cjb-2X9k7bc8m7Mdnm+yROfE0A,
	broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ, Balaji T K

pbias register controls internal power supply to sd card i/o pads
in most OMAPs (OMAP2-5, DRA7).
Control bits for selecting voltage level and
enabling/disabling are in the same PBIAS register.

Signed-off-by: Balaji T K <balajitk-l0cyMroinI0@public.gmane.org>
---
 .../bindings/regulator/pbias-regulator.txt         |   21 ++
 drivers/regulator/Kconfig                          |    7 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  264 ++++++++++++++++++++
 4 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

diff --git a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
new file mode 100644
index 0000000..712fcd8
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,21 @@
+PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
+
+Required properties:
+- compatible:
+  - "regulator-pbias-omap2" for OMAP2
+  - "regulator-pbias-omap3" for OMAP3
+  - "regulator-pbias-omap4" for OMAP4
+  - "regulator-pbias-omap5" for OMAP5, DRA7
+- pbias-reg-offset: PBIAS control register offset from syscon base address
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+		pbias_regulator: pbias_regulator {
+			pbias-reg-offset = <0>;
+			regulator-name = "pbias_regulator";
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3000000>;
+	};
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..3177f45 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -369,6 +369,13 @@ config REGULATOR_PALMAS
 	  on the muxing. This is handled automatically in the driver by
 	  reading the mux info from OTP.
 
+config REGULATOR_PBIAS
+	tristate "PBIAS OMAP regulator driver"
+	depends on ARCH_OMAP && MFD_SYSCON
+	help
+	 This driver provides support for OMAP pbias modelled
+	 regulators.
+
 config REGULATOR_PCAP
 	tristate "Motorola PCAP2 regulator driver"
 	depends on EZX_PCAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..16000fa 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
 obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
+obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
new file mode 100644
index 0000000..48fda88
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,264 @@
+/*
+ * pbias-regulator.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Balaji T K <balajitk-l0cyMroinI0@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+struct pbias_bit_map {
+	u32 enable;
+	u32 enable_mask;
+	u32 vmode;
+};
+
+struct pbias_regulator_data {
+	struct regulator_desc desc;
+	void __iomem *pbias_addr;
+	unsigned int pbias_reg;
+	struct regulator_dev *dev;
+	struct regmap *syscon;
+
+
+	const struct pbias_bit_map *bmap;
+	int voltage;
+};
+
+static int pbias_regulator_set_voltage(struct regulator_dev *dev,
+			int min_uV, int max_uV, unsigned *selector)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
+	const struct pbias_bit_map *bmap = data->bmap;
+	int ret, vmode;
+
+	if (min_uV <= 1800000)
+		vmode = 0;
+	else if (min_uV > 1800000)
+		vmode = bmap->vmode;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						bmap->vmode, vmode);
+	data->voltage = min_uV;
+
+	return ret;
+}
+
+static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+
+	return data->voltage;
+}
+
+static int pbias_regulator_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_bit_map *bmap = data->bmap;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+					bmap->enable_mask, bmap->enable);
+
+	return ret;
+}
+
+static int pbias_regulator_disable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_bit_map *bmap = data->bmap;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						bmap->enable_mask, 0);
+	return ret;
+}
+
+static int pbias_regulator_is_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_bit_map *bmap = data->bmap;
+	int value;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+
+	return value & bmap->enable_mask;
+}
+
+static struct regulator_ops pbias_regulator_voltage_ops = {
+	.set_voltage	= pbias_regulator_set_voltage,
+	.get_voltage	= pbias_regulator_get_voltage,
+	.enable		= pbias_regulator_enable,
+	.disable	= pbias_regulator_disable,
+	.is_enabled	= pbias_regulator_is_enable,
+};
+
+#if CONFIG_OF
+static const struct pbias_bit_map pbias_omap3 = {
+	.enable = BIT(1),
+	.enable_mask = BIT(1),
+	.vmode = BIT(0),
+};
+
+static const struct pbias_bit_map pbias_omap4 = {
+	.enable = BIT(26) | BIT(22),
+	.enable_mask = BIT(26) | BIT(25) | BIT(22),
+	.vmode = BIT(21),
+};
+
+static const struct pbias_bit_map pbias_omap5 = {
+	.enable = BIT(27) | BIT(26),
+	.enable_mask = BIT(27) | BIT(25) | BIT(26),
+	.vmode = BIT(21),
+};
+
+static const struct of_device_id pbias_of_match[] = {
+	{ .compatible = "regulator-pbias-omap3", .data = &pbias_omap3},
+	{ .compatible = "regulator-pbias-omap4", .data = &pbias_omap4},
+	{ .compatible = "regulator-pbias-omap5", .data = &pbias_omap5},
+	{},
+};
+MODULE_DEVICE_TABLE(of, pbias_of_match);
+#endif
+
+static int pbias_regulator_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *syscon_np;
+	struct pbias_regulator_data *drvdata;
+	const struct of_device_id *id;
+	const char *supply_name;
+	struct regulator_init_data *initdata;
+	struct regulator_config cfg = { };
+	unsigned startup_delay;
+	int ret;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data),
+			       GFP_KERNEL);
+	if (drvdata == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate device data\n");
+		return -ENOMEM;
+	}
+
+	id = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
+	if (!id)
+		return -ENODEV;
+
+	drvdata->bmap = id->data;
+	if (!drvdata->bmap)
+		return -ENODEV;
+
+	initdata = of_get_regulator_init_data(&pdev->dev, np);
+	if (!initdata)
+		return -EINVAL;
+
+	supply_name = initdata->constraints.name;
+
+	of_property_read_u32(np, "startup-delay-us", &startup_delay);
+	ret = of_property_read_u32(np, "pbias-reg-offset",
+				   &drvdata->pbias_reg);
+	if (ret) {
+		dev_err(&pdev->dev, "no pbias-reg-offset property set\n");
+		return ret;
+	}
+
+	syscon_np = of_get_parent(np);
+	if (!syscon_np)
+		return -ENODEV;
+
+	drvdata->syscon = syscon_node_to_regmap(syscon_np);
+	of_node_put(syscon_np);
+	if (IS_ERR(drvdata->syscon))
+		return PTR_ERR(drvdata->syscon);
+
+	drvdata->desc.name = kstrdup(supply_name, GFP_KERNEL);
+	if (drvdata->desc.name == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate supply name\n");
+		return -ENOMEM;
+	}
+
+	drvdata->desc.owner = THIS_MODULE;
+	drvdata->desc.enable_time = startup_delay;
+	drvdata->desc.type = REGULATOR_VOLTAGE;
+	drvdata->desc.ops = &pbias_regulator_voltage_ops;
+	drvdata->desc.n_voltages = 3;
+
+	cfg.dev = &pdev->dev;
+	cfg.init_data = initdata;
+	cfg.driver_data = drvdata;
+	cfg.of_node = np;
+
+	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
+									&cfg);
+	if (IS_ERR(drvdata->dev)) {
+		ret = PTR_ERR(drvdata->dev);
+		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
+		goto err_regulator;
+	}
+
+	platform_set_drvdata(pdev, drvdata);
+
+	return 0;
+
+err_regulator:
+	kfree(drvdata->desc.name);
+	return ret;
+}
+
+static int pbias_regulator_remove(struct platform_device *pdev)
+{
+	struct pbias_regulator_data *drvdata = platform_get_drvdata(pdev);
+
+	kfree(drvdata->desc.name);
+
+	return 0;
+}
+
+static struct platform_driver pbias_regulator_driver = {
+	.probe		= pbias_regulator_probe,
+	.remove		= pbias_regulator_remove,
+	.driver		= {
+		.name		= "pbias-regulator",
+		.owner		= THIS_MODULE,
+		.of_match_table = of_match_ptr(pbias_of_match),
+	},
+};
+
+static int __init pbias_regulator_init(void)
+{
+	return platform_driver_register(&pbias_regulator_driver);
+}
+subsys_initcall(pbias_regulator_init);
+
+static void __exit pbias_regulator_exit(void)
+{
+	platform_driver_unregister(&pbias_regulator_driver);
+}
+module_exit(pbias_regulator_exit);
+
+MODULE_AUTHOR("Balaji T K <balajitk-l0cyMroinI0@public.gmane.org>");
+MODULE_DESCRIPTION("pbias voltage regulator");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pbias-regulator");
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 4/8] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (2 preceding siblings ...)
       [not found]                             ` <1385043627-30439-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-11-21 14:20                             ` Balaji T K
  2013-11-21 14:20                             ` [RFC PATCH v3 5/8] ARM: dts: add pbias dt node Balaji T K
                                               ` (4 subsequent siblings)
  8 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

In DT case, PBAIS registers are programmed via regulator,
use regulator APIs to control PBIAS.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..0a390f8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -126,6 +126,10 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define VDD_1V8			1800000		/* 180000 uV */
+#define VDD_3V0			3000000		/* 300000 uV */
+#define VDD_165_195		(ffs(MMC_VDD_165_195) - 1)
+
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -164,6 +168,8 @@ struct omap_hsmmc_host {
 	 */
 	struct	regulator	*vcc;
 	struct	regulator	*vcc_aux;
+	struct	regulator	*pbias;
+	bool			pbias_enabled;
 	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
@@ -272,6 +278,15 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
 
+	if (host->pbias) {
+		if (host->pbias_enabled == 1) {
+			ret = regulator_disable(host->pbias);
+			if (!ret)
+				host->pbias_enabled = 0;
+		}
+		regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
+	}
+
 	/*
 	 * Assume Vcc regulator is used only to power the card ... OMAP
 	 * VDDS is used to power the pins, optionally with a transceiver to
@@ -306,9 +321,29 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		}
 	}
 
+	if (host->pbias) {
+		if (vdd <= VDD_165_195)
+			ret = regulator_set_voltage(host->pbias, VDD_1V8,
+								VDD_1V8);
+		else
+			ret = regulator_set_voltage(host->pbias, VDD_3V0,
+								VDD_3V0);
+		if (ret < 0)
+			goto error_set_power;
+
+		if (host->pbias_enabled == 0) {
+			ret = regulator_enable(host->pbias);
+			if (!ret) {
+				host->pbias_enabled = 1;
+				goto error_set_power;
+			}
+		}
+	}
+
 	if (mmc_slot(host).after_set_reg)
 		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
 
+error_set_power:
 	return ret;
 }
 
@@ -342,6 +377,9 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
+	reg = devm_regulator_get_optional(host->dev, "pbias");
+	host->pbias = IS_ERR(reg) ? NULL : reg;
+
 	/* For eMMC do not power off when not in sleep state */
 	if (mmc_slot(host).no_regulator_off_init)
 		return 0;
@@ -1808,6 +1846,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
+	host->pbias_enabled = 0;
 
 	platform_set_drvdata(pdev, host);
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 5/8] ARM: dts: add pbias dt node
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (3 preceding siblings ...)
  2013-11-21 14:20                             ` [RFC PATCH v3 4/8] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-11-21 14:20                             ` [RFC PATCH v3 6/8] ARM: dts: add pbias-supply Balaji T K
                                               ` (3 subsequent siblings)
  8 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Add pbias regulator node as a child of system control
module - syscon.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/dra7.dtsi     |   12 ++++++++++++
 arch/arm/boot/dts/omap2430.dtsi |   12 ++++++++++++
 arch/arm/boot/dts/omap3.dtsi    |   12 ++++++++++++
 arch/arm/boot/dts/omap4.dtsi    |   12 ++++++++++++
 arch/arm/boot/dts/omap5.dtsi    |   12 ++++++++++++
 5 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..08bf835 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -119,6 +119,18 @@
 			pinctrl-single,function-mask = <0x3fffffff>;
 		};
 
+		tisyscon: tisyscon@4A100600 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A002E00 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap5";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index c535a5a..d1725a4 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,18 @@
 			pinctrl-single,function-mask = <0x3f>;
 		};
 
+		tisyscon: tisyscon@490024A0 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x490024A0 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap2";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+			};
+		};
+
 		gpio1: gpio@4900c000 {
 			compatible = "ti,omap2-gpio";
 			reg = <0x4900c000 0x200>;
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index f3a0c26..4e448cf 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -130,6 +130,18 @@
 			pinctrl-single,function-mask = <0xff1f>;
 		};
 
+		tisyscon: tisyscon@48002520 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x48002520 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap3";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+			};
+		};
+
 		gpio1: gpio@48310000 {
 			compatible = "ti,omap3-gpio";
 			reg = <0x48310000 0x200>;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index a1e0585..160c25a 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,18 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		tisyscon: tisyscon@4A100600 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A100600 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap4";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index fc3fad5..86a00d7 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,18 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		tisyscon: tisyscon@4A002E00 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A002E00 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap5";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 6/8] ARM: dts: add pbias-supply
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (4 preceding siblings ...)
  2013-11-21 14:20                             ` [RFC PATCH v3 5/8] ARM: dts: add pbias dt node Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-11-21 17:03                               ` Tony Lindgren
  2013-11-21 14:20                             ` [RFC PATCH v3 7/8] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
                                               ` (2 subsequent siblings)
  8 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Add pbias-supply to mmc1/sd card.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/dra7-evm.dts            |    1 +
 arch/arm/boot/dts/omap3-beagle-xm.dts     |    1 +
 arch/arm/boot/dts/omap3-beagle.dts        |    1 +
 arch/arm/boot/dts/omap3-devkit8000.dts    |    1 +
 arch/arm/boot/dts/omap3-evm-common.dtsi   |    1 +
 arch/arm/boot/dts/omap3-gta04.dts         |    1 +
 arch/arm/boot/dts/omap3-igep.dtsi         |    1 +
 arch/arm/boot/dts/omap3-n900.dts          |    1 +
 arch/arm/boot/dts/omap3-overo.dtsi        |    1 +
 arch/arm/boot/dts/omap3-zoom3.dts         |    1 +
 arch/arm/boot/dts/omap3430-sdp.dts        |    1 +
 arch/arm/boot/dts/omap4-panda-common.dtsi |    1 +
 arch/arm/boot/dts/omap4-sdp.dts           |    1 +
 arch/arm/boot/dts/omap4-var-som.dts       |    1 +
 arch/arm/boot/dts/omap5-uevm.dts          |    1 +
 15 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 5babba0..b2a5099 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -261,6 +261,7 @@
 &mmc1 {
 	status = "okay";
 	vmmc-supply = <&ldo1_reg>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts
index 31a632f..1e9290d 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -166,6 +166,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index fa532aa..bb335c9 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -129,6 +129,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-devkit8000.dts b/arch/arm/boot/dts/omap3-devkit8000.dts
index 4665421..ff8a9f9 100644
--- a/arch/arm/boot/dts/omap3-devkit8000.dts
+++ b/arch/arm/boot/dts/omap3-devkit8000.dts
@@ -86,6 +86,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-evm-common.dtsi b/arch/arm/boot/dts/omap3-evm-common.dtsi
index 3007e79..be47a37 100644
--- a/arch/arm/boot/dts/omap3-evm-common.dtsi
+++ b/arch/arm/boot/dts/omap3-evm-common.dtsi
@@ -64,6 +64,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-gta04.dts b/arch/arm/boot/dts/omap3-gta04.dts
index b9b55c9..95854ea 100644
--- a/arch/arm/boot/dts/omap3-gta04.dts
+++ b/arch/arm/boot/dts/omap3-gta04.dts
@@ -142,6 +142,7 @@
 	pinctrl-0 = <&mmc1_pins>;
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-igep.dtsi b/arch/arm/boot/dts/omap3-igep.dtsi
index ba1e58b..6f74003 100644
--- a/arch/arm/boot/dts/omap3-igep.dtsi
+++ b/arch/arm/boot/dts/omap3-igep.dtsi
@@ -114,6 +114,7 @@
       pinctrl-0 = <&mmc1_pins>;
       vmmc-supply = <&vmmc1>;
       vmmc_aux-supply = <&vsim>;
+      pbias-supply = <&pbias_regulator>;
       bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index c4f20bf..73f26ad 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -354,6 +354,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins>;
 	vmmc-supply = <&vmmc1>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 	cd-gpios = <&gpio6 0 GPIO_ACTIVE_HIGH>; /* 160 */
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi
index a461d2f..e697f0e 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -61,6 +61,7 @@
 /* on board microSD slot */
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 };
 
diff --git a/arch/arm/boot/dts/omap3-zoom3.dts b/arch/arm/boot/dts/omap3-zoom3.dts
index 15eb9fe..a6e1557 100644
--- a/arch/arm/boot/dts/omap3-zoom3.dts
+++ b/arch/arm/boot/dts/omap3-zoom3.dts
@@ -168,6 +168,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins>;
diff --git a/arch/arm/boot/dts/omap3430-sdp.dts b/arch/arm/boot/dts/omap3430-sdp.dts
index 281914e..cee3ee4 100644
--- a/arch/arm/boot/dts/omap3430-sdp.dts
+++ b/arch/arm/boot/dts/omap3430-sdp.dts
@@ -34,6 +34,7 @@
 &mmc1 {
 	vmmc-supply = <&vmmc1>;
 	vmmc_aux-supply = <&vsim>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap4-panda-common.dtsi b/arch/arm/boot/dts/omap4-panda-common.dtsi
index 88c6a05..7a1758b 100644
--- a/arch/arm/boot/dts/omap4-panda-common.dtsi
+++ b/arch/arm/boot/dts/omap4-panda-common.dtsi
@@ -346,6 +346,7 @@
 
 &mmc1 {
 	vmmc-supply = <&vmmc>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index dbc81fb..1d2be1d 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -416,6 +416,7 @@
 
 &mmc1 {
 	vmmc-supply = <&vmmc>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <8>;
 };
 
diff --git a/arch/arm/boot/dts/omap4-var-som.dts b/arch/arm/boot/dts/omap4-var-som.dts
index b41269e..9ccb07c 100644
--- a/arch/arm/boot/dts/omap4-var-som.dts
+++ b/arch/arm/boot/dts/omap4-var-som.dts
@@ -75,6 +75,7 @@
 
 &mmc1 {
 	vmmc-supply = <&vmmc>;
+	pbias-supply = <&pbias_regulator>;
 	ti,bus-width = <8>;
 	ti,non-removable;
 };
diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 002fa70..76eae5a 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -204,6 +204,7 @@
 
 &mmc1 {
 	vmmc-supply = <&ldo9_reg>;
+	pbias-supply = <&pbias_regulator>;
 	bus-width = <4>;
 };
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 7/8] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (5 preceding siblings ...)
  2013-11-21 14:20                             ` [RFC PATCH v3 6/8] ARM: dts: add pbias-supply Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-11-21 14:20                             ` [RFC PATCH v3 8/8] mmc: omap_hsmmc: remove pbias workaround Balaji T K
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  8 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Enable REGULATOR_PBIAS needed for SD card on most OMAPs.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/configs/omap2plus_defconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 98a50c3..06c6404 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -169,6 +169,7 @@ CONFIG_DRA752_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_OMAP_WATCHDOG=y
 CONFIG_TWL4030_WATCHDOG=y
+CONFIG_MFD_SYSCON=y
 CONFIG_MFD_PALMAS=y
 CONFIG_MFD_TPS65217=y
 CONFIG_MFD_TPS65910=y
@@ -179,6 +180,7 @@ CONFIG_REGULATOR_TPS6507X=y
 CONFIG_REGULATOR_TPS65217=y
 CONFIG_REGULATOR_TPS65910=y
 CONFIG_REGULATOR_TWL4030=y
+CONFIG_REGULATOR_PBIAS=y
 CONFIG_FB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_FB_MODE_HELPERS=y
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [RFC PATCH v3 8/8] mmc: omap_hsmmc: remove pbias workaround
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (6 preceding siblings ...)
  2013-11-21 14:20                             ` [RFC PATCH v3 7/8] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2013-11-21 14:20                             ` Balaji T K
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  8 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-11-21 14:20 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

remove pbias workaround

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 0a390f8..0f0aa5d 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -170,7 +170,6 @@ struct omap_hsmmc_host {
 	struct	regulator	*vcc_aux;
 	struct	regulator	*pbias;
 	bool			pbias_enabled;
-	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
 	spinlock_t		irq_lock; /* Prevent races with irq handler */
@@ -267,13 +266,6 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 */
 	if (!host->vcc)
 		return 0;
-	/*
-	 * With DT, never turn OFF the regulator for MMC1. This is because
-	 * the pbias cell programming support is still missing when
-	 * booting with Device tree
-	 */
-	if (host->pbias_disable && !vdd)
-		return 0;
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
@@ -1541,13 +1533,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * of external transceiver; but they all handle 1.8V.
 		 */
 		if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
-			(ios->vdd == DUAL_VOLT_OCR_BIT) &&
-			/*
-			 * With pbias cell programming missing, this
-			 * can't be allowed on MMC1 when booting with device
-			 * tree.
-			 */
-			!host->pbias_disable) {
+			(ios->vdd == DUAL_VOLT_OCR_BIT)) {
 				/*
 				 * The mmc_select_voltage fn of the core does
 				 * not seem to set the power_mode to
@@ -1880,10 +1866,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_context_save(host);
 
-	/* This can be removed once we support PBIAS with DT */
-	if (host->dev->of_node && res->start == 0x4809c000)
-		host->pbias_disable = 1;
-
 	host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
 	/*
 	 * MMC can still work without debounce clock.
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 3/8] regulator: add pbias regulator support
  2013-11-21 14:20                               ` [RFC PATCH v3 3/8] regulator: add pbias regulator support Balaji T K
@ 2013-11-21 14:46                                 ` Mark Brown
  2013-12-03 15:54                                   ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Mark Brown @ 2013-11-21 14:46 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

[-- Attachment #1: Type: text/plain, Size: 2116 bytes --]

On Thu, Nov 21, 2013 at 07:50:22PM +0530, Balaji T K wrote:

> +static int pbias_regulator_set_voltage(struct regulator_dev *dev,
> +			int min_uV, int max_uV, unsigned *selector)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
> +	const struct pbias_bit_map *bmap = data->bmap;
> +	int ret, vmode;
> +
> +	if (min_uV <= 1800000)
> +		vmode = 0;
> +	else if (min_uV > 1800000)
> +		vmode = bmap->vmode;
> +
> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
> +						bmap->vmode, vmode);
> +	data->voltage = min_uV;

> +static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> +
> +	return data->voltage;
> +}

These don't match up with each other - the get and set voltage calls
should reflect what the hardware state is, not what was requested by the
caller.  You should be able to use the regmap helpers I think.

> +static int pbias_regulator_enable(struct regulator_dev *rdev)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> +	const struct pbias_bit_map *bmap = data->bmap;
> +	int ret;
> +
> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
> +					bmap->enable_mask, bmap->enable);

regulator_enable_regmap() and similarly for disable() and is_enabled().

> +	supply_name = initdata->constraints.name;
> +
> +	of_property_read_u32(np, "startup-delay-us", &startup_delay);
> +	ret = of_property_read_u32(np, "pbias-reg-offset",
> +				   &drvdata->pbias_reg);
> +	if (ret) {
> +		dev_err(&pdev->dev, "no pbias-reg-offset property set\n");
> +		return ret;
> +	}

This looks like it should be added as a standard property for overridig
the regulator delay if it can't be set based on the compatible string
alone due to board dependencies.  Do something like what's done for
regulator-ramp-delay.

> +err_regulator:
> +	kfree(drvdata->desc.name);
> +	return ret;

devm_kzalloc().

> +static int __init pbias_regulator_init(void)
> +{
> +	return platform_driver_register(&pbias_regulator_driver);
> +}
> +subsys_initcall(pbias_regulator_init);

module_platform_driver().

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API
  2013-11-21 14:20                             ` [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2013-11-21 15:08                               ` Ulf Hansson
  2013-12-05 15:29                                 ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Ulf Hansson @ 2013-11-21 15:08 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-omap, bcousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
> Use devm_regulator API, while at it use
> devm_regulator_get_optional for optional vmmc_aux supply
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index dbd32ad..1eb4350 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -316,7 +316,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>         struct regulator *reg;
>         int ocr_value = 0;
>
> -       reg = regulator_get(host->dev, "vmmc");
> +       reg = devm_regulator_get(host->dev, "vmmc");
>         if (IS_ERR(reg)) {
>                 dev_err(host->dev, "vmmc regulator missing\n");
>                 return PTR_ERR(reg);
> @@ -336,7 +336,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>                 }
>
>                 /* Allow an aux regulator */
> -               reg = regulator_get(host->dev, "vmmc_aux");
> +               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>                 host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>
>                 /* For eMMC do not power off when not in sleep state */
> @@ -366,8 +366,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>
>  static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
>  {
> -       regulator_put(host->vcc);
> -       regulator_put(host->vcc_aux);
>         mmc_slot(host).set_power = NULL;
>  }

While you are touching this code I would suggest to convert to
mmc_regulator_get_supply instead. That mean the vmmc_aux change name
to vqmmc though, so you need to adapt for this as well then.

Kind regards
Ulf Hansson

>
> --
> 1.7.5.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 6/8] ARM: dts: add pbias-supply
  2013-11-21 14:20                             ` [RFC PATCH v3 6/8] ARM: dts: add pbias-supply Balaji T K
@ 2013-11-21 17:03                               ` Tony Lindgren
  2013-12-05 14:55                                 ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-11-21 17:03 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131121 06:21]:
> Add pbias-supply to mmc1/sd card.
...

> --- a/arch/arm/boot/dts/dra7-evm.dts
> +++ b/arch/arm/boot/dts/dra7-evm.dts
> @@ -261,6 +261,7 @@
>  &mmc1 {
>  	status = "okay";
>  	vmmc-supply = <&ldo1_reg>;
> +	pbias-supply = <&pbias_regulator>;
>  	bus-width = <4>;
>  };

You may not need to patch this in at all. I think the PBIAS is there
only for the first slot and it's hardwired so it's always there. If
that's the case, then you can just always request it. Or use the
compatible flag if needed.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 3/8] regulator: add pbias regulator support
  2013-11-21 14:46                                 ` Mark Brown
@ 2013-12-03 15:54                                   ` Balaji T K
  2013-12-03 16:06                                     ` Mark Brown
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-03 15:54 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

On Thursday 21 November 2013 08:16 PM, Mark Brown wrote:
> On Thu, Nov 21, 2013 at 07:50:22PM +0530, Balaji T K wrote:
>
>> +static int pbias_regulator_set_voltage(struct regulator_dev *dev,
>> +			int min_uV, int max_uV, unsigned *selector)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
>> +	const struct pbias_bit_map *bmap = data->bmap;
>> +	int ret, vmode;
>> +
>> +	if (min_uV <= 1800000)
>> +		vmode = 0;
>> +	else if (min_uV > 1800000)
>> +		vmode = bmap->vmode;
>> +
>> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
>> +						bmap->vmode, vmode);
>> +	data->voltage = min_uV;
>
>> +static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
>> +
>> +	return data->voltage;
>> +}
>
> These don't match up with each other - the get and set voltage calls
> should reflect what the hardware state is, not what was requested by the
> caller.  You should be able to use the regmap helpers I think.
>
Hi,

get_voltage returns the min_uV, saved in set_voltage since pbias
only need to programmed if the voltage supply in for pbias cell is less than
or greater than 1.8V, so vmode bit will be set for 3V and also for 3.3V too.

>> +static int pbias_regulator_enable(struct regulator_dev *rdev)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
>> +	const struct pbias_bit_map *bmap = data->bmap;
>> +	int ret;
>> +
>> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
>> +					bmap->enable_mask, bmap->enable);
>
> regulator_enable_regmap() and similarly for disable() and is_enabled().
>

I don't think regmap helper can be used here, to enable pbias cells
I need reset a bit field (to bring pbias out of high impedence mode)
and also set a bit (to bring it out of power down mode)

>> +	supply_name = initdata->constraints.name;
>> +
>> +	of_property_read_u32(np, "startup-delay-us", &startup_delay);
>> +	ret = of_property_read_u32(np, "pbias-reg-offset",
>> +				   &drvdata->pbias_reg);
>> +	if (ret) {
>> +		dev_err(&pdev->dev, "no pbias-reg-offset property set\n");
>> +		return ret;
>> +	}
>
> This looks like it should be added as a standard property for overridig
> the regulator delay if it can't be set based on the compatible string
> alone due to board dependencies.  Do something like what's done for
> regulator-ramp-delay.
>
>> +err_regulator:
>> +	kfree(drvdata->desc.name);
>> +	return ret;
>
> devm_kzalloc().
>

Will assign desc name statically

>> +static int __init pbias_regulator_init(void)
>> +{
>> +	return platform_driver_register(&pbias_regulator_driver);
>> +}
>> +subsys_initcall(pbias_regulator_init);
>
> module_platform_driver().

OK


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 3/8] regulator: add pbias regulator support
  2013-12-03 15:54                                   ` Balaji T K
@ 2013-12-03 16:06                                     ` Mark Brown
  0 siblings, 0 replies; 112+ messages in thread
From: Mark Brown @ 2013-12-03 16:06 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

On Tue, Dec 03, 2013 at 09:24:15PM +0530, Balaji T K wrote:
> On Thursday 21 November 2013 08:16 PM, Mark Brown wrote:

> >These don't match up with each other - the get and set voltage calls
> >should reflect what the hardware state is, not what was requested by the
> >caller.  You should be able to use the regmap helpers I think.

> get_voltage returns the min_uV, saved in set_voltage since pbias
> only need to programmed if the voltage supply in for pbias cell is less than
> or greater than 1.8V, so vmode bit will be set for 3V and also for 3.3V too.

That's the problem...

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 6/8] ARM: dts: add pbias-supply
  2013-11-21 17:03                               ` Tony Lindgren
@ 2013-12-05 14:55                                 ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-05 14:55 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Thursday 21 November 2013 10:33 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131121 06:21]:
>> Add pbias-supply to mmc1/sd card.
> ...
>
>> --- a/arch/arm/boot/dts/dra7-evm.dts
>> +++ b/arch/arm/boot/dts/dra7-evm.dts
>> @@ -261,6 +261,7 @@
>>   &mmc1 {
>>   	status = "okay";
>>   	vmmc-supply = <&ldo1_reg>;
>> +	pbias-supply = <&pbias_regulator>;
>>   	bus-width = <4>;
>>   };
>
> You may not need to patch this in at all. I think the PBIAS is there
> only for the first slot and it's hardwired so it's always there. If
> that's the case, then you can just always request it. Or use the
> compatible flag if needed.

pbias is not applicable for mmc1 on am33xx and is applicable for
only for OMAP2-OMAP5, so I can add pbias-supply to omapx.dtsi files

>
> Regards,
>
> Tony
>

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API
  2013-11-21 15:08                               ` Ulf Hansson
@ 2013-12-05 15:29                                 ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-05 15:29 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-omap, bcousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On Thursday 21 November 2013 08:38 PM, Ulf Hansson wrote:
> On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
>> Use devm_regulator API, while at it use
>> devm_regulator_get_optional for optional vmmc_aux supply
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   drivers/mmc/host/omap_hsmmc.c |    6 ++----
>>   1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index dbd32ad..1eb4350 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -316,7 +316,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>          struct regulator *reg;
>>          int ocr_value = 0;
>>
>> -       reg = regulator_get(host->dev, "vmmc");
>> +       reg = devm_regulator_get(host->dev, "vmmc");
>>          if (IS_ERR(reg)) {
>>                  dev_err(host->dev, "vmmc regulator missing\n");
>>                  return PTR_ERR(reg);
>> @@ -336,7 +336,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>                  }
>>
>>                  /* Allow an aux regulator */
>> -               reg = regulator_get(host->dev, "vmmc_aux");
>> +               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>                  host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>
>>                  /* For eMMC do not power off when not in sleep state */
>> @@ -366,8 +366,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>
>>   static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
>>   {
>> -       regulator_put(host->vcc);
>> -       regulator_put(host->vcc_aux);
>>          mmc_slot(host).set_power = NULL;
>>   }
>
> While you are touching this code I would suggest to convert to
> mmc_regulator_get_supply instead. That mean the vmmc_aux change name
> to vqmmc though, so you need to adapt for this as well then.
>

Hi Ulf,

Thanks for the comments, I will address it on separate series.

Thanks and Regards,
Balaji T K

^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup
  2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                               ` (7 preceding siblings ...)
  2013-11-21 14:20                             ` [RFC PATCH v3 8/8] mmc: omap_hsmmc: remove pbias workaround Balaji T K
@ 2013-12-10 10:16                             ` Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
                                                 ` (7 more replies)
  8 siblings, 8 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Few cleanups to reduce code indent,
Add pbias_regulator support and adapt omap_hsmmc to use pbias regulator
to configure required voltage on mmc1 pad(SD card) i/o rails on OMAP SoCs.

Balaji T K (7):
  mmc: omap_hsmmc: use devm_regulator API
  mmc: omap_hsmmc: handle vcc and vcc_aux independently
  regulator: add pbias regulator support
  mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  ARM: dts: add pbias dt node
  ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  mmc: omap_hsmmc: remove pbias workaround

 .../bindings/regulator/pbias-regulator.txt         |   21 ++
 arch/arm/boot/dts/dra7.dtsi                        |   14 ++
 arch/arm/boot/dts/omap2430.dtsi                    |   14 ++
 arch/arm/boot/dts/omap3.dtsi                       |   14 ++
 arch/arm/boot/dts/omap4.dtsi                       |   14 ++
 arch/arm/boot/dts/omap5.dtsi                       |   14 ++
 arch/arm/configs/omap2plus_defconfig               |    2 +
 drivers/mmc/host/omap_hsmmc.c                      |  113 ++++++----
 drivers/regulator/Kconfig                          |    9 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  232 ++++++++++++++++++++
 11 files changed, 399 insertions(+), 49 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
                                                 ` (6 subsequent siblings)
  7 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Use devm_regulator API, while at it use
devm_regulator_get_optional for optional vmmc_aux supply

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index dbd32ad..1eb4350 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -316,7 +316,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	struct regulator *reg;
 	int ocr_value = 0;
 
-	reg = regulator_get(host->dev, "vmmc");
+	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
 		dev_err(host->dev, "vmmc regulator missing\n");
 		return PTR_ERR(reg);
@@ -336,7 +336,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 		}
 
 		/* Allow an aux regulator */
-		reg = regulator_get(host->dev, "vmmc_aux");
+		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
 		/* For eMMC do not power off when not in sleep state */
@@ -366,8 +366,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
 {
-	regulator_put(host->vcc);
-	regulator_put(host->vcc_aux);
 	mmc_slot(host).set_power = NULL;
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 3/7] regulator: add pbias regulator support Balaji T K
                                                 ` (5 subsequent siblings)
  7 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

handle vcc and vcc_aux independently to reduce indent.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   54 +++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1eb4350..342be25 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * chips/cards need an interface voltage rail too.
 	 */
 	if (power_on) {
-		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		if (host->vcc)
+			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
 		/* Enable interface voltage rail, if needed */
 		if (ret == 0 && host->vcc_aux) {
 			ret = regulator_enable(host->vcc_aux);
-			if (ret < 0)
+			if (ret < 0 && host->vcc)
 				ret = mmc_regulator_set_ocr(host->mmc,
 							host->vcc, 0);
 		}
@@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		/* Shut down the rail */
 		if (host->vcc_aux)
 			ret = regulator_disable(host->vcc_aux);
-		if (!ret) {
+		if (host->vcc) {
 			/* Then proceed to shut down the local regulator */
 			ret = mmc_regulator_set_ocr(host->mmc,
 						host->vcc, 0);
@@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
-		dev_err(host->dev, "vmmc regulator missing\n");
+		dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+			PTR_ERR(reg));
 		return PTR_ERR(reg);
 	} else {
-		mmc_slot(host).set_power = omap_hsmmc_set_power;
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {
@@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 				return -EINVAL;
 			}
 		}
+	}
+	mmc_slot(host).set_power = omap_hsmmc_set_power;
 
-		/* Allow an aux regulator */
-		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
-		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
+	/* Allow an aux regulator */
+	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
+	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
-		/* For eMMC do not power off when not in sleep state */
-		if (mmc_slot(host).no_regulator_off_init)
-			return 0;
-		/*
-		* UGLY HACK:  workaround regulator framework bugs.
-		* When the bootloader leaves a supply active, it's
-		* initialized with zero usecount ... and we can't
-		* disable it without first enabling it.  Until the
-		* framework is fixed, we need a workaround like this
-		* (which is safe for MMC, but not in general).
-		*/
-		if (regulator_is_enabled(host->vcc) > 0 ||
-		    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
-			int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+	/* For eMMC do not power off when not in sleep state */
+	if (mmc_slot(host).no_regulator_off_init)
+		return 0;
+	/*
+	 * To disable boot_on regulator, enable regulator
+	 * to increase usecount and then disable it.
+	 */
+	if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
+	    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
+		int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
 
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 1, vdd);
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 0, 0);
-		}
+		mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
+		mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
 	}
 
 	return 0;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 3/7] regulator: add pbias regulator support
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 10:40                                 ` Mark Brown
  2013-12-10 10:16                               ` [PATCH v4 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
                                                 ` (4 subsequent siblings)
  7 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

pbias register controls internal power supply to sd card i/o pads
in most OMAPs (OMAP2-5, DRA7).
Control bits for selecting voltage level and
enabling/disabling are in the same PBIAS register.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 .../bindings/regulator/pbias-regulator.txt         |   21 ++
 drivers/regulator/Kconfig                          |    9 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  232 ++++++++++++++++++++
 4 files changed, 263 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

diff --git a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
new file mode 100644
index 0000000..712fcd8
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,21 @@
+PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
+
+Required properties:
+- compatible:
+  - "regulator-pbias-omap2" for OMAP2
+  - "regulator-pbias-omap3" for OMAP3
+  - "regulator-pbias-omap4" for OMAP4
+  - "regulator-pbias-omap5" for OMAP5, DRA7
+- pbias-reg-offset: PBIAS control register offset from syscon base address
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+		pbias_regulator: pbias_regulator {
+			pbias-reg-offset = <0>;
+			regulator-name = "pbias_regulator";
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3000000>;
+	};
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..de57611 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -369,6 +369,15 @@ config REGULATOR_PALMAS
 	  on the muxing. This is handled automatically in the driver by
 	  reading the mux info from OTP.
 
+config REGULATOR_PBIAS
+	tristate "PBIAS OMAP regulator driver"
+	depends on ARCH_OMAP && MFD_SYSCON
+	help
+	 Say y here to support pbias regulator for mmc1:SD card i/o
+	 on OMAP SoCs.
+	 This driver provides support for OMAP pbias modelled
+	 regulators.
+
 config REGULATOR_PCAP
 	tristate "Motorola PCAP2 regulator driver"
 	depends on EZX_PCAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..16000fa 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
 obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
+obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
new file mode 100644
index 0000000..ae902d8
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,232 @@
+/*
+ * pbias-regulator.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Balaji T K <balajitk@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+struct pbias_reg_info {
+	u32 enable;
+	u32 enable_mask;
+	u32 vmode;
+	char *name;
+};
+
+struct pbias_regulator_data {
+	struct regulator_desc desc;
+	void __iomem *pbias_addr;
+	unsigned int pbias_reg;
+	struct regulator_dev *dev;
+	struct regmap *syscon;
+	const struct pbias_reg_info *info;
+	int voltage;
+};
+
+static int pbias_regulator_set_voltage(struct regulator_dev *dev,
+			int min_uV, int max_uV, unsigned *selector)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
+	const struct pbias_reg_info *info = data->info;
+	int ret, vmode;
+
+	if (min_uV <= 1800000)
+		vmode = 0;
+	else if (min_uV > 1800000)
+		vmode = info->vmode;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->vmode, vmode);
+	data->voltage = min_uV;
+
+	return ret;
+}
+
+static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+
+	return data->voltage;
+}
+
+static int pbias_regulator_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+					info->enable_mask, info->enable);
+
+	return ret;
+}
+
+static int pbias_regulator_disable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->enable_mask, 0);
+	return ret;
+}
+
+static int pbias_regulator_is_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int value;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+
+	return value & info->enable_mask;
+}
+
+static struct regulator_ops pbias_regulator_voltage_ops = {
+	.set_voltage	= pbias_regulator_set_voltage,
+	.get_voltage	= pbias_regulator_get_voltage,
+	.enable		= pbias_regulator_enable,
+	.disable	= pbias_regulator_disable,
+	.is_enabled	= pbias_regulator_is_enable,
+};
+
+#if CONFIG_OF
+static const struct pbias_reg_info pbias_omap3 = {
+	.enable = BIT(1),
+	.enable_mask = BIT(1),
+	.vmode = BIT(0),
+	.name = "pbias_omap3"
+};
+
+static const struct pbias_reg_info pbias_omap4 = {
+	.enable = BIT(26) | BIT(22),
+	.enable_mask = BIT(26) | BIT(25) | BIT(22),
+	.vmode = BIT(21),
+	.name = "pbias_omap4"
+};
+
+static const struct pbias_reg_info pbias_omap5 = {
+	.enable = BIT(27) | BIT(26),
+	.enable_mask = BIT(27) | BIT(25) | BIT(26),
+	.vmode = BIT(21),
+	.name = "pbias_omap5"
+};
+
+static const struct of_device_id pbias_of_match[] = {
+	{ .compatible = "regulator-pbias-omap3", .data = &pbias_omap3},
+	{ .compatible = "regulator-pbias-omap4", .data = &pbias_omap4},
+	{ .compatible = "regulator-pbias-omap5", .data = &pbias_omap5},
+	{},
+};
+MODULE_DEVICE_TABLE(of, pbias_of_match);
+#endif
+
+static int pbias_regulator_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *syscon_np;
+	struct pbias_regulator_data *drvdata;
+	const struct of_device_id *id;
+	struct regulator_init_data *initdata;
+	struct regulator_config cfg = { };
+	int ret;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data),
+			       GFP_KERNEL);
+	if (drvdata == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate device data\n");
+		return -ENOMEM;
+	}
+
+	id = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
+	if (!id)
+		return -ENODEV;
+
+	drvdata->info = id->data;
+	if (!drvdata->info)
+		return -ENODEV;
+
+	initdata = of_get_regulator_init_data(&pdev->dev, np);
+	if (!initdata)
+		return -EINVAL;
+
+	ret = of_property_read_u32(np, "pbias-reg-offset",
+				   &drvdata->pbias_reg);
+	if (ret) {
+		dev_err(&pdev->dev, "no pbias-reg-offset property set\n");
+		return ret;
+	}
+
+	syscon_np = of_get_parent(np);
+	if (!syscon_np)
+		return -ENODEV;
+
+	drvdata->syscon = syscon_node_to_regmap(syscon_np);
+	of_node_put(syscon_np);
+	if (IS_ERR(drvdata->syscon))
+		return PTR_ERR(drvdata->syscon);
+
+	drvdata->desc.name = drvdata->info->name;
+	drvdata->desc.owner = THIS_MODULE;
+	drvdata->desc.type = REGULATOR_VOLTAGE;
+	drvdata->desc.ops = &pbias_regulator_voltage_ops;
+	drvdata->desc.n_voltages = 3;
+
+	cfg.dev = &pdev->dev;
+	cfg.init_data = initdata;
+	cfg.driver_data = drvdata;
+	cfg.of_node = np;
+
+	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
+									&cfg);
+	if (IS_ERR(drvdata->dev)) {
+		ret = PTR_ERR(drvdata->dev);
+		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
+		goto err_regulator;
+	}
+
+	platform_set_drvdata(pdev, drvdata);
+
+err_regulator:
+	return ret;
+}
+
+static struct platform_driver pbias_regulator_driver = {
+	.probe		= pbias_regulator_probe,
+	.driver		= {
+		.name		= "pbias-regulator",
+		.owner		= THIS_MODULE,
+		.of_match_table = of_match_ptr(pbias_of_match),
+	},
+};
+
+module_platform_driver(pbias_regulator_driver);
+
+MODULE_AUTHOR("Balaji T K <balajitk@ti.com>");
+MODULE_DESCRIPTION("pbias voltage regulator");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pbias-regulator");
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                 ` (2 preceding siblings ...)
  2013-12-10 10:16                               ` [PATCH v4 3/7] regulator: add pbias regulator support Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 5/7] ARM: dts: add pbias dt node Balaji T K
                                                 ` (3 subsequent siblings)
  7 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

In DT case, PBAIS registers are programmed via regulator,
use regulator APIs to control PBIAS.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..0a390f8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -126,6 +126,10 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define VDD_1V8			1800000		/* 180000 uV */
+#define VDD_3V0			3000000		/* 300000 uV */
+#define VDD_165_195		(ffs(MMC_VDD_165_195) - 1)
+
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -164,6 +168,8 @@ struct omap_hsmmc_host {
 	 */
 	struct	regulator	*vcc;
 	struct	regulator	*vcc_aux;
+	struct	regulator	*pbias;
+	bool			pbias_enabled;
 	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
@@ -272,6 +278,15 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
 
+	if (host->pbias) {
+		if (host->pbias_enabled == 1) {
+			ret = regulator_disable(host->pbias);
+			if (!ret)
+				host->pbias_enabled = 0;
+		}
+		regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
+	}
+
 	/*
 	 * Assume Vcc regulator is used only to power the card ... OMAP
 	 * VDDS is used to power the pins, optionally with a transceiver to
@@ -306,9 +321,29 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		}
 	}
 
+	if (host->pbias) {
+		if (vdd <= VDD_165_195)
+			ret = regulator_set_voltage(host->pbias, VDD_1V8,
+								VDD_1V8);
+		else
+			ret = regulator_set_voltage(host->pbias, VDD_3V0,
+								VDD_3V0);
+		if (ret < 0)
+			goto error_set_power;
+
+		if (host->pbias_enabled == 0) {
+			ret = regulator_enable(host->pbias);
+			if (!ret) {
+				host->pbias_enabled = 1;
+				goto error_set_power;
+			}
+		}
+	}
+
 	if (mmc_slot(host).after_set_reg)
 		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
 
+error_set_power:
 	return ret;
 }
 
@@ -342,6 +377,9 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
+	reg = devm_regulator_get_optional(host->dev, "pbias");
+	host->pbias = IS_ERR(reg) ? NULL : reg;
+
 	/* For eMMC do not power off when not in sleep state */
 	if (mmc_slot(host).no_regulator_off_init)
 		return 0;
@@ -1808,6 +1846,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
+	host->pbias_enabled = 0;
 
 	platform_set_drvdata(pdev, host);
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 5/7] ARM: dts: add pbias dt node
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                 ` (3 preceding siblings ...)
  2013-12-10 10:16                               ` [PATCH v4 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 22:42                                 ` Tony Lindgren
  2013-12-10 10:16                               ` [PATCH v4 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
                                                 ` (2 subsequent siblings)
  7 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Add pbias regulator node as a child of system control
module - syscon.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/boot/dts/dra7.dtsi     |   14 ++++++++++++++
 arch/arm/boot/dts/omap2430.dtsi |   14 ++++++++++++++
 arch/arm/boot/dts/omap3.dtsi    |   14 ++++++++++++++
 arch/arm/boot/dts/omap4.dtsi    |   14 ++++++++++++++
 arch/arm/boot/dts/omap5.dtsi    |   14 ++++++++++++++
 5 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..1a52676 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -119,6 +119,19 @@
 			pinctrl-single,function-mask = <0x3fffffff>;
 		};
 
+		tisyscon: tisyscon@4A100600 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A002E00 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap5";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <10>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
@@ -485,6 +498,7 @@
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
 			status = "disabled";
+			pbias-supply = <&pbias_regulator>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index d624345..7d084c4 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,19 @@
 			pinctrl-single,function-mask = <0x3f>;
 		};
 
+		tisyscon: tisyscon@490024A0 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x490024A0 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap2";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+			};
+		};
+
 		gpio1: gpio@4900c000 {
 			compatible = "ti,omap2-gpio";
 			reg = <0x4900c000 0x200>;
@@ -183,6 +196,7 @@
 			ti,dual-volt;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_regulator>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index daabf99..88f0179 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -137,6 +137,19 @@
 			pinctrl-single,function-mask = <0xff1f>;
 		};
 
+		tisyscon: tisyscon@48002520 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x48002520 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap3";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+			};
+		};
+
 		gpio1: gpio@48310000 {
 			compatible = "ti,omap3-gpio";
 			reg = <0x48310000 0x200>;
@@ -351,6 +364,7 @@
 			ti,dual-volt;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_regulator>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index a1e0585..09e8d52 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,19 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		tisyscon: tisyscon@4A100600 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A100600 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap4";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <10>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
@@ -367,6 +380,7 @@
 			ti,needs-special-reset;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_regulator>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index fc3fad5..93edb2e 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,19 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		tisyscon: tisyscon@4A002E00 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A002E00 0x4>;
+				pbias_regulator: pbias_regulator {
+					compatible = "regulator-pbias-omap5";
+					pbias-reg-offset = <0>;
+					regulator-name = "pbias_regulator";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <10>;
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
@@ -409,6 +422,7 @@
 			ti,needs-special-reset;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_regulator>;
 		};
 
 		mmc2: mmc@480b4000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                 ` (4 preceding siblings ...)
  2013-12-10 10:16                               ` [PATCH v4 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-10 10:16                               ` [PATCH v4 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  7 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Enable REGULATOR_PBIAS needed for SD card on most OMAPs.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/configs/omap2plus_defconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index bfa80a1..f67baa9 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -169,6 +169,7 @@ CONFIG_DRA752_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_OMAP_WATCHDOG=y
 CONFIG_TWL4030_WATCHDOG=y
+CONFIG_MFD_SYSCON=y
 CONFIG_MFD_PALMAS=y
 CONFIG_MFD_TPS65217=y
 CONFIG_MFD_TPS65910=y
@@ -180,6 +181,7 @@ CONFIG_REGULATOR_TPS6507X=y
 CONFIG_REGULATOR_TPS65217=y
 CONFIG_REGULATOR_TPS65910=y
 CONFIG_REGULATOR_TWL4030=y
+CONFIG_REGULATOR_PBIAS=y
 CONFIG_FB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_FB_MODE_HELPERS=y
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v4 7/7] mmc: omap_hsmmc: remove pbias workaround
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                 ` (5 preceding siblings ...)
  2013-12-10 10:16                               ` [PATCH v4 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2013-12-10 10:16                               ` Balaji T K
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  7 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 10:16 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

remove pbias workaround

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 0a390f8..0f0aa5d 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -170,7 +170,6 @@ struct omap_hsmmc_host {
 	struct	regulator	*vcc_aux;
 	struct	regulator	*pbias;
 	bool			pbias_enabled;
-	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
 	spinlock_t		irq_lock; /* Prevent races with irq handler */
@@ -267,13 +266,6 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 */
 	if (!host->vcc)
 		return 0;
-	/*
-	 * With DT, never turn OFF the regulator for MMC1. This is because
-	 * the pbias cell programming support is still missing when
-	 * booting with Device tree
-	 */
-	if (host->pbias_disable && !vdd)
-		return 0;
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
@@ -1541,13 +1533,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * of external transceiver; but they all handle 1.8V.
 		 */
 		if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
-			(ios->vdd == DUAL_VOLT_OCR_BIT) &&
-			/*
-			 * With pbias cell programming missing, this
-			 * can't be allowed on MMC1 when booting with device
-			 * tree.
-			 */
-			!host->pbias_disable) {
+			(ios->vdd == DUAL_VOLT_OCR_BIT)) {
 				/*
 				 * The mmc_select_voltage fn of the core does
 				 * not seem to set the power_mode to
@@ -1880,10 +1866,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_context_save(host);
 
-	/* This can be removed once we support PBIAS with DT */
-	if (host->dev->of_node && res->start == 0x4809c000)
-		host->pbias_disable = 1;
-
 	host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
 	/*
 	 * MMC can still work without debounce clock.
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* Re: [PATCH v4 3/7] regulator: add pbias regulator support
  2013-12-10 10:16                               ` [PATCH v4 3/7] regulator: add pbias regulator support Balaji T K
@ 2013-12-10 10:40                                 ` Mark Brown
  2013-12-10 12:22                                   ` Balaji T K
  2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
  0 siblings, 2 replies; 112+ messages in thread
From: Mark Brown @ 2013-12-10 10:40 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

[-- Attachment #1: Type: text/plain, Size: 1508 bytes --]

On Tue, Dec 10, 2013 at 03:46:13PM +0530, Balaji T K wrote:

> +config REGULATOR_PBIAS
> +	tristate "PBIAS OMAP regulator driver"
> +	depends on ARCH_OMAP && MFD_SYSCON

That should be (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON

> +static int pbias_regulator_set_voltage(struct regulator_dev *dev,
> +			int min_uV, int max_uV, unsigned *selector)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
> +	const struct pbias_reg_info *info = data->info;
> +	int ret, vmode;
> +
> +	if (min_uV <= 1800000)
> +		vmode = 0;
> +	else if (min_uV > 1800000)
> +		vmode = info->vmode;
> +
> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
> +						info->vmode, vmode);
> +	data->voltage = min_uV;

This is exactly the same as it was the first time it was posted and is
still buggy.  To repeat the get and set voltage functions should reflect
the actual voltage set in the hardware.

> +static int pbias_regulator_is_enable(struct regulator_dev *rdev)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> +	const struct pbias_reg_info *info = data->info;
> +	int value;
> +
> +	regmap_read(data->syscon, data->pbias_reg, &value);
> +
> +	return value & info->enable_mask;
> +}

If the enable mask really can have multiple bits this won't do the right
thing - it'll return true if any bits are set.  It needs to make sure
all the bits are set.

> +#if CONFIG_OF

Why?

> +	drvdata->desc.n_voltages = 3;

This doesn't match your implementation which can only set two voltages.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-11-21 14:20                             ` [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2013-12-10 11:09                               ` Ulf Hansson
  2013-12-10 11:48                                 ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Ulf Hansson @ 2013-12-10 11:09 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-omap, Benoit Cousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
> handle vcc and vcc_aux independently to reduce indent.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |   54 +++++++++++++++++++----------------------
>  1 files changed, 25 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 1eb4350..342be25 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>          * chips/cards need an interface voltage rail too.
>          */
>         if (power_on) {
> -               ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
> +               if (host->vcc)
> +                       ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>                 /* Enable interface voltage rail, if needed */
>                 if (ret == 0 && host->vcc_aux) {
>                         ret = regulator_enable(host->vcc_aux);
> -                       if (ret < 0)
> +                       if (ret < 0 && host->vcc)
>                                 ret = mmc_regulator_set_ocr(host->mmc,
>                                                         host->vcc, 0);
>                 }
> @@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>                 /* Shut down the rail */
>                 if (host->vcc_aux)
>                         ret = regulator_disable(host->vcc_aux);
> -               if (!ret) {
> +               if (host->vcc) {
>                         /* Then proceed to shut down the local regulator */
>                         ret = mmc_regulator_set_ocr(host->mmc,
>                                                 host->vcc, 0);
> @@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>
>         reg = devm_regulator_get(host->dev, "vmmc");
>         if (IS_ERR(reg)) {
> -               dev_err(host->dev, "vmmc regulator missing\n");
> +               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
> +                       PTR_ERR(reg));
>                 return PTR_ERR(reg);
>         } else {
> -               mmc_slot(host).set_power = omap_hsmmc_set_power;
>                 host->vcc = reg;
>                 ocr_value = mmc_regulator_get_ocrmask(reg);
>                 if (!mmc_slot(host).ocr_mask) {
> @@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>                                 return -EINVAL;
>                         }
>                 }
> +       }
> +       mmc_slot(host).set_power = omap_hsmmc_set_power;
>
> -               /* Allow an aux regulator */
> -               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
> -               host->vcc_aux = IS_ERR(reg) ? NULL : reg;
> +       /* Allow an aux regulator */
> +       reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
> +       host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>
> -               /* For eMMC do not power off when not in sleep state */
> -               if (mmc_slot(host).no_regulator_off_init)
> -                       return 0;
> -               /*
> -               * UGLY HACK:  workaround regulator framework bugs.
> -               * When the bootloader leaves a supply active, it's
> -               * initialized with zero usecount ... and we can't
> -               * disable it without first enabling it.  Until the
> -               * framework is fixed, we need a workaround like this
> -               * (which is safe for MMC, but not in general).
> -               */

The above problem is handled by the mmc core layer. I certainly think
you shall adopt your code to it.

Kind regards
Ulf Hansson

> -               if (regulator_is_enabled(host->vcc) > 0 ||
> -                   (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
> -                       int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
> +       /* For eMMC do not power off when not in sleep state */
> +       if (mmc_slot(host).no_regulator_off_init)
> +               return 0;
> +       /*
> +        * To disable boot_on regulator, enable regulator
> +        * to increase usecount and then disable it.
> +        */
> +       if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
> +           (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
> +               int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>
> -                       mmc_slot(host).set_power(host->dev, host->slot_id,
> -                                                1, vdd);
> -                       mmc_slot(host).set_power(host->dev, host->slot_id,
> -                                                0, 0);
> -               }
> +               mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
> +               mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
>         }
>
>         return 0;
> --
> 1.7.5.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-12-10 11:09                               ` Ulf Hansson
@ 2013-12-10 11:48                                 ` Balaji T K
  2013-12-11 11:21                                   ` Ulf Hansson
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-10 11:48 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-omap, Benoit Cousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On Tuesday 10 December 2013 04:39 PM, Ulf Hansson wrote:
> On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
>> handle vcc and vcc_aux independently to reduce indent.
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   drivers/mmc/host/omap_hsmmc.c |   54 +++++++++++++++++++----------------------
>>   1 files changed, 25 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>> index 1eb4350..342be25 100644
>> --- a/drivers/mmc/host/omap_hsmmc.c
>> +++ b/drivers/mmc/host/omap_hsmmc.c
>> @@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>           * chips/cards need an interface voltage rail too.
>>           */
>>          if (power_on) {
>> -               ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>> +               if (host->vcc)
>> +                       ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>>                  /* Enable interface voltage rail, if needed */
>>                  if (ret == 0 && host->vcc_aux) {
>>                          ret = regulator_enable(host->vcc_aux);
>> -                       if (ret < 0)
>> +                       if (ret < 0 && host->vcc)
>>                                  ret = mmc_regulator_set_ocr(host->mmc,
>>                                                          host->vcc, 0);
>>                  }
>> @@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
>>                  /* Shut down the rail */
>>                  if (host->vcc_aux)
>>                          ret = regulator_disable(host->vcc_aux);
>> -               if (!ret) {
>> +               if (host->vcc) {
>>                          /* Then proceed to shut down the local regulator */
>>                          ret = mmc_regulator_set_ocr(host->mmc,
>>                                                  host->vcc, 0);
>> @@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>
>>          reg = devm_regulator_get(host->dev, "vmmc");
>>          if (IS_ERR(reg)) {
>> -               dev_err(host->dev, "vmmc regulator missing\n");
>> +               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
>> +                       PTR_ERR(reg));
>>                  return PTR_ERR(reg);
>>          } else {
>> -               mmc_slot(host).set_power = omap_hsmmc_set_power;
>>                  host->vcc = reg;
>>                  ocr_value = mmc_regulator_get_ocrmask(reg);
>>                  if (!mmc_slot(host).ocr_mask) {
>> @@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>                                  return -EINVAL;
>>                          }
>>                  }
>> +       }
>> +       mmc_slot(host).set_power = omap_hsmmc_set_power;
>>
>> -               /* Allow an aux regulator */
>> -               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>> -               host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>> +       /* Allow an aux regulator */
>> +       reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>> +       host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>
>> -               /* For eMMC do not power off when not in sleep state */
>> -               if (mmc_slot(host).no_regulator_off_init)
>> -                       return 0;
>> -               /*
>> -               * UGLY HACK:  workaround regulator framework bugs.
>> -               * When the bootloader leaves a supply active, it's
>> -               * initialized with zero usecount ... and we can't
>> -               * disable it without first enabling it.  Until the
>> -               * framework is fixed, we need a workaround like this
>> -               * (which is safe for MMC, but not in general).
>> -               */
>
> The above problem is handled by the mmc core layer. I certainly think
> you shall adopt your code to it.
Hi Ulf,

how about optional vqmmc, omap_hsmmc does call mmc_regulator_set_ocr for vmmc
Am I missing something?

>
> Kind regards
> Ulf Hansson
>
>> -               if (regulator_is_enabled(host->vcc) > 0 ||
>> -                   (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
>> -                       int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>> +       /* For eMMC do not power off when not in sleep state */
>> +       if (mmc_slot(host).no_regulator_off_init)
>> +               return 0;
>> +       /*
>> +        * To disable boot_on regulator, enable regulator
>> +        * to increase usecount and then disable it.
>> +        */
>> +       if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
>> +           (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
>> +               int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>
>> -                       mmc_slot(host).set_power(host->dev, host->slot_id,
>> -                                                1, vdd);
>> -                       mmc_slot(host).set_power(host->dev, host->slot_id,
>> -                                                0, 0);
>> -               }
>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
>>          }
>>
>>          return 0;
>> --
>> 1.7.5.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v4 3/7] regulator: add pbias regulator support
  2013-12-10 10:40                                 ` Mark Brown
@ 2013-12-10 12:22                                   ` Balaji T K
  2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
  1 sibling, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 12:22 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

On Tuesday 10 December 2013 04:10 PM, Mark Brown wrote:
> On Tue, Dec 10, 2013 at 03:46:13PM +0530, Balaji T K wrote:
>
>> +config REGULATOR_PBIAS
>> +	tristate "PBIAS OMAP regulator driver"
>> +	depends on ARCH_OMAP && MFD_SYSCON
>
> That should be (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
>

Ok

>> +static int pbias_regulator_set_voltage(struct regulator_dev *dev,
>> +			int min_uV, int max_uV, unsigned *selector)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
>> +	const struct pbias_reg_info *info = data->info;
>> +	int ret, vmode;
>> +
>> +	if (min_uV <= 1800000)
>> +		vmode = 0;
>> +	else if (min_uV > 1800000)
>> +		vmode = info->vmode;
>> +
>> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
>> +						info->vmode, vmode);
>> +	data->voltage = min_uV;
>
> This is exactly the same as it was the first time it was posted and is
> still buggy.  To repeat the get and set voltage functions should reflect
> the actual voltage set in the hardware.
>

my bad, will fix it.

>> +static int pbias_regulator_is_enable(struct regulator_dev *rdev)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
>> +	const struct pbias_reg_info *info = data->info;
>> +	int value;
>> +
>> +	regmap_read(data->syscon, data->pbias_reg, &value);
>> +
>> +	return value & info->enable_mask;
>> +}
>
> If the enable mask really can have multiple bits this won't do the right
> thing - it'll return true if any bits are set.  It needs to make sure
> all the bits are set.
>

True, will fix it.

>> +#if CONFIG_OF
>
> Why?

Driver is DT only, Will remove it.

>
>> +	drvdata->desc.n_voltages = 3;
>
> This doesn't match your implementation which can only set two voltages.
>

I considered power-off too, will make it 2 then.

Thanks and Regards,
Balaji T K

^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v5 3/7] regulator: add pbias regulator support
  2013-12-10 10:40                                 ` Mark Brown
  2013-12-10 12:22                                   ` Balaji T K
@ 2013-12-10 14:34                                   ` Balaji T K
  2013-12-10 18:33                                     ` Tony Lindgren
  2013-12-11 22:46                                     ` Mark Brown
  1 sibling, 2 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-10 14:34 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

pbias register controls internal power supply to sd card i/o pads
in most OMAPs (OMAP2-5, DRA7).
Control bits for selecting voltage level and
enabling/disabling are in the same PBIAS register.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 Documentation/devicetree/bindings/regulator/pbias-regulator.txt |   21 
 drivers/regulator/Kconfig                                       |    9 
 drivers/regulator/Makefile                                      |    1 
 drivers/regulator/pbias-regulator.c                             |  236 ++++++++++
 4 files changed, 267 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

Index: lo/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ lo/Documentation/devicetree/bindings/regulator/pbias-regulator.txt	2013-12-10 16:58:28.907927745 +0530
@@ -0,0 +1,21 @@
+PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
+
+Required properties:
+- compatible:
+  - "regulator-pbias-omap2" for OMAP2
+  - "regulator-pbias-omap3" for OMAP3
+  - "regulator-pbias-omap4" for OMAP4
+  - "regulator-pbias-omap5" for OMAP5, DRA7
+- pbias-reg-offset: PBIAS control register offset from syscon base address
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+		pbias_regulator: pbias_regulator {
+			pbias-reg-offset = <0>;
+			regulator-name = "pbias_regulator";
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3000000>;
+	};
Index: lo/drivers/regulator/Kconfig
===================================================================
--- lo.orig/drivers/regulator/Kconfig	2013-12-10 16:58:16.411852457 +0530
+++ lo/drivers/regulator/Kconfig	2013-12-10 17:08:29.291513120 +0530
@@ -369,6 +369,15 @@ config REGULATOR_PALMAS
 	  on the muxing. This is handled automatically in the driver by
 	  reading the mux info from OTP.
 
+config REGULATOR_PBIAS
+	tristate "PBIAS OMAP regulator driver"
+	depends on (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
+	help
+	 Say y here to support pbias regulator for mmc1:SD card i/o
+	 on OMAP SoCs.
+	 This driver provides support for OMAP pbias modelled
+	 regulators.
+
 config REGULATOR_PCAP
 	tristate "Motorola PCAP2 regulator driver"
 	depends on EZX_PCAP
Index: lo/drivers/regulator/Makefile
===================================================================
--- lo.orig/drivers/regulator/Makefile	2013-12-10 16:58:16.411852457 +0530
+++ lo/drivers/regulator/Makefile	2013-12-10 16:58:28.915927793 +0530
@@ -52,6 +52,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
 obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
+obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
Index: lo/drivers/regulator/pbias-regulator.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ lo/drivers/regulator/pbias-regulator.c	2013-12-10 17:06:51.046930033 +0530
@@ -0,0 +1,236 @@
+/*
+ * pbias-regulator.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Balaji T K <balajitk@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+struct pbias_reg_info {
+	u32 enable;
+	u32 enable_mask;
+	u32 vmode;
+	char *name;
+};
+
+struct pbias_regulator_data {
+	struct regulator_desc desc;
+	void __iomem *pbias_addr;
+	unsigned int pbias_reg;
+	struct regulator_dev *dev;
+	struct regmap *syscon;
+	const struct pbias_reg_info *info;
+	int voltage;
+};
+
+static int pbias_regulator_set_voltage(struct regulator_dev *dev,
+			int min_uV, int max_uV, unsigned *selector)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
+	const struct pbias_reg_info *info = data->info;
+	int ret, vmode;
+
+	if (min_uV <= 1800000)
+		vmode = 0;
+	else if (min_uV > 1800000)
+		vmode = info->vmode;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->vmode, vmode);
+
+	return ret;
+}
+
+static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int value, voltage;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+	value &= info->vmode;
+
+	voltage = value ? 1800000 : 3000000;
+
+	return voltage;
+}
+
+static int pbias_regulator_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+					info->enable_mask, info->enable);
+
+	return ret;
+}
+
+static int pbias_regulator_disable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->enable_mask, 0);
+	return ret;
+}
+
+static int pbias_regulator_is_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int value;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+
+	return (value & info->enable_mask) == info->enable_mask;
+}
+
+static struct regulator_ops pbias_regulator_voltage_ops = {
+	.set_voltage	= pbias_regulator_set_voltage,
+	.get_voltage	= pbias_regulator_get_voltage,
+	.enable		= pbias_regulator_enable,
+	.disable	= pbias_regulator_disable,
+	.is_enabled	= pbias_regulator_is_enable,
+};
+
+static const struct pbias_reg_info pbias_omap3 = {
+	.enable = BIT(1),
+	.enable_mask = BIT(1),
+	.vmode = BIT(0),
+	.name = "pbias_omap3"
+};
+
+static const struct pbias_reg_info pbias_omap4 = {
+	.enable = BIT(26) | BIT(22),
+	.enable_mask = BIT(26) | BIT(25) | BIT(22),
+	.vmode = BIT(21),
+	.name = "pbias_omap4"
+};
+
+static const struct pbias_reg_info pbias_omap5 = {
+	.enable = BIT(27) | BIT(26),
+	.enable_mask = BIT(27) | BIT(25) | BIT(26),
+	.vmode = BIT(21),
+	.name = "pbias_omap5"
+};
+
+static const struct of_device_id pbias_of_match[] = {
+	{ .compatible = "regulator-pbias-omap3", .data = &pbias_omap3},
+	{ .compatible = "regulator-pbias-omap4", .data = &pbias_omap4},
+	{ .compatible = "regulator-pbias-omap5", .data = &pbias_omap5},
+	{},
+};
+MODULE_DEVICE_TABLE(of, pbias_of_match);
+
+static int pbias_regulator_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *syscon_np;
+	struct pbias_regulator_data *drvdata;
+	const struct of_device_id *id;
+	struct regulator_init_data *initdata;
+	struct regulator_config cfg = { };
+	int ret;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data),
+			       GFP_KERNEL);
+	if (drvdata == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate device data\n");
+		return -ENOMEM;
+	}
+
+	id = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
+	if (!id)
+		return -ENODEV;
+
+	drvdata->info = id->data;
+	if (!drvdata->info)
+		return -ENODEV;
+
+	initdata = of_get_regulator_init_data(&pdev->dev, np);
+	if (!initdata)
+		return -EINVAL;
+
+	ret = of_property_read_u32(np, "pbias-reg-offset",
+				   &drvdata->pbias_reg);
+	if (ret) {
+		dev_err(&pdev->dev, "no pbias-reg-offset property set\n");
+		return ret;
+	}
+
+	syscon_np = of_get_parent(np);
+	if (!syscon_np)
+		return -ENODEV;
+
+	drvdata->syscon = syscon_node_to_regmap(syscon_np);
+	of_node_put(syscon_np);
+	if (IS_ERR(drvdata->syscon))
+		return PTR_ERR(drvdata->syscon);
+
+	drvdata->desc.name = drvdata->info->name;
+	drvdata->desc.owner = THIS_MODULE;
+	drvdata->desc.type = REGULATOR_VOLTAGE;
+	drvdata->desc.ops = &pbias_regulator_voltage_ops;
+	drvdata->desc.n_voltages = 2;
+
+	cfg.dev = &pdev->dev;
+	cfg.init_data = initdata;
+	cfg.driver_data = drvdata;
+	cfg.of_node = np;
+
+	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc,
+									&cfg);
+	if (IS_ERR(drvdata->dev)) {
+		ret = PTR_ERR(drvdata->dev);
+		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
+		goto err_regulator;
+	}
+
+	platform_set_drvdata(pdev, drvdata);
+
+err_regulator:
+	return ret;
+}
+
+static struct platform_driver pbias_regulator_driver = {
+	.probe		= pbias_regulator_probe,
+	.driver		= {
+		.name		= "pbias-regulator",
+		.owner		= THIS_MODULE,
+		.of_match_table = of_match_ptr(pbias_of_match),
+	},
+};
+
+module_platform_driver(pbias_regulator_driver);
+
+MODULE_AUTHOR("Balaji T K <balajitk@ti.com>");
+MODULE_DESCRIPTION("pbias voltage regulator");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pbias-regulator");

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v5 3/7] regulator: add pbias regulator support
  2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
@ 2013-12-10 18:33                                     ` Tony Lindgren
  2013-12-10 22:39                                       ` Tony Lindgren
  2013-12-12 15:12                                       ` Balaji T K
  2013-12-11 22:46                                     ` Mark Brown
  1 sibling, 2 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-12-10 18:33 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131210 06:36]:
> pbias register controls internal power supply to sd card i/o pads
> in most OMAPs (OMAP2-5, DRA7).
> Control bits for selecting voltage level and
> enabling/disabling are in the same PBIAS register.

Good to see this, few comments below.

> +++ lo/Documentation/devicetree/bindings/regulator/pbias-regulator.txt	2013-12-10 16:58:28.907927745 +0530
> @@ -0,0 +1,21 @@
> +PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
> +
> +Required properties:
> +- compatible:
> +  - "regulator-pbias-omap2" for OMAP2
> +  - "regulator-pbias-omap3" for OMAP3
> +  - "regulator-pbias-omap4" for OMAP4
> +  - "regulator-pbias-omap5" for OMAP5, DRA7
> +- pbias-reg-offset: PBIAS control register offset from syscon base address
> +
> +Optional properties:
> +- Any optional property defined in bindings/regulator/regulator.txt
> +
> +Example:
> +
> +		pbias_regulator: pbias_regulator {
> +			pbias-reg-offset = <0>;
> +			regulator-name = "pbias_regulator";
> +			regulator-min-microvolt = <1800000>;
> +			regulator-max-microvolt = <3000000>;
> +	};

This does not seem to support the other PBIAS controls the same
register has?

> @@ -369,6 +369,15 @@ config REGULATOR_PALMAS
>  	  on the muxing. This is handled automatically in the driver by
>  	  reading the mux info from OTP.
>  
> +config REGULATOR_PBIAS
> +	tristate "PBIAS OMAP regulator driver"
> +	depends on (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
> +	help
> +	 Say y here to support pbias regulator for mmc1:SD card i/o
> +	 on OMAP SoCs.
> +	 This driver provides support for OMAP pbias modelled
> +	 regulators.
> +

The PBIAS register is not just for MMC. Depending on the SoC revision,
you may also have 2 - 3 PBIAS devices in the same register. Please check
the 2430 TRM, it has also I2C secondary pulls in this same register. And
on 3430, there PBIAS register has also SIM voltage bits.

Certainly nothing stops from intially implementing the MMC pieces
as those are needed badly, but it should be done in a way where adding
support for the other PBIAS bits can be done easily.

You're also missing the PBIAS interrupts, so it might be worth checking
the code from that point of view also to make sure adding the support
for interrupts won't require massive changes to the driver.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v5 3/7] regulator: add pbias regulator support
  2013-12-10 18:33                                     ` Tony Lindgren
@ 2013-12-10 22:39                                       ` Tony Lindgren
  2013-12-12 15:12                                       ` Balaji T K
  1 sibling, 0 replies; 112+ messages in thread
From: Tony Lindgren @ 2013-12-10 22:39 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Tony Lindgren <tony@atomide.com> [131210 10:34]:
> * Balaji T K <balajitk@ti.com> [131210 06:36]:
> > pbias register controls internal power supply to sd card i/o pads
> > in most OMAPs (OMAP2-5, DRA7).
> > Control bits for selecting voltage level and
> > enabling/disabling are in the same PBIAS register.
> 
> Good to see this, few comments below.
> 
> > +++ lo/Documentation/devicetree/bindings/regulator/pbias-regulator.txt	2013-12-10 16:58:28.907927745 +0530
> > @@ -0,0 +1,21 @@
> > +PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
> > +
> > +Required properties:
> > +- compatible:
> > +  - "regulator-pbias-omap2" for OMAP2
> > +  - "regulator-pbias-omap3" for OMAP3
> > +  - "regulator-pbias-omap4" for OMAP4
> > +  - "regulator-pbias-omap5" for OMAP5, DRA7
> > +- pbias-reg-offset: PBIAS control register offset from syscon base address
> > +
> > +Optional properties:
> > +- Any optional property defined in bindings/regulator/regulator.txt
> > +
> > +Example:
> > +
> > +		pbias_regulator: pbias_regulator {

Hmm one more comment. This should containe the standard property:
			reg = <0x02b0 0x4>;

And the parent SCM driver should claim the whole SCM GENERAL register
area as defined in "Table 13-68. GENERAL Register Summary" for omap3
for example. So that would be the following for the parent:

			reg = <0x48002270 xxx>;

The size needs to be checked and it may need multiple regions or instances
defined. That way we can use the drivers/mfd/syscon.c SCM driver for all
the misc registers without having to redo the bindings.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v4 5/7] ARM: dts: add pbias dt node
  2013-12-10 10:16                               ` [PATCH v4 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2013-12-10 22:42                                 ` Tony Lindgren
  2013-12-12 14:58                                   ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-10 22:42 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131210 02:17]:
> Add pbias regulator node as a child of system control
> module - syscon.
> 
> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  arch/arm/boot/dts/dra7.dtsi     |   14 ++++++++++++++
>  arch/arm/boot/dts/omap2430.dtsi |   14 ++++++++++++++
>  arch/arm/boot/dts/omap3.dtsi    |   14 ++++++++++++++
>  arch/arm/boot/dts/omap4.dtsi    |   14 ++++++++++++++
>  arch/arm/boot/dts/omap5.dtsi    |   14 ++++++++++++++
>  5 files changed, 70 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index d0df4c4..1a52676 100644
> --- a/arch/arm/boot/dts/dra7.dtsi
> +++ b/arch/arm/boot/dts/dra7.dtsi
> @@ -119,6 +119,19 @@
>  			pinctrl-single,function-mask = <0x3fffffff>;
>  		};
>  
> +		tisyscon: tisyscon@4A100600 {
> +			compatible = "ti,control-syscon", "syscon", "simple-bus";
> +			reg = <0x4A002E00 0x4>;

This should map the whole GENERAL area of the SCM register space instead
in one or multiple sections or driver instances. This way the same driver
can be used for the misc SCM registers from other drivers.

If you don't define it that way now, you'll end up with broken child driver
offsets in the .dts files later on.

> +				pbias_regulator: pbias_regulator {
> +					compatible = "regulator-pbias-omap5";
> +					pbias-reg-offset = <0>;
> +					regulator-name = "pbias_regulator";
> +					regulator-min-microvolt = <1800000>;
> +					regulator-max-microvolt = <3000000>;
> +					regulator-enable-ramp-delay = <10>;

Then the pbias_regulator needs to have the standard reg property as an
offset from the SCM GENERAL base address.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-12-10 11:48                                 ` Balaji T K
@ 2013-12-11 11:21                                   ` Ulf Hansson
  2013-12-18 14:52                                     ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Ulf Hansson @ 2013-12-11 11:21 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-omap, Benoit Cousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On 10 December 2013 12:48, Balaji T K <balajitk@ti.com> wrote:
> On Tuesday 10 December 2013 04:39 PM, Ulf Hansson wrote:
>>
>> On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
>>>
>>> handle vcc and vcc_aux independently to reduce indent.
>>>
>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>> ---
>>>   drivers/mmc/host/omap_hsmmc.c |   54
>>> +++++++++++++++++++----------------------
>>>   1 files changed, 25 insertions(+), 29 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/omap_hsmmc.c
>>> b/drivers/mmc/host/omap_hsmmc.c
>>> index 1eb4350..342be25 100644
>>> --- a/drivers/mmc/host/omap_hsmmc.c
>>> +++ b/drivers/mmc/host/omap_hsmmc.c
>>> @@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev,
>>> int slot, int power_on,
>>>           * chips/cards need an interface voltage rail too.
>>>           */
>>>          if (power_on) {
>>> -               ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>>> +               if (host->vcc)
>>> +                       ret = mmc_regulator_set_ocr(host->mmc, host->vcc,
>>> vdd);
>>>                  /* Enable interface voltage rail, if needed */
>>>                  if (ret == 0 && host->vcc_aux) {
>>>                          ret = regulator_enable(host->vcc_aux);
>>> -                       if (ret < 0)
>>> +                       if (ret < 0 && host->vcc)
>>>                                  ret = mmc_regulator_set_ocr(host->mmc,
>>>                                                          host->vcc, 0);
>>>                  }
>>> @@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev,
>>> int slot, int power_on,
>>>                  /* Shut down the rail */
>>>                  if (host->vcc_aux)
>>>                          ret = regulator_disable(host->vcc_aux);
>>> -               if (!ret) {
>>> +               if (host->vcc) {
>>>                          /* Then proceed to shut down the local regulator
>>> */
>>>                          ret = mmc_regulator_set_ocr(host->mmc,
>>>                                                  host->vcc, 0);
>>> @@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct
>>> omap_hsmmc_host *host)
>>>
>>>          reg = devm_regulator_get(host->dev, "vmmc");
>>>          if (IS_ERR(reg)) {
>>> -               dev_err(host->dev, "vmmc regulator missing\n");
>>> +               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
>>> +                       PTR_ERR(reg));
>>>                  return PTR_ERR(reg);
>>>          } else {
>>> -               mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>                  host->vcc = reg;
>>>                  ocr_value = mmc_regulator_get_ocrmask(reg);
>>>                  if (!mmc_slot(host).ocr_mask) {
>>> @@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct
>>> omap_hsmmc_host *host)
>>>                                  return -EINVAL;
>>>                          }
>>>                  }
>>> +       }
>>> +       mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>
>>> -               /* Allow an aux regulator */
>>> -               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>> -               host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>> +       /* Allow an aux regulator */
>>> +       reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>> +       host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>>
>>> -               /* For eMMC do not power off when not in sleep state */
>>> -               if (mmc_slot(host).no_regulator_off_init)
>>> -                       return 0;
>>> -               /*
>>> -               * UGLY HACK:  workaround regulator framework bugs.
>>> -               * When the bootloader leaves a supply active, it's
>>> -               * initialized with zero usecount ... and we can't
>>> -               * disable it without first enabling it.  Until the
>>> -               * framework is fixed, we need a workaround like this
>>> -               * (which is safe for MMC, but not in general).
>>> -               */
>>
>>
>> The above problem is handled by the mmc core layer. I certainly think
>> you shall adopt your code to it.
>
> Hi Ulf,
>
> how about optional vqmmc, omap_hsmmc does call mmc_regulator_set_ocr for
> vmmc
> Am I missing something?

Hi Balaji,

Sorry for being to vague, let me elaborate.

1. Before omap_hsmmc_probe returns, it invokes mmc_add_host().

2. mmc_add_host() -> mmc_start_host() -> > mmc_power_up().

3. mmc_power_up() invokes the host driver's .set_ios() callback, to
makes sure boot-on regulators are kept enabled. Otherwise the
late_initcall, regulator_init_complete() will potentially cut power
for unused regulators.

This is important because there are SoCs that are only capable of
power cycling the VCC regulator but not VCCQ. According to the eMMC
spec, we must not cut VCC without sending the SLEEP cmd first.
Obviously, since we prevent VCC from being cut, we need to prevent
VCCQ from being cut as well.

Normally a .set_ios() function's invokes mmc_regulator_set_ocr() for
the VCC regulator. VCCQ ("vmmc_aux") is handled by directly using the
regulator API (I guess we could invent an API similar to
mmc_regulator_set_ocr() but for VCCQ, but that is a future task).

So, from a host driver perspective you could add a local variable to
cache the "enabled" state of the VCCQ regulator. By leaving the
default state to "disabled", you will trigger it to be enabled once
mmc_power_up() invokes your .set_ios() callback. Vice verse will then
happen when mmc_power_off gets invoked.

Finally, don't forget to enable MMC_CAP2_FULL_PWR_CYCLE, if your SoC
can cut both VCC and VCCQ for your eMMC slots. For SD cards only VCC
should be needed to enable MMC_CAP2_FULL_PWR_CYCLE.

Kind regards
Ulf Hansson


>
>
>>
>> Kind regards
>> Ulf Hansson
>>
>>> -               if (regulator_is_enabled(host->vcc) > 0 ||
>>> -                   (host->vcc_aux &&
>>> regulator_is_enabled(host->vcc_aux))) {
>>> -                       int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>> +       /* For eMMC do not power off when not in sleep state */
>>> +       if (mmc_slot(host).no_regulator_off_init)
>>> +               return 0;
>>> +       /*
>>> +        * To disable boot_on regulator, enable regulator
>>> +        * to increase usecount and then disable it.
>>> +        */
>>> +       if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
>>> +           (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
>>> +               int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>>
>>> -                       mmc_slot(host).set_power(host->dev,
>>> host->slot_id,
>>> -                                                1, vdd);
>>> -                       mmc_slot(host).set_power(host->dev,
>>> host->slot_id,
>>> -                                                0, 0);
>>> -               }
>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 1,
>>> vdd);
>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
>>>          }
>>>
>>>          return 0;
>>> --
>>> 1.7.5.4
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v5 3/7] regulator: add pbias regulator support
  2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
  2013-12-10 18:33                                     ` Tony Lindgren
@ 2013-12-11 22:46                                     ` Mark Brown
  1 sibling, 0 replies; 112+ messages in thread
From: Mark Brown @ 2013-12-11 22:46 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, tony

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

On Tue, Dec 10, 2013 at 08:04:58PM +0530, Balaji T K wrote:
> pbias register controls internal power supply to sd card i/o pads
> in most OMAPs (OMAP2-5, DRA7).
> Control bits for selecting voltage level and
> enabling/disabling are in the same PBIAS register.

This looks OK from a regulator API point of view but I expect a new
version is required to address Tony's concerns.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v4 5/7] ARM: dts: add pbias dt node
  2013-12-10 22:42                                 ` Tony Lindgren
@ 2013-12-12 14:58                                   ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-12 14:58 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Wednesday 11 December 2013 04:12 AM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131210 02:17]:
>> Add pbias regulator node as a child of system control
>> module - syscon.
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> ---
>>   arch/arm/boot/dts/dra7.dtsi     |   14 ++++++++++++++
>>   arch/arm/boot/dts/omap2430.dtsi |   14 ++++++++++++++
>>   arch/arm/boot/dts/omap3.dtsi    |   14 ++++++++++++++
>>   arch/arm/boot/dts/omap4.dtsi    |   14 ++++++++++++++
>>   arch/arm/boot/dts/omap5.dtsi    |   14 ++++++++++++++
>>   5 files changed, 70 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
>> index d0df4c4..1a52676 100644
>> --- a/arch/arm/boot/dts/dra7.dtsi
>> +++ b/arch/arm/boot/dts/dra7.dtsi
>> @@ -119,6 +119,19 @@
>>   			pinctrl-single,function-mask = <0x3fffffff>;
>>   		};
>>
>> +		tisyscon: tisyscon@4A100600 {
>> +			compatible = "ti,control-syscon", "syscon", "simple-bus";
>> +			reg = <0x4A002E00 0x4>;
>
> This should map the whole GENERAL area of the SCM register space instead
> in one or multiple sections or driver instances. This way the same driver
> can be used for the misc SCM registers from other drivers.
>
Hi,

OK, make sense, others driver wont have to patch the base address later on.

> If you don't define it that way now, you'll end up with broken child driver
> offsets in the .dts files later on.

yes, Unless someone changes the base and not the offset, given that all are in one dtsi

>
>> +				pbias_regulator: pbias_regulator {
>> +					compatible = "regulator-pbias-omap5";
>> +					pbias-reg-offset = <0>;
>> +					regulator-name = "pbias_regulator";
>> +					regulator-min-microvolt = <1800000>;
>> +					regulator-max-microvolt = <3000000>;
>> +					regulator-enable-ramp-delay = <10>;
>
> Then the pbias_regulator needs to have the standard reg property as an
> offset from the SCM GENERAL base address.

OK


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v5 3/7] regulator: add pbias regulator support
  2013-12-10 18:33                                     ` Tony Lindgren
  2013-12-10 22:39                                       ` Tony Lindgren
@ 2013-12-12 15:12                                       ` Balaji T K
  1 sibling, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-12 15:12 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Wednesday 11 December 2013 12:03 AM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131210 06:36]:
>> pbias register controls internal power supply to sd card i/o pads
>> in most OMAPs (OMAP2-5, DRA7).
>> Control bits for selecting voltage level and
>> enabling/disabling are in the same PBIAS register.
>
> Good to see this, few comments below.
>
>> +++ lo/Documentation/devicetree/bindings/regulator/pbias-regulator.txt	2013-12-10 16:58:28.907927745 +0530
>> @@ -0,0 +1,21 @@
>> +PBIAS internal regulator for SD card i/o pads on OMAP SoCs.
>> +
>> +Required properties:
>> +- compatible:
>> +  - "regulator-pbias-omap2" for OMAP2
>> +  - "regulator-pbias-omap3" for OMAP3
>> +  - "regulator-pbias-omap4" for OMAP4
>> +  - "regulator-pbias-omap5" for OMAP5, DRA7
>> +- pbias-reg-offset: PBIAS control register offset from syscon base address
>> +
>> +Optional properties:
>> +- Any optional property defined in bindings/regulator/regulator.txt
>> +
>> +Example:
>> +
>> +		pbias_regulator: pbias_regulator {
>> +			pbias-reg-offset = <0>;
>> +			regulator-name = "pbias_regulator";
>> +			regulator-min-microvolt = <1800000>;
>> +			regulator-max-microvolt = <3000000>;
>> +	};
>
> This does not seem to support the other PBIAS controls the same
> register has?
>
Hi Tony,
Thanks for the comments,

>> @@ -369,6 +369,15 @@ config REGULATOR_PALMAS
>>   	  on the muxing. This is handled automatically in the driver by
>>   	  reading the mux info from OTP.
>>
>> +config REGULATOR_PBIAS
>> +	tristate "PBIAS OMAP regulator driver"
>> +	depends on (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
>> +	help
>> +	 Say y here to support pbias regulator for mmc1:SD card i/o
>> +	 on OMAP SoCs.
>> +	 This driver provides support for OMAP pbias modelled
>> +	 regulators.
>> +
>
> The PBIAS register is not just for MMC. Depending on the SoC revision,

yes, SIM pbias bit mapping are similar to MMC.
I will try to add sim pbias to my next version.

> you may also have 2 - 3 PBIAS devices in the same register. Please check
> the 2430 TRM, it has also I2C secondary pulls in this same register. And

This regulator driver will only control bits related to voltage settings
and is not touching other bits by using masks.

> on 3430, there PBIAS register has also SIM voltage bits.
>
> Certainly nothing stops from intially implementing the MMC pieces
> as those are needed badly, but it should be done in a way where adding
> support for the other PBIAS bits can be done easily.
>

yes, It can be easily done for SIM pbias control.

> You're also missing the PBIAS interrupts, so it might be worth checking
> the code from that point of view also to make sure adding the support
> for interrupts won't require massive changes to the driver.
>

PBIAS interrupts were never used in non-dt case, so did not consider
while adapting for DT. However it can be added later on.

Thanks and Regards,
Balaji T K

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-12-11 11:21                                   ` Ulf Hansson
@ 2013-12-18 14:52                                     ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-18 14:52 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-omap, Benoit Cousson, devicetree, linux-mmc, Chris Ball,
	Mark Brown, Tony Lindgren

On Wednesday 11 December 2013 04:51 PM, Ulf Hansson wrote:
> On 10 December 2013 12:48, Balaji T K <balajitk@ti.com> wrote:
>> On Tuesday 10 December 2013 04:39 PM, Ulf Hansson wrote:
>>>
>>> On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
>>>>
>>>> handle vcc and vcc_aux independently to reduce indent.
>>>>
>>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>>> ---
>>>>    drivers/mmc/host/omap_hsmmc.c |   54
>>>> +++++++++++++++++++----------------------
>>>>    1 files changed, 25 insertions(+), 29 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/host/omap_hsmmc.c
>>>> b/drivers/mmc/host/omap_hsmmc.c
>>>> index 1eb4350..342be25 100644
>>>> --- a/drivers/mmc/host/omap_hsmmc.c
>>>> +++ b/drivers/mmc/host/omap_hsmmc.c
>>>> @@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev,
>>>> int slot, int power_on,
>>>>            * chips/cards need an interface voltage rail too.
>>>>            */
>>>>           if (power_on) {
>>>> -               ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>>>> +               if (host->vcc)
>>>> +                       ret = mmc_regulator_set_ocr(host->mmc, host->vcc,
>>>> vdd);
>>>>                   /* Enable interface voltage rail, if needed */
>>>>                   if (ret == 0 && host->vcc_aux) {
>>>>                           ret = regulator_enable(host->vcc_aux);
>>>> -                       if (ret < 0)
>>>> +                       if (ret < 0 && host->vcc)
>>>>                                   ret = mmc_regulator_set_ocr(host->mmc,
>>>>                                                           host->vcc, 0);
>>>>                   }
>>>> @@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev,
>>>> int slot, int power_on,
>>>>                   /* Shut down the rail */
>>>>                   if (host->vcc_aux)
>>>>                           ret = regulator_disable(host->vcc_aux);
>>>> -               if (!ret) {
>>>> +               if (host->vcc) {
>>>>                           /* Then proceed to shut down the local regulator
>>>> */
>>>>                           ret = mmc_regulator_set_ocr(host->mmc,
>>>>                                                   host->vcc, 0);
>>>> @@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct
>>>> omap_hsmmc_host *host)
>>>>
>>>>           reg = devm_regulator_get(host->dev, "vmmc");
>>>>           if (IS_ERR(reg)) {
>>>> -               dev_err(host->dev, "vmmc regulator missing\n");
>>>> +               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
>>>> +                       PTR_ERR(reg));
>>>>                   return PTR_ERR(reg);
>>>>           } else {
>>>> -               mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>>                   host->vcc = reg;
>>>>                   ocr_value = mmc_regulator_get_ocrmask(reg);
>>>>                   if (!mmc_slot(host).ocr_mask) {
>>>> @@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct
>>>> omap_hsmmc_host *host)
>>>>                                   return -EINVAL;
>>>>                           }
>>>>                   }
>>>> +       }
>>>> +       mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>>
>>>> -               /* Allow an aux regulator */
>>>> -               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>>> -               host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>>> +       /* Allow an aux regulator */
>>>> +       reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>>> +       host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>>>
>>>> -               /* For eMMC do not power off when not in sleep state */
>>>> -               if (mmc_slot(host).no_regulator_off_init)
>>>> -                       return 0;
>>>> -               /*
>>>> -               * UGLY HACK:  workaround regulator framework bugs.
>>>> -               * When the bootloader leaves a supply active, it's
>>>> -               * initialized with zero usecount ... and we can't
>>>> -               * disable it without first enabling it.  Until the
>>>> -               * framework is fixed, we need a workaround like this
>>>> -               * (which is safe for MMC, but not in general).
>>>> -               */
>>>
>>>
>>> The above problem is handled by the mmc core layer. I certainly think
>>> you shall adopt your code to it.
>>
>> Hi Ulf,
>>
>> how about optional vqmmc, omap_hsmmc does call mmc_regulator_set_ocr for
>> vmmc
>> Am I missing something?
>
> Hi Balaji,
>
> Sorry for being to vague, let me elaborate.
>
> 1. Before omap_hsmmc_probe returns, it invokes mmc_add_host().
>
> 2. mmc_add_host() -> mmc_start_host() -> > mmc_power_up().
>
> 3. mmc_power_up() invokes the host driver's .set_ios() callback, to
> makes sure boot-on regulators are kept enabled. Otherwise the
> late_initcall, regulator_init_complete() will potentially cut power
> for unused regulators.
>
> This is important because there are SoCs that are only capable of
> power cycling the VCC regulator but not VCCQ. According to the eMMC
> spec, we must not cut VCC without sending the SLEEP cmd first.
> Obviously, since we prevent VCC from being cut, we need to prevent
> VCCQ from being cut as well.
>
> Normally a .set_ios() function's invokes mmc_regulator_set_ocr() for
> the VCC regulator. VCCQ ("vmmc_aux") is handled by directly using the
> regulator API (I guess we could invent an API similar to
> mmc_regulator_set_ocr() but for VCCQ, but that is a future task).
>
> So, from a host driver perspective you could add a local variable to
> cache the "enabled" state of the VCCQ regulator. By leaving the
> default state to "disabled", you will trigger it to be enabled once
> mmc_power_up() invokes your .set_ios() callback. Vice verse will then
> happen when mmc_power_off gets invoked.
>
> Finally, don't forget to enable MMC_CAP2_FULL_PWR_CYCLE, if your SoC
> can cut both VCC and VCCQ for your eMMC slots. For SD cards only VCC
> should be needed to enable MMC_CAP2_FULL_PWR_CYCLE.
>

Hi Ulf,

Thanks for the explanation. I need to check if the Work around (power ON
and then power OFF) are there for legacy reason or needed for TI SDIO
detection on soft reset, if it is latter need to figure out a way to
fix TI SDIO before removing it.

> Kind regards
> Ulf Hansson
>
>
>>
>>
>>>
>>> Kind regards
>>> Ulf Hansson
>>>
>>>> -               if (regulator_is_enabled(host->vcc) > 0 ||
>>>> -                   (host->vcc_aux &&
>>>> regulator_is_enabled(host->vcc_aux))) {
>>>> -                       int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>>> +       /* For eMMC do not power off when not in sleep state */
>>>> +       if (mmc_slot(host).no_regulator_off_init)
>>>> +               return 0;
>>>> +       /*
>>>> +        * To disable boot_on regulator, enable regulator
>>>> +        * to increase usecount and then disable it.
>>>> +        */
>>>> +       if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
>>>> +           (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
>>>> +               int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>>>
>>>> -                       mmc_slot(host).set_power(host->dev,
>>>> host->slot_id,
>>>> -                                                1, vdd);
>>>> -                       mmc_slot(host).set_power(host->dev,
>>>> host->slot_id,
>>>> -                                                0, 0);
>>>> -               }
>>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 1,
>>>> vdd);
>>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
>>>>           }
>>>>
>>>>           return 0;
>>>> --
>>>> 1.7.5.4
>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup
  2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                 ` (6 preceding siblings ...)
  2013-12-10 10:16                               ` [PATCH v4 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
@ 2013-12-19 12:38                               ` Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
                                                   ` (6 more replies)
  7 siblings, 7 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Few cleanups to reduce code indent,
Add pbias_regulator support and adapt omap_hsmmc to use pbias regulator
to configure required voltage on mmc1 pad(SD card) i/o rails on OMAP SoCs.

Balaji T K (7):
  mmc: omap_hsmmc: use devm_regulator API
  mmc: omap_hsmmc: handle vcc and vcc_aux independently
  regulator: add pbias regulator support
  mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  ARM: dts: add pbias dt node
  ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  mmc: omap_hsmmc: remove pbias workaround

 .../bindings/regulator/pbias-regulator.txt         |   17 ++
 arch/arm/boot/dts/dra7.dtsi                        |   19 ++
 arch/arm/boot/dts/omap2430.dtsi                    |   19 ++
 arch/arm/boot/dts/omap3.dtsi                       |   19 ++
 arch/arm/boot/dts/omap4.dtsi                       |   19 ++
 arch/arm/boot/dts/omap5.dtsi                       |   19 ++
 arch/arm/configs/omap2plus_defconfig               |    2 +
 drivers/mmc/host/omap_hsmmc.c                      |  113 +++++----
 drivers/regulator/Kconfig                          |    9 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  255 ++++++++++++++++++++
 11 files changed, 443 insertions(+), 49 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 112+ messages in thread

* [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
                                                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Use devm_regulator API, while at it use
devm_regulator_get_optional for optional vmmc_aux supply

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index dbd32ad..1eb4350 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -316,7 +316,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	struct regulator *reg;
 	int ocr_value = 0;
 
-	reg = regulator_get(host->dev, "vmmc");
+	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
 		dev_err(host->dev, "vmmc regulator missing\n");
 		return PTR_ERR(reg);
@@ -336,7 +336,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 		}
 
 		/* Allow an aux regulator */
-		reg = regulator_get(host->dev, "vmmc_aux");
+		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
 		/* For eMMC do not power off when not in sleep state */
@@ -366,8 +366,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
 {
-	regulator_put(host->vcc);
-	regulator_put(host->vcc_aux);
 	mmc_slot(host).set_power = NULL;
 }
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 3/7] regulator: add pbias regulator support Balaji T K
                                                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

handle vcc and vcc_aux independently to reduce indent.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   54 +++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1eb4350..342be25 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 * chips/cards need an interface voltage rail too.
 	 */
 	if (power_on) {
-		ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		if (host->vcc)
+			ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
 		/* Enable interface voltage rail, if needed */
 		if (ret == 0 && host->vcc_aux) {
 			ret = regulator_enable(host->vcc_aux);
-			if (ret < 0)
+			if (ret < 0 && host->vcc)
 				ret = mmc_regulator_set_ocr(host->mmc,
 							host->vcc, 0);
 		}
@@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		/* Shut down the rail */
 		if (host->vcc_aux)
 			ret = regulator_disable(host->vcc_aux);
-		if (!ret) {
+		if (host->vcc) {
 			/* Then proceed to shut down the local regulator */
 			ret = mmc_regulator_set_ocr(host->mmc,
 						host->vcc, 0);
@@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 
 	reg = devm_regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
-		dev_err(host->dev, "vmmc regulator missing\n");
+		dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+			PTR_ERR(reg));
 		return PTR_ERR(reg);
 	} else {
-		mmc_slot(host).set_power = omap_hsmmc_set_power;
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {
@@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 				return -EINVAL;
 			}
 		}
+	}
+	mmc_slot(host).set_power = omap_hsmmc_set_power;
 
-		/* Allow an aux regulator */
-		reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
-		host->vcc_aux = IS_ERR(reg) ? NULL : reg;
+	/* Allow an aux regulator */
+	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
+	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
-		/* For eMMC do not power off when not in sleep state */
-		if (mmc_slot(host).no_regulator_off_init)
-			return 0;
-		/*
-		* UGLY HACK:  workaround regulator framework bugs.
-		* When the bootloader leaves a supply active, it's
-		* initialized with zero usecount ... and we can't
-		* disable it without first enabling it.  Until the
-		* framework is fixed, we need a workaround like this
-		* (which is safe for MMC, but not in general).
-		*/
-		if (regulator_is_enabled(host->vcc) > 0 ||
-		    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
-			int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
+	/* For eMMC do not power off when not in sleep state */
+	if (mmc_slot(host).no_regulator_off_init)
+		return 0;
+	/*
+	 * To disable boot_on regulator, enable regulator
+	 * to increase usecount and then disable it.
+	 */
+	if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
+	    (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
+		int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
 
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 1, vdd);
-			mmc_slot(host).set_power(host->dev, host->slot_id,
-						 0, 0);
-		}
+		mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
+		mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
 	}
 
 	return 0;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
       [not found]                                   ` <1387456720-7202-4-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
  2013-12-19 16:33                                   ` Tony Lindgren
  2013-12-19 12:38                                 ` [PATCH v6 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
                                                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

pbias register controls internal power supply to sd card i/o pads
in most OMAPs (OMAP2-5, DRA7).
Control bits for selecting voltage level and
enabling/disabling are in the same PBIAS register.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
Add support for sim pbias and get pbias register offset via
standard reg property

 .../bindings/regulator/pbias-regulator.txt         |   17 ++
 drivers/regulator/Kconfig                          |    9 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/pbias-regulator.c                |  255 ++++++++++++++++++++
 4 files changed, 282 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
 create mode 100644 drivers/regulator/pbias-regulator.c

diff --git a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
new file mode 100644
index 0000000..64352c1
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,17 @@
+PBIAS internal regulator for SD card dual voltage i/o pads on OMAP SoCs.
+
+Required properties:
+- compatible:
+  - "ti,pbias-omap" for OMAP2, OMAP3, OMAP4, OMAP5, DRA7
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+		pbias_regulator: pbias_regulator {
+			regulator-name = "pbias_mmc_omap4";
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3000000>;
+			regulator-enable-ramp-delay = <100>;
+	};
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..741e8fb 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -369,6 +369,15 @@ config REGULATOR_PALMAS
 	  on the muxing. This is handled automatically in the driver by
 	  reading the mux info from OTP.
 
+config REGULATOR_PBIAS
+	tristate "PBIAS OMAP regulator driver"
+	depends on (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
+	help
+	 Say y here to support pbias regulator for mmc1:SD card i/o
+	 on OMAP SoCs.
+	 This driver provides support for OMAP pbias modelled
+	 regulators.
+
 config REGULATOR_PCAP
 	tristate "Motorola PCAP2 regulator driver"
 	depends on EZX_PCAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..16000fa 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
 obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
+obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
new file mode 100644
index 0000000..42883a0
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,255 @@
+/*
+ * pbias-regulator.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Balaji T K <balajitk@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+struct pbias_reg_info {
+	u32 enable;
+	u32 enable_mask;
+	u32 vmode;
+	char *name;
+};
+
+struct pbias_regulator_data {
+	struct regulator_desc desc;
+	void __iomem *pbias_addr;
+	unsigned int pbias_reg;
+	struct regulator_dev *dev;
+	struct regmap *syscon;
+	const struct pbias_reg_info *info;
+	int voltage;
+};
+
+static int pbias_regulator_set_voltage(struct regulator_dev *dev,
+			int min_uV, int max_uV, unsigned *selector)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
+	const struct pbias_reg_info *info = data->info;
+	int ret, vmode;
+
+	if (min_uV <= 1800000)
+		vmode = 0;
+	else if (min_uV > 1800000)
+		vmode = info->vmode;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->vmode, vmode);
+
+	return ret;
+}
+
+static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int value, voltage;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+	value &= info->vmode;
+
+	voltage = value ? 3000000 : 1800000;
+
+	return voltage;
+}
+
+static int pbias_regulator_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+					info->enable_mask, info->enable);
+
+	return ret;
+}
+
+static int pbias_regulator_disable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int ret;
+
+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
+						info->enable_mask, 0);
+	return ret;
+}
+
+static int pbias_regulator_is_enable(struct regulator_dev *rdev)
+{
+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
+	const struct pbias_reg_info *info = data->info;
+	int value;
+
+	regmap_read(data->syscon, data->pbias_reg, &value);
+
+	return (value & info->enable_mask) == info->enable_mask;
+}
+
+static struct regulator_ops pbias_regulator_voltage_ops = {
+	.set_voltage	= pbias_regulator_set_voltage,
+	.get_voltage	= pbias_regulator_get_voltage,
+	.enable		= pbias_regulator_enable,
+	.disable	= pbias_regulator_disable,
+	.is_enabled	= pbias_regulator_is_enable,
+};
+
+static const struct pbias_reg_info pbias_mmc_omap3 = {
+	.enable = BIT(1),
+	.enable_mask = BIT(1),
+	.vmode = BIT(0),
+	.name = "pbias_mmc_omap3"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+	.enable = BIT(9),
+	.enable_mask = BIT(9),
+	.vmode = BIT(8),
+	.name = "pbias_sim_omap3"
+};
+
+static const struct pbias_reg_info pbias_mmc_omap4 = {
+	.enable = BIT(26) | BIT(22),
+	.enable_mask = BIT(26) | BIT(25) | BIT(22),
+	.vmode = BIT(21),
+	.name = "pbias_mmc_omap4"
+};
+
+static const struct pbias_reg_info pbias_mmc_omap5 = {
+	.enable = BIT(27) | BIT(26),
+	.enable_mask = BIT(27) | BIT(25) | BIT(26),
+	.vmode = BIT(21),
+	.name = "pbias_mmc_omap5"
+};
+
+static struct of_regulator_match pbias_matches[] = {
+	{ .name = "pbias_mmc_omap3", .driver_data = (void *)&pbias_mmc_omap3},
+	{ .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
+	{ .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
+	{ .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
+};
+#define PBIAS_NUM_REGS	ARRAY_SIZE(pbias_matches)
+
+static const struct of_device_id pbias_of_match[] = {
+	{ .compatible = "ti,pbias-omap", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, pbias_of_match);
+
+static int pbias_regulator_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *dev_node;
+	struct pbias_regulator_data *drvdata;
+	struct resource *res;
+	struct regulator_config cfg = { };
+	struct regmap *syscon;
+	const struct pbias_reg_info *info;
+	int ret = 0;
+	int count, idx, data_idx = 0;
+
+	count = of_regulator_match(&pdev->dev, np, pbias_matches,
+						PBIAS_NUM_REGS);
+	if (count < 0)
+		return count;
+
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data)
+			       * count, GFP_KERNEL);
+	if (drvdata == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate device data\n");
+		return -ENOMEM;
+	}
+
+	dev_node = of_get_parent(np);
+	if (!dev_node)
+		return -ENODEV;
+
+	syscon = syscon_node_to_regmap(dev_node);
+	of_node_put(dev_node);
+	if (IS_ERR(syscon))
+		return PTR_ERR(syscon);
+
+	cfg.dev = &pdev->dev;
+
+	for (idx = 0; idx < PBIAS_NUM_REGS, data_idx < count; idx++) {
+		if (!pbias_matches[idx].init_data ||
+			!pbias_matches[idx].of_node)
+			continue;
+
+		info = pbias_matches[idx].driver_data;
+		if (!info)
+			return -ENODEV;
+
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res)
+			return -EINVAL;
+
+		drvdata[data_idx].pbias_reg = res->start;
+		drvdata[data_idx].syscon = syscon;
+		drvdata[data_idx].info = info;
+		drvdata[data_idx].desc.name = info->name;
+		drvdata[data_idx].desc.owner = THIS_MODULE;
+		drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
+		drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
+		drvdata[data_idx].desc.n_voltages = 2;
+
+		cfg.init_data = pbias_matches[idx].init_data;
+		cfg.driver_data = &drvdata[data_idx];
+		cfg.of_node = pbias_matches[idx].of_node;
+
+		drvdata[data_idx].dev = devm_regulator_register(&pdev->dev,
+					&drvdata[data_idx].desc, &cfg);
+		if (IS_ERR(drvdata[data_idx].dev)) {
+			ret = PTR_ERR(drvdata[data_idx].dev);
+			dev_err(&pdev->dev,
+				"Failed to register regulator: %d\n", ret);
+			goto err_regulator;
+		}
+		data_idx++;
+	}
+
+	platform_set_drvdata(pdev, drvdata);
+
+err_regulator:
+	return ret;
+}
+
+static struct platform_driver pbias_regulator_driver = {
+	.probe		= pbias_regulator_probe,
+	.driver		= {
+		.name		= "pbias-regulator",
+		.owner		= THIS_MODULE,
+		.of_match_table = of_match_ptr(pbias_of_match),
+	},
+};
+
+module_platform_driver(pbias_regulator_driver);
+
+MODULE_AUTHOR("Balaji T K <balajitk@ti.com>");
+MODULE_DESCRIPTION("pbias voltage regulator");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pbias-regulator");
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                   ` (2 preceding siblings ...)
  2013-12-19 12:38                                 ` [PATCH v6 3/7] regulator: add pbias regulator support Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 5/7] ARM: dts: add pbias dt node Balaji T K
                                                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

In DT case, PBAIS registers are programmed via regulator,
use regulator APIs to control PBIAS.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..0a390f8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -126,6 +126,10 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define VDD_1V8			1800000		/* 180000 uV */
+#define VDD_3V0			3000000		/* 300000 uV */
+#define VDD_165_195		(ffs(MMC_VDD_165_195) - 1)
+
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -164,6 +168,8 @@ struct omap_hsmmc_host {
 	 */
 	struct	regulator	*vcc;
 	struct	regulator	*vcc_aux;
+	struct	regulator	*pbias;
+	bool			pbias_enabled;
 	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
@@ -272,6 +278,15 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
 
+	if (host->pbias) {
+		if (host->pbias_enabled == 1) {
+			ret = regulator_disable(host->pbias);
+			if (!ret)
+				host->pbias_enabled = 0;
+		}
+		regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
+	}
+
 	/*
 	 * Assume Vcc regulator is used only to power the card ... OMAP
 	 * VDDS is used to power the pins, optionally with a transceiver to
@@ -306,9 +321,29 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 		}
 	}
 
+	if (host->pbias) {
+		if (vdd <= VDD_165_195)
+			ret = regulator_set_voltage(host->pbias, VDD_1V8,
+								VDD_1V8);
+		else
+			ret = regulator_set_voltage(host->pbias, VDD_3V0,
+								VDD_3V0);
+		if (ret < 0)
+			goto error_set_power;
+
+		if (host->pbias_enabled == 0) {
+			ret = regulator_enable(host->pbias);
+			if (!ret) {
+				host->pbias_enabled = 1;
+				goto error_set_power;
+			}
+		}
+	}
+
 	if (mmc_slot(host).after_set_reg)
 		mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
 
+error_set_power:
 	return ret;
 }
 
@@ -342,6 +377,9 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
 	host->vcc_aux = IS_ERR(reg) ? NULL : reg;
 
+	reg = devm_regulator_get_optional(host->dev, "pbias");
+	host->pbias = IS_ERR(reg) ? NULL : reg;
+
 	/* For eMMC do not power off when not in sleep state */
 	if (mmc_slot(host).no_regulator_off_init)
 		return 0;
@@ -1808,6 +1846,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
+	host->pbias_enabled = 0;
 
 	platform_set_drvdata(pdev, host);
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 5/7] ARM: dts: add pbias dt node
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                   ` (3 preceding siblings ...)
  2013-12-19 12:38                                 ` [PATCH v6 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  2013-12-19 16:33                                   ` Tony Lindgren
  2013-12-19 12:38                                 ` [PATCH v6 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
  6 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Add pbias regulator node as a child of system control
module - syscon.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
Added control module region which has pbias register.
remaining control module region for syscon can be added later when needed.

 arch/arm/boot/dts/dra7.dtsi     |   19 +++++++++++++++++++
 arch/arm/boot/dts/omap2430.dtsi |   19 +++++++++++++++++++
 arch/arm/boot/dts/omap3.dtsi    |   19 +++++++++++++++++++
 arch/arm/boot/dts/omap4.dtsi    |   19 +++++++++++++++++++
 arch/arm/boot/dts/omap5.dtsi    |   19 +++++++++++++++++++
 5 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..a599cae 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -110,6 +110,24 @@
 			ti,hwmods = "counter_32k";
 		};
 
+		dra7_ctrl_general: tisyscon@4a002e00 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4a002e00 0x7c>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			pbias_regulator: pbias_regulator {
+				compatible = "ti,pbias-omap";
+				reg = <0 0x4>;
+				pbias_mmc_reg: pbias_mmc_omap5 {
+					regulator-name = "pbias_mmc_omap5";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+				};
+			};
+		};
+
 		dra7_pmx_core: pinmux@4a003400 {
 			compatible = "pinctrl-single";
 			reg = <0x4a003400 0x0464>;
@@ -485,6 +503,7 @@
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
 			status = "disabled";
+			pbias-supply = <&pbias_mmc_reg>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index d624345..f127901 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,24 @@
 			pinctrl-single,function-mask = <0x3f>;
 		};
 
+		omap2_scm_general: tisyscon@49002270 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x49002270 0x240>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			pbias_regulator: pbias_regulator {
+				compatible = "ti,pbias-omap";
+				reg = <0x230 0x4>;
+				pbias_mmc_reg: pbias_mmc_omap3 {
+					regulator-name = "pbias_mmc_omap3";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+				};
+			};
+		};
+
 		gpio1: gpio@4900c000 {
 			compatible = "ti,omap2-gpio";
 			reg = <0x4900c000 0x200>;
@@ -183,6 +201,7 @@
 			ti,dual-volt;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_mmc_reg>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index daabf99..380a4c4 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -137,6 +137,24 @@
 			pinctrl-single,function-mask = <0xff1f>;
 		};
 
+		omap3_scm_general: tisyscon@48002270 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x48002270 0x2f0>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			pbias_regulator: pbias_regulator {
+				compatible = "ti,pbias-omap";
+				reg = <0x2b0 0x4>;
+				pbias_mmc_reg: pbias_mmc_omap3 {
+					regulator-name = "pbias_mmc_omap3";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+				};
+			};
+		};
+
 		gpio1: gpio@48310000 {
 			compatible = "ti,omap3-gpio";
 			reg = <0x48310000 0x200>;
@@ -351,6 +369,7 @@
 			ti,dual-volt;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_mmc_reg>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index a1e0585..938b596 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,24 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		omap4_padconf_global: tisyscon@4a1005a0 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4a1005a0 0x170>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			pbias_regulator: pbias_regulator {
+				compatible = "ti,pbias-omap";
+				reg = <0x60 0x4>;
+				pbias_mmc_reg: pbias_mmc_omap4 {
+					regulator-name = "pbias_mmc_omap4";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <10>;
+				};
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
@@ -367,6 +385,7 @@
 			ti,needs-special-reset;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_mmc_reg>;
 		};
 
 		mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index fc3fad5..2df4862 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,24 @@
 			pinctrl-single,function-mask = <0x7fff>;
 		};
 
+		omap5_padconf_global: tisyscon@4a002da0 {
+			compatible = "ti,control-syscon", "syscon", "simple-bus";
+			reg = <0x4A002da0 0xec>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges;
+			pbias_regulator: pbias_regulator {
+				compatible = "ti,pbias-omap";
+				reg = <0x60 0x4>;
+				pbias_mmc_reg: pbias_mmc_omap5 {
+					regulator-name = "pbias_mmc_omap5";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-enable-ramp-delay = <100>;
+				};
+			};
+		};
+
 		sdma: dma-controller@4a056000 {
 			compatible = "ti,omap4430-sdma";
 			reg = <0x4a056000 0x1000>;
@@ -409,6 +427,7 @@
 			ti,needs-special-reset;
 			dmas = <&sdma 61>, <&sdma 62>;
 			dma-names = "tx", "rx";
+			pbias-supply = <&pbias_mmc_reg>;
 		};
 
 		mmc2: mmc@480b4000 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                   ` (4 preceding siblings ...)
  2013-12-19 12:38                                 ` [PATCH v6 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  2013-12-19 12:38                                 ` [PATCH v6 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
  6 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

Enable REGULATOR_PBIAS needed for SD card on most OMAPs.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 arch/arm/configs/omap2plus_defconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index bfa80a1..f67baa9 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -169,6 +169,7 @@ CONFIG_DRA752_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_OMAP_WATCHDOG=y
 CONFIG_TWL4030_WATCHDOG=y
+CONFIG_MFD_SYSCON=y
 CONFIG_MFD_PALMAS=y
 CONFIG_MFD_TPS65217=y
 CONFIG_MFD_TPS65910=y
@@ -180,6 +181,7 @@ CONFIG_REGULATOR_TPS6507X=y
 CONFIG_REGULATOR_TPS65217=y
 CONFIG_REGULATOR_TPS65910=y
 CONFIG_REGULATOR_TWL4030=y
+CONFIG_REGULATOR_PBIAS=y
 CONFIG_FB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_FB_MODE_HELPERS=y
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* [PATCH v6 7/7] mmc: omap_hsmmc: remove pbias workaround
  2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
                                                   ` (5 preceding siblings ...)
  2013-12-19 12:38                                 ` [PATCH v6 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2013-12-19 12:38                                 ` Balaji T K
  6 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie
  Cc: tony, Balaji T K

remove pbias workaround

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 0a390f8..0f0aa5d 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -170,7 +170,6 @@ struct omap_hsmmc_host {
 	struct	regulator	*vcc_aux;
 	struct	regulator	*pbias;
 	bool			pbias_enabled;
-	int			pbias_disable;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
 	spinlock_t		irq_lock; /* Prevent races with irq handler */
@@ -267,13 +266,6 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
 	 */
 	if (!host->vcc)
 		return 0;
-	/*
-	 * With DT, never turn OFF the regulator for MMC1. This is because
-	 * the pbias cell programming support is still missing when
-	 * booting with Device tree
-	 */
-	if (host->pbias_disable && !vdd)
-		return 0;
 
 	if (mmc_slot(host).before_set_reg)
 		mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
@@ -1541,13 +1533,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * of external transceiver; but they all handle 1.8V.
 		 */
 		if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
-			(ios->vdd == DUAL_VOLT_OCR_BIT) &&
-			/*
-			 * With pbias cell programming missing, this
-			 * can't be allowed on MMC1 when booting with device
-			 * tree.
-			 */
-			!host->pbias_disable) {
+			(ios->vdd == DUAL_VOLT_OCR_BIT)) {
 				/*
 				 * The mmc_select_voltage fn of the core does
 				 * not seem to set the power_mode to
@@ -1880,10 +1866,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_context_save(host);
 
-	/* This can be removed once we support PBIAS with DT */
-	if (host->dev->of_node && res->start == 0x4809c000)
-		host->pbias_disable = 1;
-
 	host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
 	/*
 	 * MMC can still work without debounce clock.
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
       [not found]                                   ` <1387456720-7202-4-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-12-19 12:51                                     ` Mark Brown
  0 siblings, 0 replies; 112+ messages in thread
From: Mark Brown @ 2013-12-19 12:51 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	bcousson-rdvid1DuHRBWk0Htik3J/w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, cjb-2X9k7bc8m7Mdnm+yROfE0A,
	tony-4v6yS6AI5VpBDgjK7y7TUQ

[-- Attachment #1: Type: text/plain, Size: 404 bytes --]

On Thu, Dec 19, 2013 at 06:08:36PM +0530, Balaji T K wrote:
> pbias register controls internal power supply to sd card i/o pads
> in most OMAPs (OMAP2-5, DRA7).
> Control bits for selecting voltage level and
> enabling/disabling are in the same PBIAS register.

This is basically fine from a regulator point of view but I'd like to
see some review from the OMAP side given the concerns raised last time.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-19 12:38                                 ` [PATCH v6 3/7] regulator: add pbias regulator support Balaji T K
       [not found]                                   ` <1387456720-7202-4-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
@ 2013-12-19 16:33                                   ` Tony Lindgren
  2013-12-20  9:47                                     ` Balaji T K
  1 sibling, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-19 16:33 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

Looks good to me, just few minor comments below.

* Balaji T K <balajitk@ti.com> [131219 04:40]:
> --- /dev/null
> +++ b/drivers/regulator/pbias-regulator.c
> @@ -0,0 +1,255 @@
> +/*
> + * pbias-regulator.c
> + *
> + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
> + * Author: Balaji T K <balajitk@ti.com>

Maybe use 2013 here instead?

> +static int pbias_regulator_enable(struct regulator_dev *rdev)
> +{
> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> +	const struct pbias_reg_info *info = data->info;
> +	int ret;
> +
> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
> +					info->enable_mask, info->enable);
> +
> +	return ret;
> +}

Do we need need to check the values after enable here? AFAIK setting
the PBIAS voltage change can also fail and that's probably why it has
also the interrupt available.

> +static const struct pbias_reg_info pbias_mmc_omap3 = {
> +	.enable = BIT(1),
> +	.enable_mask = BIT(1),
> +	.vmode = BIT(0),
> +	.name = "pbias_mmc_omap3"
> +};
> +
> +static const struct pbias_reg_info pbias_sim_omap3 = {
> +	.enable = BIT(9),
> +	.enable_mask = BIT(9),
> +	.vmode = BIT(8),
> +	.name = "pbias_sim_omap3"
> +};
> +
> +static const struct pbias_reg_info pbias_mmc_omap4 = {
> +	.enable = BIT(26) | BIT(22),
> +	.enable_mask = BIT(26) | BIT(25) | BIT(22),
> +	.vmode = BIT(21),
> +	.name = "pbias_mmc_omap4"
> +};
> +
> +static const struct pbias_reg_info pbias_mmc_omap5 = {
> +	.enable = BIT(27) | BIT(26),
> +	.enable_mask = BIT(27) | BIT(25) | BIT(26),
> +	.vmode = BIT(21),
> +	.name = "pbias_mmc_omap5"
> +};
>
> +static struct of_regulator_match pbias_matches[] = {
> +	{ .name = "pbias_mmc_omap3", .driver_data = (void *)&pbias_mmc_omap3},
> +	{ .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
> +	{ .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
> +	{ .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
> +};

We probably need also pbias_mmc_omap2430 as that regiter mapping is
separate from omap3?

Other than that, good to see this finally happen. This should allow us to
get rid of most of the platform data callbacks for omap_hsmmc.c driver.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 5/7] ARM: dts: add pbias dt node
  2013-12-19 12:38                                 ` [PATCH v6 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2013-12-19 16:33                                   ` Tony Lindgren
  2013-12-20 11:40                                     ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-19 16:33 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131219 04:40]:
> @@ -485,6 +503,7 @@
>  			dmas = <&sdma 61>, <&sdma 62>;
>  			dma-names = "tx", "rx";
>  			status = "disabled";
> +			pbias-supply = <&pbias_mmc_reg>;
>  		};
>  
>  		mmc2: mmc@480b4000 {
> diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
> index d624345..f127901 100644
> --- a/arch/arm/boot/dts/omap2430.dtsi
> +++ b/arch/arm/boot/dts/omap2430.dtsi
> @@ -29,6 +29,24 @@
>  			pinctrl-single,function-mask = <0x3f>;
>  		};
>  
> +		omap2_scm_general: tisyscon@49002270 {
> +			compatible = "ti,control-syscon", "syscon", "simple-bus";
> +			reg = <0x49002270 0x240>;
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			ranges;
> +			pbias_regulator: pbias_regulator {
> +				compatible = "ti,pbias-omap";
> +				reg = <0x230 0x4>;
> +				pbias_mmc_reg: pbias_mmc_omap3 {
> +					regulator-name = "pbias_mmc_omap3";
> +					regulator-min-microvolt = <1800000>;
> +					regulator-max-microvolt = <3000000>;
> +					regulator-enable-ramp-delay = <100>;
> +				};
> +			};
> +		};
> +
>  		gpio1: gpio@4900c000 {
>  			compatible = "ti,omap2-gpio";
>  			reg = <0x4900c000 0x200>;

Here too you may need to set up pbias_mmc_omap2430?

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-19 16:33                                   ` Tony Lindgren
@ 2013-12-20  9:47                                     ` Balaji T K
  2013-12-20 15:57                                       ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-20  9:47 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Thursday 19 December 2013 10:03 PM, Tony Lindgren wrote:
> Looks good to me, just few minor comments below.
>
> * Balaji T K <balajitk@ti.com> [131219 04:40]:
>> --- /dev/null
>> +++ b/drivers/regulator/pbias-regulator.c
>> @@ -0,0 +1,255 @@
>> +/*
>> + * pbias-regulator.c
>> + *
>> + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
>> + * Author: Balaji T K <balajitk@ti.com>
>
> Maybe use 2013 here instead?

yes

>
>> +static int pbias_regulator_enable(struct regulator_dev *rdev)
>> +{
>> +	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
>> +	const struct pbias_reg_info *info = data->info;
>> +	int ret;
>> +
>> +	ret = regmap_update_bits(data->syscon, data->pbias_reg,
>> +					info->enable_mask, info->enable);
>> +
>> +	return ret;
>> +}
>
> Do we need need to check the values after enable here? AFAIK setting
> the PBIAS voltage change can also fail and that's probably why it has

failure due to mismatch in input voltage, should to be avoided and should
be taken care in s/w by the caller before pbias regulator set voltage/enable.

> also the interrupt available.
>

But interrupt was never used/tested AFAIK, there is some settling time
before the generated interrupt status is truely valid, so pbias interrupt is not
reliable.

>> +static const struct pbias_reg_info pbias_mmc_omap3 = {
>> +	.enable = BIT(1),
>> +	.enable_mask = BIT(1),
>> +	.vmode = BIT(0),
>> +	.name = "pbias_mmc_omap3"
>> +};
>> +
>> +static const struct pbias_reg_info pbias_sim_omap3 = {
>> +	.enable = BIT(9),
>> +	.enable_mask = BIT(9),
>> +	.vmode = BIT(8),
>> +	.name = "pbias_sim_omap3"
>> +};
>> +
>> +static const struct pbias_reg_info pbias_mmc_omap4 = {
>> +	.enable = BIT(26) | BIT(22),
>> +	.enable_mask = BIT(26) | BIT(25) | BIT(22),
>> +	.vmode = BIT(21),
>> +	.name = "pbias_mmc_omap4"
>> +};
>> +
>> +static const struct pbias_reg_info pbias_mmc_omap5 = {
>> +	.enable = BIT(27) | BIT(26),
>> +	.enable_mask = BIT(27) | BIT(25) | BIT(26),
>> +	.vmode = BIT(21),
>> +	.name = "pbias_mmc_omap5"
>> +};
>>
>> +static struct of_regulator_match pbias_matches[] = {
>> +	{ .name = "pbias_mmc_omap3", .driver_data = (void *)&pbias_mmc_omap3},
>> +	{ .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
>> +	{ .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
>> +	{ .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
>> +};
>
> We probably need also pbias_mmc_omap2430 as that regiter mapping is
> separate from omap3?
>

between omap2430 and omap3430, 3460 pbias register address are different,
other than that enable,enable_mask and vmode are
one and the same, so re-used "pbias_mmc_omap3" name and struct pbias_reg_info pbias_mmc_omap3
for omap2430 too, save one entry in of_regulator_match!

If separate name is needed for omap2430, I can add one for 2430,
and reuse the "const struct pbias_reg_info pbias_mmc_omap3" of omap3
since the bit map for enable/disable and voltage configuration will be same.
Then pbias_matches will look like.

 >> +static struct of_regulator_match pbias_matches[] = {
 >> +	{ .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap3},
 >> +	{ .name = "pbias_mmc_omap3", .driver_data = (void *)&pbias_mmc_omap3},
 >> +	{ .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
 >> +	{ .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
 >> +	{ .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
 >> +};

Let me know if you still think that separate regulator name is needed for 2430,
I can respin this series.

> Other than that, good to see this finally happen. This should allow us to
> get rid of most of the platform data callbacks for omap_hsmmc.c driver.
>
> Regards,
>
> Tony
>

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 5/7] ARM: dts: add pbias dt node
  2013-12-19 16:33                                   ` Tony Lindgren
@ 2013-12-20 11:40                                     ` Balaji T K
  2013-12-20 15:58                                       ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Balaji T K @ 2013-12-20 11:40 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Thursday 19 December 2013 10:03 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131219 04:40]:
>> @@ -485,6 +503,7 @@
>>   			dmas = <&sdma 61>, <&sdma 62>;
>>   			dma-names = "tx", "rx";
>>   			status = "disabled";
>> +			pbias-supply = <&pbias_mmc_reg>;
>>   		};
>>
>>   		mmc2: mmc@480b4000 {
>> diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
>> index d624345..f127901 100644
>> --- a/arch/arm/boot/dts/omap2430.dtsi
>> +++ b/arch/arm/boot/dts/omap2430.dtsi
>> @@ -29,6 +29,24 @@
>>   			pinctrl-single,function-mask = <0x3f>;
>>   		};
>>
>> +		omap2_scm_general: tisyscon@49002270 {
>> +			compatible = "ti,control-syscon", "syscon", "simple-bus";
>> +			reg = <0x49002270 0x240>;
>> +			#address-cells = <1>;
>> +			#size-cells = <1>;
>> +			ranges;
>> +			pbias_regulator: pbias_regulator {
>> +				compatible = "ti,pbias-omap";
>> +				reg = <0x230 0x4>;
>> +				pbias_mmc_reg: pbias_mmc_omap3 {
>> +					regulator-name = "pbias_mmc_omap3";
>> +					regulator-min-microvolt = <1800000>;
>> +					regulator-max-microvolt = <3000000>;
>> +					regulator-enable-ramp-delay = <100>;
>> +				};
>> +			};
>> +		};
>> +
>>   		gpio1: gpio@4900c000 {
>>   			compatible = "ti,omap2-gpio";
>>   			reg = <0x4900c000 0x200>;
>
> Here too you may need to set up pbias_mmc_omap2430?
>

2430 pbias reg config is same as 3430/3630 w.r.t to mmc pbias i/o,
hence using the same name, if you think regulator name needs to be changed
let me know the more appropriate one.

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-20  9:47                                     ` Balaji T K
@ 2013-12-20 15:57                                       ` Tony Lindgren
  2013-12-20 16:09                                         ` Mark Brown
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-20 15:57 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131220 01:49]:
> On Thursday 19 December 2013 10:03 PM, Tony Lindgren wrote:
> >>+static int pbias_regulator_enable(struct regulator_dev *rdev)
> >>+{
> >>+	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> >>+	const struct pbias_reg_info *info = data->info;
> >>+	int ret;
> >>+
> >>+	ret = regmap_update_bits(data->syscon, data->pbias_reg,
> >>+					info->enable_mask, info->enable);
> >>+
> >>+	return ret;
> >>+}
> >
> >Do we need need to check the values after enable here? AFAIK setting
> >the PBIAS voltage change can also fail and that's probably why it has
> 
> failure due to mismatch in input voltage, should to be avoided and should
> be taken care in s/w by the caller before pbias regulator set voltage/enable.
> 
> >also the interrupt available.
> >
> 
> But interrupt was never used/tested AFAIK, there is some settling time
> before the generated interrupt status is truely valid, so pbias interrupt is not
> reliable.

OK. Do we need the standard regulator property startup-delay-us for the
PBIAS regulator then? Or if it's always fixed, I guess it could be done
in the pbias_regulator_enable()?
 
> >We probably need also pbias_mmc_omap2430 as that regiter mapping is
> >separate from omap3?
> >
> 
> between omap2430 and omap3430, 3460 pbias register address are different,
> other than that enable,enable_mask and vmode are
> one and the same, so re-used "pbias_mmc_omap3" name and struct pbias_reg_info pbias_mmc_omap3
> for omap2430 too, save one entry in of_regulator_match!
> 
> If separate name is needed for omap2430, I can add one for 2430,
> and reuse the "const struct pbias_reg_info pbias_mmc_omap3" of omap3
> since the bit map for enable/disable and voltage configuration will be same.
> Then pbias_matches will look like.

If they truly are compatible, then usually the earliest revision name is
used. So I guess we should use the omap2430 naming instead of omap3 naming.
 
> >> +static struct of_regulator_match pbias_matches[] = {
> >> +	{ .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap3},
> >> +	{ .name = "pbias_mmc_omap3", .driver_data = (void *)&pbias_mmc_omap3},
> >> +	{ .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
> >> +	{ .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
> >> +	{ .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
> >> +};
> 
> Let me know if you still think that separate regulator name is needed for 2430,
> I can respin this series.

Sounds like using the omap2430 naming would solve that.

Regards,

Tony 

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 5/7] ARM: dts: add pbias dt node
  2013-12-20 11:40                                     ` Balaji T K
@ 2013-12-20 15:58                                       ` Tony Lindgren
  2013-12-20 16:08                                         ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-20 15:58 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

* Balaji T K <balajitk@ti.com> [131220 03:41]:
> On Thursday 19 December 2013 10:03 PM, Tony Lindgren wrote:
> >* Balaji T K <balajitk@ti.com> [131219 04:40]:
> >>@@ -485,6 +503,7 @@
> >>  			dmas = <&sdma 61>, <&sdma 62>;
> >>  			dma-names = "tx", "rx";
> >>  			status = "disabled";
> >>+			pbias-supply = <&pbias_mmc_reg>;
> >>  		};
> >>
> >>  		mmc2: mmc@480b4000 {
> >>diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
> >>index d624345..f127901 100644
> >>--- a/arch/arm/boot/dts/omap2430.dtsi
> >>+++ b/arch/arm/boot/dts/omap2430.dtsi
> >>@@ -29,6 +29,24 @@
> >>  			pinctrl-single,function-mask = <0x3f>;
> >>  		};
> >>
> >>+		omap2_scm_general: tisyscon@49002270 {
> >>+			compatible = "ti,control-syscon", "syscon", "simple-bus";
> >>+			reg = <0x49002270 0x240>;
> >>+			#address-cells = <1>;
> >>+			#size-cells = <1>;
> >>+			ranges;
> >>+			pbias_regulator: pbias_regulator {
> >>+				compatible = "ti,pbias-omap";
> >>+				reg = <0x230 0x4>;
> >>+				pbias_mmc_reg: pbias_mmc_omap3 {
> >>+					regulator-name = "pbias_mmc_omap3";
> >>+					regulator-min-microvolt = <1800000>;
> >>+					regulator-max-microvolt = <3000000>;
> >>+					regulator-enable-ramp-delay = <100>;
> >>+				};
> >>+			};
> >>+		};
> >>+
> >>  		gpio1: gpio@4900c000 {
> >>  			compatible = "ti,omap2-gpio";
> >>  			reg = <0x4900c000 0x200>;
> >
> >Here too you may need to set up pbias_mmc_omap2430?
> >
> 
> 2430 pbias reg config is same as 3430/3630 w.r.t to mmc pbias i/o,
> hence using the same name, if you think regulator name needs to be changed
> let me know the more appropriate one.

If they are compatible then we should use the earliest revision number
which would be 2430 instead of omap3 :)

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 5/7] ARM: dts: add pbias dt node
  2013-12-20 15:58                                       ` Tony Lindgren
@ 2013-12-20 16:08                                         ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-20 16:08 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, cjb, broonie

On Friday 20 December 2013 09:28 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131220 03:41]:
>> On Thursday 19 December 2013 10:03 PM, Tony Lindgren wrote:
>>> * Balaji T K <balajitk@ti.com> [131219 04:40]:
>>>> @@ -485,6 +503,7 @@
>>>>   			dmas = <&sdma 61>, <&sdma 62>;
>>>>   			dma-names = "tx", "rx";
>>>>   			status = "disabled";
>>>> +			pbias-supply = <&pbias_mmc_reg>;
>>>>   		};
>>>>
>>>>   		mmc2: mmc@480b4000 {
>>>> diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
>>>> index d624345..f127901 100644
>>>> --- a/arch/arm/boot/dts/omap2430.dtsi
>>>> +++ b/arch/arm/boot/dts/omap2430.dtsi
>>>> @@ -29,6 +29,24 @@
>>>>   			pinctrl-single,function-mask = <0x3f>;
>>>>   		};
>>>>
>>>> +		omap2_scm_general: tisyscon@49002270 {
>>>> +			compatible = "ti,control-syscon", "syscon", "simple-bus";
>>>> +			reg = <0x49002270 0x240>;
>>>> +			#address-cells = <1>;
>>>> +			#size-cells = <1>;
>>>> +			ranges;
>>>> +			pbias_regulator: pbias_regulator {
>>>> +				compatible = "ti,pbias-omap";
>>>> +				reg = <0x230 0x4>;
>>>> +				pbias_mmc_reg: pbias_mmc_omap3 {
>>>> +					regulator-name = "pbias_mmc_omap3";
>>>> +					regulator-min-microvolt = <1800000>;
>>>> +					regulator-max-microvolt = <3000000>;
>>>> +					regulator-enable-ramp-delay = <100>;
>>>> +				};
>>>> +			};
>>>> +		};
>>>> +
>>>>   		gpio1: gpio@4900c000 {
>>>>   			compatible = "ti,omap2-gpio";
>>>>   			reg = <0x4900c000 0x200>;
>>>
>>> Here too you may need to set up pbias_mmc_omap2430?
>>>
>>
>> 2430 pbias reg config is same as 3430/3630 w.r.t to mmc pbias i/o,
>> hence using the same name, if you think regulator name needs to be changed
>> let me know the more appropriate one.
>
> If they are compatible then we should use the earliest revision number
> which would be 2430 instead of omap3 :)

I went with most commonly used omap SoC :-)

>
> Tony
>


^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-20 15:57                                       ` Tony Lindgren
@ 2013-12-20 16:09                                         ` Mark Brown
  2013-12-20 16:13                                           ` Tony Lindgren
  0 siblings, 1 reply; 112+ messages in thread
From: Mark Brown @ 2013-12-20 16:09 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Balaji T K, linux-omap, bcousson, devicetree, linux-mmc, cjb

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

On Fri, Dec 20, 2013 at 07:57:21AM -0800, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [131220 01:49]:

> > But interrupt was never used/tested AFAIK, there is some settling time
> > before the generated interrupt status is truely valid, so pbias interrupt is not
> > reliable.

> OK. Do we need the standard regulator property startup-delay-us for the
> PBIAS regulator then? Or if it's always fixed, I guess it could be done
> in the pbias_regulator_enable()?

That delay is supposed to be the time for the startup of the supply
rather than any detection code.  It should be set using enable_time in
the driver if it's not system dependent - the property is there for
cases where the delay depends on system configuration (eg, due to the
capacitor values).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-20 16:09                                         ` Mark Brown
@ 2013-12-20 16:13                                           ` Tony Lindgren
  2013-12-20 16:44                                             ` Balaji T K
  0 siblings, 1 reply; 112+ messages in thread
From: Tony Lindgren @ 2013-12-20 16:13 UTC (permalink / raw)
  To: Mark Brown; +Cc: Balaji T K, linux-omap, bcousson, devicetree, linux-mmc, cjb

* Mark Brown <broonie@kernel.org> [131220 08:10]:
> On Fri, Dec 20, 2013 at 07:57:21AM -0800, Tony Lindgren wrote:
> > * Balaji T K <balajitk@ti.com> [131220 01:49]:
> 
> > > But interrupt was never used/tested AFAIK, there is some settling time
> > > before the generated interrupt status is truely valid, so pbias interrupt is not
> > > reliable.
> 
> > OK. Do we need the standard regulator property startup-delay-us for the
> > PBIAS regulator then? Or if it's always fixed, I guess it could be done
> > in the pbias_regulator_enable()?
> 
> That delay is supposed to be the time for the startup of the supply
> rather than any detection code.  It should be set using enable_time in
> the driver if it's not system dependent - the property is there for
> cases where the delay depends on system configuration (eg, due to the
> capacitor values).

OK thanks. Let's try enable_time first then as we've had a fixed value
for years for it. If there's some difference based on the card
capacitance etc that can be added if needed.

Regards,

Tony

^ permalink raw reply	[flat|nested] 112+ messages in thread

* Re: [PATCH v6 3/7] regulator: add pbias regulator support
  2013-12-20 16:13                                           ` Tony Lindgren
@ 2013-12-20 16:44                                             ` Balaji T K
  0 siblings, 0 replies; 112+ messages in thread
From: Balaji T K @ 2013-12-20 16:44 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Mark Brown, linux-omap, bcousson, devicetree, linux-mmc, cjb

On Friday 20 December 2013 09:43 PM, Tony Lindgren wrote:
> * Mark Brown <broonie@kernel.org> [131220 08:10]:
>> On Fri, Dec 20, 2013 at 07:57:21AM -0800, Tony Lindgren wrote:
>>> * Balaji T K <balajitk@ti.com> [131220 01:49]:
>>
>>>> But interrupt was never used/tested AFAIK, there is some settling time
>>>> before the generated interrupt status is truely valid, so pbias interrupt is not
>>>> reliable.
>>
>>> OK. Do we need the standard regulator property startup-delay-us for the
>>> PBIAS regulator then? Or if it's always fixed, I guess it could be done
>>> in the pbias_regulator_enable()?
>>
>> That delay is supposed to be the time for the startup of the supply
>> rather than any detection code.  It should be set using enable_time in
>> the driver if it's not system dependent - the property is there for
>> cases where the delay depends on system configuration (eg, due to the
>> capacitor values).
>
> OK thanks. Let's try enable_time first then as we've had a fixed value
> for years for it. If there's some difference based on the card
> capacitance etc that can be added if needed.

I used regulator-enable-ramp-delay to set constraints->enable_time based on SoC.
Since it is not board dependent, I will drop regulator-enable-ramp-delay from dt and
pass the value via driver_data.

Thanks and Regards,
Balaji T K

^ permalink raw reply	[flat|nested] 112+ messages in thread

end of thread, other threads:[~2013-12-20 16:44 UTC | newest]

Thread overview: 112+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
2013-04-30 14:03 ` [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
2013-04-30 14:03 ` [PATCH 02/13] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
2013-04-30 14:03 ` [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc Balaji T K
2013-04-30 14:03 ` [PATCH 04/13] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
2013-04-30 14:03 ` [PATCH 05/13] mmc: omap_hsmmc: remove use_reg Balaji T K
2013-04-30 14:03 ` [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support Balaji T K
2013-05-16 16:16   ` Tony Lindgren
2013-05-23 16:07     ` Balaji T K
2013-05-23 18:40       ` Tony Lindgren
2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
2013-06-12 14:24             ` Tony Lindgren
     [not found]               ` <20130612142409.GW8164-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2013-06-12 17:00                 ` Balaji T K
2013-06-06 19:14           ` [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
2013-06-12 14:25             ` Tony Lindgren
2013-06-12 14:33               ` Balaji T K
2013-06-12 14:38                 ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 03/10] mmc: omap_hsmmc: use needs_vmmc Balaji T K
2013-06-06 19:14           ` [PATCH v2 04/10] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
2013-06-06 19:14           ` [PATCH v2 05/10] mmc: omap_hsmmc: remove use_reg Balaji T K
2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
2013-06-12 14:37             ` Tony Lindgren
2013-06-12 17:46               ` Balaji T K
2013-06-13  9:38               ` Linus Walleij
2013-06-13  9:37             ` Linus Walleij
2013-06-13  9:53               ` Tony Lindgren
2013-06-13 10:02                 ` Laurent Pinchart
2013-06-13 14:52                   ` Balaji T K
2013-06-13 14:53                     ` Laurent Pinchart
2013-06-13 12:39                 ` Linus Walleij
2013-06-13 14:41                 ` Balaji T K
2013-06-13 15:29                   ` Linus Walleij
     [not found]                     ` <CACRpkdY6cZ+bT-C9Go3sZVw6ErQqTm0m9__uKQrkg4eUU1thHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-13 16:29                       ` Tony Lindgren
2013-06-13 17:45                         ` Mark Brown
2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-11-21 15:08                               ` Ulf Hansson
2013-12-05 15:29                                 ` Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-10 11:09                               ` Ulf Hansson
2013-12-10 11:48                                 ` Balaji T K
2013-12-11 11:21                                   ` Ulf Hansson
2013-12-18 14:52                                     ` Balaji T K
     [not found]                             ` <1385043627-30439-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-11-21 14:20                               ` [RFC PATCH v3 3/8] regulator: add pbias regulator support Balaji T K
2013-11-21 14:46                                 ` Mark Brown
2013-12-03 15:54                                   ` Balaji T K
2013-12-03 16:06                                     ` Mark Brown
2013-11-21 14:20                             ` [RFC PATCH v3 4/8] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 5/8] ARM: dts: add pbias dt node Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 6/8] ARM: dts: add pbias-supply Balaji T K
2013-11-21 17:03                               ` Tony Lindgren
2013-12-05 14:55                                 ` Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 7/8] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 8/8] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-12-10 10:16                               ` [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-12-10 10:16                               ` [PATCH v4 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-10 10:16                               ` [PATCH v4 3/7] regulator: add pbias regulator support Balaji T K
2013-12-10 10:40                                 ` Mark Brown
2013-12-10 12:22                                   ` Balaji T K
2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
2013-12-10 18:33                                     ` Tony Lindgren
2013-12-10 22:39                                       ` Tony Lindgren
2013-12-12 15:12                                       ` Balaji T K
2013-12-11 22:46                                     ` Mark Brown
2013-12-10 10:16                               ` [PATCH v4 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-12-10 10:16                               ` [PATCH v4 5/7] ARM: dts: add pbias dt node Balaji T K
2013-12-10 22:42                                 ` Tony Lindgren
2013-12-12 14:58                                   ` Balaji T K
2013-12-10 10:16                               ` [PATCH v4 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-12-10 10:16                               ` [PATCH v4 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 3/7] regulator: add pbias regulator support Balaji T K
     [not found]                                   ` <1387456720-7202-4-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-12-19 12:51                                     ` Mark Brown
2013-12-19 16:33                                   ` Tony Lindgren
2013-12-20  9:47                                     ` Balaji T K
2013-12-20 15:57                                       ` Tony Lindgren
2013-12-20 16:09                                         ` Mark Brown
2013-12-20 16:13                                           ` Tony Lindgren
2013-12-20 16:44                                             ` Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 5/7] ARM: dts: add pbias dt node Balaji T K
2013-12-19 16:33                                   ` Tony Lindgren
2013-12-20 11:40                                     ` Balaji T K
2013-12-20 15:58                                       ` Tony Lindgren
2013-12-20 16:08                                         ` Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-06-13 10:47               ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Lee Jones
2013-06-13 15:01                 ` Balaji T K
2013-06-13 16:17                   ` Lee Jones
2013-06-06 19:14           ` [PATCH v2 07/10] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
     [not found]           ` <1370546059-24181-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-06-06 19:14             ` [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core Balaji T K
2013-06-12 14:35               ` Tony Lindgren
2013-06-12 17:08                 ` Balaji T K
2013-06-12 17:54                   ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states Balaji T K
2013-06-12 14:35             ` Tony Lindgren
2013-06-12 17:43               ` Balaji T K
2013-06-12 17:50                 ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 10/10] ARM: dts: omap4: " Balaji T K
2013-06-12 14:36             ` Tony Lindgren
2013-04-30 14:03 ` [PATCH 07/13] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
2013-04-30 14:03 ` [PATCH 08/13] Documentation: dt: mmc: omap hsmmc Balaji T K
2013-04-30 14:03 ` [PATCH 09/13] ARM: dts: omap3: Add omap control mmc data Balaji T K
2013-04-30 14:03 ` [PATCH 10/13] ARM: dts: omap36xx: " Balaji T K
2013-04-30 14:03 ` [PATCH 11/13] ARM: dts: omap4: " Balaji T K
2013-04-30 14:03 ` [PATCH 12/13] ARM: dts: omap5: " Balaji T K
2013-04-30 14:03 ` [PATCH 13/13] ARM: dts: am3517: add omap_control_mmc Balaji T K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).