Re: [PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-04-02 Thread Paul Kocialkowski
Le mercredi 30 mars 2016 à 18:56 +0300, Grygorii Strashko a écrit :
> On 03/29/2016 10:22 PM, Paul Kocialkowski wrote:
> > 
> > This adds a TWL6030 power driver, that currently only supports powering off
> > the
> > device when the TWL is used as system power controller.
> > 
> > This driver might be extended to support more power-related features of the
> > TWL6030.
> > 
> > Signed-off-by: Paul Kocialkowski 
> > ---
> >   .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
> >   drivers/mfd/Kconfig|  10 ++
> >   drivers/mfd/Makefile   |   5 +-
> >   drivers/mfd/twl-core.c |   8 ++
> >   drivers/mfd/twl6030-power.c| 102
> > +
> Seems proper place for this driver is drivers/power/reset.

twl4030-power is in drivers/mfd/ and contains similar functions. Should those be
split into a separate driver in driver/power/reset?

If not, I'd rather keep this basic driver in drivers/mfd/ since it might be
extended later to support more power-related things.

> >   5 files changed, 154 insertions(+), 2 deletions(-)
> >   create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
> >   create mode 100644 drivers/mfd/twl6030-power.c
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > new file mode 100644
> > index 000..97600e7
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > @@ -0,0 +1,31 @@
> > +Texas Instruments TWL family (twl6030) reset and power management module
> > +
> > +For now, the binding only supports the complete shutdown of the system
> > after
> > +poweroff.
> > +
> > +Required properties:
> > +- compatible : must be
> > +   "ti,twl6030-power"
> > +
> > +Optional properties:
> > +
> > +- ti,system-power-controller: This indicates that TWL6030 is the
> > +  power supply master of the system. With this flag, the chip will
> > +  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
> > +  system poweroffs.
> > +
> > +Example:
> > + {
> > +   clock-frequency = <260>;
> > +
> > +   twl: twl@48 {
> > +   reg = <0x48>;
> > +   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
> > +   interrupt-parent = <>;
> > +
> > +   twl_power: power {
> > +   compatible = "ti,twl6030-power";
> > +   ti,system-power-controller;
> > +   };
> > +   };
> > +};
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index 28bfe3d..a0a8012 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
> >     select MFD_CORE
> >     default n
> > 
> > +config TWL6030_POWER
> > +   bool "TI TWL6030 power resources"
> > +   depends on TWL_CORE && ARM
> > +   help
> > +     Say yes here if you want to use the power resources on the
> > +     TWL6030 family chips.
> > +
> > +     When used as system power controller, this driver allows turning
> > off
> > +     the main power supply.
> > +
> >   config TWL6040_CORE
> >     bool "TI TWL6040 audio codec"
> >     depends on I2C=y
> > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> > index 7daeab5..5aa16c8 100644
> > --- a/drivers/mfd/Makefile
> > +++ b/drivers/mfd/Makefile
> > @@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
> >   obj-$(CONFIG_MFD_TPS80031)+= tps80031.o
> >   obj-$(CONFIG_MENELAUS)+= menelaus.o
> > 
> > -obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
> > -obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
> > +obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-
> > irq.o
> > +obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
> >   obj-$(CONFIG_MFD_TWL4030_AUDIO)   += twl4030-audio.o
> > +obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
> >   obj-$(CONFIG_TWL6040_CORE)+= twl6040.o
> > 
> >   obj-$(CONFIG_MFD_MX25_TSADC)  += fsl-imx25-tsadc.o
> > diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> > index dae52f7..74372bc 100644
> > --- a/drivers/mfd/twl-core.c
> > +++ b/drivers/mfd/twl-core.c
> > @@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned
> > irq_base,
> >     return PTR_ERR(child);
> >     }
> > 
> > +   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
> > +   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
> > +     pdata->power, sizeof(*pdata->power),
> > false,
> > +     0, 0);
> > +   if (IS_ERR(child))
> > +   return PTR_ERR(child);
> > +   }
> > +
> non-DT boot option is not supported for twl6030 any more and
> all related code was removed already.
> 
> > 
> >     return 0;
> >   }
> > 
> > diff --git a/drivers/mfd/twl6030-power.c 

Re: [PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-04-02 Thread Paul Kocialkowski
Le mercredi 30 mars 2016 à 18:56 +0300, Grygorii Strashko a écrit :
> On 03/29/2016 10:22 PM, Paul Kocialkowski wrote:
> > 
> > This adds a TWL6030 power driver, that currently only supports powering off
> > the
> > device when the TWL is used as system power controller.
> > 
> > This driver might be extended to support more power-related features of the
> > TWL6030.
> > 
> > Signed-off-by: Paul Kocialkowski 
> > ---
> >   .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
> >   drivers/mfd/Kconfig|  10 ++
> >   drivers/mfd/Makefile   |   5 +-
> >   drivers/mfd/twl-core.c |   8 ++
> >   drivers/mfd/twl6030-power.c| 102
> > +
> Seems proper place for this driver is drivers/power/reset.

twl4030-power is in drivers/mfd/ and contains similar functions. Should those be
split into a separate driver in driver/power/reset?

If not, I'd rather keep this basic driver in drivers/mfd/ since it might be
extended later to support more power-related things.

> >   5 files changed, 154 insertions(+), 2 deletions(-)
> >   create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
> >   create mode 100644 drivers/mfd/twl6030-power.c
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > new file mode 100644
> > index 000..97600e7
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
> > @@ -0,0 +1,31 @@
> > +Texas Instruments TWL family (twl6030) reset and power management module
> > +
> > +For now, the binding only supports the complete shutdown of the system
> > after
> > +poweroff.
> > +
> > +Required properties:
> > +- compatible : must be
> > +   "ti,twl6030-power"
> > +
> > +Optional properties:
> > +
> > +- ti,system-power-controller: This indicates that TWL6030 is the
> > +  power supply master of the system. With this flag, the chip will
> > +  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
> > +  system poweroffs.
> > +
> > +Example:
> > + {
> > +   clock-frequency = <260>;
> > +
> > +   twl: twl@48 {
> > +   reg = <0x48>;
> > +   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
> > +   interrupt-parent = <>;
> > +
> > +   twl_power: power {
> > +   compatible = "ti,twl6030-power";
> > +   ti,system-power-controller;
> > +   };
> > +   };
> > +};
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index 28bfe3d..a0a8012 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
> >     select MFD_CORE
> >     default n
> > 
> > +config TWL6030_POWER
> > +   bool "TI TWL6030 power resources"
> > +   depends on TWL_CORE && ARM
> > +   help
> > +     Say yes here if you want to use the power resources on the
> > +     TWL6030 family chips.
> > +
> > +     When used as system power controller, this driver allows turning
> > off
> > +     the main power supply.
> > +
> >   config TWL6040_CORE
> >     bool "TI TWL6040 audio codec"
> >     depends on I2C=y
> > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> > index 7daeab5..5aa16c8 100644
> > --- a/drivers/mfd/Makefile
> > +++ b/drivers/mfd/Makefile
> > @@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
> >   obj-$(CONFIG_MFD_TPS80031)+= tps80031.o
> >   obj-$(CONFIG_MENELAUS)+= menelaus.o
> > 
> > -obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
> > -obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
> > +obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-
> > irq.o
> > +obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
> >   obj-$(CONFIG_MFD_TWL4030_AUDIO)   += twl4030-audio.o
> > +obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
> >   obj-$(CONFIG_TWL6040_CORE)+= twl6040.o
> > 
> >   obj-$(CONFIG_MFD_MX25_TSADC)  += fsl-imx25-tsadc.o
> > diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> > index dae52f7..74372bc 100644
> > --- a/drivers/mfd/twl-core.c
> > +++ b/drivers/mfd/twl-core.c
> > @@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned
> > irq_base,
> >     return PTR_ERR(child);
> >     }
> > 
> > +   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
> > +   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
> > +     pdata->power, sizeof(*pdata->power),
> > false,
> > +     0, 0);
> > +   if (IS_ERR(child))
> > +   return PTR_ERR(child);
> > +   }
> > +
> non-DT boot option is not supported for twl6030 any more and
> all related code was removed already.
> 
> > 
> >     return 0;
> >   }
> > 
> > diff --git a/drivers/mfd/twl6030-power.c b/drivers/mfd/twl6030-power.c
> > 

Re: [PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-03-30 Thread Grygorii Strashko

On 03/29/2016 10:22 PM, Paul Kocialkowski wrote:

This adds a TWL6030 power driver, that currently only supports powering off the
device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski 
---
  .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
  drivers/mfd/Kconfig|  10 ++
  drivers/mfd/Makefile   |   5 +-
  drivers/mfd/twl-core.c |   8 ++
  drivers/mfd/twl6030-power.c| 102 +


Seems proper place for this driver is drivers/power/reset.



  5 files changed, 154 insertions(+), 2 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
  create mode 100644 drivers/mfd/twl6030-power.c

diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
new file mode 100644
index 000..97600e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+   "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+ {
+   clock-frequency = <260>;
+
+   twl: twl@48 {
+   reg = <0x48>;
+   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+   interrupt-parent = <>;
+
+   twl_power: power {
+   compatible = "ti,twl6030-power";
+   ti,system-power-controller;
+   };
+   };
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 28bfe3d..a0a8012 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
select MFD_CORE
default n

+config TWL6030_POWER
+   bool "TI TWL6030 power resources"
+   depends on TWL_CORE && ARM
+   help
+ Say yes here if you want to use the power resources on the
+ TWL6030 family chips.
+
+ When used as system power controller, this driver allows turning off
+ the main power supply.
+
  config TWL6040_CORE
bool "TI TWL6040 audio codec"
depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 7daeab5..5aa16c8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
  obj-$(CONFIG_MFD_TPS80031)+= tps80031.o
  obj-$(CONFIG_MENELAUS)+= menelaus.o

-obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
-obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
+obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
+obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
  obj-$(CONFIG_MFD_TWL4030_AUDIO)   += twl4030-audio.o
+obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
  obj-$(CONFIG_TWL6040_CORE)+= twl6040.o

  obj-$(CONFIG_MFD_MX25_TSADC)  += fsl-imx25-tsadc.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index dae52f7..74372bc 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}

+   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
+   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
+ pdata->power, sizeof(*pdata->power), false,
+ 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+


non-DT boot option is not supported for twl6030 any more and
all related code was removed already.


return 0;
  }

diff --git a/drivers/mfd/twl6030-power.c b/drivers/mfd/twl6030-power.c
new file mode 100644
index 000..a0bb6d8
--- /dev/null
+++ b/drivers/mfd/twl6030-power.c
@@ -0,0 +1,102 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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

Re: [PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-03-30 Thread Grygorii Strashko

On 03/29/2016 10:22 PM, Paul Kocialkowski wrote:

This adds a TWL6030 power driver, that currently only supports powering off the
device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski 
---
  .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
  drivers/mfd/Kconfig|  10 ++
  drivers/mfd/Makefile   |   5 +-
  drivers/mfd/twl-core.c |   8 ++
  drivers/mfd/twl6030-power.c| 102 +


Seems proper place for this driver is drivers/power/reset.



  5 files changed, 154 insertions(+), 2 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
  create mode 100644 drivers/mfd/twl6030-power.c

diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
new file mode 100644
index 000..97600e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+   "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+ {
+   clock-frequency = <260>;
+
+   twl: twl@48 {
+   reg = <0x48>;
+   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+   interrupt-parent = <>;
+
+   twl_power: power {
+   compatible = "ti,twl6030-power";
+   ti,system-power-controller;
+   };
+   };
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 28bfe3d..a0a8012 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
select MFD_CORE
default n

+config TWL6030_POWER
+   bool "TI TWL6030 power resources"
+   depends on TWL_CORE && ARM
+   help
+ Say yes here if you want to use the power resources on the
+ TWL6030 family chips.
+
+ When used as system power controller, this driver allows turning off
+ the main power supply.
+
  config TWL6040_CORE
bool "TI TWL6040 audio codec"
depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 7daeab5..5aa16c8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
  obj-$(CONFIG_MFD_TPS80031)+= tps80031.o
  obj-$(CONFIG_MENELAUS)+= menelaus.o

-obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
-obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
+obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
+obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
  obj-$(CONFIG_MFD_TWL4030_AUDIO)   += twl4030-audio.o
+obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
  obj-$(CONFIG_TWL6040_CORE)+= twl6040.o

  obj-$(CONFIG_MFD_MX25_TSADC)  += fsl-imx25-tsadc.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index dae52f7..74372bc 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}

+   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
+   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
+ pdata->power, sizeof(*pdata->power), false,
+ 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+


non-DT boot option is not supported for twl6030 any more and
all related code was removed already.


return 0;
  }

diff --git a/drivers/mfd/twl6030-power.c b/drivers/mfd/twl6030-power.c
new file mode 100644
index 000..a0bb6d8
--- /dev/null
+++ b/drivers/mfd/twl6030-power.c
@@ -0,0 +1,102 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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 

[PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-03-29 Thread Paul Kocialkowski
This adds a TWL6030 power driver, that currently only supports powering off the
device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski 
---
 .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
 drivers/mfd/Kconfig|  10 ++
 drivers/mfd/Makefile   |   5 +-
 drivers/mfd/twl-core.c |   8 ++
 drivers/mfd/twl6030-power.c| 102 +
 5 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
 create mode 100644 drivers/mfd/twl6030-power.c

diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
new file mode 100644
index 000..97600e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+   "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+ {
+   clock-frequency = <260>;
+
+   twl: twl@48 {
+   reg = <0x48>;
+   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+   interrupt-parent = <>;
+
+   twl_power: power {
+   compatible = "ti,twl6030-power";
+   ti,system-power-controller;
+   };
+   };
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 28bfe3d..a0a8012 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
select MFD_CORE
default n
 
+config TWL6030_POWER
+   bool "TI TWL6030 power resources"
+   depends on TWL_CORE && ARM
+   help
+ Say yes here if you want to use the power resources on the
+ TWL6030 family chips.
+
+ When used as system power controller, this driver allows turning off
+ the main power supply.
+
 config TWL6040_CORE
bool "TI TWL6040 audio codec"
depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 7daeab5..5aa16c8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
 obj-$(CONFIG_MFD_TPS80031) += tps80031.o
 obj-$(CONFIG_MENELAUS) += menelaus.o
 
-obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
-obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
+obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
+obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o
+obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
 obj-$(CONFIG_TWL6040_CORE) += twl6040.o
 
 obj-$(CONFIG_MFD_MX25_TSADC)   += fsl-imx25-tsadc.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index dae52f7..74372bc 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
+   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
+   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
+ pdata->power, sizeof(*pdata->power), false,
+ 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+
return 0;
 }
 
diff --git a/drivers/mfd/twl6030-power.c b/drivers/mfd/twl6030-power.c
new file mode 100644
index 000..a0bb6d8
--- /dev/null
+++ b/drivers/mfd/twl6030-power.c
@@ -0,0 +1,102 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define 

[PATCH 4/8] mfd: Add TWL6030 power driver, with minimal support for power off

2016-03-29 Thread Paul Kocialkowski
This adds a TWL6030 power driver, that currently only supports powering off the
device when the TWL is used as system power controller.

This driver might be extended to support more power-related features of the
TWL6030.

Signed-off-by: Paul Kocialkowski 
---
 .../devicetree/bindings/mfd/twl6030-power.txt  |  31 +++
 drivers/mfd/Kconfig|  10 ++
 drivers/mfd/Makefile   |   5 +-
 drivers/mfd/twl-core.c |   8 ++
 drivers/mfd/twl6030-power.c| 102 +
 5 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/twl6030-power.txt
 create mode 100644 drivers/mfd/twl6030-power.c

diff --git a/Documentation/devicetree/bindings/mfd/twl6030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
new file mode 100644
index 000..97600e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/twl6030-power.txt
@@ -0,0 +1,31 @@
+Texas Instruments TWL family (twl6030) reset and power management module
+
+For now, the binding only supports the complete shutdown of the system after
+poweroff.
+
+Required properties:
+- compatible : must be
+   "ti,twl6030-power"
+
+Optional properties:
+
+- ti,system-power-controller: This indicates that TWL6030 is the
+  power supply master of the system. With this flag, the chip will
+  initiate an ACTIVE-to-OFF or SLEEP-to-OFF transition when the
+  system poweroffs.
+
+Example:
+ {
+   clock-frequency = <260>;
+
+   twl: twl@48 {
+   reg = <0x48>;
+   interrupts = <7>; /* SYS_NIRQ cascaded to intc */
+   interrupt-parent = <>;
+
+   twl_power: power {
+   compatible = "ti,twl6030-power";
+   ti,system-power-controller;
+   };
+   };
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 28bfe3d..a0a8012 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1301,6 +1301,16 @@ config MFD_TWL4030_AUDIO
select MFD_CORE
default n
 
+config TWL6030_POWER
+   bool "TI TWL6030 power resources"
+   depends on TWL_CORE && ARM
+   help
+ Say yes here if you want to use the power resources on the
+ TWL6030 family chips.
+
+ When used as system power controller, this driver allows turning off
+ the main power supply.
+
 config TWL6040_CORE
bool "TI TWL6040 audio codec"
depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 7daeab5..5aa16c8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -81,9 +81,10 @@ obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
 obj-$(CONFIG_MFD_TPS80031) += tps80031.o
 obj-$(CONFIG_MENELAUS) += menelaus.o
 
-obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
-obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
+obj-$(CONFIG_TWL_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
+obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o
+obj-$(CONFIG_TWL6030_POWER)+= twl6030-power.o
 obj-$(CONFIG_TWL6040_CORE) += twl6040.o
 
 obj-$(CONFIG_MFD_MX25_TSADC)   += fsl-imx25-tsadc.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index dae52f7..74372bc 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -972,6 +972,14 @@ add_children(struct twl_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
+   if (IS_ENABLED(CONFIG_TWL6030_POWER) && pdata->power) {
+   child = add_child(TWL_MODULE_PM_MASTER, "twl6030_power",
+ pdata->power, sizeof(*pdata->power), false,
+ 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+
return 0;
 }
 
diff --git a/drivers/mfd/twl6030-power.c b/drivers/mfd/twl6030-power.c
new file mode 100644
index 000..a0bb6d8
--- /dev/null
+++ b/drivers/mfd/twl6030-power.c
@@ -0,0 +1,102 @@
+/*
+ * TWL6030 power
+ *
+ * Copyright (C) 2016 Paul Kocialkowski 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define TWL6030_PHOENIX_DEV_ON 0x25
+