* [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2014-01-09 14:50 ` Balaji T K
2014-01-09 15:18 ` Felipe Balbi
2014-01-09 14:50 ` [PATCH v8 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
` (7 subsequent siblings)
8 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:50 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* Re: [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-09 14:50 ` [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2014-01-09 15:18 ` Felipe Balbi
2014-01-10 15:55 ` Balaji T K
0 siblings, 1 reply; 71+ messages in thread
From: Felipe Balbi @ 2014-01-09 15:18 UTC (permalink / raw)
To: Balaji T K
Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony,
mark.rutland
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
Hi,
On Thu, Jan 09, 2014 at 08:20:56PM +0530, Balaji T K 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>
> Acked-by: Tony Lindgren <tony@atomide.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)
since this function does nothing now, you could pretty much remove it
and move set_power assignment to ->remove() directly. No strong feelings
though.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-09 15:18 ` Felipe Balbi
@ 2014-01-10 15:55 ` Balaji T K
2014-01-10 15:58 ` Felipe Balbi
0 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-01-10 15:55 UTC (permalink / raw)
To: balbi
Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony,
mark.rutland
On Thursday 09 January 2014 08:48 PM, Felipe Balbi wrote:
> Hi,
>
> On Thu, Jan 09, 2014 at 08:20:56PM +0530, Balaji T K 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>
>> Acked-by: Tony Lindgren <tony@atomide.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)
>
> since this function does nothing now, you could pretty much remove it
> and move set_power assignment to ->remove() directly. No strong feelings
> though.
>
Hi Felipe,
omap_hsmmc_reg_put is used in probe error handling path in addition to .remove(),
so I would keep it for now to balance omap_hsmmc_reg_get.
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-10 15:55 ` Balaji T K
@ 2014-01-10 15:58 ` Felipe Balbi
0 siblings, 0 replies; 71+ messages in thread
From: Felipe Balbi @ 2014-01-10 15:58 UTC (permalink / raw)
To: Balaji T K
Cc: balbi, linux-omap, bcousson, devicetree, linux-mmc, chris,
broonie, tony, mark.rutland
[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]
hi,
On Fri, Jan 10, 2014 at 09:25:20PM +0530, Balaji T K wrote:
> On Thursday 09 January 2014 08:48 PM, Felipe Balbi wrote:
> >Hi,
> >
> >On Thu, Jan 09, 2014 at 08:20:56PM +0530, Balaji T K 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>
> >>Acked-by: Tony Lindgren <tony@atomide.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)
> >
> >since this function does nothing now, you could pretty much remove it
> >and move set_power assignment to ->remove() directly. No strong feelings
> >though.
> >
> Hi Felipe,
>
> omap_hsmmc_reg_put is used in probe error handling path in addition to .remove(),
> so I would keep it for now to balance omap_hsmmc_reg_get.
right, but it does nothing but setting set_power to NULL ;-)
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 71+ messages in thread
* [PATCH v8 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-09 14:50 ` [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2014-01-09 14:50 ` Balaji T K
2014-01-09 14:50 ` [PATCH v8 3/7] regulator: add pbias regulator support Balaji T K
` (6 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:50 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
handle vcc and vcc_aux independently to reduce indent.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v8 3/7] regulator: add pbias regulator support
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-09 14:50 ` [PATCH v8 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2014-01-09 14:50 ` [PATCH v8 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2014-01-09 14:50 ` Balaji T K
2014-01-09 17:27 ` Mark Brown
2014-01-09 14:50 ` [PATCH v8 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
` (5 subsequent siblings)
8 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:50 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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>
Acked-by: Tony Lindgren <tony@atomide.com>
---
.../bindings/regulator/pbias-regulator.txt | 27 ++
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 261 ++++++++++++++++++++
4 files changed, 298 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..d9342f9
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,27 @@
+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.
+- reg: pbias register offset from syscon base and size of pbias register.
+- regulator-name : should be
+ pbias_mmc_omap2430 for OMAP2430, OMAP3 SoCs
+ pbias_sim_omap3 for OMAP3 SoCs
+ pbias_mmc_omap4 for OMAP4 SoCs
+ pbias_mmc_omap5 for OMAP5 and DRA7 SoC
+
+pbias_regulator node should be a child of syscon node (system control module)
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+ 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>;
+ };
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..811983d
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,261 @@
+/*
+ * 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;
+ unsigned int enable_time;
+ 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_omap2430 = {
+ .enable = BIT(1),
+ .enable_mask = BIT(1),
+ .vmode = BIT(0),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap2430"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+ .enable = BIT(9),
+ .enable_mask = BIT(9),
+ .vmode = BIT(8),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap5"
+};
+
+static struct of_regulator_match pbias_matches[] = {
+ { .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap2430},
+ { .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;
+ drvdata[data_idx].desc.enable_time = info->enable_time;
+
+ 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] 71+ messages in thread
* Re: [PATCH v8 3/7] regulator: add pbias regulator support
2014-01-09 14:50 ` [PATCH v8 3/7] regulator: add pbias regulator support Balaji T K
@ 2014-01-09 17:27 ` Mark Brown
0 siblings, 0 replies; 71+ messages in thread
From: Mark Brown @ 2014-01-09 17:27 UTC (permalink / raw)
To: Balaji T K
Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, tony,
mark.rutland
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
On Thu, Jan 09, 2014 at 08:20: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.
Acked-by: Mark Brown <broonie@linaro.org>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 71+ messages in thread
* [PATCH v8 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (2 preceding siblings ...)
2014-01-09 14:50 ` [PATCH v8 3/7] regulator: add pbias regulator support Balaji T K
@ 2014-01-09 14:50 ` Balaji T K
2014-01-09 14:51 ` [PATCH v8 5/7] ARM: dts: add pbias dt node Balaji T K
` (4 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:50 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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] 71+ messages in thread
* [PATCH v8 5/7] ARM: dts: add pbias dt node
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (3 preceding siblings ...)
2014-01-09 14:50 ` [PATCH v8 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2014-01-09 14:51 ` Balaji T K
2014-01-09 14:51 ` [PATCH v8 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
` (3 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:51 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
Add pbias regulator node as a child of system control
module - syscon.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/boot/dts/dra7.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/omap2430.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/omap3.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/omap4.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/omap5.dtsi | 18 ++++++++++++++++++
5 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..9974bde 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -110,6 +110,23 @@
ti,hwmods = "counter_32k";
};
+ dra7_ctrl_general: tisyscon@4a002e00 {
+ compatible = "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>;
+ };
+ };
+ };
+
dra7_pmx_core: pinmux@4a003400 {
compatible = "pinctrl-single";
reg = <0x4a003400 0x0464>;
@@ -485,6 +502,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..5ec3638 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,23 @@
pinctrl-single,function-mask = <0x3f>;
};
+ omap2_scm_general: tisyscon@49002270 {
+ compatible = "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_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+ };
+
gpio1: gpio@4900c000 {
compatible = "ti,omap2-gpio";
reg = <0x4900c000 0x200>;
@@ -183,6 +200,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..0f50990 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -137,6 +137,23 @@
pinctrl-single,function-mask = <0xff1f>;
};
+ omap3_scm_general: tisyscon@48002270 {
+ compatible = "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_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+ };
+
gpio1: gpio@48310000 {
compatible = "ti,omap3-gpio";
reg = <0x48310000 0x200>;
@@ -351,6 +368,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..a8e036f 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,23 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap4_padconf_global: tisyscon@4a1005a0 {
+ compatible = "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>;
+ };
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -367,6 +384,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..3fd44c7 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,23 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap5_padconf_global: tisyscon@4a002da0 {
+ compatible = "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>;
+ };
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -409,6 +426,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] 71+ messages in thread
* [PATCH v8 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (4 preceding siblings ...)
2014-01-09 14:51 ` [PATCH v8 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2014-01-09 14:51 ` Balaji T K
2014-01-09 14:51 ` [PATCH v8 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
` (2 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:51 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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] 71+ messages in thread
* [PATCH v8 7/7] mmc: omap_hsmmc: remove pbias workaround
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (5 preceding siblings ...)
2014-01-09 14:51 ` [PATCH v8 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2014-01-09 14:51 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-09 14:51 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
remove pbias workaround
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (6 preceding siblings ...)
2014-01-09 14:51 ` [PATCH v8 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
` (6 more replies)
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
8 siblings, 7 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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.
v9 changes:
remove simple-bus, add phandle for syscon in dt node
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 | 27 ++
arch/arm/boot/dts/dra7.dtsi | 17 ++
arch/arm/boot/dts/omap2430.dtsi | 17 ++
arch/arm/boot/dts/omap3.dtsi | 17 ++
arch/arm/boot/dts/omap4.dtsi | 17 ++
arch/arm/boot/dts/omap5.dtsi | 17 ++
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] 71+ messages in thread
* [PATCH v9 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
` (5 subsequent siblings)
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v9 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-10 17:30 ` [PATCH v9 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 3/7] regulator: add pbias regulator support Balaji T K
` (4 subsequent siblings)
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
handle vcc and vcc_aux independently to reduce indent.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v9 3/7] regulator: add pbias regulator support
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-10 17:30 ` [PATCH v9 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2014-01-10 17:30 ` [PATCH v9 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
` (3 subsequent siblings)
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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>
Acked-by: Tony Lindgren <tony@atomide.com>
---
v9:
use syscon phandle lookup method
.../bindings/regulator/pbias-regulator.txt | 27 ++
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
4 files changed, 292 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..32aa26f
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,27 @@
+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.
+- reg: pbias register offset from syscon base and size of pbias register.
+- syscon : phandle of the system control module
+- regulator-name : should be
+ pbias_mmc_omap2430 for OMAP2430, OMAP3 SoCs
+ pbias_sim_omap3 for OMAP3 SoCs
+ pbias_mmc_omap4 for OMAP4 SoCs
+ pbias_mmc_omap5 for OMAP5 and DRA7 SoC
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
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..39518e0
--- /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;
+ unsigned int enable_time;
+ 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_omap2430 = {
+ .enable = BIT(1),
+ .enable_mask = BIT(1),
+ .vmode = BIT(0),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap2430"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+ .enable = BIT(9),
+ .enable_mask = BIT(9),
+ .vmode = BIT(8),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap5"
+};
+
+static struct of_regulator_match pbias_matches[] = {
+ { .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap2430},
+ { .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 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;
+ }
+
+ syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
+ 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;
+ drvdata[data_idx].desc.enable_time = info->enable_time;
+
+ 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] 71+ messages in thread
* [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (2 preceding siblings ...)
2014-01-10 17:30 ` [PATCH v9 3/7] regulator: add pbias regulator support Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 18:21 ` Michael Trimarchi
2014-01-10 17:30 ` [PATCH v9 5/7] ARM: dts: add pbias dt node Balaji T K
` (2 subsequent siblings)
6 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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] 71+ messages in thread
* Re: [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-01-10 17:30 ` [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2014-01-10 18:21 ` Michael Trimarchi
2014-01-13 13:29 ` Balaji T K
0 siblings, 1 reply; 71+ messages in thread
From: Michael Trimarchi @ 2014-01-10 18:21 UTC (permalink / raw)
To: Balaji T K
Cc: Linux OMAP Mailing List, Benoit Cousson, devicetree, linux-mmc,
chris, Mark Brown, Tony Lindgren, mark.rutland
Hi
On Fri, Jan 10, 2014 at 6:30 PM, Balaji T K <balajitk@ti.com> wrote:
> 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;
why you a goto to error_set_power if the regulator enable was a succes?
and if pbias_enabled is used for verify if is already enabled. Is the
same to use
regulator_is_enabled?
Michael
> + }
> + }
> + }
> +
> 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
>
> --
> 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] 71+ messages in thread
* Re: [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-01-10 18:21 ` Michael Trimarchi
@ 2014-01-13 13:29 ` Balaji T K
0 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 13:29 UTC (permalink / raw)
To: Michael Trimarchi
Cc: Linux OMAP Mailing List, Benoit Cousson, devicetree, linux-mmc,
chris, Mark Brown, Tony Lindgren, mark.rutland
On Friday 10 January 2014 11:51 PM, Michael Trimarchi wrote:
> Hi
>
> On Fri, Jan 10, 2014 at 6:30 PM, Balaji T K <balajitk@ti.com> wrote:
>> 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;
>
> why you a goto to error_set_power if the regulator enable was a succes?
Hi,
My bad
yes, goto error_set_power is not needed when regulator got enabled.
will remove it.
> and if pbias_enabled is used for verify if is already enabled. Is the
> same to use
> regulator_is_enabled?
>
pbias_enabled is used to verify if it already enabled or not
and it is used to balance regulator_enable/disable.
> Michael
>
>> + }
>> + }
>> + }
>> +
>> 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
>>
>> --
>> 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] 71+ messages in thread
* [PATCH v9 5/7] ARM: dts: add pbias dt node
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (3 preceding siblings ...)
2014-01-10 17:30 ` [PATCH v9 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2014-01-10 17:30 ` [PATCH v9 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
Add pbias regulator node as a child of system control
module - syscon.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/boot/dts/dra7.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap2430.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap3.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap4.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap5.dtsi | 17 +++++++++++++++++
5 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..876c9b8 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -110,6 +110,22 @@
ti,hwmods = "counter_32k";
};
+ dra7_ctrl_general: tisyscon@4a002e00 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a002e00 0x7c>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&dra7_ctrl_general>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
dra7_pmx_core: pinmux@4a003400 {
compatible = "pinctrl-single";
reg = <0x4a003400 0x0464>;
@@ -485,6 +501,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..af71eb0 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,22 @@
pinctrl-single,function-mask = <0x3f>;
};
+ omap2_scm_general: tisyscon@49002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x49002270 0x240>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x230 0x4>;
+ syscon = <&omap2_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@4900c000 {
compatible = "ti,omap2-gpio";
reg = <0x4900c000 0x200>;
@@ -183,6 +199,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..b7828da 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -137,6 +137,22 @@
pinctrl-single,function-mask = <0xff1f>;
};
+ omap3_scm_general: tisyscon@48002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x48002270 0x2f0>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x2b0 0x4>;
+ syscon = <&omap3_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@48310000 {
compatible = "ti,omap3-gpio";
reg = <0x48310000 0x200>;
@@ -351,6 +367,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..9e19363 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap4_padconf_global: tisyscon@4a1005a0 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a1005a0 0x170>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap4_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap4 {
+ regulator-name = "pbias_mmc_omap4";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -367,6 +383,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..f178899 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap5_padconf_global: tisyscon@4a002da0 {
+ compatible = "syscon";
+ reg = <0x4A002da0 0xec>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -409,6 +425,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] 71+ messages in thread
* [PATCH v9 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (4 preceding siblings ...)
2014-01-10 17:30 ` [PATCH v9 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
2014-01-10 17:30 ` [PATCH v9 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, 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] 71+ messages in thread
* [PATCH v9 7/7] mmc: omap_hsmmc: remove pbias workaround
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (5 preceding siblings ...)
2014-01-10 17:30 ` [PATCH v9 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2014-01-10 17:30 ` Balaji T K
6 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-10 17:30 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: mark.rutland, Balaji T K
remove pbias workaround
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-01-09 14:50 ` [PATCH v8 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (7 preceding siblings ...)
2014-01-10 17:30 ` [PATCH v9 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
` (8 more replies)
8 siblings, 9 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: 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 | 27 ++
arch/arm/boot/dts/dra7.dtsi | 17 ++
arch/arm/boot/dts/omap2430.dtsi | 17 ++
arch/arm/boot/dts/omap3.dtsi | 17 ++
arch/arm/boot/dts/omap4.dtsi | 17 ++
arch/arm/boot/dts/omap5.dtsi | 17 ++
arch/arm/configs/omap2plus_defconfig | 2 +
drivers/mmc/host/omap_hsmmc.c | 111 +++++----
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
11 files changed, 441 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] 71+ messages in thread
* [PATCH v10 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
` (7 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: 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>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v10 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-13 15:36 ` [PATCH v10 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 3/7] regulator: add pbias regulator support Balaji T K
` (6 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: Balaji T K
handle vcc and vcc_aux independently to reduce indent.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH v10 3/7] regulator: add pbias regulator support
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-01-13 15:36 ` [PATCH v10 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2014-01-13 15:36 ` [PATCH v10 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
` (5 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: 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>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Mark Brown <broonie@linaro.org>
---
.../bindings/regulator/pbias-regulator.txt | 27 ++
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
4 files changed, 292 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..32aa26f
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,27 @@
+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.
+- reg: pbias register offset from syscon base and size of pbias register.
+- syscon : phandle of the system control module
+- regulator-name : should be
+ pbias_mmc_omap2430 for OMAP2430, OMAP3 SoCs
+ pbias_sim_omap3 for OMAP3 SoCs
+ pbias_mmc_omap4 for OMAP4 SoCs
+ pbias_mmc_omap5 for OMAP5 and DRA7 SoC
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
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..39518e0
--- /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;
+ unsigned int enable_time;
+ 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_omap2430 = {
+ .enable = BIT(1),
+ .enable_mask = BIT(1),
+ .vmode = BIT(0),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap2430"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+ .enable = BIT(9),
+ .enable_mask = BIT(9),
+ .vmode = BIT(8),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap5"
+};
+
+static struct of_regulator_match pbias_matches[] = {
+ { .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap2430},
+ { .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 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;
+ }
+
+ syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
+ 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;
+ drvdata[data_idx].desc.enable_time = info->enable_time;
+
+ 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] 71+ messages in thread
* [PATCH v10 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (2 preceding siblings ...)
2014-01-13 15:36 ` [PATCH v10 3/7] regulator: add pbias regulator support Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 5/7] ARM: dts: add pbias dt node Balaji T K
` (4 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: 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 | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..2287bda 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,27 @@ 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;
+ }
+ }
+
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 +375,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 +1844,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] 71+ messages in thread
* [PATCH v10 5/7] ARM: dts: add pbias dt node
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (3 preceding siblings ...)
2014-01-13 15:36 ` [PATCH v10 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-15 15:09 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
` (3 subsequent siblings)
8 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: Balaji T K
Add pbias regulator node as a child of system control
module - syscon.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/boot/dts/dra7.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap2430.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap3.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap4.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap5.dtsi | 17 +++++++++++++++++
5 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index d0df4c4..876c9b8 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -110,6 +110,22 @@
ti,hwmods = "counter_32k";
};
+ dra7_ctrl_general: tisyscon@4a002e00 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a002e00 0x7c>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&dra7_ctrl_general>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
dra7_pmx_core: pinmux@4a003400 {
compatible = "pinctrl-single";
reg = <0x4a003400 0x0464>;
@@ -485,6 +501,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..af71eb0 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,22 @@
pinctrl-single,function-mask = <0x3f>;
};
+ omap2_scm_general: tisyscon@49002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x49002270 0x240>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x230 0x4>;
+ syscon = <&omap2_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@4900c000 {
compatible = "ti,omap2-gpio";
reg = <0x4900c000 0x200>;
@@ -183,6 +199,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..b7828da 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -137,6 +137,22 @@
pinctrl-single,function-mask = <0xff1f>;
};
+ omap3_scm_general: tisyscon@48002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x48002270 0x2f0>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x2b0 0x4>;
+ syscon = <&omap3_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@48310000 {
compatible = "ti,omap3-gpio";
reg = <0x48310000 0x200>;
@@ -351,6 +367,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..9e19363 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -134,6 +134,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap4_padconf_global: tisyscon@4a1005a0 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a1005a0 0x170>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap4_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap4 {
+ regulator-name = "pbias_mmc_omap4";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -367,6 +383,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..f178899 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -130,6 +130,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap5_padconf_global: tisyscon@4a002da0 {
+ compatible = "syscon";
+ reg = <0x4A002da0 0xec>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -409,6 +425,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] 71+ messages in thread
* Re: [PATCH v10 5/7] ARM: dts: add pbias dt node
2014-01-13 15:36 ` [PATCH v10 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2014-01-15 15:09 ` Balaji T K
0 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-15 15:09 UTC (permalink / raw)
To: Balaji T K
Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
On Monday 13 January 2014 09:06 PM, Balaji T K wrote:
> Add pbias regulator node as a child of system control
> module - syscon.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> Acked-by: Tony Lindgren <tony@atomide.com>
Hi Benoit,
Gentle Ping, Let me know if you have any comments.
> ---
> arch/arm/boot/dts/dra7.dtsi | 17 +++++++++++++++++
> arch/arm/boot/dts/omap2430.dtsi | 17 +++++++++++++++++
> arch/arm/boot/dts/omap3.dtsi | 17 +++++++++++++++++
> arch/arm/boot/dts/omap4.dtsi | 17 +++++++++++++++++
> arch/arm/boot/dts/omap5.dtsi | 17 +++++++++++++++++
> 5 files changed, 85 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index d0df4c4..876c9b8 100644
> --- a/arch/arm/boot/dts/dra7.dtsi
> +++ b/arch/arm/boot/dts/dra7.dtsi
> @@ -110,6 +110,22 @@
> ti,hwmods = "counter_32k";
> };
>
> + dra7_ctrl_general: tisyscon@4a002e00 {
> + compatible = "syscon", "simple-bus";
> + reg = <0x4a002e00 0x7c>;
> + };
> +
> + pbias_regulator: pbias_regulator {
> + compatible = "ti,pbias-omap";
> + reg = <0 0x4>;
> + syscon = <&dra7_ctrl_general>;
> + pbias_mmc_reg: pbias_mmc_omap5 {
> + regulator-name = "pbias_mmc_omap5";
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <3000000>;
> + };
> + };
> +
> dra7_pmx_core: pinmux@4a003400 {
> compatible = "pinctrl-single";
> reg = <0x4a003400 0x0464>;
> @@ -485,6 +501,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..af71eb0 100644
> --- a/arch/arm/boot/dts/omap2430.dtsi
> +++ b/arch/arm/boot/dts/omap2430.dtsi
> @@ -29,6 +29,22 @@
> pinctrl-single,function-mask = <0x3f>;
> };
>
> + omap2_scm_general: tisyscon@49002270 {
> + compatible = "syscon", "simple-bus";
> + reg = <0x49002270 0x240>;
> + };
> +
> + pbias_regulator: pbias_regulator {
> + compatible = "ti,pbias-omap";
> + reg = <0x230 0x4>;
> + syscon = <&omap2_scm_general>;
> + pbias_mmc_reg: pbias_mmc_omap2430 {
> + regulator-name = "pbias_mmc_omap2430";
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <3000000>;
> + };
> + };
> +
> gpio1: gpio@4900c000 {
> compatible = "ti,omap2-gpio";
> reg = <0x4900c000 0x200>;
> @@ -183,6 +199,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..b7828da 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -137,6 +137,22 @@
> pinctrl-single,function-mask = <0xff1f>;
> };
>
> + omap3_scm_general: tisyscon@48002270 {
> + compatible = "syscon", "simple-bus";
> + reg = <0x48002270 0x2f0>;
> + };
> +
> + pbias_regulator: pbias_regulator {
> + compatible = "ti,pbias-omap";
> + reg = <0x2b0 0x4>;
> + syscon = <&omap3_scm_general>;
> + pbias_mmc_reg: pbias_mmc_omap2430 {
> + regulator-name = "pbias_mmc_omap2430";
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <3000000>;
> + };
> + };
> +
> gpio1: gpio@48310000 {
> compatible = "ti,omap3-gpio";
> reg = <0x48310000 0x200>;
> @@ -351,6 +367,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..9e19363 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -134,6 +134,22 @@
> pinctrl-single,function-mask = <0x7fff>;
> };
>
> + omap4_padconf_global: tisyscon@4a1005a0 {
> + compatible = "syscon", "simple-bus";
> + reg = <0x4a1005a0 0x170>;
> + };
> +
> + pbias_regulator: pbias_regulator {
> + compatible = "ti,pbias-omap";
> + reg = <0x60 0x4>;
> + syscon = <&omap4_padconf_global>;
> + pbias_mmc_reg: pbias_mmc_omap4 {
> + regulator-name = "pbias_mmc_omap4";
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <3000000>;
> + };
> + };
> +
> sdma: dma-controller@4a056000 {
> compatible = "ti,omap4430-sdma";
> reg = <0x4a056000 0x1000>;
> @@ -367,6 +383,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..f178899 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -130,6 +130,22 @@
> pinctrl-single,function-mask = <0x7fff>;
> };
>
> + omap5_padconf_global: tisyscon@4a002da0 {
> + compatible = "syscon";
> + reg = <0x4A002da0 0xec>;
> + };
> +
> + pbias_regulator: pbias_regulator {
> + compatible = "ti,pbias-omap";
> + reg = <0x60 0x4>;
> + syscon = <&omap5_padconf_global>;
> + pbias_mmc_reg: pbias_mmc_omap5 {
> + regulator-name = "pbias_mmc_omap5";
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <3000000>;
> + };
> + };
> +
> sdma: dma-controller@4a056000 {
> compatible = "ti,omap4430-sdma";
> reg = <0x4a056000 0x1000>;
> @@ -409,6 +425,7 @@
> ti,needs-special-reset;
> dmas = <&sdma 61>, <&sdma 62>;
> dma-names = "tx", "rx";
> + pbias-supply = <&pbias_mmc_reg>;
> };
>
> mmc2: mmc@480b4000 {
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* [PATCH v10 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (4 preceding siblings ...)
2014-01-13 15:36 ` [PATCH v10 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-01-13 15:36 ` [PATCH v10 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
` (2 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: 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] 71+ messages in thread
* [PATCH v10 7/7] mmc: omap_hsmmc: remove pbias workaround
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (5 preceding siblings ...)
2014-01-13 15:36 ` [PATCH v10 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2014-01-13 15:36 ` Balaji T K
2014-02-04 8:32 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-01-13 15:36 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie, tony
Cc: Balaji T K
remove pbias workaround
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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 2287bda..014bfe5 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);
@@ -1539,13 +1531,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
@@ -1878,10 +1864,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] 71+ messages in thread
* Re: [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (6 preceding siblings ...)
2014-01-13 15:36 ` [PATCH v10 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
@ 2014-02-04 8:32 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-04 8:32 UTC (permalink / raw)
To: Balaji T K, chris, tony
Cc: linux-omap, bcousson, devicetree, linux-mmc, broonie
On Monday 13 January 2014 09:06 PM, Balaji T K wrote:
> 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.
>
Hi Tony,
Considering the dependencies with regulator, defconfig, mmc and device tree,
Is it possible for you to pick this series.
Thanks and Regards,
Balaji T K
> 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 | 27 ++
> arch/arm/boot/dts/dra7.dtsi | 17 ++
> arch/arm/boot/dts/omap2430.dtsi | 17 ++
> arch/arm/boot/dts/omap3.dtsi | 17 ++
> arch/arm/boot/dts/omap4.dtsi | 17 ++
> arch/arm/boot/dts/omap5.dtsi | 17 ++
> arch/arm/configs/omap2plus_defconfig | 2 +
> drivers/mmc/host/omap_hsmmc.c | 111 +++++----
> drivers/regulator/Kconfig | 9 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
> 11 files changed, 441 insertions(+), 49 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
> create mode 100644 drivers/regulator/pbias-regulator.c
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-01-13 15:36 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
` (7 preceding siblings ...)
2014-02-04 8:32 ` [PATCH v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
` (8 more replies)
8 siblings, 9 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, 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 | 27 ++
arch/arm/boot/dts/dra7.dtsi | 17 ++
arch/arm/boot/dts/omap2430.dtsi | 17 ++
arch/arm/boot/dts/omap3.dtsi | 17 ++
arch/arm/boot/dts/omap4.dtsi | 17 ++
arch/arm/boot/dts/omap5.dtsi | 17 ++
arch/arm/configs/omap2plus_defconfig | 2 +
drivers/mmc/host/omap_hsmmc.c | 111 +++++----
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
11 files changed, 441 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] 71+ messages in thread
* [PATCH RESEND v11 1/7] mmc: omap_hsmmc: use devm_regulator API
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
` (7 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, 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>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH RESEND v11 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 3/7] regulator: add pbias regulator support Balaji T K
` (6 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, Balaji T K
handle vcc and vcc_aux independently to reduce indent.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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] 71+ messages in thread
* [PATCH RESEND v11 3/7] regulator: add pbias regulator support
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
` (5 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, 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>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Mark Brown <broonie@linaro.org>
---
.../bindings/regulator/pbias-regulator.txt | 27 ++
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
4 files changed, 292 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..32aa26f
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,27 @@
+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.
+- reg: pbias register offset from syscon base and size of pbias register.
+- syscon : phandle of the system control module
+- regulator-name : should be
+ pbias_mmc_omap2430 for OMAP2430, OMAP3 SoCs
+ pbias_sim_omap3 for OMAP3 SoCs
+ pbias_mmc_omap4 for OMAP4 SoCs
+ pbias_mmc_omap5 for OMAP5 and DRA7 SoC
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+Example:
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 6a79328..58f08d1 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -384,6 +384,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 979f9dd..001712e 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -54,6 +54,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..ded3b35
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,255 @@
+/*
+ * pbias-regulator.c
+ *
+ * Copyright (C) 2014 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;
+ unsigned int enable_time;
+ 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_omap2430 = {
+ .enable = BIT(1),
+ .enable_mask = BIT(1),
+ .vmode = BIT(0),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap2430"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+ .enable = BIT(9),
+ .enable_mask = BIT(9),
+ .vmode = BIT(8),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .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),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap5"
+};
+
+static struct of_regulator_match pbias_matches[] = {
+ { .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap2430},
+ { .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 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;
+ }
+
+ syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
+ 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;
+ drvdata[data_idx].desc.enable_time = info->enable_time;
+
+ 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] 71+ messages in thread
* [PATCH RESEND v11 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (2 preceding siblings ...)
2014-02-19 14:56 ` [PATCH RESEND v11 3/7] regulator: add pbias regulator support Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 5/7] ARM: dts: add pbias dt node Balaji T K
` (4 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, 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 | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..2287bda 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,27 @@ 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;
+ }
+ }
+
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 +375,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 +1844,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] 71+ messages in thread
* [PATCH RESEND v11 5/7] ARM: dts: add pbias dt node
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (3 preceding siblings ...)
2014-02-19 14:56 ` [PATCH RESEND v11 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-19 14:56 ` [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
` (3 subsequent siblings)
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, Balaji T K
Add pbias regulator node as a child of system control
module - syscon.
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/boot/dts/dra7.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap2430.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap3.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap4.dtsi | 17 +++++++++++++++++
arch/arm/boot/dts/omap5.dtsi | 17 +++++++++++++++++
5 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 1fd75aa..63750d9 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -149,6 +149,22 @@
ti,hwmods = "counter_32k";
};
+ dra7_ctrl_general: tisyscon@4a002e00 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a002e00 0x7c>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0 0x4>;
+ syscon = <&dra7_ctrl_general>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
dra7_pmx_core: pinmux@4a003400 {
compatible = "pinctrl-single";
reg = <0x4a003400 0x0464>;
@@ -524,6 +540,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..af71eb0 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,22 @@
pinctrl-single,function-mask = <0x3f>;
};
+ omap2_scm_general: tisyscon@49002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x49002270 0x240>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x230 0x4>;
+ syscon = <&omap2_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@4900c000 {
compatible = "ti,omap2-gpio";
reg = <0x4900c000 0x200>;
@@ -183,6 +199,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 a5fc83b..3726a64 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -176,6 +176,22 @@
pinctrl-single,function-mask = <0xff1f>;
};
+ omap3_scm_general: tisyscon@48002270 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x48002270 0x2f0>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x2b0 0x4>;
+ syscon = <&omap3_scm_general>;
+ pbias_mmc_reg: pbias_mmc_omap2430 {
+ regulator-name = "pbias_mmc_omap2430";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
gpio1: gpio@48310000 {
compatible = "ti,omap3-gpio";
reg = <0x48310000 0x200>;
@@ -390,6 +406,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 d3f8a6e..8e79064 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -186,6 +186,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap4_padconf_global: tisyscon@4a1005a0 {
+ compatible = "syscon", "simple-bus";
+ reg = <0x4a1005a0 0x170>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap4_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap4 {
+ regulator-name = "pbias_mmc_omap4";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -419,6 +435,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 a72813a..1f328ad 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -192,6 +192,22 @@
pinctrl-single,function-mask = <0x7fff>;
};
+ omap5_padconf_global: tisyscon@4a002da0 {
+ compatible = "syscon";
+ reg = <0x4A002da0 0xec>;
+ };
+
+ pbias_regulator: pbias_regulator {
+ compatible = "ti,pbias-omap";
+ reg = <0x60 0x4>;
+ syscon = <&omap5_padconf_global>;
+ pbias_mmc_reg: pbias_mmc_omap5 {
+ regulator-name = "pbias_mmc_omap5";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3000000>;
+ };
+ };
+
sdma: dma-controller@4a056000 {
compatible = "ti,omap4430-sdma";
reg = <0x4a056000 0x1000>;
@@ -471,6 +487,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] 71+ messages in thread
* [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (4 preceding siblings ...)
2014-02-19 14:56 ` [PATCH RESEND v11 5/7] ARM: dts: add pbias dt node Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-26 17:01 ` Tony Lindgren
2014-02-19 14:56 ` [PATCH RESEND v11 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
` (2 subsequent siblings)
8 siblings, 1 reply; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, 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 3a0b53d..e4fec1c 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] 71+ messages in thread
* Re: [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-02-19 14:56 ` [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2014-02-26 17:01 ` Tony Lindgren
2014-03-03 14:33 ` Balaji T K
0 siblings, 1 reply; 71+ messages in thread
From: Tony Lindgren @ 2014-02-26 17:01 UTC (permalink / raw)
To: Balaji T K; +Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie
* Balaji T K <balajitk@ti.com> [140219 07:00]:
> Enable REGULATOR_PBIAS needed for SD card on most OMAPs.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
I belive this is the only one missing my ack:
Acked-by: Tony Lindgren <tony@atomide.com>
Probably best that this all gets queued along with other MMC related
patches by Balaji and Chris.
> ---
> 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 3a0b53d..e4fec1c 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
>
> --
> 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] 71+ messages in thread
* Re: [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig
2014-02-26 17:01 ` Tony Lindgren
@ 2014-03-03 14:33 ` Balaji T K
0 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-03-03 14:33 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, broonie
On Wednesday 26 February 2014 10:31 PM, Tony Lindgren wrote:
> * Balaji T K <balajitk@ti.com> [140219 07:00]:
>> Enable REGULATOR_PBIAS needed for SD card on most OMAPs.
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>
> I belive this is the only one missing my ack:
>
> Acked-by: Tony Lindgren <tony@atomide.com>
>
Thanks Tony
> Probably best that this all gets queued along with other MMC related
> patches by Balaji and Chris.
Hi Chris,
Can you please pull this patch series for 3.15?
Thanks and Regards,
Balaji T K
>
>> ---
>> 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 3a0b53d..e4fec1c 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
>>
>> --
>> 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] 71+ messages in thread
* [PATCH RESEND v11 7/7] mmc: omap_hsmmc: remove pbias workaround
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (5 preceding siblings ...)
2014-02-19 14:56 ` [PATCH RESEND v11 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
@ 2014-02-19 14:56 ` Balaji T K
2014-02-26 8:51 ` [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Stefan Roese
2014-02-26 14:04 ` Florian Vaussard
8 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-19 14:56 UTC (permalink / raw)
To: linux-omap, bcousson, devicetree, linux-mmc, chris, tony
Cc: broonie, Balaji T K
remove pbias workaround
Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Tony Lindgren <tony@atomide.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 2287bda..014bfe5 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);
@@ -1539,13 +1531,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
@@ -1878,10 +1864,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] 71+ messages in thread
* Re: [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (6 preceding siblings ...)
2014-02-19 14:56 ` [PATCH RESEND v11 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
@ 2014-02-26 8:51 ` Stefan Roese
2014-02-26 14:04 ` Florian Vaussard
8 siblings, 0 replies; 71+ messages in thread
From: Stefan Roese @ 2014-02-26 8:51 UTC (permalink / raw)
To: Balaji T K, linux-omap, bcousson, devicetree, linux-mmc, chris,
tony
Cc: broonie
On 19.02.2014 15:56, Balaji T K wrote:
> 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 | 27 ++
> arch/arm/boot/dts/dra7.dtsi | 17 ++
> arch/arm/boot/dts/omap2430.dtsi | 17 ++
> arch/arm/boot/dts/omap3.dtsi | 17 ++
> arch/arm/boot/dts/omap4.dtsi | 17 ++
> arch/arm/boot/dts/omap5.dtsi | 17 ++
> arch/arm/configs/omap2plus_defconfig | 2 +
> drivers/mmc/host/omap_hsmmc.c | 111 +++++----
> drivers/regulator/Kconfig | 9 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
> 11 files changed, 441 insertions(+), 49 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
> create mode 100644 drivers/regulator/pbias-regulator.c
This patch series (its v11 even though this mail has the subject v10)
fixes problems I'm experiencing with MMC detection on some OMAP3 based
boards. So:
Tested-by: Stefan Roese <sr@denx.de>
Thanks,
Stefan
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-02-19 14:56 ` [PATCH RESEND " Balaji T K
` (7 preceding siblings ...)
2014-02-26 8:51 ` [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup Stefan Roese
@ 2014-02-26 14:04 ` Florian Vaussard
2014-02-26 14:43 ` Balaji T K
8 siblings, 1 reply; 71+ messages in thread
From: Florian Vaussard @ 2014-02-26 14:04 UTC (permalink / raw)
To: Balaji T K, linux-omap, bcousson, devicetree, linux-mmc, chris,
tony
Cc: broonie
Hi,
On 02/19/2014 03:56 PM, Balaji T K wrote:
> 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.
>
I tested on both OMAP3630 (Overo Storm) and OMAP4430 (DuoVero). The
rootfs is mounted on mmc1 and works as usual. Here is what I can see:
- pbias-supply is parsed from DT
- VMMC1 is set to 3V
- According to the debugfs entry, we are working at 3V signaling
- By dumping CONTROL_PBIASLITE, bit MMC1_PBIASLITE_VMODE
(PBIASLITEVMODE0 on OMAP3) is set to 1 (-> 3V)
Do you see any other tests that I could run to validate your patches?
Otherwise:
Tested-by: Florian Vaussard <florian.vaussard@epfl.ch>
> 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 | 27 ++
> arch/arm/boot/dts/dra7.dtsi | 17 ++
> arch/arm/boot/dts/omap2430.dtsi | 17 ++
> arch/arm/boot/dts/omap3.dtsi | 17 ++
> arch/arm/boot/dts/omap4.dtsi | 17 ++
> arch/arm/boot/dts/omap5.dtsi | 17 ++
> arch/arm/configs/omap2plus_defconfig | 2 +
> drivers/mmc/host/omap_hsmmc.c | 111 +++++----
> drivers/regulator/Kconfig | 9 +
> drivers/regulator/Makefile | 1 +
> drivers/regulator/pbias-regulator.c | 255 ++++++++++++++++++++
> 11 files changed, 441 insertions(+), 49 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/regulator/pbias-regulator.txt
> create mode 100644 drivers/regulator/pbias-regulator.c
>
^ permalink raw reply [flat|nested] 71+ messages in thread
* Re: [PATCH RESEND v10 0/7] mmc: omap_hsmmc: pbias dt and cleanup
2014-02-26 14:04 ` Florian Vaussard
@ 2014-02-26 14:43 ` Balaji T K
0 siblings, 0 replies; 71+ messages in thread
From: Balaji T K @ 2014-02-26 14:43 UTC (permalink / raw)
To: florian.vaussard
Cc: linux-omap, bcousson, devicetree, linux-mmc, chris, tony, broonie,
Stefan Roese
On Wednesday 26 February 2014 07:34 PM, Florian Vaussard wrote:
> Hi,
>
> On 02/19/2014 03:56 PM, Balaji T K wrote:
>> 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.
>>
>
> I tested on both OMAP3630 (Overo Storm) and OMAP4430 (DuoVero). The
> rootfs is mounted on mmc1 and works as usual. Here is what I can see:
>
> - pbias-supply is parsed from DT
> - VMMC1 is set to 3V
> - According to the debugfs entry, we are working at 3V signaling
> - By dumping CONTROL_PBIASLITE, bit MMC1_PBIASLITE_VMODE
> (PBIASLITEVMODE0 on OMAP3) is set to 1 (-> 3V)
>
> Do you see any other tests that I could run to validate your patches?
Nope, Stefan has tested the other use case of detecting sd card at kernel
without any sd card/pbias activity at u-boot.
> Otherwise:
>
> Tested-by: Florian Vaussard <florian.vaussard@epfl.ch>
>
Thanks Florian, Stefan for Testing.
^ permalink raw reply [flat|nested] 71+ messages in thread