Skip to contentSkip to conversation

drivers/gpio: Altera soft IP GPIO driver

PATCH In review [email protected] 2 participants 4 messages Feb 24, 2015 – Mar 7, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v10 cover drivers/gpio: Altera soft IP GPIO driver

From: Tien Hock Loh <[email protected]>

Adds a new device tree binding and driver for Altera soft GPIO IP. The driver is able to do read/write and allows GPIO to be a interrupt controller.

Tested on Altera GHRD on interrupt handling and IO.

v10:
Updated conflicting device tree parameters
Removed unused headers
Used macro instead of magic numbers for ngpio
Code readability cleanup using ?: and temporal variables
Removed leftover garbage and unnecessary function calls
Checked bgpio_init but unusable because Altera GPIO may not be a multiple of 8 bits

v9:
Removed duplicated initialization on set_type using temporals to improve code readability in calling generic_handle_irq Using ?: ternary to reduce code size

v8:
Using for_each_set_bit
added const for struct definition
removed naggy pr_err
sort alpha header
remove unused macros
use fixed width data types instead of unsigned long whitespace issue fixes removed _relaxed function for better compatibility across different CPU changed irq_create_mapping to platform_get_irq updated implementation to use gpiochip_irqchip_add reserve interrupt-cells number 2 in device tree binding for future use remove confusing sections on devicetree bindings Added tristate Kconfig help text

v7:
used dev_warn instead of pr_warn
clean up unnecesarry if else indentation

v6:
Added irq_startup and irq_shutdown
changed bitwise clamping style
cleanup bitwise operation to improve readability change naming of mapped irqs from virq to mapped_irq

v5:
dispose irq_domain mapping correctly
update optional binding description in binding docs

v4:
added vendor prefix to devicetree binding for IP specific properties using MMIO GPIO helper library instead of manually map PIO to memory altera_gpio_chip inline struct documentation to kerneldoc using dev_ print to print a better failure message

v2, v3:
Do not reference NO_IRQ
Updated irq_set_type to only allow the hardware configured irq type

Tien Hock Loh (2):
drivers/gpio: Altera soft IP GPIO driver device tree binding drivers/gpio: Altera soft IP GPIO driver

 .../devicetree/bindings/gpio/gpio-altera.txt       |  43 +++
 MAINTAINERS                                        |   6 +
 drivers/gpio/Kconfig                               |  10 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-altera.c                         | 374 +++++++++++++++++++++
 5 files changed, 434 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-altera.txt
 create mode 100644 drivers/gpio/gpio-altera.c
Signature · 1 line
1.7.11.GIT
#1 lore raw

PATCH v10 1/2 drivers/gpio: Altera soft IP GPIO driver device tree binding

From: Tien Hock Loh <[email protected]>

Adds a new driver device tree binding for Altera soft GPIO IP

---
 .../devicetree/bindings/gpio/gpio-altera.txt       | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-altera.txt
Documentation/devicetree/bindings/gpio/gpio-altera.txt new file +43 -0
new file mode 100644
index 0000000..12f5014
@@ -0,0 +1,43 @@
+Altera GPIO controller bindings
+
+Required properties:
+- compatible:
+  - "altr,pio-1.0"
+- reg: Physical base address and length of the controller's registers.
+- #gpio-cells : Should be 2
+  - The first cell is the gpio offset number.
+  - The second cell is reserved and is currently unused.
+- gpio-controller : Marks the device node as a GPIO controller.
+- interrupt-controller: Mark the device node as an interrupt controller
+- #interrupt-cells : Should be 1. The interrupt type is fixed in the hardware.
+  - The first cell is the GPIO offset number within the GPIO controller.
+- interrupts: Specify the interrupt.
+- altr,interrupt-trigger: Specifies the interrupt trigger type the GPIO
+  hardware is synthesized. This field is required if the Altera GPIO controller
+  used has IRQ enabled as the interrupt type is not software controlled,
+  but hardware synthesized. Required if GPIO is used as an interrupt
+  controller. The value is defined in <dt-bindings/interrupt-controller/irq.h>
+  Only the following flags are supported:
+    IRQ_TYPE_EDGE_RISING
+    IRQ_TYPE_EDGE_FALLING
+    IRQ_TYPE_EDGE_BOTH
+    IRQ_TYPE_LEVEL_HIGH
+
+Optional properties:
+- altr,ngpio: Width of the GPIO bank. This defines how many pins the
+  GPIO device has. Ranges between 1-32. Optional and defaults to 32 if not
+  specified.
+
+Example:
+
+gpio_altr: gpio@0xff200000 {
+	compatible = "altr,pio-1.0";
+	reg = <0xff200000 0x10>;
+	interrupts = <0 45 4>;
+	altr,ngpio = <32>;
+	altr,interrupt-trigger = <IRQ_TYPE_EDGE_RISING>;
+	#gpio-cells = <2>;
+	gpio-controller;
+	#interrupt-cells = <1>;
+	interrupt-controller;
+};
Signature · 1 line
1.7.11.GIT
#2 lore raw

PATCH v10 2/2 drivers/gpio: Altera soft IP GPIO driver

In reply to [email protected]

From: Tien Hock Loh <[email protected]>

Adds a new driver for Altera soft GPIO IP. The driver is able to do read/write and allows GPIO to be a interrupt controller.

Tested on Altera GHRD on interrupt handling and IO.

---
 MAINTAINERS                |   6 +
 drivers/gpio/Kconfig       |  10 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-altera.c | 374 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 391 insertions(+)
 create mode 100644 drivers/gpio/gpio-altera.c
MAINTAINERS +6 -0
index 5a6cdfb..70292df 100644
@@ -563,6 +563,12 @@ S:	Odd Fixes
 L:	[email protected]
 F:	arch/alpha/
 
+ALTERA PIO DRIVER
+M:	Tien Hock Loh <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/gpio/gpio-altera.c
+
 ALTERA TRIPLE SPEED ETHERNET DRIVER
 M:	Vince Bridgers <[email protected]>
 L:	[email protected]
drivers/gpio/Kconfig +10 -0
index ae5cb4d..b7c5838 100644
@@ -156,6 +156,16 @@ config GPIO_DWAPB
 	  Say Y or M here to build support for the Synopsys DesignWare APB
 	  GPIO block.
 
+config GPIO_ALTERA
+	tristate "Altera GPIO"
+	depends on OF_GPIO
+	select GPIO_GENERIC
+	select GPIOLIB_IRQCHIP
+	help
+	  Say Y or M here to build support for the Altera PIO device.
+
+	  If driver is built as a module it will be called gpio-altera.
+
 config GPIO_IT8761E
 	tristate "IT8761E GPIO support"
 	depends on X86  # unconditional access to IO space.
drivers/gpio/Makefile +1 -0
index bdda6a9..a452b14 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_GPIO_74XX_MMIO)	+= gpio-74xx-mmio.o
 obj-$(CONFIG_GPIO_ADNP)		+= gpio-adnp.o
 obj-$(CONFIG_GPIO_ADP5520)	+= gpio-adp5520.o
 obj-$(CONFIG_GPIO_ADP5588)	+= gpio-adp5588.o
+obj-$(CONFIG_GPIO_ALTERA)  	+= gpio-altera.o
 obj-$(CONFIG_GPIO_AMD8111)	+= gpio-amd8111.o
 obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
drivers/gpio/gpio-altera.c new file +374 -0

374 lines not on this page · raw message

Signature · 1 line
1.7.11.GIT
#3 lore raw
In reply to [email protected]
Quoted 7 lines · On Tue, Feb 24, 2015 at 10:53 AM, <[email protected]> wrote:

From: Tien Hock Loh <[email protected]>

Adds a new device tree binding and driver for Altera soft GPIO IP. The driver is able to do read/write and allows GPIO to be a interrupt controller.

Tested on Altera GHRD on interrupt handling and IO.

Quoted 7 lines

v10:
Updated conflicting device tree parameters
Removed unused headers
Used macro instead of magic numbers for ngpio
Code readability cleanup using ?: and temporal variables
Removed leftover garbage and unnecessary function calls
Checked bgpio_init but unusable because Altera GPIO may not be a multiple of 8 bits

This v10 patch applied. Any remaining issues can certainly be resolved by additional patches in-tree.

Good patience and good work, the driver looks really really neat now.

Yours,
Linus Walleij