[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 

Re: [PATCH v10] mfd: Add anatop mfd driver

2012-03-16 Thread Arnd Bergmann
On Friday 16 March 2012, Ying-Chun Liu (PaulLiu) wrote:
 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

Reviewed-by: Arnd Bergmann a...@arndb.de

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


Re: [PATCH v10] mfd: Add anatop mfd driver

2012-03-16 Thread Mark Brown
On Fri, Mar 16, 2012 at 04:16:56PM +0800, Ying-Chun Liu (PaulLiu) wrote:
 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.

Reviwed-by: Mark Brown broo...@opensource.wolfsonmicro.com


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


Re: [PATCH v10] mfd: Add anatop mfd driver

2012-03-16 Thread Samuel Ortiz
Hi,

On Fri, Mar 16, 2012 at 04:16:56PM +0800, Ying-Chun Liu (PaulLiu) wrote:
 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.
I applied this one, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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