Re: [PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support

2012-07-05 Thread Ying-Chun Liu (PaulLiu)
(2012年07月04日 21:44), Shawn Guo wrote:
 On 4 July 2012 15:37, Uwe Kleine-König u.kleine-koe...@pengutronix.de wrote:
 I want to push that forward. What is the state of these patches on your
 end? Did you start to address the comments? Are there more recent
 patches than the ones in this thread?

 Whatever you might have it would be great if you could share it to help
 preventing duplicate efforts.

 As far as I know, Paul hasn't been on that effort any more.
 
 Copied his another email address.
 
 Regards,
 Shawn

Hi,

Sorry, forget to mention about this.
We have a patch for the DTS corresponding to this patch.

From f3d28445de908bf2a848f6e8104b5c7f347ecd64 Mon Sep 17 00:00:00 2001
From: Ying-Chun Liu (PaulLiu) paul@linaro.org
Date: Thu, 19 Apr 2012 15:24:10 +0800
Subject: [PATCH] arm: imx53-qsb: Add Ripley driver DT nodes

This patch adds the ripley driver and regulators.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 arch/arm/boot/dts/imx53-qsb.dts |  104
+++
 1 file changed, 104 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-qsb.dts
b/arch/arm/boot/dts/imx53-qsb.dts
index 5c57c86..c95bad7 100644
--- a/arch/arm/boot/dts/imx53-qsb.dts
+++ b/arch/arm/boot/dts/imx53-qsb.dts
@@ -80,6 +80,110 @@
compatible = dialog,da9053, 
dialog,da9052;
reg = 0x48;
};
+
+   ripley@8 {
+   compatible = fsl,mc34708;
+   reg = 0x08;
+   regulators {
+   mc34708__sw1a {
+   regulator-name = SW1;
+   regulator-min-microvolt 
= 65;
+   regulator-max-microvolt 
= 1437500;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   mc34708__sw1b {
+   regulator-name = SW1B;
+   regulator-min-microvolt 
= 65;
+   regulator-max-microvolt 
= 1437500;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   mc34708__sw2 {
+   regulator-name = SW2;
+   regulator-min-microvolt 
= 65;
+   regulator-max-microvolt 
= 1437500;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   mc34708__sw3 {
+   regulator-name = SW3;
+   regulator-min-microvolt 
= 65;
+   regulator-max-microvolt 
= 1425000;
+   regulator-boot-on;
+   };
+   mc34708__sw4a {
+   regulator-name = SW4A;
+   regulator-min-microvolt 
= 120;
+   regulator-max-microvolt 
= 330;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   mc34708__sw4b {
+   regulator-name = SW4B;
+   regulator-min-microvolt 
= 120;
+   regulator-max-microvolt 
= 330;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   mc34708__sw5 {
+   regulator-name = SW5;
+   regulator-min-microvolt 
= 120

Re: [PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support

2012-07-04 Thread Ying-Chun Liu (PaulLiu)
(2012年07月04日 21:44), Shawn Guo wrote:
 On 4 July 2012 15:37, Uwe Kleine-König u.kleine-koe...@pengutronix.de wrote:
 I want to push that forward. What is the state of these patches on your
 end? Did you start to address the comments? Are there more recent
 patches than the ones in this thread?

 Whatever you might have it would be great if you could share it to help
 preventing duplicate efforts.

 As far as I know, Paul hasn't been on that effort any more.
 
 Copied his another email address.
 
 Regards,
 Shawn

Hi Uwe,

Please take it over.
I don't have much time left to work on this patch.
I don't have a new version of this driver either.

Many Thanks,
Paul

-- 
PaulLiu (劉穎駿)
E-mail: Ying-Chun Liu (PaulLiu) paul...@debian.org



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


[PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support

2012-04-19 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Freescale MC34708 is a PMIC which supports the following features:
 * 6 multi-mode buck regulators
 * Boost regulator for USB OTG.
 * 8 regulators for thermal budget optimization
 * 10-bit ADC
 * Real time clock

Signed-off-by: Robin Gong b38...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
---
 Documentation/devicetree/bindings/mfd/mc34708.txt |   61 ++
 drivers/mfd/Kconfig   |   11 +
 drivers/mfd/Makefile  |1 +
 drivers/mfd/mc34708-core.c|  634 +
 include/linux/mfd/mc34708.h   |  134 +
 5 files changed, 841 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mc34708.txt
 create mode 100644 drivers/mfd/mc34708-core.c
 create mode 100644 include/linux/mfd/mc34708.h

diff --git a/Documentation/devicetree/bindings/mfd/mc34708.txt 
b/Documentation/devicetree/bindings/mfd/mc34708.txt
new file mode 100644
index 000..2bb5c9e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/mc34708.txt
@@ -0,0 +1,61 @@
+* Freescale MC34708 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Must be fsl,mc34708
+
+Optional properties:
+- fsl,mc34708-uses-adc   : Indicate the ADC is being used
+- fsl,mc34708-uses-rtc   : Indicate the RTC is being used
+- fsl,mc34708-uses-ts: Indicate the touchscreen controller is being used
+
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The MC34708 regulators are
+  bound using their names as listed below for enabling.
+
+mc34708__sw1a: regulator SW1A
+mc34708__sw1b: regulator SW1B
+mc34708__sw2 : regulator SW2
+mc34708__sw3 : regulator SW3
+mc34708__sw4A: regulator SW4A
+mc34708__sw4b: regulator SW4B
+mc34708__swbst   : regulator SWBST
+mc34708__vpll: regulator VPLL
+mc34708__vrefddr : regulator VREFDDR
+mc34708__vusb: regulator VUSB
+mc34708__vusb2   : regulator VUSB2
+mc34708__vdac: regulator VDAC
+mc34708__vgen1   : regulator VGEN1
+mc34708__vgen2   : regulator VGEN2
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+i2c@63fc8000 {
+   #address-cells = 1;
+   #size-cells = 0;
+   compatible = fsl,imx53-i2c, fsl,imx1-i2c;
+   reg = 0x63fc8000 0x4000;
+   interrupts = 62;
+   status = okay;
+
+   pmic: mc34708@8 {
+   compatible = fsl,mc34708;
+   reg = 0x08;
+
+   regulators {
+   mc34708__sw1a {
+   regulator-min-microvolt = 65;
+   regulator-max-microvolt = 1437500;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   mc34708__vusb {
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   };
+   };
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 29f463c..17b6cc5 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -600,6 +600,17 @@ config MFD_MC13XXX
  additional drivers must be enabled in order to use the
  functionality of the device.
 
+config MFD_MC34708
+   tristate Support for Freescale's PMIC MC34708
+   depends on I2C
+   depends on OF
+   select MFD_CORE
+   help
+ Support for the Freescale's PMIC MC34708
+ This driver provides common support for accessing the device,
+ additional drivers must be enabled in order to use the
+ functionality of the device.
+
 config ABX500_CORE
bool ST-Ericsson ABX500 Mixed Signal Circuit register functions
default y if ARCH_U300 || ARCH_U8500
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 05fa538..b98d943 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_TWL6030_PWM) += twl6030-pwm.o
 obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o twl6040-irq.o
 
 obj-$(CONFIG_MFD_MC13XXX)  += mc13xxx-core.o
+obj-$(CONFIG_MFD_MC34708)   += mc34708-core.o
 
 obj-$(CONFIG_MFD_CORE) += mfd-core.o
 
diff --git a/drivers/mfd/mc34708-core.c b/drivers/mfd/mc34708-core.c
new file mode 100644
index 000..54f469b
--- /dev/null
+++ b/drivers/mfd/mc34708-core.c
@@ -0,0 +1,634 @@
+/*
+ * 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

[PATCH 2/2] regulator: Add Freescale's MC34708 regulators

2012-04-19 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds the support of MC34708 regulators.

Signed-off-by: Robin Gong b38...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Liam Girdwood l...@ti.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
---
 drivers/regulator/Kconfig |7 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/mc34708-regulator.c |  729 +
 drivers/regulator/mc34708.h   |   79 
 4 files changed, 816 insertions(+)
 create mode 100644 drivers/regulator/mc34708-regulator.c
 create mode 100644 drivers/regulator/mc34708.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 36db5a4..ca63e7f 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -129,6 +129,13 @@ config REGULATOR_MC13892
  Say y here to support the regulators found on the Freescale MC13892
  PMIC.
 
+config REGULATOR_MC34708
+   tristate Freescale MC34708 regulator driver
+   depends on MFD_MC34708
+   help
+ Say y here to support the regulators found on the Freescale MC34708
+ PMIC.
+
 config REGULATOR_ISL6271A
tristate Intersil ISL6271A Power regulator
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 94b5274..435fb6b 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
 obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
+obj-$(CONFIG_REGULATOR_MC34708) += mc34708-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
diff --git a/drivers/regulator/mc34708-regulator.c 
b/drivers/regulator/mc34708-regulator.c
new file mode 100644
index 000..d306e6e
--- /dev/null
+++ b/drivers/regulator/mc34708-regulator.c
@@ -0,0 +1,729 @@
+/*
+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/mfd/mc34708.h
+#include linux/regulator/machine.h
+#include linux/regulator/driver.h
+#include linux/platform_device.h
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/init.h
+#include linux/err.h
+#include linux/regulator/of_regulator.h
+#include linux/of.h
+#include mc34708.h
+
+static const int mc34708_sw1A[] = {
+   65, 662500, 675000, 687500, 70, 712500,
+   725000, 737500, 75, 762500, 775000, 787500,
+   80, 812500, 825000, 837500, 85, 862500,
+   875000, 887500, 90, 912500, 925000, 937500,
+   95, 962500, 975000, 987500, 100, 1012500,
+   1025000, 1037500, 105, 1062500, 1075000, 1087500,
+   110, 1112500, 1125000, 1137500, 115, 1162500,
+   1175000, 1187500, 120, 1212500, 1225000, 1237500,
+   125, 1262500, 1275000, 1287500, 130, 1312500,
+   1325000, 1337500, 135, 1362500, 1375000, 1387500,
+   140, 1412500, 1425000, 1437500,
+};
+
+
+static const int mc34708_sw2[] = {
+   65, 662500, 675000, 687500, 70, 712500,
+   725000, 737500, 75, 762500, 775000, 787500,
+   80, 812500, 825000, 837500, 85, 862500,
+   875000, 887500, 90, 912500, 925000, 937500,
+   95, 962500, 975000, 987500, 100, 1012500,
+   1025000, 1037500, 105, 1062500, 1075000, 1087500,
+   110, 1112500, 1125000, 1137500, 115, 1162500,
+   1175000, 1187500, 120, 1212500, 1225000, 1237500,
+   125, 1262500, 1275000, 1287500, 130, 1312500,
+   1325000, 1337500, 135, 1362500, 1375000, 1387500,
+   140, 1412500, 1425000, 1437500,
+};
+
+static const int mc34708_sw3[] = {
+   65, 675000, 70, 725000, 75, 775000,
+   80, 825000, 85, 875000, 90, 925000,
+   95, 975000, 100, 1025000, 105, 1075000,
+   110, 1125000, 115, 1175000, 120, 1225000

[PATCH v4] mfd: da9052: add device-tree support for i2c driver

2012-04-15 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device-tree support for dialog MFD and the binding
documentations.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 .../devicetree/bindings/mfd/da9052-i2c.txt |   60 
 drivers/mfd/da9052-i2c.c   |   50 +---
 2 files changed, 102 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/da9052-i2c.txt

diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt 
b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
new file mode 100644
index 000..1857f4a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -0,0 +1,60 @@
+* Dialog DA9052/53 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be dlg,da9052, dlg,da9053-aa,
+dlg,da9053-ab, or dlg,da9053-bb
+
+Sub-nodes:
+- regulators : Contain the regulator nodes. The DA9052/53 regulators are
+  bound using their names as listed below:
+
+buck0 : regulator BUCK0
+buck1 : regulator BUCK1
+buck2 : regulator BUCK2
+buck3 : regulator BUCK3
+ldo4  : regulator LDO4
+ldo5  : regulator LDO5
+ldo6  : regulator LDO6
+ldo7  : regulator LDO7
+ldo8  : regulator LDO8
+ldo9  : regulator LDO9
+ldo10 : regulator LDO10
+ldo11 : regulator LDO11
+ldo12 : regulator LDO12
+ldo13 : regulator LDO13
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+i2c@63fc8000 { /* I2C1 */
+   status = okay;
+
+   pmic: dialog@48 {
+   compatible = dlg,da9053-aa;
+   reg = 0x48;
+
+   regulators {
+   buck0 {
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck1 {
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck2 {
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+
+   buck3 {
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+   };
+   };
+};
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index 36b88e3..d8abdb3 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -22,6 +22,11 @@
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
 
+#ifdef CONFIG_OF
+#include linux/of.h
+#include linux/of_device.h
+#endif
+
 static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
 {
int reg_val, ret;
@@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 
*da9052)
return 0;
 }
 
+static struct i2c_device_id da9052_i2c_id[] = {
+   {da9052, DA9052},
+   {da9053-aa, DA9053_AA},
+   {da9053-ba, DA9053_BA},
+   {da9053-bb, DA9053_BB},
+   {}
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id dialog_dt_ids[] = {
+   { .compatible = dlg,da9052, .data = da9052_i2c_id[0] },
+   { .compatible = dlg,da9053-aa, .data = da9052_i2c_id[1] },
+   { .compatible = dlg,da9053-ab, .data = da9052_i2c_id[2] },
+   { .compatible = dlg,da9053-bb, .data = da9052_i2c_id[3] },
+   { /* sentinel */ }
+};
+#endif
+
 static int __devinit da9052_i2c_probe(struct i2c_client *client,
   const struct i2c_device_id *id)
 {
@@ -76,6 +99,22 @@ static int __devinit da9052_i2c_probe(struct i2c_client 
*client,
if (ret  0)
goto err_regmap;
 
+#ifdef CONFIG_OF
+   if (!id) {
+   struct device_node *np = client-dev.of_node;
+   const struct of_device_id *deviceid;
+
+   deviceid = of_match_node(np, dialog_dt_ids);
+   id = (const struct i2c_device_id *)deviceid-data;
+   }
+#endif
+
+   if (!id) {
+   ret = -ENODEV;
+   dev_err(client-dev, id is null.\n);
+   goto err_regmap;
+   }
+
ret = da9052_device_init(da9052, id-driver_data);
if (ret != 0)
goto err_regmap;
@@ -100,14 +139,6 @@ static int __devexit da9052_i2c_remove(struct i2c_client 
*client)
return 0;
 }
 
-static struct i2c_device_id da9052_i2c_id[] = {
-   {da9052, DA9052},
-   {da9053-aa, DA9053_AA},
-   {da9053

[PATCH v3] mfd: da9052: add device-tree support for i2c driver

2012-04-14 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device-tree support for dialog MFD and the binding
documentations.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 .../devicetree/bindings/mfd/da9052-i2c.txt |   60 
 drivers/mfd/da9052-i2c.c   |   51 ++---
 2 files changed, 103 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/da9052-i2c.txt

diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt 
b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
new file mode 100644
index 000..1857f4a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -0,0 +1,60 @@
+* Dialog DA9052/53 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be dlg,da9052, dlg,da9053-aa,
+dlg,da9053-ab, or dlg,da9053-bb
+
+Sub-nodes:
+- regulators : Contain the regulator nodes. The DA9052/53 regulators are
+  bound using their names as listed below:
+
+buck0 : regulator BUCK0
+buck1 : regulator BUCK1
+buck2 : regulator BUCK2
+buck3 : regulator BUCK3
+ldo4  : regulator LDO4
+ldo5  : regulator LDO5
+ldo6  : regulator LDO6
+ldo7  : regulator LDO7
+ldo8  : regulator LDO8
+ldo9  : regulator LDO9
+ldo10 : regulator LDO10
+ldo11 : regulator LDO11
+ldo12 : regulator LDO12
+ldo13 : regulator LDO13
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+i2c@63fc8000 { /* I2C1 */
+   status = okay;
+
+   pmic: dialog@48 {
+   compatible = dlg,da9053-aa;
+   reg = 0x48;
+
+   regulators {
+   buck0 {
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck1 {
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck2 {
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+
+   buck3 {
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+   };
+   };
+};
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index 36b88e3..b946b0ff 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -22,6 +22,11 @@
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
 
+#ifdef CONFIG_OF
+#include linux/of.h
+#include linux/of_device.h
+#endif
+
 static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
 {
int reg_val, ret;
@@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 
*da9052)
return 0;
 }
 
+static struct i2c_device_id da9052_i2c_id[] = {
+   {da9052, DA9052},
+   {da9053-aa, DA9053_AA},
+   {da9053-ba, DA9053_BA},
+   {da9053-bb, DA9053_BB},
+   {}
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id dialog_dt_ids[] = {
+   { .compatible = dlg,da9052, .data = da9052_i2c_id[0] },
+   { .compatible = dlg,da9053-aa, .data = da9052_i2c_id[1] },
+   { .compatible = dlg,da9053-ab, .data = da9052_i2c_id[2] },
+   { .compatible = dlg,da9053-bb, .data = da9052_i2c_id[3] },
+   { /* sentinel */ }
+};
+#endif
+
 static int __devinit da9052_i2c_probe(struct i2c_client *client,
   const struct i2c_device_id *id)
 {
@@ -76,6 +99,23 @@ static int __devinit da9052_i2c_probe(struct i2c_client 
*client,
if (ret  0)
goto err_regmap;
 
+#ifdef CONFIG_OF
+   if (!id) {
+   int i;
+   struct device_node *np = client-dev.of_node;
+   const struct of_device_id *deviceid;
+
+   deviceid = of_match_node(np, dialog_dt_ids);
+   id = (const struct i2c_device_id *)(deviceid-data);
+   }
+#endif
+
+   if (!id) {
+   ret = -ENODEV;
+   dev_err(client-dev, id is null.\n);
+   goto err_regmap;
+   }
+
ret = da9052_device_init(da9052, id-driver_data);
if (ret != 0)
goto err_regmap;
@@ -100,14 +140,6 @@ static int __devexit da9052_i2c_remove(struct i2c_client 
*client)
return 0;
 }
 
-static struct i2c_device_id da9052_i2c_id[] = {
-   {da9052, DA9052},
-   {da9053-aa

[PATCH v2 2/2] regulator: da9052: add device tree support

2012-04-13 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device tree support for dialog regulators

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 drivers/regulator/da9052-regulator.c |   29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/da9052-regulator.c 
b/drivers/regulator/da9052-regulator.c
index b6c8c4b..2678cbe 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -19,6 +19,9 @@
 #include linux/platform_device.h
 #include linux/regulator/driver.h
 #include linux/regulator/machine.h
+#ifdef CONFIG_OF
+#include linux/regulator/of_regulator.h
+#endif
 
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
@@ -425,8 +428,32 @@ static int __devinit da9052_regulator_probe(struct 
platform_device *pdev)
}
 
config.dev = pdev-dev;
-   config.init_data = pdata-regulators[pdev-id];
config.driver_data = regulator;
+   if (pdata  pdata-regulators) {
+   config.init_data = pdata-regulators[pdev-id];
+   } else {
+#ifdef CONFIG_OF
+   struct device_node *nproot = da9052-dev-of_node;
+   struct device_node *np;
+
+   if (!nproot)
+   return -ENODEV;
+
+   nproot = of_find_node_by_name(nproot, regulators);
+   if (!nproot)
+   return -ENODEV;
+
+   for (np = of_get_next_child(nproot, NULL); !np;
+np = of_get_next_child(nproot, np)) {
+   if (!of_node_cmp(np-name,
+regulator-info-reg_desc.name)) {
+   config.init_data = of_get_regulator_init_data(
+   pdev-dev, np);
+   break;
+   }
+   }
+#endif
+   }
 
regulator-rdev = regulator_register(regulator-info-reg_desc,
 config);
-- 
1.7.9.5


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


[PATCH v2 1/2] mfd: da9052: add device-tree support for i2c driver

2012-04-13 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device-tree support for dialog MFD and the binding
documentations.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 .../devicetree/bindings/mfd/da9052-i2c.txt |   64 
 drivers/mfd/da9052-i2c.c   |   51 +---
 2 files changed, 107 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/da9052-i2c.txt

diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt 
b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
new file mode 100644
index 000..bf4ea23
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -0,0 +1,64 @@
+* Dialog DA9052/53 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be dlg,da9052, dlg,da9053-aa,
+dlg,da9053-ab, or dlg,da9053-bb
+
+Sub-nodes:
+- regulators : Contain the regulator nodes. The DA9052/53 regulators are
+  bound using their names as listed below:
+
+buck0 : regulator BUCK0
+buck1 : regulator BUCK1
+buck2 : regulator BUCK2
+buck3 : regulator BUCK3
+ldo4  : regulator LDO4
+ldo5  : regulator LDO5
+ldo6  : regulator LDO6
+ldo7  : regulator LDO7
+ldo8  : regulator LDO8
+ldo9  : regulator LDO9
+ldo10 : regulator LDO10
+ldo11 : regulator LDO11
+ldo12 : regulator LDO12
+ldo13 : regulator LDO13
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+i2c@63fc8000 { /* I2C1 */
+   status = okay;
+
+   pmic: dialog@48 {
+   compatible = dlg,da9053-aa;
+   reg = 0x48;
+
+   regulators {
+   buck0 {
+   regulator-name = DA9052_BUCK_CORE;
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck1 {
+   regulator-name = DA9052_BUCK_PRO;
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   buck2 {
+   regulator-name = DA9052_BUCK_MEM;
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+
+   buck3 {
+   regulator-name = DA9052_BUCK_PERI;
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+   };
+   };
+};
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index 36b88e3..b946b0ff 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -22,6 +22,11 @@
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
 
+#ifdef CONFIG_OF
+#include linux/of.h
+#include linux/of_device.h
+#endif
+
 static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
 {
int reg_val, ret;
@@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 
*da9052)
return 0;
 }
 
+static struct i2c_device_id da9052_i2c_id[] = {
+   {da9052, DA9052},
+   {da9053-aa, DA9053_AA},
+   {da9053-ba, DA9053_BA},
+   {da9053-bb, DA9053_BB},
+   {}
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id dialog_dt_ids[] = {
+   { .compatible = dlg,da9052, .data = da9052_i2c_id[0] },
+   { .compatible = dlg,da9053-aa, .data = da9052_i2c_id[1] },
+   { .compatible = dlg,da9053-ab, .data = da9052_i2c_id[2] },
+   { .compatible = dlg,da9053-bb, .data = da9052_i2c_id[3] },
+   { /* sentinel */ }
+};
+#endif
+
 static int __devinit da9052_i2c_probe(struct i2c_client *client,
   const struct i2c_device_id *id)
 {
@@ -76,6 +99,23 @@ static int __devinit da9052_i2c_probe(struct i2c_client 
*client,
if (ret  0)
goto err_regmap;
 
+#ifdef CONFIG_OF
+   if (!id) {
+   int i;
+   struct device_node *np = client-dev.of_node;
+   const struct of_device_id *deviceid;
+
+   deviceid = of_match_node(np, dialog_dt_ids);
+   id = (const struct i2c_device_id *)(deviceid-data);
+   }
+#endif
+
+   if (!id) {
+   ret = -ENODEV;
+   dev_err(client-dev, id is null.\n);
+   goto err_regmap;
+   }
+
ret = da9052_device_init(da9052, id-driver_data

Re: [PATCH] rtc: add support for Freescale SNVS RTC

2012-04-13 Thread Ying-Chun Liu (PaulLiu)
(2012年03月22日 23:11), Shawn Guo wrote:
 On Mon, Mar 19, 2012 at 09:04:29PM +0800, Ying-Chun Liu (PaulLiu) wrote:
 +
 +#define RTC_READ_TIME_47BIT _IOR('p', 0x20, unsigned long long)
 +/* blocks until LPSCMR is set, returns difference */
 +#define RTC_WAIT_TIME_SET   _IOR('p', 0x21, int64_t)
 +
 
 What are these local ioctl number exactly for?  How can user space
 use these driver private numbers?
 
 +
 +rtc_write_sync_lp(ioaddr);
 +
 +new_time_47bit = (((u64) (readl(ioaddr + SNVS_LPSRTCMR) 
 +((0x1  CNTR_TO_SECS_SH) - 1))  32) |
 +((u64) readl(ioaddr + SNVS_LPSRTCLR)));
 +
 +time_diff = new_time_47bit - old_time_47bit;
 +
 +/* signal all waiting threads that time changed */
 +complete_all(snvs_completion);
 +
 +/* allow signalled threads to handle the time change notification */
 +schedule();
 +
 +/* reinitialize completion variable */
 +INIT_COMPLETION(snvs_completion);
 +
 
 Are you sure all these sync need to get done in driver?
 
 +return -EINVAL;
 +}
 +}
 +
 +spin_lock_irqsave(rtc_lock, lock_flags);
 +
 +ret = rtc_update_alarm(dev, alrm-time);
 +if (ret)
 +goto out;
 +
 +lp_cr = readl(ioaddr + SNVS_LPCR);
 +
 +if (alrm-enabled)
 +lp_cr |= (SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN);
 +else
 +lp_cr = ~(SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN);
 +
 +if (lp_cr  SNVS_LPCR_ALL_INT_EN) {
 +if (!pdata-irq_enable) {
 +enable_irq(pdata-irq);
 +pdata-irq_enable = true;
 +}
 +} else {
 +if (pdata-irq_enable) {
 +disable_irq(pdata-irq);
 +pdata-irq_enable = false;
 +}
 +}
 +
 +writel(lp_cr, ioaddr + SNVS_LPCR);
 +
 +out:
 +rtc_write_sync_lp(ioaddr);
 +spin_unlock_irqrestore(rtc_lock, lock_flags);
 +
 +return ret;
 +}
 +
 +/*!
 + * This function is used to provide the content for the /proc/driver/rtc
 + * file.
 + *
 + * @param  seq  buffer to hold the information that the driver wants to 
 write
 + *
 + * @return  The number of bytes written into the rtc file.
 + */
 +static int snvs_rtc_proc(struct device *dev, struct seq_file *seq)
 +{
 +struct rtc_drv_data *pdata = dev_get_drvdata(dev);
 +void __iomem *ioaddr = pdata-ioaddr;
 +
 +seq_printf(seq, alarm_IRQ\t: %s\n,
 +   (((readl(ioaddr + SNVS_LPCR))  SNVS_LPCR_LPTA_EN) !=
 +0) ? yes : no);
 +
 +return 0;
 +}
 +
 +static int snvs_rtc_alarm_irq_enable(struct device *dev, unsigned int 
 enable)
 +{
 +struct rtc_drv_data *pdata = dev_get_drvdata(dev);
 +void __iomem *ioaddr = pdata-ioaddr;
 +u32 lp_cr;
 +unsigned long lock_flags = 0;
 +
 +spin_lock_irqsave(rtc_lock, lock_flags);
 +
 +if (enable) {
 +if (!pdata-irq_enable) {
 +enable_irq(pdata-irq);
 +pdata-irq_enable = true;
 +}
 +lp_cr = readl(ioaddr + SNVS_LPCR);
 +lp_cr |= (SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN);
 +writel(lp_cr, ioaddr + SNVS_LPCR);
 +} else {
 +lp_cr = readl(ioaddr + SNVS_LPCR);
 +lp_cr = ~(SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN);
 +if (((lp_cr  SNVS_LPCR_ALL_INT_EN) == 0)
 + (pdata-irq_enable)) {
 +disable_irq(pdata-irq);
 +pdata-irq_enable = false;
 +}
 +writel(lp_cr, ioaddr + SNVS_LPCR);
 +}
 +
 +rtc_write_sync_lp(ioaddr);
 +spin_unlock_irqrestore(rtc_lock, lock_flags);
 +
 +return 0;
 +}
 +
 +/*!
 + * This function is used to support some ioctl calls directly.
 + * Other ioctl calls are supported indirectly through the
 + * arm/common/rtctime.c file.
 + *
 + * @param  cmd  ioctl command as defined in include/linux/rtc.h
 + * @param  arg  value for the ioctl command
 + *
 + * @return  0 if successful or negative value otherwise.
 + */
 +static int snvs_rtc_ioctl(struct device *dev, unsigned int cmd,
 + unsigned long arg)
 +{
 +struct rtc_drv_data *pdata = dev_get_drvdata(dev);
 +void __iomem *ioaddr = pdata-ioaddr;
 +u64 time_47bit;
 +int retVal;
 +
 +switch (cmd) {
 +case RTC_READ_TIME_47BIT:
 +time_47bit = (((u64) (readl(ioaddr + SNVS_LPSRTCMR) 
 +((0x1  CNTR_TO_SECS_SH) - 1))  32) |
 +((u64) readl(ioaddr + SNVS_LPSRTCLR)));
 +
 +if (arg  copy_to_user((u64 *) arg, time_47bit, sizeof(u64)))
 +return -EFAULT;
 +
 +return 0;
 +
 +/* This IOCTL to be used by processes to be notified of time changes */
 +case RTC_WAIT_TIME_SET:
 +/* don't block without releasing mutex first */
 +mutex_unlock(pdata-rtc-ops_lock);
 +
 +/* sleep till awakened by SRTC driver when LPSCMR is changed

[PATCH 1/2] mfd: da9052: add device-tree support for i2c driver

2012-04-12 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device-tree support for dialog MFD and the binding
documentations.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 .../devicetree/bindings/mfd/da9052-i2c.txt |   58 
 drivers/mfd/da9052-i2c.c   |   54 +++---
 2 files changed, 104 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/da9052-i2c.txt

diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt 
b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
new file mode 100644
index 000..042d042
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -0,0 +1,58 @@
+* Dialog DA9052/53 Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible : Should be dialog,da9052, dialog,da9053-aa,
+dialog,da9053-ab, or dialog,da9053-bb
+
+Sub-nodes:
+- regulators : Contain the regulator nodes.  The DA9052 regulators are
+  sorted as following:
+
+buck_core : regulator BUCK_CORE (id: 0 )
+buck_pro  : regulator BUCK_PRO  (id: 1 )
+buck_mem  : regulator BUCK_MEM  (id: 2 )
+buck_peri : regulator BUCK_PERI (id: 3 )
+ldo1  : regulator LDO1 (id: 4 )
+ldo2  : regulator LDO2 (id: 5 )
+ldo3  : regulator LDO3 (id: 6 )
+ldo4  : regulator LDO4 (id: 7 )
+ldo5  : regulator LDO5 (id: 8 )
+ldo6  : regulator LDO6 (id: 9 )
+ldo7  : regulator LDO7 (id: 10)
+ldo8  : regulator LDO8 (id: 11)
+ldo9  : regulator LDO9 (id: 12)
+ldo10 : regulator LDO10 (id: 13)
+
+  The bindings details of individual regulator device can be found in:
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+Examples:
+
+i2c@63fc8000 { /* I2C1 */
+   status = okay;
+
+   pmic: dialog@48 {
+   compatible = dialog,da9053-aa;
+   reg = 0x48;
+
+   regulators {
+   regulator-buck0 {
+   regulator-name = DA9052_BUCK_CORE;
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   regulator-buck1 {
+   regulator-name = DA9052_BUCK_PRO;
+   regulator-min-microvolt = 50;
+   regulator-max-microvolt = 2075000;
+   };
+
+   regulator-buck2 {
+   regulator-name = DA9052_BUCK_MEM;
+   regulator-min-microvolt = 925000;
+   regulator-max-microvolt = 250;
+   };
+   };
+   };
+};
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index 36b88e3..e07bcfa 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -22,6 +22,11 @@
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
 
+#ifdef CONFIG_OF
+#include linux/of.h
+#include linux/of_device.h
+#endif
+
 static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
 {
int reg_val, ret;
@@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 
*da9052)
return 0;
 }
 
+static struct i2c_device_id da9052_i2c_id[] = {
+   {da9052, DA9052},
+   {da9053-aa, DA9053_AA},
+   {da9053-ba, DA9053_BA},
+   {da9053-bb, DA9053_BB},
+   {}
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id dialog_dt_ids[] = {
+   { .compatible = dialog,da9052 },
+   { .compatible = dialog,da9053-aa },
+   { .compatible = dialog,da9053-ab },
+   { .compatible = dialog,da9053-bb },
+   { /* sentinel */ }
+};
+#endif
+
 static int __devinit da9052_i2c_probe(struct i2c_client *client,
   const struct i2c_device_id *id)
 {
@@ -76,6 +99,26 @@ static int __devinit da9052_i2c_probe(struct i2c_client 
*client,
if (ret  0)
goto err_regmap;
 
+#ifdef CONFIG_OF
+   if (!id) {
+   int i;
+   struct device_node *np = client-dev.of_node;
+
+   for (i = 0;
+i  sizeof(dialog_dt_ids)/sizeof(dialog_dt_ids[0]);
+i++)
+   if (of_device_is_compatible(np,
+   dialog_dt_ids[i].compatible))
+   id = da9052_i2c_id[i];
+   }
+#endif
+
+   if (!id) {
+   ret = -ENODEV;
+   dev_err(client-dev, id is null.\n);
+   goto err_regmap;
+   }
+
ret = da9052_device_init(da9052, id-driver_data);
if (ret != 0)
goto err_regmap;
@@ -100,14

[PATCH 2/2] regulator: da9052: add device tree support

2012-04-12 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This patch adds device tree support for dialog regulators

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
Cc: Ashish Jangam ashish.jan...@kpitcummins.com
---
 drivers/regulator/da9052-regulator.c |   44 +-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/da9052-regulator.c 
b/drivers/regulator/da9052-regulator.c
index 09915e8..892700c 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -19,6 +19,9 @@
 #include linux/platform_device.h
 #include linux/regulator/driver.h
 #include linux/regulator/machine.h
+#ifdef CONFIG_OF
+#include linux/regulator/of_regulator.h
+#endif
 
 #include linux/mfd/da9052/da9052.h
 #include linux/mfd/da9052/reg.h
@@ -536,6 +539,7 @@ static int __devinit da9052_regulator_probe(struct 
platform_device *pdev)
struct da9052_regulator *regulator;
struct da9052 *da9052;
struct da9052_pdata *pdata;
+   struct regulator_init_data *initdata = NULL;
int ret;
 
regulator = devm_kzalloc(pdev-dev, sizeof(struct da9052_regulator),
@@ -554,9 +558,47 @@ static int __devinit da9052_regulator_probe(struct 
platform_device *pdev)
ret = -EINVAL;
goto err;
}
+   if (pdata  pdata-regulators) {
+   initdata = pdata-regulators[pdev-id];
+   } else {
+#ifdef CONFIG_OF
+   struct device_node *nproot = da9052-dev-of_node;
+   struct device_node *np;
+   int c;
+
+   if (!nproot) {
+   ret = -ENODEV;
+   goto err;
+   }
+
+   nproot = of_find_node_by_name(nproot, regulators);
+   if (!nproot) {
+   ret = -ENODEV;
+   goto err;
+   }
+
+   c = 0;
+   for (np = of_get_next_child(nproot, NULL);
+np != NULL;
+np = of_get_next_child(nproot, np)) {
+   if (c == pdev-id) {
+   initdata = of_get_regulator_init_data(
+   pdev-dev, np);
+   break;
+   }
+   c++;
+   }
+#endif
+   }
+
+   if (!initdata) {
+   dev_err(pdev-dev, no initdata\n);
+   ret = -ENODEV;
+   goto err;
+   }
regulator-rdev = regulator_register(regulator-info-reg_desc,
 pdev-dev,
-pdata-regulators[pdev-id],
+initdata,
 regulator, NULL);
if (IS_ERR(regulator-rdev)) {
dev_err(pdev-dev, failed to register regulator %s\n,
-- 
1.7.9.5


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


Re: [PATCH] ARM: dts: imx6q: add anatop regulators

2012-03-30 Thread Ying-Chun Liu (PaulLiu)
(2012年03月22日 15:45), Shawn Guo wrote:
 +};
 +
 +regulator-1p1@110 {
 +compatible = fsl,anatop-regulator;
 +regulator-name = vdd1p1;
 +regulator-min-microvolt = 80;
 +regulator-max-microvolt = 140;
 +regulator-always-on;
 +reg = 0x110;
 +anatop-vol-bit-shift = 8;
 +anatop-vol-bit-width = 5;
 +anatop-min-bit-val = 4;
 +anatop-min-voltage = 80;
 +anatop-max-voltage = 140;
 
 1.375V

Hi Shawn,

Sorry, why it is not 1.4V?

LDO 1p1 should be from range 0.8V to 1.4V on section 53.3.1

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


[PATCH v2] ARM: dts: imx6q: add anatop regulators

2012-03-30 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add anatop regulators to imx6q.dtsi for all imx6q platforms.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Signed-off-by: Richard Zhao richard.z...@linaro.org
Cc: Shawn Guo shawn@linaro.org
---
 arch/arm/boot/dts/imx6q.dtsi |   86 ++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 263e8f3..79f59e7 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -346,6 +346,92 @@
compatible = fsl,imx6q-anatop;
reg = 0x020c8000 0x1000;
interrupts = 0 49 0x04 0 54 0x04 0 127 0x04;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   regulator-1p1@110 {
+   compatible = fsl,anatop-regulator;
+   regulator-name = vdd1p1;
+   regulator-min-microvolt = 80;
+   regulator-max-microvolt = 1375000;
+   regulator-always-on;
+   anatop-reg-offset = 0x110;
+   anatop-vol-bit-shift = 8;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 4;
+   anatop-min-voltage = 80;
+   anatop-max-voltage = 1375000;
+   };
+
+   regulator-3p0@120 {
+   compatible = fsl,anatop-regulator;
+   regulator-name = vdd3p0;
+   regulator-min-microvolt = 280;
+   regulator-max-microvolt = 315;
+   regulator-always-on;
+   anatop-reg-offset = 0x120;
+   anatop-vol-bit-shift = 8;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 0;
+   anatop-min-voltage = 2625000;
+   anatop-max-voltage = 340;
+   };
+
+   regulator-2p5@130 {
+   compatible = fsl,anatop-regulator;
+   regulator-name = vdd2p5;
+   regulator-min-microvolt = 200;
+   regulator-max-microvolt = 275;
+   regulator-always-on;
+   anatop-reg-offset = 0x130;
+   anatop-vol-bit-shift = 8;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 0;
+   anatop-min-voltage = 200;
+   anatop-max-voltage = 275;
+   };
+
+   regulator-vddcore@140 {
+   compatible = fsl,anatop-regulator;
+   regulator-name = cpu;
+   regulator-min-microvolt = 725000;
+   regulator-max-microvolt = 145;
+   regulator-always-on;
+   anatop-reg-offset = 0x140;
+   anatop-vol-bit-shift = 0;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 1;
+   anatop-min-voltage = 725000;
+   anatop-max-voltage = 145;
+   };
+
+   regulator-vddpu@140 {
+   compatible = fsl,anatop-regulator;
+   regulator-name = vddpu;
+   regulator-min-microvolt = 725000;
+   regulator-max-microvolt = 145;
+   regulator-always-on;
+   anatop-reg-offset = 0x140;
+   anatop-vol-bit-shift = 9;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 1;
+   anatop-min-voltage = 725000

[PATCH] Regulator: anatop-regulator: patching to device-tree property reg.

2012-03-27 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Change reg to anatop-reg-offset due to there is a warning of handling no
size field in reg.

This patch also adds the missing device-tree binding documentation.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Shawn Guo shawn@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
---
 .../bindings/regulator/anatop-regulator.txt|   29 
 drivers/regulator/anatop-regulator.c   |5 ++-
 2 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/anatop-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/anatop-regulator.txt 
b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
new file mode 100644
index 000..357758c
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
@@ -0,0 +1,29 @@
+Anatop Voltage regulators
+
+Required properties:
+- compatible: Must be fsl,anatop-regulator
+- anatop-reg-offset: Anatop MFD register offset
+- anatop-vol-bit-shift: Bit shift for the register
+- anatop-vol-bit-width: Number of bits used in the register
+- anatop-min-bit-val: Minimum value of this register
+- anatop-min-voltage: Minimum voltage of this regulator
+- anatop-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:
+
+   regulator-vddpu {
+   compatible = fsl,anatop-regulator;
+   regulator-name = vddpu;
+   regulator-min-microvolt = 725000;
+   regulator-max-microvolt = 130;
+   regulator-always-on;
+   anatop-reg-offset = 0x140;
+   anatop-vol-bit-shift = 9;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 1;
+   anatop-min-voltage = 725000;
+   anatop-max-voltage = 130;
+   };
diff --git a/drivers/regulator/anatop-regulator.c 
b/drivers/regulator/anatop-regulator.c
index 17499a5..53969af 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -138,9 +138,10 @@ static int __devinit anatop_regulator_probe(struct 
platform_device *pdev)
rdesc-type = REGULATOR_VOLTAGE;
rdesc-owner = THIS_MODULE;
sreg-mfd = anatopmfd;
-   ret = of_property_read_u32(np, reg, sreg-control_reg);
+   ret = of_property_read_u32(np, anatop-reg-offset,
+  sreg-control_reg);
if (ret) {
-   dev_err(dev, no reg property set\n);
+   dev_err(dev, no anatop-reg-offset property set\n);
goto anatop_probe_end;
}
ret = of_property_read_u32(np, anatop-vol-bit-width,
-- 
1.7.9.1


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


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

2012-03-22 Thread Ying-Chun Liu (PaulLiu)
(2012年03月22日 13:24), Shawn Guo wrote:
 On Wed, Mar 14, 2012 at 10:29:12AM +0800, Ying-Chun Liu (PaulLiu) wrote:
 From: Ying-Chun Liu (PaulLiu) paul@linaro.org

 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 nancy.c...@freescale.com
 Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
 Acked-by: Shawn Guo shawn@linaro.org
 Reviewed-by: Axel Lin axel@gmail.com
 Cc: Mark Brown broo...@opensource.wolfsonmicro.com
 Cc: Liam Girdwood l...@ti.com
 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  drivers/regulator/Kconfig|8 +
  drivers/regulator/Makefile   |1 +
  drivers/regulator/anatop-regulator.c |  241 
 ++
  3 files changed, 250 insertions(+), 0 deletions(-)
  create mode 100644 drivers/regulator/anatop-regulator.c

 I just noticed that the binding document below got lost since v11 of
 the series.
 
   Documentation/devicetree/bindings/regulator/anatop-regulator.txt
 
 It got lost by mistaken or you dropped it for some reason?
 

Ouch. I'll prepare a separate patch to add back the documentation.

Sorry,

Paul


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


[PATCH] rtc: add support for Freescale SNVS RTC

2012-03-19 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

This adds an RTC driver for the Low Power (LP) section of SNVS.
It hooks into the /dev/rtc interface and supports ioctl to complete RTC
features. This driver supports device tree bindings.
It only uses the RTC hw in non-secure mode.

Signed-off-by: Anish Trivedi an...@freescale.com
Signed-off-by: Eric Miao eric.m...@linaro.org
Signed-off-by: Anson Huang b20...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Alessandro Zummo a.zu...@towertech.it
Cc: Shawn Guo shawn@linaro.org
---
 drivers/rtc/Kconfig|   11 +
 drivers/rtc/Makefile   |1 +
 drivers/rtc/rtc-snvs.c |  737 
 3 files changed, 749 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-snvs.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 3a125b8..d58f4b7 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -634,6 +634,17 @@ config RTC_MXC
   This driver can also be built as a module, if so, the module
   will be called rtc-mxc.
 
+config RTC_DRV_SNVS
+   tristate Freescale SNVS Real Time Clock
+   depends on ARCH_MXC
+   depends on RTC_CLASS
+   help
+  If you say yes here you get support for the Freescale SNVS
+  Low Power (LP) RTC module.
+
+  This driver can also be built as a module, if so, the module
+  will be called rtc-snvs.
+
 config RTC_DRV_BQ4802
tristate TI BQ4802
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 6e69823..8b30686 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -93,6 +93,7 @@ obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o
 obj-$(CONFIG_RTC_DRV_S3C)  += rtc-s3c.o
 obj-$(CONFIG_RTC_DRV_SA1100)   += rtc-sa1100.o
 obj-$(CONFIG_RTC_DRV_SH)   += rtc-sh.o
+obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o
 obj-$(CONFIG_RTC_DRV_SPEAR)+= rtc-spear.o
 obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o
 obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
new file mode 100644
index 000..49ac8a5
--- /dev/null
+++ b/drivers/rtc/rtc-snvs.c
@@ -0,0 +1,737 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc.
+ */
+
+/*
+ * 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.
+ */
+/*
+ * Implementation based on rtc-ds1553.c
+ */
+
+/*!
+ * @defgroup RTC Real Time Clock (RTC) Driver
+ */
+/*!
+ * @file rtc-snvs.c
+ * @brief Secure Real Time Clock (SRTC) interface in Freescale's SNVS module
+ *
+ * This file contains Real Time Clock interface for Linux. The Freescale
+ * SNVS module's Low Power (LP) SRTC functionality is utilized in this driver,
+ * in non-secure mode.
+ *
+ * @ingroup RTC
+ */
+
+#include linux/slab.h
+#include linux/delay.h
+#include linux/rtc.h
+#include linux/module.h
+#include linux/fs.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+#include linux/uaccess.h
+#include linux/io.h
+#include linux/sched.h
+#include linux/of.h
+#include linux/of_device.h
+
+/* Register definitions */
+#defineSNVS_HPSR   0x14/* HP Status Register */
+#defineSNVS_LPCR   0x38/* LP Control Register */
+#defineSNVS_LPSR   0x4C/* LP Status Register */
+#defineSNVS_LPSRTCMR   0x50/* LP Secure Real Time Counter MSB 
Register */
+#defineSNVS_LPSRTCLR   0x54/* LP Secure Real Time Counter LSB 
Register */
+#defineSNVS_LPTAR  0x58/* LP Time Alarm Register */
+#defineSNVS_LPSMCMR0x5C/* LP Secure Monotonic Counter MSB 
Register */
+#defineSNVS_LPSMCLR0x60/* LP Secure Monotonic Counter LSB 
Register */
+#defineSNVS_LPPGDR 0x64/* LP Power Glitch Detector Register */
+#defineSNVS_LPGPR  0x68/* LP General Purpose Register */
+
+/* Bit Definitions */
+#defineSNVS_HPSR_SSM_ST_MASK   0x0F00
+#defineSNVS_HPSR_SSM_ST_SHIFT  8
+
+#defineSNVS_LPCR_SRTC_ENV  (1  0)
+#defineSNVS_LPCR_LPTA_EN   (1  1)
+#defineSNVS_LPCR_LPWUI_EN  (1  3)
+#defineSNVS_LPCR_ALL_INT_EN (SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN)
+#defineSNVS_LPSR_LPTA  (1  0)
+#defineSNVS_LPPGDR_INIT

[PATCH v10] mfd: Add anatop mfd driver

2012-03-16 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Venu Byravarasu vbyravar...@nvidia.com
Cc: Peter Korsgaard jac...@sunsite.dk
Cc: Arnd Bergmann a...@arndb.de
Cc: Rob Lee rob@linaro.org
---
 drivers/mfd/Kconfig|8 +++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  137 
 include/linux/mfd/anatop.h |   40 +
 4 files changed, 186 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 82da448..c3a9f31 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -846,6 +846,14 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+   bool Support for Freescale i.MX on-chip ANATOP controller
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Freescale i.MX on-chip ANATOP
+ MFD controller. This controller embeds regulator and
+ thermal devices for Freescale i.MX platforms.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 27430d3..42c8bf6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -113,3 +113,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..2af4248
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,137 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift,
+   int bit_width)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   val = readl(adata-ioreg + addr);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL_GPL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bit_width, u32 data)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg + addr);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL_GPL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_match[] = {
+   { .compatible = fsl,imx6q-anatop, },
+   { },
+};
+
+static int __devinit of_anatop_probe

[PATCH v9] mfd: Add anatop mfd driver

2012-03-15 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Venu Byravarasu vbyravar...@nvidia.com
Cc: Peter Korsgaard jac...@sunsite.dk
---
 drivers/mfd/Kconfig|8 +++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  142 
 include/linux/mfd/anatop.h |   40 
 4 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 82da448..c3a9f31 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -846,6 +846,14 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+   bool Support for Freescale i.MX on-chip ANATOP controller
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Freescale i.MX on-chip ANATOP
+ MFD controller. This controller embeds regulator and
+ thermal devices for Freescale i.MX platforms.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 27430d3..42c8bf6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -113,3 +113,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..4272e60
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,142 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift,
+   int bit_width)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   val = readl(adata-ioreg + addr);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bit_width, u32 data)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg + addr);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_subdevice_match[] = {
+   { .compatible = fsl,anatop-regulator, },
+   { .compatible = fsl,anatop-thermal, },
+   { },
+};
+
+static int __devinit of_anatop_probe(struct

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

2012-03-09 Thread Ying-Chun Liu (PaulLiu)
(2012年03月08日 22:18), Jean-Christophe PLAGNIOL-VILLARD wrote:
 +static int __devexit anatop_regulator_remove(struct platform_device *pdev)
 +{
 +struct regulator_dev *rdev = platform_get_drvdata(pdev);
 +struct anatop_regulator *sreg = rdev_get_drvdata(rdev);
 +kfree(sreg-name);
 +regulator_unregister(rdev);
 return from the unregister
 +return 0;
 +}
 Best Regards,
 J.

Hi Jean-Christophe,

I've modify the patch based on your review. However, the last one cannot
be made because regulator_unregister is void return.

Yours Sincerely,
Paul

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


[PATCH v12] Regulator: Add Anatop regulator driver

2012-03-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Reviewed-by: Axel Lin axel@gmail.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 drivers/regulator/Kconfig|8 +
 drivers/regulator/Makefile   |1 +
 drivers/regulator/anatop-regulator.c |  241 ++
 3 files changed, 250 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index c733df5..a229de9 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -102,6 +102,14 @@ config REGULATOR_DA9052
  This driver supports the voltage regulators of DA9052-BC and
  DA9053-AA/Bx PMIC.
 
+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.
+
 config REGULATOR_MC13XXX_CORE
tristate
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2b09c81..b5042c8 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
+obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
diff --git a/drivers/regulator/anatop-regulator.c 
b/drivers/regulator/anatop-regulator.c
new file mode 100644
index 000..17499a5
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,241 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+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;
+   dev_dbg(reg-dev, %s: uv %d, min %d, max %d\n, __func__,
+   uv, anatop_reg-min_voltage,
+   anatop_reg-max_voltage);
+
+   if (uv  anatop_reg-min_voltage) {
+   if (max_uV  anatop_reg-min_voltage)
+   uv = anatop_reg-min_voltage;
+   else
+   return -EINVAL;
+   }
+
+   if (!anatop_reg-control_reg)
+   return -ENOTSUPP;
+
+   sel = DIV_ROUND_UP(uv - anatop_reg-min_voltage, 25000);
+   if (sel * 25000 + anatop_reg-min_voltage  anatop_reg-max_voltage)
+   return -EINVAL;
+   val = anatop_reg-min_bit_val + sel;
+   *selector = sel;
+   dev_dbg(reg-dev, %s: calculated val %d\n, __func__, val);
+   anatop_set_bits(anatop_reg-mfd,
+   anatop_reg-control_reg,
+   anatop_reg-vol_bit_shift

[PATCH v10] Regulator: Add Anatop regulator driver

2012-03-08 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
Cc: Axel Lin axel@gmail.com
---
 .../bindings/regulator/anatop-regulator.txt|   28 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  236 
 4 files changed, 273 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..73363e76
--- /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
+- anatop-vol-bit-shift: Bit shift for the register
+- anatop-vol-bit-width: Number of bits used in the register
+- anatop-min-bit-val: Minimum value of this register
+- anatop-min-voltage: Minimum voltage of this regulator
+- anatop-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;
+   anatop-vol-bit-shift = 9;
+   anatop-vol-bit-width = 5;
+   anatop-min-bit-val = 1;
+   anatop-min-voltage = 725000;
+   anatop-max-voltage = 130;
+   };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 7a61b17..3857209 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -213,6 +213,14 @@ config REGULATOR_PCAP
 This driver provides support for the voltage regulators of the
 PCAP2 PMIC.
 
+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.
+
 config REGULATOR_MC13XXX_CORE
tristate
 
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..133a17b
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,236 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+struct anatop_regulator {
+   const char *name;
+   u32 control_reg

[PATCH v11] Regulator: Add Anatop regulator driver

2012-03-08 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
Cc: Axel Lin axel@gmail.com
---
 drivers/regulator/Kconfig|8 +
 drivers/regulator/Makefile   |1 +
 drivers/regulator/anatop-regulator.c |  238 ++
 3 files changed, 247 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index c733df5..a229de9 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -102,6 +102,14 @@ config REGULATOR_DA9052
  This driver supports the voltage regulators of DA9052-BC and
  DA9053-AA/Bx PMIC.
 
+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.
+
 config REGULATOR_MC13XXX_CORE
tristate
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2b09c81..b5042c8 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
+obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
diff --git a/drivers/regulator/anatop-regulator.c 
b/drivers/regulator/anatop-regulator.c
new file mode 100644
index 000..53a2d87
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,238 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+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;
+   dev_dbg(reg-dev, %s: uv %d, min %d, max %d\n, __func__,
+   uv, anatop_reg-min_voltage,
+   anatop_reg-max_voltage);
+
+   if (uv  anatop_reg-min_voltage) {
+   if (max_uV  anatop_reg-min_voltage)
+   uv = anatop_reg-min_voltage;
+   else
+   return -EINVAL;
+   }
+
+   if (!anatop_reg-control_reg)
+   return -ENOTSUPP;
+
+   sel = DIV_ROUND_UP(uv - anatop_reg-min_voltage, 25000);
+   if (sel * 25000 + anatop_reg-min_voltage  anatop_reg-max_voltage)
+   return -EINVAL;
+   val = anatop_reg-min_bit_val + sel;
+   *selector = sel;
+   dev_dbg(reg-dev, %s: calculated val %d\n, __func__, val);
+   anatop_set_bits(anatop_reg-mfd,
+   anatop_reg-control_reg,
+   anatop_reg-vol_bit_shift

[PATCH v9] Regulator: Add Anatop regulator driver

2012-03-07 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
---
 .../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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+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

[PATCH v8 1/2] mfd: Add anatop mfd driver

2012-03-05 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Acked-by: Shawn Guo shawn@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Venu Byravarasu vbyravar...@nvidia.com
Cc: Peter Korsgaard jac...@sunsite.dk
---
 drivers/mfd/Kconfig|8 +++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  142 
 include/linux/mfd/anatop.h |   40 
 4 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f147395..f7e2f61 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -830,6 +830,14 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+   bool Support for Freescale i.MX on-chip ANATOP controller
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Freescale i.MX on-chip ANATOP
+ MFD controller. This controller embeds regulator and
+ thermal devices for Freescale i.MX platforms.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..8e11060 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -112,3 +112,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..d9bc63c
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,142 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift,
+   int bit_width)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   val = readl(adata-ioreg + addr);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bit_width, u32 data)
+{
+   u32 val, mask;
+
+   if (bit_width == 32)
+   mask = ~0;
+   else
+   mask = (1  bit_width) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_subdevice_match[] = {
+   { .compatible = fsl,anatop-regulator, },
+   { .compatible = fsl,anatop-thermal, },
+   { },
+};
+
+static int __devinit of_anatop_probe(struct

[PATCH v8 2/2] Regulator: Add Anatop regulator driver

2012-03-05 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
---
 .../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..e9917c6
--- /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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+#include linux/regulator/driver.h
+#include linux/regulator/of_regulator.h
+
+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

[PATCH v7 1/2] mfd: Add anatop mfd driver

2012-03-03 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
Cc: Venu Byravarasu vbyravar...@nvidia.com
Cc: Peter Korsgaard jac...@sunsite.dk
---
 drivers/mfd/Kconfig|6 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  142 
 include/linux/mfd/anatop.h |   40 
 4 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f147395..78593e8 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -830,6 +830,12 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+   bool Support for Anatop
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Anatop MFD driver.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..8e11060 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -112,3 +112,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..0307051
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,142 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift, int bits)
+{
+   u32 val;
+   int mask;
+
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   val = readl(adata-ioreg + addr);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bits, u32 data)
+{
+   u32 val;
+   int mask;
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_subdevice_match[] = {
+   { .compatible = fsl,anatop-regulator, },
+   { .compatible = fsl,anatop-thermal, },
+   { },
+};
+
+static int of_anatop_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
+   void *ioreg;
+   struct anatop *drvdata;
+
+   ioreg = of_iomap(np, 0);
+   if (!ioreg

[PATCH v5 2/2] Regulator: Add Anatop regulator driver

2012-03-01 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
---
 .../bindings/regulator/anatop-regulator.txt|   28 +++
 drivers/regulator/Kconfig  |6 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  203 
 include/linux/regulator/anatop-regulator.h |   40 
 5 files changed, 278 insertions(+), 0 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/anatop-regulator.txt
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/Documentation/devicetree/bindings/regulator/anatop-regulator.txt 
b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
new file mode 100644
index 000..9ed7326
--- /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-size: 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-size = 5;
+   min-bit-val = 1;
+   min-voltage = 725000;
+   max-voltage = 130;
+   };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 7a61b17..5fbcda2 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -335,5 +335,11 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on MFD_ANATOP
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 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..1f3a878
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,203 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/regulator/of_regulator.h
+
+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

[PATCH v5 1/2] mfd: Add anatop mfd driver

2012-03-01 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
---
 drivers/mfd/Kconfig|6 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  144 
 include/linux/mfd/anatop.h |   40 
 4 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f147395..f787d17 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -830,6 +830,12 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+bool Support for Anatop
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Anatop MFD driver.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..8e11060 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -112,3 +112,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..86e2b8e
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,144 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift, int bits)
+{
+   u32 val;
+   int mask;
+
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr);
+   spin_unlock(adata-reglock);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bits, u32 data)
+{
+   u32 val;
+   int mask;
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_subdevice_match[] = {
+   { .compatible = fsl,anatop-regulator, },
+   { .compatible = fsl,anatop-thermal, },
+   { },
+};
+
+static int of_anatop_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
+   void *ioreg;
+   struct anatop *drvdata;
+
+   ioreg = of_iomap(np, 0);
+   if (!ioreg

[PATCH v6 1/2] mfd: Add anatop mfd driver

2012-03-01 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Shawn Guo shawn@linaro.org
---
 drivers/mfd/Kconfig|6 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  142 
 include/linux/mfd/anatop.h |   40 
 4 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f147395..f787d17 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -830,6 +830,12 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+bool Support for Anatop
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Anatop MFD driver.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..8e11060 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -112,3 +112,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..0307051
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,142 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift, int bits)
+{
+   u32 val;
+   int mask;
+
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   val = readl(adata-ioreg + addr);
+   val = (val  bit_shift)  mask;
+
+   return val;
+}
+EXPORT_SYMBOL(anatop_get_bits);
+
+void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
+int bits, u32 data)
+{
+   u32 val;
+   int mask;
+   if (bits == 32)
+   mask = ~0;
+   else
+   mask = (1  bits) - 1;
+
+   spin_lock(adata-reglock);
+   val = readl(adata-ioreg + addr)  ~(mask  bit_shift);
+   writel((data  bit_shift) | val, adata-ioreg);
+   spin_unlock(adata-reglock);
+}
+EXPORT_SYMBOL(anatop_set_bits);
+
+static const struct of_device_id of_anatop_subdevice_match[] = {
+   { .compatible = fsl,anatop-regulator, },
+   { .compatible = fsl,anatop-thermal, },
+   { },
+};
+
+static int of_anatop_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
+   void *ioreg;
+   struct anatop *drvdata;
+
+   ioreg = of_iomap(np, 0);
+   if (!ioreg)
+   return -EINVAL;
+   drvdata = devm_kzalloc(dev, sizeof(struct

[PATCH v6 2/2] Regulator: Add Anatop regulator driver

2012-03-01 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Shawn Guo shawn@linaro.org
---
 .../bindings/regulator/anatop-regulator.txt|   28 +++
 drivers/regulator/Kconfig  |6 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  205 
 include/linux/regulator/anatop-regulator.h |   40 
 5 files changed, 280 insertions(+), 0 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/anatop-regulator.txt
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/Documentation/devicetree/bindings/regulator/anatop-regulator.txt 
b/Documentation/devicetree/bindings/regulator/anatop-regulator.txt
new file mode 100644
index 000..f19cfea
--- /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-size: 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 1;
+   vol-bit-shift = 9;
+   vol-bit-size = 5;
+   min-bit-val = 1;
+   min-voltage = 725000;
+   max-voltage = 130;
+   };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 7a61b17..5fbcda2 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -335,5 +335,11 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on MFD_ANATOP
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 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..84d8f50
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,205 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/regulator/of_regulator.h
+
+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

Re: Salon 3, today and tomorrow (16th and 17th)

2012-02-15 Thread Ying-Chun Liu (PaulLiu)
On 02/16/2012 06:08 AM, Zach Pfeffer wrote:
 Alexander had the very good idea to ask the Linux Foundation if they
 would set up a hacking room. They set aside Salon 3 for today and
 tomorrow. I've brought some (all) of the hardware down if people need
 to run stuff or want to collaborate.
 

Hi Zach,

Is it open for 24 hrs? Can I hack something there for 24 hrs?

Yours Sincerely,
Paul

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


[PATCH v4 1/2] mfd: Add anatop mfd driver

2012-02-08 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop is a mfd chip embedded in Freescale i.MX6Q SoC.
Anatop provides regulators and thermal.
This driver handles the address space and the operation of the mfd device.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
---
 drivers/mfd/Kconfig|6 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/anatop-mfd.c   |  152 
 include/linux/mfd/anatop.h |   39 +++
 4 files changed, 198 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/anatop-mfd.c
 create mode 100644 include/linux/mfd/anatop.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index cd13e9f..4f71627 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -830,6 +830,12 @@ config MFD_INTEL_MSIC
  Passage) chip. This chip embeds audio, battery, GPIO, etc.
  devices used in Intel Medfield platforms.
 
+config MFD_ANATOP
+bool Support for Anatop
+   depends on SOC_IMX6Q
+   help
+ Select this option to enable Anatop MFD driver.
+
 endmenu
 endif
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..8e11060 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -112,3 +112,4 @@ obj-$(CONFIG_TPS65911_COMPARATOR)   += tps65911-comparator.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+obj-$(CONFIG_MFD_ANATOP)   += anatop-mfd.o
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
new file mode 100644
index 000..58c6054
--- /dev/null
+++ b/drivers/mfd/anatop-mfd.c
@@ -0,0 +1,152 @@
+/*
+ * Anatop MFD driver
+ *
+ * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) paul@linaro.org
+ * Copyright (C) 2012 Linaro
+ *
+ *  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.
+ *  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 linux/io.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_address.h
+#include linux/mfd/anatop.h
+
+static u32 anatop_read(struct anatop *adata, u32 addr, int bit_shift, int bits)
+{
+   u32 val;
+   int mask;
+   if (bits == 32)
+   mask = 0xff;
+   else
+   mask = (1  bits) - 1;
+
+   val = ioread32(adata-ioreg+addr);
+   val = (val  bit_shift)  mask;
+   return val;
+}
+
+static void anatop_write(struct anatop *adata, u32 addr, int bit_shift,
+int bits, u32 data)
+{
+   u32 val;
+   int mask;
+   if (bits == 32)
+   mask = 0xff;
+   else
+   mask = (1  bits) - 1;
+
+   val = ioread32(adata-ioreg+addr)  ~(mask  bit_shift);
+   iowrite32((data  bit_shift) | val, adata-ioreg);
+}
+
+static const struct of_device_id of_anatop_regulator_match[] = {
+   {
+   .compatible = fsl,anatop-regulator,
+   },
+   {
+   .compatible = fsl,anatop-thermal,
+   },
+   { },
+};
+
+static int of_anatop_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
+   u64 ofaddr;
+   u64 ofsize;
+   void *ioreg;
+   struct anatop *drvdata;
+   int ret = 0;
+   const __be32 *rval;
+
+   rval = of_get_address(np, 0, ofsize, NULL);
+   if (rval)
+   ofaddr = be32_to_cpu(*rval);
+   else
+   return -EINVAL;
+
+   ioreg = ioremap(ofaddr, ofsize

[PATCH v4 2/2] Regulator: Add Anatop regulator driver

2012-02-08 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
---
 drivers/regulator/Kconfig  |6 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  204 
 include/linux/regulator/anatop-regulator.h |   49 +++
 4 files changed, 260 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 7a61b17..5fbcda2 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -335,5 +335,11 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on MFD_ANATOP
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 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..d800c88
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,204 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/regulator/of_regulator.h
+
+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;
+   pr_debug(%s: uv %d, min %d, max %d\n, __func__,
+uv, anatop_reg-rdata-min_voltage,
+anatop_reg-rdata-max_voltage);
+
+   if (uv  anatop_reg-rdata-min_voltage
+   || uv  anatop_reg-rdata-max_voltage) {
+   if (max_uV  anatop_reg-rdata-min_voltage)
+   uv = anatop_reg-rdata-min_voltage;
+   else
+   return -EINVAL;
+   }
+
+   if (anatop_reg-rdata-control_reg) {
+   sel = (uv - anatop_reg-rdata-min_voltage) / 25000;
+   val = anatop_reg-rdata-min_bit_val + sel;
+   *selector = sel;
+   pr_debug(%s: calculated val %d\n, __func__, val);
+   anatop_reg-rdata-mfd-write(anatop_reg-rdata-mfd,
+ anatop_reg-rdata-control_reg,
+ anatop_reg-rdata-vol_bit_shift,
+ anatop_reg-rdata-vol_bit_size,
+ val);
+   return 0;
+   } else {
+   return -ENOTSUPP;
+   }
+}
+
+static int anatop_get_voltage_sel(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+   int selector;
+   struct anatop_regulator_data *rdata = anatop_reg-rdata;
+
+   if (rdata-control_reg) {
+   u32 val = rdata-mfd-read(rdata-mfd,
+rdata

Re: [PATCH] mx53_loco: add DA9053 PMIC support

2012-01-17 Thread Ying-Chun Liu (PaulLiu)
Thanks all.

I'm preparing another new upload to fix all the problems.

(2012年01月17日 05:08), Arnaud Patard (Rtp) wrote:
 Ying-Chun Liu (PaulLiu) paul@linaro.org writes:
 
 Hi,
 
 From: Ying-Chun Liu (PaulLiu) paul@linaro.org

 +
 +#define MX53_LOCO_DA9052_IRQ(6*32 + 11) /* 
 GPIO7_11 */
 
 you're aware that there's a IMX_GPIO_NR() macro for defining gpio,
 right ? Moreover, why not putting it with other #defines for gpio in the
 top of the file ?

Thanks. My fault. I'll change to use this macro.

 
 diff --git a/arch/arm/plat-mxc/include/mach/irqs.h 
 b/arch/arm/plat-mxc/include/mach/irqs.h
 index fd9efb0..9fb56eb 100644
 --- a/arch/arm/plat-mxc/include/mach/irqs.h
 +++ b/arch/arm/plat-mxc/include/mach/irqs.h
 @@ -53,7 +53,15 @@
  #endif
  /* REVISIT: Add IPU irqs on IMX51 */
  
 -#define NR_IRQS (MXC_IPU_IRQ_START + MX3_IPU_IRQS)
 +#define MXC_PMIC_IRQ_START  (MXC_IPU_IRQ_START + MX3_IPU_IRQS)
 +
 +#ifdef CONFIG_MACH_MX53_LOCO
 +#define MXC_PMIC_IRQS 32
 +#else
 +#define MXC_PMIC_IRQS 0
 +#endif
 
 So, each board using a pmic needing some irqs will need to add a
 #ifdef/#define combo ? Can it be made more generic ? How will it work
 with a kernel compiled for several machines, say loco and an other using
 a pmic using more than 32 irqs ?
 

Sorry. Any possible suggestions?

I'm thinking about using CONFIG_SPARSE_IRQ
and then we can use .nr_irqs in MACHINE_START block so I can acquire
more irqs there.
But I don't know if this is another intrusive way.

Many Thanks,
Paul

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


[PATCH] mx53_loco: add DA9053 PMIC support

2012-01-16 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 PMIC support for Freescale QuickStart Loco board.
The model of PMIC on QuickStart Loco board is da9053-aa.

Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Amit Kucheria amit.kuche...@canonical.com
Cc: Sascha Hauer ker...@pengutronix.de
---
 arch/arm/mach-mx5/board-mx53_loco.c   |  128 +
 arch/arm/plat-mxc/include/mach/irqs.h |   10 +++-
 2 files changed, 137 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx53_loco.c 
b/arch/arm/mach-mx5/board-mx53_loco.c
index fd8b524..61dd8c9 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -23,10 +23,21 @@
 #include linux/delay.h
 #include linux/gpio.h
 #include linux/i2c.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/irq.h
+#include linux/interrupt.h
+#include linux/err.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/pdata.h
 
 #include mach/common.h
 #include mach/hardware.h
 #include mach/iomux-mx53.h
+#include mach/irqs.h
+#include mach/gpio.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -45,6 +56,32 @@
 #define LOCO_SD1_CDIMX_GPIO_NR(3, 13)
 #define LOCO_ACCEL_EN  IMX_GPIO_NR(6, 14)
 
+#define DA9052_LDO1_VOLT_UPPER 1800
+#define DA9052_LDO1_VOLT_LOWER 600
+#define DA9052_LDO1_VOLT_STEP  50
+#define DA9052_LDO2_VOLT_UPPER 1800
+#define DA9052_LDO2_VOLT_LOWER 600
+#define DA9052_LDO2_VOLT_STEP  25
+#define DA9052_LDO34_VOLT_UPPER3300
+#define DA9052_LDO34_VOLT_LOWER1725
+#define DA9052_LDO34_VOLT_STEP 25
+#define DA9052_LDO567810_VOLT_UPPER3600
+#define DA9052_LDO567810_VOLT_LOWER1200
+#define DA9052_LDO567810_VOLT_STEP 50
+#define DA9052_LDO9_VOLT_STEP  50
+#define DA9052_LDO9_VOLT_LOWER 1250
+#define DA9052_LDO9_VOLT_UPPER 3650
+/* Buck Config Validation Macros */
+#define DA9052_BUCK_CORE_PRO_VOLT_UPPER2075
+#define DA9052_BUCK_CORE_PRO_VOLT_LOWER500
+#define DA9052_BUCK_CORE_PRO_STEP  25
+#define DA9052_BUCK_MEM_VOLT_UPPER 2500
+#define DA9052_BUCK_MEM_VOLT_LOWER 925
+#define DA9052_BUCK_MEM_STEP   25
+#define DA9052_BUCK_PERI_VOLT_UPPER2500
+#define DA9052_BUCK_PERI_VOLT_LOWER925
+#define DA9052_BUCK_PERI_STEP  25
+
 static iomux_v3_cfg_t mx53_loco_pads[] = {
/* FEC */
MX53_PAD_FEC_MDC__FEC_MDC,
@@ -227,6 +264,93 @@ static const struct esdhc_platform_data mx53_loco_sd3_data 
__initconst = {
.wp_type = ESDHC_WP_GPIO,
 };
 
+#define DA9052_LDO(max, min, rname, suspend_mv) \
+{\
+   .constraints = {\
+   .name   = (rname), \
+   .max_uV = (max) * 1000,\
+   .min_uV = (min) * 1000,\
+   .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE\
+   |REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE,\
+   .valid_modes_mask = REGULATOR_MODE_NORMAL,\
+   .state_mem = { \
+   .uV = suspend_mv * 1000, \
+   .mode = REGULATOR_MODE_NORMAL, \
+   .enabled = (0 == suspend_mv) ? 0 : 1, \
+   .disabled = 0, \
+   }, \
+   },\
+}
+
+/* currently the suspend_mv here takes no effects for DA9053
+preset-voltage have to be done in the latest stage during
+suspend*/
+static struct regulator_init_data da9052_regulators_init[] = {
+   /* BUCKS */
+   DA9052_LDO(DA9052_BUCK_CORE_PRO_VOLT_UPPER,
+  DA9052_BUCK_CORE_PRO_VOLT_LOWER, DA9052_BUCK_CORE, 850),
+   DA9052_LDO(DA9052_BUCK_CORE_PRO_VOLT_UPPER,
+  DA9052_BUCK_CORE_PRO_VOLT_LOWER, DA9052_BUCK_PRO, 950),
+   DA9052_LDO(DA9052_BUCK_MEM_VOLT_UPPER,
+  DA9052_BUCK_MEM_VOLT_LOWER, DA9052_BUCK_MEM, 1500),
+   DA9052_LDO(DA9052_BUCK_PERI_VOLT_UPPER,
+  DA9052_BUCK_PERI_VOLT_LOWER, DA9052_BUCK_PERI, 2500),
+   DA9052_LDO(DA9052_LDO1_VOLT_UPPER,
+  DA9052_LDO1_VOLT_LOWER, DA9052_LDO1, 1300),
+   DA9052_LDO(DA9052_LDO2_VOLT_UPPER,
+  DA9052_LDO2_VOLT_LOWER, DA9052_LDO2, 1300),
+   DA9052_LDO(DA9052_LDO34_VOLT_UPPER,
+  DA9052_LDO34_VOLT_LOWER, DA9052_LDO3, 3300),
+   DA9052_LDO(DA9052_LDO34_VOLT_UPPER,
+  DA9052_LDO34_VOLT_LOWER, DA9052_LDO4, 2775),
+   DA9052_LDO(DA9052_LDO567810_VOLT_UPPER,
+  DA9052_LDO567810_VOLT_LOWER, DA9052_LDO5, 1300),
+   DA9052_LDO(DA9052_LDO567810_VOLT_UPPER,
+  DA9052_LDO567810_VOLT_LOWER, DA9052_LDO6

Re: [PATCHv2] Regulator: Add Anatop regulator driver

2011-12-27 Thread Ying-Chun Liu (PaulLiu)
(2011年12月22日 19:33), Mark Brown wrote:
 
 +#include linux/platform_device.h
 +#include linux/regulator/machine.h
 
 Why does your regulator driver need this?  That suggests a layering
 violation.
 

Sorry, I'm not sure what does this mean.
But if I want to access regulator_constraints, shouldn't I include this
header file?

Yours Sincerely,
Paul


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


[PATCH v3] Regulator: Add Anatop regulator driver

2011-12-27 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

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 nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
---
 drivers/regulator/Kconfig  |6 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  214 
 include/linux/regulator/anatop-regulator.h |   63 
 4 files changed, 284 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 9713b1b..fc22b8d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -327,5 +327,11 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on SOC_IMX6
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 93a6318..990c332 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -46,5 +46,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..a925bcc
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,214 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/regulator/machine.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+
+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, rega, sel;
+   int uv;
+
+   uv = min_uV;
+   pr_debug(%s: uv %d, min %d, max %d\n, __func__,
+uv, anatop_reg-rdata-min_voltage,
+anatop_reg-rdata-max_voltage);
+
+   if (uv  anatop_reg-rdata-min_voltage
+   || uv  anatop_reg-rdata-max_voltage) {
+   if (max_uV  anatop_reg-rdata-min_voltage)
+   uv = anatop_reg-rdata-min_voltage;
+   else
+   return -EINVAL;
+   }
+
+   if (uv  reg-constraints-min_uV || uv  reg-constraints-max_uV)
+   return -EINVAL;
+
+   if (anatop_reg-rdata-control_reg) {
+   sel = (uv - anatop_reg-rdata-min_voltage) / 25000;
+   val = anatop_reg-rdata-min_bit_val + sel;
+   rega = (__raw_readl(anatop_reg-rdata-control_reg) 
+  ~(anatop_reg-rdata-vol_bit_mask 
+anatop_reg-rdata-vol_bit_shift));
+   *selector = sel;
+   pr_debug(%s: calculated val %d\n, __func__, val);
+   __raw_writel((val  anatop_reg-rdata-vol_bit_shift) | rega,
+anatop_reg-rdata-control_reg);
+   return 0;
+   } else {
+   return -ENOTSUPP;
+   }
+}
+
+static int anatop_get_voltage_sel(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+   int selector;
+   struct anatop_regulator_data *rdata = anatop_reg-rdata;
+
+   if (rdata-control_reg) {
+   u32 val = (__raw_readl(rdata-control_reg

[PATCHv2] Regulator: Add Anatop regulator driver

2011-12-21 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop regulator driver is used by i.MX6 SoC. The regulator provides
controlling the voltage of PU, CORE, SOC, and some devices. This patch
adds the Anatop regulator driver.

Signed-off-by: Nancy Chen nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
---
 drivers/regulator/Kconfig  |7 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  260 
 include/linux/regulator/anatop-regulator.h |   67 +++
 4 files changed, 335 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 9713b1b..6aebd6d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -327,5 +327,12 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on SOC_IMX6
+   default y if SOC_IMX6
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 93a6318..990c332 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -46,5 +46,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..31156d5
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,260 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/regulator/machine.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+
+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, rega;
+   int uv;
+
+   uv = max_uV;
+   pr_debug(%s: uv %d, min %d, max %d\n, __func__,
+uv, reg-constraints-min_uV,
+reg-constraints-max_uV);
+
+   if (uv  reg-constraints-min_uV || uv  reg-constraints-max_uV)
+   return -EINVAL;
+
+   if (anatop_reg-rdata-control_reg) {
+   val = anatop_reg-rdata-min_bit_val +
+   (uv - reg-constraints-min_uV) / 25000;
+   rega = (__raw_readl(anatop_reg-rdata-control_reg) 
+  ~(anatop_reg-rdata-vol_bit_mask 
+anatop_reg-rdata-vol_bit_shift));
+   pr_debug(%s: calculated val %d\n, __func__, val);
+   __raw_writel((val  anatop_reg-rdata-vol_bit_shift) | rega,
+anatop_reg-rdata-control_reg);
+   return 0;
+   } else {
+   pr_debug(Regulator not supported.\n);
+   return -ENOTSUPP;
+   }
+}
+
+static int anatop_get_voltage(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+   int uv;
+   struct anatop_regulator_data *rdata = anatop_reg-rdata;
+
+   if (rdata-control_reg) {
+   u32 val = (__raw_readl(rdata-control_reg) 
+  rdata-vol_bit_shift)  rdata-vol_bit_mask;
+   uv = reg-constraints-min_uV
+ + (val - rdata-min_bit_val) * 25000;
+   pr_debug(vddio = %d, val=%u\n, uv, val);
+   return uv;
+   } else {
+   pr_debug(Regulator not supported.\n

[PATCH] Regulator: Add Anatop regulator driver

2011-12-07 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Hi all,

This is the Anatop regulator used by Freescale i.MX6 SoC.
Please take a look and give me some comments.

Many Thanks,
Paul

Ying-Chun Liu (PaulLiu) (1):
  Regulator: Add Anatop regulator driver

 drivers/regulator/Kconfig  |7 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  236 
 include/linux/regulator/anatop-regulator.h |   82 ++
 4 files changed, 326 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

-- 
1.7.7.3


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


[PATCH] Regulator: Add Anatop regulator driver

2011-12-07 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop regulator driver is used by i.MX6 SoC. This patch adds the
Anatop regulator driver.

Signed-off-by: Nancy Chen nancy.c...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Liam Girdwood l...@ti.com
---
 drivers/regulator/Kconfig  |7 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/anatop-regulator.c   |  236 
 include/linux/regulator/anatop-regulator.h |   82 ++
 4 files changed, 326 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/anatop-regulator.c
 create mode 100644 include/linux/regulator/anatop-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 9713b1b..790eca5 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -327,5 +327,12 @@ config REGULATOR_AAT2870
  If you have a AnalogicTech AAT2870 say Y to enable the
  regulator driver.
 
+config REGULATOR_ANATOP
+   tristate ANATOP LDO regulators
+   depends on ARCH_MX6
+   default y if ARCH_MX6
+   help
+ Say y here to support ANATOP LDOs regulators.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 93a6318..990c332 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -46,5 +46,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..61ad1c2
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,236 @@
+/*
+ * 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 linux/slab.h
+#include linux/device.h
+#include linux/module.h
+#include linux/err.h
+#include linux/platform_device.h
+#include linux/regulator/machine.h
+#include linux/regulator/driver.h
+#include linux/regulator/anatop-regulator.h
+
+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);
+
+   if (anatop_reg-rdata-set_voltage)
+   return anatop_reg-rdata-set_voltage(anatop_reg, max_uV);
+   else
+   return -ENOTSUPP;
+}
+
+static int anatop_get_voltage(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+   if (anatop_reg-rdata-get_voltage)
+   return anatop_reg-rdata-get_voltage(anatop_reg);
+   else
+   return -ENOTSUPP;
+}
+
+static int anatop_enable(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+   return anatop_reg-rdata-enable(anatop_reg);
+}
+
+static int anatop_disable(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+   return anatop_reg-rdata-disable(anatop_reg);
+}
+
+static int anatop_is_enabled(struct regulator_dev *reg)
+{
+   struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+   return anatop_reg-rdata-is_enabled(anatop_reg);
+}
+
+static struct regulator_ops anatop_rops = {
+   .set_voltage= anatop_set_voltage,
+   .get_voltage= anatop_get_voltage,
+   .enable = anatop_enable,
+   .disable= anatop_disable,
+   .is_enabled = anatop_is_enabled,
+};
+
+static struct regulator_desc anatop_reg_desc[] = {
+   {
+   .name = vddpu,
+   .id = ANATOP_VDDPU,
+   .ops = anatop_rops,
+   .irq = 0,
+   .type = REGULATOR_VOLTAGE,
+   .owner = THIS_MODULE
+   },
+   {
+   .name = vddcore,
+   .id = ANATOP_VDDCORE,
+   .ops = anatop_rops,
+   .irq = 0,
+   .type

Re: [PATCH] Regulator: Add Anatop regulator driver

2011-12-07 Thread Ying-Chun Liu (PaulLiu)
(2011年12月07日 23:54), Mark Brown wrote:
 On Wed, Dec 07, 2011 at 09:53:18PM +0800, Ying-Chun Liu (PaulLiu) wrote:
 From: Ying-Chun Liu (PaulLiu) paul@linaro.org

 Anatop regulator driver is used by i.MX6 SoC. This patch adds the
 Anatop regulator driver.
 
 This changelog isn't terribly verbose but looking at the code what
 you've actually got here is a driver that is simply an indirection
 layer for the regulator API and no explanation as to why you're doing
 this.  My first thought is that anything using this driver should just
 be a regulator driver directly.

Hi Mark,

Thanks. I think you are correct. I just search the LKML and found that
this has been discussed already.
https://lkml.org/lkml/2011/10/28/325

So what we should do is forget this patch and use fixed regulators
rather than create an indirection layer.

Many Thanks,
Paul


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


Re: [PATCH] thermal: Add anatop thermal driver

2011-12-06 Thread Ying-Chun Liu (PaulLiu)
(2011年12月06日 18:45), Amit Kachhap wrote:
 +struct anatop_handle_list {
 +   u32 count;
 +   acpi_namespace_node * handles[ANATOP_ACPI_MAX_HANDLES];
 
 
 Is this handle used any where ?
  
 

Hi Amit,

No. It is not using at all.

As you said this driver needs a lot of clean-up.
I've discussed with Rob. We have split the tasks for power management.
He will upstream this driver soon. I'll do other drivers first and if I
have time left, I'll go back to help on this driver.

So I think we can reject this patch and wait for new version.

Many Thanks,
Paul

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


[PATCH] thermal: anatop thermal driver for imx6 platform

2011-12-03 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Dear all,

Please help me to review this thermal driver.
It uses Intel's thermal (drivers/thermal/thermal_sys.c) interface.
But looking into drivers/thermal I didn't find other drivers there.
I'm also thinking to put this driver into drivers/hwmon.
However, this driver doesn't create files in /sys/class/hwmon.

There are some discussions in
http://lists.linaro.org/pipermail/linaro-dev/2010-November/001626.html

There's currently no maintainers for drivers/thermal in MAINTAINERS in kernel
tree. So I send this mail to public mailing lists. Please give me some
comments.

Yours Sincerely,
Paul

Ying-Chun Liu (PaulLiu) (1):
  thermal: Add anatop thermal driver

 drivers/thermal/Kconfig  |   11 +
 drivers/thermal/Makefile |1 +
 drivers/thermal/anatop_driver.h  |  146 +++
 drivers/thermal/anatop_thermal.c |  825 ++
 4 files changed, 983 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/anatop_driver.h
 create mode 100644 drivers/thermal/anatop_thermal.c

-- 
1.7.7.3


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


[PATCH] thermal: Add anatop thermal driver

2011-12-03 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Anatop thermal driver for Freescale imx6 system. This driver currently
supports basic temperature reading.

Signed-off-by: Anson Huang b20...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/thermal/Kconfig  |   11 +
 drivers/thermal/Makefile |1 +
 drivers/thermal/anatop_driver.h  |  146 +++
 drivers/thermal/anatop_thermal.c |  825 ++
 4 files changed, 983 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/anatop_driver.h
 create mode 100644 drivers/thermal/anatop_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index f7f71b2..792152e 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -18,3 +18,14 @@ config THERMAL_HWMON
depends on THERMAL
depends on HWMON=y || HWMON=THERMAL
default y
+
+config THERMAL_ANATOP
+   tristate Anatop Thermal Zone
+   depends on THERMAL
+   default y
+   help
+ This driver supports ANATOP thermal zones. It is HIGHLY
+ recommended that this option be enabled on MX6 platform, as
+ your processor(s) may be damaged without it.
+
+ To compile this driver as a module, choose M here.
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 31108a0..2f88011 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_THERMAL)  += thermal_sys.o
+obj-$(CONFIG_THERMAL_ANATOP)   += anatop_thermal.o
diff --git a/drivers/thermal/anatop_driver.h b/drivers/thermal/anatop_driver.h
new file mode 100644
index 000..5879fca
--- /dev/null
+++ b/drivers/thermal/anatop_driver.h
@@ -0,0 +1,146 @@
+/*
+ *  anatop_drivers.h
+ *
+ *  Copyright (C) 2001, 2002 Andy Grover andrew.gro...@intel.com
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh paul.s.diefenba...@intel.com
+ *
+ *  Copyright (C) 2011 Freescale Semiconductor, Inc.
+ * ~~
+ *
+ *  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.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~
+ */
+
+#ifndef __ANATOP_DRIVERS_H__
+#define __ANATOP_DRIVERS_H__
+
+/* Device */
+#define ANATOP_ACPI_MAX_HANDLES10
+struct anatop_handle_list {
+   u32 count;
+   acpi_namespace_node * handles[ANATOP_ACPI_MAX_HANDLES];
+};
+
+struct anatop_device {
+   struct device dev;
+   acpi_namespace_node *handle;/* no handle for fixed hardware */
+   char name[40];
+   int id;
+   void *driver_data;
+};
+struct anatop_device_id {
+   __u8 id[ACPI_ID_LEN];
+   kernel_ulong_t driver_data;
+};
+typedef int (*anatop_op_add) (struct anatop_device *device);
+typedef int (*anatop_op_remove) (struct anatop_device *device, int type);
+typedef int (*anatop_op_start) (struct anatop_device *device);
+typedef int (*anatop_op_suspend) (struct anatop_device *device,
+   pm_message_t state);
+typedef int (*anatop_op_resume) (struct anatop_device *device);
+typedef int (*anatop_op_bind) (struct anatop_device *device);
+typedef int (*anatop_op_unbind) (struct anatop_device *device);
+typedef void (*anatop_op_notify) (struct anatop_device *device, u32 event);
+
+struct anatop_ops {
+   u32 anatop_op_add:1;
+   u32 anatop_op_start:1;
+};
+
+struct anatop_device_ops {
+   anatop_op_add add;
+   anatop_op_remove remove;
+   anatop_op_start start;
+   anatop_op_suspend suspend;
+   anatop_op_resume resume;
+   anatop_op_bind bind;
+   anatop_op_unbind unbind;
+   anatop_op_notify notify;
+};
+
+struct anatop_driver {
+   char name[80];
+   char class[80];
+   const struct acpi_device_id *ids; /* Supported Hardware IDs */
+   unsigned int flags;
+   struct anatop_device_ops ops;
+   struct device_driver drv;
+   struct module *owner;
+};
+
+
+
+typedef u32 anatop_status; /* All ANATOP Exceptions */
+
+#define AT_OK   (anatop_status) 0x
+#define AT_ERROR(anatop_status) 0x0001
+
+
+#define ANATOP_MAX_STRING  80
+
+/*
+ * Please update drivers/acpi/debug.c and Documentation/acpi/debug.txt

Re: [Patch 5/11] Regulator: DA9052/53 regulator support v4

2011-10-12 Thread Ying-Chun Liu (PaulLiu)
(2011年10月07日 20:20), ashishj3 wrote:
 The Dialog PMIC has below featured regulators:-
 DA9052-BC - 4 DVS Buck converters 0.5V - 3.6V upto 1Amp.
 DA9053-AA/BX - 4 DVS Buck converters 0.5V - 2.5V upto 3Amp.
 DA9052/53 - 10 Programmable LDO's High PSSR, 1% accuracy.
 
 This patch support all the DA9052 and Da9053 regulators. The output voltages 
 are
 fully programmable via I2C or SPI interface. The platform data with regulation
 constraints is passed down from the board to the regulator.
 
 Signed-off-by: David Dajun Chen dc...@diasemi.com
 Signed-off-by: Ashish Jangam ashish.jan...@kpitcummins.com
 CC: Mark Brown broo...@opensource.wolfsonmicro.com

Tested-by: Ying-Chun Liu (PaulLiu) paul@linaro.org

Hi,

I've reviewed the source code and tested this driver on imx53 QuickStart
board. Works good.

There are some minor warnings and error by running checkpatch.pl on this
patch.

WARNING: please write a paragraph that describes the config symbol fully
#50: FILE: drivers/regulator/Kconfig:173:
+   help

ERROR: do not set execute permissions for source files
#70: FILE: drivers/regulator/da9052-regulator.c

WARNING: line over 80 characters
#117: FILE: drivers/regulator/da9052-regulator.c:43:
+   {80, 100, 120, 150}, /* DA9053-AA/Bx BUCK-PRO,MEM,PERI 
*/

Yours Sincerely,
Paul

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


Re: [PATCH 01/11] MFD: DA9052/53 MFD core module v6

2011-10-11 Thread Ying-Chun Liu (PaulLiu)
(2011年09月19日 20:32), ashishj3 wrote:
 --- /dev/null
 +++ b/drivers/mfd/da9052-i2c.c
 @@ -0,0 +1,142 @@
 +/*
 + * I2C access for DA9052 PMICs.
 + *
 + * Copyright(c) 2011 Dialog Semiconductor Ltd.
 + *
 + * Author: David Dajun Chen dc...@diasemi.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; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + */
 +
 +#include linux/device.h
 +#include linux/input.h
 +#include linux/mfd/core.h
 +#include linux/i2c.h
 +#include linux/err.h
 +
 +#include linux/mfd/da9052/da9052.h
 +#include linux/mfd/da9052/reg.h
 +
 +static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
 +{
 + int reg_val, ret;
 +
 + ret = regmap_read(da9052-regmap, DA9052_CONTROL_B_REG, reg_val);
 + if (ret  0)
 + return ret;
 +
 + if (reg_val  DA9052_CONTROL_B_WRITEMODE) {
 + reg_val = ~DA9052_CONTROL_B_WRITEMODE;

Hi Ashish,

I think you should use reg_val = ~DA9052_CONTROL_B_WRITEMODE; instead
of just =.

Regards,
Paul

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


Re: [Patch 5/11] Regulator: DA9052 regulator support v3

2011-10-07 Thread Ying-Chun Liu (PaulLiu)
(2011年07月06日 18:36), ashishj3 wrote:
 +static int __devinit da9052_regulator_probe(struct platform_device *pdev)
 +{
 + struct da9052_regulator *regulator;
 + struct da9052 *da9052;
 + struct da9052_pdata *pdata;
 + int ret;
 +
 + regulator = kzalloc(sizeof(struct da9052_regulator), GFP_KERNEL);
 + if (!regulator)
 + return -ENOMEM;
 +
 + da9052 = dev_get_drvdata(pdev-dev.parent);
 + pdata = da9052-dev-platform_data;
 +
 + regulator-info = find_regulator_info(pdev-id);
 + if (regulator-info == NULL) {
 + dev_err(pdev-dev, invalid regulator ID specified\n);
 + ret = -EINVAL;
 + goto err;
 + }
 +
 + regulator-rdev = regulator_register(regulator-info-reg_desc,
 +  pdev-dev,
 +  pdata-regulators[pdev-id],
 +  regulator);
 + if (IS_ERR(regulator-rdev)) {
 + dev_err(pdev-dev, failed to register regulator %s\n,
 + regulator-info-reg_desc.name);
 + ret = PTR_ERR(regulator-rdev);
 + goto err;
 + }
 +
 + platform_set_drvdata(pdev, regulator);
 +
 + return 0;
 +err:
 + kfree(regulator);
 + return ret;
 +}

Hi Ashish,

It seems to me that in this function, regulator-da9052 isn't initialized.

Regards,
Paul

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


Re: Meeting request

2011-06-22 Thread Ying-Chun Liu (PaulLiu)
(2011年06月22日 21:08), Eric Miao wrote:
 Will the same time slot for Friday works for you all? Also thanks for 
 extending
 the help.
 
 That works for me.

I'm ok with that too.. :)


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


Re: [PATCH 00/11] RFC: DA9053 PMIC driver

2011-06-11 Thread Ying-Chun Liu (PaulLiu)
Hi Andy, Mark, Arnd, Rob,

Thanks for the reviews.
As Mark said, there's already same and better patches on LKML.
Thus I'm going to try using the patches posted on LKML on my board
(imx53) to see if they work or not. And then add some comments.

Here's the list:
 * LED https://lkml.org/lkml/2011/5/13/168
 * MFD https://lkml.org/lkml/2011/5/3/128
 * GPIO https://lkml.org/lkml/2011/4/13/107
 * Backlight https://lkml.org/lkml/2011/5/4/81
 * Regulator http://lkml.org/lkml/2011/5/3/126
 * HWMON https://lkml.org/lkml/2011/5/4/118
 * Battery https://lkml.org/lkml/2011/4/13/110
 * RTC https://lkml.org/lkml/2011/4/6/179
 * TSI https://lkml.org/lkml/2011/4/13/112
 * Watchdog https://lkml.org/lkml/2011/4/6/159

Regards,
Paul

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


[PATCH 00/11] RFC: DA9053 PMIC driver

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Hi. I'm trying to push DA9053 PMIC driver to mainline kernel.
Please help me to review these patches.
Many Thanks.

Ying-Chun Liu (PaulLiu) (11):
  PMIC: Add DA9053 headers from Dialog
  PMIC: Add GPIO Driver for Dialog DA9052
  PMIC: Add ADC Driver for Dialog DA9052
  PMIC: Add TSI/misc input Driver for Dialog DA9052
  PMIC: Add LED Driver for Dialog DA9052
  PMIC: Add MFD Driver for Dialog DA9052
  PMIC: Add BATTERY Driver for Dialog DA9052
  PMIC: Add REGULATOR Driver for Dialog DA9052
  PMIC: Add RTC Driver for Dialog DA9052
  PMIC: Add Video Backlight Driver for Dialog DA9052
  PMIC: Add Watchdog Driver for Dialog DA9052

 drivers/gpio/Kconfig |7 +
 drivers/gpio/Makefile|1 +
 drivers/gpio/da9052-gpio.c   |  731 +++
 drivers/hwmon/Kconfig|   10 +
 drivers/hwmon/Makefile   |1 +
 drivers/hwmon/da9052-adc.c   |  644 ++
 drivers/input/misc/Kconfig   |   10 +
 drivers/input/misc/Makefile  |1 +
 drivers/input/misc/da9052_onkey.c|  133 ++
 drivers/input/touchscreen/Kconfig|7 +
 drivers/input/touchscreen/Makefile   |2 +
 drivers/input/touchscreen/da9052_tsi.c   | 1446 ++
 drivers/input/touchscreen/da9052_tsi_calibrate.c |  107 ++
 drivers/input/touchscreen/da9052_tsi_filter.c|  489 
 drivers/leds/Kconfig |   10 +
 drivers/leds/Makefile|1 +
 drivers/leds/leds-da9052.c   |  308 +
 drivers/mfd/Kconfig  |   37 +
 drivers/mfd/Makefile |2 +
 drivers/mfd/da9052-core.c|  536 
 drivers/mfd/da9052-i2c.c |  378 ++
 drivers/mfd/da9052-spi.c |  402 ++
 drivers/power/Kconfig|7 +
 drivers/power/Makefile   |1 +
 drivers/power/da9052-battery.c   |  847 +
 drivers/regulator/Kconfig|7 +
 drivers/regulator/Makefile   |2 +
 drivers/regulator/da9052-regulator.c |  490 
 drivers/rtc/Kconfig  |7 +
 drivers/rtc/Makefile |1 +
 drivers/rtc/rtc-da9052.c |  694 +++
 drivers/video/backlight/Kconfig  |6 +
 drivers/video/backlight/Makefile |2 +-
 drivers/video/backlight/da9052_bl.c  |  461 +++
 drivers/watchdog/Kconfig |5 +
 drivers/watchdog/Makefile|1 +
 drivers/watchdog/da9052_wdt.c|  542 
 include/linux/mfd/da9052/adc.h   |   66 +
 include/linux/mfd/da9052/bat.h   |  264 
 include/linux/mfd/da9052/bl.h|  289 +
 include/linux/mfd/da9052/da9052.h|  209 
 include/linux/mfd/da9052/eh.h|   77 ++
 include/linux/mfd/da9052/gpio.h  |  253 
 include/linux/mfd/da9052/led.h   |   39 +
 include/linux/mfd/da9052/pm.h|   81 ++
 include/linux/mfd/da9052/reg.h   |  929 ++
 include/linux/mfd/da9052/rtc.h   |  322 +
 include/linux/mfd/da9052/tsi.h   |  427 +++
 include/linux/mfd/da9052/tsi_calibrate.h |   47 +
 include/linux/mfd/da9052/tsi_cfg.h   |  132 ++
 include/linux/mfd/da9052/tsi_filter.h|   58 +
 include/linux/mfd/da9052/wdt.h   |   83 ++
 include/linux/regulator/da9052-regulator.h   |   15 +
 53 files changed, 11626 insertions(+), 1 deletions(-)
 create mode 100644 drivers/gpio/da9052-gpio.c
 create mode 100644 drivers/hwmon/da9052-adc.c
 create mode 100644 drivers/input/misc/da9052_onkey.c
 create mode 100644 drivers/input/touchscreen/da9052_tsi.c
 create mode 100644 drivers/input/touchscreen/da9052_tsi_calibrate.c
 create mode 100644 drivers/input/touchscreen/da9052_tsi_filter.c
 create mode 100644 drivers/leds/leds-da9052.c
 create mode 100644 drivers/mfd/da9052-core.c
 create mode 100644 drivers/mfd/da9052-i2c.c
 create mode 100644 drivers/mfd/da9052-spi.c
 create mode 100644 drivers/power/da9052-battery.c
 create mode 100644 drivers/regulator/da9052-regulator.c
 create mode 100644 drivers/rtc/rtc-da9052.c
 create mode 100644 drivers/video/backlight/da9052_bl.c
 create mode 100644 drivers/watchdog/da9052_wdt.c
 create mode 100644 include/linux/mfd/da9052/adc.h
 create mode 100644 include/linux/mfd/da9052/bat.h
 create mode 100644 include/linux/mfd/da9052/bl.h
 create mode 100644 include/linux/mfd

[PATCH 02/11] PMIC: Add GPIO Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 gpio driver from Dialog.
Modify Kconfig/Makefile for DA9052 gpio driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/gpio/Kconfig   |7 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/da9052-gpio.c |  731 
 3 files changed, 739 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpio/da9052-gpio.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 2967002..ab93c7ab 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -453,4 +453,11 @@ config GPIO_TPS65910
help
  Select this option to enable GPIO driver for the TPS65910
  chip family.
+
+config DA9052_GPIO_ENABLE
+   bool Dialog DA9052 GPIO
+   depends on PMIC_DIALOG
+   help
+ Say Y  to enable the GPIO driver for the DA9052 chip
+
 endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index b605f8e..cebe1c3 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -48,3 +48,4 @@ obj-$(CONFIG_GPIO_VX855)  += vx855_gpio.o
 obj-$(CONFIG_GPIO_ML_IOH)  += ml_ioh_gpio.o
 obj-$(CONFIG_AB8500_GPIO)   += ab8500-gpio.o
 obj-$(CONFIG_GPIO_TPS65910)+= tps65910-gpio.o
+obj-$(CONFIG_DA9052_GPIO_ENABLE)+= da9052-gpio.o
diff --git a/drivers/gpio/da9052-gpio.c b/drivers/gpio/da9052-gpio.c
new file mode 100644
index 000..a9c53f2
--- /dev/null
+++ b/drivers/gpio/da9052-gpio.c
@@ -0,0 +1,731 @@
+/*
+ * da9052-gpio.c  --  GPIO Driver for Dialog DA9052
+ *
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * Author: Dialog Semiconductor Ltd dc...@diasemi.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;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include linux/module.h
+#include linux/fs.h
+#include linux/uaccess.h
+#include linux/platform_device.h
+#include linux/syscalls.h
+#include linux/seq_file.h
+#include linux/gpio.h
+
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/reg.h
+#include linux/mfd/da9052/gpio.h
+
+#define DRIVER_NAME da9052-gpio
+static inline struct da9052_gpio_chip *to_da9052_gpio(struct gpio_chip *chip)
+{
+   return container_of(chip, struct da9052_gpio_chip, gp);
+}
+
+void da9052_gpio_notifier(struct da9052_eh_nb *eh_data, unsigned int event)
+{
+   struct da9052_gpio_chip *gpio =
+   container_of(eh_data, struct da9052_gpio_chip, eh_data);
+   kobject_uevent(gpio-gp.dev-kobj, KOBJ_CHANGE);
+   printk(KERN_INFO Event received from GPIO8\n);
+}
+
+static u8 create_gpio_config_value(u8 gpio_function, u8 gpio_type, u8 
gpio_mode)
+{
+   /* The format is -
+   function - 2 bits
+   type - 1 bit
+   mode - 1 bit */
+   return gpio_function | (gpio_type  2) | (gpio_mode  3);
+}
+
+static s32 write_default_gpio_values(struct da9052 *da9052)
+{
+   struct da9052_ssc_msg msg;
+   u8 created_val = 0;
+
+#if (DA9052_GPIO_PIN_0 == DA9052_GPIO_CONFIG)
+   da9052_lock(da9052);
+   msg.addr = DA9052_GPIO0001_REG;
+   msg.data = 0;
+
+   if (da9052-read(da9052, msg)) {
+   da9052_unlock(da9052);
+   return -EIO;
+   }
+
+   created_val = create_gpio_config_value(DEFAULT_GPIO0_FUNCTION,
+   DEFAULT_GPIO0_TYPE, DEFAULT_GPIO0_MODE);
+   msg.data = DA9052_GPIO_MASK_UPPER_NIBBLE;
+   msg.data |= created_val;
+
+   if (da9052-write(da9052, msg)) {
+   da9052_unlock(da9052);
+   return -EIO;
+   }
+   da9052_unlock(da9052);
+#endif
+#if (DA9052_GPIO_PIN_1 == DA9052_GPIO_CONFIG)
+   da9052_lock(da9052);
+   msg.addr = DA9052_GPIO0001_REG;
+   msg.data = 0;
+
+   if (da9052-read(da9052, msg)) {
+   da9052_unlock(da9052);
+   return -EIO;
+   }
+
+   created_val = create_gpio_config_value(DEFAULT_GPIO1_FUNCTION,
+   DEFAULT_GPIO1_TYPE, DEFAULT_GPIO1_MODE);
+   created_val = created_val  DA9052_GPIO_NIBBLE_SHIFT;
+   msg.data = DA9052_GPIO_MASK_LOWER_NIBBLE;
+   msg.data |= created_val;
+
+   if (da9052-write(da9052, msg)) {
+   da9052_unlock(da9052);
+   return -EIO;
+   }
+   da9052_unlock(da9052);
+#endif
+/* GPIO 2-3*/
+#if (DA9052_GPIO_PIN_2 == DA9052_GPIO_CONFIG)
+   da9052_lock(da9052);
+   msg.addr = DA9052_GPIO0203_REG;
+   msg.data = 0;
+
+   if (da9052-read(da9052, msg)) {
+   da9052_unlock(da9052);
+   return -EIO;
+   }
+
+   created_val = create_gpio_config_value(DEFAULT_GPIO2_FUNCTION,
+   DEFAULT_GPIO2_TYPE, DEFAULT_GPIO2_MODE

[PATCH 03/11] PMIC: Add ADC Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 ADC driver from Dialog.
Modify Kconfig/Makefile for DA9052 ADC driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/hwmon/Kconfig  |   10 +
 drivers/hwmon/Makefile |1 +
 drivers/hwmon/da9052-adc.c |  644 
 3 files changed, 655 insertions(+), 0 deletions(-)
 create mode 100644 drivers/hwmon/da9052-adc.c

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 16db83c..ad652dd 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -39,6 +39,16 @@ config HWMON_DEBUG_CHIP
 
 comment Native drivers
 
+config SENSORS_DA9052
+   tristate Dialog DA9052 HWMon
+   depends on PMIC_DIALOG
+   help
+ Say y here to support the ADC found on Dialog Semiconductor DA9052
+ PMIC.
+
+ This driver can also be built as a module.  If so, the module
+ will be called da9052-adc.
+
 config SENSORS_ABITUGURU
tristate Abit uGuru (rev 1  2)
depends on X86  DMI  EXPERIMENTAL
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 28061cf..e640ff8 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -118,6 +118,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
 obj-$(CONFIG_SENSORS_W83L786NG)+= w83l786ng.o
 obj-$(CONFIG_SENSORS_WM831X)   += wm831x-hwmon.o
 obj-$(CONFIG_SENSORS_WM8350)   += wm8350-hwmon.o
+obj-$(CONFIG_SENSORS_DA9052)   += da9052-adc.o
 
 # PMBus drivers
 obj-$(CONFIG_PMBUS)+= pmbus_core.o
diff --git a/drivers/hwmon/da9052-adc.c b/drivers/hwmon/da9052-adc.c
new file mode 100644
index 000..57985c2
--- /dev/null
+++ b/drivers/hwmon/da9052-adc.c
@@ -0,0 +1,644 @@
+/*
+ * da9052-adc.c  --  ADC Driver for Dialog DA9052
+ *
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * Author: Dialog Semiconductor Ltd dc...@diasemi.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;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+#include linux/platform_device.h
+#include linux/hwmon-sysfs.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/hwmon.h
+#include linux/slab.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/reg.h
+#include linux/mfd/da9052/adc.h
+
+#define DRIVER_NAME da9052-adc
+
+static const char * const input_names[] = {
+   [DA9052_ADC_VDDOUT] =   VDDOUT,
+   [DA9052_ADC_ICH]=   CHARGING CURRENT,
+   [DA9052_ADC_TBAT]   =   BATTERY TEMP,
+   [DA9052_ADC_VBAT]   =   BATTERY VOLTAGE,
+   [DA9052_ADC_ADCIN4] =   ADC INPUT 4,
+   [DA9052_ADC_ADCIN5] =   ADC INPUT 5,
+   [DA9052_ADC_ADCIN6] =   ADC INPUT 6,
+   [DA9052_ADC_TSI]=   TSI,
+   [DA9052_ADC_TJUNC]  =   BATTERY JUNCTION TEMP,
+   [DA9052_ADC_VBBAT]  =   BACK-UP BATTERY TEMP,
+};
+
+
+int da9052_manual_read(struct da9052 *da9052,
+   unsigned char channel)
+{
+   unsigned char man_timeout_cnt = DA9052_ADC_MAX_MANCONV_RETRY_COUNT;
+   struct da9052_ssc_msg msg;
+   unsigned short calc_data;
+   unsigned int ret;
+   u16 data = 0;
+
+   msg.addr = DA9052_ADCMAN_REG;
+   msg.data = channel;
+   msg.data =  (msg.data | DA9052_ADCMAN_MANCONV);
+
+   mutex_lock(da9052-manconv_lock);
+   da9052_lock(da9052);
+
+   ret = da9052-write(da9052, msg);
+   if (ret)
+   goto err_ssc_comm;
+   da9052_unlock(da9052);
+
+   /* Wait for the event */
+   do {
+   msg.addr = DA9052_ADCCONT_REG;
+   msg.data = 0;
+   da9052_lock(da9052);
+   ret = da9052-read(da9052, msg);
+   if (ret)
+   goto err_ssc_comm;
+   da9052_unlock(da9052);
+
+   if (DA9052_ADCCONT_ADCMODE  msg.data)
+   msleep(1);
+   else
+   msleep(10);
+
+   msg.addr = DA9052_ADCMAN_REG;
+   msg.data = 0;
+   da9052_lock(da9052);
+   ret = da9052-read(da9052, msg);
+   if (ret)
+   goto err_ssc_comm;
+   da9052_unlock(da9052);
+
+   /* Counter to avoid endless while loop */
+   man_timeout_cnt--;
+   if (man_timeout_cnt == 1) {
+   if (!(msg.data  DA9052_ADCMAN_MANCONV))
+   break;
+   else
+   goto err_ssc_comm;
+   }
+   /* Wait until the MAN_CONV bit is cleared

[PATCH 06/11] PMIC: Add MFD Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 mfd driver from Dialog.
Modify Kconfig/Makefile for DA9052 mfd driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/mfd/Kconfig   |   37 +++
 drivers/mfd/Makefile  |2 +
 drivers/mfd/da9052-core.c |  536 +
 drivers/mfd/da9052-i2c.c  |  378 
 drivers/mfd/da9052-spi.c  |  402 +
 5 files changed, 1355 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/da9052-core.c
 create mode 100644 drivers/mfd/da9052-i2c.c
 create mode 100644 drivers/mfd/da9052-spi.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 0f09c05..a3d0568 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -483,6 +483,43 @@ config PCF50633_GPIO
 Say yes here if you want to include support GPIO for pins on
 the PCF50633 chip.
 
+config PMIC_DIALOG
+   bool Support Dialog Semiconductor PMIC
+   depends on I2C=y
+   depends on SPI=y
+   select MFD_CORE
+   help
+   Support for Dialog semiconductor PMIC chips.
+   Use the options provided to support the desired PMIC's.
+choice
+   prompt Chip Type
+   depends on PMIC_DIALOG
+config PMIC_DA9052
+   bool Support Dialog Semiconductor DA9052 PMIC
+   help
+   Support for Dialog semiconductor DA9052 PMIC with inbuilt
+   SPI  I2C connectivities.
+   This driver provides common support for accessing  the device,
+   additional drivers must be enabled in order to use the
+   functionality of the device.
+config PMIC_DA9053AA
+   bool Support Dialog Semiconductor DA9053 AA PMIC
+   help
+   Support for Dialog semiconductor DA9053 AA PMIC with inbuilt
+   SPI  I2C connectivities.
+   This driver provides common support for accessing  the device,
+   additional drivers must be enabled in order to use the
+   functionality of the device.
+config PMIC_DA9053Bx
+   bool Support Dialog Semiconductor DA9053 BA/BB PMIC
+   help
+   Support for Dialog semiconductor DA9053 BA/BB PMIC with inbuilt
+   SPI  I2C connectivities.
+   This driver provides common support for accessing  the device,
+   additional drivers must be enabled in order to use the
+   functionality of the device.
+endchoice
+
 config MFD_MC13783
tristate
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index efe3cc3..d30b69c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -94,3 +94,5 @@ obj-$(CONFIG_MFD_OMAP_USB_HOST)   += omap-usb-host.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o
 obj-$(CONFIG_MFD_PM8XXX_IRQ)   += pm8xxx-irq.o
 obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o
+da9052-objs:= da9052-spi.o da9052-i2c.o da9052-core.o
+obj-$(CONFIG_PMIC_DIALOG)  += da9052.o
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
new file mode 100644
index 000..002cf50
--- /dev/null
+++ b/drivers/mfd/da9052-core.c
@@ -0,0 +1,536 @@
+/*
+ * da9052-core.c  --  Device access for Dialog DA9052
+ *
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * Author: Dialog Semiconductor Ltd dc...@diasemi.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;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include linux/device.h
+#include linux/jiffies.h
+#include linux/delay.h
+#include linux/interrupt.h
+#include linux/workqueue.h
+#include linux/irq.h
+#include linux/list.h
+#include linux/mfd/core.h
+#include linux/spi/spi.h
+#include linux/i2c.h
+#include linux/semaphore.h
+
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/adc.h
+
+#define SUCCESS0
+#define FAILURE1
+
+struct da9052_eh_nb eve_nb_array[EVE_CNT];
+static struct da9052_ssc_ops ssc_ops;
+struct mutex manconv_lock;
+static struct semaphore eve_nb_array_lock;
+
+void da9052_lock(struct da9052 *da9052)
+{
+   mutex_lock(da9052-ssc_lock);
+}
+EXPORT_SYMBOL(da9052_lock);
+
+void da9052_unlock(struct da9052 *da9052)
+{
+   mutex_unlock(da9052-ssc_lock);
+}
+EXPORT_SYMBOL(da9052_unlock);
+
+int da9052_ssc_write(struct da9052 *da9052, struct da9052_ssc_msg *sscmsg)
+{
+   int ret = 0;
+
+   /* Reg address should be a valid address on PAGE0 or PAGE1 */
+   if ((sscmsg-addr  DA9052_PAGE0_REG_START) ||
+   (sscmsg-addr  DA9052_PAGE1_REG_END) ||
+   ((sscmsg-addr  DA9052_PAGE0_REG_END) 
+   (sscmsg-addr  DA9052_PAGE1_REG_START)))
+   return INVALID_REGISTER;
+
+   ret = ssc_ops.write(da9052, sscmsg);
+
+   /* Update local cache if required */
+   if (!ret

[PATCH 10/11] PMIC: Add Video Backlight Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 video backlight driver from Dialog.
Modify Kconfig/Makefile for DA9052 video backlight driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/video/backlight/Kconfig |6 +
 drivers/video/backlight/Makefile|2 +-
 drivers/video/backlight/da9052_bl.c |  461 +++
 3 files changed, 468 insertions(+), 1 deletions(-)
 create mode 100644 drivers/video/backlight/da9052_bl.c

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 0c9373b..a233749 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -315,6 +315,12 @@ config BACKLIGHT_PCF50633
  If you have a backlight driven by a NXP PCF50633 MFD, say Y here to
  enable its driver.
 
+config BACKLIGHT_DA9052
+   tristate Dialog DA9052 WLED
+   depends on PMIC_DIALOG
+   help
+ Enable the DA9052 Backlight Driver
+
 endif # BACKLIGHT_CLASS_DEVICE
 
 endif # BACKLIGHT_LCD_SUPPORT
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index b9ca849..0c8334f 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -36,4 +36,4 @@ obj-$(CONFIG_BACKLIGHT_ADP5520)   += adp5520_bl.o
 obj-$(CONFIG_BACKLIGHT_ADP8860)+= adp8860_bl.o
 obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o
 obj-$(CONFIG_BACKLIGHT_PCF50633)   += pcf50633-backlight.o
-
+obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o
diff --git a/drivers/video/backlight/da9052_bl.c 
b/drivers/video/backlight/da9052_bl.c
new file mode 100644
index 000..0692194
--- /dev/null
+++ b/drivers/video/backlight/da9052_bl.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * 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.
+ *
+ * da9052_bl.c: Backlight driver for DA9052
+ */
+
+#include linux/platform_device.h
+#include linux/fb.h
+#include linux/backlight.h
+
+#include linux/delay.h
+
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/reg.h
+#include linux/mfd/da9052/bl.h
+
+
+#define DRIVER_NAMEda9052-backlight
+#define DRIVER_NAME1   WLED-1
+#define DRIVER_NAME2   WLED-2
+#define DRIVER_NAME3   WLED-3
+
+/* These flags define if Backlight LEDs are present */
+/* Set the following macros to 1, if LEDs are present. Otherwise set to 0 */
+#define DA9052_LED1_PRESENT1
+#define DA9052_LED2_PRESENT1
+#define DA9052_LED3_PRESENT1
+
+#define DA9052_MAX_BRIGHTNESS  0xFF
+
+struct da9052_backlight_data {
+   struct device *da9052_dev;
+   int current_brightness;
+   struct da9052 *da9052;
+
+   int is_led1_present;
+   int is_led2_present;
+   int is_led3_present;
+};
+
+enum da9052_led_number {
+   LED1 = 1,
+   LED2,
+   LED3,
+};
+
+static int da9052_backlight_brightness_set(struct da9052_backlight_data *data,
+   int brightness, enum da9052_led_number led)
+{
+   /*
+* Mechanism for brightness control:
+* For brightness control, current is used.
+* PWM feature is not used.
+* To use PWM feature, a fixed value of current should be defined.
+*/
+
+   int ret = 0;
+   unsigned int led_ramp_bit;
+   unsigned int led_current_register;
+   unsigned int led_current_sink_bit;
+   unsigned int led_boost_en_bit;
+   struct da9052_ssc_msg msg;
+
+   switch (led) {
+   case LED1:
+   led_ramp_bit = DA9052_LEDCONT_LED1RAMP;
+   led_current_register = DA9052_LED1CONF_REG;
+   led_current_sink_bit = DA9052_LEDCONT_LED1EN;
+   led_boost_en_bit = DA9052_BOOST_LED1INEN;
+   break;
+   case LED2:
+   led_ramp_bit = DA9052_LEDCONT_LED2RAMP;
+   led_current_register = DA9052_LED2CONF_REG;
+   led_current_sink_bit = DA9052_LEDCONT_LED2EN;
+   led_boost_en_bit = DA9052_BOOST_LED2INEN;
+   break;
+   case LED3:
+   led_ramp_bit = DA9052_LEDCONT_LED3RAMP;
+   led_current_register = DA9052_LED3CONF_REG;
+   led_current_sink_bit = DA9052_LEDCONT_LED3EN;
+   led_boost_en_bit = DA9052_BOOST_LED3INEN;
+   break;
+   default:
+   return -EIO;
+   }
+
+   /*
+   1. Configure the boost register
+   2. Configure the LED _CONT register
+   3. Configure the LEDx_CONF registers to the brightness value.
+   */
+   msg.addr = DA9052_BOOST_REG;
+   msg.data = 0x3F;
+   if (brightness) {
+   da9052_lock(data-da9052

[PATCH 11/11] PMIC: Add Watchdog Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 watchdog driver from Dialog.
Modify Kconfig/Makefile for DA9052 watchdog driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/watchdog/Kconfig  |5 +
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/da9052_wdt.c |  542 +
 3 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/da9052_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 022f9eb..f2a8025 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1232,6 +1232,11 @@ config WDTPCI
  To compile this driver as a module, choose M here: the
  module will be called wdt_pci.
 
+config DA9052_WATCHDOG
+   tristate Dialog DA9052 Watchdog
+   depends on PMIC_DIALOG
+   help
+ Support for the watchdog in the DA9052 PMIC.
 #
 # USB-based Watchdog Cards
 #
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index ed26f70..fae2cfc 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -159,3 +159,4 @@ obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o
 obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
 obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
+obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o
diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c
new file mode 100644
index 000..7d0ecd9
--- /dev/null
+++ b/drivers/watchdog/da9052_wdt.c
@@ -0,0 +1,542 @@
+#include linux/miscdevice.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/fs.h
+#include linux/delay.h
+#include linux/timer.h
+#include linux/uaccess.h
+#include linux/jiffies.h
+#include linux/platform_device.h
+#include linux/time.h
+#include linux/watchdog.h
+#include linux/types.h
+#include linux/kernel.h
+
+
+#include linux/mfd/da9052/reg.h
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/wdt.h
+
+#define DRIVER_NAME da9052-wdt
+
+#defineDA9052_STROBING_FILTER_ENABLE   0x0001
+#defineDA9052_STROBING_FILTER_DISABLE  0x0002
+#defineDA9052_SET_STROBING_MODE_MANUAL 0x0004
+#defineDA9052_SET_STROBING_MODE_AUTO   0x0008
+
+#define KERNEL_MODULE  0
+#define ENABLE 1
+#define DISABLE0
+
+static u8 sm_strobe_filter_flag = DISABLE;
+static u8 sm_strobe_mode_flag = DA9052_STROBE_MANUAL;
+static u32 sm_mon_interval = DA9052_ADC_TWDMIN_TIME;
+static u8 sm_str_req = DISABLE;
+static u8 da9052_sm_scale = DA9052_WDT_DISABLE;
+module_param(sm_strobe_filter_flag,  byte, 0);
+MODULE_PARM_DESC(sm_strobe_filter_flag,
+   DA9052 SM driver strobe filter flag default = DISABLE);
+
+module_param(sm_strobe_mode_flag, byte, 0);
+MODULE_PARM_DESC(sm_strobe_mode_flag,
+   DA9052 SM driver watchdog strobing mode default\
+   = DA9052_STROBE_MANUAL);
+
+module_param(da9052_sm_scale, byte, 0);
+MODULE_PARM_DESC(da9052_sm_scale,
+   DA9052 SM driver scaling value used to calculate the\
+   time for the strobing  filter default = 0);
+
+module_param(sm_str_req, byte, 0);
+MODULE_PARM_DESC(sm_str_req,
+   DA9052 SM driver strobe request flag default = DISABLE);
+
+static int nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout,
+   Watchdog cannot be stopped once started (default=
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ));
+
+static struct timer_list *monitoring_timer;
+
+struct da9052_wdt {
+   struct platform_device *pdev;
+   struct da9052 *da9052;
+};
+static struct miscdevice da9052_wdt_miscdev;
+static unsigned long da9052_wdt_users;
+static int da9052_wdt_expect_close;
+
+static struct da9052_wdt *get_wdt_da9052(void)
+{
+   /*return dev_get_drvdata(da9052_wdt_miscdev.parent);*/
+   return platform_get_drvdata
+   (to_platform_device(da9052_wdt_miscdev.parent));
+}
+
+void start_strobing(struct work_struct *work)
+{
+   struct da9052_ssc_msg msg;
+   int ret;
+   struct da9052_wdt *wdt = get_wdt_da9052();
+
+
+   if (NULL == wdt) {
+   mod_timer(monitoring_timer, jiffies + sm_mon_interval);
+   return;
+   }
+   msg.addr = DA9052_CONTROLD_REG;
+   msg.data = 0;
+   da9052_lock(wdt-da9052);
+   ret = wdt-da9052-read(wdt-da9052, msg);
+   if (ret) {
+   da9052_unlock(wdt-da9052);
+   return;
+   }
+   da9052_unlock(wdt-da9052);
+
+   msg.data = (msg.data | DA9052_CONTROLD_WATCHDOG);
+   da9052_lock(wdt-da9052);
+   ret = wdt-da9052-write(wdt-da9052, msg);
+   if (ret) {
+   da9052_unlock(wdt-da9052

[PATCH 08/11] PMIC: Add REGULATOR Driver for Dialog DA9052

2011-06-09 Thread Ying-Chun Liu (PaulLiu)
From: Ying-Chun Liu (PaulLiu) paul@linaro.org

Add DA9052 regulator driver from Dialog.
Modify Kconfig/Makefile for DA9052 regulator driver.

Signed-off-by: Zhou Jingyu jingyu.z...@freescale.com
Acked-by: Lily Zhang r58...@freescale.com
Signed-off-by: Ying-Chun Liu (PaulLiu) paul@linaro.org
---
 drivers/regulator/Kconfig  |7 +
 drivers/regulator/Makefile |2 +
 drivers/regulator/da9052-regulator.c   |  490 
 include/linux/regulator/da9052-regulator.h |   15 +
 4 files changed, 514 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/da9052-regulator.c
 create mode 100644 include/linux/regulator/da9052-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index d7ed20f..4ae56ac 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -303,5 +303,12 @@ config REGULATOR_TPS65910
help
  This driver supports TPS65910 voltage regulator chips.
 
+config REGULATOR_DA9052
+   tristate Dialog DA9052 regulators
+   depends on PMIC_DIALOG
+   help
+ Say y here to support the BUCKs and LDOs regulators found on
+ Dialog Semiconductor DA9052 PMIC.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 3932d2e..2aa6496 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
+obj-$(CONFIG_REGULATOR_DA9052)  += da9052-regulator.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
 obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
@@ -43,5 +44,6 @@ obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
 obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
+obj-$(CONFIG_REGULATOR_DA9052)  += da9052-regulator.o
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/da9052-regulator.c 
b/drivers/regulator/da9052-regulator.c
new file mode 100644
index 000..612fe60
--- /dev/null
+++ b/drivers/regulator/da9052-regulator.c
@@ -0,0 +1,490 @@
+/*
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * 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.
+ *
+ * da9052-regulator.c: Regulator driver for DA9052
+ */
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/err.h
+#include linux/platform_device.h
+#include linux/regulator/driver.h
+#include linux/regulator/machine.h
+
+#include linux/mfd/da9052/da9052.h
+#include linux/mfd/da9052/reg.h
+#include linux/mfd/da9052/pm.h
+
+static struct regulator_ops da9052_ldo_buck_ops;
+
+
+struct regulator {
+   struct device *dev;
+   struct list_head list;
+   int uA_load;
+   int min_uV;
+   int max_uV;
+   int enabled; /* client has called enabled */
+   char *supply_name;
+   struct device_attribute dev_attr;
+   struct regulator_dev *rdev;
+};
+
+
+
+
+#define DA9052_LDO(_id, max, min, step_v, reg, mbits, cbits) \
+{\
+   .reg_desc   = {\
+   .name   = #_id,\
+   .ops= da9052_ldo_buck_ops,\
+   .type   = REGULATOR_VOLTAGE,\
+   .id = _id,\
+   .owner  = THIS_MODULE,\
+   },\
+   .reg_const = {\
+   .max_uV = (max) * 1000,\
+   .min_uV = (min) * 1000,\
+   .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE\
+   | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE,\
+   .valid_modes_mask = REGULATOR_MODE_NORMAL,\
+   },\
+   .step_uV= (step_v) * 1000,\
+   .reg_add= (reg),\
+   .mask_bits  = (mbits),\
+   .en_bit_mask= (cbits),\
+}
+
+struct regulator_info {
+   struct regulator_desc reg_desc;
+   struct regulation_constraints reg_const;
+   int step_uV;
+   unsigned char reg_add;
+   unsigned char mask_bits;
+   unsigned char en_bit_mask;
+};
+
+struct da9052_regulator_priv {
+   struct da9052 *da9052;
+   struct regulator_dev *regulators[];
+};
+
+struct regulator_info da9052_regulators[] = {
+   /* LD01 - LDO10*/
+   DA9052_LDO(DA9052_LDO1, DA9052_LDO1_VOLT_UPPER, DA9052_LDO1_VOLT_LOWER,
+   DA9052_LDO1_VOLT_STEP, DA9052_LDO1_REG,
+   DA9052_LDO1_VLDO1, DA9052_LDO1_LDO1EN),
+
+   DA9052_LDO