All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS
@ 2019-01-24 20:33 Adam Ford
  2019-01-25 12:12 ` Jean-Jacques Hiblot
  2019-02-03  1:09 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Adam Ford @ 2019-01-24 20:33 UTC (permalink / raw)
  To: u-boot

The OMAP36 and DM37 TRM state to disable extneded drain IO before
changing the PBIAS.  This patch does this before pmic writes if
the CONFIG_MMC_OMAP36XX_PINS flag is set and the cpu family is
omap36xx

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
index 366f97b38b..4ed3c94e03 100644
--- a/drivers/power/regulator/pbias_regulator.c
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -14,6 +14,11 @@
 #include <linux/bitops.h>
 #include <linux/ioport.h>
 #include <dm/read.h>
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+#include <asm/arch/sys_proto.h>
+#include <asm/io.h>
+#include <asm/arch/mux.h>
+#endif
 
 struct pbias_reg_info {
 	u32 enable;
@@ -223,8 +228,11 @@ static int pbias_regulator_get_value(struct udevice *dev)
 static int pbias_regulator_set_value(struct udevice *dev, int uV)
 {
 	const struct pbias_reg_info *p = dev_get_priv(dev);
-	int rc;
+	int rc, ret;
 	u32 reg;
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	u32 wkup_ctrl = readl(OMAP34XX_CTRL_WKUP_CTRL);
+#endif
 
 	rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
 	if (rc)
@@ -240,7 +248,23 @@ static int pbias_regulator_set_value(struct udevice *dev, int uV)
 	debug("Setting %s voltage to %s\n", p->name,
 	      (reg & p->vmode) ? "3.0v" : "1.8v");
 
-	return pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	if (get_cpu_family() == CPU_OMAP36XX) {
+		/* Disable extended drain IO before changing PBIAS */
+		wkup_ctrl &= ~OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ;
+		writel(wkup_ctrl, OMAP34XX_CTRL_WKUP_CTRL);
+	}
+#endif
+	ret = pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	if (get_cpu_family() == CPU_OMAP36XX) {
+		/* Enable extended drain IO after changing PBIAS */
+		writel(wkup_ctrl |
+				OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ,
+				OMAP34XX_CTRL_WKUP_CTRL);
+	}
+#endif
+	return ret;
 }
 
 static int pbias_regulator_get_enable(struct udevice *dev)
@@ -264,9 +288,20 @@ static int pbias_regulator_set_enable(struct udevice *dev, bool enable)
 	const struct pbias_reg_info *p = dev_get_priv(dev);
 	int rc;
 	u32 reg;
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	u32 wkup_ctrl = readl(OMAP34XX_CTRL_WKUP_CTRL);
+#endif
 
 	debug("Turning %s %s\n", enable ? "on" : "off", p->name);
 
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	if (get_cpu_family() == CPU_OMAP36XX) {
+		/* Disable extended drain IO before changing PBIAS */
+		wkup_ctrl &= ~OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ;
+		writel(wkup_ctrl, OMAP34XX_CTRL_WKUP_CTRL);
+	}
+#endif
+
 	rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
 	if (rc)
 		return rc;
@@ -278,6 +313,16 @@ static int pbias_regulator_set_enable(struct udevice *dev, bool enable)
 		reg |= p->disable_val;
 
 	rc = pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+
+#ifdef CONFIG_MMC_OMAP36XX_PINS
+	if (get_cpu_family() == CPU_OMAP36XX) {
+		/* Enable extended drain IO after changing PBIAS */
+		writel(wkup_ctrl |
+				OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ,
+				OMAP34XX_CTRL_WKUP_CTRL);
+	}
+#endif
+
 	if (rc)
 		return rc;
 
-- 
2.17.1

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

* [U-Boot] [PATCH] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS
  2019-01-24 20:33 [U-Boot] [PATCH] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS Adam Ford
@ 2019-01-25 12:12 ` Jean-Jacques Hiblot
  2019-02-03  1:09 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Jean-Jacques Hiblot @ 2019-01-25 12:12 UTC (permalink / raw)
  To: u-boot

Hi Adam,

On 24/01/2019 21:33, Adam Ford wrote:
> The OMAP36 and DM37 TRM state to disable extneded drain IO before
> changing the PBIAS.  This patch does this before pmic writes if
> the CONFIG_MMC_OMAP36XX_PINS flag is set and the cpu family is
> omap36xx

I believe things could be done without all the #ifdef, in a more dynamic 
way.

>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
> diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
> index 366f97b38b..4ed3c94e03 100644
> --- a/drivers/power/regulator/pbias_regulator.c
> +++ b/drivers/power/regulator/pbias_regulator.c
> @@ -14,6 +14,11 @@
>   #include <linux/bitops.h>
>   #include <linux/ioport.h>
>   #include <dm/read.h>
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +#include <asm/arch/sys_proto.h>
> +#include <asm/io.h>
> +#include <asm/arch/mux.h>
> +#endif
>   
>   struct pbias_reg_info {
>   	u32 enable;
> @@ -223,8 +228,11 @@ static int pbias_regulator_get_value(struct udevice *dev)
>   static int pbias_regulator_set_value(struct udevice *dev, int uV)
>   {
>   	const struct pbias_reg_info *p = dev_get_priv(dev);
> -	int rc;
> +	int rc, ret;
>   	u32 reg;
> +#ifdef CONFIG_MMC_OMAP36XX_PINS

> +	u32 wkup_ctrl = readl(OMAP34XX_CTRL_WKUP_CTRL);

Could usage of OMAP34XX_CTRL_WKUP_CTRLbe removed and replaced by 
something coming from DT ?

JJ

> +#endif
>   
>   	rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
>   	if (rc)
> @@ -240,7 +248,23 @@ static int pbias_regulator_set_value(struct udevice *dev, int uV)
>   	debug("Setting %s voltage to %s\n", p->name,
>   	      (reg & p->vmode) ? "3.0v" : "1.8v");
>   
> -	return pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +	if (get_cpu_family() == CPU_OMAP36XX) {
> +		/* Disable extended drain IO before changing PBIAS */
> +		wkup_ctrl &= ~OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ;
> +		writel(wkup_ctrl, OMAP34XX_CTRL_WKUP_CTRL);
> +	}
> +#endif
> +	ret = pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +	if (get_cpu_family() == CPU_OMAP36XX) {
> +		/* Enable extended drain IO after changing PBIAS */
> +		writel(wkup_ctrl |
> +				OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ,
> +				OMAP34XX_CTRL_WKUP_CTRL);
> +	}
> +#endif
> +	return ret;
>   }
>   
>   static int pbias_regulator_get_enable(struct udevice *dev)
> @@ -264,9 +288,20 @@ static int pbias_regulator_set_enable(struct udevice *dev, bool enable)
>   	const struct pbias_reg_info *p = dev_get_priv(dev);
>   	int rc;
>   	u32 reg;
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +	u32 wkup_ctrl = readl(OMAP34XX_CTRL_WKUP_CTRL);
> +#endif
>   
>   	debug("Turning %s %s\n", enable ? "on" : "off", p->name);
>   
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +	if (get_cpu_family() == CPU_OMAP36XX) {
> +		/* Disable extended drain IO before changing PBIAS */
> +		wkup_ctrl &= ~OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ;
> +		writel(wkup_ctrl, OMAP34XX_CTRL_WKUP_CTRL);
> +	}
> +#endif
> +
>   	rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
>   	if (rc)
>   		return rc;
> @@ -278,6 +313,16 @@ static int pbias_regulator_set_enable(struct udevice *dev, bool enable)
>   		reg |= p->disable_val;
>   
>   	rc = pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
> +
> +#ifdef CONFIG_MMC_OMAP36XX_PINS
> +	if (get_cpu_family() == CPU_OMAP36XX) {
> +		/* Enable extended drain IO after changing PBIAS */
> +		writel(wkup_ctrl |
> +				OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ,
> +				OMAP34XX_CTRL_WKUP_CTRL);
> +	}
> +#endif
> +
>   	if (rc)
>   		return rc;
>   

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

* [U-Boot] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS
  2019-01-24 20:33 [U-Boot] [PATCH] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS Adam Ford
  2019-01-25 12:12 ` Jean-Jacques Hiblot
@ 2019-02-03  1:09 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2019-02-03  1:09 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 24, 2019 at 02:33:36PM -0600, Adam Ford wrote:

> The OMAP36 and DM37 TRM state to disable extneded drain IO before
> changing the PBIAS.  This patch does this before pmic writes if
> the CONFIG_MMC_OMAP36XX_PINS flag is set and the cpu family is
> omap36xx
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
> index 366f97b38b..4ed3c94e03 100644

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190202/7b37c56e/attachment.sig>

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

end of thread, other threads:[~2019-02-03  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 20:33 [U-Boot] [PATCH] regulator: pbias: Handle extended drain IO when changing omap36 PBIAS Adam Ford
2019-01-25 12:12 ` Jean-Jacques Hiblot
2019-02-03  1:09 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.