Re: [U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-08-06 Thread Jaehoon Chung
Hi JJ,

On 08/04/2017 09:26 PM, Jean-Jacques Hiblot wrote:
> Hi Jaehoon,
> 
> 
> On 01/08/2017 06:23, Jaehoon Chung wrote:
>> Dear JJ,
>>
>> On 07/19/2017 10:52 PM, Jean-Jacques Hiblot wrote:
>>> In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
>>> IO cells. Without this bias voltage these I/O cells can not function
>>> properly. The PBIAS cell is controlled by software.
>>>
>>> Signed-off-by: Jean-Jacques Hiblot 
>>> Reviewed-by: Tom Rini 
>>> Reviewed-by: Simon Glass 
>>> ---
>>>
>>> changes since v1:
>>>   - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
>>> MMC_OMAP_HS are set
>>>   - use the dev_read_*() API to access the DT
>>>
>>>   drivers/mmc/Kconfig   |   1 +
>>>   drivers/power/regulator/Kconfig   |  10 +
>>>   drivers/power/regulator/Makefile  |   1 +
>>>   drivers/power/regulator/pbias_regulator.c | 302 
>>> ++
>>>   4 files changed, 314 insertions(+)
>>>   create mode 100644 drivers/power/regulator/pbias_regulator.c
>>>
>>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>>> index 588e118..63e1122 100644
>>> --- a/drivers/mmc/Kconfig
>>> +++ b/drivers/mmc/Kconfig
>>> @@ -158,6 +158,7 @@ config MMC_PCI
>>>   config MMC_OMAP_HS
>>>   bool "TI OMAP High Speed Multimedia Card Interface support"
>>>   select DM_MMC_OPS if DM_MMC
>>> +select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
>>>   help
>>> This selects the TI OMAP High Speed Multimedia card Interface.
>>> If you have an omap2plus board with a Multimedia Card slot,
>>> diff --git a/drivers/power/regulator/Kconfig 
>>> b/drivers/power/regulator/Kconfig
>>> index f213487..f4ed3cc 100644
>>> --- a/drivers/power/regulator/Kconfig
>>> +++ b/drivers/power/regulator/Kconfig
>>> @@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
>>>   features for REGULATOR PALMAS and the family of PALMAS PMICs.
>>>   The driver implements get/set api for: value and enable.
>>>   +config DM_REGULATOR_PBIAS
>>> +bool "Enable driver for PBIAS regulator"
>> pbias_regulator is using the regmap and syscon..
>> I think that i needs to select REGMAP and SYSCON at here.
>>
>> So i dropped the your patch from my repository.
>> Could you resend the patch? otherwise i will resend your patch after fixing.
>> let me know what you want.
> I won't be able to work on it before September. So I guess, it's better if 
> you can make the changes.

Sorry for reviewing late. If you resend the patch, i will pick this immediately.

Best Regards,
Jaehoon Chung

> Thank you,
> 
> jean-Jacques
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>> +---help---
>>> +This enables implementation of driver-model regulator uclass
>>> +features for pseudo-regulator PBIAS found in the OMAP SOCs.
>>> +This pseudo-regulator is used to provide a BIAS voltage to MMC1
>>> +signal pads and must be configured properly during a voltage switch.
>>> +Voltage switching is required by some operating modes of SDcards and
>>> +eMMC.
>>> +
>>>   config DM_REGULATOR_LP873X
>>>   bool "Enable driver for LP873X PMIC regulators"
>>>   depends on PMIC_LP873X
>>> diff --git a/drivers/power/regulator/Makefile 
>>> b/drivers/power/regulator/Makefile
>>> index ce14d08..75d611a 100644
>>> --- a/drivers/power/regulator/Makefile
>>> +++ b/drivers/power/regulator/Makefile
>>> @@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
>>>   obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
>>>   obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
>>>   obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
>>> +obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
>>>   obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
>>>   obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
>>> diff --git a/drivers/power/regulator/pbias_regulator.c 
>>> b/drivers/power/regulator/pbias_regulator.c
>>> new file mode 100644
>>> index 000..303eca9
>>> --- /dev/null
>>> +++ b/drivers/power/regulator/pbias_regulator.c
>>> @@ -0,0 +1,302 @@
>>> +/*
>>> + * (C) Copyright 2016 Texas Instruments Incorporated, 
>>> + * Jean-Jacques Hiblot 
>>> + *
>>> + * SPDX-License-Identifier:GPL-2.0+
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +DECLARE_GLOBAL_DATA_PTR;
>>> +
>>> +struct pbias_reg_info {
>>> +u32 enable;
>>> +u32 enable_mask;
>>> +u32 disable_val;
>>> +u32 vmode;
>>> +unsigned int enable_time;
>>> +char *name;
>>> +};
>>> +
>>> +struct pbias_priv {
>>> +struct regmap *regmap;
>>> +int offset;
>>> +};
>>> +
>>> +static const struct pmic_child_info pmic_children_info[] = {
>>> +{ .prefix = "pbias", .driver = "pbias_regulator"},
>>> +{ },
>>> +};
>>> +
>>> +static int 

Re: [U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-08-04 Thread Jean-Jacques Hiblot

Hi Jaehoon,


On 01/08/2017 06:23, Jaehoon Chung wrote:

Dear JJ,

On 07/19/2017 10:52 PM, Jean-Jacques Hiblot wrote:

In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
IO cells. Without this bias voltage these I/O cells can not function
properly. The PBIAS cell is controlled by software.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---

changes since v1:
  - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
MMC_OMAP_HS are set
  - use the dev_read_*() API to access the DT

  drivers/mmc/Kconfig   |   1 +
  drivers/power/regulator/Kconfig   |  10 +
  drivers/power/regulator/Makefile  |   1 +
  drivers/power/regulator/pbias_regulator.c | 302 ++
  4 files changed, 314 insertions(+)
  create mode 100644 drivers/power/regulator/pbias_regulator.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 588e118..63e1122 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -158,6 +158,7 @@ config MMC_PCI
  config MMC_OMAP_HS
bool "TI OMAP High Speed Multimedia Card Interface support"
select DM_MMC_OPS if DM_MMC
+   select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
help
  This selects the TI OMAP High Speed Multimedia card Interface.
  If you have an omap2plus board with a Multimedia Card slot,
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index f213487..f4ed3cc 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
features for REGULATOR PALMAS and the family of PALMAS PMICs.
The driver implements get/set api for: value and enable.
  
+config DM_REGULATOR_PBIAS

+   bool "Enable driver for PBIAS regulator"

pbias_regulator is using the regmap and syscon..
I think that i needs to select REGMAP and SYSCON at here.

So i dropped the your patch from my repository.
Could you resend the patch? otherwise i will resend your patch after fixing.
let me know what you want.
I won't be able to work on it before September. So I guess, it's better 
if you can make the changes.

Thank you,

jean-Jacques


Best Regards,
Jaehoon Chung


+   ---help---
+   This enables implementation of driver-model regulator uclass
+   features for pseudo-regulator PBIAS found in the OMAP SOCs.
+   This pseudo-regulator is used to provide a BIAS voltage to MMC1
+   signal pads and must be configured properly during a voltage switch.
+   Voltage switching is required by some operating modes of SDcards and
+   eMMC.
+
  config DM_REGULATOR_LP873X
bool "Enable driver for LP873X PMIC regulators"
  depends on PMIC_LP873X
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index ce14d08..75d611a 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
  obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
  obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
diff --git a/drivers/power/regulator/pbias_regulator.c 
b/drivers/power/regulator/pbias_regulator.c
new file mode 100644
index 000..303eca9
--- /dev/null
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -0,0 +1,302 @@
+/*
+ * (C) Copyright 2016 Texas Instruments Incorporated, 
+ * Jean-Jacques Hiblot 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct pbias_reg_info {
+   u32 enable;
+   u32 enable_mask;
+   u32 disable_val;
+   u32 vmode;
+   unsigned int enable_time;
+   char *name;
+};
+
+struct pbias_priv {
+   struct regmap *regmap;
+   int offset;
+};
+
+static const struct pmic_child_info pmic_children_info[] = {
+   { .prefix = "pbias", .driver = "pbias_regulator"},
+   { },
+};
+
+static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+   uint32_t val = *(uint32_t *)buff;
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_write(priv->regmap, priv->offset, val);
+}
+
+static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_read(priv->regmap, priv->offset, (uint32_t *)buff);
+}
+
+static 

Re: [U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-07-31 Thread Jaehoon Chung
Dear JJ,

On 07/19/2017 10:52 PM, Jean-Jacques Hiblot wrote:
> In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
> IO cells. Without this bias voltage these I/O cells can not function
> properly. The PBIAS cell is controlled by software.
> 
> Signed-off-by: Jean-Jacques Hiblot 
> Reviewed-by: Tom Rini 
> Reviewed-by: Simon Glass 
> ---
> 
> changes since v1:
>  - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
>MMC_OMAP_HS are set
>  - use the dev_read_*() API to access the DT
> 
>  drivers/mmc/Kconfig   |   1 +
>  drivers/power/regulator/Kconfig   |  10 +
>  drivers/power/regulator/Makefile  |   1 +
>  drivers/power/regulator/pbias_regulator.c | 302 
> ++
>  4 files changed, 314 insertions(+)
>  create mode 100644 drivers/power/regulator/pbias_regulator.c
> 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index 588e118..63e1122 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -158,6 +158,7 @@ config MMC_PCI
>  config MMC_OMAP_HS
>   bool "TI OMAP High Speed Multimedia Card Interface support"
>   select DM_MMC_OPS if DM_MMC
> + select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
>   help
> This selects the TI OMAP High Speed Multimedia card Interface.
> If you have an omap2plus board with a Multimedia Card slot,
> diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
> index f213487..f4ed3cc 100644
> --- a/drivers/power/regulator/Kconfig
> +++ b/drivers/power/regulator/Kconfig
> @@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
>   features for REGULATOR PALMAS and the family of PALMAS PMICs.
>   The driver implements get/set api for: value and enable.
>  
> +config DM_REGULATOR_PBIAS
> + bool "Enable driver for PBIAS regulator"

pbias_regulator is using the regmap and syscon..
I think that i needs to select REGMAP and SYSCON at here.

So i dropped the your patch from my repository.
Could you resend the patch? otherwise i will resend your patch after fixing.
let me know what you want.

Best Regards,
Jaehoon Chung

> + ---help---
> + This enables implementation of driver-model regulator uclass
> + features for pseudo-regulator PBIAS found in the OMAP SOCs.
> + This pseudo-regulator is used to provide a BIAS voltage to MMC1
> + signal pads and must be configured properly during a voltage switch.
> + Voltage switching is required by some operating modes of SDcards and
> + eMMC.
> +
>  config DM_REGULATOR_LP873X
>   bool "Enable driver for LP873X PMIC regulators"
>  depends on PMIC_LP873X
> diff --git a/drivers/power/regulator/Makefile 
> b/drivers/power/regulator/Makefile
> index ce14d08..75d611a 100644
> --- a/drivers/power/regulator/Makefile
> +++ b/drivers/power/regulator/Makefile
> @@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
>  obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
>  obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
> +obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
> diff --git a/drivers/power/regulator/pbias_regulator.c 
> b/drivers/power/regulator/pbias_regulator.c
> new file mode 100644
> index 000..303eca9
> --- /dev/null
> +++ b/drivers/power/regulator/pbias_regulator.c
> @@ -0,0 +1,302 @@
> +/*
> + * (C) Copyright 2016 Texas Instruments Incorporated, 
> + * Jean-Jacques Hiblot 
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct pbias_reg_info {
> + u32 enable;
> + u32 enable_mask;
> + u32 disable_val;
> + u32 vmode;
> + unsigned int enable_time;
> + char *name;
> +};
> +
> +struct pbias_priv {
> + struct regmap *regmap;
> + int offset;
> +};
> +
> +static const struct pmic_child_info pmic_children_info[] = {
> + { .prefix = "pbias", .driver = "pbias_regulator"},
> + { },
> +};
> +
> +static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
> +   int len)
> +{
> + struct pbias_priv *priv = dev_get_priv(dev);
> + uint32_t val = *(uint32_t *)buff;
> +
> + if (len != 4)
> + return -EINVAL;
> +
> + return regmap_write(priv->regmap, priv->offset, val);
> +}
> +
> +static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
> +{
> + struct pbias_priv *priv = dev_get_priv(dev);
> +
> + if (len != 4)
> + return -EINVAL;
> +
> + return regmap_read(priv->regmap, priv->offset, (uint32_t *)buff);
> +}
> +
> +static int 

[U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-07-19 Thread Jean-Jacques Hiblot
In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
IO cells. Without this bias voltage these I/O cells can not function
properly. The PBIAS cell is controlled by software.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---

changes since v1:
 - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
   MMC_OMAP_HS are set
 - use the dev_read_*() API to access the DT

 drivers/mmc/Kconfig   |   1 +
 drivers/power/regulator/Kconfig   |  10 +
 drivers/power/regulator/Makefile  |   1 +
 drivers/power/regulator/pbias_regulator.c | 302 ++
 4 files changed, 314 insertions(+)
 create mode 100644 drivers/power/regulator/pbias_regulator.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 588e118..63e1122 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -158,6 +158,7 @@ config MMC_PCI
 config MMC_OMAP_HS
bool "TI OMAP High Speed Multimedia Card Interface support"
select DM_MMC_OPS if DM_MMC
+   select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
help
  This selects the TI OMAP High Speed Multimedia card Interface.
  If you have an omap2plus board with a Multimedia Card slot,
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index f213487..f4ed3cc 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
features for REGULATOR PALMAS and the family of PALMAS PMICs.
The driver implements get/set api for: value and enable.
 
+config DM_REGULATOR_PBIAS
+   bool "Enable driver for PBIAS regulator"
+   ---help---
+   This enables implementation of driver-model regulator uclass
+   features for pseudo-regulator PBIAS found in the OMAP SOCs.
+   This pseudo-regulator is used to provide a BIAS voltage to MMC1
+   signal pads and must be configured properly during a voltage switch.
+   Voltage switching is required by some operating modes of SDcards and
+   eMMC.
+
 config DM_REGULATOR_LP873X
bool "Enable driver for LP873X PMIC regulators"
 depends on PMIC_LP873X
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index ce14d08..75d611a 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
 obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
diff --git a/drivers/power/regulator/pbias_regulator.c 
b/drivers/power/regulator/pbias_regulator.c
new file mode 100644
index 000..303eca9
--- /dev/null
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -0,0 +1,302 @@
+/*
+ * (C) Copyright 2016 Texas Instruments Incorporated, 
+ * Jean-Jacques Hiblot 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct pbias_reg_info {
+   u32 enable;
+   u32 enable_mask;
+   u32 disable_val;
+   u32 vmode;
+   unsigned int enable_time;
+   char *name;
+};
+
+struct pbias_priv {
+   struct regmap *regmap;
+   int offset;
+};
+
+static const struct pmic_child_info pmic_children_info[] = {
+   { .prefix = "pbias", .driver = "pbias_regulator"},
+   { },
+};
+
+static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+   uint32_t val = *(uint32_t *)buff;
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_write(priv->regmap, priv->offset, val);
+}
+
+static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_read(priv->regmap, priv->offset, (uint32_t *)buff);
+}
+
+static int pbias_ofdata_to_platdata(struct udevice *dev)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+   struct udevice *syscon;
+   struct regmap *regmap;
+   struct resource res;
+   int err;
+
+   err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
+  "syscon", );
+   if (err) {
+   error("%s: unable to find syscon device (%d)\n", __func__,
+ err);
+   return err;
+   }
+
+   regmap = syscon_get_regmap(syscon);
+   if