Re: [PATCH v3 4/4] gpio-tz1090-pdc: add TZ1090 PDC gpio driver

2013-06-24 Thread Linus Walleij
On Thu, Jun 20, 2013 at 11:26 AM, James Hogan james.ho...@imgtec.com wrote:

 Add a GPIO driver for the low-power Powerdown Controller GPIOs in the
 TZ1090 SoC.

 The driver is instantiated by device tree and supports interrupts for
 the SysWake GPIOs only.

 Signed-off-by: James Hogan james.ho...@imgtec.com
 Cc: Grant Likely grant.lik...@linaro.org
 Cc: Rob Herring rob.herr...@calxeda.com
 Cc: Rob Landley r...@landley.net
 Cc: Linus Walleij linus.wall...@linaro.org
 Cc: linux-...@vger.kernel.org
 Cc: devicetree-discuss@lists.ozlabs.org
 ---
 Changes in v3:
  - separated from irq-imgpdc and removed arch/metag changes to allow
these patches to go upstream separately via the pinctrl[/gpio] trees
(particularly the pinctrl drivers depend on the new pinconf DT
bindings).
  - some s/unsigned/unsigned int/.
  - gpio-tz1090*: refer to dt-bindings/gpio/gpio.h and
dt-bindings/interrupt-controller/irq.h flags in bindings.
  - gpio-tz1090*: move initcall from postcore to subsys.

I'll be happy to apply the GPIO patches to the pinctrl tree as well
once you fixed the comments on patch 2 from Grant.

Yours,
Linus Walleij
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3 4/4] gpio-tz1090-pdc: add TZ1090 PDC gpio driver

2013-06-20 Thread James Hogan
Add a GPIO driver for the low-power Powerdown Controller GPIOs in the
TZ1090 SoC.

The driver is instantiated by device tree and supports interrupts for
the SysWake GPIOs only.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Grant Likely grant.lik...@linaro.org
Cc: Rob Herring rob.herr...@calxeda.com
Cc: Rob Landley r...@landley.net
Cc: Linus Walleij linus.wall...@linaro.org
Cc: linux-...@vger.kernel.org
Cc: devicetree-discuss@lists.ozlabs.org
---
Changes in v3:
 - separated from irq-imgpdc and removed arch/metag changes to allow
   these patches to go upstream separately via the pinctrl[/gpio] trees
   (particularly the pinctrl drivers depend on the new pinconf DT
   bindings).
 - some s/unsigned/unsigned int/.
 - gpio-tz1090*: refer to dt-bindings/gpio/gpio.h and
   dt-bindings/interrupt-controller/irq.h flags in bindings.
 - gpio-tz1090*: move initcall from postcore to subsys.

Changes in v2:
 - gpio-tz1090-pdc: remove references to Linux flags in dt bindings
 - gpio-tz1090-pdc: make use of BIT() from linux/bitops.h
 - gpio-tz1090-pdc: make register accessors inline to match pinctrl
 - gpio-tz1090-pdc: update gpio-ranges to use 3 cells after recent ABI
   breakage

 .../devicetree/bindings/gpio/gpio-tz1090-pdc.txt   |  43 
 drivers/gpio/Kconfig   |   7 +
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-tz1090-pdc.c | 243 +
 4 files changed, 294 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-tz1090-pdc.txt
 create mode 100644 drivers/gpio/gpio-tz1090-pdc.c

diff --git a/Documentation/devicetree/bindings/gpio/gpio-tz1090-pdc.txt 
b/Documentation/devicetree/bindings/gpio/gpio-tz1090-pdc.txt
new file mode 100644
index 000..704a277
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-tz1090-pdc.txt
@@ -0,0 +1,43 @@
+ImgTec TZ1090 PDC GPIO Controller
+
+Required properties:
+- compatible: Compatible property value should be img,tz1090-pdc-gpio.
+
+- reg: Physical base address of the controller and length of memory mapped
+  region. This starts at and cover the SOC_GPIO_CONTROL registers.
+
+- gpio-controller: Specifies that the node is a gpio controller.
+
+- #gpio-cells: Should be 2. The syntax of the gpio specifier used by client
+  nodes should have the following values.
+ [phandle of the gpio controller node]
+  [PDC gpio number]
+  [gpio flags]
+
+  Values for gpio specifier:
+  - GPIO number: a value in the range 0 to 6.
+  - GPIO flags: bit field of flags, as defined in dt-bindings/gpio/gpio.h.
+Only the following flags are supported:
+  GPIO_ACTIVE_HIGH
+  GPIO_ACTIVE_LOW
+
+Optional properties:
+- gpio-ranges: Mapping to pin controller pins
+
+- interrupts: Individual syswake interrupts (other GPIOs cannot interrupt)
+
+
+Example:
+
+   pdc_gpios: gpio-controller@02006500 {
+   gpio-controller;
+   #gpio-cells = 2;
+
+   compatible = img,tz1090-pdc-gpio;
+   reg = 0x02006500 0x100;
+
+   interrupt-parent = pdc;
+   interrupts =8  IRQ_TYPE_NONE, /* Syswake 0 */
+   9  IRQ_TYPE_NONE, /* Syswake 1 */
+   10 IRQ_TYPE_NONE; /* Syswake 2 */
+   };
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ee27c2e..08dbfbe 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -239,6 +239,13 @@ config GPIO_TZ1090
help
  Say yes here to support Toumaz Xenif TZ1090 GPIOs.
 
+config GPIO_TZ1090_PDC
+   bool Toumaz Xenif TZ1090 PDC GPIO support
+   depends on SOC_TZ1090
+   default y
+   help
+ Say yes here to support Toumaz Xenif TZ1090 PDC GPIOs.
+
 config GPIO_XILINX
bool Xilinx GPIO support
depends on PPC_OF || MICROBLAZE
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 37bdc1e..44341c7 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o
 obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o
 obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o
 obj-$(CONFIG_GPIO_TZ1090)  += gpio-tz1090.o
+obj-$(CONFIG_GPIO_TZ1090_PDC)  += gpio-tz1090-pdc.o
 obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o
 obj-$(CONFIG_GPIO_VIPERBOARD)  += gpio-viperboard.o
 obj-$(CONFIG_GPIO_VR41XX)  += gpio-vr41xx.o
diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c
new file mode 100644
index 000..f512da2
--- /dev/null
+++ b/drivers/gpio/gpio-tz1090-pdc.c
@@ -0,0 +1,243 @@
+/*
+ * Toumaz Xenif TZ1090 PDC GPIO handling.
+ *
+ * Copyright (C) 2012-2013 Imagination Technologies Ltd.
+ *
+ * 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.
+ */
+
+#include linux/bitops.h
+#include linux/gpio.h