Re: [PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-19 Thread Mike Turquette
Quoting Lee Jones (2015-02-19 04:13:04)
> On Thu, 19 Feb 2015, Sascha Hauer wrote:
> 
> > On Thu, Feb 19, 2015 at 08:43:49AM +, Lee Jones wrote:
> > > On Thu, 19 Feb 2015, Sascha Hauer wrote:
> > > 
> > > > > > Looks okay to me now.
> > > > > > 
> > > > > > Acked-by: Lee Jones 
> > > > > > 
> > > > > > What's the merge plan for this set?
> > > > > 
> > > > > Patches 1-9 are clock related an several of them have review comments
> > > > > that need to be addressed. I wonder if a V2 series can break out the
> > > > > various subsystems bits from each other?
> > > > 
> > > > I'll send a new series later this day. These used to be two series, but
> > > > the PMIC wrapper patches depend on the clock and reset controllers, also
> > > > the device nodes depend on the clock/reset defines from the clock
> > > > support patches. What do you suggest? In the early days of a SoC
> > > > everything seems to depend on everything.
> > > 
> > > Only build dependencies count.  So long as the Kconfigs are setup
> > > correct, there shouldn't be any issue in taking patches in one
> > > subsystem at a time.
> > 
> > The dts snippets need the files in include/dt-bindings, so indeed this
> > is a build dependency. However, this comes only in with the dts changes.
> > 
> > So here's the plan:
> > 
> > - Mike takes the clk patches
> > - Matthias takes the pmic wrapper driver (in drivers/soc/mediatek/)
> > - You take the MT6397 core driver.
> 
> Sounds reasonable.  Just ensure that each set is orthogonal and builds
> (or doesn't attempt to) and we'll be in a good place.

Agreed.

Regards,
Mike

> 
> > I'll queue up the dts changes locally and ask Arnd to take these after
> > next -rc1 so that all dependencies are in. Unfortunately this means that
> > the patches can't be tested until everything is together after next
> > -rc1.
> 
> I'm sure you will be diligent enough to test the interoperability of
> the sets combined.  Failing that we can deal with any unavoidable
> fall-out during the -rcs.
> 
> -- 
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-19 Thread Mike Turquette
Quoting Lee Jones (2015-02-19 04:13:04)
 On Thu, 19 Feb 2015, Sascha Hauer wrote:
 
  On Thu, Feb 19, 2015 at 08:43:49AM +, Lee Jones wrote:
   On Thu, 19 Feb 2015, Sascha Hauer wrote:
   
  Looks okay to me now.
  
  Acked-by: Lee Jones lee.jo...@linaro.org
  
  What's the merge plan for this set?
 
 Patches 1-9 are clock related an several of them have review comments
 that need to be addressed. I wonder if a V2 series can break out the
 various subsystems bits from each other?

I'll send a new series later this day. These used to be two series, but
the PMIC wrapper patches depend on the clock and reset controllers, also
the device nodes depend on the clock/reset defines from the clock
support patches. What do you suggest? In the early days of a SoC
everything seems to depend on everything.
   
   Only build dependencies count.  So long as the Kconfigs are setup
   correct, there shouldn't be any issue in taking patches in one
   subsystem at a time.
  
  The dts snippets need the files in include/dt-bindings, so indeed this
  is a build dependency. However, this comes only in with the dts changes.
  
  So here's the plan:
  
  - Mike takes the clk patches
  - Matthias takes the pmic wrapper driver (in drivers/soc/mediatek/)
  - You take the MT6397 core driver.
 
 Sounds reasonable.  Just ensure that each set is orthogonal and builds
 (or doesn't attempt to) and we'll be in a good place.

Agreed.

Regards,
Mike

 
  I'll queue up the dts changes locally and ask Arnd to take these after
  next -rc1 so that all dependencies are in. Unfortunately this means that
  the patches can't be tested until everything is together after next
  -rc1.
 
 I'm sure you will be diligent enough to test the interoperability of
 the sets combined.  Failing that we can deal with any unavoidable
 fall-out during the -rcs.
 
 -- 
 Lee Jones
 Linaro STMicroelectronics Landing Team Lead
 Linaro.org │ Open source software for ARM SoCs
 Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-16 Thread Lee Jones
> From: Flora Fu 
> 
> This adds support for the MediaTek MT6397 PMIC. This is a
> multifunction device with the following sub modules:
> 
> - Regulator
> - RTC
> - Audio codec
> - GPIO
> - Clock
> 
> It is interfaced to the host controller using SPI interface by a proprietary
> hardware called PMIC wrapper or pwrap. MT6397 MFD is a child device of the
> pwrap.
> 
> Signed-off-by: Flora Fu, MediaTek
> Signed-off-by: Sascha Hauer 
> Cc: Samuel Ortiz 
> Cc: Lee Jones 
> ---
>  drivers/mfd/Kconfig  |  10 +
>  drivers/mfd/Makefile |   1 +
>  drivers/mfd/mt6397-core.c| 223 +
>  include/linux/mfd/mt6397/core.h  |  64 +++
>  include/linux/mfd/mt6397/registers.h | 362 
> +++
>  5 files changed, 660 insertions(+)
>  create mode 100644 drivers/mfd/mt6397-core.c
>  create mode 100644 include/linux/mfd/mt6397/core.h
>  create mode 100644 include/linux/mfd/mt6397/registers.h

Looks okay to me now.

Acked-by: Lee Jones 

What's the merge plan for this set?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-16 Thread Lee Jones
 From: Flora Fu flora...@mediatek.com
 
 This adds support for the MediaTek MT6397 PMIC. This is a
 multifunction device with the following sub modules:
 
 - Regulator
 - RTC
 - Audio codec
 - GPIO
 - Clock
 
 It is interfaced to the host controller using SPI interface by a proprietary
 hardware called PMIC wrapper or pwrap. MT6397 MFD is a child device of the
 pwrap.
 
 Signed-off-by: Flora Fu, MediaTek
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.jo...@linaro.org
 ---
  drivers/mfd/Kconfig  |  10 +
  drivers/mfd/Makefile |   1 +
  drivers/mfd/mt6397-core.c| 223 +
  include/linux/mfd/mt6397/core.h  |  64 +++
  include/linux/mfd/mt6397/registers.h | 362 
 +++
  5 files changed, 660 insertions(+)
  create mode 100644 drivers/mfd/mt6397-core.c
  create mode 100644 include/linux/mfd/mt6397/core.h
  create mode 100644 include/linux/mfd/mt6397/registers.h

Looks okay to me now.

Acked-by: Lee Jones lee.jo...@linaro.org

What's the merge plan for this set?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-09 Thread Sascha Hauer
From: Flora Fu 

This adds support for the MediaTek MT6397 PMIC. This is a
multifunction device with the following sub modules:

- Regulator
- RTC
- Audio codec
- GPIO
- Clock

It is interfaced to the host controller using SPI interface by a proprietary
hardware called PMIC wrapper or pwrap. MT6397 MFD is a child device of the
pwrap.

Signed-off-by: Flora Fu, MediaTek
Signed-off-by: Sascha Hauer 
Cc: Samuel Ortiz 
Cc: Lee Jones 
---
 drivers/mfd/Kconfig  |  10 +
 drivers/mfd/Makefile |   1 +
 drivers/mfd/mt6397-core.c| 223 +
 include/linux/mfd/mt6397/core.h  |  64 +++
 include/linux/mfd/mt6397/registers.h | 362 +++
 5 files changed, 660 insertions(+)
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..7782e95 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -489,6 +489,16 @@ config MFD_MAX8998
  additional drivers must be enabled in order to use the functionality
  of the device.
 
+config MFD_MT6397
+   tristate "MediaTek MT6397 PMIC Support"
+   select MFD_CORE
+   select IRQ_DOMAIN
+   help
+ Say yes here to add support for MediaTek MT6397 PMIC. This is
+ a Power Management IC. This driver provides common support for
+ accessing the device; additional drivers must be enabled in order
+ to use the functionality of the device.
+
 config MFD_MENF21BMC
tristate "MEN 14F021P00 Board Management Controller Support"
depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..329d4ed 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -179,3 +179,4 @@ obj-$(CONFIG_MFD_DLN2)  += dln2.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
+obj-$(CONFIG_MFD_MT6397)   += mt6397-core.o
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
new file mode 100644
index 000..b61c4eb
--- /dev/null
+++ b/drivers/mfd/mt6397-core.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu, MediaTek
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const struct mfd_cell mt6397_devs[] = {
+   {
+   .name = "mt6397-rtc",
+   .of_compatible = "mediatek,mt6397-rtc",
+   }, {
+   .name = "mt6397-regulator",
+   .of_compatible = "mediatek,mt6397-regulator",
+   }, {
+   .name = "mt6397-codec",
+   .of_compatible = "mediatek,mt6397-codec",
+   }, {
+   .name = "mt6397-clk",
+   .of_compatible = "mediatek,mt6397-clk",
+   },
+};
+
+static void mt6397_irq_lock(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
+
+   mutex_lock(>irqlock);
+}
+
+static void mt6397_irq_sync_unlock(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
+
+   regmap_write(mt6397->regmap, MT6397_INT_CON0, mt6397->irq_masks_cur[0]);
+   regmap_write(mt6397->regmap, MT6397_INT_CON1, mt6397->irq_masks_cur[1]);
+
+   mutex_unlock(>irqlock);
+}
+
+static void mt6397_irq_disable(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
+   int shift = data->hwirq & 0xf;
+   int reg = data->hwirq >> 4;
+
+   mt6397->irq_masks_cur[reg] &= ~BIT(shift);
+}
+
+static void mt6397_irq_enable(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data->irq);
+   int shift = data->hwirq & 0xf;
+   int reg = data->hwirq >> 4;
+
+   mt6397->irq_masks_cur[reg] |= BIT(shift);
+}
+
+static struct irq_chip mt6397_irq_chip = {
+   .name = "mt6397-irq",
+   .irq_bus_lock = mt6397_irq_lock,
+   .irq_bus_sync_unlock = mt6397_irq_sync_unlock,
+   .irq_enable = mt6397_irq_enable,
+   .irq_disable = mt6397_irq_disable,
+};
+
+static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg,
+   int irqbase)
+{
+   unsigned int status;
+   int i, irq, ret;
+
+   ret = regmap_read(mt6397->regmap, reg, );
+   if (ret) {
+   dev_err(mt6397->dev, "Failed to read irq status: %d\n", ret);
+   

[PATCH 13/13] mfd: Add support for the MediaTek MT6397 PMIC

2015-02-09 Thread Sascha Hauer
From: Flora Fu flora...@mediatek.com

This adds support for the MediaTek MT6397 PMIC. This is a
multifunction device with the following sub modules:

- Regulator
- RTC
- Audio codec
- GPIO
- Clock

It is interfaced to the host controller using SPI interface by a proprietary
hardware called PMIC wrapper or pwrap. MT6397 MFD is a child device of the
pwrap.

Signed-off-by: Flora Fu, MediaTek
Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
---
 drivers/mfd/Kconfig  |  10 +
 drivers/mfd/Makefile |   1 +
 drivers/mfd/mt6397-core.c| 223 +
 include/linux/mfd/mt6397/core.h  |  64 +++
 include/linux/mfd/mt6397/registers.h | 362 +++
 5 files changed, 660 insertions(+)
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..7782e95 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -489,6 +489,16 @@ config MFD_MAX8998
  additional drivers must be enabled in order to use the functionality
  of the device.
 
+config MFD_MT6397
+   tristate MediaTek MT6397 PMIC Support
+   select MFD_CORE
+   select IRQ_DOMAIN
+   help
+ Say yes here to add support for MediaTek MT6397 PMIC. This is
+ a Power Management IC. This driver provides common support for
+ accessing the device; additional drivers must be enabled in order
+ to use the functionality of the device.
+
 config MFD_MENF21BMC
tristate MEN 14F021P00 Board Management Controller Support
depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..329d4ed 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -179,3 +179,4 @@ obj-$(CONFIG_MFD_DLN2)  += dln2.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
+obj-$(CONFIG_MFD_MT6397)   += mt6397-core.o
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
new file mode 100644
index 000..b61c4eb
--- /dev/null
+++ b/drivers/mfd/mt6397-core.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu, MediaTek
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include linux/interrupt.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/of_irq.h
+#include linux/regmap.h
+#include linux/mfd/core.h
+#include linux/mfd/mt6397/core.h
+#include linux/mfd/mt6397/registers.h
+
+static const struct mfd_cell mt6397_devs[] = {
+   {
+   .name = mt6397-rtc,
+   .of_compatible = mediatek,mt6397-rtc,
+   }, {
+   .name = mt6397-regulator,
+   .of_compatible = mediatek,mt6397-regulator,
+   }, {
+   .name = mt6397-codec,
+   .of_compatible = mediatek,mt6397-codec,
+   }, {
+   .name = mt6397-clk,
+   .of_compatible = mediatek,mt6397-clk,
+   },
+};
+
+static void mt6397_irq_lock(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data-irq);
+
+   mutex_lock(mt6397-irqlock);
+}
+
+static void mt6397_irq_sync_unlock(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data-irq);
+
+   regmap_write(mt6397-regmap, MT6397_INT_CON0, mt6397-irq_masks_cur[0]);
+   regmap_write(mt6397-regmap, MT6397_INT_CON1, mt6397-irq_masks_cur[1]);
+
+   mutex_unlock(mt6397-irqlock);
+}
+
+static void mt6397_irq_disable(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data-irq);
+   int shift = data-hwirq  0xf;
+   int reg = data-hwirq  4;
+
+   mt6397-irq_masks_cur[reg] = ~BIT(shift);
+}
+
+static void mt6397_irq_enable(struct irq_data *data)
+{
+   struct mt6397_chip *mt6397 = irq_get_chip_data(data-irq);
+   int shift = data-hwirq  0xf;
+   int reg = data-hwirq  4;
+
+   mt6397-irq_masks_cur[reg] |= BIT(shift);
+}
+
+static struct irq_chip mt6397_irq_chip = {
+   .name = mt6397-irq,
+   .irq_bus_lock = mt6397_irq_lock,
+   .irq_bus_sync_unlock = mt6397_irq_sync_unlock,
+   .irq_enable = mt6397_irq_enable,
+   .irq_disable = mt6397_irq_disable,
+};
+
+static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg,
+   int irqbase)
+{
+   unsigned int status;