Re: [PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Jean-Christophe PLAGNIOL-VILLARD
On 13:45 Wed 07 Mar , Mark Brown wrote:
> On Wed, Mar 07, 2012 at 02:22:25PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
> wrote:
> 
> > > +- compatible: Must be "fsl,anatop-regulator"
> > > +- vol-bit-shift: Bit shift for the register
> > > +- vol-bit-width: Number of bits used in the register
> > > +- min-bit-val: Minimum value of this register
> > > +- min-voltage: Minimum voltage of this regulator
> > > +- max-voltage: Maximum voltage of this regulator
> 
> > specific properites need to be prefix by the vendor
> 
> This really doesn't seem at all sane for a device which is already
> vendor specific, it's just noise in the bindings.
No it's
Here is a good example as we have regulator generic binding & vendor
specific bindig

Best Regards,
J.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Jean-Christophe PLAGNIOL-VILLARD
On 21:24 Wed 07 Mar , Ying-Chun Liu (PaulLiu) wrote:
> From: "Ying-Chun Liu (PaulLiu)" 
> 
> Anatop is an integrated regulator inside i.MX6 SoC.
> There are 3 digital regulators which controls PU, CORE (ARM), and SOC.
> And 3 analog regulators which controls 1P1, 2P5, 3P0 (USB).
> This patch adds the Anatop regulator driver.
> 
> Signed-off-by: Nancy Chen 
> Signed-off-by: Ying-Chun Liu (PaulLiu) 
> Acked-by: Shawn Guo 
> Cc: Mark Brown 
> Cc: Liam Girdwood 
> Cc: Samuel Ortiz 
> ---
>  .../bindings/regulator/anatop-regulator.txt|   28 +++
>  drivers/regulator/Kconfig  |8 +
>  drivers/regulator/Makefile |1 +
>  drivers/regulator/anatop-regulator.c   |  231 
> 
>  4 files changed, 268 insertions(+), 0 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/regulator/anatop-regulator.txt
>  create mode 100644 drivers/regulator/anatop-regulator.c
> 
> diff --git a/Documentation/devicetree/bindings/regulator/anatop-regulator.txt 
> b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
> new file mode 100644
> index 000..500463e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
> @@ -0,0 +1,28 @@
> +Anatop Voltage regulators
> +
> +Required properties:
> +- compatible: Must be "fsl,anatop-regulator"
> +- vol-bit-shift: Bit shift for the register
> +- vol-bit-width: Number of bits used in the register
> +- min-bit-val: Minimum value of this register
> +- min-voltage: Minimum voltage of this regulator
> +- max-voltage: Maximum voltage of this regulator
specific properites need to be prefix by the vendor

Best Regards,
J.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Mark Brown
On Wed, Mar 07, 2012 at 04:36:22PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:

> > This really doesn't seem at all sane for a device which is already
> > vendor specific, it's just noise in the bindings.

> No it's

...?

> Here is a good example as we have regulator generic binding & vendor
> specific bindig

It's not vendor specific, it's device specific and people are doing it
even for devices with no generic bindings at all which is particularly
silly.

Device specific prefixes probably make sense, but vendor specific ones
are just noise.


signature.asc
Description: Digital signature
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Mark Brown
On Wed, Mar 07, 2012 at 02:22:25PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:

> > +- compatible: Must be "fsl,anatop-regulator"
> > +- vol-bit-shift: Bit shift for the register
> > +- vol-bit-width: Number of bits used in the register
> > +- min-bit-val: Minimum value of this register
> > +- min-voltage: Minimum voltage of this regulator
> > +- max-voltage: Maximum voltage of this regulator

> specific properites need to be prefix by the vendor

This really doesn't seem at all sane for a device which is already
vendor specific, it's just noise in the bindings.


signature.asc
Description: Digital signature
___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Ying-Chun Liu (PaulLiu)
From: "Ying-Chun Liu (PaulLiu)" 

Anatop is an integrated regulator inside i.MX6 SoC.
There are 3 digital regulators which controls PU, CORE (ARM), and SOC.
And 3 analog regulators which controls 1P1, 2P5, 3P0 (USB).
This patch adds the Anatop regulator driver.

Signed-off-by: Nancy Chen 
Signed-off-by: Ying-Chun Liu (PaulLiu) 
Acked-by: Shawn Guo 
Cc: Mark Brown 
Cc: Liam Girdwood 
Cc: Samuel Ortiz 
---
 .../bindings/regulator/anatop-regulator.txt|   28 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  231 
 4 files changed, 268 insertions(+), 0 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/anatop-regulator.txt
 create mode 100644 drivers/regulator/anatop-regulator.c

diff --git a/Documentation/devicetree/bindings/regulator/anatop-regulator.txt 
b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
new file mode 100644
index 000..500463e
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
@@ -0,0 +1,28 @@
+Anatop Voltage regulators
+
+Required properties:
+- compatible: Must be "fsl,anatop-regulator"
+- vol-bit-shift: Bit shift for the register
+- vol-bit-width: Number of bits used in the register
+- min-bit-val: Minimum value of this register
+- min-voltage: Minimum voltage of this regulator
+- max-voltage: Maximum voltage of this regulator
+
+Any property defined as part of the core regulator
+binding, defined in regulator.txt, can also be used.
+
+Example:
+
+   reg_vddpu: regulator-vddpu@140 {
+   compatible = "fsl,anatop-regulator";
+   regulator-name = "vddpu";
+   regulator-min-microvolt = <725000>;
+   regulator-max-microvolt = <130>;
+   regulator-always-on;
+   reg = <0x140>;
+   vol-bit-shift = <9>;
+   vol-bit-width = <5>;
+   min-bit-val = <1>;
+   min-voltage = <725000>;
+   max-voltage = <130>;
+   };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 7a61b17..5366991 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -335,5 +335,13 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate "Freescale i.MX on-chip ANATOP LDO regulators"
+   depends on MFD_ANATOP
+   help
+ Say y here to support Freescale i.MX on-chip ANATOP LDOs
+ regulators. It is recommended that this option be
+ enabled on i.MX6 platform.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 503bac8..8440871 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -48,5 +48,6 @@ obj-$(CONFIG_REGULATOR_AB8500)+= ab8500.o
 obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
 obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
+obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/anatop-regulator.c 
b/drivers/regulator/anatop-regulator.c
new file mode 100644
index 000..1e20690
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct anatop_regulator {
+   const char *name;
+   u32 control_reg;
+   struct anatop *mfd;
+   int vol_bit_shift;
+   int vol_bit_width;
+   int min_bit_val;
+   int min_voltage;
+   int max_voltage;
+   struct regulator_desc rdesc;
+   struct regulator_init_data *initdata;
+};
+
+static int anatop_set_voltage(struct regulator_dev *reg, int min_uV,
+ int max_uV, unsigned *selector)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+   u32 val, sel;
+   int uv;
+
+   uv = min_uV;
+