Skip to content

Commit 5e969a4

Browse files
Thierry Redinglinusw
authored andcommitted
gpio: Add Avionic Design N-bit GPIO expander support
This commit adds a driver for the Avionic Design N-bit GPIO expander. The expander provides a variable number of GPIO pins with interrupt support. Changes in v2: - allow building the driver as a module - assign of_node unconditionally - use linear mapping IRQ domain - properly cleanup IRQ domain - add OF device table and annotate device tables - emulate rising and falling edge triggers - increase #gpio-cells to 2 - drop support for !OF - use IS_ENABLED to conditionalize DEBUG_FS code Changes in v3: - make IRQ support runtime configurable (interrupt-controller property) - drop interrupt-controller and #interrupt-cells from DT binding - add inline to_adnp() function to wrap container_of() macro - consistently use adnp as name for struct adnp variables - remove irq_mask_cur and rename irq_mask to irq_enable - fix a subtle deadlock in adnp_gpio_direction_output() - remove dynamic allocations from debugfs code - rename regs to num_regs to avoid confusion - annotate non-trivial code with comments - don't acquire mutex in adnp_gpio_get() - assume NO_IRQ == 0 Cc: Grant Likely <grant.likely@secretlab.ca> Cc: devicetree-discuss@lists.ozlabs.org Cc: Linus Walleij <linus.walleij@stericsson.com> Cc: linux-kernel@vger.kernel.org Acked-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent d724f1c commit 5e969a4

File tree

4 files changed

+653
-0
lines changed

4 files changed

+653
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Avionic Design N-bit GPIO expander bindings
2+
3+
Required properties:
4+
- compatible: should be "ad,gpio-adnp"
5+
- reg: The I2C slave address for this device.
6+
- interrupt-parent: phandle of the parent interrupt controller.
7+
- interrupts: Interrupt specifier for the controllers interrupt.
8+
- #gpio-cells: Should be 2. The first cell is the GPIO number and the
9+
second cell is used to specify optional parameters:
10+
- bit 0: polarity (0: normal, 1: inverted)
11+
- gpio-controller: Marks the device as a GPIO controller
12+
- nr-gpios: The number of pins supported by the controller.
13+
14+
Example:
15+
16+
gpioext: gpio-controller@41 {
17+
compatible = "ad,gpio-adnp";
18+
reg = <0x41>;
19+
20+
interrupt-parent = <&gpio>;
21+
interrupts = <160 1>;
22+
23+
gpio-controller;
24+
#gpio-cells = <2>;
25+
26+
interrupt-controller;
27+
#interrupt-cells = <2>;
28+
29+
nr-gpios = <64>;
30+
};

drivers/gpio/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,17 @@ config GPIO_ADP5588_IRQ
444444
Say yes here to enable the adp5588 to be used as an interrupt
445445
controller. It requires the driver to be built in the kernel.
446446

447+
config GPIO_ADNP
448+
tristate "Avionic Design N-bit GPIO expander"
449+
depends on I2C && OF
450+
help
451+
This option enables support for N GPIOs found on Avionic Design
452+
I2C GPIO expanders. The register space will be extended by powers
453+
of two, so the controller will need to accomodate for that. For
454+
example: if a controller provides 48 pins, 6 registers will be
455+
enough to represent all pins, but the driver will assume a
456+
register layout for 64 pins (8 registers).
457+
447458
comment "PCI GPIO expanders:"
448459

449460
config GPIO_CS5535

drivers/gpio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
1010

1111
obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o
1212
obj-$(CONFIG_GPIO_AB8500) += gpio-ab8500.o
13+
obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o
1314
obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o
1415
obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o
1516
obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o

0 commit comments

Comments
 (0)