Skip to content

Commit 9e80f90

Browse files
superna9999linusw
authored andcommitted
pinctrl: Add SX150X GPIO Extender Pinctrl Driver
Since the I2C sx150x GPIO expander driver uses platform_data to manage the pins configurations, rewrite the driver as a pinctrl driver using pinconf to get/set pin configurations from DT or debugfs. The pinctrl driver is functionnally equivalent as the gpio-only driver and can use DT for pinconf. The platform_data confirmation is dropped. This patchset removed the gpio-only driver and selects the Pinctrl driver config instead. This patchset also migrates the gpio dt-bindings to pinctrl and add the pinctrl optional properties. The driver was tested with a SX1509 device on a BeagleBone black with interrupt support and on an X86_64 machine over an I2C to USB converter. This is a fixed version that builds and runs on non-OF platforms and on arm based OF. The GPIO version is removed and the bindings are also moved to the pinctrl bindings. Changes since v2 - rebased on v4.9-rc1 - removed MODULE_DEVICE_TABLE as in upstream bb411e7 ("gpio: sx150x: fix implicit assumption module.h is present") Changes since v1 - Fix Kconfig descriptions on pinctrl and gpio - Fix Kconfig dependency - Remove oscio support for non-789 devices - correct typo in dt bindings - remove probe reset for non-789 devices Changes since RFC - Put #ifdef CONFIG_OF/CONFIG_OF_GPIO to remove OF code for non-of platforms - No more rely on OF_GPIO config - Moved and enhanced bindings to pinctrl bindings - Removed gpio-sx150x.c - Temporary select PINCTRL_SX150X when GPIO_SX150X - Temporary mark GPIO_SX150X as deprecated Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Tested-by: Peter Rosin <peda@axentia.se> Acked-by: Rob Herring <robh@kernel.org> ested-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 07d9a38 commit 9e80f90

File tree

8 files changed

+1151
-842
lines changed

8 files changed

+1151
-842
lines changed

Documentation/devicetree/bindings/gpio/gpio-sx150x.txt

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
SEMTECH SX150x GPIO expander bindings
2+
3+
Please refer to pinctrl-bindings.txt, ../gpio/gpio.txt, and
4+
../interrupt-controller/interrupts.txt for generic information regarding
5+
pin controller, GPIO, and interrupt bindings.
6+
7+
Required properties:
8+
- compatible: should be one of :
9+
"semtech,sx1506q",
10+
"semtech,sx1508q",
11+
"semtech,sx1509q",
12+
"semtech,sx1502q".
13+
14+
- reg: The I2C slave address for this device.
15+
16+
- #gpio-cells: Should be 2. The first cell is the GPIO number and the
17+
second cell is used to specify optional parameters:
18+
bit 0: polarity (0: normal, 1: inverted)
19+
20+
- gpio-controller: Marks the device as a GPIO controller.
21+
22+
Optional properties :
23+
- interrupt-parent: phandle of the parent interrupt controller.
24+
25+
- interrupts: Interrupt specifier for the controllers interrupt.
26+
27+
- interrupt-controller: Marks the device as a interrupt controller.
28+
29+
- semtech,probe-reset: Will trigger a reset of the GPIO expander on probe,
30+
only for sx1508q and sx1509q
31+
32+
The GPIO expander can optionally be used as an interrupt controller, in
33+
which case it uses the default two cell specifier.
34+
35+
Required properties for pin configuration sub-nodes:
36+
- pins: List of pins to which the configuration applies.
37+
38+
Optional properties for pin configuration sub-nodes:
39+
----------------------------------------------------
40+
- bias-disable: disable any pin bias, except the OSCIO pin
41+
- bias-pull-up: pull up the pin, except the OSCIO pin
42+
- bias-pull-down: pull down the pin, except the OSCIO pin
43+
- bias-pull-pin-default: use pin-default pull state, except the OSCIO pin
44+
- drive-push-pull: drive actively high and low
45+
- drive-open-drain: drive with open drain only for sx1508q and sx1509q and except the OSCIO pin
46+
- output-low: set the pin to output mode with low level
47+
- output-high: set the pin to output mode with high level
48+
49+
Example:
50+
51+
i2c0gpio-expander@20{
52+
#gpio-cells = <2>;
53+
#interrupt-cells = <2>;
54+
compatible = "semtech,sx1506q";
55+
reg = <0x20>;
56+
interrupt-parent = <&gpio_1>;
57+
interrupts = <16 0>;
58+
59+
gpio-controller;
60+
interrupt-controller;
61+
62+
pinctrl-names = "default";
63+
pinctrl-0 = <&gpio1_cfg_pins>;
64+
65+
gpio1_cfg_pins: gpio1-cfg {
66+
pins = "gpio1";
67+
bias-pull-up;
68+
};
69+
};

drivers/gpio/Kconfig

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -781,16 +781,13 @@ config GPIO_PCF857X
781781
platform-neutral GPIO calls.
782782

783783
config GPIO_SX150X
784-
bool "Semtech SX150x I2C GPIO expander"
785-
depends on I2C=y
786-
select GPIOLIB_IRQCHIP
784+
bool "Semtech SX150x I2C GPIO expander (deprecated)"
785+
depends on PINCTRL && I2C=y
786+
select PINCTRL_SX150X
787787
default n
788788
help
789-
Say yes here to provide support for Semtech SX150-series I2C
790-
GPIO expanders. Compatible models include:
791-
792-
8 bits: sx1508q
793-
16 bits: sx1509q
789+
Say yes here to provide support for Semtech SX150x-series I2C
790+
GPIO expanders. The GPIO driver was replaced by a Pinctrl version.
794791

795792
config GPIO_TPIC2810
796793
tristate "TPIC2810 8-Bit I2C GPO expander"

drivers/gpio/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o
102102
obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o
103103
obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o
104104
obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o
105-
obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o
106105
obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o
107106
obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o
108107
obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o

0 commit comments

Comments
 (0)