aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-13 10:59:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-13 10:59:10 -0500
commit20d5ba4928ceb79b919092c939ae4ef4d88807bd (patch)
treef8bd3653a63baa80a02be48443575ae83ac1d290
parent061ad5038ca5ac75419204b216bddc2806008ead (diff)
parentf821444508743a3e56320d0cb2b8c4603637660c (diff)
Merge tag 'pinctrl-v4.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pinctrl updates from Linus Walleij: "Bulk pin control changes for the v4.10 kernel cycle: No core changes this time. Mainly gradual improvement and feature growth in the drivers. New drivers: - New driver for TI DA850/OMAP-L138/AM18XX pinconf - The SX150x was moved over from the GPIO subsystem and reimagined as a pin control driver with GPIO support in a joint effort by three independent users of this hardware. The result was amazingly good! - New subdriver for the Oxnas OX820 Improvements: - The sunxi driver now supports the generic pin control bindings rather than the sunxi-specific. Add debouncing support to the driver. - Simplifications in pinctrl-single adding a generic parser. - Two downstream fixes and move the Raspberry Pi BCM2835 over to use the generic GPIOLIB_IRQCHIP" * tag 'pinctrl-v4.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: (92 commits) pinctrl: sx150x: use new nested IRQ infrastructure pinctrl: sx150x: handle missing 'advanced' reg in sx1504 and sx1505 pinctrl: sx150x: rename 'reg_advance' to 'reg_advanced' pinctrl: sx150x: access the correct bits in the 4-bit regs of sx150[147] pinctrl: mt8173: set GPIO16 to usb iddig mode pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP pinctrl: New driver for TI DA850/OMAP-L138/AM18XX pinconf devicetree: bindings: pinctrl: Add binding for ti,da850-pupd Documentation: pinctrl: palmas: Add ti,palmas-powerhold-override property definition pinctrl: intel: set default handler to be handle_bad_irq() pinctrl: sx150x: add support for sx1501, sx1504, sx1505 and sx1507 pinctrl: sx150x: sort chips by part number pinctrl: sx150x: use correct registers for reg_sense (sx1502 and sx1508) pinctrl: imx: fix imx_pinctrl_desc initialization pinctrl: sx150x: support setting multiple pins at once pinctrl: sx150x: various spelling fixes and some white-space cleanup pinctrl: mediatek: use builtin_platform_driver pinctrl: stm32: use builtin_platform_driver pinctrl: sunxi: Testing the wrong variable pinctrl: nomadik: split up and comments MC0 pins ...
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio_oxnas.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt30
-rw-r--r--Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/oxnas,pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt44
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt9
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt13
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,msm8994-pinctrl.txt177
-rw-r--r--Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt9
-rw-r--r--Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt19
-rw-r--r--Documentation/devicetree/bindings/pinctrl/ti,da850-pupd.txt55
-rw-r--r--drivers/pinctrl/Kconfig12
-rw-r--r--drivers/pinctrl/Makefile1
-rw-r--r--drivers/pinctrl/bcm/Kconfig1
-rw-r--r--drivers/pinctrl/bcm/pinctrl-bcm2835.c165
-rw-r--r--drivers/pinctrl/devicetree.c144
-rw-r--r--drivers/pinctrl/devicetree.h23
-rw-r--r--drivers/pinctrl/freescale/pinctrl-imx.c8
-rw-r--r--drivers/pinctrl/intel/pinctrl-baytrail.c2
-rw-r--r--drivers/pinctrl/intel/pinctrl-cherryview.c2
-rw-r--r--drivers/pinctrl/intel/pinctrl-intel.c2
-rw-r--r--drivers/pinctrl/intel/pinctrl-merrifield.c41
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt6397.c6
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-mt8173.h2
-rw-r--r--drivers/pinctrl/meson/Makefile3
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson-gxl.c589
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.c8
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.h2
-rw-r--r--drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c23
-rw-r--r--drivers/pinctrl/pinconf-generic.c2
-rw-r--r--drivers/pinctrl/pinctrl-at91.c21
-rw-r--r--drivers/pinctrl/pinctrl-da850-pupd.c210
-rw-r--r--drivers/pinctrl/pinctrl-oxnas.c605
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c86
-rw-r--r--drivers/pinctrl/pinctrl-single.c217
-rw-r--r--drivers/pinctrl/pinctrl-st.c4
-rw-r--r--drivers/pinctrl/pinctrl-sx150x.c969
-rw-r--r--drivers/pinctrl/pinctrl-zynq.c6
-rw-r--r--drivers/pinctrl/qcom/Kconfig9
-rw-r--r--drivers/pinctrl/qcom/Makefile1
-rw-r--r--drivers/pinctrl/qcom/pinctrl-msm8994.c1379
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.c45
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.h11
-rw-r--r--drivers/pinctrl/samsung/pinctrl-s3c24xx.c37
-rw-r--r--drivers/pinctrl/samsung/pinctrl-s3c64xx.c40
-rw-r--r--drivers/pinctrl/samsung/pinctrl-samsung.c40
-rw-r--r--drivers/pinctrl/samsung/pinctrl-samsung.h10
-rw-r--r--drivers/pinctrl/sh-pfc/core.c15
-rw-r--r--drivers/pinctrl/sh-pfc/core.h4
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7778.c342
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7795.c616
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7796.c576
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c3
-rw-r--r--drivers/pinctrl/sh-pfc/sh_pfc.h14
-rw-r--r--drivers/pinctrl/stm32/pinctrl-stm32f429.c6
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-gr8.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun5i-a10s.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun5i-a13.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun6i-a31-r.c10
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun6i-a31s.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun7i-a20.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a23-r.c11
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c10
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c9
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sunxi.c506
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sunxi.h8
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-vt8500.c17
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wm8505.c17
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wm8650.c17
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wm8750.c17
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wm8850.c17
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wmt.c10
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wmt.h1
-rw-r--r--include/dt-bindings/gpio/meson-gxl-gpio.h131
-rw-r--r--include/dt-bindings/pinctrl/at91.h2
80 files changed, 6174 insertions, 1356 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio_oxnas.txt b/Documentation/devicetree/bindings/gpio/gpio_oxnas.txt
index 928ed4f43907..966514744df4 100644
--- a/Documentation/devicetree/bindings/gpio/gpio_oxnas.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio_oxnas.txt
@@ -3,7 +3,7 @@
3Please refer to gpio.txt for generic information regarding GPIO bindings. 3Please refer to gpio.txt for generic information regarding GPIO bindings.
4 4
5Required properties: 5Required properties:
6 - compatible: "oxsemi,ox810se-gpio" 6 - compatible: "oxsemi,ox810se-gpio" or "oxsemi,ox820-gpio"
7 - reg: Base address and length for the device. 7 - reg: Base address and length for the device.
8 - interrupts: The port interrupt shared by all pins. 8 - interrupts: The port interrupt shared by all pins.
9 - gpio-controller: Marks the port as GPIO controller. 9 - gpio-controller: Marks the port as GPIO controller.
diff --git a/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
index 1685821eea41..de1378b4efad 100644
--- a/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt
@@ -28,6 +28,20 @@ Required properties:
28- reg: Should contain the register physical address and length for the 28- reg: Should contain the register physical address and length for the
29 pin controller. 29 pin controller.
30 30
31- clocks: phandle to the clocks feeding the pin controller:
32 - "apb": the gated APB parent clock
33 - "hosc": the high frequency oscillator in the system
34 - "losc": the low frequency oscillator in the system
35
36Note: For backward compatibility reasons, the hosc and losc clocks are only
37required if you need to use the optional input-debounce property. Any new
38device tree should set them.
39
40Optional properties:
41 - input-debounce: Array of debouncing periods in microseconds. One period per
42 irq bank found in the controller. 0 if no setup required.
43
44
31Please refer to pinctrl-bindings.txt in this directory for details of the 45Please refer to pinctrl-bindings.txt in this directory for details of the
32common pinctrl bindings used by client devices. 46common pinctrl bindings used by client devices.
33 47
@@ -37,6 +51,22 @@ pins it needs, and how they should be configured, with regard to muxer
37configuration, drive strength and pullups. If one of these options is 51configuration, drive strength and pullups. If one of these options is
38not set, its actual value will be unspecified. 52not set, its actual value will be unspecified.
39 53
54This driver supports the generic pin multiplexing and configuration
55bindings. For details on each properties, you can refer to
56./pinctrl-bindings.txt.
57
58Required sub-node properties:
59 - pins
60 - function
61
62Optional sub-node properties:
63 - bias-disable
64 - bias-pull-up
65 - bias-pull-down
66 - drive-strength
67
68*** Deprecated pin configuration and multiplexing binding
69
40Required subnode-properties: 70Required subnode-properties:
41 71
42- allwinner,pins: List of strings containing the pin name. 72- allwinner,pins: List of strings containing the pin name.
diff --git a/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
index b7a93e80a302..9a8a45d9d8ab 100644
--- a/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
@@ -98,6 +98,8 @@ DRIVE_STRENGTH (3 << 5): indicate the drive strength of the pin using the
98 01 - Low 98 01 - Low
99 10 - Medium 99 10 - Medium
100 11 - High 100 11 - High
101OUTPUT (1 << 7): indicate this pin need to be configured as an output.
102OUTPUT_VAL (1 << 8): output val (1 = high, 0 = low)
101DEBOUNCE (1 << 16): indicate this pin needs debounce. 103DEBOUNCE (1 << 16): indicate this pin needs debounce.
102DEBOUNCE_VAL (0x3fff << 17): debounce value. 104DEBOUNCE_VAL (0x3fff << 17): debounce value.
103 105
diff --git a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
index fe7fe0b03cfb..2392557ede27 100644
--- a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
@@ -7,6 +7,8 @@ Required properties for the root node:
7 "amlogic,meson8b-aobus-pinctrl" 7 "amlogic,meson8b-aobus-pinctrl"
8 "amlogic,meson-gxbb-periphs-pinctrl" 8 "amlogic,meson-gxbb-periphs-pinctrl"
9 "amlogic,meson-gxbb-aobus-pinctrl" 9 "amlogic,meson-gxbb-aobus-pinctrl"
10 "amlogic,meson-gxl-periphs-pinctrl"
11 "amlogic,meson-gxl-aobus-pinctrl"
10 - reg: address and size of registers controlling irq functionality 12 - reg: address and size of registers controlling irq functionality
11 13
12=== GPIO sub-nodes === 14=== GPIO sub-nodes ===
diff --git a/Documentation/devicetree/bindings/pinctrl/oxnas,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/oxnas,pinctrl.txt
index d6074321f730..09e81a95bbfd 100644
--- a/Documentation/devicetree/bindings/pinctrl/oxnas,pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/oxnas,pinctrl.txt
@@ -9,7 +9,7 @@ used for a specific device or function. This node represents configurations of
9pins, optional function, and optional mux related configuration. 9pins, optional function, and optional mux related configuration.
10 10
11Required properties for pin controller node: 11Required properties for pin controller node:
12 - compatible: "oxsemi,ox810se-pinctrl" 12 - compatible: "oxsemi,ox810se-pinctrl" or "oxsemi,ox820-pinctrl"
13 - oxsemi,sys-ctrl: a phandle to the system controller syscon node 13 - oxsemi,sys-ctrl: a phandle to the system controller syscon node
14 14
15Required properties for pin configuration sub-nodes: 15Required properties for pin configuration sub-nodes:
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
index b73c96d24f59..bf3f7b014724 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
@@ -97,6 +97,11 @@ For example:
97 }; 97 };
98 98
99== Pin controller devices == 99== Pin controller devices ==
100Required properties: See the pin controller driver specific documentation
101
102Optional properties:
103#pinctrl-cells: Number of pin control cells in addition to the index within the
104 pin controller device instance
100 105
101Pin controller devices should contain the pin configuration nodes that client 106Pin controller devices should contain the pin configuration nodes that client
102devices reference. 107devices reference.
@@ -119,7 +124,8 @@ For example:
119 124
120The contents of each of those pin configuration child nodes is defined 125The contents of each of those pin configuration child nodes is defined
121entirely by the binding for the individual pin controller device. There 126entirely by the binding for the individual pin controller device. There
122exists no common standard for this content. 127exists no common standard for this content. The pinctrl framework only
128provides generic helper bindings that the pin controller driver can use.
123 129
124The pin configuration nodes need not be direct children of the pin controller 130The pin configuration nodes need not be direct children of the pin controller
125device; they may be grandchildren, for example. Whether this is legal, and 131device; they may be grandchildren, for example. Whether this is legal, and
@@ -156,6 +162,42 @@ state_2_node_a {
156 pins = "mfio29", "mfio30"; 162 pins = "mfio29", "mfio30";
157}; 163};
158 164
165Optionally an altenative binding can be used if more suitable depending on the
166pin controller hardware. For hardaware where there is a large number of identical
167pin controller instances, naming each pin and function can easily become
168unmaintainable. This is especially the case if the same controller is used for
169different pins and functions depending on the SoC revision and packaging.
170
171For cases like this, the pin controller driver may use pinctrl-pin-array helper
172binding with a hardware based index and a number of pin configuration values:
173
174pincontroller {
175 ... /* Standard DT properties for the device itself elided */
176 #pinctrl-cells = <2>;
177
178 state_0_node_a {
179 pinctrl-pin-array = <
180 0 A_DELAY_PS(0) G_DELAY_PS(120)
181 4 A_DELAY_PS(0) G_DELAY_PS(360)
182 ...
183 >;
184 };
185 ...
186};
187
188Above #pinctrl-cells specifies the number of value cells in addition to the
189index of the registers. This is similar to the interrupts-extended binding with
190one exception. There is no need to specify the phandle for each entry as that
191is already known as the defined pins are always children of the pin controller
192node. Further having the phandle pointing to another pin controller would not
193currently work as the pinctrl framework uses named modes to group pins for each
194pin control device.
195
196The index for pinctrl-pin-array must relate to the hardware for the pinctrl
197registers, and must not be a virtual index of pin instances. The reason for
198this is to avoid mapping of the index in the dts files and the pin controller
199driver as it can change.
200
159== Generic pin configuration node content == 201== Generic pin configuration node content ==
160 202
161Many data items that are represented in a pin configuration node are common 203Many data items that are represented in a pin configuration node are common
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt
index caf297bee1fb..c28d4eb83b76 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt
@@ -35,6 +35,15 @@ Optional properties:
35- ti,palmas-enable-dvfs2: Enable DVFS2. Configure pins for DVFS2 mode. 35- ti,palmas-enable-dvfs2: Enable DVFS2. Configure pins for DVFS2 mode.
36 Selection primary or secondary function associated to GPADC_START 36 Selection primary or secondary function associated to GPADC_START
37 and SYSEN2 pin/pad for DVFS2 interface 37 and SYSEN2 pin/pad for DVFS2 interface
38- ti,palmas-override-powerhold: This is applicable for PMICs for which
39 GPIO7 is configured in POWERHOLD mode which has higher priority
40 over DEV_ON bit and keeps the PMIC supplies on even after the DEV_ON
41 bit is turned off. This property enables driver to over ride the
42 POWERHOLD value to GPIO7 so as to turn off the PMIC in power off
43 scenarios. So for GPIO7 if ti,palmas-override-powerhold is set
44 then the GPIO_7 field should never be muxed to anything else.
45 It should be set to POWERHOLD by default and only in case of
46 power off scenarios the driver will over ride the mux value.
38 47
39This binding uses the following generic properties as defined in 48This binding uses the following generic properties as defined in
40pinctrl-bindings.txt: 49pinctrl-bindings.txt:
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt
index c293c8aaac73..bf76867168e9 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt
@@ -6,10 +6,15 @@ pin controller, GPIO, and interrupt bindings.
6 6
7Required properties: 7Required properties:
8- compatible: should be one of : 8- compatible: should be one of :
9 "semtech,sx1501q",
10 "semtech,sx1502q",
11 "semtech,sx1503q",
12 "semtech,sx1504q",
13 "semtech,sx1505q",
9 "semtech,sx1506q", 14 "semtech,sx1506q",
15 "semtech,sx1507q",
10 "semtech,sx1508q", 16 "semtech,sx1508q",
11 "semtech,sx1509q", 17 "semtech,sx1509q".
12 "semtech,sx1502q".
13 18
14- reg: The I2C slave address for this device. 19- reg: The I2C slave address for this device.
15 20
@@ -27,7 +32,7 @@ Optional properties :
27- interrupt-controller: Marks the device as a interrupt controller. 32- interrupt-controller: Marks the device as a interrupt controller.
28 33
29- semtech,probe-reset: Will trigger a reset of the GPIO expander on probe, 34- semtech,probe-reset: Will trigger a reset of the GPIO expander on probe,
30 only for sx1508q and sx1509q 35 only for sx1507q, sx1508q and sx1509q
31 36
32The GPIO expander can optionally be used as an interrupt controller, in 37The GPIO expander can optionally be used as an interrupt controller, in
33which case it uses the default two cell specifier. 38which case it uses the default two cell specifier.
@@ -42,7 +47,7 @@ Optional properties for pin configuration sub-nodes:
42 - bias-pull-down: pull down the pin, except the OSCIO pin 47 - 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 48 - bias-pull-pin-default: use pin-default pull state, except the OSCIO pin
44 - drive-push-pull: drive actively high and low 49 - 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 50 - drive-open-drain: drive with open drain only for sx1507q, sx1508q and sx1509q and except the OSCIO pin
46 - output-low: set the pin to output mode with low level 51 - output-low: set the pin to output mode with low level
47 - output-high: set the pin to output mode with high level 52 - output-high: set the pin to output mode with high level
48 53
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,msm8994-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,msm8994-pinctrl.txt
new file mode 100644
index 000000000000..13cd629f896e
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,msm8994-pinctrl.txt
@@ -0,0 +1,177 @@
1Qualcomm MSM8994 TLMM block
2
3This binding describes the Top Level Mode Multiplexer block found in the
4MSM8994 platform.
5
6- compatible:
7 Usage: required
8 Value type: <string>
9 Definition: Should contain one of:
10 "qcom,msm8992-pinctrl",
11 "qcom,msm8994-pinctrl".
12
13- reg:
14 Usage: required
15 Value type: <prop-encoded-array>
16 Definition: the base address and size of the TLMM register space.
17
18- interrupts:
19 Usage: required
20 Value type: <prop-encoded-array>
21 Definition: should specify the TLMM summary IRQ.
22
23- interrupt-controller:
24 Usage: required
25 Value type: <none>
26 Definition: identifies this node as an interrupt controller
27
28- #interrupt-cells:
29 Usage: required
30 Value type: <u32>
31 Definition: must be 2. Specifying the pin number and flags, as defined
32 in <dt-bindings/interrupt-controller/irq.h>
33
34- gpio-controller:
35 Usage: required
36 Value type: <none>
37 Definition: identifies this node as a gpio controller
38
39- #gpio-cells:
40 Usage: required
41 Value type: <u32>
42 Definition: must be 2. Specifying the pin number and flags, as defined
43 in <dt-bindings/gpio/gpio.h>
44
45Please refer to ../gpio/gpio.txt and ../interrupt-controller/interrupts.txt for
46a general description of GPIO and interrupt bindings.
47
48Please refer to pinctrl-bindings.txt in this directory for details of the
49common pinctrl bindings used by client devices, including the meaning of the
50phrase "pin configuration node".
51
52The pin configuration nodes act as a container for an arbitrary number of
53subnodes. Each of these subnodes represents some desired configuration for a
54pin, a group, or a list of pins or groups. This configuration can include the
55mux function to select on those pin(s)/group(s), and various pin configuration
56parameters, such as pull-up, drive strength, etc.
57
58
59PIN CONFIGURATION NODES:
60
61The name of each subnode is not important; all subnodes should be enumerated
62and processed purely based on their content.
63
64Each subnode only affects those parameters that are explicitly listed. In
65other words, a subnode that lists a mux function but no pin configuration
66parameters implies no information about any pin configuration parameters.
67Similarly, a pin subnode that describes a pullup parameter implies no
68information about e.g. the mux function.
69
70
71The following generic properties as defined in pinctrl-bindings.txt are valid
72to specify in a pin configuration subnode:
73
74- pins:
75 Usage: required
76 Value type: <string-array>
77 Definition: List of gpio pins affected by the properties specified in
78 this subnode.
79
80 Valid pins are:
81 gpio0-gpio145
82 Supports mux, bias and drive-strength
83
84 sdc1_clk, sdc1_cmd, sdc1_data sdc1_rclk, sdc2_clk,
85 sdc2_cmd, sdc2_data
86 Supports bias and drive-strength
87
88- function:
89 Usage: required
90 Value type: <string>
91 Definition: Specify the alternative function to be configured for the
92 specified pins. Functions are only valid for gpio pins.
93 Valid values are:
94
95 audio_ref_clk, blsp_i2c1, blsp_i2c2, blsp_i2c3, blsp_i2c4, blsp_i2c5,
96 blsp_i2c6, blsp_i2c7, blsp_i2c8, blsp_i2c9, blsp_i2c10, blsp_i2c11,
97 blsp_i2c12, blsp_spi1, blsp_spi1_cs1, blsp_spi1_cs2, blsp_spi1_cs3,
98 blsp_spi2, blsp_spi2_cs1, blsp_spi2_cs2, blsp_spi2_cs3, blsp_spi3,
99 blsp_spi4, blsp_spi5, blsp_spi6, blsp_spi7, blsp_spi8, blsp_spi9,
100 blsp_spi10, blsp_spi10_cs1, blsp_spi10_cs2, blsp_spi10_cs3, blsp_spi11,
101 blsp_spi12, blsp_uart1, blsp_uart2, blsp_uart3, blsp_uart4, blsp_uart5,
102 blsp_uart6, blsp_uart7, blsp_uart8, blsp_uart9, blsp_uart10, blsp_uart11,
103 blsp_uart12, blsp_uim1, blsp_uim2, blsp_uim3, blsp_uim4, blsp_uim5,
104 blsp_uim6, blsp_uim7, blsp_uim8, blsp_uim9, blsp_uim10, blsp_uim11,
105 blsp_uim12, blsp11_i2c_scl_b, blsp11_i2c_sda_b, blsp11_uart_rx_b,
106 blsp11_uart_tx_b, cam_mclk0, cam_mclk1, cam_mclk2, cam_mclk3,
107 cci_async_in0, cci_async_in1, cci_async_in2, cci_i2c0, cci_i2c1,
108 cci_timer0, cci_timer1, cci_timer2, cci_timer3, cci_timer4,
109 gcc_gp1_clk_a, gcc_gp1_clk_b, gcc_gp2_clk_a, gcc_gp2_clk_b, gcc_gp3_clk_a,
110 gcc_gp3_clk_b, gp_mn, gp_pdm0, gp_pdm1, gp_pdm2, gp0_clk,
111 gp1_clk, gps_tx, gsm_tx, hdmi_cec, hdmi_ddc, hdmi_hpd, hdmi_rcv,
112 mdp_vsync, mss_lte, nav_pps, nav_tsync, qdss_cti_trig_in_a,
113 qdss_cti_trig_in_b, qdss_cti_trig_in_c, qdss_cti_trig_in_d,
114 qdss_cti_trig_out_a, qdss_cti_trig_out_b, qdss_cti_trig_out_c,
115 qdss_cti_trig_out_d, qdss_traceclk_a, qdss_traceclk_b, qdss_tracectl_a,
116 qdss_tracectl_b, qdss_tracedata_a, qdss_tracedata_b, qua_mi2s, pci_e0,
117 pci_e1, pri_mi2s, sdc4, sec_mi2s, slimbus, spkr_i2s, ter_mi2s, tsif1,
118 tsif2, uim_batt_alarm, uim1, uim2, uim3, uim4, gpio
119
120- bias-disable:
121 Usage: optional
122 Value type: <none>
123 Definition: The specified pins should be configued as no pull.
124
125- bias-pull-down:
126 Usage: optional
127 Value type: <none>
128 Definition: The specified pins should be configued as pull down.
129
130- bias-pull-up:
131 Usage: optional
132 Value type: <none>
133 Definition: The specified pins should be configued as pull up.
134
135- output-high:
136 Usage: optional
137 Value type: <none>
138 Definition: The specified pins are configured in output mode, driven
139 high.
140 Not valid for sdc pins.
141
142- output-low:
143 Usage: optional
144 Value type: <none>
145 Definition: The specified pins are configured in output mode, driven
146 low.
147 Not valid for sdc pins.
148
149- drive-strength:
150 Usage: optional
151 Value type: <u32>
152 Definition: Selects the drive strength for the specified pins, in mA.
153 Valid values are: 2, 4, 6, 8, 10, 12, 14 and 16
154
155Example:
156
157 msmgpio: pinctrl@fd510000 {
158 compatible = "qcom,msm8994-pinctrl";
159 reg = <0xfd510000 0x4000>;
160 interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
161 gpio-controller;
162 #gpio-cells = <2>;
163 interrupt-controller;
164 #interrupt-cells = <2>;
165
166 blsp1_uart2_default: blsp1_uart2_default {
167 pinmux {
168 pins = "gpio4", "gpio5";
169 function = "blsp_uart2";
170 };
171 pinconf {
172 pins = "gpio4", "gpio5";
173 drive-strength = <16>;
174 bias-disable;
175 };
176 };
177 };
diff --git a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt
index c68b9554561f..4722bc61a1a2 100644
--- a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt
@@ -19,10 +19,11 @@ The pins are grouped into up to 5 individual pin banks which need to be
19defined as gpio sub-nodes of the pinmux controller. 19defined as gpio sub-nodes of the pinmux controller.
20 20
21Required properties for iomux controller: 21Required properties for iomux controller:
22 - compatible: one of "rockchip,rk2928-pinctrl", "rockchip,rk3066a-pinctrl" 22 - compatible: one of "rockchip,rk1108-pinctrl", "rockchip,rk2928-pinctrl"
23 "rockchip,rk3066b-pinctrl", "rockchip,rk3188-pinctrl" 23 "rockchip,rk3066a-pinctrl", "rockchip,rk3066b-pinctrl"
24 "rockchip,rk3228-pinctrl", "rockchip,rk3288-pinctrl" 24 "rockchip,rk3188-pinctrl", "rockchip,rk3228-pinctrl"
25 "rockchip,rk3368-pinctrl", "rockchip,rk3399-pinctrl" 25 "rockchip,rk3288-pinctrl", "rockchip,rk3368-pinctrl"
26 "rockchip,rk3399-pinctrl"
26 - rockchip,grf: phandle referencing a syscon providing the 27 - rockchip,grf: phandle referencing a syscon providing the
27 "general register files" 28 "general register files"
28 29
diff --git a/Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt
index d49e22d2a8b5..1baf19eecabf 100644
--- a/Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt
@@ -19,11 +19,30 @@ Required Properties:
19 - "samsung,exynos5260-pinctrl": for Exynos5260 compatible pin-controller. 19 - "samsung,exynos5260-pinctrl": for Exynos5260 compatible pin-controller.
20 - "samsung,exynos5410-pinctrl": for Exynos5410 compatible pin-controller. 20 - "samsung,exynos5410-pinctrl": for Exynos5410 compatible pin-controller.
21 - "samsung,exynos5420-pinctrl": for Exynos5420 compatible pin-controller. 21 - "samsung,exynos5420-pinctrl": for Exynos5420 compatible pin-controller.
22 - "samsung,exynos5433-pinctrl": for Exynos5433 compatible pin-controller.
22 - "samsung,exynos7-pinctrl": for Exynos7 compatible pin-controller. 23 - "samsung,exynos7-pinctrl": for Exynos7 compatible pin-controller.
23 24
24- reg: Base address of the pin controller hardware module and length of 25- reg: Base address of the pin controller hardware module and length of
25 the address space it occupies. 26 the address space it occupies.
26 27
28 - reg: Second base address of the pin controller if the specific registers
29 of the pin controller are separated into the different base address.
30
31 Eg: GPF[1-5] of Exynos5433 are separated into the two base address.
32 - First base address is for GPAx and GPF[1-5] external interrupt
33 registers.
34 - Second base address is for GPF[1-5] pinctrl registers.
35
36 pinctrl_0: pinctrl@10580000 {
37 compatible = "samsung,exynos5433-pinctrl";
38 reg = <0x10580000 0x1a20>, <0x11090000 0x100>;
39
40 wakeup-interrupt-controller {
41 compatible = "samsung,exynos7-wakeup-eint";
42 interrupts = <0 16 0>;
43 };
44 };
45
27- Pin banks as child nodes: Pin banks of the controller are represented by child 46- Pin banks as child nodes: Pin banks of the controller are represented by child
28 nodes of the controller node. Bank name is taken from name of the node. Each 47 nodes of the controller node. Bank name is taken from name of the node. Each
29 bank node must contain following properties: 48 bank node must contain following properties:
diff --git a/Documentation/devicetree/bindings/pinctrl/ti,da850-pupd.txt b/Documentation/devicetree/bindings/pinctrl/ti,da850-pupd.txt
new file mode 100644
index 000000000000..7f2980567c9f
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/ti,da850-pupd.txt
@@ -0,0 +1,55 @@
1* Pin configuration for TI DA850/OMAP-L138/AM18x
2
3These SoCs have a separate controller for setting bias (internal pullup/down).
4Bias can only be selected for groups rather than individual pins.
5
6Required Properties:
7
8 - compatible: Must be "ti,da850-pupd"
9 - reg: Base address and length of the memory resource used by the pullup/down
10 controller hardware module.
11
12The controller node also acts as a container for pin group configuration nodes.
13The names of these groups are ignored.
14
15Pin Group Node Properties:
16
17- groups: An array of strings, each string containing the name of a pin group.
18 Valid names are "cp0".."cp31".
19
20The pin configuration parameters use the generic pinconf bindings defined in
21pinctrl-bindings.txt in this directory. The supported parameters are
22bias-disable, bias-pull-up, bias-pull-down.
23
24
25Example
26-------
27
28In common dtsi file:
29
30 pinconf: pin-controller@22c00c {
31 compatible = "ti,da850-pupd";
32 reg = <0x22c00c 0x8>;
33 };
34
35In board-specific file:
36
37 &pinconf {
38 pinctrl-0 = <&pinconf_bias_groups>;
39 pinctrl-names = "default";
40
41 pinconf_bias_groups: bias-groups {
42 pull-up {
43 groups = "cp30", "cp31";
44 bias-pull-up;
45 };
46 pull-down {
47 groups = "cp29", "cp28";
48 bias-pull-down;
49 };
50 disable {
51 groups = "cp27", "cp26";
52 bias-disable;
53 };
54 };
55 };
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 801fa8bb05e1..54044a8ecbd7 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -93,6 +93,15 @@ config PINCTRL_AMD
93 Requires ACPI/FDT device enumeration code to set up a platform 93 Requires ACPI/FDT device enumeration code to set up a platform
94 device. 94 device.
95 95
96config PINCTRL_DA850_PUPD
97 tristate "TI DA850/OMAP-L138/AM18XX pullup/pulldown groups"
98 depends on OF && (ARCH_DAVINCI_DA850 || COMPILE_TEST)
99 select PINCONF
100 select GENERIC_PINCONF
101 help
102 Driver for TI DA850/OMAP-L138/AM18XX pinconf. Used to control
103 pullup/pulldown pin groups.
104
96config PINCTRL_DIGICOLOR 105config PINCTRL_DIGICOLOR
97 bool 106 bool
98 depends on OF && (ARCH_DIGICOLOR || COMPILE_TEST) 107 depends on OF && (ARCH_DIGICOLOR || COMPILE_TEST)
@@ -171,6 +180,7 @@ config PINCTRL_SX150X
171 select PINCONF 180 select PINCONF
172 select GENERIC_PINCONF 181 select GENERIC_PINCONF
173 select GPIOLIB_IRQCHIP 182 select GPIOLIB_IRQCHIP
183 select REGMAP
174 help 184 help
175 Say yes here to provide support for Semtech SX150x-series I2C 185 Say yes here to provide support for Semtech SX150x-series I2C
176 GPIO expanders as pinctrl module. 186 GPIO expanders as pinctrl module.
@@ -223,7 +233,7 @@ config PINCTRL_COH901
223 233
224config PINCTRL_MAX77620 234config PINCTRL_MAX77620
225 tristate "MAX77620/MAX20024 Pincontrol support" 235 tristate "MAX77620/MAX20024 Pincontrol support"
226 depends on MFD_MAX77620 236 depends on MFD_MAX77620 && OF
227 select PINMUX 237 select PINMUX
228 select GENERIC_PINCONF 238 select GENERIC_PINCONF
229 help 239 help
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 3b8e6f726acb..25d50a86981d 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_PINCTRL_BF60x) += pinctrl-adi2-bf60x.o
14obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o 14obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
15obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o 15obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o
16obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o 16obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o
17obj-$(CONFIG_PINCTRL_DA850_PUPD) += pinctrl-da850-pupd.o
17obj-$(CONFIG_PINCTRL_DIGICOLOR) += pinctrl-digicolor.o 18obj-$(CONFIG_PINCTRL_DIGICOLOR) += pinctrl-digicolor.o
18obj-$(CONFIG_PINCTRL_FALCON) += pinctrl-falcon.o 19obj-$(CONFIG_PINCTRL_FALCON) += pinctrl-falcon.o
19obj-$(CONFIG_PINCTRL_MAX77620) += pinctrl-max77620.o 20obj-$(CONFIG_PINCTRL_MAX77620) += pinctrl-max77620.o
diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig
index 63246770bd74..8968dd7aebed 100644
--- a/drivers/pinctrl/bcm/Kconfig
+++ b/drivers/pinctrl/bcm/Kconfig
@@ -20,6 +20,7 @@ config PINCTRL_BCM2835
20 bool 20 bool
21 select PINMUX 21 select PINMUX
22 select PINCONF 22 select PINCONF
23 select GPIOLIB_IRQCHIP
23 24
24config PINCTRL_IPROC_GPIO 25config PINCTRL_IPROC_GPIO
25 bool "Broadcom iProc GPIO (with PINCONF) driver" 26 bool "Broadcom iProc GPIO (with PINCONF) driver"
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index fa77165fab2c..1bb38d0493eb 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -24,11 +24,9 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/gpio/driver.h> 26#include <linux/gpio/driver.h>
27#include <linux/interrupt.h>
28#include <linux/io.h> 27#include <linux/io.h>
29#include <linux/irq.h> 28#include <linux/irq.h>
30#include <linux/irqdesc.h> 29#include <linux/irqdesc.h>
31#include <linux/irqdomain.h>
32#include <linux/module.h> 30#include <linux/module.h>
33#include <linux/of_address.h> 31#include <linux/of_address.h>
34#include <linux/of.h> 32#include <linux/of.h>
@@ -47,6 +45,7 @@
47#define MODULE_NAME "pinctrl-bcm2835" 45#define MODULE_NAME "pinctrl-bcm2835"
48#define BCM2835_NUM_GPIOS 54 46#define BCM2835_NUM_GPIOS 54
49#define BCM2835_NUM_BANKS 2 47#define BCM2835_NUM_BANKS 2
48#define BCM2835_NUM_IRQS 3
50 49
51#define BCM2835_PIN_BITMAP_SZ \ 50#define BCM2835_PIN_BITMAP_SZ \
52 DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8) 51 DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8)
@@ -86,31 +85,23 @@ enum bcm2835_pinconf_pull {
86#define BCM2835_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16) 85#define BCM2835_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16)
87#define BCM2835_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff) 86#define BCM2835_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff)
88 87
89struct bcm2835_gpio_irqdata {
90 struct bcm2835_pinctrl *pc;
91 int bank;
92};
93
94struct bcm2835_pinctrl { 88struct bcm2835_pinctrl {
95 struct device *dev; 89 struct device *dev;
96 void __iomem *base; 90 void __iomem *base;
97 int irq[BCM2835_NUM_BANKS]; 91 int irq[BCM2835_NUM_IRQS];
98 92
99 /* note: locking assumes each bank will have its own unsigned long */ 93 /* note: locking assumes each bank will have its own unsigned long */
100 unsigned long enabled_irq_map[BCM2835_NUM_BANKS]; 94 unsigned long enabled_irq_map[BCM2835_NUM_BANKS];
101 unsigned int irq_type[BCM2835_NUM_GPIOS]; 95 unsigned int irq_type[BCM2835_NUM_GPIOS];
102 96
103 struct pinctrl_dev *pctl_dev; 97 struct pinctrl_dev *pctl_dev;
104 struct irq_domain *irq_domain;
105 struct gpio_chip gpio_chip; 98 struct gpio_chip gpio_chip;
106 struct pinctrl_gpio_range gpio_range; 99 struct pinctrl_gpio_range gpio_range;
107 100
108 struct bcm2835_gpio_irqdata irq_data[BCM2835_NUM_BANKS]; 101 int irq_group[BCM2835_NUM_IRQS];
109 spinlock_t irq_lock[BCM2835_NUM_BANKS]; 102 spinlock_t irq_lock[BCM2835_NUM_BANKS];
110}; 103};
111 104
112static struct lock_class_key gpio_lock_class;
113
114/* pins are just named GPIO0..GPIO53 */ 105/* pins are just named GPIO0..GPIO53 */
115#define BCM2835_GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a) 106#define BCM2835_GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a)
116static struct pinctrl_pin_desc bcm2835_gpio_pins[] = { 107static struct pinctrl_pin_desc bcm2835_gpio_pins[] = {
@@ -368,13 +359,6 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
368 return pinctrl_gpio_direction_output(chip->base + offset); 359 return pinctrl_gpio_direction_output(chip->base + offset);
369} 360}
370 361
371static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
372{
373 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
374
375 return irq_linear_revmap(pc->irq_domain, offset);
376}
377
378static struct gpio_chip bcm2835_gpio_chip = { 362static struct gpio_chip bcm2835_gpio_chip = {
379 .label = MODULE_NAME, 363 .label = MODULE_NAME,
380 .owner = THIS_MODULE, 364 .owner = THIS_MODULE,
@@ -385,31 +369,67 @@ static struct gpio_chip bcm2835_gpio_chip = {
385 .get_direction = bcm2835_gpio_get_direction, 369 .get_direction = bcm2835_gpio_get_direction,
386 .get = bcm2835_gpio_get, 370 .get = bcm2835_gpio_get,
387 .set = bcm2835_gpio_set, 371 .set = bcm2835_gpio_set,
388 .to_irq = bcm2835_gpio_to_irq,
389 .base = -1, 372 .base = -1,
390 .ngpio = BCM2835_NUM_GPIOS, 373 .ngpio = BCM2835_NUM_GPIOS,
391 .can_sleep = false, 374 .can_sleep = false,
392}; 375};
393 376
394static irqreturn_t bcm2835_gpio_irq_handler(int irq, void *dev_id) 377static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,
378 unsigned int bank, u32 mask)
395{ 379{
396 struct bcm2835_gpio_irqdata *irqdata = dev_id;
397 struct bcm2835_pinctrl *pc = irqdata->pc;
398 int bank = irqdata->bank;
399 unsigned long events; 380 unsigned long events;
400 unsigned offset; 381 unsigned offset;
401 unsigned gpio; 382 unsigned gpio;
402 unsigned int type; 383 unsigned int type;
403 384
404 events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4); 385 events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4);
386 events &= mask;
405 events &= pc->enabled_irq_map[bank]; 387 events &= pc->enabled_irq_map[bank];
406 for_each_set_bit(offset, &events, 32) { 388 for_each_set_bit(offset, &events, 32) {
407 gpio = (32 * bank) + offset; 389 gpio = (32 * bank) + offset;
390 /* FIXME: no clue why the code looks up the type here */
408 type = pc->irq_type[gpio]; 391 type = pc->irq_type[gpio];
409 392
410 generic_handle_irq(irq_linear_revmap(pc->irq_domain, gpio)); 393 generic_handle_irq(irq_linear_revmap(pc->gpio_chip.irqdomain,
394 gpio));
411 } 395 }
412 return events ? IRQ_HANDLED : IRQ_NONE; 396}
397
398static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
399{
400 struct gpio_chip *chip = irq_desc_get_handler_data(desc);
401 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
402 struct irq_chip *host_chip = irq_desc_get_chip(desc);
403 int irq = irq_desc_get_irq(desc);
404 int group;
405 int i;
406
407 for (i = 0; i < ARRAY_SIZE(pc->irq); i++) {
408 if (pc->irq[i] == irq) {
409 group = pc->irq_group[i];
410 break;
411 }
412 }
413 /* This should not happen, every IRQ has a bank */
414 if (i == ARRAY_SIZE(pc->irq))
415 BUG();
416
417 chained_irq_enter(host_chip, desc);
418
419 switch (group) {
420 case 0: /* IRQ0 covers GPIOs 0-27 */
421 bcm2835_gpio_irq_handle_bank(pc, 0, 0x0fffffff);
422 break;
423 case 1: /* IRQ1 covers GPIOs 28-45 */
424 bcm2835_gpio_irq_handle_bank(pc, 0, 0xf0000000);
425 bcm2835_gpio_irq_handle_bank(pc, 1, 0x00003fff);
426 break;
427 case 2: /* IRQ2 covers GPIOs 46-53 */
428 bcm2835_gpio_irq_handle_bank(pc, 1, 0x003fc000);
429 break;
430 }
431
432 chained_irq_exit(host_chip, desc);
413} 433}
414 434
415static inline void __bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc, 435static inline void __bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc,
@@ -455,7 +475,8 @@ static void bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc,
455 475
456static void bcm2835_gpio_irq_enable(struct irq_data *data) 476static void bcm2835_gpio_irq_enable(struct irq_data *data)
457{ 477{
458 struct bcm2835_pinctrl *pc = irq_data_get_irq_chip_data(data); 478 struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
479 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
459 unsigned gpio = irqd_to_hwirq(data); 480 unsigned gpio = irqd_to_hwirq(data);
460 unsigned offset = GPIO_REG_SHIFT(gpio); 481 unsigned offset = GPIO_REG_SHIFT(gpio);
461 unsigned bank = GPIO_REG_OFFSET(gpio); 482 unsigned bank = GPIO_REG_OFFSET(gpio);
@@ -469,7 +490,8 @@ static void bcm2835_gpio_irq_enable(struct irq_data *data)
469 490
470static void bcm2835_gpio_irq_disable(struct irq_data *data) 491static void bcm2835_gpio_irq_disable(struct irq_data *data)
471{ 492{
472 struct bcm2835_pinctrl *pc = irq_data_get_irq_chip_data(data); 493 struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
494 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
473 unsigned gpio = irqd_to_hwirq(data); 495 unsigned gpio = irqd_to_hwirq(data);
474 unsigned offset = GPIO_REG_SHIFT(gpio); 496 unsigned offset = GPIO_REG_SHIFT(gpio);
475 unsigned bank = GPIO_REG_OFFSET(gpio); 497 unsigned bank = GPIO_REG_OFFSET(gpio);
@@ -575,7 +597,8 @@ static int __bcm2835_gpio_irq_set_type_enabled(struct bcm2835_pinctrl *pc,
575 597
576static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type) 598static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
577{ 599{
578 struct bcm2835_pinctrl *pc = irq_data_get_irq_chip_data(data); 600 struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
601 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
579 unsigned gpio = irqd_to_hwirq(data); 602 unsigned gpio = irqd_to_hwirq(data);
580 unsigned offset = GPIO_REG_SHIFT(gpio); 603 unsigned offset = GPIO_REG_SHIFT(gpio);
581 unsigned bank = GPIO_REG_OFFSET(gpio); 604 unsigned bank = GPIO_REG_OFFSET(gpio);
@@ -601,7 +624,8 @@ static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
601 624
602static void bcm2835_gpio_irq_ack(struct irq_data *data) 625static void bcm2835_gpio_irq_ack(struct irq_data *data)
603{ 626{
604 struct bcm2835_pinctrl *pc = irq_data_get_irq_chip_data(data); 627 struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
628 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
605 unsigned gpio = irqd_to_hwirq(data); 629 unsigned gpio = irqd_to_hwirq(data);
606 630
607 bcm2835_gpio_set_bit(pc, GPEDS0, gpio); 631 bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
@@ -644,10 +668,11 @@ static void bcm2835_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
644 unsigned offset) 668 unsigned offset)
645{ 669{
646 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 670 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
671 struct gpio_chip *chip = &pc->gpio_chip;
647 enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset); 672 enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
648 const char *fname = bcm2835_functions[fsel]; 673 const char *fname = bcm2835_functions[fsel];
649 int value = bcm2835_gpio_get_bit(pc, GPLEV0, offset); 674 int value = bcm2835_gpio_get_bit(pc, GPLEV0, offset);
650 int irq = irq_find_mapping(pc->irq_domain, offset); 675 int irq = irq_find_mapping(chip->irqdomain, offset);
651 676
652 seq_printf(s, "function %s in %s; irq %d (%s)", 677 seq_printf(s, "function %s in %s; irq %d (%s)",
653 fname, value ? "hi" : "lo", 678 fname, value ? "hi" : "lo",
@@ -821,6 +846,16 @@ static const struct pinctrl_ops bcm2835_pctl_ops = {
821 .dt_free_map = bcm2835_pctl_dt_free_map, 846 .dt_free_map = bcm2835_pctl_dt_free_map,
822}; 847};
823 848
849static int bcm2835_pmx_free(struct pinctrl_dev *pctldev,
850 unsigned offset)
851{
852 struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
853
854 /* disable by setting to GPIO_IN */
855 bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
856 return 0;
857}
858
824static int bcm2835_pmx_get_functions_count(struct pinctrl_dev *pctldev) 859static int bcm2835_pmx_get_functions_count(struct pinctrl_dev *pctldev)
825{ 860{
826 return BCM2835_FSEL_COUNT; 861 return BCM2835_FSEL_COUNT;
@@ -880,6 +915,7 @@ static int bcm2835_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
880} 915}
881 916
882static const struct pinmux_ops bcm2835_pmx_ops = { 917static const struct pinmux_ops bcm2835_pmx_ops = {
918 .free = bcm2835_pmx_free,
883 .get_functions_count = bcm2835_pmx_get_functions_count, 919 .get_functions_count = bcm2835_pmx_get_functions_count,
884 .get_function_name = bcm2835_pmx_get_function_name, 920 .get_function_name = bcm2835_pmx_get_function_name,
885 .get_function_groups = bcm2835_pmx_get_function_groups, 921 .get_function_groups = bcm2835_pmx_get_function_groups,
@@ -917,12 +953,14 @@ static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev,
917 953
918 bcm2835_gpio_wr(pc, GPPUD, arg & 3); 954 bcm2835_gpio_wr(pc, GPPUD, arg & 3);
919 /* 955 /*
920 * Docs say to wait 150 cycles, but not of what. We assume a 956 * BCM2835 datasheet say to wait 150 cycles, but not of what.
921 * 1 MHz clock here, which is pretty slow... 957 * But the VideoCore firmware delay for this operation
958 * based nearly on the same amount of VPU cycles and this clock
959 * runs at 250 MHz.
922 */ 960 */
923 udelay(150); 961 udelay(1);
924 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit)); 962 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit));
925 udelay(150); 963 udelay(1);
926 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0); 964 bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0);
927 } /* for each config */ 965 } /* for each config */
928 966
@@ -980,26 +1018,9 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
980 pc->gpio_chip.parent = dev; 1018 pc->gpio_chip.parent = dev;
981 pc->gpio_chip.of_node = np; 1019 pc->gpio_chip.of_node = np;
982 1020
983 pc->irq_domain = irq_domain_add_linear(np, BCM2835_NUM_GPIOS,
984 &irq_domain_simple_ops, NULL);
985 if (!pc->irq_domain) {
986 dev_err(dev, "could not create IRQ domain\n");
987 return -ENOMEM;
988 }
989
990 for (i = 0; i < BCM2835_NUM_GPIOS; i++) {
991 int irq = irq_create_mapping(pc->irq_domain, i);
992 irq_set_lockdep_class(irq, &gpio_lock_class);
993 irq_set_chip_and_handler(irq, &bcm2835_gpio_irq_chip,
994 handle_level_irq);
995 irq_set_chip_data(irq, pc);
996 }
997
998 for (i = 0; i < BCM2835_NUM_BANKS; i++) { 1021 for (i = 0; i < BCM2835_NUM_BANKS; i++) {
999 unsigned long events; 1022 unsigned long events;
1000 unsigned offset; 1023 unsigned offset;
1001 int len;
1002 char *name;
1003 1024
1004 /* clear event detection flags */ 1025 /* clear event detection flags */
1005 bcm2835_gpio_wr(pc, GPREN0 + i * 4, 0); 1026 bcm2835_gpio_wr(pc, GPREN0 + i * 4, 0);
@@ -1014,24 +1035,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
1014 for_each_set_bit(offset, &events, 32) 1035 for_each_set_bit(offset, &events, 32)
1015 bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset)); 1036 bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset));
1016 1037
1017 pc->irq[i] = irq_of_parse_and_map(np, i);
1018 pc->irq_data[i].pc = pc;
1019 pc->irq_data[i].bank = i;
1020 spin_lock_init(&pc->irq_lock[i]); 1038 spin_lock_init(&pc->irq_lock[i]);
1021
1022 len = strlen(dev_name(pc->dev)) + 16;
1023 name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
1024 if (!name)
1025 return -ENOMEM;
1026 snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i);
1027
1028 err = devm_request_irq(dev, pc->irq[i],
1029 bcm2835_gpio_irq_handler, IRQF_SHARED,
1030 name, &pc->irq_data[i]);
1031 if (err) {
1032 dev_err(dev, "unable to request IRQ %d\n", pc->irq[i]);
1033 return err;
1034 }
1035 } 1039 }
1036 1040
1037 err = gpiochip_add_data(&pc->gpio_chip, pc); 1041 err = gpiochip_add_data(&pc->gpio_chip, pc);
@@ -1040,6 +1044,29 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
1040 return err; 1044 return err;
1041 } 1045 }
1042 1046
1047 err = gpiochip_irqchip_add(&pc->gpio_chip, &bcm2835_gpio_irq_chip,
1048 0, handle_level_irq, IRQ_TYPE_NONE);
1049 if (err) {
1050 dev_info(dev, "could not add irqchip\n");
1051 return err;
1052 }
1053
1054 for (i = 0; i < BCM2835_NUM_IRQS; i++) {
1055 pc->irq[i] = irq_of_parse_and_map(np, i);
1056 pc->irq_group[i] = i;
1057 /*
1058 * Use the same handler for all groups: this is necessary
1059 * since we use one gpiochip to cover all lines - the
1060 * irq handler then needs to figure out which group and
1061 * bank that was firing the IRQ and look up the per-group
1062 * and bank data.
1063 */
1064 gpiochip_set_chained_irqchip(&pc->gpio_chip,
1065 &bcm2835_gpio_irq_chip,
1066 pc->irq[i],
1067 bcm2835_gpio_irq_handler);
1068 }
1069
1043 pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc); 1070 pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc);
1044 if (IS_ERR(pc->pctl_dev)) { 1071 if (IS_ERR(pc->pctl_dev)) {
1045 gpiochip_remove(&pc->gpio_chip); 1072 gpiochip_remove(&pc->gpio_chip);
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 54dad89fc9bf..260908480075 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -253,3 +253,147 @@ err:
253 pinctrl_dt_free_maps(p); 253 pinctrl_dt_free_maps(p);
254 return ret; 254 return ret;
255} 255}
256
257/*
258 * For pinctrl binding, typically #pinctrl-cells is for the pin controller
259 * device, so either parent or grandparent. See pinctrl-bindings.txt.
260 */
261static int pinctrl_find_cells_size(const struct device_node *np)
262{
263 const char *cells_name = "#pinctrl-cells";
264 int cells_size, error;
265
266 error = of_property_read_u32(np->parent, cells_name, &cells_size);
267 if (error) {
268 error = of_property_read_u32(np->parent->parent,
269 cells_name, &cells_size);
270 if (error)
271 return -ENOENT;
272 }
273
274 return cells_size;
275}
276
277/**
278 * pinctrl_get_list_and_count - Gets the list and it's cell size and number
279 * @np: pointer to device node with the property
280 * @list_name: property that contains the list
281 * @list: pointer for the list found
282 * @cells_size: pointer for the cell size found
283 * @nr_elements: pointer for the number of elements found
284 *
285 * Typically np is a single pinctrl entry containing the list.
286 */
287static int pinctrl_get_list_and_count(const struct device_node *np,
288 const char *list_name,
289 const __be32 **list,
290 int *cells_size,
291 int *nr_elements)
292{
293 int size;
294
295 *cells_size = 0;
296 *nr_elements = 0;
297
298 *list = of_get_property(np, list_name, &size);
299 if (!*list)
300 return -ENOENT;
301
302 *cells_size = pinctrl_find_cells_size(np);
303 if (*cells_size < 0)
304 return -ENOENT;
305
306 /* First element is always the index within the pinctrl device */
307 *nr_elements = (size / sizeof(**list)) / (*cells_size + 1);
308
309 return 0;
310}
311
312/**
313 * pinctrl_count_index_with_args - Count number of elements in a pinctrl entry
314 * @np: pointer to device node with the property
315 * @list_name: property that contains the list
316 *
317 * Counts the number of elements in a pinctrl array consisting of an index
318 * within the controller and a number of u32 entries specified for each
319 * entry. Note that device_node is always for the parent pin controller device.
320 */
321int pinctrl_count_index_with_args(const struct device_node *np,
322 const char *list_name)
323{
324 const __be32 *list;
325 int size, nr_cells, error;
326
327 error = pinctrl_get_list_and_count(np, list_name, &list,
328 &nr_cells, &size);
329 if (error)
330 return error;
331
332 return size;
333}
334EXPORT_SYMBOL_GPL(pinctrl_count_index_with_args);
335
336/**
337 * pinctrl_copy_args - Populates of_phandle_args based on index
338 * @np: pointer to device node with the property
339 * @list: pointer to a list with the elements
340 * @index: entry within the list of elements
341 * @nr_cells: number of cells in the list
342 * @nr_elem: number of elements for each entry in the list
343 * @out_args: returned values
344 *
345 * Populates the of_phandle_args based on the index in the list.
346 */
347static int pinctrl_copy_args(const struct device_node *np,
348 const __be32 *list,
349 int index, int nr_cells, int nr_elem,
350 struct of_phandle_args *out_args)
351{
352 int i;
353
354 memset(out_args, 0, sizeof(*out_args));
355 out_args->np = (struct device_node *)np;
356 out_args->args_count = nr_cells + 1;
357
358 if (index >= nr_elem)
359 return -EINVAL;
360
361 list += index * (nr_cells + 1);
362
363 for (i = 0; i < nr_cells + 1; i++)
364 out_args->args[i] = be32_to_cpup(list++);
365
366 return 0;
367}
368
369/**
370 * pinctrl_parse_index_with_args - Find a node pointed by index in a list
371 * @np: pointer to device node with the property
372 * @list_name: property that contains the list
373 * @index: index within the list
374 * @out_arts: entries in the list pointed by index
375 *
376 * Finds the selected element in a pinctrl array consisting of an index
377 * within the controller and a number of u32 entries specified for each
378 * entry. Note that device_node is always for the parent pin controller device.
379 */
380int pinctrl_parse_index_with_args(const struct device_node *np,
381 const char *list_name, int index,
382 struct of_phandle_args *out_args)
383{
384 const __be32 *list;
385 int nr_elem, nr_cells, error;
386
387 error = pinctrl_get_list_and_count(np, list_name, &list,
388 &nr_cells, &nr_elem);
389 if (error || !nr_cells)
390 return error;
391
392 error = pinctrl_copy_args(np, list, index, nr_cells, nr_elem,
393 out_args);
394 if (error)
395 return error;
396
397 return 0;
398}
399EXPORT_SYMBOL_GPL(pinctrl_parse_index_with_args);
diff --git a/drivers/pinctrl/devicetree.h b/drivers/pinctrl/devicetree.h
index 760bc4960f58..c2d1a5505850 100644
--- a/drivers/pinctrl/devicetree.h
+++ b/drivers/pinctrl/devicetree.h
@@ -16,11 +16,20 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19struct of_phandle_args;
20
19#ifdef CONFIG_OF 21#ifdef CONFIG_OF
20 22
21void pinctrl_dt_free_maps(struct pinctrl *p); 23void pinctrl_dt_free_maps(struct pinctrl *p);
22int pinctrl_dt_to_map(struct pinctrl *p); 24int pinctrl_dt_to_map(struct pinctrl *p);
23 25
26int pinctrl_count_index_with_args(const struct device_node *np,
27 const char *list_name);
28
29int pinctrl_parse_index_with_args(const struct device_node *np,
30 const char *list_name, int index,
31 struct of_phandle_args *out_args);
32
24#else 33#else
25 34
26static inline int pinctrl_dt_to_map(struct pinctrl *p) 35static inline int pinctrl_dt_to_map(struct pinctrl *p)
@@ -32,4 +41,18 @@ static inline void pinctrl_dt_free_maps(struct pinctrl *p)
32{ 41{
33} 42}
34 43
44static inline int pinctrl_count_index_with_args(const struct device_node *np,
45 const char *list_name)
46{
47 return -ENODEV;
48}
49
50static inline int
51pinctrl_parse_index_with_args(const struct device_node *np,
52 const char *list_name, int index,
53 struct of_phandle_args *out_args)
54{
55 return -ENODEV;
56}
57
35#endif 58#endif
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 79c4e14a5a75..5ef7e875b50e 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -778,10 +778,10 @@ int imx_pinctrl_probe(struct platform_device *pdev,
778 imx_pinctrl_desc->name = dev_name(&pdev->dev); 778 imx_pinctrl_desc->name = dev_name(&pdev->dev);
779 imx_pinctrl_desc->pins = info->pins; 779 imx_pinctrl_desc->pins = info->pins;
780 imx_pinctrl_desc->npins = info->npins; 780 imx_pinctrl_desc->npins = info->npins;
781 imx_pinctrl_desc->pctlops = &imx_pctrl_ops, 781 imx_pinctrl_desc->pctlops = &imx_pctrl_ops;
782 imx_pinctrl_desc->pmxops = &imx_pmx_ops, 782 imx_pinctrl_desc->pmxops = &imx_pmx_ops;
783 imx_pinctrl_desc->confops = &imx_pinconf_ops, 783 imx_pinctrl_desc->confops = &imx_pinconf_ops;
784 imx_pinctrl_desc->owner = THIS_MODULE, 784 imx_pinctrl_desc->owner = THIS_MODULE;
785 785
786 ret = imx_pinctrl_probe_dt(pdev, info); 786 ret = imx_pinctrl_probe_dt(pdev, info);
787 if (ret) { 787 if (ret) {
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 71bbeb9321ba..37300634b7d2 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1703,7 +1703,7 @@ static int byt_gpio_probe(struct byt_gpio *vg)
1703 if (irq_rc && irq_rc->start) { 1703 if (irq_rc && irq_rc->start) {
1704 byt_gpio_irq_init_hw(vg); 1704 byt_gpio_irq_init_hw(vg);
1705 ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0, 1705 ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0,
1706 handle_simple_irq, IRQ_TYPE_NONE); 1706 handle_bad_irq, IRQ_TYPE_NONE);
1707 if (ret) { 1707 if (ret) {
1708 dev_err(&vg->pdev->dev, "failed to add irqchip\n"); 1708 dev_err(&vg->pdev->dev, "failed to add irqchip\n");
1709 goto fail; 1709 goto fail;
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index c43b1e9a06af..5e66860a5e67 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -762,7 +762,7 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
762 seq_printf(s, "mode %d ", mode); 762 seq_printf(s, "mode %d ", mode);
763 } 763 }
764 764
765 seq_printf(s, "ctrl0 0x%08x ctrl1 0x%08x", ctrl0, ctrl1); 765 seq_printf(s, "0x%08x 0x%08x", ctrl0, ctrl1);
766 766
767 if (locked) 767 if (locked)
768 seq_puts(s, " [LOCKED]"); 768 seq_puts(s, " [LOCKED]");
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 01443762e570..1e139672f1af 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -911,7 +911,7 @@ static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq)
911 } 911 }
912 912
913 ret = gpiochip_irqchip_add(&pctrl->chip, &intel_gpio_irqchip, 0, 913 ret = gpiochip_irqchip_add(&pctrl->chip, &intel_gpio_irqchip, 0,
914 handle_simple_irq, IRQ_TYPE_NONE); 914 handle_bad_irq, IRQ_TYPE_NONE);
915 if (ret) { 915 if (ret) {
916 dev_err(pctrl->dev, "failed to add irqchip\n"); 916 dev_err(pctrl->dev, "failed to add irqchip\n");
917 goto fail; 917 goto fail;
diff --git a/drivers/pinctrl/intel/pinctrl-merrifield.c b/drivers/pinctrl/intel/pinctrl-merrifield.c
index 7826c7f0cb7c..b21896126f76 100644
--- a/drivers/pinctrl/intel/pinctrl-merrifield.c
+++ b/drivers/pinctrl/intel/pinctrl-merrifield.c
@@ -814,10 +814,51 @@ static int mrfld_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
814 return 0; 814 return 0;
815} 815}
816 816
817static int mrfld_config_group_get(struct pinctrl_dev *pctldev,
818 unsigned int group, unsigned long *config)
819{
820 const unsigned int *pins;
821 unsigned int npins;
822 int ret;
823
824 ret = mrfld_get_group_pins(pctldev, group, &pins, &npins);
825 if (ret)
826 return ret;
827
828 ret = mrfld_config_get(pctldev, pins[0], config);
829 if (ret)
830 return ret;
831
832 return 0;
833}
834
835static int mrfld_config_group_set(struct pinctrl_dev *pctldev,
836 unsigned int group, unsigned long *configs,
837 unsigned int num_configs)
838{
839 const unsigned int *pins;
840 unsigned int npins;
841 int i, ret;
842
843 ret = mrfld_get_group_pins(pctldev, group, &pins, &npins);
844 if (ret)
845 return ret;
846
847 for (i = 0; i < npins; i++) {
848 ret = mrfld_config_set(pctldev, pins[i], configs, num_configs);
849 if (ret)
850 return ret;
851 }
852
853 return 0;
854}
855
817static const struct pinconf_ops mrfld_pinconf_ops = { 856static const struct pinconf_ops mrfld_pinconf_ops = {
818 .is_generic = true, 857 .is_generic = true,
819 .pin_config_get = mrfld_config_get, 858 .pin_config_get = mrfld_config_get,
820 .pin_config_set = mrfld_config_set, 859 .pin_config_set = mrfld_config_set,
860 .pin_config_group_get = mrfld_config_group_get,
861 .pin_config_group_set = mrfld_config_group_set,
821}; 862};
822 863
823static const struct pinctrl_desc mrfld_pinctrl_desc = { 864static const struct pinctrl_desc mrfld_pinctrl_desc = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6397.c b/drivers/pinctrl/mediatek/pinctrl-mt6397.c
index 6eccb85c02cd..afcede7e2222 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt6397.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt6397.c
@@ -64,8 +64,4 @@ static struct platform_driver mtk_pinctrl_driver = {
64 }, 64 },
65}; 65};
66 66
67static int __init mtk_pinctrl_init(void) 67builtin_platform_driver(mtk_pinctrl_driver);
68{
69 return platform_driver_register(&mtk_pinctrl_driver);
70}
71device_initcall(mtk_pinctrl_init);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8173.h b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8173.h
index 13e5b68bfe1b..9b018fdbeb51 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8173.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8173.h
@@ -201,7 +201,7 @@ static const struct mtk_desc_pin mtk_pins_mt8173[] = {
201 MTK_PIN( 201 MTK_PIN(
202 PINCTRL_PIN(16, "IDDIG"), 202 PINCTRL_PIN(16, "IDDIG"),
203 NULL, "mt8173", 203 NULL, "mt8173",
204 MTK_EINT_FUNCTION(0, 16), 204 MTK_EINT_FUNCTION(1, 16),
205 MTK_FUNCTION(0, "GPIO16"), 205 MTK_FUNCTION(0, "GPIO16"),
206 MTK_FUNCTION(1, "IDDIG"), 206 MTK_FUNCTION(1, "IDDIG"),
207 MTK_FUNCTION(2, "CMFLASH"), 207 MTK_FUNCTION(2, "CMFLASH"),
diff --git a/drivers/pinctrl/meson/Makefile b/drivers/pinctrl/meson/Makefile
index 24434f139947..27c5b5126008 100644
--- a/drivers/pinctrl/meson/Makefile
+++ b/drivers/pinctrl/meson/Makefile
@@ -1,2 +1,3 @@
1obj-y += pinctrl-meson8.o pinctrl-meson8b.o pinctrl-meson-gxbb.o 1obj-y += pinctrl-meson8.o pinctrl-meson8b.o
2obj-y += pinctrl-meson-gxbb.o pinctrl-meson-gxl.o
2obj-y += pinctrl-meson.o 3obj-y += pinctrl-meson.o
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
new file mode 100644
index 000000000000..25694f7094c7
--- /dev/null
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
@@ -0,0 +1,589 @@
1/*
2 * Pin controller and GPIO driver for Amlogic Meson GXL.
3 *
4 * Copyright (C) 2016 Endless Mobile, Inc.
5 * Author: Carlo Caione <carlo@endlessm.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14
15#include <dt-bindings/gpio/meson-gxl-gpio.h>
16#include "pinctrl-meson.h"
17
18#define EE_OFF 10
19
20static const struct pinctrl_pin_desc meson_gxl_periphs_pins[] = {
21 MESON_PIN(GPIOZ_0, EE_OFF),
22 MESON_PIN(GPIOZ_1, EE_OFF),
23 MESON_PIN(GPIOZ_2, EE_OFF),
24 MESON_PIN(GPIOZ_3, EE_OFF),
25 MESON_PIN(GPIOZ_4, EE_OFF),
26 MESON_PIN(GPIOZ_5, EE_OFF),
27 MESON_PIN(GPIOZ_6, EE_OFF),
28 MESON_PIN(GPIOZ_7, EE_OFF),
29 MESON_PIN(GPIOZ_8, EE_OFF),
30 MESON_PIN(GPIOZ_9, EE_OFF),
31 MESON_PIN(GPIOZ_10, EE_OFF),
32 MESON_PIN(GPIOZ_11, EE_OFF),
33 MESON_PIN(GPIOZ_12, EE_OFF),
34 MESON_PIN(GPIOZ_13, EE_OFF),
35 MESON_PIN(GPIOZ_14, EE_OFF),
36 MESON_PIN(GPIOZ_15, EE_OFF),
37
38 MESON_PIN(GPIOH_0, EE_OFF),
39 MESON_PIN(GPIOH_1, EE_OFF),
40 MESON_PIN(GPIOH_2, EE_OFF),
41 MESON_PIN(GPIOH_3, EE_OFF),
42 MESON_PIN(GPIOH_4, EE_OFF),
43 MESON_PIN(GPIOH_5, EE_OFF),
44 MESON_PIN(GPIOH_6, EE_OFF),
45 MESON_PIN(GPIOH_7, EE_OFF),
46 MESON_PIN(GPIOH_8, EE_OFF),
47 MESON_PIN(GPIOH_9, EE_OFF),
48
49 MESON_PIN(BOOT_0, EE_OFF),
50 MESON_PIN(BOOT_1, EE_OFF),
51 MESON_PIN(BOOT_2, EE_OFF),
52 MESON_PIN(BOOT_3, EE_OFF),
53 MESON_PIN(BOOT_4, EE_OFF),
54 MESON_PIN(BOOT_5, EE_OFF),
55 MESON_PIN(BOOT_6, EE_OFF),
56 MESON_PIN(BOOT_7, EE_OFF),
57 MESON_PIN(BOOT_8, EE_OFF),
58 MESON_PIN(BOOT_9, EE_OFF),
59 MESON_PIN(BOOT_10, EE_OFF),
60 MESON_PIN(BOOT_11, EE_OFF),
61 MESON_PIN(BOOT_12, EE_OFF),
62 MESON_PIN(BOOT_13, EE_OFF),
63 MESON_PIN(BOOT_14, EE_OFF),
64 MESON_PIN(BOOT_15, EE_OFF),
65
66 MESON_PIN(CARD_0, EE_OFF),
67 MESON_PIN(CARD_1, EE_OFF),
68 MESON_PIN(CARD_2, EE_OFF),
69 MESON_PIN(CARD_3, EE_OFF),
70 MESON_PIN(CARD_4, EE_OFF),
71 MESON_PIN(CARD_5, EE_OFF),
72 MESON_PIN(CARD_6, EE_OFF),
73
74 MESON_PIN(GPIODV_0, EE_OFF),
75 MESON_PIN(GPIODV_1, EE_OFF),
76 MESON_PIN(GPIODV_2, EE_OFF),
77 MESON_PIN(GPIODV_3, EE_OFF),
78 MESON_PIN(GPIODV_4, EE_OFF),
79 MESON_PIN(GPIODV_5, EE_OFF),
80 MESON_PIN(GPIODV_6, EE_OFF),
81 MESON_PIN(GPIODV_7, EE_OFF),
82 MESON_PIN(GPIODV_8, EE_OFF),
83 MESON_PIN(GPIODV_9, EE_OFF),
84 MESON_PIN(GPIODV_10, EE_OFF),
85 MESON_PIN(GPIODV_11, EE_OFF),
86 MESON_PIN(GPIODV_12, EE_OFF),
87 MESON_PIN(GPIODV_13, EE_OFF),
88 MESON_PIN(GPIODV_14, EE_OFF),
89 MESON_PIN(GPIODV_15, EE_OFF),
90 MESON_PIN(GPIODV_16, EE_OFF),
91 MESON_PIN(GPIODV_17, EE_OFF),
92 MESON_PIN(GPIODV_19, EE_OFF),
93 MESON_PIN(GPIODV_20, EE_OFF),
94 MESON_PIN(GPIODV_21, EE_OFF),
95 MESON_PIN(GPIODV_22, EE_OFF),
96 MESON_PIN(GPIODV_23, EE_OFF),
97 MESON_PIN(GPIODV_24, EE_OFF),
98 MESON_PIN(GPIODV_25, EE_OFF),
99 MESON_PIN(GPIODV_26, EE_OFF),
100 MESON_PIN(GPIODV_27, EE_OFF),
101 MESON_PIN(GPIODV_28, EE_OFF),
102 MESON_PIN(GPIODV_29, EE_OFF),
103
104 MESON_PIN(GPIOX_0, EE_OFF),
105 MESON_PIN(GPIOX_1, EE_OFF),
106 MESON_PIN(GPIOX_2, EE_OFF),
107 MESON_PIN(GPIOX_3, EE_OFF),
108 MESON_PIN(GPIOX_4, EE_OFF),
109 MESON_PIN(GPIOX_5, EE_OFF),
110 MESON_PIN(GPIOX_6, EE_OFF),
111 MESON_PIN(GPIOX_7, EE_OFF),
112 MESON_PIN(GPIOX_8, EE_OFF),
113 MESON_PIN(GPIOX_9, EE_OFF),
114 MESON_PIN(GPIOX_10, EE_OFF),
115 MESON_PIN(GPIOX_11, EE_OFF),
116 MESON_PIN(GPIOX_12, EE_OFF),
117 MESON_PIN(GPIOX_13, EE_OFF),
118 MESON_PIN(GPIOX_14, EE_OFF),
119 MESON_PIN(GPIOX_15, EE_OFF),
120 MESON_PIN(GPIOX_16, EE_OFF),
121 MESON_PIN(GPIOX_17, EE_OFF),
122 MESON_PIN(GPIOX_18, EE_OFF),
123
124 MESON_PIN(GPIOCLK_0, EE_OFF),
125 MESON_PIN(GPIOCLK_1, EE_OFF),
126
127 MESON_PIN(GPIO_TEST_N, EE_OFF),
128};
129
130static const unsigned int emmc_nand_d07_pins[] = {
131 PIN(BOOT_0, EE_OFF), PIN(BOOT_1, EE_OFF), PIN(BOOT_2, EE_OFF),
132 PIN(BOOT_3, EE_OFF), PIN(BOOT_4, EE_OFF), PIN(BOOT_5, EE_OFF),
133 PIN(BOOT_6, EE_OFF), PIN(BOOT_7, EE_OFF),
134};
135static const unsigned int emmc_clk_pins[] = { PIN(BOOT_8, EE_OFF) };
136static const unsigned int emmc_cmd_pins[] = { PIN(BOOT_10, EE_OFF) };
137static const unsigned int emmc_ds_pins[] = { PIN(BOOT_15, EE_OFF) };
138
139static const unsigned int sdcard_d0_pins[] = { PIN(CARD_1, EE_OFF) };
140static const unsigned int sdcard_d1_pins[] = { PIN(CARD_0, EE_OFF) };
141static const unsigned int sdcard_d2_pins[] = { PIN(CARD_5, EE_OFF) };
142static const unsigned int sdcard_d3_pins[] = { PIN(CARD_4, EE_OFF) };
143static const unsigned int sdcard_cmd_pins[] = { PIN(CARD_3, EE_OFF) };
144static const unsigned int sdcard_clk_pins[] = { PIN(CARD_2, EE_OFF) };
145
146static const unsigned int sdio_d0_pins[] = { PIN(GPIOX_0, EE_OFF) };
147static const unsigned int sdio_d1_pins[] = { PIN(GPIOX_1, EE_OFF) };
148static const unsigned int sdio_d2_pins[] = { PIN(GPIOX_2, EE_OFF) };
149static const unsigned int sdio_d3_pins[] = { PIN(GPIOX_3, EE_OFF) };
150static const unsigned int sdio_cmd_pins[] = { PIN(GPIOX_4, EE_OFF) };
151static const unsigned int sdio_clk_pins[] = { PIN(GPIOX_5, EE_OFF) };
152static const unsigned int sdio_irq_pins[] = { PIN(GPIOX_7, EE_OFF) };
153
154static const unsigned int nand_ce0_pins[] = { PIN(BOOT_8, EE_OFF) };
155static const unsigned int nand_ce1_pins[] = { PIN(BOOT_9, EE_OFF) };
156static const unsigned int nand_rb0_pins[] = { PIN(BOOT_10, EE_OFF) };
157static const unsigned int nand_ale_pins[] = { PIN(BOOT_11, EE_OFF) };
158static const unsigned int nand_cle_pins[] = { PIN(BOOT_12, EE_OFF) };
159static const unsigned int nand_wen_clk_pins[] = { PIN(BOOT_13, EE_OFF) };
160static const unsigned int nand_ren_wr_pins[] = { PIN(BOOT_14, EE_OFF) };
161static const unsigned int nand_dqs_pins[] = { PIN(BOOT_15, EE_OFF) };
162
163static const unsigned int uart_tx_a_pins[] = { PIN(GPIOX_12, EE_OFF) };
164static const unsigned int uart_rx_a_pins[] = { PIN(GPIOX_13, EE_OFF) };
165static const unsigned int uart_cts_a_pins[] = { PIN(GPIOX_14, EE_OFF) };
166static const unsigned int uart_rts_a_pins[] = { PIN(GPIOX_15, EE_OFF) };
167
168static const unsigned int uart_tx_b_pins[] = { PIN(GPIODV_24, EE_OFF) };
169static const unsigned int uart_rx_b_pins[] = { PIN(GPIODV_25, EE_OFF) };
170
171static const unsigned int uart_tx_c_pins[] = { PIN(GPIOX_8, EE_OFF) };
172static const unsigned int uart_rx_c_pins[] = { PIN(GPIOX_9, EE_OFF) };
173
174static const unsigned int i2c_sck_a_pins[] = { PIN(GPIODV_25, EE_OFF) };
175static const unsigned int i2c_sda_a_pins[] = { PIN(GPIODV_24, EE_OFF) };
176
177static const unsigned int i2c_sck_b_pins[] = { PIN(GPIODV_27, EE_OFF) };
178static const unsigned int i2c_sda_b_pins[] = { PIN(GPIODV_26, EE_OFF) };
179
180static const unsigned int i2c_sck_c_pins[] = { PIN(GPIODV_29, EE_OFF) };
181static const unsigned int i2c_sda_c_pins[] = { PIN(GPIODV_28, EE_OFF) };
182
183static const unsigned int eth_mdio_pins[] = { PIN(GPIOZ_0, EE_OFF) };
184static const unsigned int eth_mdc_pins[] = { PIN(GPIOZ_1, EE_OFF) };
185static const unsigned int eth_clk_rx_clk_pins[] = { PIN(GPIOZ_2, EE_OFF) };
186static const unsigned int eth_rx_dv_pins[] = { PIN(GPIOZ_3, EE_OFF) };
187static const unsigned int eth_rxd0_pins[] = { PIN(GPIOZ_4, EE_OFF) };
188static const unsigned int eth_rxd1_pins[] = { PIN(GPIOZ_5, EE_OFF) };
189static const unsigned int eth_rxd2_pins[] = { PIN(GPIOZ_6, EE_OFF) };
190static const unsigned int eth_rxd3_pins[] = { PIN(GPIOZ_7, EE_OFF) };
191static const unsigned int eth_rgmii_tx_clk_pins[] = { PIN(GPIOZ_8, EE_OFF) };
192static const unsigned int eth_tx_en_pins[] = { PIN(GPIOZ_9, EE_OFF) };
193static const unsigned int eth_txd0_pins[] = { PIN(GPIOZ_10, EE_OFF) };
194static const unsigned int eth_txd1_pins[] = { PIN(GPIOZ_11, EE_OFF) };
195static const unsigned int eth_txd2_pins[] = { PIN(GPIOZ_12, EE_OFF) };
196static const unsigned int eth_txd3_pins[] = { PIN(GPIOZ_13, EE_OFF) };
197
198static const unsigned int pwm_e_pins[] = { PIN(GPIOX_16, EE_OFF) };
199
200static const struct pinctrl_pin_desc meson_gxl_aobus_pins[] = {
201 MESON_PIN(GPIOAO_0, 0),
202 MESON_PIN(GPIOAO_1, 0),
203 MESON_PIN(GPIOAO_2, 0),
204 MESON_PIN(GPIOAO_3, 0),
205 MESON_PIN(GPIOAO_4, 0),
206 MESON_PIN(GPIOAO_5, 0),
207 MESON_PIN(GPIOAO_6, 0),
208 MESON_PIN(GPIOAO_7, 0),
209 MESON_PIN(GPIOAO_8, 0),
210 MESON_PIN(GPIOAO_9, 0),
211};
212
213static const unsigned int uart_tx_ao_a_pins[] = { PIN(GPIOAO_0, 0) };
214static const unsigned int uart_rx_ao_a_pins[] = { PIN(GPIOAO_1, 0) };
215static const unsigned int uart_cts_ao_a_pins[] = { PIN(GPIOAO_2, 0) };
216static const unsigned int uart_rts_ao_a_pins[] = { PIN(GPIOAO_3, 0) };
217static const unsigned int uart_tx_ao_b_pins[] = { PIN(GPIOAO_0, 0) };
218static const unsigned int uart_rx_ao_b_pins[] = { PIN(GPIOAO_1, 0),
219 PIN(GPIOAO_5, 0) };
220static const unsigned int uart_cts_ao_b_pins[] = { PIN(GPIOAO_2, 0) };
221static const unsigned int uart_rts_ao_b_pins[] = { PIN(GPIOAO_3, 0) };
222
223static const unsigned int remote_input_ao_pins[] = {PIN(GPIOAO_7, 0) };
224
225static struct meson_pmx_group meson_gxl_periphs_groups[] = {
226 GPIO_GROUP(GPIOZ_0, EE_OFF),
227 GPIO_GROUP(GPIOZ_1, EE_OFF),
228 GPIO_GROUP(GPIOZ_2, EE_OFF),
229 GPIO_GROUP(GPIOZ_3, EE_OFF),
230 GPIO_GROUP(GPIOZ_4, EE_OFF),
231 GPIO_GROUP(GPIOZ_5, EE_OFF),
232 GPIO_GROUP(GPIOZ_6, EE_OFF),
233 GPIO_GROUP(GPIOZ_7, EE_OFF),
234 GPIO_GROUP(GPIOZ_8, EE_OFF),
235 GPIO_GROUP(GPIOZ_9, EE_OFF),
236 GPIO_GROUP(GPIOZ_10, EE_OFF),
237 GPIO_GROUP(GPIOZ_11, EE_OFF),
238 GPIO_GROUP(GPIOZ_12, EE_OFF),
239 GPIO_GROUP(GPIOZ_13, EE_OFF),
240 GPIO_GROUP(GPIOZ_14, EE_OFF),
241 GPIO_GROUP(GPIOZ_15, EE_OFF),
242
243 GPIO_GROUP(GPIOH_0, EE_OFF),
244 GPIO_GROUP(GPIOH_1, EE_OFF),
245 GPIO_GROUP(GPIOH_2, EE_OFF),
246 GPIO_GROUP(GPIOH_3, EE_OFF),
247 GPIO_GROUP(GPIOH_4, EE_OFF),
248 GPIO_GROUP(GPIOH_5, EE_OFF),
249 GPIO_GROUP(GPIOH_6, EE_OFF),
250 GPIO_GROUP(GPIOH_7, EE_OFF),
251 GPIO_GROUP(GPIOH_8, EE_OFF),
252 GPIO_GROUP(GPIOH_9, EE_OFF),
253
254 GPIO_GROUP(BOOT_0, EE_OFF),
255 GPIO_GROUP(BOOT_1, EE_OFF),
256 GPIO_GROUP(BOOT_2, EE_OFF),
257 GPIO_GROUP(BOOT_3, EE_OFF),
258 GPIO_GROUP(BOOT_4, EE_OFF),
259 GPIO_GROUP(BOOT_5, EE_OFF),
260 GPIO_GROUP(BOOT_6, EE_OFF),
261 GPIO_GROUP(BOOT_7, EE_OFF),
262 GPIO_GROUP(BOOT_8, EE_OFF),
263 GPIO_GROUP(BOOT_9, EE_OFF),
264 GPIO_GROUP(BOOT_10, EE_OFF),
265 GPIO_GROUP(BOOT_11, EE_OFF),
266 GPIO_GROUP(BOOT_12, EE_OFF),
267 GPIO_GROUP(BOOT_13, EE_OFF),
268 GPIO_GROUP(BOOT_14, EE_OFF),
269 GPIO_GROUP(BOOT_15, EE_OFF),
270
271 GPIO_GROUP(CARD_0, EE_OFF),
272 GPIO_GROUP(CARD_1, EE_OFF),
273 GPIO_GROUP(CARD_2, EE_OFF),
274 GPIO_GROUP(CARD_3, EE_OFF),
275 GPIO_GROUP(CARD_4, EE_OFF),
276 GPIO_GROUP(CARD_5, EE_OFF),
277 GPIO_GROUP(CARD_6, EE_OFF),
278
279 GPIO_GROUP(GPIODV_0, EE_OFF),
280 GPIO_GROUP(GPIODV_1, EE_OFF),
281 GPIO_GROUP(GPIODV_2, EE_OFF),
282 GPIO_GROUP(GPIODV_3, EE_OFF),
283 GPIO_GROUP(GPIODV_4, EE_OFF),
284 GPIO_GROUP(GPIODV_5, EE_OFF),
285 GPIO_GROUP(GPIODV_6, EE_OFF),
286 GPIO_GROUP(GPIODV_7, EE_OFF),
287 GPIO_GROUP(GPIODV_8, EE_OFF),
288 GPIO_GROUP(GPIODV_9, EE_OFF),
289 GPIO_GROUP(GPIODV_10, EE_OFF),
290 GPIO_GROUP(GPIODV_11, EE_OFF),
291 GPIO_GROUP(GPIODV_12, EE_OFF),
292 GPIO_GROUP(GPIODV_13, EE_OFF),
293 GPIO_GROUP(GPIODV_14, EE_OFF),
294 GPIO_GROUP(GPIODV_15, EE_OFF),
295 GPIO_GROUP(GPIODV_16, EE_OFF),
296 GPIO_GROUP(GPIODV_17, EE_OFF),
297 GPIO_GROUP(GPIODV_19, EE_OFF),
298 GPIO_GROUP(GPIODV_20, EE_OFF),
299 GPIO_GROUP(GPIODV_21, EE_OFF),
300 GPIO_GROUP(GPIODV_22, EE_OFF),
301 GPIO_GROUP(GPIODV_23, EE_OFF),
302 GPIO_GROUP(GPIODV_24, EE_OFF),
303 GPIO_GROUP(GPIODV_25, EE_OFF),
304 GPIO_GROUP(GPIODV_26, EE_OFF),
305 GPIO_GROUP(GPIODV_27, EE_OFF),
306 GPIO_GROUP(GPIODV_28, EE_OFF),
307 GPIO_GROUP(GPIODV_29, EE_OFF),
308
309 GPIO_GROUP(GPIOX_0, EE_OFF),
310 GPIO_GROUP(GPIOX_1, EE_OFF),
311 GPIO_GROUP(GPIOX_2, EE_OFF),
312 GPIO_GROUP(GPIOX_3, EE_OFF),
313 GPIO_GROUP(GPIOX_4, EE_OFF),
314 GPIO_GROUP(GPIOX_5, EE_OFF),
315 GPIO_GROUP(GPIOX_6, EE_OFF),
316 GPIO_GROUP(GPIOX_7, EE_OFF),
317 GPIO_GROUP(GPIOX_8, EE_OFF),
318 GPIO_GROUP(GPIOX_9, EE_OFF),
319 GPIO_GROUP(GPIOX_10, EE_OFF),
320 GPIO_GROUP(GPIOX_11, EE_OFF),
321 GPIO_GROUP(GPIOX_12, EE_OFF),
322 GPIO_GROUP(GPIOX_13, EE_OFF),
323 GPIO_GROUP(GPIOX_14, EE_OFF),
324 GPIO_GROUP(GPIOX_15, EE_OFF),
325 GPIO_GROUP(GPIOX_16, EE_OFF),
326 GPIO_GROUP(GPIOX_17, EE_OFF),
327 GPIO_GROUP(GPIOX_18, EE_OFF),
328
329 GPIO_GROUP(GPIOCLK_0, EE_OFF),
330 GPIO_GROUP(GPIOCLK_1, EE_OFF),
331
332 GPIO_GROUP(GPIO_TEST_N, EE_OFF),
333
334 /* Bank X */
335 GROUP(sdio_d0, 5, 31),
336 GROUP(sdio_d1, 5, 30),
337 GROUP(sdio_d2, 5, 29),
338 GROUP(sdio_d3, 5, 28),
339 GROUP(sdio_cmd, 5, 27),
340 GROUP(sdio_clk, 5, 26),
341 GROUP(sdio_irq, 5, 24),
342 GROUP(uart_tx_a, 5, 19),
343 GROUP(uart_rx_a, 5, 18),
344 GROUP(uart_cts_a, 5, 17),
345 GROUP(uart_rts_a, 5, 16),
346 GROUP(uart_tx_c, 5, 13),
347 GROUP(uart_rx_c, 5, 12),
348 GROUP(pwm_e, 5, 15),
349
350 /* Bank Z */
351 GROUP(eth_mdio, 4, 22),
352 GROUP(eth_mdc, 4, 23),
353 GROUP(eth_clk_rx_clk, 4, 21),
354 GROUP(eth_rx_dv, 4, 20),
355 GROUP(eth_rxd0, 4, 19),
356 GROUP(eth_rxd1, 4, 18),
357 GROUP(eth_rxd2, 4, 17),
358 GROUP(eth_rxd3, 4, 16),
359 GROUP(eth_rgmii_tx_clk, 4, 15),
360 GROUP(eth_tx_en, 4, 14),
361 GROUP(eth_txd0, 4, 13),
362 GROUP(eth_txd1, 4, 12),
363 GROUP(eth_txd2, 4, 11),
364 GROUP(eth_txd3, 4, 10),
365
366 /* Bank DV */
367 GROUP(uart_tx_b, 2, 16),
368 GROUP(uart_rx_b, 2, 15),
369 GROUP(i2c_sck_a, 1, 15),
370 GROUP(i2c_sda_a, 1, 14),
371 GROUP(i2c_sck_b, 1, 13),
372 GROUP(i2c_sda_b, 1, 12),
373 GROUP(i2c_sck_c, 1, 11),
374 GROUP(i2c_sda_c, 1, 10),
375
376 /* Bank BOOT */
377 GROUP(emmc_nand_d07, 7, 31),
378 GROUP(emmc_clk, 7, 30),
379 GROUP(emmc_cmd, 7, 29),
380 GROUP(emmc_ds, 7, 28),
381 GROUP(nand_ce0, 7, 7),
382 GROUP(nand_ce1, 7, 6),
383 GROUP(nand_rb0, 7, 5),
384 GROUP(nand_ale, 7, 4),
385 GROUP(nand_cle, 7, 3),
386 GROUP(nand_wen_clk, 7, 2),
387 GROUP(nand_ren_wr, 7, 1),
388 GROUP(nand_dqs, 7, 0),
389
390 /* Bank CARD */
391 GROUP(sdcard_d1, 6, 5),
392 GROUP(sdcard_d0, 6, 4),
393 GROUP(sdcard_d3, 6, 1),
394 GROUP(sdcard_d2, 6, 0),
395 GROUP(sdcard_cmd, 6, 2),
396 GROUP(sdcard_clk, 6, 3),
397};
398
399static struct meson_pmx_group meson_gxl_aobus_groups[] = {
400 GPIO_GROUP(GPIOAO_0, 0),
401 GPIO_GROUP(GPIOAO_1, 0),
402 GPIO_GROUP(GPIOAO_2, 0),
403 GPIO_GROUP(GPIOAO_3, 0),
404 GPIO_GROUP(GPIOAO_4, 0),
405 GPIO_GROUP(GPIOAO_5, 0),
406 GPIO_GROUP(GPIOAO_6, 0),
407 GPIO_GROUP(GPIOAO_7, 0),
408 GPIO_GROUP(GPIOAO_8, 0),
409 GPIO_GROUP(GPIOAO_9, 0),
410
411 /* bank AO */
412 GROUP(uart_tx_ao_b, 0, 26),
413 GROUP(uart_rx_ao_b, 0, 25),
414 GROUP(uart_tx_ao_a, 0, 12),
415 GROUP(uart_rx_ao_a, 0, 11),
416 GROUP(uart_cts_ao_a, 0, 10),
417 GROUP(uart_rts_ao_a, 0, 9),
418 GROUP(uart_cts_ao_b, 0, 8),
419 GROUP(uart_rts_ao_b, 0, 7),
420 GROUP(remote_input_ao, 0, 0),
421};
422
423static const char * const gpio_periphs_groups[] = {
424 "GPIOZ_0", "GPIOZ_1", "GPIOZ_2", "GPIOZ_3", "GPIOZ_4",
425 "GPIOZ_5", "GPIOZ_6", "GPIOZ_7", "GPIOZ_8", "GPIOZ_9",
426 "GPIOZ_10", "GPIOZ_11", "GPIOZ_12", "GPIOZ_13", "GPIOZ_14",
427 "GPIOZ_15",
428
429 "GPIOH_0", "GPIOH_1", "GPIOH_2", "GPIOH_3", "GPIOH_4",
430 "GPIOH_5", "GPIOH_6", "GPIOH_7", "GPIOH_8", "GPIOH_9",
431
432 "BOOT_0", "BOOT_1", "BOOT_2", "BOOT_3", "BOOT_4",
433 "BOOT_5", "BOOT_6", "BOOT_7", "BOOT_8", "BOOT_9",
434 "BOOT_10", "BOOT_11", "BOOT_12", "BOOT_13", "BOOT_14",
435 "BOOT_15",
436
437 "CARD_0", "CARD_1", "CARD_2", "CARD_3", "CARD_4",
438 "CARD_5", "CARD_6",
439
440 "GPIODV_0", "GPIODV_1", "GPIODV_2", "GPIODV_3", "GPIODV_4",
441 "GPIODV_5", "GPIODV_6", "GPIODV_7", "GPIODV_8", "GPIODV_9",
442 "GPIODV_10", "GPIODV_11", "GPIODV_12", "GPIODV_13", "GPIODV_14",
443 "GPIODV_15", "GPIODV_16", "GPIODV_17", "GPIODV_18", "GPIODV_19",
444 "GPIODV_20", "GPIODV_21", "GPIODV_22", "GPIODV_23", "GPIODV_24",
445 "GPIODV_25", "GPIODV_26", "GPIODV_27", "GPIODV_28", "GPIODV_29",
446
447 "GPIOX_0", "GPIOX_1", "GPIOX_2", "GPIOX_3", "GPIOX_4",
448 "GPIOX_5", "GPIOX_6", "GPIOX_7", "GPIOX_8", "GPIOX_9",
449 "GPIOX_10", "GPIOX_11", "GPIOX_12", "GPIOX_13", "GPIOX_14",
450 "GPIOX_15", "GPIOX_16", "GPIOX_17", "GPIOX_18",
451
452 "GPIO_TEST_N",
453};
454
455static const char * const emmc_groups[] = {
456 "emmc_nand_d07", "emmc_clk", "emmc_cmd", "emmc_ds",
457};
458
459static const char * const sdcard_groups[] = {
460 "sdcard_d0", "sdcard_d1", "sdcard_d2", "sdcard_d3",
461 "sdcard_cmd", "sdcard_clk",
462};
463
464static const char * const sdio_groups[] = {
465 "sdio_d0", "sdio_d1", "sdio_d2", "sdio_d3",
466 "sdio_cmd", "sdio_clk", "sdio_irq",
467};
468
469static const char * const nand_groups[] = {
470 "nand_ce0", "nand_ce1", "nand_rb0", "nand_ale", "nand_cle",
471 "nand_wen_clk", "nand_ren_wr", "nand_dqs",
472};
473
474static const char * const uart_a_groups[] = {
475 "uart_tx_a", "uart_rx_a", "uart_cts_a", "uart_rts_a",
476};
477
478static const char * const uart_b_groups[] = {
479 "uart_tx_b", "uart_rx_b",
480};
481
482static const char * const uart_c_groups[] = {
483 "uart_tx_c", "uart_rx_c",
484};
485
486static const char * const i2c_a_groups[] = {
487 "i2c_sck_a", "i2c_sda_a",
488};
489
490static const char * const i2c_b_groups[] = {
491 "i2c_sck_b", "i2c_sda_b",
492};
493
494static const char * const i2c_c_groups[] = {
495 "i2c_sck_c", "i2c_sda_c",
496};
497
498static const char * const eth_groups[] = {
499 "eth_mdio", "eth_mdc", "eth_clk_rx_clk", "eth_rx_dv",
500 "eth_rxd0", "eth_rxd1", "eth_rxd2", "eth_rxd3",
501 "eth_rgmii_tx_clk", "eth_tx_en",
502 "eth_txd0", "eth_txd1", "eth_txd2", "eth_txd3",
503};
504
505static const char * const pwm_e_groups[] = {
506 "pwm_e",
507};
508
509static const char * const gpio_aobus_groups[] = {
510 "GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4",
511 "GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9",
512};
513
514static const char * const uart_ao_groups[] = {
515 "uart_tx_ao_a", "uart_rx_ao_a", "uart_cts_ao_a", "uart_rts_ao_a",
516};
517
518static const char * const uart_ao_b_groups[] = {
519 "uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
520};
521
522static const char * const remote_input_ao_groups[] = {
523 "remote_input_ao",
524};
525
526static struct meson_pmx_func meson_gxl_periphs_functions[] = {
527 FUNCTION(gpio_periphs),
528 FUNCTION(emmc),
529 FUNCTION(sdcard),
530 FUNCTION(sdio),
531 FUNCTION(nand),
532 FUNCTION(uart_a),
533 FUNCTION(uart_b),
534 FUNCTION(uart_c),
535 FUNCTION(i2c_a),
536 FUNCTION(i2c_b),
537 FUNCTION(i2c_c),
538 FUNCTION(eth),
539 FUNCTION(pwm_e),
540};
541
542static struct meson_pmx_func meson_gxl_aobus_functions[] = {
543 FUNCTION(gpio_aobus),
544 FUNCTION(uart_ao),
545 FUNCTION(uart_ao_b),
546 FUNCTION(remote_input_ao),
547};
548
549static struct meson_bank meson_gxl_periphs_banks[] = {
550 /* name first last pullen pull dir out in */
551 BANK("X", PIN(GPIOX_0, EE_OFF), PIN(GPIOX_18, EE_OFF), 4, 0, 4, 0, 12, 0, 13, 0, 14, 0),
552 BANK("DV", PIN(GPIODV_0, EE_OFF), PIN(GPIODV_29, EE_OFF), 0, 0, 0, 0, 0, 0, 1, 0, 2, 0),
553 BANK("H", PIN(GPIOH_0, EE_OFF), PIN(GPIOH_9, EE_OFF), 1, 20, 1, 20, 3, 20, 4, 20, 5, 20),
554 BANK("Z", PIN(GPIOZ_0, EE_OFF), PIN(GPIOZ_15, EE_OFF), 3, 0, 3, 0, 9, 0, 10, 0, 11, 0),
555 BANK("CARD", PIN(CARD_0, EE_OFF), PIN(CARD_6, EE_OFF), 2, 20, 2, 20, 6, 20, 7, 20, 8, 20),
556 BANK("BOOT", PIN(BOOT_0, EE_OFF), PIN(BOOT_15, EE_OFF), 2, 0, 2, 0, 6, 0, 7, 0, 8, 0),
557 BANK("CLK", PIN(GPIOCLK_0, EE_OFF), PIN(GPIOCLK_1, EE_OFF), 3, 28, 3, 28, 9, 28, 10, 28, 11, 28),
558};
559
560static struct meson_bank meson_gxl_aobus_banks[] = {
561 /* name first last pullen pull dir out in */
562 BANK("AO", PIN(GPIOAO_0, 0), PIN(GPIOAO_9, 0), 0, 0, 0, 16, 0, 0, 0, 16, 1, 0),
563};
564
565struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data = {
566 .name = "periphs-banks",
567 .pin_base = 10,
568 .pins = meson_gxl_periphs_pins,
569 .groups = meson_gxl_periphs_groups,
570 .funcs = meson_gxl_periphs_functions,
571 .banks = meson_gxl_periphs_banks,
572 .num_pins = ARRAY_SIZE(meson_gxl_periphs_pins),
573 .num_groups = ARRAY_SIZE(meson_gxl_periphs_groups),
574 .num_funcs = ARRAY_SIZE(meson_gxl_periphs_functions),
575 .num_banks = ARRAY_SIZE(meson_gxl_periphs_banks),
576};
577
578struct meson_pinctrl_data meson_gxl_aobus_pinctrl_data = {
579 .name = "aobus-banks",
580 .pin_base = 0,
581 .pins = meson_gxl_aobus_pins,
582 .groups = meson_gxl_aobus_groups,
583 .funcs = meson_gxl_aobus_functions,
584 .banks = meson_gxl_aobus_banks,
585 .num_pins = ARRAY_SIZE(meson_gxl_aobus_pins),
586 .num_groups = ARRAY_SIZE(meson_gxl_aobus_groups),
587 .num_funcs = ARRAY_SIZE(meson_gxl_aobus_functions),
588 .num_banks = ARRAY_SIZE(meson_gxl_aobus_banks),
589};
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 57122eda155a..a579126832af 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -524,6 +524,14 @@ static const struct of_device_id meson_pinctrl_dt_match[] = {
524 .compatible = "amlogic,meson-gxbb-aobus-pinctrl", 524 .compatible = "amlogic,meson-gxbb-aobus-pinctrl",
525 .data = &meson_gxbb_aobus_pinctrl_data, 525 .data = &meson_gxbb_aobus_pinctrl_data,
526 }, 526 },
527 {
528 .compatible = "amlogic,meson-gxl-periphs-pinctrl",
529 .data = &meson_gxl_periphs_pinctrl_data,
530 },
531 {
532 .compatible = "amlogic,meson-gxl-aobus-pinctrl",
533 .data = &meson_gxl_aobus_pinctrl_data,
534 },
527 { }, 535 { },
528}; 536};
529 537
diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
index 98b5080650c1..1aa871d5431e 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.h
+++ b/drivers/pinctrl/meson/pinctrl-meson.h
@@ -169,3 +169,5 @@ extern struct meson_pinctrl_data meson8b_cbus_pinctrl_data;
169extern struct meson_pinctrl_data meson8b_aobus_pinctrl_data; 169extern struct meson_pinctrl_data meson8b_aobus_pinctrl_data;
170extern struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data; 170extern struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data;
171extern struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data; 171extern struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data;
172extern struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data;
173extern struct meson_pinctrl_data meson_gxl_aobus_pinctrl_data;
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c b/drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c
index 8392083514fb..af4814479eb0 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c
@@ -379,13 +379,24 @@ static const unsigned msp0txrx_a_1_pins[] = { DB8500_PIN_AC4, DB8500_PIN_AC3 };
379static const unsigned msp0tfstck_a_1_pins[] = { DB8500_PIN_AF3, DB8500_PIN_AE3 }; 379static const unsigned msp0tfstck_a_1_pins[] = { DB8500_PIN_AF3, DB8500_PIN_AE3 };
380static const unsigned msp0rfsrck_a_1_pins[] = { DB8500_PIN_AD3, DB8500_PIN_AD4 }; 380static const unsigned msp0rfsrck_a_1_pins[] = { DB8500_PIN_AD3, DB8500_PIN_AD4 };
381/* Basic pins of the MMC/SD card 0 interface */ 381/* Basic pins of the MMC/SD card 0 interface */
382static const unsigned mc0_a_1_pins[] = { DB8500_PIN_AC2, DB8500_PIN_AC1, 382static const unsigned mc0_a_1_pins[] = { DB8500_PIN_AC2, /* MC0_CMDDIR */
383 DB8500_PIN_AB4, DB8500_PIN_AA3, DB8500_PIN_AA4, DB8500_PIN_AB2, 383 DB8500_PIN_AC1, /* MC0_DAT0DIR */
384 DB8500_PIN_Y4, DB8500_PIN_Y2, DB8500_PIN_AA2, DB8500_PIN_AA1 }; 384 DB8500_PIN_AB4, /* MC0_DAT2DIR */
385 DB8500_PIN_AA3, /* MC0_FBCLK */
386 DB8500_PIN_AA4, /* MC0_CLK */
387 DB8500_PIN_AB2, /* MC0_CMD */
388 DB8500_PIN_Y4, /* MC0_DAT0 */
389 DB8500_PIN_Y2, /* MC0_DAT1 */
390 DB8500_PIN_AA2, /* MC0_DAT2 */
391 DB8500_PIN_AA1 /* MC0_DAT3 */
392};
385/* Often only 4 bits are used, then these are not needed (only used for MMC) */ 393/* Often only 4 bits are used, then these are not needed (only used for MMC) */
386static const unsigned mc0_dat47_a_1_pins[] = { DB8500_PIN_W2, DB8500_PIN_W3, 394static const unsigned mc0_dat47_a_1_pins[] = { DB8500_PIN_W2, /* MC0_DAT4 */
387 DB8500_PIN_V3, DB8500_PIN_V2}; 395 DB8500_PIN_W3, /* MC0_DAT5 */
388static const unsigned mc0dat31dir_a_1_pins[] = { DB8500_PIN_AB3 }; 396 DB8500_PIN_V3, /* MC0_DAT6 */
397 DB8500_PIN_V2 /* MC0_DAT7 */
398};
399static const unsigned mc0dat31dir_a_1_pins[] = { DB8500_PIN_AB3 }; /* MC0_DAT31DIR */
389/* MSP1 can only be on these pins, but TXD and RXD can be flipped */ 400/* MSP1 can only be on these pins, but TXD and RXD can be flipped */
390static const unsigned msp1txrx_a_1_pins[] = { DB8500_PIN_AF2, DB8500_PIN_AG2 }; 401static const unsigned msp1txrx_a_1_pins[] = { DB8500_PIN_AF2, DB8500_PIN_AG2 };
391static const unsigned msp1_a_1_pins[] = { DB8500_PIN_AE1, DB8500_PIN_AE2 }; 402static const unsigned msp1_a_1_pins[] = { DB8500_PIN_AE1, DB8500_PIN_AE2 };
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 5020ae534479..ce3335accb5b 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -381,7 +381,7 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
381 if (ret < 0) 381 if (ret < 0)
382 goto exit; 382 goto exit;
383 383
384 for_each_child_of_node(np_config, np) { 384 for_each_available_child_of_node(np_config, np) {
385 ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map, 385 ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
386 &reserved_maps, num_maps, type); 386 &reserved_maps, num_maps, type);
387 if (ret < 0) 387 if (ret < 0)
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 9f0904185909..569bc28cb909 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -56,6 +56,9 @@ static int gpio_banks;
56#define DRIVE_STRENGTH_SHIFT 5 56#define DRIVE_STRENGTH_SHIFT 5
57#define DRIVE_STRENGTH_MASK 0x3 57#define DRIVE_STRENGTH_MASK 0x3
58#define DRIVE_STRENGTH (DRIVE_STRENGTH_MASK << DRIVE_STRENGTH_SHIFT) 58#define DRIVE_STRENGTH (DRIVE_STRENGTH_MASK << DRIVE_STRENGTH_SHIFT)
59#define OUTPUT (1 << 7)
60#define OUTPUT_VAL_SHIFT 8
61#define OUTPUT_VAL (0x1 << OUTPUT_VAL_SHIFT)
59#define DEBOUNCE (1 << 16) 62#define DEBOUNCE (1 << 16)
60#define DEBOUNCE_VAL_SHIFT 17 63#define DEBOUNCE_VAL_SHIFT 17
61#define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) 64#define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT)
@@ -375,6 +378,19 @@ static void at91_mux_set_pullup(void __iomem *pio, unsigned mask, bool on)
375 writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); 378 writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR));
376} 379}
377 380
381static bool at91_mux_get_output(void __iomem *pio, unsigned int pin, bool *val)
382{
383 *val = (readl_relaxed(pio + PIO_ODSR) >> pin) & 0x1;
384 return (readl_relaxed(pio + PIO_OSR) >> pin) & 0x1;
385}
386
387static void at91_mux_set_output(void __iomem *pio, unsigned int mask,
388 bool is_on, bool val)
389{
390 writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR));
391 writel_relaxed(mask, pio + (is_on ? PIO_OER : PIO_ODR));
392}
393
378static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) 394static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin)
379{ 395{
380 return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1; 396 return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1;
@@ -848,6 +864,7 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
848 void __iomem *pio; 864 void __iomem *pio;
849 unsigned pin; 865 unsigned pin;
850 int div; 866 int div;
867 bool out;
851 868
852 *config = 0; 869 *config = 0;
853 dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id); 870 dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id);
@@ -875,6 +892,8 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
875 if (info->ops->get_drivestrength) 892 if (info->ops->get_drivestrength)
876 *config |= (info->ops->get_drivestrength(pio, pin) 893 *config |= (info->ops->get_drivestrength(pio, pin)
877 << DRIVE_STRENGTH_SHIFT); 894 << DRIVE_STRENGTH_SHIFT);
895 if (at91_mux_get_output(pio, pin, &out))
896 *config |= OUTPUT | (out << OUTPUT_VAL_SHIFT);
878 897
879 return 0; 898 return 0;
880} 899}
@@ -907,6 +926,8 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
907 if (config & PULL_UP && config & PULL_DOWN) 926 if (config & PULL_UP && config & PULL_DOWN)
908 return -EINVAL; 927 return -EINVAL;
909 928
929 at91_mux_set_output(pio, mask, config & OUTPUT,
930 (config & OUTPUT_VAL) >> OUTPUT_VAL_SHIFT);
910 at91_mux_set_pullup(pio, mask, config & PULL_UP); 931 at91_mux_set_pullup(pio, mask, config & PULL_UP);
911 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 932 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE);
912 if (info->ops->set_deglitch) 933 if (info->ops->set_deglitch)
diff --git a/drivers/pinctrl/pinctrl-da850-pupd.c b/drivers/pinctrl/pinctrl-da850-pupd.c
new file mode 100644
index 000000000000..b36a90a3f3e4
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-da850-pupd.c
@@ -0,0 +1,210 @@
1/*
2 * Pinconf driver for TI DA850/OMAP-L138/AM18XX pullup/pulldown groups
3 *
4 * Copyright (C) 2016 David Lechner
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/bitops.h>
17#include <linux/device.h>
18#include <linux/io.h>
19#include <linux/ioport.h>
20#include <linux/mod_devicetable.h>
21#include <linux/module.h>
22#include <linux/pinctrl/pinconf.h>
23#include <linux/pinctrl/pinconf-generic.h>
24#include <linux/pinctrl/pinctrl.h>
25#include <linux/platform_device.h>
26
27#define DA850_PUPD_ENA 0x00
28#define DA850_PUPD_SEL 0x04
29
30struct da850_pupd_data {
31 void __iomem *base;
32 struct pinctrl_desc desc;
33 struct pinctrl_dev *pinctrl;
34};
35
36static const char * const da850_pupd_group_names[] = {
37 "cp0", "cp1", "cp2", "cp3", "cp4", "cp5", "cp6", "cp7",
38 "cp8", "cp9", "cp10", "cp11", "cp12", "cp13", "cp14", "cp15",
39 "cp16", "cp17", "cp18", "cp19", "cp20", "cp21", "cp22", "cp23",
40 "cp24", "cp25", "cp26", "cp27", "cp28", "cp29", "cp30", "cp31",
41};
42
43static int da850_pupd_get_groups_count(struct pinctrl_dev *pctldev)
44{
45 return ARRAY_SIZE(da850_pupd_group_names);
46}
47
48static const char *da850_pupd_get_group_name(struct pinctrl_dev *pctldev,
49 unsigned int selector)
50{
51 return da850_pupd_group_names[selector];
52}
53
54static int da850_pupd_get_group_pins(struct pinctrl_dev *pctldev,
55 unsigned int selector,
56 const unsigned int **pins,
57 unsigned int *num_pins)
58{
59 *num_pins = 0;
60
61 return 0;
62}
63
64static const struct pinctrl_ops da850_pupd_pctlops = {
65 .get_groups_count = da850_pupd_get_groups_count,
66 .get_group_name = da850_pupd_get_group_name,
67 .get_group_pins = da850_pupd_get_group_pins,
68 .dt_node_to_map = pinconf_generic_dt_node_to_map_group,
69 .dt_free_map = pinconf_generic_dt_free_map,
70};
71
72static int da850_pupd_pin_config_group_get(struct pinctrl_dev *pctldev,
73 unsigned int selector,
74 unsigned long *config)
75{
76 struct da850_pupd_data *data = pinctrl_dev_get_drvdata(pctldev);
77 enum pin_config_param param = pinconf_to_config_param(*config);
78 u32 val;
79 u16 arg;
80
81 val = readl(data->base + DA850_PUPD_ENA);
82 arg = !!(~val & BIT(selector));
83
84 switch (param) {
85 case PIN_CONFIG_BIAS_DISABLE:
86 break;
87 case PIN_CONFIG_BIAS_PULL_UP:
88 case PIN_CONFIG_BIAS_PULL_DOWN:
89 if (arg) {
90 /* bias is disabled */
91 arg = 0;
92 break;
93 }
94 val = readl(data->base + DA850_PUPD_SEL);
95 if (param == PIN_CONFIG_BIAS_PULL_DOWN)
96 val = ~val;
97 arg = !!(val & BIT(selector));
98 break;
99 default:
100 return -EINVAL;
101 }
102
103 *config = pinconf_to_config_packed(param, arg);
104
105 return 0;
106}
107
108static int da850_pupd_pin_config_group_set(struct pinctrl_dev *pctldev,
109 unsigned int selector,
110 unsigned long *configs,
111 unsigned int num_configs)
112{
113 struct da850_pupd_data *data = pinctrl_dev_get_drvdata(pctldev);
114 u32 ena, sel;
115 enum pin_config_param param;
116 u16 arg;
117 int i;
118
119 ena = readl(data->base + DA850_PUPD_ENA);
120 sel = readl(data->base + DA850_PUPD_SEL);
121
122 for (i = 0; i < num_configs; i++) {
123 param = pinconf_to_config_param(configs[i]);
124 arg = pinconf_to_config_argument(configs[i]);
125
126 switch (param) {
127 case PIN_CONFIG_BIAS_DISABLE:
128 ena &= ~BIT(selector);
129 break;
130 case PIN_CONFIG_BIAS_PULL_UP:
131 ena |= BIT(selector);
132 sel |= BIT(selector);
133 break;
134 case PIN_CONFIG_BIAS_PULL_DOWN:
135 ena |= BIT(selector);
136 sel &= ~BIT(selector);
137 break;
138 default:
139 return -EINVAL;
140 }
141 }
142
143 writel(sel, data->base + DA850_PUPD_SEL);
144 writel(ena, data->base + DA850_PUPD_ENA);
145
146 return 0;
147}
148
149static const struct pinconf_ops da850_pupd_confops = {
150 .is_generic = true,
151 .pin_config_group_get = da850_pupd_pin_config_group_get,
152 .pin_config_group_set = da850_pupd_pin_config_group_set,
153};
154
155static int da850_pupd_probe(struct platform_device *pdev)
156{
157 struct device *dev = &pdev->dev;
158 struct da850_pupd_data *data;
159 struct resource *res;
160
161 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
162 if (!data)
163 return -ENOMEM;
164
165 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
166 data->base = devm_ioremap_resource(dev, res);
167 if (IS_ERR(data->base)) {
168 dev_err(dev, "Could not map resource\n");
169 return PTR_ERR(data->base);
170 }
171
172 data->desc.name = dev_name(dev);
173 data->desc.pctlops = &da850_pupd_pctlops;
174 data->desc.confops = &da850_pupd_confops;
175 data->desc.owner = THIS_MODULE;
176
177 data->pinctrl = devm_pinctrl_register(dev, &data->desc, data);
178 if (IS_ERR(data->pinctrl)) {
179 dev_err(dev, "Failed to register pinctrl\n");
180 return PTR_ERR(data->pinctrl);
181 }
182
183 platform_set_drvdata(pdev, data);
184
185 return 0;
186}
187
188static int da850_pupd_remove(struct platform_device *pdev)
189{
190 return 0;
191}
192
193static const struct of_device_id da850_pupd_of_match[] = {
194 { .compatible = "ti,da850-pupd" },
195 { }
196};
197
198static struct platform_driver da850_pupd_driver = {
199 .driver = {
200 .name = "ti-da850-pupd",
201 .of_match_table = da850_pupd_of_match,
202 },
203 .probe = da850_pupd_probe,
204 .remove = da850_pupd_remove,
205};
206module_platform_driver(da850_pupd_driver);
207
208MODULE_AUTHOR("David Lechner <david@lechnology.com>");
209MODULE_DESCRIPTION("TI DA850/OMAP-L138/AM18XX pullup/pulldown configuration");
210MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/pinctrl-oxnas.c b/drivers/pinctrl/pinctrl-oxnas.c
index 917a7d2535d7..494ec9a7573a 100644
--- a/drivers/pinctrl/pinctrl-oxnas.c
+++ b/drivers/pinctrl/pinctrl-oxnas.c
@@ -37,15 +37,24 @@
37 37
38#define GPIO_BANK_START(bank) ((bank) * PINS_PER_BANK) 38#define GPIO_BANK_START(bank) ((bank) * PINS_PER_BANK)
39 39
40/* Regmap Offsets */ 40/* OX810 Regmap Offsets */
41#define PINMUX_PRIMARY_SEL0 0x0c 41#define PINMUX_810_PRIMARY_SEL0 0x0c
42#define PINMUX_SECONDARY_SEL0 0x14 42#define PINMUX_810_SECONDARY_SEL0 0x14
43#define PINMUX_TERTIARY_SEL0 0x8c 43#define PINMUX_810_TERTIARY_SEL0 0x8c
44#define PINMUX_PRIMARY_SEL1 0x10 44#define PINMUX_810_PRIMARY_SEL1 0x10
45#define PINMUX_SECONDARY_SEL1 0x18 45#define PINMUX_810_SECONDARY_SEL1 0x18
46#define PINMUX_TERTIARY_SEL1 0x90 46#define PINMUX_810_TERTIARY_SEL1 0x90
47#define PINMUX_PULLUP_CTRL0 0xac 47#define PINMUX_810_PULLUP_CTRL0 0xac
48#define PINMUX_PULLUP_CTRL1 0xb0 48#define PINMUX_810_PULLUP_CTRL1 0xb0
49
50/* OX820 Regmap Offsets */
51#define PINMUX_820_BANK_OFFSET 0x100000
52#define PINMUX_820_SECONDARY_SEL 0x14
53#define PINMUX_820_TERTIARY_SEL 0x8c
54#define PINMUX_820_QUATERNARY_SEL 0x94
55#define PINMUX_820_DEBUG_SEL 0x9c
56#define PINMUX_820_ALTERNATIVE_SEL 0xa4
57#define PINMUX_820_PULLUP_CTRL 0xac
49 58
50/* GPIO Registers */ 59/* GPIO Registers */
51#define INPUT_VALUE 0x00 60#define INPUT_VALUE 0x00
@@ -87,8 +96,6 @@ struct oxnas_pinctrl {
87 struct regmap *regmap; 96 struct regmap *regmap;
88 struct device *dev; 97 struct device *dev;
89 struct pinctrl_dev *pctldev; 98 struct pinctrl_dev *pctldev;
90 const struct pinctrl_pin_desc *pins;
91 unsigned int npins;
92 const struct oxnas_function *functions; 99 const struct oxnas_function *functions;
93 unsigned int nfunctions; 100 unsigned int nfunctions;
94 const struct oxnas_pin_group *groups; 101 const struct oxnas_pin_group *groups;
@@ -97,7 +104,50 @@ struct oxnas_pinctrl {
97 unsigned int nbanks; 104 unsigned int nbanks;
98}; 105};
99 106
100static const struct pinctrl_pin_desc oxnas_pins[] = { 107struct oxnas_pinctrl_data {
108 struct pinctrl_desc *desc;
109 struct oxnas_pinctrl *pctl;
110};
111
112static const struct pinctrl_pin_desc oxnas_ox810se_pins[] = {
113 PINCTRL_PIN(0, "gpio0"),
114 PINCTRL_PIN(1, "gpio1"),
115 PINCTRL_PIN(2, "gpio2"),
116 PINCTRL_PIN(3, "gpio3"),
117 PINCTRL_PIN(4, "gpio4"),
118 PINCTRL_PIN(5, "gpio5"),
119 PINCTRL_PIN(6, "gpio6"),
120 PINCTRL_PIN(7, "gpio7"),
121 PINCTRL_PIN(8, "gpio8"),
122 PINCTRL_PIN(9, "gpio9"),
123 PINCTRL_PIN(10, "gpio10"),
124 PINCTRL_PIN(11, "gpio11"),
125 PINCTRL_PIN(12, "gpio12"),
126 PINCTRL_PIN(13, "gpio13"),
127 PINCTRL_PIN(14, "gpio14"),
128 PINCTRL_PIN(15, "gpio15"),
129 PINCTRL_PIN(16, "gpio16"),
130 PINCTRL_PIN(17, "gpio17"),
131 PINCTRL_PIN(18, "gpio18"),
132 PINCTRL_PIN(19, "gpio19"),
133 PINCTRL_PIN(20, "gpio20"),
134 PINCTRL_PIN(21, "gpio21"),
135 PINCTRL_PIN(22, "gpio22"),
136 PINCTRL_PIN(23, "gpio23"),
137 PINCTRL_PIN(24, "gpio24"),
138 PINCTRL_PIN(25, "gpio25"),
139 PINCTRL_PIN(26, "gpio26"),
140 PINCTRL_PIN(27, "gpio27"),
141 PINCTRL_PIN(28, "gpio28"),
142 PINCTRL_PIN(29, "gpio29"),
143 PINCTRL_PIN(30, "gpio30"),
144 PINCTRL_PIN(31, "gpio31"),
145 PINCTRL_PIN(32, "gpio32"),
146 PINCTRL_PIN(33, "gpio33"),
147 PINCTRL_PIN(34, "gpio34"),
148};
149
150static const struct pinctrl_pin_desc oxnas_ox820_pins[] = {
101 PINCTRL_PIN(0, "gpio0"), 151 PINCTRL_PIN(0, "gpio0"),
102 PINCTRL_PIN(1, "gpio1"), 152 PINCTRL_PIN(1, "gpio1"),
103 PINCTRL_PIN(2, "gpio2"), 153 PINCTRL_PIN(2, "gpio2"),
@@ -133,9 +183,24 @@ static const struct pinctrl_pin_desc oxnas_pins[] = {
133 PINCTRL_PIN(32, "gpio32"), 183 PINCTRL_PIN(32, "gpio32"),
134 PINCTRL_PIN(33, "gpio33"), 184 PINCTRL_PIN(33, "gpio33"),
135 PINCTRL_PIN(34, "gpio34"), 185 PINCTRL_PIN(34, "gpio34"),
186 PINCTRL_PIN(35, "gpio35"),
187 PINCTRL_PIN(36, "gpio36"),
188 PINCTRL_PIN(37, "gpio37"),
189 PINCTRL_PIN(38, "gpio38"),
190 PINCTRL_PIN(39, "gpio39"),
191 PINCTRL_PIN(40, "gpio40"),
192 PINCTRL_PIN(41, "gpio41"),
193 PINCTRL_PIN(42, "gpio42"),
194 PINCTRL_PIN(43, "gpio43"),
195 PINCTRL_PIN(44, "gpio44"),
196 PINCTRL_PIN(45, "gpio45"),
197 PINCTRL_PIN(46, "gpio46"),
198 PINCTRL_PIN(47, "gpio47"),
199 PINCTRL_PIN(48, "gpio48"),
200 PINCTRL_PIN(49, "gpio49"),
136}; 201};
137 202
138static const char * const oxnas_fct0_group[] = { 203static const char * const oxnas_ox810se_fct0_group[] = {
139 "gpio0", "gpio1", "gpio2", "gpio3", 204 "gpio0", "gpio1", "gpio2", "gpio3",
140 "gpio4", "gpio5", "gpio6", "gpio7", 205 "gpio4", "gpio5", "gpio6", "gpio7",
141 "gpio8", "gpio9", "gpio10", "gpio11", 206 "gpio8", "gpio9", "gpio10", "gpio11",
@@ -147,7 +212,7 @@ static const char * const oxnas_fct0_group[] = {
147 "gpio32", "gpio33", "gpio34" 212 "gpio32", "gpio33", "gpio34"
148}; 213};
149 214
150static const char * const oxnas_fct3_group[] = { 215static const char * const oxnas_ox810se_fct3_group[] = {
151 "gpio0", "gpio1", "gpio2", "gpio3", 216 "gpio0", "gpio1", "gpio2", "gpio3",
152 "gpio4", "gpio5", "gpio6", "gpio7", 217 "gpio4", "gpio5", "gpio6", "gpio7",
153 "gpio8", "gpio9", 218 "gpio8", "gpio9",
@@ -158,6 +223,40 @@ static const char * const oxnas_fct3_group[] = {
158 "gpio34" 223 "gpio34"
159}; 224};
160 225
226static const char * const oxnas_ox820_fct0_group[] = {
227 "gpio0", "gpio1", "gpio2", "gpio3",
228 "gpio4", "gpio5", "gpio6", "gpio7",
229 "gpio8", "gpio9", "gpio10", "gpio11",
230 "gpio12", "gpio13", "gpio14", "gpio15",
231 "gpio16", "gpio17", "gpio18", "gpio19",
232 "gpio20", "gpio21", "gpio22", "gpio23",
233 "gpio24", "gpio25", "gpio26", "gpio27",
234 "gpio28", "gpio29", "gpio30", "gpio31",
235 "gpio32", "gpio33", "gpio34", "gpio35",
236 "gpio36", "gpio37", "gpio38", "gpio39",
237 "gpio40", "gpio41", "gpio42", "gpio43",
238 "gpio44", "gpio45", "gpio46", "gpio47",
239 "gpio48", "gpio49"
240};
241
242static const char * const oxnas_ox820_fct1_group[] = {
243 "gpio3", "gpio4",
244 "gpio12", "gpio13", "gpio14", "gpio15",
245 "gpio16", "gpio17", "gpio18", "gpio19",
246 "gpio20", "gpio21", "gpio22", "gpio23",
247 "gpio24"
248};
249
250static const char * const oxnas_ox820_fct4_group[] = {
251 "gpio5", "gpio6", "gpio7", "gpio8",
252 "gpio24", "gpio25", "gpio26", "gpio27",
253 "gpio40", "gpio41", "gpio42", "gpio43"
254};
255
256static const char * const oxnas_ox820_fct5_group[] = {
257 "gpio28", "gpio29", "gpio30", "gpio31"
258};
259
161#define FUNCTION(_name, _gr) \ 260#define FUNCTION(_name, _gr) \
162 { \ 261 { \
163 .name = #_name, \ 262 .name = #_name, \
@@ -165,9 +264,16 @@ static const char * const oxnas_fct3_group[] = {
165 .ngroups = ARRAY_SIZE(oxnas_##_gr##_group), \ 264 .ngroups = ARRAY_SIZE(oxnas_##_gr##_group), \
166 } 265 }
167 266
168static const struct oxnas_function oxnas_functions[] = { 267static const struct oxnas_function oxnas_ox810se_functions[] = {
169 FUNCTION(gpio, fct0), 268 FUNCTION(gpio, ox810se_fct0),
170 FUNCTION(fct3, fct3), 269 FUNCTION(fct3, ox810se_fct3),
270};
271
272static const struct oxnas_function oxnas_ox820_functions[] = {
273 FUNCTION(gpio, ox820_fct0),
274 FUNCTION(fct1, ox820_fct1),
275 FUNCTION(fct4, ox820_fct4),
276 FUNCTION(fct5, ox820_fct5),
171}; 277};
172 278
173#define OXNAS_PINCTRL_GROUP(_pin, _name, ...) \ 279#define OXNAS_PINCTRL_GROUP(_pin, _name, ...) \
@@ -185,7 +291,7 @@ static const struct oxnas_function oxnas_functions[] = {
185 .fct = _fct, \ 291 .fct = _fct, \
186 } 292 }
187 293
188static const struct oxnas_pin_group oxnas_groups[] = { 294static const struct oxnas_pin_group oxnas_ox810se_groups[] = {
189 OXNAS_PINCTRL_GROUP(0, gpio0, 295 OXNAS_PINCTRL_GROUP(0, gpio0,
190 OXNAS_PINCTRL_FUNCTION(gpio, 0), 296 OXNAS_PINCTRL_FUNCTION(gpio, 0),
191 OXNAS_PINCTRL_FUNCTION(fct3, 3)), 297 OXNAS_PINCTRL_FUNCTION(fct3, 3)),
@@ -282,6 +388,140 @@ static const struct oxnas_pin_group oxnas_groups[] = {
282 OXNAS_PINCTRL_FUNCTION(fct3, 3)), 388 OXNAS_PINCTRL_FUNCTION(fct3, 3)),
283}; 389};
284 390
391static const struct oxnas_pin_group oxnas_ox820_groups[] = {
392 OXNAS_PINCTRL_GROUP(0, gpio0,
393 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
394 OXNAS_PINCTRL_GROUP(1, gpio1,
395 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
396 OXNAS_PINCTRL_GROUP(2, gpio2,
397 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
398 OXNAS_PINCTRL_GROUP(3, gpio3,
399 OXNAS_PINCTRL_FUNCTION(gpio, 0),
400 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
401 OXNAS_PINCTRL_GROUP(4, gpio4,
402 OXNAS_PINCTRL_FUNCTION(gpio, 0),
403 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
404 OXNAS_PINCTRL_GROUP(5, gpio5,
405 OXNAS_PINCTRL_FUNCTION(gpio, 0),
406 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
407 OXNAS_PINCTRL_GROUP(6, gpio6,
408 OXNAS_PINCTRL_FUNCTION(gpio, 0),
409 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
410 OXNAS_PINCTRL_GROUP(7, gpio7,
411 OXNAS_PINCTRL_FUNCTION(gpio, 0),
412 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
413 OXNAS_PINCTRL_GROUP(8, gpio8,
414 OXNAS_PINCTRL_FUNCTION(gpio, 0),
415 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
416 OXNAS_PINCTRL_GROUP(9, gpio9,
417 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
418 OXNAS_PINCTRL_GROUP(10, gpio10,
419 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
420 OXNAS_PINCTRL_GROUP(11, gpio11,
421 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
422 OXNAS_PINCTRL_GROUP(12, gpio12,
423 OXNAS_PINCTRL_FUNCTION(gpio, 0),
424 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
425 OXNAS_PINCTRL_GROUP(13, gpio13,
426 OXNAS_PINCTRL_FUNCTION(gpio, 0),
427 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
428 OXNAS_PINCTRL_GROUP(14, gpio14,
429 OXNAS_PINCTRL_FUNCTION(gpio, 0),
430 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
431 OXNAS_PINCTRL_GROUP(15, gpio15,
432 OXNAS_PINCTRL_FUNCTION(gpio, 0),
433 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
434 OXNAS_PINCTRL_GROUP(16, gpio16,
435 OXNAS_PINCTRL_FUNCTION(gpio, 0),
436 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
437 OXNAS_PINCTRL_GROUP(17, gpio17,
438 OXNAS_PINCTRL_FUNCTION(gpio, 0),
439 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
440 OXNAS_PINCTRL_GROUP(18, gpio18,
441 OXNAS_PINCTRL_FUNCTION(gpio, 0),
442 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
443 OXNAS_PINCTRL_GROUP(19, gpio19,
444 OXNAS_PINCTRL_FUNCTION(gpio, 0),
445 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
446 OXNAS_PINCTRL_GROUP(20, gpio20,
447 OXNAS_PINCTRL_FUNCTION(gpio, 0),
448 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
449 OXNAS_PINCTRL_GROUP(21, gpio21,
450 OXNAS_PINCTRL_FUNCTION(gpio, 0),
451 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
452 OXNAS_PINCTRL_GROUP(22, gpio22,
453 OXNAS_PINCTRL_FUNCTION(gpio, 0),
454 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
455 OXNAS_PINCTRL_GROUP(23, gpio23,
456 OXNAS_PINCTRL_FUNCTION(gpio, 0),
457 OXNAS_PINCTRL_FUNCTION(fct1, 1)),
458 OXNAS_PINCTRL_GROUP(24, gpio24,
459 OXNAS_PINCTRL_FUNCTION(gpio, 0),
460 OXNAS_PINCTRL_FUNCTION(fct1, 1),
461 OXNAS_PINCTRL_FUNCTION(fct4, 5)),
462 OXNAS_PINCTRL_GROUP(25, gpio25,
463 OXNAS_PINCTRL_FUNCTION(gpio, 0),
464 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
465 OXNAS_PINCTRL_GROUP(26, gpio26,
466 OXNAS_PINCTRL_FUNCTION(gpio, 0),
467 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
468 OXNAS_PINCTRL_GROUP(27, gpio27,
469 OXNAS_PINCTRL_FUNCTION(gpio, 0),
470 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
471 OXNAS_PINCTRL_GROUP(28, gpio28,
472 OXNAS_PINCTRL_FUNCTION(gpio, 0),
473 OXNAS_PINCTRL_FUNCTION(fct5, 5)),
474 OXNAS_PINCTRL_GROUP(29, gpio29,
475 OXNAS_PINCTRL_FUNCTION(gpio, 0),
476 OXNAS_PINCTRL_FUNCTION(fct5, 5)),
477 OXNAS_PINCTRL_GROUP(30, gpio30,
478 OXNAS_PINCTRL_FUNCTION(gpio, 0),
479 OXNAS_PINCTRL_FUNCTION(fct5, 5)),
480 OXNAS_PINCTRL_GROUP(31, gpio31,
481 OXNAS_PINCTRL_FUNCTION(gpio, 0),
482 OXNAS_PINCTRL_FUNCTION(fct5, 5)),
483 OXNAS_PINCTRL_GROUP(32, gpio32,
484 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
485 OXNAS_PINCTRL_GROUP(33, gpio33,
486 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
487 OXNAS_PINCTRL_GROUP(34, gpio34,
488 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
489 OXNAS_PINCTRL_GROUP(35, gpio35,
490 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
491 OXNAS_PINCTRL_GROUP(36, gpio36,
492 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
493 OXNAS_PINCTRL_GROUP(37, gpio37,
494 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
495 OXNAS_PINCTRL_GROUP(38, gpio38,
496 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
497 OXNAS_PINCTRL_GROUP(39, gpio39,
498 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
499 OXNAS_PINCTRL_GROUP(40, gpio40,
500 OXNAS_PINCTRL_FUNCTION(gpio, 0),
501 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
502 OXNAS_PINCTRL_GROUP(41, gpio41,
503 OXNAS_PINCTRL_FUNCTION(gpio, 0),
504 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
505 OXNAS_PINCTRL_GROUP(42, gpio42,
506 OXNAS_PINCTRL_FUNCTION(gpio, 0),
507 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
508 OXNAS_PINCTRL_GROUP(43, gpio43,
509 OXNAS_PINCTRL_FUNCTION(gpio, 0),
510 OXNAS_PINCTRL_FUNCTION(fct4, 4)),
511 OXNAS_PINCTRL_GROUP(44, gpio44,
512 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
513 OXNAS_PINCTRL_GROUP(45, gpio45,
514 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
515 OXNAS_PINCTRL_GROUP(46, gpio46,
516 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
517 OXNAS_PINCTRL_GROUP(47, gpio47,
518 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
519 OXNAS_PINCTRL_GROUP(48, gpio48,
520 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
521 OXNAS_PINCTRL_GROUP(49, gpio49,
522 OXNAS_PINCTRL_FUNCTION(gpio, 0)),
523};
524
285static inline struct oxnas_gpio_bank *pctl_to_bank(struct oxnas_pinctrl *pctl, 525static inline struct oxnas_gpio_bank *pctl_to_bank(struct oxnas_pinctrl *pctl,
286 unsigned int pin) 526 unsigned int pin)
287{ 527{
@@ -352,8 +592,8 @@ static int oxnas_pinmux_get_function_groups(struct pinctrl_dev *pctldev,
352 return 0; 592 return 0;
353} 593}
354 594
355static int oxnas_pinmux_enable(struct pinctrl_dev *pctldev, 595static int oxnas_ox810se_pinmux_enable(struct pinctrl_dev *pctldev,
356 unsigned int func, unsigned int group) 596 unsigned int func, unsigned int group)
357{ 597{
358 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 598 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
359 const struct oxnas_pin_group *pg = &pctl->groups[group]; 599 const struct oxnas_pin_group *pg = &pctl->groups[group];
@@ -371,22 +611,22 @@ static int oxnas_pinmux_enable(struct pinctrl_dev *pctldev,
371 611
372 regmap_write_bits(pctl->regmap, 612 regmap_write_bits(pctl->regmap,
373 (pg->bank ? 613 (pg->bank ?
374 PINMUX_PRIMARY_SEL1 : 614 PINMUX_810_PRIMARY_SEL1 :
375 PINMUX_PRIMARY_SEL0), 615 PINMUX_810_PRIMARY_SEL0),
376 mask, 616 mask,
377 (functions->fct == 1 ? 617 (functions->fct == 1 ?
378 mask : 0)); 618 mask : 0));
379 regmap_write_bits(pctl->regmap, 619 regmap_write_bits(pctl->regmap,
380 (pg->bank ? 620 (pg->bank ?
381 PINMUX_SECONDARY_SEL1 : 621 PINMUX_810_SECONDARY_SEL1 :
382 PINMUX_SECONDARY_SEL0), 622 PINMUX_810_SECONDARY_SEL0),
383 mask, 623 mask,
384 (functions->fct == 2 ? 624 (functions->fct == 2 ?
385 mask : 0)); 625 mask : 0));
386 regmap_write_bits(pctl->regmap, 626 regmap_write_bits(pctl->regmap,
387 (pg->bank ? 627 (pg->bank ?
388 PINMUX_TERTIARY_SEL1 : 628 PINMUX_810_TERTIARY_SEL1 :
389 PINMUX_TERTIARY_SEL0), 629 PINMUX_810_TERTIARY_SEL0),
390 mask, 630 mask,
391 (functions->fct == 3 ? 631 (functions->fct == 3 ?
392 mask : 0)); 632 mask : 0));
@@ -402,9 +642,64 @@ static int oxnas_pinmux_enable(struct pinctrl_dev *pctldev,
402 return -EINVAL; 642 return -EINVAL;
403} 643}
404 644
405static int oxnas_gpio_request_enable(struct pinctrl_dev *pctldev, 645static int oxnas_ox820_pinmux_enable(struct pinctrl_dev *pctldev,
406 struct pinctrl_gpio_range *range, 646 unsigned int func, unsigned int group)
407 unsigned int offset) 647{
648 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
649 const struct oxnas_pin_group *pg = &pctl->groups[group];
650 const struct oxnas_function *pf = &pctl->functions[func];
651 const char *fname = pf->name;
652 struct oxnas_desc_function *functions = pg->functions;
653 unsigned int offset = (pg->bank ? PINMUX_820_BANK_OFFSET : 0);
654 u32 mask = BIT(pg->pin);
655
656 while (functions->name) {
657 if (!strcmp(functions->name, fname)) {
658 dev_dbg(pctl->dev,
659 "setting function %s bank %d pin %d fct %d mask %x\n",
660 fname, pg->bank, pg->pin,
661 functions->fct, mask);
662
663 regmap_write_bits(pctl->regmap,
664 offset + PINMUX_820_SECONDARY_SEL,
665 mask,
666 (functions->fct == 1 ?
667 mask : 0));
668 regmap_write_bits(pctl->regmap,
669 offset + PINMUX_820_TERTIARY_SEL,
670 mask,
671 (functions->fct == 2 ?
672 mask : 0));
673 regmap_write_bits(pctl->regmap,
674 offset + PINMUX_820_QUATERNARY_SEL,
675 mask,
676 (functions->fct == 3 ?
677 mask : 0));
678 regmap_write_bits(pctl->regmap,
679 offset + PINMUX_820_DEBUG_SEL,
680 mask,
681 (functions->fct == 4 ?
682 mask : 0));
683 regmap_write_bits(pctl->regmap,
684 offset + PINMUX_820_ALTERNATIVE_SEL,
685 mask,
686 (functions->fct == 5 ?
687 mask : 0));
688
689 return 0;
690 }
691
692 functions++;
693 }
694
695 dev_err(pctl->dev, "cannot mux pin %u to function %u\n", group, func);
696
697 return -EINVAL;
698}
699
700static int oxnas_ox810se_gpio_request_enable(struct pinctrl_dev *pctldev,
701 struct pinctrl_gpio_range *range,
702 unsigned int offset)
408{ 703{
409 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 704 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
410 struct oxnas_gpio_bank *bank = gpiochip_get_data(range->gc); 705 struct oxnas_gpio_bank *bank = gpiochip_get_data(range->gc);
@@ -415,18 +710,49 @@ static int oxnas_gpio_request_enable(struct pinctrl_dev *pctldev,
415 710
416 regmap_write_bits(pctl->regmap, 711 regmap_write_bits(pctl->regmap,
417 (bank->id ? 712 (bank->id ?
418 PINMUX_PRIMARY_SEL1 : 713 PINMUX_810_PRIMARY_SEL1 :
419 PINMUX_PRIMARY_SEL0), 714 PINMUX_810_PRIMARY_SEL0),
420 mask, 0); 715 mask, 0);
421 regmap_write_bits(pctl->regmap, 716 regmap_write_bits(pctl->regmap,
422 (bank->id ? 717 (bank->id ?
423 PINMUX_SECONDARY_SEL1 : 718 PINMUX_810_SECONDARY_SEL1 :
424 PINMUX_SECONDARY_SEL0), 719 PINMUX_810_SECONDARY_SEL0),
425 mask, 0); 720 mask, 0);
426 regmap_write_bits(pctl->regmap, 721 regmap_write_bits(pctl->regmap,
427 (bank->id ? 722 (bank->id ?
428 PINMUX_TERTIARY_SEL1 : 723 PINMUX_810_TERTIARY_SEL1 :
429 PINMUX_TERTIARY_SEL0), 724 PINMUX_810_TERTIARY_SEL0),
725 mask, 0);
726
727 return 0;
728}
729
730static int oxnas_ox820_gpio_request_enable(struct pinctrl_dev *pctldev,
731 struct pinctrl_gpio_range *range,
732 unsigned int offset)
733{
734 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
735 struct oxnas_gpio_bank *bank = gpiochip_get_data(range->gc);
736 unsigned int bank_offset = (bank->id ? PINMUX_820_BANK_OFFSET : 0);
737 u32 mask = BIT(offset - bank->gpio_chip.base);
738
739 dev_dbg(pctl->dev, "requesting gpio %d in bank %d (id %d) with mask 0x%x\n",
740 offset, bank->gpio_chip.base, bank->id, mask);
741
742 regmap_write_bits(pctl->regmap,
743 bank_offset + PINMUX_820_SECONDARY_SEL,
744 mask, 0);
745 regmap_write_bits(pctl->regmap,
746 bank_offset + PINMUX_820_TERTIARY_SEL,
747 mask, 0);
748 regmap_write_bits(pctl->regmap,
749 bank_offset + PINMUX_820_QUATERNARY_SEL,
750 mask, 0);
751 regmap_write_bits(pctl->regmap,
752 bank_offset + PINMUX_820_DEBUG_SEL,
753 mask, 0);
754 regmap_write_bits(pctl->regmap,
755 bank_offset + PINMUX_820_ALTERNATIVE_SEL,
430 mask, 0); 756 mask, 0);
431 757
432 return 0; 758 return 0;
@@ -498,17 +824,26 @@ static int oxnas_gpio_set_direction(struct pinctrl_dev *pctldev,
498 return 0; 824 return 0;
499} 825}
500 826
501static const struct pinmux_ops oxnas_pinmux_ops = { 827static const struct pinmux_ops oxnas_ox810se_pinmux_ops = {
502 .get_functions_count = oxnas_pinmux_get_functions_count, 828 .get_functions_count = oxnas_pinmux_get_functions_count,
503 .get_function_name = oxnas_pinmux_get_function_name, 829 .get_function_name = oxnas_pinmux_get_function_name,
504 .get_function_groups = oxnas_pinmux_get_function_groups, 830 .get_function_groups = oxnas_pinmux_get_function_groups,
505 .set_mux = oxnas_pinmux_enable, 831 .set_mux = oxnas_ox810se_pinmux_enable,
506 .gpio_request_enable = oxnas_gpio_request_enable, 832 .gpio_request_enable = oxnas_ox810se_gpio_request_enable,
507 .gpio_set_direction = oxnas_gpio_set_direction, 833 .gpio_set_direction = oxnas_gpio_set_direction,
508}; 834};
509 835
510static int oxnas_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, 836static const struct pinmux_ops oxnas_ox820_pinmux_ops = {
511 unsigned long *config) 837 .get_functions_count = oxnas_pinmux_get_functions_count,
838 .get_function_name = oxnas_pinmux_get_function_name,
839 .get_function_groups = oxnas_pinmux_get_function_groups,
840 .set_mux = oxnas_ox820_pinmux_enable,
841 .gpio_request_enable = oxnas_ox820_gpio_request_enable,
842 .gpio_set_direction = oxnas_gpio_set_direction,
843};
844
845static int oxnas_ox810se_pinconf_get(struct pinctrl_dev *pctldev,
846 unsigned int pin, unsigned long *config)
512{ 847{
513 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 848 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
514 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin); 849 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin);
@@ -521,8 +856,38 @@ static int oxnas_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
521 case PIN_CONFIG_BIAS_PULL_UP: 856 case PIN_CONFIG_BIAS_PULL_UP:
522 ret = regmap_read(pctl->regmap, 857 ret = regmap_read(pctl->regmap,
523 (bank->id ? 858 (bank->id ?
524 PINMUX_PULLUP_CTRL1 : 859 PINMUX_810_PULLUP_CTRL1 :
525 PINMUX_PULLUP_CTRL0), 860 PINMUX_810_PULLUP_CTRL0),
861 &arg);
862 if (ret)
863 return ret;
864
865 arg = !!(arg & mask);
866 break;
867 default:
868 return -ENOTSUPP;
869 }
870
871 *config = pinconf_to_config_packed(param, arg);
872
873 return 0;
874}
875
876static int oxnas_ox820_pinconf_get(struct pinctrl_dev *pctldev,
877 unsigned int pin, unsigned long *config)
878{
879 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
880 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin);
881 unsigned int param = pinconf_to_config_param(*config);
882 unsigned int bank_offset = (bank->id ? PINMUX_820_BANK_OFFSET : 0);
883 u32 mask = BIT(pin - bank->gpio_chip.base);
884 int ret;
885 u32 arg;
886
887 switch (param) {
888 case PIN_CONFIG_BIAS_PULL_UP:
889 ret = regmap_read(pctl->regmap,
890 bank_offset + PINMUX_820_PULLUP_CTRL,
526 &arg); 891 &arg);
527 if (ret) 892 if (ret)
528 return ret; 893 return ret;
@@ -538,8 +903,9 @@ static int oxnas_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
538 return 0; 903 return 0;
539} 904}
540 905
541static int oxnas_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 906static int oxnas_ox810se_pinconf_set(struct pinctrl_dev *pctldev,
542 unsigned long *configs, unsigned int num_configs) 907 unsigned int pin, unsigned long *configs,
908 unsigned int num_configs)
543{ 909{
544 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 910 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
545 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin); 911 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin);
@@ -561,8 +927,8 @@ static int oxnas_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
561 dev_dbg(pctl->dev, " pullup\n"); 927 dev_dbg(pctl->dev, " pullup\n");
562 regmap_write_bits(pctl->regmap, 928 regmap_write_bits(pctl->regmap,
563 (bank->id ? 929 (bank->id ?
564 PINMUX_PULLUP_CTRL1 : 930 PINMUX_810_PULLUP_CTRL1 :
565 PINMUX_PULLUP_CTRL0), 931 PINMUX_810_PULLUP_CTRL0),
566 mask, mask); 932 mask, mask);
567 break; 933 break;
568 default: 934 default:
@@ -575,18 +941,53 @@ static int oxnas_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
575 return 0; 941 return 0;
576} 942}
577 943
578static const struct pinconf_ops oxnas_pinconf_ops = { 944static int oxnas_ox820_pinconf_set(struct pinctrl_dev *pctldev,
579 .pin_config_get = oxnas_pinconf_get, 945 unsigned int pin, unsigned long *configs,
580 .pin_config_set = oxnas_pinconf_set, 946 unsigned int num_configs)
947{
948 struct oxnas_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
949 struct oxnas_gpio_bank *bank = pctl_to_bank(pctl, pin);
950 unsigned int bank_offset = (bank->id ? PINMUX_820_BANK_OFFSET : 0);
951 unsigned int param;
952 u32 arg;
953 unsigned int i;
954 u32 offset = pin - bank->gpio_chip.base;
955 u32 mask = BIT(offset);
956
957 dev_dbg(pctl->dev, "setting pin %d bank %d mask 0x%x\n",
958 pin, bank->gpio_chip.base, mask);
959
960 for (i = 0; i < num_configs; i++) {
961 param = pinconf_to_config_param(configs[i]);
962 arg = pinconf_to_config_argument(configs[i]);
963
964 switch (param) {
965 case PIN_CONFIG_BIAS_PULL_UP:
966 dev_dbg(pctl->dev, " pullup\n");
967 regmap_write_bits(pctl->regmap,
968 bank_offset + PINMUX_820_PULLUP_CTRL,
969 mask, mask);
970 break;
971 default:
972 dev_err(pctl->dev, "Property %u not supported\n",
973 param);
974 return -ENOTSUPP;
975 }
976 }
977
978 return 0;
979}
980
981static const struct pinconf_ops oxnas_ox810se_pinconf_ops = {
982 .pin_config_get = oxnas_ox810se_pinconf_get,
983 .pin_config_set = oxnas_ox810se_pinconf_set,
581 .is_generic = true, 984 .is_generic = true,
582}; 985};
583 986
584static struct pinctrl_desc oxnas_pinctrl_desc = { 987static const struct pinconf_ops oxnas_ox820_pinconf_ops = {
585 .name = "oxnas-pinctrl", 988 .pin_config_get = oxnas_ox820_pinconf_get,
586 .pctlops = &oxnas_pinctrl_ops, 989 .pin_config_set = oxnas_ox820_pinconf_set,
587 .pmxops = &oxnas_pinmux_ops, 990 .is_generic = true,
588 .confops = &oxnas_pinconf_ops,
589 .owner = THIS_MODULE,
590}; 991};
591 992
592static void oxnas_gpio_irq_ack(struct irq_data *data) 993static void oxnas_gpio_irq_ack(struct irq_data *data)
@@ -699,10 +1100,78 @@ static struct oxnas_gpio_bank oxnas_gpio_banks[] = {
699 GPIO_BANK(1), 1100 GPIO_BANK(1),
700}; 1101};
701 1102
1103static struct oxnas_pinctrl ox810se_pinctrl = {
1104 .functions = oxnas_ox810se_functions,
1105 .nfunctions = ARRAY_SIZE(oxnas_ox810se_functions),
1106 .groups = oxnas_ox810se_groups,
1107 .ngroups = ARRAY_SIZE(oxnas_ox810se_groups),
1108 .gpio_banks = oxnas_gpio_banks,
1109 .nbanks = ARRAY_SIZE(oxnas_gpio_banks),
1110};
1111
1112static struct pinctrl_desc oxnas_ox810se_pinctrl_desc = {
1113 .name = "oxnas-pinctrl",
1114 .pins = oxnas_ox810se_pins,
1115 .npins = ARRAY_SIZE(oxnas_ox810se_pins),
1116 .pctlops = &oxnas_pinctrl_ops,
1117 .pmxops = &oxnas_ox810se_pinmux_ops,
1118 .confops = &oxnas_ox810se_pinconf_ops,
1119 .owner = THIS_MODULE,
1120};
1121
1122static struct oxnas_pinctrl ox820_pinctrl = {
1123 .functions = oxnas_ox820_functions,
1124 .nfunctions = ARRAY_SIZE(oxnas_ox820_functions),
1125 .groups = oxnas_ox820_groups,
1126 .ngroups = ARRAY_SIZE(oxnas_ox820_groups),
1127 .gpio_banks = oxnas_gpio_banks,
1128 .nbanks = ARRAY_SIZE(oxnas_gpio_banks),
1129};
1130
1131static struct pinctrl_desc oxnas_ox820_pinctrl_desc = {
1132 .name = "oxnas-pinctrl",
1133 .pins = oxnas_ox820_pins,
1134 .npins = ARRAY_SIZE(oxnas_ox820_pins),
1135 .pctlops = &oxnas_pinctrl_ops,
1136 .pmxops = &oxnas_ox820_pinmux_ops,
1137 .confops = &oxnas_ox820_pinconf_ops,
1138 .owner = THIS_MODULE,
1139};
1140
1141static struct oxnas_pinctrl_data oxnas_ox810se_pinctrl_data = {
1142 .desc = &oxnas_ox810se_pinctrl_desc,
1143 .pctl = &ox810se_pinctrl,
1144};
1145
1146static struct oxnas_pinctrl_data oxnas_ox820_pinctrl_data = {
1147 .desc = &oxnas_ox820_pinctrl_desc,
1148 .pctl = &ox820_pinctrl,
1149};
1150
1151static const struct of_device_id oxnas_pinctrl_of_match[] = {
1152 { .compatible = "oxsemi,ox810se-pinctrl",
1153 .data = &oxnas_ox810se_pinctrl_data
1154 },
1155 { .compatible = "oxsemi,ox820-pinctrl",
1156 .data = &oxnas_ox820_pinctrl_data,
1157 },
1158 { },
1159};
1160
702static int oxnas_pinctrl_probe(struct platform_device *pdev) 1161static int oxnas_pinctrl_probe(struct platform_device *pdev)
703{ 1162{
1163 const struct of_device_id *id;
1164 const struct oxnas_pinctrl_data *data;
704 struct oxnas_pinctrl *pctl; 1165 struct oxnas_pinctrl *pctl;
705 1166
1167 id = of_match_node(oxnas_pinctrl_of_match, pdev->dev.of_node);
1168 if (!id)
1169 return -ENODEV;
1170
1171 data = id->data;
1172 if (!data || !data->pctl || !data->desc)
1173 return -EINVAL;
1174
706 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); 1175 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
707 if (!pctl) 1176 if (!pctl)
708 return -ENOMEM; 1177 return -ENOMEM;
@@ -716,20 +1185,14 @@ static int oxnas_pinctrl_probe(struct platform_device *pdev)
716 return -ENODEV; 1185 return -ENODEV;
717 } 1186 }
718 1187
719 pctl->pins = oxnas_pins; 1188 pctl->functions = data->pctl->functions;
720 pctl->npins = ARRAY_SIZE(oxnas_pins); 1189 pctl->nfunctions = data->pctl->nfunctions;
721 pctl->functions = oxnas_functions; 1190 pctl->groups = data->pctl->groups;
722 pctl->nfunctions = ARRAY_SIZE(oxnas_functions); 1191 pctl->ngroups = data->pctl->ngroups;
723 pctl->groups = oxnas_groups; 1192 pctl->gpio_banks = data->pctl->gpio_banks;
724 pctl->ngroups = ARRAY_SIZE(oxnas_groups); 1193 pctl->nbanks = data->pctl->nbanks;
725 pctl->gpio_banks = oxnas_gpio_banks;
726 pctl->nbanks = ARRAY_SIZE(oxnas_gpio_banks);
727
728 oxnas_pinctrl_desc.pins = pctl->pins;
729 oxnas_pinctrl_desc.npins = pctl->npins;
730 1194
731 pctl->pctldev = pinctrl_register(&oxnas_pinctrl_desc, 1195 pctl->pctldev = pinctrl_register(data->desc, &pdev->dev, pctl);
732 &pdev->dev, pctl);
733 if (IS_ERR(pctl->pctldev)) { 1196 if (IS_ERR(pctl->pctldev)) {
734 dev_err(&pdev->dev, "Failed to register pinctrl device\n"); 1197 dev_err(&pdev->dev, "Failed to register pinctrl device\n");
735 return PTR_ERR(pctl->pctldev); 1198 return PTR_ERR(pctl->pctldev);
@@ -805,11 +1268,6 @@ static int oxnas_gpio_probe(struct platform_device *pdev)
805 return 0; 1268 return 0;
806} 1269}
807 1270
808static const struct of_device_id oxnas_pinctrl_of_match[] = {
809 { .compatible = "oxsemi,ox810se-pinctrl", },
810 { },
811};
812
813static struct platform_driver oxnas_pinctrl_driver = { 1271static struct platform_driver oxnas_pinctrl_driver = {
814 .driver = { 1272 .driver = {
815 .name = "oxnas-pinctrl", 1273 .name = "oxnas-pinctrl",
@@ -821,6 +1279,7 @@ static struct platform_driver oxnas_pinctrl_driver = {
821 1279
822static const struct of_device_id oxnas_gpio_of_match[] = { 1280static const struct of_device_id oxnas_gpio_of_match[] = {
823 { .compatible = "oxsemi,ox810se-gpio", }, 1281 { .compatible = "oxsemi,ox810se-gpio", },
1282 { .compatible = "oxsemi,ox820-gpio", },
824 { }, 1283 { },
825}; 1284};
826 1285
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 49bf7dcb7ed8..08765f58253c 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -59,6 +59,7 @@
59#define GPIO_LS_SYNC 0x60 59#define GPIO_LS_SYNC 0x60
60 60
61enum rockchip_pinctrl_type { 61enum rockchip_pinctrl_type {
62 RK1108,
62 RK2928, 63 RK2928,
63 RK3066B, 64 RK3066B,
64 RK3188, 65 RK3188,
@@ -624,6 +625,65 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
624 return ret; 625 return ret;
625} 626}
626 627
628#define RK1108_PULL_PMU_OFFSET 0x10
629#define RK1108_PULL_OFFSET 0x110
630#define RK1108_PULL_PINS_PER_REG 8
631#define RK1108_PULL_BITS_PER_PIN 2
632#define RK1108_PULL_BANK_STRIDE 16
633
634static void rk1108_calc_pull_reg_and_bit(struct rockchip_pin_bank *bank,
635 int pin_num, struct regmap **regmap,
636 int *reg, u8 *bit)
637{
638 struct rockchip_pinctrl *info = bank->drvdata;
639
640 /* The first 24 pins of the first bank are located in PMU */
641 if (bank->bank_num == 0) {
642 *regmap = info->regmap_pmu;
643 *reg = RK1108_PULL_PMU_OFFSET;
644 } else {
645 *reg = RK1108_PULL_OFFSET;
646 *regmap = info->regmap_base;
647 /* correct the offset, as we're starting with the 2nd bank */
648 *reg -= 0x10;
649 *reg += bank->bank_num * RK1108_PULL_BANK_STRIDE;
650 }
651
652 *reg += ((pin_num / RK1108_PULL_PINS_PER_REG) * 4);
653 *bit = (pin_num % RK1108_PULL_PINS_PER_REG);
654 *bit *= RK1108_PULL_BITS_PER_PIN;
655}
656
657#define RK1108_DRV_PMU_OFFSET 0x20
658#define RK1108_DRV_GRF_OFFSET 0x210
659#define RK1108_DRV_BITS_PER_PIN 2
660#define RK1108_DRV_PINS_PER_REG 8
661#define RK1108_DRV_BANK_STRIDE 16
662
663static void rk1108_calc_drv_reg_and_bit(struct rockchip_pin_bank *bank,
664 int pin_num, struct regmap **regmap,
665 int *reg, u8 *bit)
666{
667 struct rockchip_pinctrl *info = bank->drvdata;
668
669 /* The first 24 pins of the first bank are located in PMU */
670 if (bank->bank_num == 0) {
671 *regmap = info->regmap_pmu;
672 *reg = RK1108_DRV_PMU_OFFSET;
673 } else {
674 *regmap = info->regmap_base;
675 *reg = RK1108_DRV_GRF_OFFSET;
676
677 /* correct the offset, as we're starting with the 2nd bank */
678 *reg -= 0x10;
679 *reg += bank->bank_num * RK1108_DRV_BANK_STRIDE;
680 }
681
682 *reg += ((pin_num / RK1108_DRV_PINS_PER_REG) * 4);
683 *bit = pin_num % RK1108_DRV_PINS_PER_REG;
684 *bit *= RK1108_DRV_BITS_PER_PIN;
685}
686
627#define RK2928_PULL_OFFSET 0x118 687#define RK2928_PULL_OFFSET 0x118
628#define RK2928_PULL_PINS_PER_REG 16 688#define RK2928_PULL_PINS_PER_REG 16
629#define RK2928_PULL_BANK_STRIDE 8 689#define RK2928_PULL_BANK_STRIDE 8
@@ -1123,6 +1183,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num)
1123 return !(data & BIT(bit)) 1183 return !(data & BIT(bit))
1124 ? PIN_CONFIG_BIAS_PULL_PIN_DEFAULT 1184 ? PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
1125 : PIN_CONFIG_BIAS_DISABLE; 1185 : PIN_CONFIG_BIAS_DISABLE;
1186 case RK1108:
1126 case RK3188: 1187 case RK3188:
1127 case RK3288: 1188 case RK3288:
1128 case RK3368: 1189 case RK3368:
@@ -1169,6 +1230,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
1169 1230
1170 spin_unlock_irqrestore(&bank->slock, flags); 1231 spin_unlock_irqrestore(&bank->slock, flags);
1171 break; 1232 break;
1233 case RK1108:
1172 case RK3188: 1234 case RK3188:
1173 case RK3288: 1235 case RK3288:
1174 case RK3368: 1236 case RK3368:
@@ -1358,6 +1420,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
1358 pull == PIN_CONFIG_BIAS_DISABLE); 1420 pull == PIN_CONFIG_BIAS_DISABLE);
1359 case RK3066B: 1421 case RK3066B:
1360 return pull ? false : true; 1422 return pull ? false : true;
1423 case RK1108:
1361 case RK3188: 1424 case RK3188:
1362 case RK3288: 1425 case RK3288:
1363 case RK3368: 1426 case RK3368:
@@ -2455,6 +2518,27 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
2455 return 0; 2518 return 0;
2456} 2519}
2457 2520
2521static struct rockchip_pin_bank rk1108_pin_banks[] = {
2522 PIN_BANK_IOMUX_FLAGS(0, 32, "gpio0", IOMUX_SOURCE_PMU,
2523 IOMUX_SOURCE_PMU,
2524 IOMUX_SOURCE_PMU,
2525 IOMUX_SOURCE_PMU),
2526 PIN_BANK_IOMUX_FLAGS(1, 32, "gpio1", 0, 0, 0, 0),
2527 PIN_BANK_IOMUX_FLAGS(2, 32, "gpio2", 0, 0, 0, 0),
2528 PIN_BANK_IOMUX_FLAGS(3, 32, "gpio3", 0, 0, 0, 0),
2529};
2530
2531static struct rockchip_pin_ctrl rk1108_pin_ctrl = {
2532 .pin_banks = rk1108_pin_banks,
2533 .nr_banks = ARRAY_SIZE(rk1108_pin_banks),
2534 .label = "RK1108-GPIO",
2535 .type = RK1108,
2536 .grf_mux_offset = 0x10,
2537 .pmu_mux_offset = 0x0,
2538 .pull_calc_reg = rk1108_calc_pull_reg_and_bit,
2539 .drv_calc_reg = rk1108_calc_drv_reg_and_bit,
2540};
2541
2458static struct rockchip_pin_bank rk2928_pin_banks[] = { 2542static struct rockchip_pin_bank rk2928_pin_banks[] = {
2459 PIN_BANK(0, 32, "gpio0"), 2543 PIN_BANK(0, 32, "gpio0"),
2460 PIN_BANK(1, 32, "gpio1"), 2544 PIN_BANK(1, 32, "gpio1"),
@@ -2684,6 +2768,8 @@ static struct rockchip_pin_ctrl rk3399_pin_ctrl = {
2684}; 2768};
2685 2769
2686static const struct of_device_id rockchip_pinctrl_dt_match[] = { 2770static const struct of_device_id rockchip_pinctrl_dt_match[] = {
2771 { .compatible = "rockchip,rk1108-pinctrl",
2772 .data = (void *)&rk1108_pin_ctrl },
2687 { .compatible = "rockchip,rk2928-pinctrl", 2773 { .compatible = "rockchip,rk2928-pinctrl",
2688 .data = (void *)&rk2928_pin_ctrl }, 2774 .data = (void *)&rk2928_pin_ctrl },
2689 { .compatible = "rockchip,rk3036-pinctrl", 2775 { .compatible = "rockchip,rk3036-pinctrl",
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index bfdf720db270..a5a0392ab817 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -31,12 +31,10 @@
31#include <linux/platform_data/pinctrl-single.h> 31#include <linux/platform_data/pinctrl-single.h>
32 32
33#include "core.h" 33#include "core.h"
34#include "devicetree.h"
34#include "pinconf.h" 35#include "pinconf.h"
35 36
36#define DRIVER_NAME "pinctrl-single" 37#define DRIVER_NAME "pinctrl-single"
37#define PCS_MUX_PINS_NAME "pinctrl-single,pins"
38#define PCS_MUX_BITS_NAME "pinctrl-single,bits"
39#define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 3)
40#define PCS_OFF_DISABLED ~0U 38#define PCS_OFF_DISABLED ~0U
41 39
42/** 40/**
@@ -142,20 +140,6 @@ struct pcs_data {
142}; 140};
143 141
144/** 142/**
145 * struct pcs_name - register name for a pin
146 * @name: name of the pinctrl register
147 *
148 * REVISIT: We may want to make names optional in the pinctrl
149 * framework as some drivers may not care about pin names to
150 * avoid kernel bloat. The pin names can be deciphered by user
151 * space tools using debugfs based on the register address and
152 * SoC packaging information.
153 */
154struct pcs_name {
155 char name[PCS_REG_NAME_LEN];
156};
157
158/**
159 * struct pcs_soc_data - SoC specific settings 143 * struct pcs_soc_data - SoC specific settings
160 * @flags: initial SoC specific PCS_FEAT_xxx values 144 * @flags: initial SoC specific PCS_FEAT_xxx values
161 * @irq: optional interrupt for the controller 145 * @irq: optional interrupt for the controller
@@ -177,8 +161,11 @@ struct pcs_soc_data {
177 * @base: virtual address of the controller 161 * @base: virtual address of the controller
178 * @size: size of the ioremapped area 162 * @size: size of the ioremapped area
179 * @dev: device entry 163 * @dev: device entry
164 * @np: device tree node
180 * @pctl: pin controller device 165 * @pctl: pin controller device
181 * @flags: mask of PCS_FEAT_xxx values 166 * @flags: mask of PCS_FEAT_xxx values
167 * @missing_nr_pinctrl_cells: for legacy binding, may go away
168 * @socdata: soc specific data
182 * @lock: spinlock for register access 169 * @lock: spinlock for register access
183 * @mutex: mutex protecting the lists 170 * @mutex: mutex protecting the lists
184 * @width: bits per mux register 171 * @width: bits per mux register
@@ -186,8 +173,8 @@ struct pcs_soc_data {
186 * @fshift: function register shift 173 * @fshift: function register shift
187 * @foff: value to turn mux off 174 * @foff: value to turn mux off
188 * @fmax: max number of functions in fmask 175 * @fmax: max number of functions in fmask
189 * @bits_per_pin:number of bits per pin 176 * @bits_per_mux: number of bits per mux
190 * @names: array of register names for pins 177 * @bits_per_pin: number of bits per pin
191 * @pins: physical pins on the SoC 178 * @pins: physical pins on the SoC
192 * @pgtree: pingroup index radix tree 179 * @pgtree: pingroup index radix tree
193 * @ftree: function index radix tree 180 * @ftree: function index radix tree
@@ -208,11 +195,13 @@ struct pcs_device {
208 void __iomem *base; 195 void __iomem *base;
209 unsigned size; 196 unsigned size;
210 struct device *dev; 197 struct device *dev;
198 struct device_node *np;
211 struct pinctrl_dev *pctl; 199 struct pinctrl_dev *pctl;
212 unsigned flags; 200 unsigned flags;
213#define PCS_QUIRK_SHARED_IRQ (1 << 2) 201#define PCS_QUIRK_SHARED_IRQ (1 << 2)
214#define PCS_FEAT_IRQ (1 << 1) 202#define PCS_FEAT_IRQ (1 << 1)
215#define PCS_FEAT_PINCONF (1 << 0) 203#define PCS_FEAT_PINCONF (1 << 0)
204 struct property *missing_nr_pinctrl_cells;
216 struct pcs_soc_data socdata; 205 struct pcs_soc_data socdata;
217 raw_spinlock_t lock; 206 raw_spinlock_t lock;
218 struct mutex mutex; 207 struct mutex mutex;
@@ -223,7 +212,6 @@ struct pcs_device {
223 unsigned fmax; 212 unsigned fmax;
224 bool bits_per_mux; 213 bool bits_per_mux;
225 unsigned bits_per_pin; 214 unsigned bits_per_pin;
226 struct pcs_name *names;
227 struct pcs_data pins; 215 struct pcs_data pins;
228 struct radix_tree_root pgtree; 216 struct radix_tree_root pgtree;
229 struct radix_tree_root ftree; 217 struct radix_tree_root ftree;
@@ -354,13 +342,17 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
354{ 342{
355 struct pcs_device *pcs; 343 struct pcs_device *pcs;
356 unsigned val, mux_bytes; 344 unsigned val, mux_bytes;
345 unsigned long offset;
346 size_t pa;
357 347
358 pcs = pinctrl_dev_get_drvdata(pctldev); 348 pcs = pinctrl_dev_get_drvdata(pctldev);
359 349
360 mux_bytes = pcs->width / BITS_PER_BYTE; 350 mux_bytes = pcs->width / BITS_PER_BYTE;
361 val = pcs->read(pcs->base + pin * mux_bytes); 351 offset = pin * mux_bytes;
352 val = pcs->read(pcs->base + offset);
353 pa = pcs->res->start + offset;
362 354
363 seq_printf(s, "%08x %s " , val, DRIVER_NAME); 355 seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
364} 356}
365 357
366static void pcs_dt_free_map(struct pinctrl_dev *pctldev, 358static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
@@ -763,7 +755,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
763{ 755{
764 struct pcs_soc_data *pcs_soc = &pcs->socdata; 756 struct pcs_soc_data *pcs_soc = &pcs->socdata;
765 struct pinctrl_pin_desc *pin; 757 struct pinctrl_pin_desc *pin;
766 struct pcs_name *pn;
767 int i; 758 int i;
768 759
769 i = pcs->pins.cur; 760 i = pcs->pins.cur;
@@ -786,10 +777,6 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
786 } 777 }
787 778
788 pin = &pcs->pins.pa[i]; 779 pin = &pcs->pins.pa[i];
789 pn = &pcs->names[i];
790 sprintf(pn->name, "%lx.%u",
791 (unsigned long)pcs->res->start + offset, pin_pos);
792 pin->name = pn->name;
793 pin->number = i; 780 pin->number = i;
794 pcs->pins.cur++; 781 pcs->pins.cur++;
795 782
@@ -827,12 +814,6 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
827 if (!pcs->pins.pa) 814 if (!pcs->pins.pa)
828 return -ENOMEM; 815 return -ENOMEM;
829 816
830 pcs->names = devm_kzalloc(pcs->dev,
831 sizeof(struct pcs_name) * nr_pins,
832 GFP_KERNEL);
833 if (!pcs->names)
834 return -ENOMEM;
835
836 pcs->desc.pins = pcs->pins.pa; 817 pcs->desc.pins = pcs->pins.pa;
837 pcs->desc.npins = nr_pins; 818 pcs->desc.npins = nr_pins;
838 819
@@ -1146,21 +1127,17 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
1146 unsigned *num_maps, 1127 unsigned *num_maps,
1147 const char **pgnames) 1128 const char **pgnames)
1148{ 1129{
1130 const char *name = "pinctrl-single,pins";
1149 struct pcs_func_vals *vals; 1131 struct pcs_func_vals *vals;
1150 const __be32 *mux; 1132 int rows, *pins, found = 0, res = -ENOMEM, i;
1151 int size, rows, *pins, index = 0, found = 0, res = -ENOMEM;
1152 struct pcs_function *function; 1133 struct pcs_function *function;
1153 1134
1154 mux = of_get_property(np, PCS_MUX_PINS_NAME, &size); 1135 rows = pinctrl_count_index_with_args(np, name);
1155 if ((!mux) || (size < sizeof(*mux) * 2)) { 1136 if (rows <= 0) {
1156 dev_err(pcs->dev, "bad data for mux %s\n", 1137 dev_err(pcs->dev, "Ivalid number of rows: %d\n", rows);
1157 np->name);
1158 return -EINVAL; 1138 return -EINVAL;
1159 } 1139 }
1160 1140
1161 size /= sizeof(*mux); /* Number of elements in array */
1162 rows = size / 2;
1163
1164 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL); 1141 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
1165 if (!vals) 1142 if (!vals)
1166 return -ENOMEM; 1143 return -ENOMEM;
@@ -1169,14 +1146,28 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
1169 if (!pins) 1146 if (!pins)
1170 goto free_vals; 1147 goto free_vals;
1171 1148
1172 while (index < size) { 1149 for (i = 0; i < rows; i++) {
1173 unsigned offset, val; 1150 struct of_phandle_args pinctrl_spec;
1151 unsigned int offset;
1174 int pin; 1152 int pin;
1175 1153
1176 offset = be32_to_cpup(mux + index++); 1154 res = pinctrl_parse_index_with_args(np, name, i, &pinctrl_spec);
1177 val = be32_to_cpup(mux + index++); 1155 if (res)
1156 return res;
1157
1158 if (pinctrl_spec.args_count < 2) {
1159 dev_err(pcs->dev, "invalid args_count for spec: %i\n",
1160 pinctrl_spec.args_count);
1161 break;
1162 }
1163
1164 /* Index plus one value cell */
1165 offset = pinctrl_spec.args[0];
1178 vals[found].reg = pcs->base + offset; 1166 vals[found].reg = pcs->base + offset;
1179 vals[found].val = val; 1167 vals[found].val = pinctrl_spec.args[1];
1168
1169 dev_dbg(pcs->dev, "%s index: 0x%x value: 0x%x\n",
1170 pinctrl_spec.np->name, offset, pinctrl_spec.args[1]);
1180 1171
1181 pin = pcs_get_pin_by_offset(pcs, offset); 1172 pin = pcs_get_pin_by_offset(pcs, offset);
1182 if (pin < 0) { 1173 if (pin < 0) {
@@ -1190,8 +1181,10 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
1190 1181
1191 pgnames[0] = np->name; 1182 pgnames[0] = np->name;
1192 function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1); 1183 function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1);
1193 if (!function) 1184 if (!function) {
1185 res = -ENOMEM;
1194 goto free_pins; 1186 goto free_pins;
1187 }
1195 1188
1196 res = pcs_add_pingroup(pcs, np, np->name, pins, found); 1189 res = pcs_add_pingroup(pcs, np, np->name, pins, found);
1197 if (res < 0) 1190 if (res < 0)
@@ -1226,36 +1219,24 @@ free_vals:
1226 return res; 1219 return res;
1227} 1220}
1228 1221
1229#define PARAMS_FOR_BITS_PER_MUX 3
1230
1231static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, 1222static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1232 struct device_node *np, 1223 struct device_node *np,
1233 struct pinctrl_map **map, 1224 struct pinctrl_map **map,
1234 unsigned *num_maps, 1225 unsigned *num_maps,
1235 const char **pgnames) 1226 const char **pgnames)
1236{ 1227{
1228 const char *name = "pinctrl-single,bits";
1237 struct pcs_func_vals *vals; 1229 struct pcs_func_vals *vals;
1238 const __be32 *mux; 1230 int rows, *pins, found = 0, res = -ENOMEM, i;
1239 int size, rows, *pins, index = 0, found = 0, res = -ENOMEM;
1240 int npins_in_row; 1231 int npins_in_row;
1241 struct pcs_function *function; 1232 struct pcs_function *function;
1242 1233
1243 mux = of_get_property(np, PCS_MUX_BITS_NAME, &size); 1234 rows = pinctrl_count_index_with_args(np, name);
1244 1235 if (rows <= 0) {
1245 if (!mux) { 1236 dev_err(pcs->dev, "Invalid number of rows: %d\n", rows);
1246 dev_err(pcs->dev, "no valid property for %s\n", np->name);
1247 return -EINVAL;
1248 }
1249
1250 if (size < (sizeof(*mux) * PARAMS_FOR_BITS_PER_MUX)) {
1251 dev_err(pcs->dev, "bad data for %s\n", np->name);
1252 return -EINVAL; 1237 return -EINVAL;
1253 } 1238 }
1254 1239
1255 /* Number of elements in array */
1256 size /= sizeof(*mux);
1257
1258 rows = size / PARAMS_FOR_BITS_PER_MUX;
1259 npins_in_row = pcs->width / pcs->bits_per_pin; 1240 npins_in_row = pcs->width / pcs->bits_per_pin;
1260 1241
1261 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row, 1242 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row,
@@ -1268,15 +1249,30 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1268 if (!pins) 1249 if (!pins)
1269 goto free_vals; 1250 goto free_vals;
1270 1251
1271 while (index < size) { 1252 for (i = 0; i < rows; i++) {
1253 struct of_phandle_args pinctrl_spec;
1272 unsigned offset, val; 1254 unsigned offset, val;
1273 unsigned mask, bit_pos, val_pos, mask_pos, submask; 1255 unsigned mask, bit_pos, val_pos, mask_pos, submask;
1274 unsigned pin_num_from_lsb; 1256 unsigned pin_num_from_lsb;
1275 int pin; 1257 int pin;
1276 1258
1277 offset = be32_to_cpup(mux + index++); 1259 res = pinctrl_parse_index_with_args(np, name, i, &pinctrl_spec);
1278 val = be32_to_cpup(mux + index++); 1260 if (res)
1279 mask = be32_to_cpup(mux + index++); 1261 return res;
1262
1263 if (pinctrl_spec.args_count < 3) {
1264 dev_err(pcs->dev, "invalid args_count for spec: %i\n",
1265 pinctrl_spec.args_count);
1266 break;
1267 }
1268
1269 /* Index plus two value cells */
1270 offset = pinctrl_spec.args[0];
1271 val = pinctrl_spec.args[1];
1272 mask = pinctrl_spec.args[2];
1273
1274 dev_dbg(pcs->dev, "%s index: 0x%x value: 0x%x mask: 0x%x\n",
1275 pinctrl_spec.np->name, offset, val, mask);
1280 1276
1281 /* Parse pins in each row from LSB */ 1277 /* Parse pins in each row from LSB */
1282 while (mask) { 1278 while (mask) {
@@ -1319,8 +1315,10 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1319 1315
1320 pgnames[0] = np->name; 1316 pgnames[0] = np->name;
1321 function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1); 1317 function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1);
1322 if (!function) 1318 if (!function) {
1319 res = -ENOMEM;
1323 goto free_pins; 1320 goto free_pins;
1321 }
1324 1322
1325 res = pcs_add_pingroup(pcs, np, np->name, pins, found); 1323 res = pcs_add_pingroup(pcs, np, np->name, pins, found);
1326 if (res < 0) 1324 if (res < 0)
@@ -1494,17 +1492,12 @@ static void pcs_free_resources(struct pcs_device *pcs)
1494 pinctrl_unregister(pcs->pctl); 1492 pinctrl_unregister(pcs->pctl);
1495 pcs_free_funcs(pcs); 1493 pcs_free_funcs(pcs);
1496 pcs_free_pingroups(pcs); 1494 pcs_free_pingroups(pcs);
1495#if IS_BUILTIN(CONFIG_PINCTRL_SINGLE)
1496 if (pcs->missing_nr_pinctrl_cells)
1497 of_remove_property(pcs->np, pcs->missing_nr_pinctrl_cells);
1498#endif
1497} 1499}
1498 1500
1499#define PCS_GET_PROP_U32(name, reg, err) \
1500 do { \
1501 ret = of_property_read_u32(np, name, reg); \
1502 if (ret) { \
1503 dev_err(pcs->dev, err); \
1504 return ret; \
1505 } \
1506 } while (0);
1507
1508static const struct of_device_id pcs_of_match[]; 1501static const struct of_device_id pcs_of_match[];
1509 1502
1510static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs) 1503static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)
@@ -1820,6 +1813,55 @@ static int pinctrl_single_resume(struct platform_device *pdev)
1820} 1813}
1821#endif 1814#endif
1822 1815
1816/**
1817 * pcs_quirk_missing_pinctrl_cells - handle legacy binding
1818 * @pcs: pinctrl driver instance
1819 * @np: device tree node
1820 * @cells: number of cells
1821 *
1822 * Handle legacy binding with no #pinctrl-cells. This should be
1823 * always two pinctrl-single,bit-per-mux and one for others.
1824 * At some point we may want to consider removing this.
1825 */
1826static int pcs_quirk_missing_pinctrl_cells(struct pcs_device *pcs,
1827 struct device_node *np,
1828 int cells)
1829{
1830 struct property *p;
1831 const char *name = "#pinctrl-cells";
1832 int error;
1833 u32 val;
1834
1835 error = of_property_read_u32(np, name, &val);
1836 if (!error)
1837 return 0;
1838
1839 dev_warn(pcs->dev, "please update dts to use %s = <%i>\n",
1840 name, cells);
1841
1842 p = devm_kzalloc(pcs->dev, sizeof(*p), GFP_KERNEL);
1843 if (!p)
1844 return -ENOMEM;
1845
1846 p->length = sizeof(__be32);
1847 p->value = devm_kzalloc(pcs->dev, sizeof(__be32), GFP_KERNEL);
1848 if (!p->value)
1849 return -ENOMEM;
1850 *(__be32 *)p->value = cpu_to_be32(cells);
1851
1852 p->name = devm_kstrdup(pcs->dev, name, GFP_KERNEL);
1853 if (!p->name)
1854 return -ENOMEM;
1855
1856 pcs->missing_nr_pinctrl_cells = p;
1857
1858#if IS_BUILTIN(CONFIG_PINCTRL_SINGLE)
1859 error = of_add_property(np, pcs->missing_nr_pinctrl_cells);
1860#endif
1861
1862 return error;
1863}
1864
1823static int pcs_probe(struct platform_device *pdev) 1865static int pcs_probe(struct platform_device *pdev)
1824{ 1866{
1825 struct device_node *np = pdev->dev.of_node; 1867 struct device_node *np = pdev->dev.of_node;
@@ -1840,6 +1882,7 @@ static int pcs_probe(struct platform_device *pdev)
1840 return -ENOMEM; 1882 return -ENOMEM;
1841 } 1883 }
1842 pcs->dev = &pdev->dev; 1884 pcs->dev = &pdev->dev;
1885 pcs->np = np;
1843 raw_spin_lock_init(&pcs->lock); 1886 raw_spin_lock_init(&pcs->lock);
1844 mutex_init(&pcs->mutex); 1887 mutex_init(&pcs->mutex);
1845 INIT_LIST_HEAD(&pcs->pingroups); 1888 INIT_LIST_HEAD(&pcs->pingroups);
@@ -1849,8 +1892,13 @@ static int pcs_probe(struct platform_device *pdev)
1849 pcs->flags = soc->flags; 1892 pcs->flags = soc->flags;
1850 memcpy(&pcs->socdata, soc, sizeof(*soc)); 1893 memcpy(&pcs->socdata, soc, sizeof(*soc));
1851 1894
1852 PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width, 1895 ret = of_property_read_u32(np, "pinctrl-single,register-width",
1853 "register width not specified\n"); 1896 &pcs->width);
1897 if (ret) {
1898 dev_err(pcs->dev, "register width not specified\n");
1899
1900 return ret;
1901 }
1854 1902
1855 ret = of_property_read_u32(np, "pinctrl-single,function-mask", 1903 ret = of_property_read_u32(np, "pinctrl-single,function-mask",
1856 &pcs->fmask); 1904 &pcs->fmask);
@@ -1871,6 +1919,13 @@ static int pcs_probe(struct platform_device *pdev)
1871 1919
1872 pcs->bits_per_mux = of_property_read_bool(np, 1920 pcs->bits_per_mux = of_property_read_bool(np,
1873 "pinctrl-single,bit-per-mux"); 1921 "pinctrl-single,bit-per-mux");
1922 ret = pcs_quirk_missing_pinctrl_cells(pcs, np,
1923 pcs->bits_per_mux ? 2 : 1);
1924 if (ret) {
1925 dev_err(&pdev->dev, "unable to patch #pinctrl-cells\n");
1926
1927 return ret;
1928 }
1874 1929
1875 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1930 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1876 if (!res) { 1931 if (!res) {
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index b7bb37167969..676efcc032d2 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1006,7 +1006,7 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,
1006 1006
1007 function = st_pctl_get_pin_function(pc, offset); 1007 function = st_pctl_get_pin_function(pc, offset);
1008 if (function) 1008 if (function)
1009 snprintf(f, 10, "Alt Fn %d", function); 1009 snprintf(f, 10, "Alt Fn %u", function);
1010 else 1010 else
1011 snprintf(f, 5, "GPIO"); 1011 snprintf(f, 5, "GPIO");
1012 1012
@@ -1181,7 +1181,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
1181 if (!strcmp(pp->name, "name")) 1181 if (!strcmp(pp->name, "name"))
1182 continue; 1182 continue;
1183 1183
1184 if (pp && (pp->length/sizeof(__be32)) >= OF_GPIO_ARGS_MIN) { 1184 if (pp->length / sizeof(__be32) >= OF_GPIO_ARGS_MIN) {
1185 npins++; 1185 npins++;
1186 } else { 1186 } else {
1187 pr_warn("Invalid st,pins in %s node\n", np->name); 1187 pr_warn("Invalid st,pins in %s node\n", np->name);
diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
index d2d4211e615e..29fb7403d24e 100644
--- a/drivers/pinctrl/pinctrl-sx150x.c
+++ b/drivers/pinctrl/pinctrl-sx150x.c
@@ -5,6 +5,7 @@
5 * Copyright (c) 2010, Code Aurora Forum. All rights reserved. 5 * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
6 * 6 *
7 * Driver for Semtech SX150X I2C GPIO Expanders 7 * Driver for Semtech SX150X I2C GPIO Expanders
8 * The handling of the 4-bit chips (SX1501/SX1504/SX1507) is untested.
8 * 9 *
9 * Author: Gregory Bean <gbean@codeaurora.org> 10 * Author: Gregory Bean <gbean@codeaurora.org>
10 * 11 *
@@ -18,6 +19,7 @@
18 * GNU General Public License for more details. 19 * GNU General Public License for more details.
19 */ 20 */
20 21
22#include <linux/regmap.h>
21#include <linux/i2c.h> 23#include <linux/i2c.h>
22#include <linux/init.h> 24#include <linux/init.h>
23#include <linux/interrupt.h> 25#include <linux/interrupt.h>
@@ -25,8 +27,8 @@
25#include <linux/mutex.h> 27#include <linux/mutex.h>
26#include <linux/slab.h> 28#include <linux/slab.h>
27#include <linux/of.h> 29#include <linux/of.h>
28#include <linux/gpio.h> 30#include <linux/of_device.h>
29#include <linux/pinctrl/machine.h> 31#include <linux/gpio/driver.h>
30#include <linux/pinctrl/pinconf.h> 32#include <linux/pinctrl/pinconf.h>
31#include <linux/pinctrl/pinctrl.h> 33#include <linux/pinctrl/pinctrl.h>
32#include <linux/pinctrl/pinmux.h> 34#include <linux/pinctrl/pinmux.h>
@@ -42,6 +44,14 @@ enum {
42 SX150X_456, 44 SX150X_456,
43 SX150X_789, 45 SX150X_789,
44}; 46};
47enum {
48 SX150X_789_REG_MISC_AUTOCLEAR_OFF = 1 << 0,
49 SX150X_MAX_REGISTER = 0xad,
50 SX150X_IRQ_TYPE_EDGE_RISING = 0x1,
51 SX150X_IRQ_TYPE_EDGE_FALLING = 0x2,
52 SX150X_789_RESET_KEY1 = 0x12,
53 SX150X_789_RESET_KEY2 = 0x34,
54};
45 55
46struct sx150x_123_pri { 56struct sx150x_123_pri {
47 u8 reg_pld_mode; 57 u8 reg_pld_mode;
@@ -50,7 +60,7 @@ struct sx150x_123_pri {
50 u8 reg_pld_table2; 60 u8 reg_pld_table2;
51 u8 reg_pld_table3; 61 u8 reg_pld_table3;
52 u8 reg_pld_table4; 62 u8 reg_pld_table4;
53 u8 reg_advance; 63 u8 reg_advanced;
54}; 64};
55 65
56struct sx150x_456_pri { 66struct sx150x_456_pri {
@@ -60,7 +70,7 @@ struct sx150x_456_pri {
60 u8 reg_pld_table2; 70 u8 reg_pld_table2;
61 u8 reg_pld_table3; 71 u8 reg_pld_table3;
62 u8 reg_pld_table4; 72 u8 reg_pld_table4;
63 u8 reg_advance; 73 u8 reg_advanced;
64}; 74};
65 75
66struct sx150x_789_pri { 76struct sx150x_789_pri {
@@ -98,17 +108,23 @@ struct sx150x_pinctrl {
98 struct pinctrl_desc pinctrl_desc; 108 struct pinctrl_desc pinctrl_desc;
99 struct gpio_chip gpio; 109 struct gpio_chip gpio;
100 struct irq_chip irq_chip; 110 struct irq_chip irq_chip;
111 struct regmap *regmap;
101 struct { 112 struct {
102 int update;
103 u32 sense; 113 u32 sense;
104 u32 masked; 114 u32 masked;
105 u32 dev_sense;
106 u32 dev_masked;
107 } irq; 115 } irq;
108 struct mutex lock; 116 struct mutex lock;
109 const struct sx150x_device_data *data; 117 const struct sx150x_device_data *data;
110}; 118};
111 119
120static const struct pinctrl_pin_desc sx150x_4_pins[] = {
121 PINCTRL_PIN(0, "gpio0"),
122 PINCTRL_PIN(1, "gpio1"),
123 PINCTRL_PIN(2, "gpio2"),
124 PINCTRL_PIN(3, "gpio3"),
125 PINCTRL_PIN(4, "oscio"),
126};
127
112static const struct pinctrl_pin_desc sx150x_8_pins[] = { 128static const struct pinctrl_pin_desc sx150x_8_pins[] = {
113 PINCTRL_PIN(0, "gpio0"), 129 PINCTRL_PIN(0, "gpio0"),
114 PINCTRL_PIN(1, "gpio1"), 130 PINCTRL_PIN(1, "gpio1"),
@@ -141,179 +157,198 @@ static const struct pinctrl_pin_desc sx150x_16_pins[] = {
141 PINCTRL_PIN(16, "oscio"), 157 PINCTRL_PIN(16, "oscio"),
142}; 158};
143 159
144static const struct sx150x_device_data sx1508q_device_data = { 160static const struct sx150x_device_data sx1501q_device_data = {
145 .model = SX150X_789, 161 .model = SX150X_123,
146 .reg_pullup = 0x03, 162 .reg_pullup = 0x02,
147 .reg_pulldn = 0x04, 163 .reg_pulldn = 0x03,
148 .reg_dir = 0x07, 164 .reg_dir = 0x01,
149 .reg_data = 0x08, 165 .reg_data = 0x00,
150 .reg_irq_mask = 0x09, 166 .reg_irq_mask = 0x05,
151 .reg_irq_src = 0x0c, 167 .reg_irq_src = 0x08,
152 .reg_sense = 0x0b, 168 .reg_sense = 0x07,
153 .pri.x789 = { 169 .pri.x123 = {
154 .reg_drain = 0x05, 170 .reg_pld_mode = 0x10,
155 .reg_polarity = 0x06, 171 .reg_pld_table0 = 0x11,
156 .reg_clock = 0x0f, 172 .reg_pld_table2 = 0x13,
157 .reg_misc = 0x10, 173 .reg_advanced = 0xad,
158 .reg_reset = 0x7d,
159 }, 174 },
160 .ngpios = 8, 175 .ngpios = 4,
176 .pins = sx150x_4_pins,
177 .npins = 4, /* oscio not available */
178};
179
180static const struct sx150x_device_data sx1502q_device_data = {
181 .model = SX150X_123,
182 .reg_pullup = 0x02,
183 .reg_pulldn = 0x03,
184 .reg_dir = 0x01,
185 .reg_data = 0x00,
186 .reg_irq_mask = 0x05,
187 .reg_irq_src = 0x08,
188 .reg_sense = 0x06,
189 .pri.x123 = {
190 .reg_pld_mode = 0x10,
191 .reg_pld_table0 = 0x11,
192 .reg_pld_table1 = 0x12,
193 .reg_pld_table2 = 0x13,
194 .reg_pld_table3 = 0x14,
195 .reg_pld_table4 = 0x15,
196 .reg_advanced = 0xad,
197 },
198 .ngpios = 8,
161 .pins = sx150x_8_pins, 199 .pins = sx150x_8_pins,
162 .npins = ARRAY_SIZE(sx150x_8_pins), 200 .npins = 8, /* oscio not available */
163}; 201};
164 202
165static const struct sx150x_device_data sx1509q_device_data = { 203static const struct sx150x_device_data sx1503q_device_data = {
166 .model = SX150X_789, 204 .model = SX150X_123,
167 .reg_pullup = 0x07, 205 .reg_pullup = 0x04,
168 .reg_pulldn = 0x09, 206 .reg_pulldn = 0x06,
169 .reg_dir = 0x0f, 207 .reg_dir = 0x02,
170 .reg_data = 0x11, 208 .reg_data = 0x00,
171 .reg_irq_mask = 0x13, 209 .reg_irq_mask = 0x08,
172 .reg_irq_src = 0x19, 210 .reg_irq_src = 0x0e,
173 .reg_sense = 0x17, 211 .reg_sense = 0x0a,
174 .pri.x789 = { 212 .pri.x123 = {
175 .reg_drain = 0x0b, 213 .reg_pld_mode = 0x20,
176 .reg_polarity = 0x0d, 214 .reg_pld_table0 = 0x22,
177 .reg_clock = 0x1e, 215 .reg_pld_table1 = 0x24,
178 .reg_misc = 0x1f, 216 .reg_pld_table2 = 0x26,
179 .reg_reset = 0x7d, 217 .reg_pld_table3 = 0x28,
218 .reg_pld_table4 = 0x2a,
219 .reg_advanced = 0xad,
180 }, 220 },
181 .ngpios = 16, 221 .ngpios = 16,
182 .pins = sx150x_16_pins, 222 .pins = sx150x_16_pins,
183 .npins = ARRAY_SIZE(sx150x_16_pins), 223 .npins = 16, /* oscio not available */
184}; 224};
185 225
186static const struct sx150x_device_data sx1506q_device_data = { 226static const struct sx150x_device_data sx1504q_device_data = {
187 .model = SX150X_456, 227 .model = SX150X_456,
188 .reg_pullup = 0x05, 228 .reg_pullup = 0x02,
189 .reg_pulldn = 0x07, 229 .reg_pulldn = 0x03,
190 .reg_dir = 0x03, 230 .reg_dir = 0x01,
191 .reg_data = 0x01, 231 .reg_data = 0x00,
192 .reg_irq_mask = 0x09, 232 .reg_irq_mask = 0x05,
193 .reg_irq_src = 0x0f, 233 .reg_irq_src = 0x08,
194 .reg_sense = 0x0d, 234 .reg_sense = 0x07,
195 .pri.x456 = { 235 .pri.x456 = {
196 .reg_pld_mode = 0x21, 236 .reg_pld_mode = 0x10,
197 .reg_pld_table0 = 0x23, 237 .reg_pld_table0 = 0x11,
198 .reg_pld_table1 = 0x25, 238 .reg_pld_table2 = 0x13,
199 .reg_pld_table2 = 0x27,
200 .reg_pld_table3 = 0x29,
201 .reg_pld_table4 = 0x2b,
202 .reg_advance = 0xad,
203 }, 239 },
204 .ngpios = 16, 240 .ngpios = 4,
205 .pins = sx150x_16_pins, 241 .pins = sx150x_4_pins,
206 .npins = 16, /* oscio not available */ 242 .npins = 4, /* oscio not available */
207}; 243};
208 244
209static const struct sx150x_device_data sx1502q_device_data = { 245static const struct sx150x_device_data sx1505q_device_data = {
210 .model = SX150X_123, 246 .model = SX150X_456,
211 .reg_pullup = 0x02, 247 .reg_pullup = 0x02,
212 .reg_pulldn = 0x03, 248 .reg_pulldn = 0x03,
213 .reg_dir = 0x01, 249 .reg_dir = 0x01,
214 .reg_data = 0x00, 250 .reg_data = 0x00,
215 .reg_irq_mask = 0x05, 251 .reg_irq_mask = 0x05,
216 .reg_irq_src = 0x08, 252 .reg_irq_src = 0x08,
217 .reg_sense = 0x07, 253 .reg_sense = 0x06,
218 .pri.x123 = { 254 .pri.x456 = {
219 .reg_pld_mode = 0x10, 255 .reg_pld_mode = 0x10,
220 .reg_pld_table0 = 0x11, 256 .reg_pld_table0 = 0x11,
221 .reg_pld_table1 = 0x12, 257 .reg_pld_table1 = 0x12,
222 .reg_pld_table2 = 0x13, 258 .reg_pld_table2 = 0x13,
223 .reg_pld_table3 = 0x14, 259 .reg_pld_table3 = 0x14,
224 .reg_pld_table4 = 0x15, 260 .reg_pld_table4 = 0x15,
225 .reg_advance = 0xad,
226 }, 261 },
227 .ngpios = 8, 262 .ngpios = 8,
228 .pins = sx150x_8_pins, 263 .pins = sx150x_8_pins,
229 .npins = 8, /* oscio not available */ 264 .npins = 8, /* oscio not available */
230}; 265};
231 266
232static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val) 267static const struct sx150x_device_data sx1506q_device_data = {
233{ 268 .model = SX150X_456,
234 s32 err = i2c_smbus_write_byte_data(client, reg, val); 269 .reg_pullup = 0x04,
235 270 .reg_pulldn = 0x06,
236 if (err < 0) 271 .reg_dir = 0x02,
237 dev_warn(&client->dev, 272 .reg_data = 0x00,
238 "i2c write fail: can't write %02x to %02x: %d\n", 273 .reg_irq_mask = 0x08,
239 val, reg, err); 274 .reg_irq_src = 0x0e,
240 return err; 275 .reg_sense = 0x0a,
241} 276 .pri.x456 = {
242 277 .reg_pld_mode = 0x20,
243static s32 sx150x_i2c_read(struct i2c_client *client, u8 reg, u8 *val) 278 .reg_pld_table0 = 0x22,
244{ 279 .reg_pld_table1 = 0x24,
245 s32 err = i2c_smbus_read_byte_data(client, reg); 280 .reg_pld_table2 = 0x26,
246 281 .reg_pld_table3 = 0x28,
247 if (err >= 0) 282 .reg_pld_table4 = 0x2a,
248 *val = err; 283 .reg_advanced = 0xad,
249 else 284 },
250 dev_warn(&client->dev, 285 .ngpios = 16,
251 "i2c read fail: can't read from %02x: %d\n", 286 .pins = sx150x_16_pins,
252 reg, err); 287 .npins = 16, /* oscio not available */
253 return err; 288};
254}
255
256/*
257 * These utility functions solve the common problem of locating and setting
258 * configuration bits. Configuration bits are grouped into registers
259 * whose indexes increase downwards. For example, with eight-bit registers,
260 * sixteen gpios would have their config bits grouped in the following order:
261 * REGISTER N-1 [ f e d c b a 9 8 ]
262 * N [ 7 6 5 4 3 2 1 0 ]
263 *
264 * For multi-bit configurations, the pattern gets wider:
265 * REGISTER N-3 [ f f e e d d c c ]
266 * N-2 [ b b a a 9 9 8 8 ]
267 * N-1 [ 7 7 6 6 5 5 4 4 ]
268 * N [ 3 3 2 2 1 1 0 0 ]
269 *
270 * Given the address of the starting register 'N', the index of the gpio
271 * whose configuration we seek to change, and the width in bits of that
272 * configuration, these functions allow us to locate the correct
273 * register and mask the correct bits.
274 */
275static inline void sx150x_find_cfg(u8 offset, u8 width,
276 u8 *reg, u8 *mask, u8 *shift)
277{
278 *reg -= offset * width / 8;
279 *mask = (1 << width) - 1;
280 *shift = (offset * width) % 8;
281 *mask <<= *shift;
282}
283
284static int sx150x_write_cfg(struct i2c_client *client,
285 u8 offset, u8 width, u8 reg, u8 val)
286{
287 u8 mask;
288 u8 data;
289 u8 shift;
290 int err;
291
292 sx150x_find_cfg(offset, width, &reg, &mask, &shift);
293 err = sx150x_i2c_read(client, reg, &data);
294 if (err < 0)
295 return err;
296
297 data &= ~mask;
298 data |= (val << shift) & mask;
299 return sx150x_i2c_write(client, reg, data);
300}
301 289
302static int sx150x_read_cfg(struct i2c_client *client, 290static const struct sx150x_device_data sx1507q_device_data = {
303 u8 offset, u8 width, u8 reg) 291 .model = SX150X_789,
304{ 292 .reg_pullup = 0x03,
305 u8 mask; 293 .reg_pulldn = 0x04,
306 u8 data; 294 .reg_dir = 0x07,
307 u8 shift; 295 .reg_data = 0x08,
308 int err; 296 .reg_irq_mask = 0x09,
297 .reg_irq_src = 0x0b,
298 .reg_sense = 0x0a,
299 .pri.x789 = {
300 .reg_drain = 0x05,
301 .reg_polarity = 0x06,
302 .reg_clock = 0x0d,
303 .reg_misc = 0x0e,
304 .reg_reset = 0x7d,
305 },
306 .ngpios = 4,
307 .pins = sx150x_4_pins,
308 .npins = ARRAY_SIZE(sx150x_4_pins),
309};
309 310
310 sx150x_find_cfg(offset, width, &reg, &mask, &shift); 311static const struct sx150x_device_data sx1508q_device_data = {
311 err = sx150x_i2c_read(client, reg, &data); 312 .model = SX150X_789,
312 if (err < 0) 313 .reg_pullup = 0x03,
313 return err; 314 .reg_pulldn = 0x04,
315 .reg_dir = 0x07,
316 .reg_data = 0x08,
317 .reg_irq_mask = 0x09,
318 .reg_irq_src = 0x0c,
319 .reg_sense = 0x0a,
320 .pri.x789 = {
321 .reg_drain = 0x05,
322 .reg_polarity = 0x06,
323 .reg_clock = 0x0f,
324 .reg_misc = 0x10,
325 .reg_reset = 0x7d,
326 },
327 .ngpios = 8,
328 .pins = sx150x_8_pins,
329 .npins = ARRAY_SIZE(sx150x_8_pins),
330};
314 331
315 return (data & mask); 332static const struct sx150x_device_data sx1509q_device_data = {
316} 333 .model = SX150X_789,
334 .reg_pullup = 0x06,
335 .reg_pulldn = 0x08,
336 .reg_dir = 0x0e,
337 .reg_data = 0x10,
338 .reg_irq_mask = 0x12,
339 .reg_irq_src = 0x18,
340 .reg_sense = 0x14,
341 .pri.x789 = {
342 .reg_drain = 0x0a,
343 .reg_polarity = 0x0c,
344 .reg_clock = 0x1e,
345 .reg_misc = 0x1f,
346 .reg_reset = 0x7d,
347 },
348 .ngpios = 16,
349 .pins = sx150x_16_pins,
350 .npins = ARRAY_SIZE(sx150x_16_pins),
351};
317 352
318static int sx150x_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) 353static int sx150x_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
319{ 354{
@@ -360,31 +395,33 @@ static int sx150x_gpio_get_direction(struct gpio_chip *chip,
360 unsigned int offset) 395 unsigned int offset)
361{ 396{
362 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); 397 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
363 int status; 398 unsigned int value;
399 int ret;
364 400
365 if (sx150x_pin_is_oscio(pctl, offset)) 401 if (sx150x_pin_is_oscio(pctl, offset))
366 return false; 402 return false;
367 403
368 status = sx150x_read_cfg(pctl->client, offset, 1, pctl->data->reg_dir); 404 ret = regmap_read(pctl->regmap, pctl->data->reg_dir, &value);
369 if (status >= 0) 405 if (ret < 0)
370 status = !!status; 406 return ret;
371 407
372 return status; 408 return !!(value & BIT(offset));
373} 409}
374 410
375static int sx150x_gpio_get(struct gpio_chip *chip, unsigned int offset) 411static int sx150x_gpio_get(struct gpio_chip *chip, unsigned int offset)
376{ 412{
377 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); 413 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
378 int status; 414 unsigned int value;
415 int ret;
379 416
380 if (sx150x_pin_is_oscio(pctl, offset)) 417 if (sx150x_pin_is_oscio(pctl, offset))
381 return -EINVAL; 418 return -EINVAL;
382 419
383 status = sx150x_read_cfg(pctl->client, offset, 1, pctl->data->reg_data); 420 ret = regmap_read(pctl->regmap, pctl->data->reg_data, &value);
384 if (status >= 0) 421 if (ret < 0)
385 status = !!status; 422 return ret;
386 423
387 return status; 424 return !!(value & BIT(offset));
388} 425}
389 426
390static int sx150x_gpio_set_single_ended(struct gpio_chip *chip, 427static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
@@ -400,13 +437,9 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
400 sx150x_pin_is_oscio(pctl, offset)) 437 sx150x_pin_is_oscio(pctl, offset))
401 return 0; 438 return 0;
402 439
403 mutex_lock(&pctl->lock); 440 ret = regmap_write_bits(pctl->regmap,
404 ret = sx150x_write_cfg(pctl->client, offset, 1, 441 pctl->data->pri.x789.reg_drain,
405 pctl->data->pri.x789.reg_drain, 442 BIT(offset), 0);
406 0);
407 mutex_unlock(&pctl->lock);
408 if (ret < 0)
409 return ret;
410 break; 443 break;
411 444
412 case LINE_MODE_OPEN_DRAIN: 445 case LINE_MODE_OPEN_DRAIN:
@@ -414,81 +447,83 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
414 sx150x_pin_is_oscio(pctl, offset)) 447 sx150x_pin_is_oscio(pctl, offset))
415 return -ENOTSUPP; 448 return -ENOTSUPP;
416 449
417 mutex_lock(&pctl->lock); 450 ret = regmap_write_bits(pctl->regmap,
418 ret = sx150x_write_cfg(pctl->client, offset, 1, 451 pctl->data->pri.x789.reg_drain,
419 pctl->data->pri.x789.reg_drain, 452 BIT(offset), BIT(offset));
420 1);
421 mutex_unlock(&pctl->lock);
422 if (ret < 0)
423 return ret;
424 break; 453 break;
425
426 default: 454 default:
427 return -ENOTSUPP; 455 ret = -ENOTSUPP;
456 break;
428 } 457 }
429 458
430 return 0; 459 return ret;
460}
461
462static int __sx150x_gpio_set(struct sx150x_pinctrl *pctl, unsigned int offset,
463 int value)
464{
465 return regmap_write_bits(pctl->regmap, pctl->data->reg_data,
466 BIT(offset), value ? BIT(offset) : 0);
467}
468
469static int sx150x_gpio_oscio_set(struct sx150x_pinctrl *pctl,
470 int value)
471{
472 return regmap_write(pctl->regmap,
473 pctl->data->pri.x789.reg_clock,
474 (value ? 0x1f : 0x10));
431} 475}
432 476
433static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset, 477static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset,
434 int value) 478 int value)
435{ 479{
436 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); 480 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
437 481
438 if (sx150x_pin_is_oscio(pctl, offset)) { 482 if (sx150x_pin_is_oscio(pctl, offset))
483 sx150x_gpio_oscio_set(pctl, value);
484 else
485 __sx150x_gpio_set(pctl, offset, value);
439 486
440 mutex_lock(&pctl->lock); 487}
441 sx150x_i2c_write(pctl->client, 488
442 pctl->data->pri.x789.reg_clock, 489static void sx150x_gpio_set_multiple(struct gpio_chip *chip,
443 (value ? 0x1f : 0x10)); 490 unsigned long *mask,
444 mutex_unlock(&pctl->lock); 491 unsigned long *bits)
445 } else { 492{
446 mutex_lock(&pctl->lock); 493 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
447 sx150x_write_cfg(pctl->client, offset, 1, 494
448 pctl->data->reg_data, 495 regmap_write_bits(pctl->regmap, pctl->data->reg_data, *mask, *bits);
449 (value ? 1 : 0));
450 mutex_unlock(&pctl->lock);
451 }
452} 496}
453 497
454static int sx150x_gpio_direction_input(struct gpio_chip *chip, 498static int sx150x_gpio_direction_input(struct gpio_chip *chip,
455 unsigned int offset) 499 unsigned int offset)
456{ 500{
457 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); 501 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
458 int ret;
459 502
460 if (sx150x_pin_is_oscio(pctl, offset)) 503 if (sx150x_pin_is_oscio(pctl, offset))
461 return -EINVAL; 504 return -EINVAL;
462 505
463 mutex_lock(&pctl->lock); 506 return regmap_write_bits(pctl->regmap,
464 ret = sx150x_write_cfg(pctl->client, offset, 1, 507 pctl->data->reg_dir,
465 pctl->data->reg_dir, 1); 508 BIT(offset), BIT(offset));
466 mutex_unlock(&pctl->lock);
467
468 return ret;
469} 509}
470 510
471static int sx150x_gpio_direction_output(struct gpio_chip *chip, 511static int sx150x_gpio_direction_output(struct gpio_chip *chip,
472 unsigned int offset, int value) 512 unsigned int offset, int value)
473{ 513{
474 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); 514 struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
475 int status; 515 int ret;
476 516
477 if (sx150x_pin_is_oscio(pctl, offset)) { 517 if (sx150x_pin_is_oscio(pctl, offset))
478 sx150x_gpio_set(chip, offset, value); 518 return sx150x_gpio_oscio_set(pctl, value);
479 return 0;
480 }
481 519
482 mutex_lock(&pctl->lock); 520 ret = __sx150x_gpio_set(pctl, offset, value);
483 status = sx150x_write_cfg(pctl->client, offset, 1, 521 if (ret < 0)
484 pctl->data->reg_data, 522 return ret;
485 (value ? 1 : 0));
486 if (status >= 0)
487 status = sx150x_write_cfg(pctl->client, offset, 1,
488 pctl->data->reg_dir, 0);
489 mutex_unlock(&pctl->lock);
490 523
491 return status; 524 return regmap_write_bits(pctl->regmap,
525 pctl->data->reg_dir,
526 BIT(offset), 0);
492} 527}
493 528
494static void sx150x_irq_mask(struct irq_data *d) 529static void sx150x_irq_mask(struct irq_data *d)
@@ -497,8 +532,7 @@ static void sx150x_irq_mask(struct irq_data *d)
497 gpiochip_get_data(irq_data_get_irq_chip_data(d)); 532 gpiochip_get_data(irq_data_get_irq_chip_data(d));
498 unsigned int n = d->hwirq; 533 unsigned int n = d->hwirq;
499 534
500 pctl->irq.masked |= (1 << n); 535 pctl->irq.masked |= BIT(n);
501 pctl->irq.update = n;
502} 536}
503 537
504static void sx150x_irq_unmask(struct irq_data *d) 538static void sx150x_irq_unmask(struct irq_data *d)
@@ -507,8 +541,22 @@ static void sx150x_irq_unmask(struct irq_data *d)
507 gpiochip_get_data(irq_data_get_irq_chip_data(d)); 541 gpiochip_get_data(irq_data_get_irq_chip_data(d));
508 unsigned int n = d->hwirq; 542 unsigned int n = d->hwirq;
509 543
510 pctl->irq.masked &= ~(1 << n); 544 pctl->irq.masked &= ~BIT(n);
511 pctl->irq.update = n; 545}
546
547static void sx150x_irq_set_sense(struct sx150x_pinctrl *pctl,
548 unsigned int line, unsigned int sense)
549{
550 /*
551 * Every interrupt line is represented by two bits shifted
552 * proportionally to the line number
553 */
554 const unsigned int n = line * 2;
555 const unsigned int mask = ~((SX150X_IRQ_TYPE_EDGE_RISING |
556 SX150X_IRQ_TYPE_EDGE_FALLING) << n);
557
558 pctl->irq.sense &= mask;
559 pctl->irq.sense |= sense << n;
512} 560}
513 561
514static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type) 562static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
@@ -523,51 +571,34 @@ static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
523 n = d->hwirq; 571 n = d->hwirq;
524 572
525 if (flow_type & IRQ_TYPE_EDGE_RISING) 573 if (flow_type & IRQ_TYPE_EDGE_RISING)
526 val |= 0x1; 574 val |= SX150X_IRQ_TYPE_EDGE_RISING;
527 if (flow_type & IRQ_TYPE_EDGE_FALLING) 575 if (flow_type & IRQ_TYPE_EDGE_FALLING)
528 val |= 0x2; 576 val |= SX150X_IRQ_TYPE_EDGE_FALLING;
529 577
530 pctl->irq.sense &= ~(3UL << (n * 2)); 578 sx150x_irq_set_sense(pctl, n, val);
531 pctl->irq.sense |= val << (n * 2);
532 pctl->irq.update = n;
533 return 0; 579 return 0;
534} 580}
535 581
536static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id) 582static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id)
537{ 583{
538 struct sx150x_pinctrl *pctl = (struct sx150x_pinctrl *)dev_id; 584 struct sx150x_pinctrl *pctl = (struct sx150x_pinctrl *)dev_id;
539 unsigned int nhandled = 0; 585 unsigned long n, status;
540 unsigned int sub_irq; 586 unsigned int val;
541 unsigned int n; 587 int err;
542 s32 err;
543 u8 val;
544 int i;
545 588
546 for (i = (pctl->data->ngpios / 8) - 1; i >= 0; --i) { 589 err = regmap_read(pctl->regmap, pctl->data->reg_irq_src, &val);
547 err = sx150x_i2c_read(pctl->client, 590 if (err < 0)
548 pctl->data->reg_irq_src - i, 591 return IRQ_NONE;
549 &val);
550 if (err < 0)
551 continue;
552 592
553 err = sx150x_i2c_write(pctl->client, 593 err = regmap_write(pctl->regmap, pctl->data->reg_irq_src, val);
554 pctl->data->reg_irq_src - i, 594 if (err < 0)
555 val); 595 return IRQ_NONE;
556 if (err < 0)
557 continue;
558
559 for (n = 0; n < 8; ++n) {
560 if (val & (1 << n)) {
561 sub_irq = irq_find_mapping(
562 pctl->gpio.irqdomain,
563 (i * 8) + n);
564 handle_nested_irq(sub_irq);
565 ++nhandled;
566 }
567 }
568 }
569 596
570 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); 597 status = val;
598 for_each_set_bit(n, &status, pctl->data->ngpios)
599 handle_nested_irq(irq_find_mapping(pctl->gpio.irqdomain, n));
600
601 return IRQ_HANDLED;
571} 602}
572 603
573static void sx150x_irq_bus_lock(struct irq_data *d) 604static void sx150x_irq_bus_lock(struct irq_data *d)
@@ -582,35 +613,9 @@ static void sx150x_irq_bus_sync_unlock(struct irq_data *d)
582{ 613{
583 struct sx150x_pinctrl *pctl = 614 struct sx150x_pinctrl *pctl =
584 gpiochip_get_data(irq_data_get_irq_chip_data(d)); 615 gpiochip_get_data(irq_data_get_irq_chip_data(d));
585 unsigned int n;
586
587 if (pctl->irq.update < 0)
588 goto out;
589 616
590 n = pctl->irq.update; 617 regmap_write(pctl->regmap, pctl->data->reg_irq_mask, pctl->irq.masked);
591 pctl->irq.update = -1; 618 regmap_write(pctl->regmap, pctl->data->reg_sense, pctl->irq.sense);
592
593 /* Avoid updates if nothing changed */
594 if (pctl->irq.dev_sense == pctl->irq.sense &&
595 pctl->irq.dev_masked == pctl->irq.masked)
596 goto out;
597
598 pctl->irq.dev_sense = pctl->irq.sense;
599 pctl->irq.dev_masked = pctl->irq.masked;
600
601 if (pctl->irq.masked & (1 << n)) {
602 sx150x_write_cfg(pctl->client, n, 1,
603 pctl->data->reg_irq_mask, 1);
604 sx150x_write_cfg(pctl->client, n, 2,
605 pctl->data->reg_sense, 0);
606 } else {
607 sx150x_write_cfg(pctl->client, n, 1,
608 pctl->data->reg_irq_mask, 0);
609 sx150x_write_cfg(pctl->client, n, 2,
610 pctl->data->reg_sense,
611 pctl->irq.sense >> (n * 2));
612 }
613out:
614 mutex_unlock(&pctl->lock); 619 mutex_unlock(&pctl->lock);
615} 620}
616 621
@@ -621,19 +626,15 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
621 unsigned int param = pinconf_to_config_param(*config); 626 unsigned int param = pinconf_to_config_param(*config);
622 int ret; 627 int ret;
623 u32 arg; 628 u32 arg;
629 unsigned int data;
624 630
625 if (sx150x_pin_is_oscio(pctl, pin)) { 631 if (sx150x_pin_is_oscio(pctl, pin)) {
626 u8 data;
627
628 switch (param) { 632 switch (param) {
629 case PIN_CONFIG_DRIVE_PUSH_PULL: 633 case PIN_CONFIG_DRIVE_PUSH_PULL:
630 case PIN_CONFIG_OUTPUT: 634 case PIN_CONFIG_OUTPUT:
631 mutex_lock(&pctl->lock); 635 ret = regmap_read(pctl->regmap,
632 ret = sx150x_i2c_read(pctl->client, 636 pctl->data->pri.x789.reg_clock,
633 pctl->data->pri.x789.reg_clock, 637 &data);
634 &data);
635 mutex_unlock(&pctl->lock);
636
637 if (ret < 0) 638 if (ret < 0)
638 return ret; 639 return ret;
639 640
@@ -658,10 +659,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
658 659
659 switch (param) { 660 switch (param) {
660 case PIN_CONFIG_BIAS_PULL_DOWN: 661 case PIN_CONFIG_BIAS_PULL_DOWN:
661 mutex_lock(&pctl->lock); 662 ret = regmap_read(pctl->regmap,
662 ret = sx150x_read_cfg(pctl->client, pin, 1, 663 pctl->data->reg_pulldn,
663 pctl->data->reg_pulldn); 664 &data);
664 mutex_unlock(&pctl->lock); 665 data &= BIT(pin);
665 666
666 if (ret < 0) 667 if (ret < 0)
667 return ret; 668 return ret;
@@ -673,10 +674,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
673 break; 674 break;
674 675
675 case PIN_CONFIG_BIAS_PULL_UP: 676 case PIN_CONFIG_BIAS_PULL_UP:
676 mutex_lock(&pctl->lock); 677 ret = regmap_read(pctl->regmap,
677 ret = sx150x_read_cfg(pctl->client, pin, 1, 678 pctl->data->reg_pullup,
678 pctl->data->reg_pullup); 679 &data);
679 mutex_unlock(&pctl->lock); 680 data &= BIT(pin);
680 681
681 if (ret < 0) 682 if (ret < 0)
682 return ret; 683 return ret;
@@ -691,15 +692,15 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
691 if (pctl->data->model != SX150X_789) 692 if (pctl->data->model != SX150X_789)
692 return -ENOTSUPP; 693 return -ENOTSUPP;
693 694
694 mutex_lock(&pctl->lock); 695 ret = regmap_read(pctl->regmap,
695 ret = sx150x_read_cfg(pctl->client, pin, 1, 696 pctl->data->pri.x789.reg_drain,
696 pctl->data->pri.x789.reg_drain); 697 &data);
697 mutex_unlock(&pctl->lock); 698 data &= BIT(pin);
698 699
699 if (ret < 0) 700 if (ret < 0)
700 return ret; 701 return ret;
701 702
702 if (!ret) 703 if (!data)
703 return -EINVAL; 704 return -EINVAL;
704 705
705 arg = 1; 706 arg = 1;
@@ -709,15 +710,15 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
709 if (pctl->data->model != SX150X_789) 710 if (pctl->data->model != SX150X_789)
710 arg = true; 711 arg = true;
711 else { 712 else {
712 mutex_lock(&pctl->lock); 713 ret = regmap_read(pctl->regmap,
713 ret = sx150x_read_cfg(pctl->client, pin, 1, 714 pctl->data->pri.x789.reg_drain,
714 pctl->data->pri.x789.reg_drain); 715 &data);
715 mutex_unlock(&pctl->lock); 716 data &= BIT(pin);
716 717
717 if (ret < 0) 718 if (ret < 0)
718 return ret; 719 return ret;
719 720
720 if (ret) 721 if (data)
721 return -EINVAL; 722 return -EINVAL;
722 723
723 arg = 1; 724 arg = 1;
@@ -777,39 +778,33 @@ static int sx150x_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
777 switch (param) { 778 switch (param) {
778 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: 779 case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
779 case PIN_CONFIG_BIAS_DISABLE: 780 case PIN_CONFIG_BIAS_DISABLE:
780 mutex_lock(&pctl->lock); 781 ret = regmap_write_bits(pctl->regmap,
781 ret = sx150x_write_cfg(pctl->client, pin, 1, 782 pctl->data->reg_pulldn,
782 pctl->data->reg_pulldn, 0); 783 BIT(pin), 0);
783 mutex_unlock(&pctl->lock);
784 if (ret < 0) 784 if (ret < 0)
785 return ret; 785 return ret;
786 786
787 mutex_lock(&pctl->lock); 787 ret = regmap_write_bits(pctl->regmap,
788 ret = sx150x_write_cfg(pctl->client, pin, 1, 788 pctl->data->reg_pullup,
789 pctl->data->reg_pullup, 0); 789 BIT(pin), 0);
790 mutex_unlock(&pctl->lock);
791 if (ret < 0) 790 if (ret < 0)
792 return ret; 791 return ret;
793 792
794 break; 793 break;
795 794
796 case PIN_CONFIG_BIAS_PULL_UP: 795 case PIN_CONFIG_BIAS_PULL_UP:
797 mutex_lock(&pctl->lock); 796 ret = regmap_write_bits(pctl->regmap,
798 ret = sx150x_write_cfg(pctl->client, pin, 1, 797 pctl->data->reg_pullup,
799 pctl->data->reg_pullup, 798 BIT(pin), BIT(pin));
800 1);
801 mutex_unlock(&pctl->lock);
802 if (ret < 0) 799 if (ret < 0)
803 return ret; 800 return ret;
804 801
805 break; 802 break;
806 803
807 case PIN_CONFIG_BIAS_PULL_DOWN: 804 case PIN_CONFIG_BIAS_PULL_DOWN:
808 mutex_lock(&pctl->lock); 805 ret = regmap_write_bits(pctl->regmap,
809 ret = sx150x_write_cfg(pctl->client, pin, 1, 806 pctl->data->reg_pulldn,
810 pctl->data->reg_pulldn, 807 BIT(pin), BIT(pin));
811 1);
812 mutex_unlock(&pctl->lock);
813 if (ret < 0) 808 if (ret < 0)
814 return ret; 809 return ret;
815 810
@@ -854,49 +849,86 @@ static const struct pinconf_ops sx150x_pinconf_ops = {
854}; 849};
855 850
856static const struct i2c_device_id sx150x_id[] = { 851static const struct i2c_device_id sx150x_id[] = {
852 {"sx1501q", (kernel_ulong_t) &sx1501q_device_data },
853 {"sx1502q", (kernel_ulong_t) &sx1502q_device_data },
854 {"sx1503q", (kernel_ulong_t) &sx1503q_device_data },
855 {"sx1504q", (kernel_ulong_t) &sx1504q_device_data },
856 {"sx1505q", (kernel_ulong_t) &sx1505q_device_data },
857 {"sx1506q", (kernel_ulong_t) &sx1506q_device_data },
858 {"sx1507q", (kernel_ulong_t) &sx1507q_device_data },
857 {"sx1508q", (kernel_ulong_t) &sx1508q_device_data }, 859 {"sx1508q", (kernel_ulong_t) &sx1508q_device_data },
858 {"sx1509q", (kernel_ulong_t) &sx1509q_device_data }, 860 {"sx1509q", (kernel_ulong_t) &sx1509q_device_data },
859 {"sx1506q", (kernel_ulong_t) &sx1506q_device_data },
860 {"sx1502q", (kernel_ulong_t) &sx1502q_device_data },
861 {} 861 {}
862}; 862};
863 863
864static const struct of_device_id sx150x_of_match[] = { 864static const struct of_device_id sx150x_of_match[] = {
865 { .compatible = "semtech,sx1508q" }, 865 { .compatible = "semtech,sx1501q", .data = &sx1501q_device_data },
866 { .compatible = "semtech,sx1509q" }, 866 { .compatible = "semtech,sx1502q", .data = &sx1502q_device_data },
867 { .compatible = "semtech,sx1506q" }, 867 { .compatible = "semtech,sx1503q", .data = &sx1503q_device_data },
868 { .compatible = "semtech,sx1502q" }, 868 { .compatible = "semtech,sx1504q", .data = &sx1504q_device_data },
869 { .compatible = "semtech,sx1505q", .data = &sx1505q_device_data },
870 { .compatible = "semtech,sx1506q", .data = &sx1506q_device_data },
871 { .compatible = "semtech,sx1507q", .data = &sx1507q_device_data },
872 { .compatible = "semtech,sx1508q", .data = &sx1508q_device_data },
873 { .compatible = "semtech,sx1509q", .data = &sx1509q_device_data },
869 {}, 874 {},
870}; 875};
871 876
872static int sx150x_init_io(struct sx150x_pinctrl *pctl, u8 base, u16 cfg)
873{
874 int err = 0;
875 unsigned int n;
876
877 for (n = 0; err >= 0 && n < (pctl->data->ngpios / 8); ++n)
878 err = sx150x_i2c_write(pctl->client, base - n, cfg >> (n * 8));
879 return err;
880}
881
882static int sx150x_reset(struct sx150x_pinctrl *pctl) 877static int sx150x_reset(struct sx150x_pinctrl *pctl)
883{ 878{
884 int err; 879 int err;
885 880
886 err = i2c_smbus_write_byte_data(pctl->client, 881 err = i2c_smbus_write_byte_data(pctl->client,
887 pctl->data->pri.x789.reg_reset, 882 pctl->data->pri.x789.reg_reset,
888 0x12); 883 SX150X_789_RESET_KEY1);
889 if (err < 0) 884 if (err < 0)
890 return err; 885 return err;
891 886
892 err = i2c_smbus_write_byte_data(pctl->client, 887 err = i2c_smbus_write_byte_data(pctl->client,
893 pctl->data->pri.x789.reg_reset, 888 pctl->data->pri.x789.reg_reset,
894 0x34); 889 SX150X_789_RESET_KEY2);
895 return err; 890 return err;
896} 891}
897 892
893static int sx150x_init_misc(struct sx150x_pinctrl *pctl)
894{
895 u8 reg, value;
896
897 switch (pctl->data->model) {
898 case SX150X_789:
899 reg = pctl->data->pri.x789.reg_misc;
900 value = SX150X_789_REG_MISC_AUTOCLEAR_OFF;
901 break;
902 case SX150X_456:
903 reg = pctl->data->pri.x456.reg_advanced;
904 value = 0x00;
905
906 /*
907 * Only SX1506 has RegAdvanced, SX1504/5 are expected
908 * to initialize this offset to zero
909 */
910 if (!reg)
911 return 0;
912 break;
913 case SX150X_123:
914 reg = pctl->data->pri.x123.reg_advanced;
915 value = 0x00;
916 break;
917 default:
918 WARN(1, "Unknown chip model %d\n", pctl->data->model);
919 return -EINVAL;
920 }
921
922 return regmap_write(pctl->regmap, reg, value);
923}
924
898static int sx150x_init_hw(struct sx150x_pinctrl *pctl) 925static int sx150x_init_hw(struct sx150x_pinctrl *pctl)
899{ 926{
927 const u8 reg[] = {
928 [SX150X_789] = pctl->data->pri.x789.reg_polarity,
929 [SX150X_456] = pctl->data->pri.x456.reg_pld_mode,
930 [SX150X_123] = pctl->data->pri.x123.reg_pld_mode,
931 };
900 int err; 932 int err;
901 933
902 if (pctl->data->model == SX150X_789 && 934 if (pctl->data->model == SX150X_789 &&
@@ -906,47 +938,193 @@ static int sx150x_init_hw(struct sx150x_pinctrl *pctl)
906 return err; 938 return err;
907 } 939 }
908 940
909 if (pctl->data->model == SX150X_789) 941 err = sx150x_init_misc(pctl);
910 err = sx150x_i2c_write(pctl->client,
911 pctl->data->pri.x789.reg_misc,
912 0x01);
913 else if (pctl->data->model == SX150X_456)
914 err = sx150x_i2c_write(pctl->client,
915 pctl->data->pri.x456.reg_advance,
916 0x04);
917 else
918 err = sx150x_i2c_write(pctl->client,
919 pctl->data->pri.x123.reg_advance,
920 0x00);
921 if (err < 0) 942 if (err < 0)
922 return err; 943 return err;
923 944
924 /* Set all pins to work in normal mode */ 945 /* Set all pins to work in normal mode */
925 if (pctl->data->model == SX150X_789) { 946 return regmap_write(pctl->regmap, reg[pctl->data->model], 0);
926 err = sx150x_init_io(pctl, 947}
927 pctl->data->pri.x789.reg_polarity, 948
928 0); 949static int sx150x_regmap_reg_width(struct sx150x_pinctrl *pctl,
929 if (err < 0) 950 unsigned int reg)
930 return err; 951{
931 } else if (pctl->data->model == SX150X_456) { 952 const struct sx150x_device_data *data = pctl->data;
932 /* Set all pins to work in normal mode */ 953
933 err = sx150x_init_io(pctl, 954 if (reg == data->reg_sense) {
934 pctl->data->pri.x456.reg_pld_mode, 955 /*
935 0); 956 * RegSense packs two bits of configuration per GPIO,
936 if (err < 0) 957 * so we'd need to read twice as many bits as there
937 return err; 958 * are GPIO in our chip
959 */
960 return 2 * data->ngpios;
961 } else if ((data->model == SX150X_789 &&
962 (reg == data->pri.x789.reg_misc ||
963 reg == data->pri.x789.reg_clock ||
964 reg == data->pri.x789.reg_reset))
965 ||
966 (data->model == SX150X_123 &&
967 reg == data->pri.x123.reg_advanced)
968 ||
969 (data->model == SX150X_456 &&
970 data->pri.x456.reg_advanced &&
971 reg == data->pri.x456.reg_advanced)) {
972 return 8;
938 } else { 973 } else {
939 /* Set all pins to work in normal mode */ 974 return data->ngpios;
940 err = sx150x_init_io(pctl, 975 }
941 pctl->data->pri.x123.reg_pld_mode, 976}
942 0); 977
943 if (err < 0) 978static unsigned int sx150x_maybe_swizzle(struct sx150x_pinctrl *pctl,
944 return err; 979 unsigned int reg, unsigned int val)
980{
981 unsigned int a, b;
982 const struct sx150x_device_data *data = pctl->data;
983
984 /*
985 * Whereas SX1509 presents RegSense in a simple layout as such:
986 * reg [ f f e e d d c c ]
987 * reg + 1 [ b b a a 9 9 8 8 ]
988 * reg + 2 [ 7 7 6 6 5 5 4 4 ]
989 * reg + 3 [ 3 3 2 2 1 1 0 0 ]
990 *
991 * SX1503 and SX1506 deviate from that data layout, instead storing
992 * their contents as follows:
993 *
994 * reg [ f f e e d d c c ]
995 * reg + 1 [ 7 7 6 6 5 5 4 4 ]
996 * reg + 2 [ b b a a 9 9 8 8 ]
997 * reg + 3 [ 3 3 2 2 1 1 0 0 ]
998 *
999 * so, taking that into account, we swap two
1000 * inner bytes of a 4-byte result
1001 */
1002
1003 if (reg == data->reg_sense &&
1004 data->ngpios == 16 &&
1005 (data->model == SX150X_123 ||
1006 data->model == SX150X_456)) {
1007 a = val & 0x00ff0000;
1008 b = val & 0x0000ff00;
1009
1010 val &= 0xff0000ff;
1011 val |= b << 8;
1012 val |= a >> 8;
1013 }
1014
1015 return val;
1016}
1017
1018/*
1019 * In order to mask the differences between 16 and 8 bit expander
1020 * devices we set up a sligthly ficticious regmap that pretends to be
1021 * a set of 32-bit (to accomodate RegSenseLow/RegSenseHigh
1022 * pair/quartet) registers and transparently reconstructs those
1023 * registers via multiple I2C/SMBus reads
1024 *
1025 * This way the rest of the driver code, interfacing with the chip via
1026 * regmap API, can work assuming that each GPIO pin is represented by
1027 * a group of bits at an offset proportional to GPIO number within a
1028 * given register.
1029 */
1030static int sx150x_regmap_reg_read(void *context, unsigned int reg,
1031 unsigned int *result)
1032{
1033 int ret, n;
1034 struct sx150x_pinctrl *pctl = context;
1035 struct i2c_client *i2c = pctl->client;
1036 const int width = sx150x_regmap_reg_width(pctl, reg);
1037 unsigned int idx, val;
1038
1039 /*
1040 * There are four potential cases covered by this function:
1041 *
1042 * 1) 8-pin chip, single configuration bit register
1043 *
1044 * This is trivial the code below just needs to read:
1045 * reg [ 7 6 5 4 3 2 1 0 ]
1046 *
1047 * 2) 8-pin chip, double configuration bit register (RegSense)
1048 *
1049 * The read will be done as follows:
1050 * reg [ 7 7 6 6 5 5 4 4 ]
1051 * reg + 1 [ 3 3 2 2 1 1 0 0 ]
1052 *
1053 * 3) 16-pin chip, single configuration bit register
1054 *
1055 * The read will be done as follows:
1056 * reg [ f e d c b a 9 8 ]
1057 * reg + 1 [ 7 6 5 4 3 2 1 0 ]
1058 *
1059 * 4) 16-pin chip, double configuration bit register (RegSense)
1060 *
1061 * The read will be done as follows:
1062 * reg [ f f e e d d c c ]
1063 * reg + 1 [ b b a a 9 9 8 8 ]
1064 * reg + 2 [ 7 7 6 6 5 5 4 4 ]
1065 * reg + 3 [ 3 3 2 2 1 1 0 0 ]
1066 */
1067
1068 for (n = width, val = 0, idx = reg; n > 0; n -= 8, idx++) {
1069 val <<= 8;
1070
1071 ret = i2c_smbus_read_byte_data(i2c, idx);
1072 if (ret < 0)
1073 return ret;
1074
1075 val |= ret;
945 } 1076 }
946 1077
1078 *result = sx150x_maybe_swizzle(pctl, reg, val);
1079
1080 return 0;
1081}
1082
1083static int sx150x_regmap_reg_write(void *context, unsigned int reg,
1084 unsigned int val)
1085{
1086 int ret, n;
1087 struct sx150x_pinctrl *pctl = context;
1088 struct i2c_client *i2c = pctl->client;
1089 const int width = sx150x_regmap_reg_width(pctl, reg);
1090
1091 val = sx150x_maybe_swizzle(pctl, reg, val);
1092
1093 n = (width - 1) & ~7;
1094 do {
1095 const u8 byte = (val >> n) & 0xff;
1096
1097 ret = i2c_smbus_write_byte_data(i2c, reg, byte);
1098 if (ret < 0)
1099 return ret;
1100
1101 reg++;
1102 n -= 8;
1103 } while (n >= 0);
1104
947 return 0; 1105 return 0;
948} 1106}
949 1107
1108static bool sx150x_reg_volatile(struct device *dev, unsigned int reg)
1109{
1110 struct sx150x_pinctrl *pctl = i2c_get_clientdata(to_i2c_client(dev));
1111
1112 return reg == pctl->data->reg_irq_src || reg == pctl->data->reg_data;
1113}
1114
1115const struct regmap_config sx150x_regmap_config = {
1116 .reg_bits = 8,
1117 .val_bits = 32,
1118
1119 .cache_type = REGCACHE_RBTREE,
1120
1121 .reg_read = sx150x_regmap_reg_read,
1122 .reg_write = sx150x_regmap_reg_write,
1123
1124 .max_register = SX150X_MAX_REGISTER,
1125 .volatile_reg = sx150x_reg_volatile,
1126};
1127
950static int sx150x_probe(struct i2c_client *client, 1128static int sx150x_probe(struct i2c_client *client,
951 const struct i2c_device_id *id) 1129 const struct i2c_device_id *id)
952{ 1130{
@@ -956,9 +1134,6 @@ static int sx150x_probe(struct i2c_client *client,
956 struct sx150x_pinctrl *pctl; 1134 struct sx150x_pinctrl *pctl;
957 int ret; 1135 int ret;
958 1136
959 if (!id->driver_data)
960 return -EINVAL;
961
962 if (!i2c_check_functionality(client->adapter, i2c_funcs)) 1137 if (!i2c_check_functionality(client->adapter, i2c_funcs))
963 return -ENOSYS; 1138 return -ENOSYS;
964 1139
@@ -966,9 +1141,27 @@ static int sx150x_probe(struct i2c_client *client,
966 if (!pctl) 1141 if (!pctl)
967 return -ENOMEM; 1142 return -ENOMEM;
968 1143
1144 i2c_set_clientdata(client, pctl);
1145
969 pctl->dev = dev; 1146 pctl->dev = dev;
970 pctl->client = client; 1147 pctl->client = client;
971 pctl->data = (void *)id->driver_data; 1148
1149 if (dev->of_node)
1150 pctl->data = of_device_get_match_data(dev);
1151 else
1152 pctl->data = (struct sx150x_device_data *)id->driver_data;
1153
1154 if (!pctl->data)
1155 return -EINVAL;
1156
1157 pctl->regmap = devm_regmap_init(dev, NULL, pctl,
1158 &sx150x_regmap_config);
1159 if (IS_ERR(pctl->regmap)) {
1160 ret = PTR_ERR(pctl->regmap);
1161 dev_err(dev, "Failed to allocate register map: %d\n",
1162 ret);
1163 return ret;
1164 }
972 1165
973 mutex_init(&pctl->lock); 1166 mutex_init(&pctl->lock);
974 1167
@@ -991,6 +1184,14 @@ static int sx150x_probe(struct i2c_client *client,
991 pctl->gpio.of_node = dev->of_node; 1184 pctl->gpio.of_node = dev->of_node;
992#endif 1185#endif
993 pctl->gpio.can_sleep = true; 1186 pctl->gpio.can_sleep = true;
1187 /*
1188 * Setting multiple pins is not safe when all pins are not
1189 * handled by the same regmap register. The oscio pin (present
1190 * on the SX150X_789 chips) lives in its own register, so
1191 * would require locking that is not in place at this time.
1192 */
1193 if (pctl->data->model != SX150X_789)
1194 pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
994 1195
995 ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl); 1196 ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
996 if (ret) 1197 if (ret)
@@ -1008,13 +1209,21 @@ static int sx150x_probe(struct i2c_client *client,
1008 1209
1009 pctl->irq.masked = ~0; 1210 pctl->irq.masked = ~0;
1010 pctl->irq.sense = 0; 1211 pctl->irq.sense = 0;
1011 pctl->irq.dev_masked = ~0;
1012 pctl->irq.dev_sense = 0;
1013 pctl->irq.update = -1;
1014 1212
1015 ret = gpiochip_irqchip_add(&pctl->gpio, 1213 /*
1016 &pctl->irq_chip, 0, 1214 * Because sx150x_irq_threaded_fn invokes all of the
1017 handle_edge_irq, IRQ_TYPE_NONE); 1215 * nested interrrupt handlers via handle_nested_irq,
1216 * any "handler" passed to gpiochip_irqchip_add()
1217 * below is going to be ignored, so the choice of the
1218 * function does not matter that much.
1219 *
1220 * We set it to handle_bad_irq to avoid confusion,
1221 * plus it will be instantly noticeable if it is ever
1222 * called (should not happen)
1223 */
1224 ret = gpiochip_irqchip_add_nested(&pctl->gpio,
1225 &pctl->irq_chip, 0,
1226 handle_bad_irq, IRQ_TYPE_NONE);
1018 if (ret) { 1227 if (ret) {
1019 dev_err(dev, "could not connect irqchip to gpiochip\n"); 1228 dev_err(dev, "could not connect irqchip to gpiochip\n");
1020 return ret; 1229 return ret;
@@ -1027,6 +1236,10 @@ static int sx150x_probe(struct i2c_client *client,
1027 pctl->irq_chip.name, pctl); 1236 pctl->irq_chip.name, pctl);
1028 if (ret < 0) 1237 if (ret < 0)
1029 return ret; 1238 return ret;
1239
1240 gpiochip_set_nested_irqchip(&pctl->gpio,
1241 &pctl->irq_chip,
1242 client->irq);
1030 } 1243 }
1031 1244
1032 /* Pinctrl_desc */ 1245 /* Pinctrl_desc */
diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
index e0ecffcbe11f..b51a46dfdcc3 100644
--- a/drivers/pinctrl/pinctrl-zynq.c
+++ b/drivers/pinctrl/pinctrl-zynq.c
@@ -247,6 +247,8 @@ static const unsigned int smc0_nor_addr25_pins[] = {1};
247static const unsigned int smc0_nand_pins[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 247static const unsigned int smc0_nand_pins[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
248 12, 13, 14, 16, 17, 18, 19, 20, 248 12, 13, 14, 16, 17, 18, 19, 20,
249 21, 22, 23}; 249 21, 22, 23};
250static const unsigned int smc0_nand8_pins[] = {0, 2, 3, 4, 5, 6, 7,
251 8, 9, 10, 11, 12, 13, 14};
250/* Note: CAN MIO clock inputs are modeled in the clock framework */ 252/* Note: CAN MIO clock inputs are modeled in the clock framework */
251static const unsigned int can0_0_pins[] = {10, 11}; 253static const unsigned int can0_0_pins[] = {10, 11};
252static const unsigned int can0_1_pins[] = {14, 15}; 254static const unsigned int can0_1_pins[] = {14, 15};
@@ -445,6 +447,7 @@ static const struct zynq_pctrl_group zynq_pctrl_groups[] = {
445 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_cs1), 447 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_cs1),
446 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_addr25), 448 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nor_addr25),
447 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nand), 449 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nand),
450 DEFINE_ZYNQ_PINCTRL_GRP(smc0_nand8),
448 DEFINE_ZYNQ_PINCTRL_GRP(can0_0), 451 DEFINE_ZYNQ_PINCTRL_GRP(can0_0),
449 DEFINE_ZYNQ_PINCTRL_GRP(can0_1), 452 DEFINE_ZYNQ_PINCTRL_GRP(can0_1),
450 DEFINE_ZYNQ_PINCTRL_GRP(can0_2), 453 DEFINE_ZYNQ_PINCTRL_GRP(can0_2),
@@ -709,7 +712,8 @@ static const char * const sdio1_wp_groups[] = {"gpio0_0_grp",
709static const char * const smc0_nor_groups[] = {"smc0_nor_grp"}; 712static const char * const smc0_nor_groups[] = {"smc0_nor_grp"};
710static const char * const smc0_nor_cs1_groups[] = {"smc0_nor_cs1_grp"}; 713static const char * const smc0_nor_cs1_groups[] = {"smc0_nor_cs1_grp"};
711static const char * const smc0_nor_addr25_groups[] = {"smc0_nor_addr25_grp"}; 714static const char * const smc0_nor_addr25_groups[] = {"smc0_nor_addr25_grp"};
712static const char * const smc0_nand_groups[] = {"smc0_nand_grp"}; 715static const char * const smc0_nand_groups[] = {"smc0_nand_grp",
716 "smc0_nand8_grp"};
713static const char * const can0_groups[] = {"can0_0_grp", "can0_1_grp", 717static const char * const can0_groups[] = {"can0_0_grp", "can0_1_grp",
714 "can0_2_grp", "can0_3_grp", "can0_4_grp", "can0_5_grp", 718 "can0_2_grp", "can0_3_grp", "can0_4_grp", "can0_5_grp",
715 "can0_6_grp", "can0_7_grp", "can0_8_grp", "can0_9_grp", 719 "can0_6_grp", "can0_7_grp", "can0_8_grp", "can0_9_grp",
diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 93ef268d5ccd..3ebdc01f53c0 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -79,6 +79,15 @@ config PINCTRL_MSM8916
79 This is the pinctrl, pinmux, pinconf and gpiolib driver for the 79 This is the pinctrl, pinmux, pinconf and gpiolib driver for the
80 Qualcomm TLMM block found on the Qualcomm 8916 platform. 80 Qualcomm TLMM block found on the Qualcomm 8916 platform.
81 81
82config PINCTRL_MSM8994
83 tristate "Qualcomm 8994 pin controller driver"
84 depends on GPIOLIB && OF
85 select PINCTRL_MSM
86 help
87 This is the pinctrl, pinmux, pinconf and gpiolib driver for the
88 Qualcomm TLMM block found in the Qualcomm 8994 platform. The
89 Qualcomm 8992 platform is also supported by this driver.
90
82config PINCTRL_MSM8996 91config PINCTRL_MSM8996
83 tristate "Qualcomm MSM8996 pin controller driver" 92 tristate "Qualcomm MSM8996 pin controller driver"
84 depends on GPIOLIB && OF 93 depends on GPIOLIB && OF
diff --git a/drivers/pinctrl/qcom/Makefile b/drivers/pinctrl/qcom/Makefile
index 8319e11cecb5..ab47764dbc5c 100644
--- a/drivers/pinctrl/qcom/Makefile
+++ b/drivers/pinctrl/qcom/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_PINCTRL_MSM8660) += pinctrl-msm8660.o
8obj-$(CONFIG_PINCTRL_MSM8960) += pinctrl-msm8960.o 8obj-$(CONFIG_PINCTRL_MSM8960) += pinctrl-msm8960.o
9obj-$(CONFIG_PINCTRL_MSM8X74) += pinctrl-msm8x74.o 9obj-$(CONFIG_PINCTRL_MSM8X74) += pinctrl-msm8x74.o
10obj-$(CONFIG_PINCTRL_MSM8916) += pinctrl-msm8916.o 10obj-$(CONFIG_PINCTRL_MSM8916) += pinctrl-msm8916.o
11obj-$(CONFIG_PINCTRL_MSM8994) += pinctrl-msm8994.o
11obj-$(CONFIG_PINCTRL_MSM8996) += pinctrl-msm8996.o 12obj-$(CONFIG_PINCTRL_MSM8996) += pinctrl-msm8996.o
12obj-$(CONFIG_PINCTRL_QDF2XXX) += pinctrl-qdf2xxx.o 13obj-$(CONFIG_PINCTRL_QDF2XXX) += pinctrl-qdf2xxx.o
13obj-$(CONFIG_PINCTRL_MDM9615) += pinctrl-mdm9615.o 14obj-$(CONFIG_PINCTRL_MDM9615) += pinctrl-mdm9615.o
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8994.c b/drivers/pinctrl/qcom/pinctrl-msm8994.c
new file mode 100644
index 000000000000..8e16d9ae0c39
--- /dev/null
+++ b/drivers/pinctrl/qcom/pinctrl-msm8994.c
@@ -0,0 +1,1379 @@
1/*
2 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/module.h>
15#include <linux/of.h>
16#include <linux/platform_device.h>
17#include <linux/pinctrl/pinctrl.h>
18
19#include "pinctrl-msm.h"
20
21#define FUNCTION(fname) \
22 [MSM_MUX_##fname] = { \
23 .name = #fname, \
24 .groups = fname##_groups, \
25 .ngroups = ARRAY_SIZE(fname##_groups), \
26 }
27
28#define PINGROUP(id, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) \
29 { \
30 .name = "gpio" #id, \
31 .pins = gpio##id##_pins, \
32 .npins = ARRAY_SIZE(gpio##id##_pins), \
33 .funcs = (int[]){ \
34 MSM_MUX_gpio, \
35 MSM_MUX_##f1, \
36 MSM_MUX_##f2, \
37 MSM_MUX_##f3, \
38 MSM_MUX_##f4, \
39 MSM_MUX_##f5, \
40 MSM_MUX_##f6, \
41 MSM_MUX_##f7, \
42 MSM_MUX_##f8, \
43 MSM_MUX_##f9, \
44 MSM_MUX_##f10, \
45 MSM_MUX_##f11 \
46 }, \
47 .nfuncs = 12, \
48 .ctl_reg = 0x1000 + 0x10 * id, \
49 .io_reg = 0x1004 + 0x10 * id, \
50 .intr_cfg_reg = 0x1008 + 0x10 * id, \
51 .intr_status_reg = 0x100c + 0x10 * id, \
52 .intr_target_reg = 0x1008 + 0x10 * id, \
53 .mux_bit = 2, \
54 .pull_bit = 0, \
55 .drv_bit = 6, \
56 .oe_bit = 9, \
57 .in_bit = 0, \
58 .out_bit = 1, \
59 .intr_enable_bit = 0, \
60 .intr_status_bit = 0, \
61 .intr_target_bit = 5, \
62 .intr_target_kpss_val = 4, \
63 .intr_raw_status_bit = 4, \
64 .intr_polarity_bit = 1, \
65 .intr_detection_bit = 2, \
66 .intr_detection_width = 2, \
67 }
68
69#define SDC_PINGROUP(pg_name, ctl, pull, drv) \
70 { \
71 .name = #pg_name, \
72 .pins = pg_name##_pins, \
73 .npins = ARRAY_SIZE(pg_name##_pins), \
74 .ctl_reg = ctl, \
75 .io_reg = 0, \
76 .intr_cfg_reg = 0, \
77 .intr_status_reg = 0, \
78 .intr_target_reg = 0, \
79 .mux_bit = -1, \
80 .pull_bit = pull, \
81 .drv_bit = drv, \
82 .oe_bit = -1, \
83 .in_bit = -1, \
84 .out_bit = -1, \
85 .intr_enable_bit = -1, \
86 .intr_status_bit = -1, \
87 .intr_target_bit = -1, \
88 .intr_target_kpss_val = -1, \
89 .intr_raw_status_bit = -1, \
90 .intr_polarity_bit = -1, \
91 .intr_detection_bit = -1, \
92 .intr_detection_width = -1, \
93 }
94static const struct pinctrl_pin_desc msm8994_pins[] = {
95 PINCTRL_PIN(0, "GPIO_0"),
96 PINCTRL_PIN(1, "GPIO_1"),
97 PINCTRL_PIN(2, "GPIO_2"),
98 PINCTRL_PIN(3, "GPIO_3"),
99 PINCTRL_PIN(4, "GPIO_4"),
100 PINCTRL_PIN(5, "GPIO_5"),
101 PINCTRL_PIN(6, "GPIO_6"),
102 PINCTRL_PIN(7, "GPIO_7"),
103 PINCTRL_PIN(8, "GPIO_8"),
104 PINCTRL_PIN(9, "GPIO_9"),
105 PINCTRL_PIN(10, "GPIO_10"),
106 PINCTRL_PIN(11, "GPIO_11"),
107 PINCTRL_PIN(12, "GPIO_12"),
108 PINCTRL_PIN(13, "GPIO_13"),
109 PINCTRL_PIN(14, "GPIO_14"),
110 PINCTRL_PIN(15, "GPIO_15"),
111 PINCTRL_PIN(16, "GPIO_16"),
112 PINCTRL_PIN(17, "GPIO_17"),
113 PINCTRL_PIN(18, "GPIO_18"),
114 PINCTRL_PIN(19, "GPIO_19"),
115 PINCTRL_PIN(20, "GPIO_20"),
116 PINCTRL_PIN(21, "GPIO_21"),
117 PINCTRL_PIN(22, "GPIO_22"),
118 PINCTRL_PIN(23, "GPIO_23"),
119 PINCTRL_PIN(24, "GPIO_24"),
120 PINCTRL_PIN(25, "GPIO_25"),
121 PINCTRL_PIN(26, "GPIO_26"),
122 PINCTRL_PIN(27, "GPIO_27"),
123 PINCTRL_PIN(28, "GPIO_28"),
124 PINCTRL_PIN(29, "GPIO_29"),
125 PINCTRL_PIN(30, "GPIO_30"),
126 PINCTRL_PIN(31, "GPIO_31"),
127 PINCTRL_PIN(32, "GPIO_32"),
128 PINCTRL_PIN(33, "GPIO_33"),
129 PINCTRL_PIN(34, "GPIO_34"),
130 PINCTRL_PIN(35, "GPIO_35"),
131 PINCTRL_PIN(36, "GPIO_36"),
132 PINCTRL_PIN(37, "GPIO_37"),
133 PINCTRL_PIN(38, "GPIO_38"),
134 PINCTRL_PIN(39, "GPIO_39"),
135 PINCTRL_PIN(40, "GPIO_40"),
136 PINCTRL_PIN(41, "GPIO_41"),
137 PINCTRL_PIN(42, "GPIO_42"),
138 PINCTRL_PIN(43, "GPIO_43"),
139 PINCTRL_PIN(44, "GPIO_44"),
140 PINCTRL_PIN(45, "GPIO_45"),
141 PINCTRL_PIN(46, "GPIO_46"),
142 PINCTRL_PIN(47, "GPIO_47"),
143 PINCTRL_PIN(48, "GPIO_48"),
144 PINCTRL_PIN(49, "GPIO_49"),
145 PINCTRL_PIN(50, "GPIO_50"),
146 PINCTRL_PIN(51, "GPIO_51"),
147 PINCTRL_PIN(52, "GPIO_52"),
148 PINCTRL_PIN(53, "GPIO_53"),
149 PINCTRL_PIN(54, "GPIO_54"),
150 PINCTRL_PIN(55, "GPIO_55"),
151 PINCTRL_PIN(56, "GPIO_56"),
152 PINCTRL_PIN(57, "GPIO_57"),
153 PINCTRL_PIN(58, "GPIO_58"),
154 PINCTRL_PIN(59, "GPIO_59"),
155 PINCTRL_PIN(60, "GPIO_60"),
156 PINCTRL_PIN(61, "GPIO_61"),
157 PINCTRL_PIN(62, "GPIO_62"),
158 PINCTRL_PIN(63, "GPIO_63"),
159 PINCTRL_PIN(64, "GPIO_64"),
160 PINCTRL_PIN(65, "GPIO_65"),
161 PINCTRL_PIN(66, "GPIO_66"),
162 PINCTRL_PIN(67, "GPIO_67"),
163 PINCTRL_PIN(68, "GPIO_68"),
164 PINCTRL_PIN(69, "GPIO_69"),
165 PINCTRL_PIN(70, "GPIO_70"),
166 PINCTRL_PIN(71, "GPIO_71"),
167 PINCTRL_PIN(72, "GPIO_72"),
168 PINCTRL_PIN(73, "GPIO_73"),
169 PINCTRL_PIN(74, "GPIO_74"),
170 PINCTRL_PIN(75, "GPIO_75"),
171 PINCTRL_PIN(76, "GPIO_76"),
172 PINCTRL_PIN(77, "GPIO_77"),
173 PINCTRL_PIN(78, "GPIO_78"),
174 PINCTRL_PIN(79, "GPIO_79"),
175 PINCTRL_PIN(80, "GPIO_80"),
176 PINCTRL_PIN(81, "GPIO_81"),
177 PINCTRL_PIN(82, "GPIO_82"),
178 PINCTRL_PIN(83, "GPIO_83"),
179 PINCTRL_PIN(84, "GPIO_84"),
180 PINCTRL_PIN(85, "GPIO_85"),
181 PINCTRL_PIN(86, "GPIO_86"),
182 PINCTRL_PIN(87, "GPIO_87"),
183 PINCTRL_PIN(88, "GPIO_88"),
184 PINCTRL_PIN(89, "GPIO_89"),
185 PINCTRL_PIN(90, "GPIO_90"),
186 PINCTRL_PIN(91, "GPIO_91"),
187 PINCTRL_PIN(92, "GPIO_92"),
188 PINCTRL_PIN(93, "GPIO_93"),
189 PINCTRL_PIN(94, "GPIO_94"),
190 PINCTRL_PIN(95, "GPIO_95"),
191 PINCTRL_PIN(96, "GPIO_96"),
192 PINCTRL_PIN(97, "GPIO_97"),
193 PINCTRL_PIN(98, "GPIO_98"),
194 PINCTRL_PIN(99, "GPIO_99"),
195 PINCTRL_PIN(100, "GPIO_100"),
196 PINCTRL_PIN(101, "GPIO_101"),
197 PINCTRL_PIN(102, "GPIO_102"),
198 PINCTRL_PIN(103, "GPIO_103"),
199 PINCTRL_PIN(104, "GPIO_104"),
200 PINCTRL_PIN(105, "GPIO_105"),
201 PINCTRL_PIN(106, "GPIO_106"),
202 PINCTRL_PIN(107, "GPIO_107"),
203 PINCTRL_PIN(108, "GPIO_108"),
204 PINCTRL_PIN(109, "GPIO_109"),
205 PINCTRL_PIN(110, "GPIO_110"),
206 PINCTRL_PIN(111, "GPIO_111"),
207 PINCTRL_PIN(112, "GPIO_112"),
208 PINCTRL_PIN(113, "GPIO_113"),
209 PINCTRL_PIN(114, "GPIO_114"),
210 PINCTRL_PIN(115, "GPIO_115"),
211 PINCTRL_PIN(116, "GPIO_116"),
212 PINCTRL_PIN(117, "GPIO_117"),
213 PINCTRL_PIN(118, "GPIO_118"),
214 PINCTRL_PIN(119, "GPIO_119"),
215 PINCTRL_PIN(120, "GPIO_120"),
216 PINCTRL_PIN(121, "GPIO_121"),
217 PINCTRL_PIN(122, "GPIO_122"),
218 PINCTRL_PIN(123, "GPIO_123"),
219 PINCTRL_PIN(124, "GPIO_124"),
220 PINCTRL_PIN(125, "GPIO_125"),
221 PINCTRL_PIN(126, "GPIO_126"),
222 PINCTRL_PIN(127, "GPIO_127"),
223 PINCTRL_PIN(128, "GPIO_128"),
224 PINCTRL_PIN(129, "GPIO_129"),
225 PINCTRL_PIN(130, "GPIO_130"),
226 PINCTRL_PIN(131, "GPIO_131"),
227 PINCTRL_PIN(132, "GPIO_132"),
228 PINCTRL_PIN(133, "GPIO_133"),
229 PINCTRL_PIN(134, "GPIO_134"),
230 PINCTRL_PIN(135, "GPIO_135"),
231 PINCTRL_PIN(136, "GPIO_136"),
232 PINCTRL_PIN(137, "GPIO_137"),
233 PINCTRL_PIN(138, "GPIO_138"),
234 PINCTRL_PIN(139, "GPIO_139"),
235 PINCTRL_PIN(140, "GPIO_140"),
236 PINCTRL_PIN(141, "GPIO_141"),
237 PINCTRL_PIN(142, "GPIO_142"),
238 PINCTRL_PIN(143, "GPIO_143"),
239 PINCTRL_PIN(144, "GPIO_144"),
240 PINCTRL_PIN(145, "GPIO_145"),
241 PINCTRL_PIN(146, "SDC1_RCLK"),
242 PINCTRL_PIN(147, "SDC1_CLK"),
243 PINCTRL_PIN(148, "SDC1_CMD"),
244 PINCTRL_PIN(149, "SDC1_DATA"),
245 PINCTRL_PIN(150, "SDC2_CLK"),
246 PINCTRL_PIN(151, "SDC2_CMD"),
247 PINCTRL_PIN(152, "SDC2_DATA"),
248 PINCTRL_PIN(153, "SDC3_CLK"),
249 PINCTRL_PIN(154, "SDC3_CMD"),
250 PINCTRL_PIN(155, "SDC3_DATA"),
251};
252
253#define DECLARE_MSM_GPIO_PINS(pin) \
254 static const unsigned int gpio##pin##_pins[] = { pin }
255DECLARE_MSM_GPIO_PINS(0);
256DECLARE_MSM_GPIO_PINS(1);
257DECLARE_MSM_GPIO_PINS(2);
258DECLARE_MSM_GPIO_PINS(3);
259DECLARE_MSM_GPIO_PINS(4);
260DECLARE_MSM_GPIO_PINS(5);
261DECLARE_MSM_GPIO_PINS(6);
262DECLARE_MSM_GPIO_PINS(7);
263DECLARE_MSM_GPIO_PINS(8);
264DECLARE_MSM_GPIO_PINS(9);
265DECLARE_MSM_GPIO_PINS(10);
266DECLARE_MSM_GPIO_PINS(11);
267DECLARE_MSM_GPIO_PINS(12);
268DECLARE_MSM_GPIO_PINS(13);
269DECLARE_MSM_GPIO_PINS(14);
270DECLARE_MSM_GPIO_PINS(15);
271DECLARE_MSM_GPIO_PINS(16);
272DECLARE_MSM_GPIO_PINS(17);
273DECLARE_MSM_GPIO_PINS(18);
274DECLARE_MSM_GPIO_PINS(19);
275DECLARE_MSM_GPIO_PINS(20);
276DECLARE_MSM_GPIO_PINS(21);
277DECLARE_MSM_GPIO_PINS(22);
278DECLARE_MSM_GPIO_PINS(23);
279DECLARE_MSM_GPIO_PINS(24);
280DECLARE_MSM_GPIO_PINS(25);
281DECLARE_MSM_GPIO_PINS(26);
282DECLARE_MSM_GPIO_PINS(27);
283DECLARE_MSM_GPIO_PINS(28);
284DECLARE_MSM_GPIO_PINS(29);
285DECLARE_MSM_GPIO_PINS(30);
286DECLARE_MSM_GPIO_PINS(31);
287DECLARE_MSM_GPIO_PINS(32);
288DECLARE_MSM_GPIO_PINS(33);
289DECLARE_MSM_GPIO_PINS(34);
290DECLARE_MSM_GPIO_PINS(35);
291DECLARE_MSM_GPIO_PINS(36);
292DECLARE_MSM_GPIO_PINS(37);
293DECLARE_MSM_GPIO_PINS(38);
294DECLARE_MSM_GPIO_PINS(39);
295DECLARE_MSM_GPIO_PINS(40);
296DECLARE_MSM_GPIO_PINS(41);
297DECLARE_MSM_GPIO_PINS(42);
298DECLARE_MSM_GPIO_PINS(43);
299DECLARE_MSM_GPIO_PINS(44);
300DECLARE_MSM_GPIO_PINS(45);
301DECLARE_MSM_GPIO_PINS(46);
302DECLARE_MSM_GPIO_PINS(47);
303DECLARE_MSM_GPIO_PINS(48);
304DECLARE_MSM_GPIO_PINS(49);
305DECLARE_MSM_GPIO_PINS(50);
306DECLARE_MSM_GPIO_PINS(51);
307DECLARE_MSM_GPIO_PINS(52);
308DECLARE_MSM_GPIO_PINS(53);
309DECLARE_MSM_GPIO_PINS(54);
310DECLARE_MSM_GPIO_PINS(55);
311DECLARE_MSM_GPIO_PINS(56);
312DECLARE_MSM_GPIO_PINS(57);
313DECLARE_MSM_GPIO_PINS(58);
314DECLARE_MSM_GPIO_PINS(59);
315DECLARE_MSM_GPIO_PINS(60);
316DECLARE_MSM_GPIO_PINS(61);
317DECLARE_MSM_GPIO_PINS(62);
318DECLARE_MSM_GPIO_PINS(63);
319DECLARE_MSM_GPIO_PINS(64);
320DECLARE_MSM_GPIO_PINS(65);
321DECLARE_MSM_GPIO_PINS(66);
322DECLARE_MSM_GPIO_PINS(67);
323DECLARE_MSM_GPIO_PINS(68);
324DECLARE_MSM_GPIO_PINS(69);
325DECLARE_MSM_GPIO_PINS(70);
326DECLARE_MSM_GPIO_PINS(71);
327DECLARE_MSM_GPIO_PINS(72);
328DECLARE_MSM_GPIO_PINS(73);
329DECLARE_MSM_GPIO_PINS(74);
330DECLARE_MSM_GPIO_PINS(75);
331DECLARE_MSM_GPIO_PINS(76);
332DECLARE_MSM_GPIO_PINS(77);
333DECLARE_MSM_GPIO_PINS(78);
334DECLARE_MSM_GPIO_PINS(79);
335DECLARE_MSM_GPIO_PINS(80);
336DECLARE_MSM_GPIO_PINS(81);
337DECLARE_MSM_GPIO_PINS(82);
338DECLARE_MSM_GPIO_PINS(83);
339DECLARE_MSM_GPIO_PINS(84);
340DECLARE_MSM_GPIO_PINS(85);
341DECLARE_MSM_GPIO_PINS(86);
342DECLARE_MSM_GPIO_PINS(87);
343DECLARE_MSM_GPIO_PINS(88);
344DECLARE_MSM_GPIO_PINS(89);
345DECLARE_MSM_GPIO_PINS(90);
346DECLARE_MSM_GPIO_PINS(91);
347DECLARE_MSM_GPIO_PINS(92);
348DECLARE_MSM_GPIO_PINS(93);
349DECLARE_MSM_GPIO_PINS(94);
350DECLARE_MSM_GPIO_PINS(95);
351DECLARE_MSM_GPIO_PINS(96);
352DECLARE_MSM_GPIO_PINS(97);
353DECLARE_MSM_GPIO_PINS(98);
354DECLARE_MSM_GPIO_PINS(99);
355DECLARE_MSM_GPIO_PINS(100);
356DECLARE_MSM_GPIO_PINS(101);
357DECLARE_MSM_GPIO_PINS(102);
358DECLARE_MSM_GPIO_PINS(103);
359DECLARE_MSM_GPIO_PINS(104);
360DECLARE_MSM_GPIO_PINS(105);
361DECLARE_MSM_GPIO_PINS(106);
362DECLARE_MSM_GPIO_PINS(107);
363DECLARE_MSM_GPIO_PINS(108);
364DECLARE_MSM_GPIO_PINS(109);
365DECLARE_MSM_GPIO_PINS(110);
366DECLARE_MSM_GPIO_PINS(111);
367DECLARE_MSM_GPIO_PINS(112);
368DECLARE_MSM_GPIO_PINS(113);
369DECLARE_MSM_GPIO_PINS(114);
370DECLARE_MSM_GPIO_PINS(115);
371DECLARE_MSM_GPIO_PINS(116);
372DECLARE_MSM_GPIO_PINS(117);
373DECLARE_MSM_GPIO_PINS(118);
374DECLARE_MSM_GPIO_PINS(119);
375DECLARE_MSM_GPIO_PINS(120);
376DECLARE_MSM_GPIO_PINS(121);
377DECLARE_MSM_GPIO_PINS(122);
378DECLARE_MSM_GPIO_PINS(123);
379DECLARE_MSM_GPIO_PINS(124);
380DECLARE_MSM_GPIO_PINS(125);
381DECLARE_MSM_GPIO_PINS(126);
382DECLARE_MSM_GPIO_PINS(127);
383DECLARE_MSM_GPIO_PINS(128);
384DECLARE_MSM_GPIO_PINS(129);
385DECLARE_MSM_GPIO_PINS(130);
386DECLARE_MSM_GPIO_PINS(131);
387DECLARE_MSM_GPIO_PINS(132);
388DECLARE_MSM_GPIO_PINS(133);
389DECLARE_MSM_GPIO_PINS(134);
390DECLARE_MSM_GPIO_PINS(135);
391DECLARE_MSM_GPIO_PINS(136);
392DECLARE_MSM_GPIO_PINS(137);
393DECLARE_MSM_GPIO_PINS(138);
394DECLARE_MSM_GPIO_PINS(139);
395DECLARE_MSM_GPIO_PINS(140);
396DECLARE_MSM_GPIO_PINS(141);
397DECLARE_MSM_GPIO_PINS(142);
398DECLARE_MSM_GPIO_PINS(143);
399DECLARE_MSM_GPIO_PINS(144);
400DECLARE_MSM_GPIO_PINS(145);
401
402static const unsigned int sdc1_rclk_pins[] = { 146 };
403static const unsigned int sdc1_clk_pins[] = { 147 };
404static const unsigned int sdc1_cmd_pins[] = { 148 };
405static const unsigned int sdc1_data_pins[] = { 149 };
406static const unsigned int sdc2_clk_pins[] = { 150 };
407static const unsigned int sdc2_cmd_pins[] = { 151 };
408static const unsigned int sdc2_data_pins[] = { 152 };
409static const unsigned int sdc3_clk_pins[] = { 153 };
410static const unsigned int sdc3_cmd_pins[] = { 154 };
411static const unsigned int sdc3_data_pins[] = { 155 };
412
413enum msm8994_functions {
414 MSM_MUX_audio_ref_clk,
415 MSM_MUX_blsp_i2c1,
416 MSM_MUX_blsp_i2c2,
417 MSM_MUX_blsp_i2c3,
418 MSM_MUX_blsp_i2c4,
419 MSM_MUX_blsp_i2c5,
420 MSM_MUX_blsp_i2c6,
421 MSM_MUX_blsp_i2c7,
422 MSM_MUX_blsp_i2c8,
423 MSM_MUX_blsp_i2c9,
424 MSM_MUX_blsp_i2c10,
425 MSM_MUX_blsp_i2c11,
426 MSM_MUX_blsp_i2c12,
427 MSM_MUX_blsp_spi1,
428 MSM_MUX_blsp_spi1_cs1,
429 MSM_MUX_blsp_spi1_cs2,
430 MSM_MUX_blsp_spi1_cs3,
431 MSM_MUX_blsp_spi2,
432 MSM_MUX_blsp_spi2_cs1,
433 MSM_MUX_blsp_spi2_cs2,
434 MSM_MUX_blsp_spi2_cs3,
435 MSM_MUX_blsp_spi3,
436 MSM_MUX_blsp_spi4,
437 MSM_MUX_blsp_spi5,
438 MSM_MUX_blsp_spi6,
439 MSM_MUX_blsp_spi7,
440 MSM_MUX_blsp_spi8,
441 MSM_MUX_blsp_spi9,
442 MSM_MUX_blsp_spi10,
443 MSM_MUX_blsp_spi10_cs1,
444 MSM_MUX_blsp_spi10_cs2,
445 MSM_MUX_blsp_spi10_cs3,
446 MSM_MUX_blsp_spi11,
447 MSM_MUX_blsp_spi12,
448 MSM_MUX_blsp_uart1,
449 MSM_MUX_blsp_uart2,
450 MSM_MUX_blsp_uart3,
451 MSM_MUX_blsp_uart4,
452 MSM_MUX_blsp_uart5,
453 MSM_MUX_blsp_uart6,
454 MSM_MUX_blsp_uart7,
455 MSM_MUX_blsp_uart8,
456 MSM_MUX_blsp_uart9,
457 MSM_MUX_blsp_uart10,
458 MSM_MUX_blsp_uart11,
459 MSM_MUX_blsp_uart12,
460 MSM_MUX_blsp_uim1,
461 MSM_MUX_blsp_uim2,
462 MSM_MUX_blsp_uim3,
463 MSM_MUX_blsp_uim4,
464 MSM_MUX_blsp_uim5,
465 MSM_MUX_blsp_uim6,
466 MSM_MUX_blsp_uim7,
467 MSM_MUX_blsp_uim8,
468 MSM_MUX_blsp_uim9,
469 MSM_MUX_blsp_uim10,
470 MSM_MUX_blsp_uim11,
471 MSM_MUX_blsp_uim12,
472 MSM_MUX_blsp11_i2c_scl_b,
473 MSM_MUX_blsp11_i2c_sda_b,
474 MSM_MUX_blsp11_uart_rx_b,
475 MSM_MUX_blsp11_uart_tx_b,
476 MSM_MUX_cam_mclk0,
477 MSM_MUX_cam_mclk1,
478 MSM_MUX_cam_mclk2,
479 MSM_MUX_cam_mclk3,
480 MSM_MUX_cci_async_in0,
481 MSM_MUX_cci_async_in1,
482 MSM_MUX_cci_async_in2,
483 MSM_MUX_cci_i2c0,
484 MSM_MUX_cci_i2c1,
485 MSM_MUX_cci_timer0,
486 MSM_MUX_cci_timer1,
487 MSM_MUX_cci_timer2,
488 MSM_MUX_cci_timer3,
489 MSM_MUX_cci_timer4,
490 MSM_MUX_gcc_gp1_clk_a,
491 MSM_MUX_gcc_gp1_clk_b,
492 MSM_MUX_gcc_gp2_clk_a,
493 MSM_MUX_gcc_gp2_clk_b,
494 MSM_MUX_gcc_gp3_clk_a,
495 MSM_MUX_gcc_gp3_clk_b,
496 MSM_MUX_gp_mn,
497 MSM_MUX_gp_pdm0,
498 MSM_MUX_gp_pdm1,
499 MSM_MUX_gp_pdm2,
500 MSM_MUX_gp0_clk,
501 MSM_MUX_gp1_clk,
502 MSM_MUX_gps_tx,
503 MSM_MUX_gsm_tx,
504 MSM_MUX_hdmi_cec,
505 MSM_MUX_hdmi_ddc,
506 MSM_MUX_hdmi_hpd,
507 MSM_MUX_hdmi_rcv,
508 MSM_MUX_mdp_vsync,
509 MSM_MUX_mss_lte,
510 MSM_MUX_nav_pps,
511 MSM_MUX_nav_tsync,
512 MSM_MUX_qdss_cti_trig_in_a,
513 MSM_MUX_qdss_cti_trig_in_b,
514 MSM_MUX_qdss_cti_trig_in_c,
515 MSM_MUX_qdss_cti_trig_in_d,
516 MSM_MUX_qdss_cti_trig_out_a,
517 MSM_MUX_qdss_cti_trig_out_b,
518 MSM_MUX_qdss_cti_trig_out_c,
519 MSM_MUX_qdss_cti_trig_out_d,
520 MSM_MUX_qdss_traceclk_a,
521 MSM_MUX_qdss_traceclk_b,
522 MSM_MUX_qdss_tracectl_a,
523 MSM_MUX_qdss_tracectl_b,
524 MSM_MUX_qdss_tracedata_a,
525 MSM_MUX_qdss_tracedata_b,
526 MSM_MUX_qua_mi2s,
527 MSM_MUX_pci_e0,
528 MSM_MUX_pci_e1,
529 MSM_MUX_pri_mi2s,
530 MSM_MUX_sdc4,
531 MSM_MUX_sec_mi2s,
532 MSM_MUX_slimbus,
533 MSM_MUX_spkr_i2s,
534 MSM_MUX_ter_mi2s,
535 MSM_MUX_tsif1,
536 MSM_MUX_tsif2,
537 MSM_MUX_uim1,
538 MSM_MUX_uim2,
539 MSM_MUX_uim3,
540 MSM_MUX_uim4,
541 MSM_MUX_uim_batt_alarm,
542 MSM_MUX_gpio,
543 MSM_MUX_NA,
544};
545
546static const char * const gpio_groups[] = {
547 "gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
548 "gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
549 "gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
550 "gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
551 "gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35",
552 "gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42",
553 "gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49",
554 "gpio50", "gpio51", "gpio52", "gpio53", "gpio54", "gpio55", "gpio56",
555 "gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
556 "gpio64", "gpio65", "gpio66", "gpio67", "gpio68", "gpio69", "gpio70",
557 "gpio71", "gpio72", "gpio73", "gpio74", "gpio75", "gpio76", "gpio77",
558 "gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
559 "gpio85", "gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91",
560 "gpio92", "gpio93", "gpio94", "gpio95", "gpio96", "gpio97", "gpio98",
561 "gpio99", "gpio100", "gpio101", "gpio102", "gpio103", "gpio104",
562 "gpio105", "gpio106", "gpio107", "gpio108", "gpio109", "gpio110",
563 "gpio111", "gpio112", "gpio113", "gpio114", "gpio115", "gpio116",
564 "gpio117", "gpio118", "gpio119", "gpio120", "gpio121", "gpio122",
565 "gpio123", "gpio124", "gpio125", "gpio126", "gpio127", "gpio128",
566 "gpio129", "gpio130", "gpio131", "gpio132", "gpio133", "gpio134",
567 "gpio135", "gpio136", "gpio137", "gpio138", "gpio139", "gpio140",
568 "gpio141", "gpio142", "gpio143", "gpio144", "gpio145",
569};
570
571static const char * const blsp_spi1_groups[] = {
572 "gpio0", "gpio1", "gpio2", "gpio3"
573};
574static const char * const blsp_uart1_groups[] = {
575 "gpio0", "gpio1", "gpio2", "gpio3"
576};
577static const char * const blsp_uim1_groups[] = {
578 "gpio0", "gpio1"
579};
580static const char * const hdmi_rcv_groups[] = {
581 "gpio0"
582};
583static const char * const blsp_i2c1_groups[] = {
584 "gpio2", "gpio3"
585};
586static const char * const blsp_spi2_groups[] = {
587 "gpio4", "gpio5", "gpio6", "gpio7"
588};
589static const char * const blsp_uart2_groups[] = {
590 "gpio4", "gpio5", "gpio6", "gpio7"
591};
592static const char * const blsp_uim2_groups[] = {
593 "gpio4", "gpio5"
594};
595static const char * const qdss_cti_trig_out_b_groups[] = {
596 "gpio4",
597};
598static const char * const qdss_cti_trig_in_b_groups[] = {
599 "gpio5",
600};
601static const char * const blsp_i2c2_groups[] = {
602 "gpio6", "gpio7"
603};
604static const char * const blsp_spi3_groups[] = {
605 "gpio8", "gpio9", "gpio10", "gpio11"
606};
607static const char * const blsp_uart3_groups[] = {
608 "gpio8", "gpio9", "gpio10", "gpio11"
609};
610static const char * const blsp_uim3_groups[] = {
611 "gpio8", "gpio9"
612};
613static const char * const blsp_spi1_cs1_groups[] = {
614 "gpio8"
615};
616static const char * const blsp_spi1_cs2_groups[] = {
617 "gpio9", "gpio11"
618};
619static const char * const mdp_vsync_groups[] = {
620 "gpio10", "gpio11", "gpio12"
621};
622static const char * const blsp_i2c3_groups[] = {
623 "gpio10", "gpio11"
624};
625static const char * const blsp_spi1_cs3_groups[] = {
626 "gpio10"
627};
628static const char * const qdss_tracedata_b_groups[] = {
629 "gpio13", "gpio14", "gpio15", "gpio16", "gpio17", "gpio18",
630 "gpio19", "gpio21", "gpio22", "gpio23", "gpio25", "gpio26",
631 "gpio57", "gpio58", "gpio92", "gpio93",
632};
633static const char * const cam_mclk0_groups[] = {
634 "gpio13"
635};
636static const char * const cam_mclk1_groups[] = {
637 "gpio14"
638};
639static const char * const cam_mclk2_groups[] = {
640 "gpio15"
641};
642static const char * const cam_mclk3_groups[] = {
643 "gpio16"
644};
645static const char * const cci_i2c0_groups[] = {
646 "gpio17", "gpio18"
647};
648static const char * const blsp_spi4_groups[] = {
649 "gpio17", "gpio18", "gpio19", "gpio20"
650};
651static const char * const blsp_uart4_groups[] = {
652 "gpio17", "gpio18", "gpio19", "gpio20"
653};
654static const char * const blsp_uim4_groups[] = {
655 "gpio17", "gpio18"
656};
657static const char * const cci_i2c1_groups[] = {
658 "gpio19", "gpio20"
659};
660static const char * const blsp_i2c4_groups[] = {
661 "gpio19", "gpio20"
662};
663static const char * const cci_timer0_groups[] = {
664 "gpio21"
665};
666static const char * const blsp_spi5_groups[] = {
667 "gpio21", "gpio22", "gpio23", "gpio24"
668};
669static const char * const blsp_uart5_groups[] = {
670 "gpio21", "gpio22", "gpio23", "gpio24"
671};
672static const char * const blsp_uim5_groups[] = {
673 "gpio21", "gpio22"
674};
675static const char * const cci_timer1_groups[] = {
676 "gpio22"
677};
678static const char * const cci_timer2_groups[] = {
679 "gpio23"
680};
681static const char * const blsp_i2c5_groups[] = {
682 "gpio23", "gpio24"
683};
684static const char * const cci_timer3_groups[] = {
685 "gpio24"
686};
687static const char * const cci_async_in1_groups[] = {
688 "gpio24"
689};
690static const char * const cci_timer4_groups[] = {
691 "gpio25"
692};
693static const char * const cci_async_in2_groups[] = {
694 "gpio25"
695};
696static const char * const blsp_spi6_groups[] = {
697 "gpio25", "gpio26", "gpio27", "gpio28"
698};
699static const char * const blsp_uart6_groups[] = {
700 "gpio25", "gpio26", "gpio27", "gpio28"
701};
702static const char * const blsp_uim6_groups[] = {
703 "gpio25", "gpio26"
704};
705static const char * const cci_async_in0_groups[] = {
706 "gpio26"
707};
708static const char * const gp0_clk_groups[] = {
709 "gpio26"
710};
711static const char * const gp1_clk_groups[] = {
712 "gpio27", "gpio57", "gpio78"
713};
714static const char * const blsp_i2c6_groups[] = {
715 "gpio27", "gpio28"
716};
717static const char * const qdss_tracectl_a_groups[] = {
718 "gpio27",
719};
720static const char * const qdss_traceclk_a_groups[] = {
721 "gpio28",
722};
723static const char * const gp_mn_groups[] = {
724 "gpio29"
725};
726static const char * const hdmi_cec_groups[] = {
727 "gpio31"
728};
729static const char * const hdmi_ddc_groups[] = {
730 "gpio32", "gpio33"
731};
732static const char * const hdmi_hpd_groups[] = {
733 "gpio34"
734};
735static const char * const uim3_groups[] = {
736 "gpio35", "gpio36", "gpio37", "gpio38"
737};
738static const char * const pci_e1_groups[] = {
739 "gpio35", "gpio36",
740};
741static const char * const blsp_spi7_groups[] = {
742 "gpio41", "gpio42", "gpio43", "gpio44"
743};
744static const char * const blsp_uart7_groups[] = {
745 "gpio41", "gpio42", "gpio43", "gpio44"
746};
747static const char * const blsp_uim7_groups[] = {
748 "gpio41", "gpio42"
749};
750static const char * const qdss_cti_trig_out_c_groups[] = {
751 "gpio41",
752};
753static const char * const qdss_cti_trig_in_c_groups[] = {
754 "gpio42",
755};
756static const char * const blsp_i2c7_groups[] = {
757 "gpio43", "gpio44"
758};
759static const char * const blsp_spi8_groups[] = {
760 "gpio45", "gpio46", "gpio47", "gpio48"
761};
762static const char * const blsp_uart8_groups[] = {
763 "gpio45", "gpio46", "gpio47", "gpio48"
764};
765static const char * const blsp_uim8_groups[] = {
766 "gpio45", "gpio46"
767};
768static const char * const blsp_i2c8_groups[] = {
769 "gpio47", "gpio48"
770};
771static const char * const blsp_spi10_cs1_groups[] = {
772 "gpio47", "gpio67"
773};
774static const char * const blsp_spi10_cs2_groups[] = {
775 "gpio48", "gpio68"
776};
777static const char * const uim2_groups[] = {
778 "gpio49", "gpio50", "gpio51", "gpio52"
779};
780static const char * const blsp_spi9_groups[] = {
781 "gpio49", "gpio50", "gpio51", "gpio52"
782};
783static const char * const blsp_uart9_groups[] = {
784 "gpio49", "gpio50", "gpio51", "gpio52"
785};
786static const char * const blsp_uim9_groups[] = {
787 "gpio49", "gpio50"
788};
789static const char * const blsp_i2c9_groups[] = {
790 "gpio51", "gpio52"
791};
792static const char * const pci_e0_groups[] = {
793 "gpio53", "gpio54",
794};
795static const char * const uim4_groups[] = {
796 "gpio53", "gpio54", "gpio55", "gpio56"
797};
798static const char * const blsp_spi10_groups[] = {
799 "gpio53", "gpio54", "gpio55", "gpio56"
800};
801static const char * const blsp_uart10_groups[] = {
802 "gpio53", "gpio54", "gpio55", "gpio56"
803};
804static const char * const blsp_uim10_groups[] = {
805 "gpio53", "gpio54"
806};
807static const char * const qdss_tracedata_a_groups[] = {
808 "gpio53", "gpio54", "gpio63", "gpio64", "gpio65",
809 "gpio66", "gpio67", "gpio74", "gpio75", "gpio76",
810 "gpio77", "gpio85", "gpio86", "gpio87", "gpio89",
811 "gpio90"
812};
813static const char * const gp_pdm0_groups[] = {
814 "gpio54", "gpio95"
815};
816static const char * const blsp_i2c10_groups[] = {
817 "gpio55", "gpio56"
818};
819static const char * const qdss_cti_trig_in_a_groups[] = {
820 "gpio55",
821};
822static const char * const qdss_cti_trig_out_a_groups[] = {
823 "gpio56",
824};
825static const char * const qua_mi2s_groups[] = {
826 "gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
827};
828static const char * const gcc_gp1_clk_a_groups[] = {
829 "gpio57"
830};
831static const char * const gcc_gp2_clk_a_groups[] = {
832 "gpio58"
833};
834static const char * const gcc_gp3_clk_a_groups[] = {
835 "gpio59"
836};
837static const char * const blsp_spi2_cs1_groups[] = {
838 "gpio62"
839};
840static const char * const blsp_spi2_cs2_groups[] = {
841 "gpio63"
842};
843static const char * const gp_pdm2_groups[] = {
844 "gpio63", "gpio79"
845};
846static const char * const pri_mi2s_groups[] = {
847 "gpio64", "gpio65", "gpio66", "gpio67", "gpio68"
848};
849static const char * const blsp_spi2_cs3_groups[] = {
850 "gpio66"
851};
852static const char * const spkr_i2s_groups[] = {
853 "gpio69", "gpio70", "gpio71", "gpio72"
854};
855static const char * const audio_ref_clk_groups[] = {
856 "gpio69"
857};
858static const char * const slimbus_groups[] = {
859 "gpio70", "gpio71"
860};
861static const char * const ter_mi2s_groups[] = {
862 "gpio73", "gpio74", "gpio75", "gpio76", "gpio77"
863};
864static const char * const gp_pdm1_groups[] = {
865 "gpio74", "gpio86"
866};
867static const char * const sec_mi2s_groups[] = {
868 "gpio78", "gpio79", "gpio80", "gpio81", "gpio82"
869};
870static const char * const gcc_gp1_clk_b_groups[] = {
871 "gpio78"
872};
873static const char * const blsp_spi11_groups[] = {
874 "gpio81", "gpio82", "gpio83", "gpio84"
875};
876static const char * const blsp_uart11_groups[] = {
877 "gpio81", "gpio82", "gpio83", "gpio84"
878};
879static const char * const blsp_uim11_groups[] = {
880 "gpio81", "gpio82"
881};
882static const char * const gcc_gp2_clk_b_groups[] = {
883 "gpio81"
884};
885static const char * const gcc_gp3_clk_b_groups[] = {
886 "gpio82"
887};
888static const char * const blsp_i2c11_groups[] = {
889 "gpio83", "gpio84"
890};
891static const char * const blsp_uart12_groups[] = {
892 "gpio85", "gpio86", "gpio87", "gpio88"
893};
894static const char * const blsp_uim12_groups[] = {
895 "gpio85", "gpio86"
896};
897static const char * const blsp_i2c12_groups[] = {
898 "gpio87", "gpio88"
899};
900static const char * const blsp_spi12_groups[] = {
901 "gpio85", "gpio86", "gpio87", "gpio88"
902};
903static const char * const tsif1_groups[] = {
904 "gpio89", "gpio90", "gpio91", "gpio110", "gpio111"
905};
906static const char * const blsp_spi10_cs3_groups[] = {
907 "gpio90"
908};
909static const char * const sdc4_groups[] = {
910 "gpio91", "gpio92", "gpio93", "gpio94", "gpio95", "gpio96"
911};
912static const char * const qdss_traceclk_b_groups[] = {
913 "gpio91",
914};
915static const char * const tsif2_groups[] = {
916 "gpio92", "gpio93", "gpio94", "gpio95", "gpio96"
917};
918static const char * const qdss_tracectl_b_groups[] = {
919 "gpio94",
920};
921static const char * const qdss_cti_trig_out_d_groups[] = {
922 "gpio95",
923};
924static const char * const qdss_cti_trig_in_d_groups[] = {
925 "gpio96",
926};
927static const char * const uim1_groups[] = {
928 "gpio97", "gpio98", "gpio99", "gpio100"
929};
930static const char * const uim_batt_alarm_groups[] = {
931 "gpio101"
932};
933static const char * const blsp11_uart_tx_b_groups[] = {
934 "gpio111"
935};
936static const char * const blsp11_uart_rx_b_groups[] = {
937 "gpio112"
938};
939static const char * const blsp11_i2c_sda_b_groups[] = {
940 "gpio113"
941};
942static const char * const blsp11_i2c_scl_b_groups[] = {
943 "gpio114"
944};
945static const char * const gsm_tx_groups[] = {
946 "gpio126", "gpio131", "gpio132", "gpio133"
947};
948static const char * const nav_tsync_groups[] = {
949 "gpio127"
950};
951static const char * const nav_pps_groups[] = {
952 "gpio127"
953};
954static const char * const gps_tx_groups[] = {
955 "gpio130"
956};
957static const char * const mss_lte_groups[] = {
958 "gpio134", "gpio135"
959};
960
961static const struct msm_function msm8994_functions[] = {
962 FUNCTION(audio_ref_clk),
963 FUNCTION(blsp_i2c1),
964 FUNCTION(blsp_i2c2),
965 FUNCTION(blsp_i2c3),
966 FUNCTION(blsp_i2c4),
967 FUNCTION(blsp_i2c5),
968 FUNCTION(blsp_i2c6),
969 FUNCTION(blsp_i2c7),
970 FUNCTION(blsp_i2c8),
971 FUNCTION(blsp_i2c9),
972 FUNCTION(blsp_i2c10),
973 FUNCTION(blsp_i2c11),
974 FUNCTION(blsp_i2c12),
975 FUNCTION(blsp_spi1),
976 FUNCTION(blsp_spi1_cs1),
977 FUNCTION(blsp_spi1_cs2),
978 FUNCTION(blsp_spi1_cs3),
979 FUNCTION(blsp_spi2),
980 FUNCTION(blsp_spi2_cs1),
981 FUNCTION(blsp_spi2_cs2),
982 FUNCTION(blsp_spi2_cs3),
983 FUNCTION(blsp_spi3),
984 FUNCTION(blsp_spi4),
985 FUNCTION(blsp_spi5),
986 FUNCTION(blsp_spi6),
987 FUNCTION(blsp_spi7),
988 FUNCTION(blsp_spi8),
989 FUNCTION(blsp_spi9),
990 FUNCTION(blsp_spi10),
991 FUNCTION(blsp_spi10_cs1),
992 FUNCTION(blsp_spi10_cs2),
993 FUNCTION(blsp_spi10_cs3),
994 FUNCTION(blsp_spi11),
995 FUNCTION(blsp_spi12),
996 FUNCTION(blsp_uart1),
997 FUNCTION(blsp_uart2),
998 FUNCTION(blsp_uart3),
999 FUNCTION(blsp_uart4),
1000 FUNCTION(blsp_uart5),
1001 FUNCTION(blsp_uart6),
1002 FUNCTION(blsp_uart7),
1003 FUNCTION(blsp_uart8),
1004 FUNCTION(blsp_uart9),
1005 FUNCTION(blsp_uart10),
1006 FUNCTION(blsp_uart11),
1007 FUNCTION(blsp_uart12),
1008 FUNCTION(blsp_uim1),
1009 FUNCTION(blsp_uim2),
1010 FUNCTION(blsp_uim3),
1011 FUNCTION(blsp_uim4),
1012 FUNCTION(blsp_uim5),
1013 FUNCTION(blsp_uim6),
1014 FUNCTION(blsp_uim7),
1015 FUNCTION(blsp_uim8),
1016 FUNCTION(blsp_uim9),
1017 FUNCTION(blsp_uim10),
1018 FUNCTION(blsp_uim11),
1019 FUNCTION(blsp_uim12),
1020 FUNCTION(blsp11_i2c_scl_b),
1021 FUNCTION(blsp11_i2c_sda_b),
1022 FUNCTION(blsp11_uart_rx_b),
1023 FUNCTION(blsp11_uart_tx_b),
1024 FUNCTION(cam_mclk0),
1025 FUNCTION(cam_mclk1),
1026 FUNCTION(cam_mclk2),
1027 FUNCTION(cam_mclk3),
1028 FUNCTION(cci_async_in0),
1029 FUNCTION(cci_async_in1),
1030 FUNCTION(cci_async_in2),
1031 FUNCTION(cci_i2c0),
1032 FUNCTION(cci_i2c1),
1033 FUNCTION(cci_timer0),
1034 FUNCTION(cci_timer1),
1035 FUNCTION(cci_timer2),
1036 FUNCTION(cci_timer3),
1037 FUNCTION(cci_timer4),
1038 FUNCTION(gcc_gp1_clk_a),
1039 FUNCTION(gcc_gp1_clk_b),
1040 FUNCTION(gcc_gp2_clk_a),
1041 FUNCTION(gcc_gp2_clk_b),
1042 FUNCTION(gcc_gp3_clk_a),
1043 FUNCTION(gcc_gp3_clk_b),
1044 FUNCTION(gp_mn),
1045 FUNCTION(gp_pdm0),
1046 FUNCTION(gp_pdm1),
1047 FUNCTION(gp_pdm2),
1048 FUNCTION(gp0_clk),
1049 FUNCTION(gp1_clk),
1050 FUNCTION(gps_tx),
1051 FUNCTION(gsm_tx),
1052 FUNCTION(hdmi_cec),
1053 FUNCTION(hdmi_ddc),
1054 FUNCTION(hdmi_hpd),
1055 FUNCTION(hdmi_rcv),
1056 FUNCTION(mdp_vsync),
1057 FUNCTION(mss_lte),
1058 FUNCTION(nav_pps),
1059 FUNCTION(nav_tsync),
1060 FUNCTION(qdss_cti_trig_in_a),
1061 FUNCTION(qdss_cti_trig_in_b),
1062 FUNCTION(qdss_cti_trig_in_c),
1063 FUNCTION(qdss_cti_trig_in_d),
1064 FUNCTION(qdss_cti_trig_out_a),
1065 FUNCTION(qdss_cti_trig_out_b),
1066 FUNCTION(qdss_cti_trig_out_c),
1067 FUNCTION(qdss_cti_trig_out_d),
1068 FUNCTION(qdss_traceclk_a),
1069 FUNCTION(qdss_traceclk_b),
1070 FUNCTION(qdss_tracectl_a),
1071 FUNCTION(qdss_tracectl_b),
1072 FUNCTION(qdss_tracedata_a),
1073 FUNCTION(qdss_tracedata_b),
1074 FUNCTION(qua_mi2s),
1075 FUNCTION(pci_e0),
1076 FUNCTION(pci_e1),
1077 FUNCTION(pri_mi2s),
1078 FUNCTION(sdc4),
1079 FUNCTION(sec_mi2s),
1080 FUNCTION(slimbus),
1081 FUNCTION(spkr_i2s),
1082 FUNCTION(ter_mi2s),
1083 FUNCTION(tsif1),
1084 FUNCTION(tsif2),
1085 FUNCTION(uim_batt_alarm),
1086 FUNCTION(uim1),
1087 FUNCTION(uim2),
1088 FUNCTION(uim3),
1089 FUNCTION(uim4),
1090 FUNCTION(gpio),
1091};
1092
1093static const struct msm_pingroup msm8994_groups[] = {
1094 PINGROUP(0, blsp_spi1, blsp_uart1, blsp_uim1, hdmi_rcv, NA, NA, NA,
1095 NA, NA, NA, NA),
1096 PINGROUP(1, blsp_spi1, blsp_uart1, blsp_uim1, NA, NA, NA, NA, NA, NA,
1097 NA, NA),
1098 PINGROUP(2, blsp_spi1, blsp_uart1, blsp_i2c1, NA, NA, NA, NA, NA, NA,
1099 NA, NA),
1100 PINGROUP(3, blsp_spi1, blsp_uart1, blsp_i2c1, NA, NA, NA, NA, NA, NA,
1101 NA, NA),
1102 PINGROUP(4, blsp_spi2, blsp_uart2, blsp_uim2, NA, qdss_cti_trig_out_b,
1103 NA, NA, NA, NA, NA, NA),
1104 PINGROUP(5, blsp_spi2, blsp_uart2, blsp_uim2, NA, qdss_cti_trig_in_b,
1105 NA, NA, NA, NA, NA, NA),
1106 PINGROUP(6, blsp_spi2, blsp_uart2, blsp_i2c2, NA, NA, NA, NA, NA, NA,
1107 NA, NA),
1108 PINGROUP(7, blsp_spi2, blsp_uart2, blsp_i2c2, NA, NA, NA, NA, NA, NA,
1109 NA, NA),
1110 PINGROUP(8, blsp_spi3, blsp_uart3, blsp_uim3, blsp_spi1_cs1, NA, NA,
1111 NA, NA, NA, NA, NA),
1112 PINGROUP(9, blsp_spi3, blsp_uart3, blsp_uim3, blsp_spi1_cs2, NA, NA,
1113 NA, NA, NA, NA, NA),
1114 PINGROUP(10, mdp_vsync, blsp_spi3, blsp_uart3, blsp_i2c3,
1115 blsp_spi1_cs3, NA, NA, NA, NA, NA, NA),
1116 PINGROUP(11, mdp_vsync, blsp_spi3, blsp_uart3, blsp_i2c3,
1117 blsp_spi1_cs2, NA, NA, NA, NA, NA, NA),
1118 PINGROUP(12, mdp_vsync, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1119 PINGROUP(13, cam_mclk0, NA, NA, qdss_tracedata_b, NA, NA, NA, NA, NA,
1120 NA, NA),
1121 PINGROUP(14, cam_mclk1, NA, NA, qdss_tracedata_b, NA, NA, NA, NA, NA,
1122 NA, NA),
1123 PINGROUP(15, cam_mclk2, NA, qdss_tracedata_b, NA, NA, NA, NA, NA, NA,
1124 NA, NA),
1125 PINGROUP(16, cam_mclk3, NA, qdss_tracedata_b, NA, NA, NA, NA, NA, NA,
1126 NA, NA),
1127 PINGROUP(17, cci_i2c0, blsp_spi4, blsp_uart4, blsp_uim4, NA,
1128 qdss_tracedata_b, NA, NA, NA, NA, NA),
1129 PINGROUP(18, cci_i2c0, blsp_spi4, blsp_uart4, blsp_uim4, NA,
1130 qdss_tracedata_b, NA, NA, NA, NA, NA),
1131 PINGROUP(19, cci_i2c1, blsp_spi4, blsp_uart4, blsp_i2c4, NA,
1132 qdss_tracedata_b, NA, NA, NA, NA, NA),
1133 PINGROUP(20, cci_i2c1, blsp_spi4, blsp_uart4, blsp_i2c4, NA, NA, NA,
1134 NA, NA, NA, NA),
1135 PINGROUP(21, cci_timer0, blsp_spi5, blsp_uart5, blsp_uim5, NA,
1136 qdss_tracedata_b, NA, NA, NA, NA, NA),
1137 PINGROUP(22, cci_timer1, blsp_spi5, blsp_uart5, blsp_uim5, NA,
1138 qdss_tracedata_b, NA, NA, NA, NA, NA),
1139 PINGROUP(23, cci_timer2, blsp_spi5, blsp_uart5, blsp_i2c5, NA, NA,
1140 qdss_tracedata_b, NA, NA, NA, NA),
1141 PINGROUP(24, cci_timer3, cci_async_in1, blsp_spi5, blsp_uart5,
1142 blsp_i2c5, NA, NA, NA, NA, NA, NA),
1143 PINGROUP(25, cci_timer4, cci_async_in2, blsp_spi6, blsp_uart6,
1144 blsp_uim6, NA, NA, qdss_tracedata_b, NA, NA, NA),
1145 PINGROUP(26, cci_async_in0, blsp_spi6, blsp_uart6, blsp_uim6, gp0_clk,
1146 NA, qdss_tracedata_b, NA, NA, NA, NA),
1147 PINGROUP(27, blsp_spi6, blsp_uart6, blsp_i2c6, gp1_clk,
1148 qdss_tracectl_a, NA, NA, NA, NA, NA, NA),
1149 PINGROUP(28, blsp_spi6, blsp_uart6, blsp_i2c6, qdss_traceclk_a, NA,
1150 NA, NA, NA, NA, NA, NA),
1151 PINGROUP(29, gp_mn, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1152 PINGROUP(30, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1153 PINGROUP(31, hdmi_cec, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1154 PINGROUP(32, hdmi_ddc, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1155 PINGROUP(33, hdmi_ddc, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1156 PINGROUP(34, hdmi_hpd, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1157 PINGROUP(35, uim3, pci_e1, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1158 PINGROUP(36, uim3, pci_e1, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1159 PINGROUP(37, uim3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1160 PINGROUP(38, uim3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1161 PINGROUP(39, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1162 PINGROUP(40, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1163 PINGROUP(41, blsp_spi7, blsp_uart7, blsp_uim7, qdss_cti_trig_out_c,
1164 NA, NA, NA, NA, NA, NA, NA),
1165 PINGROUP(42, blsp_spi7, blsp_uart7, blsp_uim7, qdss_cti_trig_in_c, NA,
1166 NA, NA, NA, NA, NA, NA),
1167 PINGROUP(43, blsp_spi7, blsp_uart7, blsp_i2c7, NA, NA, NA, NA, NA, NA,
1168 NA, NA),
1169 PINGROUP(44, blsp_spi7, blsp_uart7, blsp_i2c7, NA, NA, NA, NA, NA, NA,
1170 NA, NA),
1171 PINGROUP(45, blsp_spi8, blsp_uart8, blsp_uim8, NA, NA, NA, NA, NA, NA,
1172 NA, NA),
1173 PINGROUP(46, blsp_spi8, blsp_uart8, blsp_uim8, NA, NA, NA, NA, NA, NA,
1174 NA, NA),
1175 PINGROUP(47, blsp_spi8, blsp_uart8, blsp_i2c8, blsp_spi10_cs1, NA, NA,
1176 NA, NA, NA, NA, NA),
1177 PINGROUP(48, blsp_spi8, blsp_uart8, blsp_i2c8, blsp_spi10_cs2, NA, NA,
1178 NA, NA, NA, NA, NA),
1179 PINGROUP(49, uim2, blsp_spi9, blsp_uart9, blsp_uim9, NA, NA, NA, NA,
1180 NA, NA, NA),
1181 PINGROUP(50, uim2, blsp_spi9, blsp_uart9, blsp_uim9, NA, NA, NA, NA,
1182 NA, NA, NA),
1183 PINGROUP(51, uim2, blsp_spi9, blsp_uart9, blsp_i2c9, NA, NA, NA, NA,
1184 NA, NA, NA),
1185 PINGROUP(52, uim2, blsp_spi9, blsp_uart9, blsp_i2c9, NA, NA, NA, NA,
1186 NA, NA, NA),
1187 PINGROUP(53, uim4, pci_e0, blsp_spi10, blsp_uart10, blsp_uim10, NA,
1188 NA, qdss_tracedata_a, NA, NA, NA),
1189 PINGROUP(54, uim4, pci_e0, blsp_spi10, blsp_uart10, blsp_uim10,
1190 gp_pdm0, NA, NA, qdss_tracedata_a, NA, NA),
1191 PINGROUP(55, uim4, blsp_spi10, blsp_uart10, blsp_i2c10, NA, NA, NA,
1192 qdss_cti_trig_in_a, NA, NA, NA),
1193 PINGROUP(56, uim4, blsp_spi10, blsp_uart10, blsp_i2c10, NA, NA,
1194 qdss_cti_trig_out_a, NA, NA, NA, NA),
1195 PINGROUP(57, qua_mi2s, gcc_gp1_clk_a, NA, NA, qdss_tracedata_b, NA, NA,
1196 NA, NA, NA, NA),
1197 PINGROUP(58, qua_mi2s, gcc_gp2_clk_a, NA, NA, qdss_tracedata_b, NA, NA,
1198 NA, NA, NA, NA),
1199 PINGROUP(59, qua_mi2s, gcc_gp3_clk_a, NA, NA, NA, NA, NA, NA, NA, NA,
1200 NA),
1201 PINGROUP(60, qua_mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1202 PINGROUP(61, qua_mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1203 PINGROUP(62, qua_mi2s, blsp_spi2_cs1, NA, NA, NA, NA, NA, NA, NA, NA,
1204 NA),
1205 PINGROUP(63, qua_mi2s, blsp_spi2_cs2, gp_pdm2, NA, NA, NA, NA, NA,
1206 qdss_tracedata_a, NA, NA),
1207 PINGROUP(64, pri_mi2s, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA,
1208 NA, NA),
1209 PINGROUP(65, pri_mi2s, NA, NA, NA, qdss_tracedata_a, NA, NA, NA, NA,
1210 NA, NA),
1211 PINGROUP(66, pri_mi2s, blsp_spi2_cs3, NA, NA, NA, qdss_tracedata_a,
1212 NA, NA, NA, NA, NA),
1213 PINGROUP(67, pri_mi2s, blsp_spi10_cs1, NA, NA, NA, qdss_tracedata_a,
1214 NA, NA, NA, NA, NA),
1215 PINGROUP(68, pri_mi2s, blsp_spi10_cs2, NA, NA, NA, NA, NA, NA, NA, NA,
1216 NA),
1217 PINGROUP(69, spkr_i2s, audio_ref_clk, NA, NA, NA, NA, NA, NA, NA, NA,
1218 NA),
1219 PINGROUP(70, slimbus, spkr_i2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1220 PINGROUP(71, slimbus, spkr_i2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1221 PINGROUP(72, spkr_i2s, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1222 PINGROUP(73, ter_mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1223 PINGROUP(74, ter_mi2s, gp_pdm1, NA, NA, NA, qdss_tracedata_a, NA, NA,
1224 NA, NA, NA),
1225 PINGROUP(75, ter_mi2s, NA, NA, qdss_tracedata_a, NA, NA, NA, NA, NA,
1226 NA, NA),
1227 PINGROUP(76, ter_mi2s, NA, NA, qdss_tracedata_a, NA, NA, NA, NA, NA,
1228 NA, NA),
1229 PINGROUP(77, ter_mi2s, NA, NA, qdss_tracedata_a, NA, NA, NA, NA, NA,
1230 NA, NA),
1231 PINGROUP(78, sec_mi2s, gcc_gp1_clk_b, NA, NA, NA, NA, NA, NA, NA, NA,
1232 NA),
1233 PINGROUP(79, sec_mi2s, gp_pdm2, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1234 PINGROUP(80, sec_mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1235 PINGROUP(81, sec_mi2s, blsp_spi11, blsp_uart11, blsp_uim11,
1236 gcc_gp2_clk_b, NA, NA, NA, NA, NA, NA),
1237 PINGROUP(82, sec_mi2s, blsp_spi11, blsp_uart11, blsp_uim11,
1238 gcc_gp3_clk_b, NA, NA, NA, NA, NA, NA),
1239 PINGROUP(83, blsp_spi11, blsp_uart11, blsp_i2c11, NA, NA, NA, NA, NA,
1240 NA, NA, NA),
1241 PINGROUP(84, blsp_spi11, blsp_uart11, blsp_i2c11, NA, NA, NA, NA, NA,
1242 NA, NA, NA),
1243 PINGROUP(85, blsp_spi12, blsp_uart12, blsp_uim12, NA, NA,
1244 qdss_tracedata_a, NA, NA, NA, NA, NA),
1245 PINGROUP(86, blsp_spi12, blsp_uart12, blsp_uim12, gp_pdm1, NA,
1246 qdss_tracedata_a, NA, NA, NA, NA, NA),
1247 PINGROUP(87, blsp_spi12, blsp_uart12, blsp_i2c12, NA,
1248 qdss_tracedata_a, NA, NA, NA, NA, NA, NA),
1249 PINGROUP(88, blsp_spi12, blsp_uart12, blsp_i2c12, NA, NA, NA, NA, NA,
1250 NA, NA, NA),
1251 PINGROUP(89, tsif1, NA, qdss_tracedata_a, NA, NA, NA, NA, NA, NA, NA,
1252 NA),
1253 PINGROUP(90, tsif1, blsp_spi10_cs3, qdss_tracedata_a, NA, NA, NA, NA,
1254 NA, NA, NA, NA),
1255 PINGROUP(91, tsif1, sdc4, NA, NA, NA, NA, qdss_traceclk_b, NA, NA, NA,
1256 NA),
1257 PINGROUP(92, tsif2, sdc4, NA, NA, qdss_tracedata_b, NA, NA, NA, NA,
1258 NA, NA),
1259 PINGROUP(93, tsif2, sdc4, NA, NA, NA, NA, qdss_tracedata_b, NA, NA,
1260 NA, NA),
1261 PINGROUP(94, tsif2, sdc4, NA, NA, NA, NA, qdss_tracectl_b, NA, NA, NA,
1262 NA),
1263 PINGROUP(95, tsif2, sdc4, gp_pdm0, NA, NA, NA, qdss_cti_trig_out_d,
1264 NA, NA, NA, NA),
1265 PINGROUP(96, tsif2, sdc4, qdss_cti_trig_in_d, NA, NA, NA, NA, NA, NA,
1266 NA, NA),
1267 PINGROUP(97, uim1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1268 PINGROUP(98, uim1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1269 PINGROUP(99, uim1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1270 PINGROUP(100, uim1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1271 PINGROUP(101, uim_batt_alarm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1272 PINGROUP(102, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1273 PINGROUP(103, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1274 PINGROUP(104, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1275 PINGROUP(105, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1276 PINGROUP(106, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1277 PINGROUP(107, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1278 PINGROUP(108, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1279 PINGROUP(109, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1280 PINGROUP(110, tsif1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1281 PINGROUP(111, tsif1, blsp11_uart_tx_b, NA, NA, NA, NA, NA, NA, NA, NA,
1282 NA),
1283 PINGROUP(112, blsp11_uart_rx_b, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1284 NA),
1285 PINGROUP(113, blsp11_i2c_sda_b, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1286 NA),
1287 PINGROUP(114, blsp11_i2c_scl_b, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1288 NA),
1289 PINGROUP(115, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1290 PINGROUP(116, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1291 PINGROUP(117, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1292 PINGROUP(118, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1293 PINGROUP(119, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1294 PINGROUP(120, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1295 PINGROUP(121, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1296 PINGROUP(122, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1297 PINGROUP(123, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1298 PINGROUP(124, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1299 PINGROUP(125, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1300 PINGROUP(126, NA, gsm_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1301 PINGROUP(127, NA, nav_tsync, nav_pps, NA, NA, NA, NA, NA, NA, NA,
1302 NA),
1303 PINGROUP(128, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1304 PINGROUP(129, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1305 PINGROUP(130, gps_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1306 PINGROUP(131, gsm_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1307 PINGROUP(132, gsm_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1308 PINGROUP(133, gsm_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1309 PINGROUP(134, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1310 PINGROUP(135, mss_lte, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1311 PINGROUP(136, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1312 PINGROUP(137, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1313 PINGROUP(138, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1314 PINGROUP(139, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1315 PINGROUP(140, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1316 PINGROUP(141, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1317 PINGROUP(142, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1318 PINGROUP(143, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1319 PINGROUP(144, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1320 PINGROUP(145, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
1321 SDC_PINGROUP(sdc1_rclk, 0x2044, 15, 0),
1322 SDC_PINGROUP(sdc1_clk, 0x2044, 13, 6),
1323 SDC_PINGROUP(sdc1_cmd, 0x2044, 11, 3),
1324 SDC_PINGROUP(sdc1_data, 0x2044, 9, 0),
1325 SDC_PINGROUP(sdc2_clk, 0x2048, 14, 6),
1326 SDC_PINGROUP(sdc2_cmd, 0x2048, 11, 3),
1327 SDC_PINGROUP(sdc2_data, 0x2048, 9, 0),
1328 SDC_PINGROUP(sdc3_clk, 0x206c, 14, 6),
1329 SDC_PINGROUP(sdc3_cmd, 0x206c, 11, 3),
1330 SDC_PINGROUP(sdc3_data, 0x206c, 9, 0),
1331};
1332
1333#define NUM_GPIO_PINGROUPS 146
1334
1335static const struct msm_pinctrl_soc_data msm8994_pinctrl = {
1336 .pins = msm8994_pins,
1337 .npins = ARRAY_SIZE(msm8994_pins),
1338 .functions = msm8994_functions,
1339 .nfunctions = ARRAY_SIZE(msm8994_functions),
1340 .groups = msm8994_groups,
1341 .ngroups = ARRAY_SIZE(msm8994_groups),
1342 .ngpios = NUM_GPIO_PINGROUPS,
1343};
1344
1345static int msm8994_pinctrl_probe(struct platform_device *pdev)
1346{
1347 return msm_pinctrl_probe(pdev, &msm8994_pinctrl);
1348}
1349
1350static const struct of_device_id msm8994_pinctrl_of_match[] = {
1351 { .compatible = "qcom,msm8992-pinctrl", },
1352 { .compatible = "qcom,msm8994-pinctrl", },
1353 { }
1354};
1355
1356static struct platform_driver msm8994_pinctrl_driver = {
1357 .driver = {
1358 .name = "msm8994-pinctrl",
1359 .of_match_table = msm8994_pinctrl_of_match,
1360 },
1361 .probe = msm8994_pinctrl_probe,
1362 .remove = msm_pinctrl_remove,
1363};
1364
1365static int __init msm8994_pinctrl_init(void)
1366{
1367 return platform_driver_register(&msm8994_pinctrl_driver);
1368}
1369arch_initcall(msm8994_pinctrl_init);
1370
1371static void __exit msm8994_pinctrl_exit(void)
1372{
1373 platform_driver_unregister(&msm8994_pinctrl_driver);
1374}
1375module_exit(msm8994_pinctrl_exit);
1376
1377MODULE_DESCRIPTION("Qualcomm MSM8994 pinctrl driver");
1378MODULE_LICENSE("GPL v2");
1379MODULE_DEVICE_TABLE(of, msm8994_pinctrl_of_match);
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index d32fa2b5ff82..12f7d1eb65bc 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -61,16 +61,15 @@ static void exynos_irq_mask(struct irq_data *irqd)
61 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 61 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
62 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 62 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
63 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 63 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
64 struct samsung_pinctrl_drv_data *d = bank->drvdata;
65 unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset; 64 unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset;
66 unsigned long mask; 65 unsigned long mask;
67 unsigned long flags; 66 unsigned long flags;
68 67
69 spin_lock_irqsave(&bank->slock, flags); 68 spin_lock_irqsave(&bank->slock, flags);
70 69
71 mask = readl(d->virt_base + reg_mask); 70 mask = readl(bank->eint_base + reg_mask);
72 mask |= 1 << irqd->hwirq; 71 mask |= 1 << irqd->hwirq;
73 writel(mask, d->virt_base + reg_mask); 72 writel(mask, bank->eint_base + reg_mask);
74 73
75 spin_unlock_irqrestore(&bank->slock, flags); 74 spin_unlock_irqrestore(&bank->slock, flags);
76} 75}
@@ -80,10 +79,9 @@ static void exynos_irq_ack(struct irq_data *irqd)
80 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 79 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
81 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 80 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
82 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 81 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
83 struct samsung_pinctrl_drv_data *d = bank->drvdata;
84 unsigned long reg_pend = our_chip->eint_pend + bank->eint_offset; 82 unsigned long reg_pend = our_chip->eint_pend + bank->eint_offset;
85 83
86 writel(1 << irqd->hwirq, d->virt_base + reg_pend); 84 writel(1 << irqd->hwirq, bank->eint_base + reg_pend);
87} 85}
88 86
89static void exynos_irq_unmask(struct irq_data *irqd) 87static void exynos_irq_unmask(struct irq_data *irqd)
@@ -91,7 +89,6 @@ static void exynos_irq_unmask(struct irq_data *irqd)
91 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 89 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
92 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 90 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
93 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 91 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
94 struct samsung_pinctrl_drv_data *d = bank->drvdata;
95 unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset; 92 unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset;
96 unsigned long mask; 93 unsigned long mask;
97 unsigned long flags; 94 unsigned long flags;
@@ -109,9 +106,9 @@ static void exynos_irq_unmask(struct irq_data *irqd)
109 106
110 spin_lock_irqsave(&bank->slock, flags); 107 spin_lock_irqsave(&bank->slock, flags);
111 108
112 mask = readl(d->virt_base + reg_mask); 109 mask = readl(bank->eint_base + reg_mask);
113 mask &= ~(1 << irqd->hwirq); 110 mask &= ~(1 << irqd->hwirq);
114 writel(mask, d->virt_base + reg_mask); 111 writel(mask, bank->eint_base + reg_mask);
115 112
116 spin_unlock_irqrestore(&bank->slock, flags); 113 spin_unlock_irqrestore(&bank->slock, flags);
117} 114}
@@ -121,7 +118,6 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
121 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 118 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
122 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 119 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
123 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 120 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
124 struct samsung_pinctrl_drv_data *d = bank->drvdata;
125 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq; 121 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
126 unsigned int con, trig_type; 122 unsigned int con, trig_type;
127 unsigned long reg_con = our_chip->eint_con + bank->eint_offset; 123 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
@@ -152,10 +148,10 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
152 else 148 else
153 irq_set_handler_locked(irqd, handle_level_irq); 149 irq_set_handler_locked(irqd, handle_level_irq);
154 150
155 con = readl(d->virt_base + reg_con); 151 con = readl(bank->eint_base + reg_con);
156 con &= ~(EXYNOS_EINT_CON_MASK << shift); 152 con &= ~(EXYNOS_EINT_CON_MASK << shift);
157 con |= trig_type << shift; 153 con |= trig_type << shift;
158 writel(con, d->virt_base + reg_con); 154 writel(con, bank->eint_base + reg_con);
159 155
160 return 0; 156 return 0;
161} 157}
@@ -166,7 +162,6 @@ static int exynos_irq_request_resources(struct irq_data *irqd)
166 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 162 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
167 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 163 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
168 const struct samsung_pin_bank_type *bank_type = bank->type; 164 const struct samsung_pin_bank_type *bank_type = bank->type;
169 struct samsung_pinctrl_drv_data *d = bank->drvdata;
170 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq; 165 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
171 unsigned long reg_con = our_chip->eint_con + bank->eint_offset; 166 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
172 unsigned long flags; 167 unsigned long flags;
@@ -188,10 +183,10 @@ static int exynos_irq_request_resources(struct irq_data *irqd)
188 183
189 spin_lock_irqsave(&bank->slock, flags); 184 spin_lock_irqsave(&bank->slock, flags);
190 185
191 con = readl(d->virt_base + reg_con); 186 con = readl(bank->eint_base + reg_con);
192 con &= ~(mask << shift); 187 con &= ~(mask << shift);
193 con |= EXYNOS_EINT_FUNC << shift; 188 con |= EXYNOS_EINT_FUNC << shift;
194 writel(con, d->virt_base + reg_con); 189 writel(con, bank->eint_base + reg_con);
195 190
196 spin_unlock_irqrestore(&bank->slock, flags); 191 spin_unlock_irqrestore(&bank->slock, flags);
197 192
@@ -206,7 +201,6 @@ static void exynos_irq_release_resources(struct irq_data *irqd)
206 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 201 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
207 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 202 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
208 const struct samsung_pin_bank_type *bank_type = bank->type; 203 const struct samsung_pin_bank_type *bank_type = bank->type;
209 struct samsung_pinctrl_drv_data *d = bank->drvdata;
210 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq; 204 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
211 unsigned long reg_con = our_chip->eint_con + bank->eint_offset; 205 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
212 unsigned long flags; 206 unsigned long flags;
@@ -221,10 +215,10 @@ static void exynos_irq_release_resources(struct irq_data *irqd)
221 215
222 spin_lock_irqsave(&bank->slock, flags); 216 spin_lock_irqsave(&bank->slock, flags);
223 217
224 con = readl(d->virt_base + reg_con); 218 con = readl(bank->eint_base + reg_con);
225 con &= ~(mask << shift); 219 con &= ~(mask << shift);
226 con |= FUNC_INPUT << shift; 220 con |= FUNC_INPUT << shift;
227 writel(con, d->virt_base + reg_con); 221 writel(con, bank->eint_base + reg_con);
228 222
229 spin_unlock_irqrestore(&bank->slock, flags); 223 spin_unlock_irqrestore(&bank->slock, flags);
230 224
@@ -274,7 +268,7 @@ static irqreturn_t exynos_eint_gpio_irq(int irq, void *data)
274 struct samsung_pin_bank *bank = d->pin_banks; 268 struct samsung_pin_bank *bank = d->pin_banks;
275 unsigned int svc, group, pin, virq; 269 unsigned int svc, group, pin, virq;
276 270
277 svc = readl(d->virt_base + EXYNOS_SVC_OFFSET); 271 svc = readl(bank->eint_base + EXYNOS_SVC_OFFSET);
278 group = EXYNOS_SVC_GROUP(svc); 272 group = EXYNOS_SVC_GROUP(svc);
279 pin = svc & EXYNOS_SVC_NUM_MASK; 273 pin = svc & EXYNOS_SVC_NUM_MASK;
280 274
@@ -452,7 +446,6 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
452{ 446{
453 struct irq_chip *chip = irq_desc_get_chip(desc); 447 struct irq_chip *chip = irq_desc_get_chip(desc);
454 struct exynos_muxed_weint_data *eintd = irq_desc_get_handler_data(desc); 448 struct exynos_muxed_weint_data *eintd = irq_desc_get_handler_data(desc);
455 struct samsung_pinctrl_drv_data *d = eintd->banks[0]->drvdata;
456 unsigned long pend; 449 unsigned long pend;
457 unsigned long mask; 450 unsigned long mask;
458 int i; 451 int i;
@@ -461,9 +454,9 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
461 454
462 for (i = 0; i < eintd->nr_banks; ++i) { 455 for (i = 0; i < eintd->nr_banks; ++i) {
463 struct samsung_pin_bank *b = eintd->banks[i]; 456 struct samsung_pin_bank *b = eintd->banks[i];
464 pend = readl(d->virt_base + b->irq_chip->eint_pend 457 pend = readl(b->eint_base + b->irq_chip->eint_pend
465 + b->eint_offset); 458 + b->eint_offset);
466 mask = readl(d->virt_base + b->irq_chip->eint_mask 459 mask = readl(b->eint_base + b->irq_chip->eint_mask
467 + b->eint_offset); 460 + b->eint_offset);
468 exynos_irq_demux_eint(pend & ~mask, b->irq_domain); 461 exynos_irq_demux_eint(pend & ~mask, b->irq_domain);
469 } 462 }
@@ -581,7 +574,7 @@ static void exynos_pinctrl_suspend_bank(
581 struct samsung_pin_bank *bank) 574 struct samsung_pin_bank *bank)
582{ 575{
583 struct exynos_eint_gpio_save *save = bank->soc_priv; 576 struct exynos_eint_gpio_save *save = bank->soc_priv;
584 void __iomem *regs = drvdata->virt_base; 577 void __iomem *regs = bank->eint_base;
585 578
586 save->eint_con = readl(regs + EXYNOS_GPIO_ECON_OFFSET 579 save->eint_con = readl(regs + EXYNOS_GPIO_ECON_OFFSET
587 + bank->eint_offset); 580 + bank->eint_offset);
@@ -610,7 +603,7 @@ static void exynos_pinctrl_resume_bank(
610 struct samsung_pin_bank *bank) 603 struct samsung_pin_bank *bank)
611{ 604{
612 struct exynos_eint_gpio_save *save = bank->soc_priv; 605 struct exynos_eint_gpio_save *save = bank->soc_priv;
613 void __iomem *regs = drvdata->virt_base; 606 void __iomem *regs = bank->eint_base;
614 607
615 pr_debug("%s: con %#010x => %#010x\n", bank->name, 608 pr_debug("%s: con %#010x => %#010x\n", bank->name,
616 readl(regs + EXYNOS_GPIO_ECON_OFFSET 609 readl(regs + EXYNOS_GPIO_ECON_OFFSET
@@ -1346,6 +1339,11 @@ static const struct samsung_pin_bank_data exynos5433_pin_banks0[] = {
1346 EXYNOS_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04), 1339 EXYNOS_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04),
1347 EXYNOS_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08), 1340 EXYNOS_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08),
1348 EXYNOS_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c), 1341 EXYNOS_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c),
1342 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1),
1343 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1),
1344 EXYNOS_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1),
1345 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1),
1346 EXYNOS_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1),
1349}; 1347};
1350 1348
1351/* pin banks of exynos5433 pin-controller - AUD */ 1349/* pin banks of exynos5433 pin-controller - AUD */
@@ -1427,6 +1425,7 @@ const struct samsung_pin_ctrl exynos5433_pin_ctrl[] = {
1427 .eint_wkup_init = exynos_eint_wkup_init, 1425 .eint_wkup_init = exynos_eint_wkup_init,
1428 .suspend = exynos_pinctrl_suspend, 1426 .suspend = exynos_pinctrl_suspend,
1429 .resume = exynos_pinctrl_resume, 1427 .resume = exynos_pinctrl_resume,
1428 .nr_ext_resources = 1,
1430 }, { 1429 }, {
1431 /* pin-controller instance 1 data */ 1430 /* pin-controller instance 1 data */
1432 .pin_banks = exynos5433_pin_banks1, 1431 .pin_banks = exynos5433_pin_banks1,
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.h b/drivers/pinctrl/samsung/pinctrl-exynos.h
index 0f0f7cedb2dc..5821525a2c84 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.h
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.h
@@ -79,6 +79,17 @@
79 .name = id \ 79 .name = id \
80 } 80 }
81 81
82#define EXYNOS_PIN_BANK_EINTW_EXT(pins, reg, id, offs, pctl_idx) \
83 { \
84 .type = &bank_type_alive, \
85 .pctl_offset = reg, \
86 .nr_pins = pins, \
87 .eint_type = EINT_TYPE_WKUP, \
88 .eint_offset = offs, \
89 .name = id, \
90 .pctl_res_idx = pctl_idx, \
91 } \
92
82/** 93/**
83 * struct exynos_weint_data: irq specific data for all the wakeup interrupts 94 * struct exynos_weint_data: irq specific data for all the wakeup interrupts
84 * generated by the external wakeup interrupt controller. 95 * generated by the external wakeup interrupt controller.
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
index 3d92f827da7a..b82a003546ae 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
@@ -151,7 +151,7 @@ static void s3c24xx_eint_set_function(struct samsung_pinctrl_drv_data *d,
151 u32 val; 151 u32 val;
152 152
153 /* Make sure that pin is configured as interrupt */ 153 /* Make sure that pin is configured as interrupt */
154 reg = d->virt_base + bank->pctl_offset; 154 reg = bank->pctl_base + bank->pctl_offset;
155 shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC]; 155 shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC];
156 mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; 156 mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
157 157
@@ -184,7 +184,7 @@ static int s3c24xx_eint_type(struct irq_data *data, unsigned int type)
184 s3c24xx_eint_set_handler(data, type); 184 s3c24xx_eint_set_handler(data, type);
185 185
186 /* Set up interrupt trigger */ 186 /* Set up interrupt trigger */
187 reg = d->virt_base + EINT_REG(index); 187 reg = bank->eint_base + EINT_REG(index);
188 shift = EINT_OFFS(index); 188 shift = EINT_OFFS(index);
189 189
190 val = readl(reg); 190 val = readl(reg);
@@ -259,32 +259,29 @@ static void s3c2410_demux_eint0_3(struct irq_desc *desc)
259static void s3c2412_eint0_3_ack(struct irq_data *data) 259static void s3c2412_eint0_3_ack(struct irq_data *data)
260{ 260{
261 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 261 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
262 struct samsung_pinctrl_drv_data *d = bank->drvdata;
263 262
264 unsigned long bitval = 1UL << data->hwirq; 263 unsigned long bitval = 1UL << data->hwirq;
265 writel(bitval, d->virt_base + EINTPEND_REG); 264 writel(bitval, bank->eint_base + EINTPEND_REG);
266} 265}
267 266
268static void s3c2412_eint0_3_mask(struct irq_data *data) 267static void s3c2412_eint0_3_mask(struct irq_data *data)
269{ 268{
270 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 269 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
271 struct samsung_pinctrl_drv_data *d = bank->drvdata;
272 unsigned long mask; 270 unsigned long mask;
273 271
274 mask = readl(d->virt_base + EINTMASK_REG); 272 mask = readl(bank->eint_base + EINTMASK_REG);
275 mask |= (1UL << data->hwirq); 273 mask |= (1UL << data->hwirq);
276 writel(mask, d->virt_base + EINTMASK_REG); 274 writel(mask, bank->eint_base + EINTMASK_REG);
277} 275}
278 276
279static void s3c2412_eint0_3_unmask(struct irq_data *data) 277static void s3c2412_eint0_3_unmask(struct irq_data *data)
280{ 278{
281 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 279 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
282 struct samsung_pinctrl_drv_data *d = bank->drvdata;
283 unsigned long mask; 280 unsigned long mask;
284 281
285 mask = readl(d->virt_base + EINTMASK_REG); 282 mask = readl(bank->eint_base + EINTMASK_REG);
286 mask &= ~(1UL << data->hwirq); 283 mask &= ~(1UL << data->hwirq);
287 writel(mask, d->virt_base + EINTMASK_REG); 284 writel(mask, bank->eint_base + EINTMASK_REG);
288} 285}
289 286
290static struct irq_chip s3c2412_eint0_3_chip = { 287static struct irq_chip s3c2412_eint0_3_chip = {
@@ -319,34 +316,31 @@ static void s3c2412_demux_eint0_3(struct irq_desc *desc)
319static void s3c24xx_eint_ack(struct irq_data *data) 316static void s3c24xx_eint_ack(struct irq_data *data)
320{ 317{
321 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 318 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
322 struct samsung_pinctrl_drv_data *d = bank->drvdata;
323 unsigned char index = bank->eint_offset + data->hwirq; 319 unsigned char index = bank->eint_offset + data->hwirq;
324 320
325 writel(1UL << index, d->virt_base + EINTPEND_REG); 321 writel(1UL << index, bank->eint_base + EINTPEND_REG);
326} 322}
327 323
328static void s3c24xx_eint_mask(struct irq_data *data) 324static void s3c24xx_eint_mask(struct irq_data *data)
329{ 325{
330 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 326 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
331 struct samsung_pinctrl_drv_data *d = bank->drvdata;
332 unsigned char index = bank->eint_offset + data->hwirq; 327 unsigned char index = bank->eint_offset + data->hwirq;
333 unsigned long mask; 328 unsigned long mask;
334 329
335 mask = readl(d->virt_base + EINTMASK_REG); 330 mask = readl(bank->eint_base + EINTMASK_REG);
336 mask |= (1UL << index); 331 mask |= (1UL << index);
337 writel(mask, d->virt_base + EINTMASK_REG); 332 writel(mask, bank->eint_base + EINTMASK_REG);
338} 333}
339 334
340static void s3c24xx_eint_unmask(struct irq_data *data) 335static void s3c24xx_eint_unmask(struct irq_data *data)
341{ 336{
342 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data); 337 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
343 struct samsung_pinctrl_drv_data *d = bank->drvdata;
344 unsigned char index = bank->eint_offset + data->hwirq; 338 unsigned char index = bank->eint_offset + data->hwirq;
345 unsigned long mask; 339 unsigned long mask;
346 340
347 mask = readl(d->virt_base + EINTMASK_REG); 341 mask = readl(bank->eint_base + EINTMASK_REG);
348 mask &= ~(1UL << index); 342 mask &= ~(1UL << index);
349 writel(mask, d->virt_base + EINTMASK_REG); 343 writel(mask, bank->eint_base + EINTMASK_REG);
350} 344}
351 345
352static struct irq_chip s3c24xx_eint_chip = { 346static struct irq_chip s3c24xx_eint_chip = {
@@ -362,13 +356,14 @@ static inline void s3c24xx_demux_eint(struct irq_desc *desc,
362{ 356{
363 struct s3c24xx_eint_data *data = irq_desc_get_handler_data(desc); 357 struct s3c24xx_eint_data *data = irq_desc_get_handler_data(desc);
364 struct irq_chip *chip = irq_desc_get_chip(desc); 358 struct irq_chip *chip = irq_desc_get_chip(desc);
365 struct samsung_pinctrl_drv_data *d = data->drvdata; 359 struct irq_data *irqd = irq_desc_get_irq_data(desc);
360 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
366 unsigned int pend, mask; 361 unsigned int pend, mask;
367 362
368 chained_irq_enter(chip, desc); 363 chained_irq_enter(chip, desc);
369 364
370 pend = readl(d->virt_base + EINTPEND_REG); 365 pend = readl(bank->eint_base + EINTPEND_REG);
371 mask = readl(d->virt_base + EINTMASK_REG); 366 mask = readl(bank->eint_base + EINTMASK_REG);
372 367
373 pend &= ~mask; 368 pend &= ~mask;
374 pend &= range; 369 pend &= range;
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
index 43407ab248f5..4c632812ccff 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
@@ -280,7 +280,7 @@ static void s3c64xx_irq_set_function(struct samsung_pinctrl_drv_data *d,
280 u32 val; 280 u32 val;
281 281
282 /* Make sure that pin is configured as interrupt */ 282 /* Make sure that pin is configured as interrupt */
283 reg = d->virt_base + bank->pctl_offset; 283 reg = bank->pctl_base + bank->pctl_offset;
284 shift = pin; 284 shift = pin;
285 if (bank_type->fld_width[PINCFG_TYPE_FUNC] * shift >= 32) { 285 if (bank_type->fld_width[PINCFG_TYPE_FUNC] * shift >= 32) {
286 /* 4-bit bank type with 2 con regs */ 286 /* 4-bit bank type with 2 con regs */
@@ -308,9 +308,8 @@ static void s3c64xx_irq_set_function(struct samsung_pinctrl_drv_data *d,
308static inline void s3c64xx_gpio_irq_set_mask(struct irq_data *irqd, bool mask) 308static inline void s3c64xx_gpio_irq_set_mask(struct irq_data *irqd, bool mask)
309{ 309{
310 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 310 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
311 struct samsung_pinctrl_drv_data *d = bank->drvdata;
312 unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq; 311 unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
313 void __iomem *reg = d->virt_base + EINTMASK_REG(bank->eint_offset); 312 void __iomem *reg = bank->eint_base + EINTMASK_REG(bank->eint_offset);
314 u32 val; 313 u32 val;
315 314
316 val = readl(reg); 315 val = readl(reg);
@@ -334,9 +333,8 @@ static void s3c64xx_gpio_irq_mask(struct irq_data *irqd)
334static void s3c64xx_gpio_irq_ack(struct irq_data *irqd) 333static void s3c64xx_gpio_irq_ack(struct irq_data *irqd)
335{ 334{
336 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 335 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
337 struct samsung_pinctrl_drv_data *d = bank->drvdata;
338 unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq; 336 unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
339 void __iomem *reg = d->virt_base + EINTPEND_REG(bank->eint_offset); 337 void __iomem *reg = bank->eint_base + EINTPEND_REG(bank->eint_offset);
340 338
341 writel(1 << index, reg); 339 writel(1 << index, reg);
342} 340}
@@ -359,7 +357,7 @@ static int s3c64xx_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
359 s3c64xx_irq_set_handler(irqd, type); 357 s3c64xx_irq_set_handler(irqd, type);
360 358
361 /* Set up interrupt trigger */ 359 /* Set up interrupt trigger */
362 reg = d->virt_base + EINTCON_REG(bank->eint_offset); 360 reg = bank->eint_base + EINTCON_REG(bank->eint_offset);
363 shift = EINT_OFFS(bank->eint_offset) + irqd->hwirq; 361 shift = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
364 shift = 4 * (shift / 4); /* 4 EINTs per trigger selector */ 362 shift = 4 * (shift / 4); /* 4 EINTs per trigger selector */
365 363
@@ -411,7 +409,8 @@ static void s3c64xx_eint_gpio_irq(struct irq_desc *desc)
411{ 409{
412 struct irq_chip *chip = irq_desc_get_chip(desc); 410 struct irq_chip *chip = irq_desc_get_chip(desc);
413 struct s3c64xx_eint_gpio_data *data = irq_desc_get_handler_data(desc); 411 struct s3c64xx_eint_gpio_data *data = irq_desc_get_handler_data(desc);
414 struct samsung_pinctrl_drv_data *drvdata = data->drvdata; 412 struct irq_data *irqd = irq_desc_get_irq_data(desc);
413 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
415 414
416 chained_irq_enter(chip, desc); 415 chained_irq_enter(chip, desc);
417 416
@@ -421,7 +420,7 @@ static void s3c64xx_eint_gpio_irq(struct irq_desc *desc)
421 unsigned int pin; 420 unsigned int pin;
422 unsigned int virq; 421 unsigned int virq;
423 422
424 svc = readl(drvdata->virt_base + SERVICE_REG); 423 svc = readl(bank->eint_base + SERVICE_REG);
425 group = SVC_GROUP(svc); 424 group = SVC_GROUP(svc);
426 pin = svc & SVC_NUM_MASK; 425 pin = svc & SVC_NUM_MASK;
427 426
@@ -518,15 +517,15 @@ static inline void s3c64xx_eint0_irq_set_mask(struct irq_data *irqd, bool mask)
518{ 517{
519 struct s3c64xx_eint0_domain_data *ddata = 518 struct s3c64xx_eint0_domain_data *ddata =
520 irq_data_get_irq_chip_data(irqd); 519 irq_data_get_irq_chip_data(irqd);
521 struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata; 520 struct samsung_pin_bank *bank = ddata->bank;
522 u32 val; 521 u32 val;
523 522
524 val = readl(d->virt_base + EINT0MASK_REG); 523 val = readl(bank->eint_base + EINT0MASK_REG);
525 if (mask) 524 if (mask)
526 val |= 1 << ddata->eints[irqd->hwirq]; 525 val |= 1 << ddata->eints[irqd->hwirq];
527 else 526 else
528 val &= ~(1 << ddata->eints[irqd->hwirq]); 527 val &= ~(1 << ddata->eints[irqd->hwirq]);
529 writel(val, d->virt_base + EINT0MASK_REG); 528 writel(val, bank->eint_base + EINT0MASK_REG);
530} 529}
531 530
532static void s3c64xx_eint0_irq_unmask(struct irq_data *irqd) 531static void s3c64xx_eint0_irq_unmask(struct irq_data *irqd)
@@ -543,10 +542,10 @@ static void s3c64xx_eint0_irq_ack(struct irq_data *irqd)
543{ 542{
544 struct s3c64xx_eint0_domain_data *ddata = 543 struct s3c64xx_eint0_domain_data *ddata =
545 irq_data_get_irq_chip_data(irqd); 544 irq_data_get_irq_chip_data(irqd);
546 struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata; 545 struct samsung_pin_bank *bank = ddata->bank;
547 546
548 writel(1 << ddata->eints[irqd->hwirq], 547 writel(1 << ddata->eints[irqd->hwirq],
549 d->virt_base + EINT0PEND_REG); 548 bank->eint_base + EINT0PEND_REG);
550} 549}
551 550
552static int s3c64xx_eint0_irq_set_type(struct irq_data *irqd, unsigned int type) 551static int s3c64xx_eint0_irq_set_type(struct irq_data *irqd, unsigned int type)
@@ -554,7 +553,7 @@ static int s3c64xx_eint0_irq_set_type(struct irq_data *irqd, unsigned int type)
554 struct s3c64xx_eint0_domain_data *ddata = 553 struct s3c64xx_eint0_domain_data *ddata =
555 irq_data_get_irq_chip_data(irqd); 554 irq_data_get_irq_chip_data(irqd);
556 struct samsung_pin_bank *bank = ddata->bank; 555 struct samsung_pin_bank *bank = ddata->bank;
557 struct samsung_pinctrl_drv_data *d = bank->drvdata; 556 struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata;
558 void __iomem *reg; 557 void __iomem *reg;
559 int trigger; 558 int trigger;
560 u8 shift; 559 u8 shift;
@@ -569,7 +568,7 @@ static int s3c64xx_eint0_irq_set_type(struct irq_data *irqd, unsigned int type)
569 s3c64xx_irq_set_handler(irqd, type); 568 s3c64xx_irq_set_handler(irqd, type);
570 569
571 /* Set up interrupt trigger */ 570 /* Set up interrupt trigger */
572 reg = d->virt_base + EINT0CON0_REG; 571 reg = bank->eint_base + EINT0CON0_REG;
573 shift = ddata->eints[irqd->hwirq]; 572 shift = ddata->eints[irqd->hwirq];
574 if (shift >= EINT_MAX_PER_REG) { 573 if (shift >= EINT_MAX_PER_REG) {
575 reg += 4; 574 reg += 4;
@@ -601,14 +600,19 @@ static struct irq_chip s3c64xx_eint0_irq_chip = {
601static inline void s3c64xx_irq_demux_eint(struct irq_desc *desc, u32 range) 600static inline void s3c64xx_irq_demux_eint(struct irq_desc *desc, u32 range)
602{ 601{
603 struct irq_chip *chip = irq_desc_get_chip(desc); 602 struct irq_chip *chip = irq_desc_get_chip(desc);
603 struct irq_data *irqd = irq_desc_get_irq_data(desc);
604 struct s3c64xx_eint0_domain_data *ddata =
605 irq_data_get_irq_chip_data(irqd);
606 struct samsung_pin_bank *bank = ddata->bank;
607
604 struct s3c64xx_eint0_data *data = irq_desc_get_handler_data(desc); 608 struct s3c64xx_eint0_data *data = irq_desc_get_handler_data(desc);
605 struct samsung_pinctrl_drv_data *drvdata = data->drvdata; 609
606 unsigned int pend, mask; 610 unsigned int pend, mask;
607 611
608 chained_irq_enter(chip, desc); 612 chained_irq_enter(chip, desc);
609 613
610 pend = readl(drvdata->virt_base + EINT0PEND_REG); 614 pend = readl(bank->eint_base + EINT0PEND_REG);
611 mask = readl(drvdata->virt_base + EINT0MASK_REG); 615 mask = readl(bank->eint_base + EINT0MASK_REG);
612 616
613 pend = pend & range & ~mask; 617 pend = pend & range & ~mask;
614 pend &= range; 618 pend &= range;
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index 620727fabe64..41e62391c33c 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -33,6 +33,9 @@
33#include "../core.h" 33#include "../core.h"
34#include "pinctrl-samsung.h" 34#include "pinctrl-samsung.h"
35 35
36/* maximum number of the memory resources */
37#define SAMSUNG_PINCTRL_NUM_RESOURCES 2
38
36/* list of all possible config options supported */ 39/* list of all possible config options supported */
37static struct pin_config { 40static struct pin_config {
38 const char *property; 41 const char *property;
@@ -345,7 +348,7 @@ static void pin_to_reg_bank(struct samsung_pinctrl_drv_data *drvdata,
345 ((b->pin_base + b->nr_pins - 1) < pin)) 348 ((b->pin_base + b->nr_pins - 1) < pin))
346 b++; 349 b++;
347 350
348 *reg = drvdata->virt_base + b->pctl_offset; 351 *reg = b->pctl_base + b->pctl_offset;
349 *offset = pin - b->pin_base; 352 *offset = pin - b->pin_base;
350 if (bank) 353 if (bank)
351 *bank = b; 354 *bank = b;
@@ -526,7 +529,7 @@ static void samsung_gpio_set_value(struct gpio_chip *gc,
526 void __iomem *reg; 529 void __iomem *reg;
527 u32 data; 530 u32 data;
528 531
529 reg = bank->drvdata->virt_base + bank->pctl_offset; 532 reg = bank->pctl_base + bank->pctl_offset;
530 533
531 data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]); 534 data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
532 data &= ~(1 << offset); 535 data &= ~(1 << offset);
@@ -554,7 +557,7 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset)
554 struct samsung_pin_bank *bank = gpiochip_get_data(gc); 557 struct samsung_pin_bank *bank = gpiochip_get_data(gc);
555 const struct samsung_pin_bank_type *type = bank->type; 558 const struct samsung_pin_bank_type *type = bank->type;
556 559
557 reg = bank->drvdata->virt_base + bank->pctl_offset; 560 reg = bank->pctl_base + bank->pctl_offset;
558 561
559 data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]); 562 data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
560 data >>= offset; 563 data >>= offset;
@@ -581,8 +584,8 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc,
581 type = bank->type; 584 type = bank->type;
582 drvdata = bank->drvdata; 585 drvdata = bank->drvdata;
583 586
584 reg = drvdata->virt_base + bank->pctl_offset + 587 reg = bank->pctl_base + bank->pctl_offset
585 type->reg_offset[PINCFG_TYPE_FUNC]; 588 + type->reg_offset[PINCFG_TYPE_FUNC];
586 589
587 mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1; 590 mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1;
588 shift = offset * type->fld_width[PINCFG_TYPE_FUNC]; 591 shift = offset * type->fld_width[PINCFG_TYPE_FUNC];
@@ -979,6 +982,8 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
979 const struct samsung_pin_bank_data *bdata; 982 const struct samsung_pin_bank_data *bdata;
980 const struct samsung_pin_ctrl *ctrl; 983 const struct samsung_pin_ctrl *ctrl;
981 struct samsung_pin_bank *bank; 984 struct samsung_pin_bank *bank;
985 struct resource *res;
986 void __iomem *virt_base[SAMSUNG_PINCTRL_NUM_RESOURCES];
982 int i; 987 int i;
983 988
984 id = of_alias_get_id(node, "pinctrl"); 989 id = of_alias_get_id(node, "pinctrl");
@@ -997,6 +1002,17 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
997 if (!d->pin_banks) 1002 if (!d->pin_banks)
998 return ERR_PTR(-ENOMEM); 1003 return ERR_PTR(-ENOMEM);
999 1004
1005 if (ctrl->nr_ext_resources + 1 > SAMSUNG_PINCTRL_NUM_RESOURCES)
1006 return ERR_PTR(-EINVAL);
1007
1008 for (i = 0; i < ctrl->nr_ext_resources + 1; i++) {
1009 res = platform_get_resource(pdev, IORESOURCE_MEM, i);
1010 virt_base[i] = devm_ioremap(&pdev->dev, res->start,
1011 resource_size(res));
1012 if (IS_ERR(virt_base[i]))
1013 return ERR_PTR(-EIO);
1014 }
1015
1000 bank = d->pin_banks; 1016 bank = d->pin_banks;
1001 bdata = ctrl->pin_banks; 1017 bdata = ctrl->pin_banks;
1002 for (i = 0; i < ctrl->nr_banks; ++i, ++bdata, ++bank) { 1018 for (i = 0; i < ctrl->nr_banks; ++i, ++bdata, ++bank) {
@@ -1013,6 +1029,9 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
1013 bank->drvdata = d; 1029 bank->drvdata = d;
1014 bank->pin_base = d->nr_pins; 1030 bank->pin_base = d->nr_pins;
1015 d->nr_pins += bank->nr_pins; 1031 d->nr_pins += bank->nr_pins;
1032
1033 bank->eint_base = virt_base[0];
1034 bank->pctl_base = virt_base[bdata->pctl_res_idx];
1016 } 1035 }
1017 1036
1018 for_each_child_of_node(node, np) { 1037 for_each_child_of_node(node, np) {
@@ -1052,11 +1071,6 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
1052 } 1071 }
1053 drvdata->dev = dev; 1072 drvdata->dev = dev;
1054 1073
1055 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1056 drvdata->virt_base = devm_ioremap_resource(&pdev->dev, res);
1057 if (IS_ERR(drvdata->virt_base))
1058 return PTR_ERR(drvdata->virt_base);
1059
1060 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1074 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1061 if (res) 1075 if (res)
1062 drvdata->irq = res->start; 1076 drvdata->irq = res->start;
@@ -1094,12 +1108,11 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
1094static void samsung_pinctrl_suspend_dev( 1108static void samsung_pinctrl_suspend_dev(
1095 struct samsung_pinctrl_drv_data *drvdata) 1109 struct samsung_pinctrl_drv_data *drvdata)
1096{ 1110{
1097 void __iomem *virt_base = drvdata->virt_base;
1098 int i; 1111 int i;
1099 1112
1100 for (i = 0; i < drvdata->nr_banks; i++) { 1113 for (i = 0; i < drvdata->nr_banks; i++) {
1101 struct samsung_pin_bank *bank = &drvdata->pin_banks[i]; 1114 struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
1102 void __iomem *reg = virt_base + bank->pctl_offset; 1115 void __iomem *reg = bank->pctl_base + bank->pctl_offset;
1103 const u8 *offs = bank->type->reg_offset; 1116 const u8 *offs = bank->type->reg_offset;
1104 const u8 *widths = bank->type->fld_width; 1117 const u8 *widths = bank->type->fld_width;
1105 enum pincfg_type type; 1118 enum pincfg_type type;
@@ -1140,7 +1153,6 @@ static void samsung_pinctrl_suspend_dev(
1140 */ 1153 */
1141static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata) 1154static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata)
1142{ 1155{
1143 void __iomem *virt_base = drvdata->virt_base;
1144 int i; 1156 int i;
1145 1157
1146 if (drvdata->resume) 1158 if (drvdata->resume)
@@ -1148,7 +1160,7 @@ static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata)
1148 1160
1149 for (i = 0; i < drvdata->nr_banks; i++) { 1161 for (i = 0; i < drvdata->nr_banks; i++) {
1150 struct samsung_pin_bank *bank = &drvdata->pin_banks[i]; 1162 struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
1151 void __iomem *reg = virt_base + bank->pctl_offset; 1163 void __iomem *reg = bank->pctl_base + bank->pctl_offset;
1152 const u8 *offs = bank->type->reg_offset; 1164 const u8 *offs = bank->type->reg_offset;
1153 const u8 *widths = bank->type->fld_width; 1165 const u8 *widths = bank->type->fld_width;
1154 enum pincfg_type type; 1166 enum pincfg_type type;
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h
index cd31bfaf62cb..043cb6c11180 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.h
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
@@ -116,6 +116,7 @@ struct samsung_pin_bank_type {
116 * struct samsung_pin_bank_data: represent a controller pin-bank (init data). 116 * struct samsung_pin_bank_data: represent a controller pin-bank (init data).
117 * @type: type of the bank (register offsets and bitfield widths) 117 * @type: type of the bank (register offsets and bitfield widths)
118 * @pctl_offset: starting offset of the pin-bank registers. 118 * @pctl_offset: starting offset of the pin-bank registers.
119 * @pctl_res_idx: index of base address for pin-bank registers.
119 * @nr_pins: number of pins included in this bank. 120 * @nr_pins: number of pins included in this bank.
120 * @eint_func: function to set in CON register to configure pin as EINT. 121 * @eint_func: function to set in CON register to configure pin as EINT.
121 * @eint_type: type of the external interrupt supported by the bank. 122 * @eint_type: type of the external interrupt supported by the bank.
@@ -126,6 +127,7 @@ struct samsung_pin_bank_type {
126struct samsung_pin_bank_data { 127struct samsung_pin_bank_data {
127 const struct samsung_pin_bank_type *type; 128 const struct samsung_pin_bank_type *type;
128 u32 pctl_offset; 129 u32 pctl_offset;
130 u8 pctl_res_idx;
129 u8 nr_pins; 131 u8 nr_pins;
130 u8 eint_func; 132 u8 eint_func;
131 enum eint_type eint_type; 133 enum eint_type eint_type;
@@ -137,8 +139,10 @@ struct samsung_pin_bank_data {
137/** 139/**
138 * struct samsung_pin_bank: represent a controller pin-bank. 140 * struct samsung_pin_bank: represent a controller pin-bank.
139 * @type: type of the bank (register offsets and bitfield widths) 141 * @type: type of the bank (register offsets and bitfield widths)
142 * @pctl_base: base address of the pin-bank registers
140 * @pctl_offset: starting offset of the pin-bank registers. 143 * @pctl_offset: starting offset of the pin-bank registers.
141 * @nr_pins: number of pins included in this bank. 144 * @nr_pins: number of pins included in this bank.
145 * @eint_base: base address of the pin-bank EINT registers.
142 * @eint_func: function to set in CON register to configure pin as EINT. 146 * @eint_func: function to set in CON register to configure pin as EINT.
143 * @eint_type: type of the external interrupt supported by the bank. 147 * @eint_type: type of the external interrupt supported by the bank.
144 * @eint_mask: bit mask of pins which support EINT function. 148 * @eint_mask: bit mask of pins which support EINT function.
@@ -157,8 +161,10 @@ struct samsung_pin_bank_data {
157 */ 161 */
158struct samsung_pin_bank { 162struct samsung_pin_bank {
159 const struct samsung_pin_bank_type *type; 163 const struct samsung_pin_bank_type *type;
164 void __iomem *pctl_base;
160 u32 pctl_offset; 165 u32 pctl_offset;
161 u8 nr_pins; 166 u8 nr_pins;
167 void __iomem *eint_base;
162 u8 eint_func; 168 u8 eint_func;
163 enum eint_type eint_type; 169 enum eint_type eint_type;
164 u32 eint_mask; 170 u32 eint_mask;
@@ -182,6 +188,7 @@ struct samsung_pin_bank {
182 * struct samsung_pin_ctrl: represent a pin controller. 188 * struct samsung_pin_ctrl: represent a pin controller.
183 * @pin_banks: list of pin banks included in this controller. 189 * @pin_banks: list of pin banks included in this controller.
184 * @nr_banks: number of pin banks. 190 * @nr_banks: number of pin banks.
191 * @nr_ext_resources: number of the extra base address for pin banks.
185 * @eint_gpio_init: platform specific callback to setup the external gpio 192 * @eint_gpio_init: platform specific callback to setup the external gpio
186 * interrupts for the controller. 193 * interrupts for the controller.
187 * @eint_wkup_init: platform specific callback to setup the external wakeup 194 * @eint_wkup_init: platform specific callback to setup the external wakeup
@@ -190,6 +197,7 @@ struct samsung_pin_bank {
190struct samsung_pin_ctrl { 197struct samsung_pin_ctrl {
191 const struct samsung_pin_bank_data *pin_banks; 198 const struct samsung_pin_bank_data *pin_banks;
192 u32 nr_banks; 199 u32 nr_banks;
200 int nr_ext_resources;
193 201
194 int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *); 202 int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *);
195 int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *); 203 int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *);
@@ -200,7 +208,6 @@ struct samsung_pin_ctrl {
200/** 208/**
201 * struct samsung_pinctrl_drv_data: wrapper for holding driver data together. 209 * struct samsung_pinctrl_drv_data: wrapper for holding driver data together.
202 * @node: global list node 210 * @node: global list node
203 * @virt_base: register base address of the controller.
204 * @dev: device instance representing the controller. 211 * @dev: device instance representing the controller.
205 * @irq: interrpt number used by the controller to notify gpio interrupts. 212 * @irq: interrpt number used by the controller to notify gpio interrupts.
206 * @ctrl: pin controller instance managed by the driver. 213 * @ctrl: pin controller instance managed by the driver.
@@ -215,7 +222,6 @@ struct samsung_pin_ctrl {
215 */ 222 */
216struct samsung_pinctrl_drv_data { 223struct samsung_pinctrl_drv_data {
217 struct list_head node; 224 struct list_head node;
218 void __iomem *virt_base;
219 struct device *dev; 225 struct device *dev;
220 int irq; 226 int irq;
221 227
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index f3a8897d4e8f..cf80ce1dd7ce 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -389,6 +389,21 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
389 return 0; 389 return 0;
390} 390}
391 391
392const struct sh_pfc_bias_info *
393sh_pfc_pin_to_bias_info(const struct sh_pfc_bias_info *info,
394 unsigned int num, unsigned int pin)
395{
396 unsigned int i;
397
398 for (i = 0; i < num; i++)
399 if (info[i].pin == pin)
400 return &info[i];
401
402 WARN_ONCE(1, "Pin %u is not in bias info list\n", pin);
403
404 return NULL;
405}
406
392static int sh_pfc_init_ranges(struct sh_pfc *pfc) 407static int sh_pfc_init_ranges(struct sh_pfc *pfc)
393{ 408{
394 struct sh_pfc_pin_range *range; 409 struct sh_pfc_pin_range *range;
diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h
index 0bbdea5849f4..6d598dd63720 100644
--- a/drivers/pinctrl/sh-pfc/core.h
+++ b/drivers/pinctrl/sh-pfc/core.h
@@ -33,4 +33,8 @@ void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width,
33int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); 33int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin);
34int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type); 34int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type);
35 35
36const struct sh_pfc_bias_info *
37sh_pfc_pin_to_bias_info(const struct sh_pfc_bias_info *info,
38 unsigned int num, unsigned int pin);
39
36#endif /* __SH_PFC_CORE_H__ */ 40#endif /* __SH_PFC_CORE_H__ */
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7778.c b/drivers/pinctrl/sh-pfc/pfc-r8a7778.c
index 18ef7042b3d1..c3af9ebee4af 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7778.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7778.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/pinctrl/pinconf-generic.h> 25#include <linux/pinctrl/pinconf-generic.h>
26 26
27#include "core.h"
27#include "sh_pfc.h" 28#include "sh_pfc.h"
28 29
29#define PORT_GP_PUP_1(bank, pin, fn, sfx) \ 30#define PORT_GP_PUP_1(bank, pin, fn, sfx) \
@@ -2918,183 +2919,182 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
2918#define PUPR4 0x110 2919#define PUPR4 0x110
2919#define PUPR5 0x114 2920#define PUPR5 0x114
2920 2921
2921static const struct { 2922static const struct sh_pfc_bias_info bias_info[] = {
2922 u16 reg : 11; 2923 { RCAR_GP_PIN(0, 6), PUPR0, 0 }, /* A0 */
2923 u16 bit : 5; 2924 { RCAR_GP_PIN(0, 7), PUPR0, 1 }, /* A1 */
2924} pullups[] = { 2925 { RCAR_GP_PIN(0, 8), PUPR0, 2 }, /* A2 */
2925 [RCAR_GP_PIN(0, 6)] = { PUPR0, 0 }, /* A0 */ 2926 { RCAR_GP_PIN(0, 9), PUPR0, 3 }, /* A3 */
2926 [RCAR_GP_PIN(0, 7)] = { PUPR0, 1 }, /* A1 */ 2927 { RCAR_GP_PIN(0, 10), PUPR0, 4 }, /* A4 */
2927 [RCAR_GP_PIN(0, 8)] = { PUPR0, 2 }, /* A2 */ 2928 { RCAR_GP_PIN(0, 11), PUPR0, 5 }, /* A5 */
2928 [RCAR_GP_PIN(0, 9)] = { PUPR0, 3 }, /* A3 */ 2929 { RCAR_GP_PIN(0, 12), PUPR0, 6 }, /* A6 */
2929 [RCAR_GP_PIN(0, 10)] = { PUPR0, 4 }, /* A4 */ 2930 { RCAR_GP_PIN(0, 13), PUPR0, 7 }, /* A7 */
2930 [RCAR_GP_PIN(0, 11)] = { PUPR0, 5 }, /* A5 */ 2931 { RCAR_GP_PIN(0, 14), PUPR0, 8 }, /* A8 */
2931 [RCAR_GP_PIN(0, 12)] = { PUPR0, 6 }, /* A6 */ 2932 { RCAR_GP_PIN(0, 15), PUPR0, 9 }, /* A9 */
2932 [RCAR_GP_PIN(0, 13)] = { PUPR0, 7 }, /* A7 */ 2933 { RCAR_GP_PIN(0, 16), PUPR0, 10 }, /* A10 */
2933 [RCAR_GP_PIN(0, 14)] = { PUPR0, 8 }, /* A8 */ 2934 { RCAR_GP_PIN(0, 17), PUPR0, 11 }, /* A11 */
2934 [RCAR_GP_PIN(0, 15)] = { PUPR0, 9 }, /* A9 */ 2935 { RCAR_GP_PIN(0, 18), PUPR0, 12 }, /* A12 */
2935 [RCAR_GP_PIN(0, 16)] = { PUPR0, 10 }, /* A10 */ 2936 { RCAR_GP_PIN(0, 19), PUPR0, 13 }, /* A13 */
2936 [RCAR_GP_PIN(0, 17)] = { PUPR0, 11 }, /* A11 */ 2937 { RCAR_GP_PIN(0, 20), PUPR0, 14 }, /* A14 */
2937 [RCAR_GP_PIN(0, 18)] = { PUPR0, 12 }, /* A12 */ 2938 { RCAR_GP_PIN(0, 21), PUPR0, 15 }, /* A15 */
2938 [RCAR_GP_PIN(0, 19)] = { PUPR0, 13 }, /* A13 */ 2939 { RCAR_GP_PIN(0, 22), PUPR0, 16 }, /* A16 */
2939 [RCAR_GP_PIN(0, 20)] = { PUPR0, 14 }, /* A14 */ 2940 { RCAR_GP_PIN(0, 23), PUPR0, 17 }, /* A17 */
2940 [RCAR_GP_PIN(0, 21)] = { PUPR0, 15 }, /* A15 */ 2941 { RCAR_GP_PIN(0, 24), PUPR0, 18 }, /* A18 */
2941 [RCAR_GP_PIN(0, 22)] = { PUPR0, 16 }, /* A16 */ 2942 { RCAR_GP_PIN(0, 25), PUPR0, 19 }, /* A19 */
2942 [RCAR_GP_PIN(0, 23)] = { PUPR0, 17 }, /* A17 */ 2943 { RCAR_GP_PIN(0, 26), PUPR0, 20 }, /* A20 */
2943 [RCAR_GP_PIN(0, 24)] = { PUPR0, 18 }, /* A18 */ 2944 { RCAR_GP_PIN(0, 27), PUPR0, 21 }, /* A21 */
2944 [RCAR_GP_PIN(0, 25)] = { PUPR0, 19 }, /* A19 */ 2945 { RCAR_GP_PIN(0, 28), PUPR0, 22 }, /* A22 */
2945 [RCAR_GP_PIN(0, 26)] = { PUPR0, 20 }, /* A20 */ 2946 { RCAR_GP_PIN(0, 29), PUPR0, 23 }, /* A23 */
2946 [RCAR_GP_PIN(0, 27)] = { PUPR0, 21 }, /* A21 */ 2947 { RCAR_GP_PIN(0, 30), PUPR0, 24 }, /* A24 */
2947 [RCAR_GP_PIN(0, 28)] = { PUPR0, 22 }, /* A22 */ 2948 { RCAR_GP_PIN(0, 31), PUPR0, 25 }, /* A25 */
2948 [RCAR_GP_PIN(0, 29)] = { PUPR0, 23 }, /* A23 */ 2949 { RCAR_GP_PIN(1, 3), PUPR0, 26 }, /* /EX_CS0 */
2949 [RCAR_GP_PIN(0, 30)] = { PUPR0, 24 }, /* A24 */ 2950 { RCAR_GP_PIN(1, 4), PUPR0, 27 }, /* /EX_CS1 */
2950 [RCAR_GP_PIN(0, 31)] = { PUPR0, 25 }, /* A25 */ 2951 { RCAR_GP_PIN(1, 5), PUPR0, 28 }, /* /EX_CS2 */
2951 [RCAR_GP_PIN(1, 3)] = { PUPR0, 26 }, /* /EX_CS0 */ 2952 { RCAR_GP_PIN(1, 6), PUPR0, 29 }, /* /EX_CS3 */
2952 [RCAR_GP_PIN(1, 4)] = { PUPR0, 27 }, /* /EX_CS1 */ 2953 { RCAR_GP_PIN(1, 7), PUPR0, 30 }, /* /EX_CS4 */
2953 [RCAR_GP_PIN(1, 5)] = { PUPR0, 28 }, /* /EX_CS2 */ 2954 { RCAR_GP_PIN(1, 8), PUPR0, 31 }, /* /EX_CS5 */
2954 [RCAR_GP_PIN(1, 6)] = { PUPR0, 29 }, /* /EX_CS3 */ 2955
2955 [RCAR_GP_PIN(1, 7)] = { PUPR0, 30 }, /* /EX_CS4 */ 2956 { RCAR_GP_PIN(0, 0), PUPR1, 0 }, /* /PRESETOUT */
2956 [RCAR_GP_PIN(1, 8)] = { PUPR0, 31 }, /* /EX_CS5 */ 2957 { RCAR_GP_PIN(0, 5), PUPR1, 1 }, /* /BS */
2957 2958 { RCAR_GP_PIN(1, 0), PUPR1, 2 }, /* RD//WR */
2958 [RCAR_GP_PIN(0, 0)] = { PUPR1, 0 }, /* /PRESETOUT */ 2959 { RCAR_GP_PIN(1, 1), PUPR1, 3 }, /* /WE0 */
2959 [RCAR_GP_PIN(0, 5)] = { PUPR1, 1 }, /* /BS */ 2960 { RCAR_GP_PIN(1, 2), PUPR1, 4 }, /* /WE1 */
2960 [RCAR_GP_PIN(1, 0)] = { PUPR1, 2 }, /* RD//WR */ 2961 { RCAR_GP_PIN(1, 11), PUPR1, 5 }, /* EX_WAIT0 */
2961 [RCAR_GP_PIN(1, 1)] = { PUPR1, 3 }, /* /WE0 */ 2962 { RCAR_GP_PIN(1, 9), PUPR1, 6 }, /* DREQ0 */
2962 [RCAR_GP_PIN(1, 2)] = { PUPR1, 4 }, /* /WE1 */ 2963 { RCAR_GP_PIN(1, 10), PUPR1, 7 }, /* DACK0 */
2963 [RCAR_GP_PIN(1, 11)] = { PUPR1, 5 }, /* EX_WAIT0 */ 2964 { RCAR_GP_PIN(1, 12), PUPR1, 8 }, /* IRQ0 */
2964 [RCAR_GP_PIN(1, 9)] = { PUPR1, 6 }, /* DREQ0 */ 2965 { RCAR_GP_PIN(1, 13), PUPR1, 9 }, /* IRQ1 */
2965 [RCAR_GP_PIN(1, 10)] = { PUPR1, 7 }, /* DACK0 */ 2966
2966 [RCAR_GP_PIN(1, 12)] = { PUPR1, 8 }, /* IRQ0 */ 2967 { RCAR_GP_PIN(1, 22), PUPR2, 0 }, /* DU0_DR0 */
2967 [RCAR_GP_PIN(1, 13)] = { PUPR1, 9 }, /* IRQ1 */ 2968 { RCAR_GP_PIN(1, 23), PUPR2, 1 }, /* DU0_DR1 */
2968 2969 { RCAR_GP_PIN(1, 24), PUPR2, 2 }, /* DU0_DR2 */
2969 [RCAR_GP_PIN(1, 22)] = { PUPR2, 0 }, /* DU0_DR0 */ 2970 { RCAR_GP_PIN(1, 25), PUPR2, 3 }, /* DU0_DR3 */
2970 [RCAR_GP_PIN(1, 23)] = { PUPR2, 1 }, /* DU0_DR1 */ 2971 { RCAR_GP_PIN(1, 26), PUPR2, 4 }, /* DU0_DR4 */
2971 [RCAR_GP_PIN(1, 24)] = { PUPR2, 2 }, /* DU0_DR2 */ 2972 { RCAR_GP_PIN(1, 27), PUPR2, 5 }, /* DU0_DR5 */
2972 [RCAR_GP_PIN(1, 25)] = { PUPR2, 3 }, /* DU0_DR3 */ 2973 { RCAR_GP_PIN(1, 28), PUPR2, 6 }, /* DU0_DR6 */
2973 [RCAR_GP_PIN(1, 26)] = { PUPR2, 4 }, /* DU0_DR4 */ 2974 { RCAR_GP_PIN(1, 29), PUPR2, 7 }, /* DU0_DR7 */
2974 [RCAR_GP_PIN(1, 27)] = { PUPR2, 5 }, /* DU0_DR5 */ 2975 { RCAR_GP_PIN(1, 30), PUPR2, 8 }, /* DU0_DG0 */
2975 [RCAR_GP_PIN(1, 28)] = { PUPR2, 6 }, /* DU0_DR6 */ 2976 { RCAR_GP_PIN(1, 31), PUPR2, 9 }, /* DU0_DG1 */
2976 [RCAR_GP_PIN(1, 29)] = { PUPR2, 7 }, /* DU0_DR7 */ 2977 { RCAR_GP_PIN(2, 0), PUPR2, 10 }, /* DU0_DG2 */
2977 [RCAR_GP_PIN(1, 30)] = { PUPR2, 8 }, /* DU0_DG0 */ 2978 { RCAR_GP_PIN(2, 1), PUPR2, 11 }, /* DU0_DG3 */
2978 [RCAR_GP_PIN(1, 31)] = { PUPR2, 9 }, /* DU0_DG1 */ 2979 { RCAR_GP_PIN(2, 2), PUPR2, 12 }, /* DU0_DG4 */
2979 [RCAR_GP_PIN(2, 0)] = { PUPR2, 10 }, /* DU0_DG2 */ 2980 { RCAR_GP_PIN(2, 3), PUPR2, 13 }, /* DU0_DG5 */
2980 [RCAR_GP_PIN(2, 1)] = { PUPR2, 11 }, /* DU0_DG3 */ 2981 { RCAR_GP_PIN(2, 4), PUPR2, 14 }, /* DU0_DG6 */
2981 [RCAR_GP_PIN(2, 2)] = { PUPR2, 12 }, /* DU0_DG4 */ 2982 { RCAR_GP_PIN(2, 5), PUPR2, 15 }, /* DU0_DG7 */
2982 [RCAR_GP_PIN(2, 3)] = { PUPR2, 13 }, /* DU0_DG5 */ 2983 { RCAR_GP_PIN(2, 6), PUPR2, 16 }, /* DU0_DB0 */
2983 [RCAR_GP_PIN(2, 4)] = { PUPR2, 14 }, /* DU0_DG6 */ 2984 { RCAR_GP_PIN(2, 7), PUPR2, 17 }, /* DU0_DB1 */
2984 [RCAR_GP_PIN(2, 5)] = { PUPR2, 15 }, /* DU0_DG7 */ 2985 { RCAR_GP_PIN(2, 8), PUPR2, 18 }, /* DU0_DB2 */
2985 [RCAR_GP_PIN(2, 6)] = { PUPR2, 16 }, /* DU0_DB0 */ 2986 { RCAR_GP_PIN(2, 9), PUPR2, 19 }, /* DU0_DB3 */
2986 [RCAR_GP_PIN(2, 7)] = { PUPR2, 17 }, /* DU0_DB1 */ 2987 { RCAR_GP_PIN(2, 10), PUPR2, 20 }, /* DU0_DB4 */
2987 [RCAR_GP_PIN(2, 8)] = { PUPR2, 18 }, /* DU0_DB2 */ 2988 { RCAR_GP_PIN(2, 11), PUPR2, 21 }, /* DU0_DB5 */
2988 [RCAR_GP_PIN(2, 9)] = { PUPR2, 19 }, /* DU0_DB3 */ 2989 { RCAR_GP_PIN(2, 12), PUPR2, 22 }, /* DU0_DB6 */
2989 [RCAR_GP_PIN(2, 10)] = { PUPR2, 20 }, /* DU0_DB4 */ 2990 { RCAR_GP_PIN(2, 13), PUPR2, 23 }, /* DU0_DB7 */
2990 [RCAR_GP_PIN(2, 11)] = { PUPR2, 21 }, /* DU0_DB5 */ 2991 { RCAR_GP_PIN(2, 14), PUPR2, 24 }, /* DU0_DOTCLKIN */
2991 [RCAR_GP_PIN(2, 12)] = { PUPR2, 22 }, /* DU0_DB6 */ 2992 { RCAR_GP_PIN(2, 15), PUPR2, 25 }, /* DU0_DOTCLKOUT0 */
2992 [RCAR_GP_PIN(2, 13)] = { PUPR2, 23 }, /* DU0_DB7 */ 2993 { RCAR_GP_PIN(2, 17), PUPR2, 26 }, /* DU0_HSYNC */
2993 [RCAR_GP_PIN(2, 14)] = { PUPR2, 24 }, /* DU0_DOTCLKIN */ 2994 { RCAR_GP_PIN(2, 18), PUPR2, 27 }, /* DU0_VSYNC */
2994 [RCAR_GP_PIN(2, 15)] = { PUPR2, 25 }, /* DU0_DOTCLKOUT0 */ 2995 { RCAR_GP_PIN(2, 19), PUPR2, 28 }, /* DU0_EXODDF */
2995 [RCAR_GP_PIN(2, 17)] = { PUPR2, 26 }, /* DU0_HSYNC */ 2996 { RCAR_GP_PIN(2, 20), PUPR2, 29 }, /* DU0_DISP */
2996 [RCAR_GP_PIN(2, 18)] = { PUPR2, 27 }, /* DU0_VSYNC */ 2997 { RCAR_GP_PIN(2, 21), PUPR2, 30 }, /* DU0_CDE */
2997 [RCAR_GP_PIN(2, 19)] = { PUPR2, 28 }, /* DU0_EXODDF */ 2998 { RCAR_GP_PIN(2, 16), PUPR2, 31 }, /* DU0_DOTCLKOUT1 */
2998 [RCAR_GP_PIN(2, 20)] = { PUPR2, 29 }, /* DU0_DISP */ 2999
2999 [RCAR_GP_PIN(2, 21)] = { PUPR2, 30 }, /* DU0_CDE */ 3000 { RCAR_GP_PIN(3, 24), PUPR3, 0 }, /* VI0_CLK */
3000 [RCAR_GP_PIN(2, 16)] = { PUPR2, 31 }, /* DU0_DOTCLKOUT1 */ 3001 { RCAR_GP_PIN(3, 25), PUPR3, 1 }, /* VI0_CLKENB */
3001 3002 { RCAR_GP_PIN(3, 26), PUPR3, 2 }, /* VI0_FIELD */
3002 [RCAR_GP_PIN(3, 24)] = { PUPR3, 0 }, /* VI0_CLK */ 3003 { RCAR_GP_PIN(3, 27), PUPR3, 3 }, /* /VI0_HSYNC */
3003 [RCAR_GP_PIN(3, 25)] = { PUPR3, 1 }, /* VI0_CLKENB */ 3004 { RCAR_GP_PIN(3, 28), PUPR3, 4 }, /* /VI0_VSYNC */
3004 [RCAR_GP_PIN(3, 26)] = { PUPR3, 2 }, /* VI0_FIELD */ 3005 { RCAR_GP_PIN(3, 29), PUPR3, 5 }, /* VI0_DATA0 */
3005 [RCAR_GP_PIN(3, 27)] = { PUPR3, 3 }, /* /VI0_HSYNC */ 3006 { RCAR_GP_PIN(3, 30), PUPR3, 6 }, /* VI0_DATA1 */
3006 [RCAR_GP_PIN(3, 28)] = { PUPR3, 4 }, /* /VI0_VSYNC */ 3007 { RCAR_GP_PIN(3, 31), PUPR3, 7 }, /* VI0_DATA2 */
3007 [RCAR_GP_PIN(3, 29)] = { PUPR3, 5 }, /* VI0_DATA0 */ 3008 { RCAR_GP_PIN(4, 0), PUPR3, 8 }, /* VI0_DATA3 */
3008 [RCAR_GP_PIN(3, 30)] = { PUPR3, 6 }, /* VI0_DATA1 */ 3009 { RCAR_GP_PIN(4, 1), PUPR3, 9 }, /* VI0_DATA4 */
3009 [RCAR_GP_PIN(3, 31)] = { PUPR3, 7 }, /* VI0_DATA2 */ 3010 { RCAR_GP_PIN(4, 2), PUPR3, 10 }, /* VI0_DATA5 */
3010 [RCAR_GP_PIN(4, 0)] = { PUPR3, 8 }, /* VI0_DATA3 */ 3011 { RCAR_GP_PIN(4, 3), PUPR3, 11 }, /* VI0_DATA6 */
3011 [RCAR_GP_PIN(4, 1)] = { PUPR3, 9 }, /* VI0_DATA4 */ 3012 { RCAR_GP_PIN(4, 4), PUPR3, 12 }, /* VI0_DATA7 */
3012 [RCAR_GP_PIN(4, 2)] = { PUPR3, 10 }, /* VI0_DATA5 */ 3013 { RCAR_GP_PIN(4, 5), PUPR3, 13 }, /* VI0_G2 */
3013 [RCAR_GP_PIN(4, 3)] = { PUPR3, 11 }, /* VI0_DATA6 */ 3014 { RCAR_GP_PIN(4, 6), PUPR3, 14 }, /* VI0_G3 */
3014 [RCAR_GP_PIN(4, 4)] = { PUPR3, 12 }, /* VI0_DATA7 */ 3015 { RCAR_GP_PIN(4, 7), PUPR3, 15 }, /* VI0_G4 */
3015 [RCAR_GP_PIN(4, 5)] = { PUPR3, 13 }, /* VI0_G2 */ 3016 { RCAR_GP_PIN(4, 8), PUPR3, 16 }, /* VI0_G5 */
3016 [RCAR_GP_PIN(4, 6)] = { PUPR3, 14 }, /* VI0_G3 */ 3017 { RCAR_GP_PIN(4, 21), PUPR3, 17 }, /* VI1_DATA12 */
3017 [RCAR_GP_PIN(4, 7)] = { PUPR3, 15 }, /* VI0_G4 */ 3018 { RCAR_GP_PIN(4, 22), PUPR3, 18 }, /* VI1_DATA13 */
3018 [RCAR_GP_PIN(4, 8)] = { PUPR3, 16 }, /* VI0_G5 */ 3019 { RCAR_GP_PIN(4, 23), PUPR3, 19 }, /* VI1_DATA14 */
3019 [RCAR_GP_PIN(4, 21)] = { PUPR3, 17 }, /* VI1_DATA12 */ 3020 { RCAR_GP_PIN(4, 24), PUPR3, 20 }, /* VI1_DATA15 */
3020 [RCAR_GP_PIN(4, 22)] = { PUPR3, 18 }, /* VI1_DATA13 */ 3021 { RCAR_GP_PIN(4, 9), PUPR3, 21 }, /* ETH_REF_CLK */
3021 [RCAR_GP_PIN(4, 23)] = { PUPR3, 19 }, /* VI1_DATA14 */ 3022 { RCAR_GP_PIN(4, 10), PUPR3, 22 }, /* ETH_TXD0 */
3022 [RCAR_GP_PIN(4, 24)] = { PUPR3, 20 }, /* VI1_DATA15 */ 3023 { RCAR_GP_PIN(4, 11), PUPR3, 23 }, /* ETH_TXD1 */
3023 [RCAR_GP_PIN(4, 9)] = { PUPR3, 21 }, /* ETH_REF_CLK */ 3024 { RCAR_GP_PIN(4, 12), PUPR3, 24 }, /* ETH_CRS_DV */
3024 [RCAR_GP_PIN(4, 10)] = { PUPR3, 22 }, /* ETH_TXD0 */ 3025 { RCAR_GP_PIN(4, 13), PUPR3, 25 }, /* ETH_TX_EN */
3025 [RCAR_GP_PIN(4, 11)] = { PUPR3, 23 }, /* ETH_TXD1 */ 3026 { RCAR_GP_PIN(4, 14), PUPR3, 26 }, /* ETH_RX_ER */
3026 [RCAR_GP_PIN(4, 12)] = { PUPR3, 24 }, /* ETH_CRS_DV */ 3027 { RCAR_GP_PIN(4, 15), PUPR3, 27 }, /* ETH_RXD0 */
3027 [RCAR_GP_PIN(4, 13)] = { PUPR3, 25 }, /* ETH_TX_EN */ 3028 { RCAR_GP_PIN(4, 16), PUPR3, 28 }, /* ETH_RXD1 */
3028 [RCAR_GP_PIN(4, 14)] = { PUPR3, 26 }, /* ETH_RX_ER */ 3029 { RCAR_GP_PIN(4, 17), PUPR3, 29 }, /* ETH_MDC */
3029 [RCAR_GP_PIN(4, 15)] = { PUPR3, 27 }, /* ETH_RXD0 */ 3030 { RCAR_GP_PIN(4, 18), PUPR3, 30 }, /* ETH_MDIO */
3030 [RCAR_GP_PIN(4, 16)] = { PUPR3, 28 }, /* ETH_RXD1 */ 3031 { RCAR_GP_PIN(4, 19), PUPR3, 31 }, /* ETH_LINK */
3031 [RCAR_GP_PIN(4, 17)] = { PUPR3, 29 }, /* ETH_MDC */ 3032
3032 [RCAR_GP_PIN(4, 18)] = { PUPR3, 30 }, /* ETH_MDIO */ 3033 { RCAR_GP_PIN(3, 6), PUPR4, 0 }, /* SSI_SCK012 */
3033 [RCAR_GP_PIN(4, 19)] = { PUPR3, 31 }, /* ETH_LINK */ 3034 { RCAR_GP_PIN(3, 7), PUPR4, 1 }, /* SSI_WS012 */
3034 3035 { RCAR_GP_PIN(3, 10), PUPR4, 2 }, /* SSI_SDATA0 */
3035 [RCAR_GP_PIN(3, 6)] = { PUPR4, 0 }, /* SSI_SCK012 */ 3036 { RCAR_GP_PIN(3, 9), PUPR4, 3 }, /* SSI_SDATA1 */
3036 [RCAR_GP_PIN(3, 7)] = { PUPR4, 1 }, /* SSI_WS012 */ 3037 { RCAR_GP_PIN(3, 8), PUPR4, 4 }, /* SSI_SDATA2 */
3037 [RCAR_GP_PIN(3, 10)] = { PUPR4, 2 }, /* SSI_SDATA0 */ 3038 { RCAR_GP_PIN(3, 2), PUPR4, 5 }, /* SSI_SCK34 */
3038 [RCAR_GP_PIN(3, 9)] = { PUPR4, 3 }, /* SSI_SDATA1 */ 3039 { RCAR_GP_PIN(3, 3), PUPR4, 6 }, /* SSI_WS34 */
3039 [RCAR_GP_PIN(3, 8)] = { PUPR4, 4 }, /* SSI_SDATA2 */ 3040 { RCAR_GP_PIN(3, 5), PUPR4, 7 }, /* SSI_SDATA3 */
3040 [RCAR_GP_PIN(3, 2)] = { PUPR4, 5 }, /* SSI_SCK34 */ 3041 { RCAR_GP_PIN(3, 4), PUPR4, 8 }, /* SSI_SDATA4 */
3041 [RCAR_GP_PIN(3, 3)] = { PUPR4, 6 }, /* SSI_WS34 */ 3042 { RCAR_GP_PIN(2, 31), PUPR4, 9 }, /* SSI_SCK5 */
3042 [RCAR_GP_PIN(3, 5)] = { PUPR4, 7 }, /* SSI_SDATA3 */ 3043 { RCAR_GP_PIN(3, 0), PUPR4, 10 }, /* SSI_WS5 */
3043 [RCAR_GP_PIN(3, 4)] = { PUPR4, 8 }, /* SSI_SDATA4 */ 3044 { RCAR_GP_PIN(3, 1), PUPR4, 11 }, /* SSI_SDATA5 */
3044 [RCAR_GP_PIN(2, 31)] = { PUPR4, 9 }, /* SSI_SCK5 */ 3045 { RCAR_GP_PIN(2, 28), PUPR4, 12 }, /* SSI_SCK6 */
3045 [RCAR_GP_PIN(3, 0)] = { PUPR4, 10 }, /* SSI_WS5 */ 3046 { RCAR_GP_PIN(2, 29), PUPR4, 13 }, /* SSI_WS6 */
3046 [RCAR_GP_PIN(3, 1)] = { PUPR4, 11 }, /* SSI_SDATA5 */ 3047 { RCAR_GP_PIN(2, 30), PUPR4, 14 }, /* SSI_SDATA6 */
3047 [RCAR_GP_PIN(2, 28)] = { PUPR4, 12 }, /* SSI_SCK6 */ 3048 { RCAR_GP_PIN(2, 24), PUPR4, 15 }, /* SSI_SCK78 */
3048 [RCAR_GP_PIN(2, 29)] = { PUPR4, 13 }, /* SSI_WS6 */ 3049 { RCAR_GP_PIN(2, 25), PUPR4, 16 }, /* SSI_WS78 */
3049 [RCAR_GP_PIN(2, 30)] = { PUPR4, 14 }, /* SSI_SDATA6 */ 3050 { RCAR_GP_PIN(2, 27), PUPR4, 17 }, /* SSI_SDATA7 */
3050 [RCAR_GP_PIN(2, 24)] = { PUPR4, 15 }, /* SSI_SCK78 */ 3051 { RCAR_GP_PIN(2, 26), PUPR4, 18 }, /* SSI_SDATA8 */
3051 [RCAR_GP_PIN(2, 25)] = { PUPR4, 16 }, /* SSI_WS78 */ 3052 { RCAR_GP_PIN(3, 23), PUPR4, 19 }, /* TCLK0 */
3052 [RCAR_GP_PIN(2, 27)] = { PUPR4, 17 }, /* SSI_SDATA7 */ 3053 { RCAR_GP_PIN(3, 11), PUPR4, 20 }, /* SD0_CLK */
3053 [RCAR_GP_PIN(2, 26)] = { PUPR4, 18 }, /* SSI_SDATA8 */ 3054 { RCAR_GP_PIN(3, 12), PUPR4, 21 }, /* SD0_CMD */
3054 [RCAR_GP_PIN(3, 23)] = { PUPR4, 19 }, /* TCLK0 */ 3055 { RCAR_GP_PIN(3, 13), PUPR4, 22 }, /* SD0_DAT0 */
3055 [RCAR_GP_PIN(3, 11)] = { PUPR4, 20 }, /* SD0_CLK */ 3056 { RCAR_GP_PIN(3, 14), PUPR4, 23 }, /* SD0_DAT1 */
3056 [RCAR_GP_PIN(3, 12)] = { PUPR4, 21 }, /* SD0_CMD */ 3057 { RCAR_GP_PIN(3, 15), PUPR4, 24 }, /* SD0_DAT2 */
3057 [RCAR_GP_PIN(3, 13)] = { PUPR4, 22 }, /* SD0_DAT0 */ 3058 { RCAR_GP_PIN(3, 16), PUPR4, 25 }, /* SD0_DAT3 */
3058 [RCAR_GP_PIN(3, 14)] = { PUPR4, 23 }, /* SD0_DAT1 */ 3059 { RCAR_GP_PIN(3, 17), PUPR4, 26 }, /* SD0_CD */
3059 [RCAR_GP_PIN(3, 15)] = { PUPR4, 24 }, /* SD0_DAT2 */ 3060 { RCAR_GP_PIN(3, 18), PUPR4, 27 }, /* SD0_WP */
3060 [RCAR_GP_PIN(3, 16)] = { PUPR4, 25 }, /* SD0_DAT3 */ 3061 { RCAR_GP_PIN(2, 22), PUPR4, 28 }, /* AUDIO_CLKA */
3061 [RCAR_GP_PIN(3, 17)] = { PUPR4, 26 }, /* SD0_CD */ 3062 { RCAR_GP_PIN(2, 23), PUPR4, 29 }, /* AUDIO_CLKB */
3062 [RCAR_GP_PIN(3, 18)] = { PUPR4, 27 }, /* SD0_WP */ 3063 { RCAR_GP_PIN(1, 14), PUPR4, 30 }, /* IRQ2 */
3063 [RCAR_GP_PIN(2, 22)] = { PUPR4, 28 }, /* AUDIO_CLKA */ 3064 { RCAR_GP_PIN(1, 15), PUPR4, 31 }, /* IRQ3 */
3064 [RCAR_GP_PIN(2, 23)] = { PUPR4, 29 }, /* AUDIO_CLKB */ 3065
3065 [RCAR_GP_PIN(1, 14)] = { PUPR4, 30 }, /* IRQ2 */ 3066 { RCAR_GP_PIN(0, 1), PUPR5, 0 }, /* PENC0 */
3066 [RCAR_GP_PIN(1, 15)] = { PUPR4, 31 }, /* IRQ3 */ 3067 { RCAR_GP_PIN(0, 2), PUPR5, 1 }, /* PENC1 */
3067 3068 { RCAR_GP_PIN(0, 3), PUPR5, 2 }, /* USB_OVC0 */
3068 [RCAR_GP_PIN(0, 1)] = { PUPR5, 0 }, /* PENC0 */ 3069 { RCAR_GP_PIN(0, 4), PUPR5, 3 }, /* USB_OVC1 */
3069 [RCAR_GP_PIN(0, 2)] = { PUPR5, 1 }, /* PENC1 */ 3070 { RCAR_GP_PIN(1, 16), PUPR5, 4 }, /* SCIF_CLK */
3070 [RCAR_GP_PIN(0, 3)] = { PUPR5, 2 }, /* USB_OVC0 */ 3071 { RCAR_GP_PIN(1, 17), PUPR5, 5 }, /* TX0 */
3071 [RCAR_GP_PIN(0, 4)] = { PUPR5, 3 }, /* USB_OVC1 */ 3072 { RCAR_GP_PIN(1, 18), PUPR5, 6 }, /* RX0 */
3072 [RCAR_GP_PIN(1, 16)] = { PUPR5, 4 }, /* SCIF_CLK */ 3073 { RCAR_GP_PIN(1, 19), PUPR5, 7 }, /* SCK0 */
3073 [RCAR_GP_PIN(1, 17)] = { PUPR5, 5 }, /* TX0 */ 3074 { RCAR_GP_PIN(1, 20), PUPR5, 8 }, /* /CTS0 */
3074 [RCAR_GP_PIN(1, 18)] = { PUPR5, 6 }, /* RX0 */ 3075 { RCAR_GP_PIN(1, 21), PUPR5, 9 }, /* /RTS0 */
3075 [RCAR_GP_PIN(1, 19)] = { PUPR5, 7 }, /* SCK0 */ 3076 { RCAR_GP_PIN(3, 19), PUPR5, 10 }, /* HSPI_CLK0 */
3076 [RCAR_GP_PIN(1, 20)] = { PUPR5, 8 }, /* /CTS0 */ 3077 { RCAR_GP_PIN(3, 20), PUPR5, 11 }, /* /HSPI_CS0 */
3077 [RCAR_GP_PIN(1, 21)] = { PUPR5, 9 }, /* /RTS0 */ 3078 { RCAR_GP_PIN(3, 21), PUPR5, 12 }, /* HSPI_RX0 */
3078 [RCAR_GP_PIN(3, 19)] = { PUPR5, 10 }, /* HSPI_CLK0 */ 3079 { RCAR_GP_PIN(3, 22), PUPR5, 13 }, /* HSPI_TX0 */
3079 [RCAR_GP_PIN(3, 20)] = { PUPR5, 11 }, /* /HSPI_CS0 */ 3080 { RCAR_GP_PIN(4, 20), PUPR5, 14 }, /* ETH_MAGIC */
3080 [RCAR_GP_PIN(3, 21)] = { PUPR5, 12 }, /* HSPI_RX0 */ 3081 { RCAR_GP_PIN(4, 25), PUPR5, 15 }, /* AVS1 */
3081 [RCAR_GP_PIN(3, 22)] = { PUPR5, 13 }, /* HSPI_TX0 */ 3082 { RCAR_GP_PIN(4, 26), PUPR5, 16 }, /* AVS2 */
3082 [RCAR_GP_PIN(4, 20)] = { PUPR5, 14 }, /* ETH_MAGIC */
3083 [RCAR_GP_PIN(4, 25)] = { PUPR5, 15 }, /* AVS1 */
3084 [RCAR_GP_PIN(4, 26)] = { PUPR5, 16 }, /* AVS2 */
3085}; 3083};
3086 3084
3087static unsigned int r8a7778_pinmux_get_bias(struct sh_pfc *pfc, 3085static unsigned int r8a7778_pinmux_get_bias(struct sh_pfc *pfc,
3088 unsigned int pin) 3086 unsigned int pin)
3089{ 3087{
3088 const struct sh_pfc_bias_info *info;
3090 void __iomem *addr; 3089 void __iomem *addr;
3091 3090
3092 if (WARN_ON_ONCE(!pullups[pin].reg)) 3091 info = sh_pfc_pin_to_bias_info(bias_info, ARRAY_SIZE(bias_info), pin);
3092 if (!info)
3093 return PIN_CONFIG_BIAS_DISABLE; 3093 return PIN_CONFIG_BIAS_DISABLE;
3094 3094
3095 addr = pfc->windows->virt + pullups[pin].reg; 3095 addr = pfc->windows->virt + info->reg;
3096 3096
3097 if (ioread32(addr) & BIT(pullups[pin].bit)) 3097 if (ioread32(addr) & BIT(info->bit))
3098 return PIN_CONFIG_BIAS_PULL_UP; 3098 return PIN_CONFIG_BIAS_PULL_UP;
3099 else 3099 else
3100 return PIN_CONFIG_BIAS_DISABLE; 3100 return PIN_CONFIG_BIAS_DISABLE;
@@ -3103,15 +3103,17 @@ static unsigned int r8a7778_pinmux_get_bias(struct sh_pfc *pfc,
3103static void r8a7778_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin, 3103static void r8a7778_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
3104 unsigned int bias) 3104 unsigned int bias)
3105{ 3105{
3106 const struct sh_pfc_bias_info *info;
3106 void __iomem *addr; 3107 void __iomem *addr;
3107 u32 value; 3108 u32 value;
3108 u32 bit; 3109 u32 bit;
3109 3110
3110 if (WARN_ON_ONCE(!pullups[pin].reg)) 3111 info = sh_pfc_pin_to_bias_info(bias_info, ARRAY_SIZE(bias_info), pin);
3112 if (!info)
3111 return; 3113 return;
3112 3114
3113 addr = pfc->windows->virt + pullups[pin].reg; 3115 addr = pfc->windows->virt + info->reg;
3114 bit = BIT(pullups[pin].bit); 3116 bit = BIT(info->bit);
3115 3117
3116 value = ioread32(addr) & ~bit; 3118 value = ioread32(addr) & ~bit;
3117 if (bias == PIN_CONFIG_BIAS_PULL_UP) 3119 if (bias == PIN_CONFIG_BIAS_PULL_UP)
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c
index 2e8cc2adbed7..135ed5cbeb44 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c
@@ -523,6 +523,22 @@ MOD_SEL0_2_1 MOD_SEL1_2 \
523 MOD_SEL1_1 \ 523 MOD_SEL1_1 \
524 MOD_SEL1_0 MOD_SEL2_0 524 MOD_SEL1_0 MOD_SEL2_0
525 525
526/*
527 * These pins are not able to be muxed but have other properties
528 * that can be set, such as drive-strength or pull-up/pull-down enable.
529 */
530#define PINMUX_STATIC \
531 FM(QSPI0_SPCLK) FM(QSPI0_SSL) FM(QSPI0_MOSI_IO0) FM(QSPI0_MISO_IO1) \
532 FM(QSPI0_IO2) FM(QSPI0_IO3) \
533 FM(QSPI1_SPCLK) FM(QSPI1_SSL) FM(QSPI1_MOSI_IO0) FM(QSPI1_MISO_IO1) \
534 FM(QSPI1_IO2) FM(QSPI1_IO3) \
535 FM(RPC_INT) FM(RPC_WP) FM(RPC_RESET) \
536 FM(AVB_TX_CTL) FM(AVB_TXC) FM(AVB_TD0) FM(AVB_TD1) FM(AVB_TD2) FM(AVB_TD3) \
537 FM(AVB_RX_CTL) FM(AVB_RXC) FM(AVB_RD0) FM(AVB_RD1) FM(AVB_RD2) FM(AVB_RD3) \
538 FM(AVB_TXCREFCLK) FM(AVB_MDIO) \
539 FM(CLKOUT) FM(PRESETOUT) \
540 FM(DU_DOTCLKIN0) FM(DU_DOTCLKIN1) FM(DU_DOTCLKIN2) FM(DU_DOTCLKIN3) \
541 FM(TMS) FM(TDO) FM(ASEBRK) FM(MLB_REF)
526 542
527enum { 543enum {
528 PINMUX_RESERVED = 0, 544 PINMUX_RESERVED = 0,
@@ -548,6 +564,7 @@ enum {
548 PINMUX_GPSR 564 PINMUX_GPSR
549 PINMUX_IPSR 565 PINMUX_IPSR
550 PINMUX_MOD_SELS 566 PINMUX_MOD_SELS
567 PINMUX_STATIC
551 PINMUX_MARK_END, 568 PINMUX_MARK_END,
552#undef F_ 569#undef F_
553#undef FM 570#undef FM
@@ -1412,10 +1429,78 @@ static const u16 pinmux_data[] = {
1412 PINMUX_IPSR_MSEL(IP17_7_4, STP_ISSYNC_0_E, SEL_SSP1_0_4), 1429 PINMUX_IPSR_MSEL(IP17_7_4, STP_ISSYNC_0_E, SEL_SSP1_0_4),
1413 PINMUX_IPSR_MSEL(IP17_7_4, RIF2_D1_B, SEL_DRIF2_1), 1430 PINMUX_IPSR_MSEL(IP17_7_4, RIF2_D1_B, SEL_DRIF2_1),
1414 PINMUX_IPSR_GPSR(IP17_7_4, TPU0TO3), 1431 PINMUX_IPSR_GPSR(IP17_7_4, TPU0TO3),
1432
1433/*
1434 * Static pins can not be muxed between different functions but
1435 * still needs a mark entry in the pinmux list. Add each static
1436 * pin to the list without an associated function. The sh-pfc
1437 * core will do the right thing and skip trying to mux then pin
1438 * while still applying configuration to it
1439 */
1440#define FM(x) PINMUX_DATA(x##_MARK, 0),
1441 PINMUX_STATIC
1442#undef FM
1415}; 1443};
1416 1444
1445/*
1446 * R8A7795 has 8 banks with 32 PGIOS in each => 256 GPIOs.
1447 * Physical layout rows: A - AW, cols: 1 - 39.
1448 */
1449#define ROW_GROUP_A(r) ('Z' - 'A' + 1 + (r))
1450#define PIN_NUMBER(r, c) (((r) - 'A') * 39 + (c) + 300)
1451#define PIN_A_NUMBER(r, c) PIN_NUMBER(ROW_GROUP_A(r), c)
1452
1417static const struct sh_pfc_pin pinmux_pins[] = { 1453static const struct sh_pfc_pin pinmux_pins[] = {
1418 PINMUX_GPIO_GP_ALL(), 1454 PINMUX_GPIO_GP_ALL(),
1455
1456 /*
1457 * Pins not associated with a GPIO port.
1458 *
1459 * The pin positions are different between different r8a7795
1460 * packages, all that is needed for the pfc driver is a unique
1461 * number for each pin. To this end use the pin layout from
1462 * R-Car H3SiP to calculate a unique number for each pin.
1463 */
1464 SH_PFC_PIN_NAMED_CFG('A', 8, AVB_TX_CTL, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1465 SH_PFC_PIN_NAMED_CFG('A', 9, AVB_MDIO, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1466 SH_PFC_PIN_NAMED_CFG('A', 12, AVB_TXCREFCLK, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1467 SH_PFC_PIN_NAMED_CFG('A', 13, AVB_RD0, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1468 SH_PFC_PIN_NAMED_CFG('A', 14, AVB_RD2, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1469 SH_PFC_PIN_NAMED_CFG('A', 16, AVB_RX_CTL, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1470 SH_PFC_PIN_NAMED_CFG('A', 17, AVB_TD2, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1471 SH_PFC_PIN_NAMED_CFG('A', 18, AVB_TD0, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1472 SH_PFC_PIN_NAMED_CFG('A', 19, AVB_TXC, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1473 SH_PFC_PIN_NAMED_CFG('B', 13, AVB_RD1, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1474 SH_PFC_PIN_NAMED_CFG('B', 14, AVB_RD3, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1475 SH_PFC_PIN_NAMED_CFG('B', 17, AVB_TD3, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1476 SH_PFC_PIN_NAMED_CFG('B', 18, AVB_TD1, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1477 SH_PFC_PIN_NAMED_CFG('B', 19, AVB_RXC, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1478 SH_PFC_PIN_NAMED_CFG('C', 1, PRESETOUT#, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1479 SH_PFC_PIN_NAMED_CFG('F', 1, CLKOUT, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1480 SH_PFC_PIN_NAMED_CFG('H', 37, MLB_REF, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1481 SH_PFC_PIN_NAMED_CFG('V', 3, QSPI1_SPCLK, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1482 SH_PFC_PIN_NAMED_CFG('V', 5, QSPI1_SSL, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1483 SH_PFC_PIN_NAMED_CFG('V', 6, RPC_WP#, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1484 SH_PFC_PIN_NAMED_CFG('V', 7, RPC_RESET#, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1485 SH_PFC_PIN_NAMED_CFG('W', 3, QSPI0_SPCLK, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1486 SH_PFC_PIN_NAMED_CFG('Y', 3, QSPI0_SSL, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1487 SH_PFC_PIN_NAMED_CFG('Y', 6, QSPI0_IO2, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1488 SH_PFC_PIN_NAMED_CFG('Y', 7, RPC_INT#, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1489 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('B'), 4, QSPI0_MISO_IO1, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1490 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('B'), 6, QSPI0_IO3, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1491 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('C'), 3, QSPI1_IO3, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1492 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('C'), 5, QSPI0_MOSI_IO0, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1493 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('C'), 7, QSPI1_MOSI_IO0, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1494 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('D'), 38, FSCLKST#, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1495 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('E'), 4, QSPI1_IO2, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1496 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('E'), 5, QSPI1_MISO_IO1, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1497 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('P'), 7, DU_DOTCLKIN0, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1498 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('P'), 8, DU_DOTCLKIN1, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1499 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('R'), 7, DU_DOTCLKIN2, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1500 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('R'), 8, DU_DOTCLKIN3, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1501 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('R'), 30, TMS, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1502 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('T'), 28, TDO, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1503 SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('T'), 30, ASEBRK, SH_PFC_PIN_CFG_DRIVE_STRENGTH),
1419}; 1504};
1420 1505
1421/* - AUDIO CLOCK ------------------------------------------------------------ */ 1506/* - AUDIO CLOCK ------------------------------------------------------------ */
@@ -1563,11 +1648,33 @@ static const unsigned int avb_phy_int_mux[] = {
1563 AVB_PHY_INT_MARK, 1648 AVB_PHY_INT_MARK,
1564}; 1649};
1565static const unsigned int avb_mdc_pins[] = { 1650static const unsigned int avb_mdc_pins[] = {
1566 /* AVB_MDC */ 1651 /* AVB_MDC, AVB_MDIO */
1567 RCAR_GP_PIN(2, 9), 1652 RCAR_GP_PIN(2, 9), PIN_NUMBER('A', 9),
1568}; 1653};
1569static const unsigned int avb_mdc_mux[] = { 1654static const unsigned int avb_mdc_mux[] = {
1570 AVB_MDC_MARK, 1655 AVB_MDC_MARK, AVB_MDIO_MARK,
1656};
1657static const unsigned int avb_mii_pins[] = {
1658 /*
1659 * AVB_TX_CTL, AVB_TXC, AVB_TD0,
1660 * AVB_TD1, AVB_TD2, AVB_TD3,
1661 * AVB_RX_CTL, AVB_RXC, AVB_RD0,
1662 * AVB_RD1, AVB_RD2, AVB_RD3,
1663 * AVB_TXCREFCLK
1664 */
1665 PIN_NUMBER('A', 8), PIN_NUMBER('A', 19), PIN_NUMBER('A', 18),
1666 PIN_NUMBER('B', 18), PIN_NUMBER('A', 17), PIN_NUMBER('B', 17),
1667 PIN_NUMBER('A', 16), PIN_NUMBER('B', 19), PIN_NUMBER('A', 13),
1668 PIN_NUMBER('B', 13), PIN_NUMBER('A', 14), PIN_NUMBER('B', 14),
1669 PIN_NUMBER('A', 12),
1670
1671};
1672static const unsigned int avb_mii_mux[] = {
1673 AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
1674 AVB_TD1_MARK, AVB_TD2_MARK, AVB_TD3_MARK,
1675 AVB_RX_CTL_MARK, AVB_RXC_MARK, AVB_RD0_MARK,
1676 AVB_RD1_MARK, AVB_RD2_MARK, AVB_RD3_MARK,
1677 AVB_TXCREFCLK_MARK,
1571}; 1678};
1572static const unsigned int avb_avtp_pps_pins[] = { 1679static const unsigned int avb_avtp_pps_pins[] = {
1573 /* AVB_AVTP_PPS */ 1680 /* AVB_AVTP_PPS */
@@ -3613,6 +3720,55 @@ static const unsigned int usb2_mux[] = {
3613 USB2_PWEN_MARK, USB2_OVC_MARK, 3720 USB2_PWEN_MARK, USB2_OVC_MARK,
3614}; 3721};
3615 3722
3723/* - QSPI0 ------------------------------------------------------------------ */
3724static const unsigned int qspi0_ctrl_pins[] = {
3725 /* QSPI0_SPCLK, QSPI0_SSL */
3726 PIN_NUMBER('W', 3), PIN_NUMBER('Y', 3),
3727};
3728static const unsigned int qspi0_ctrl_mux[] = {
3729 QSPI0_SPCLK_MARK, QSPI0_SSL_MARK,
3730};
3731static const unsigned int qspi0_data2_pins[] = {
3732 /* QSPI0_MOSI_IO0, QSPI0_MISO_IO1 */
3733 PIN_A_NUMBER('C', 5), PIN_A_NUMBER('B', 4),
3734};
3735static const unsigned int qspi0_data2_mux[] = {
3736 QSPI0_MOSI_IO0_MARK, QSPI0_MISO_IO1_MARK,
3737};
3738static const unsigned int qspi0_data4_pins[] = {
3739 /* QSPI0_MOSI_IO0, QSPI0_MISO_IO1, QSPI0_IO2, QSPI0_IO3 */
3740 PIN_A_NUMBER('C', 5), PIN_A_NUMBER('B', 4),
3741 PIN_NUMBER('Y', 6), PIN_A_NUMBER('B', 6),
3742};
3743static const unsigned int qspi0_data4_mux[] = {
3744 QSPI0_MOSI_IO0_MARK, QSPI0_MISO_IO1_MARK,
3745 QSPI0_IO2_MARK, QSPI0_IO3_MARK,
3746};
3747/* - QSPI1 ------------------------------------------------------------------ */
3748static const unsigned int qspi1_ctrl_pins[] = {
3749 /* QSPI1_SPCLK, QSPI1_SSL */
3750 PIN_NUMBER('V', 3), PIN_NUMBER('V', 5),
3751};
3752static const unsigned int qspi1_ctrl_mux[] = {
3753 QSPI1_SPCLK_MARK, QSPI1_SSL_MARK,
3754};
3755static const unsigned int qspi1_data2_pins[] = {
3756 /* QSPI1_MOSI_IO0, QSPI1_MISO_IO1 */
3757 PIN_A_NUMBER('C', 7), PIN_A_NUMBER('E', 5),
3758};
3759static const unsigned int qspi1_data2_mux[] = {
3760 QSPI1_MOSI_IO0_MARK, QSPI1_MISO_IO1_MARK,
3761};
3762static const unsigned int qspi1_data4_pins[] = {
3763 /* QSPI1_MOSI_IO0, QSPI1_MISO_IO1, QSPI1_IO2, QSPI1_IO3 */
3764 PIN_A_NUMBER('C', 7), PIN_A_NUMBER('E', 5),
3765 PIN_A_NUMBER('E', 4), PIN_A_NUMBER('C', 3),
3766};
3767static const unsigned int qspi1_data4_mux[] = {
3768 QSPI1_MOSI_IO0_MARK, QSPI1_MISO_IO1_MARK,
3769 QSPI1_IO2_MARK, QSPI1_IO3_MARK,
3770};
3771
3616static const struct sh_pfc_pin_group pinmux_groups[] = { 3772static const struct sh_pfc_pin_group pinmux_groups[] = {
3617 SH_PFC_PIN_GROUP(audio_clk_a_a), 3773 SH_PFC_PIN_GROUP(audio_clk_a_a),
3618 SH_PFC_PIN_GROUP(audio_clk_a_b), 3774 SH_PFC_PIN_GROUP(audio_clk_a_b),
@@ -3635,6 +3791,7 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
3635 SH_PFC_PIN_GROUP(avb_magic), 3791 SH_PFC_PIN_GROUP(avb_magic),
3636 SH_PFC_PIN_GROUP(avb_phy_int), 3792 SH_PFC_PIN_GROUP(avb_phy_int),
3637 SH_PFC_PIN_GROUP(avb_mdc), 3793 SH_PFC_PIN_GROUP(avb_mdc),
3794 SH_PFC_PIN_GROUP(avb_mii),
3638 SH_PFC_PIN_GROUP(avb_avtp_pps), 3795 SH_PFC_PIN_GROUP(avb_avtp_pps),
3639 SH_PFC_PIN_GROUP(avb_avtp_match_a), 3796 SH_PFC_PIN_GROUP(avb_avtp_match_a),
3640 SH_PFC_PIN_GROUP(avb_avtp_capture_a), 3797 SH_PFC_PIN_GROUP(avb_avtp_capture_a),
@@ -3912,6 +4069,12 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
3912 SH_PFC_PIN_GROUP(usb0), 4069 SH_PFC_PIN_GROUP(usb0),
3913 SH_PFC_PIN_GROUP(usb1), 4070 SH_PFC_PIN_GROUP(usb1),
3914 SH_PFC_PIN_GROUP(usb2), 4071 SH_PFC_PIN_GROUP(usb2),
4072 SH_PFC_PIN_GROUP(qspi0_ctrl),
4073 SH_PFC_PIN_GROUP(qspi0_data2),
4074 SH_PFC_PIN_GROUP(qspi0_data4),
4075 SH_PFC_PIN_GROUP(qspi1_ctrl),
4076 SH_PFC_PIN_GROUP(qspi1_data2),
4077 SH_PFC_PIN_GROUP(qspi1_data4),
3915}; 4078};
3916 4079
3917static const char * const audio_clk_groups[] = { 4080static const char * const audio_clk_groups[] = {
@@ -3939,6 +4102,7 @@ static const char * const avb_groups[] = {
3939 "avb_magic", 4102 "avb_magic",
3940 "avb_phy_int", 4103 "avb_phy_int",
3941 "avb_mdc", 4104 "avb_mdc",
4105 "avb_mii",
3942 "avb_avtp_pps", 4106 "avb_avtp_pps",
3943 "avb_avtp_match_a", 4107 "avb_avtp_match_a",
3944 "avb_avtp_capture_a", 4108 "avb_avtp_capture_a",
@@ -4356,6 +4520,18 @@ static const char * const usb2_groups[] = {
4356 "usb2", 4520 "usb2",
4357}; 4521};
4358 4522
4523static const char * const qspi0_groups[] = {
4524 "qspi0_ctrl",
4525 "qspi0_data2",
4526 "qspi0_data4",
4527};
4528
4529static const char * const qspi1_groups[] = {
4530 "qspi1_ctrl",
4531 "qspi1_data2",
4532 "qspi1_data4",
4533};
4534
4359static const struct sh_pfc_function pinmux_functions[] = { 4535static const struct sh_pfc_function pinmux_functions[] = {
4360 SH_PFC_FUNCTION(audio_clk), 4536 SH_PFC_FUNCTION(audio_clk),
4361 SH_PFC_FUNCTION(avb), 4537 SH_PFC_FUNCTION(avb),
@@ -4405,6 +4581,8 @@ static const struct sh_pfc_function pinmux_functions[] = {
4405 SH_PFC_FUNCTION(usb0), 4581 SH_PFC_FUNCTION(usb0),
4406 SH_PFC_FUNCTION(usb1), 4582 SH_PFC_FUNCTION(usb1),
4407 SH_PFC_FUNCTION(usb2), 4583 SH_PFC_FUNCTION(usb2),
4584 SH_PFC_FUNCTION(qspi0),
4585 SH_PFC_FUNCTION(qspi1),
4408}; 4586};
4409 4587
4410static const struct pinmux_cfg_reg pinmux_config_regs[] = { 4588static const struct pinmux_cfg_reg pinmux_config_regs[] = {
@@ -4962,10 +5140,45 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
4962}; 5140};
4963 5141
4964static const struct pinmux_drive_reg pinmux_drive_regs[] = { 5142static const struct pinmux_drive_reg pinmux_drive_regs[] = {
5143 { PINMUX_DRIVE_REG("DRVCTRL0", 0xe6060300) {
5144 { PIN_NUMBER('W', 3), 28, 2 }, /* QSPI0_SPCLK */
5145 { PIN_A_NUMBER('C', 5), 24, 2 }, /* QSPI0_MOSI_IO0 */
5146 { PIN_A_NUMBER('B', 4), 20, 2 }, /* QSPI0_MISO_IO1 */
5147 { PIN_NUMBER('Y', 6), 16, 2 }, /* QSPI0_IO2 */
5148 { PIN_A_NUMBER('B', 6), 12, 2 }, /* QSPI0_IO3 */
5149 { PIN_NUMBER('Y', 3), 8, 2 }, /* QSPI0_SSL */
5150 { PIN_NUMBER('V', 3), 4, 2 }, /* QSPI1_SPCLK */
5151 { PIN_A_NUMBER('C', 7), 0, 2 }, /* QSPI1_MOSI_IO0 */
5152 } },
5153 { PINMUX_DRIVE_REG("DRVCTRL1", 0xe6060304) {
5154 { PIN_A_NUMBER('E', 5), 28, 2 }, /* QSPI1_MISO_IO1 */
5155 { PIN_A_NUMBER('E', 4), 24, 2 }, /* QSPI1_IO2 */
5156 { PIN_A_NUMBER('C', 3), 20, 2 }, /* QSPI1_IO3 */
5157 { PIN_NUMBER('V', 5), 16, 2 }, /* QSPI1_SSL */
5158 { PIN_NUMBER('Y', 7), 12, 2 }, /* RPC_INT# */
5159 { PIN_NUMBER('V', 6), 8, 2 }, /* RPC_WP# */
5160 { PIN_NUMBER('V', 7), 4, 2 }, /* RPC_RESET# */
5161 { PIN_NUMBER('A', 16), 0, 3 }, /* AVB_RX_CTL */
5162 } },
5163 { PINMUX_DRIVE_REG("DRVCTRL2", 0xe6060308) {
5164 { PIN_NUMBER('B', 19), 28, 3 }, /* AVB_RXC */
5165 { PIN_NUMBER('A', 13), 24, 3 }, /* AVB_RD0 */
5166 { PIN_NUMBER('B', 13), 20, 3 }, /* AVB_RD1 */
5167 { PIN_NUMBER('A', 14), 16, 3 }, /* AVB_RD2 */
5168 { PIN_NUMBER('B', 14), 12, 3 }, /* AVB_RD3 */
5169 { PIN_NUMBER('A', 8), 8, 3 }, /* AVB_TX_CTL */
5170 { PIN_NUMBER('A', 19), 4, 3 }, /* AVB_TXC */
5171 { PIN_NUMBER('A', 18), 0, 3 }, /* AVB_TD0 */
5172 } },
4965 { PINMUX_DRIVE_REG("DRVCTRL3", 0xe606030c) { 5173 { PINMUX_DRIVE_REG("DRVCTRL3", 0xe606030c) {
4966 { RCAR_GP_PIN(2, 9), 8, 3 }, /* AVB_MDC */ 5174 { PIN_NUMBER('B', 18), 28, 3 }, /* AVB_TD1 */
4967 { RCAR_GP_PIN(2, 10), 4, 3 }, /* AVB_MAGIC */ 5175 { PIN_NUMBER('A', 17), 24, 3 }, /* AVB_TD2 */
4968 { RCAR_GP_PIN(2, 11), 0, 3 }, /* AVB_PHY_INT */ 5176 { PIN_NUMBER('B', 17), 20, 3 }, /* AVB_TD3 */
5177 { PIN_NUMBER('A', 12), 16, 3 }, /* AVB_TXCREFCLK */
5178 { PIN_NUMBER('A', 9), 12, 3 }, /* AVB_MDIO */
5179 { RCAR_GP_PIN(2, 9), 8, 3 }, /* AVB_MDC */
5180 { RCAR_GP_PIN(2, 10), 4, 3 }, /* AVB_MAGIC */
5181 { RCAR_GP_PIN(2, 11), 0, 3 }, /* AVB_PHY_INT */
4969 } }, 5182 } },
4970 { PINMUX_DRIVE_REG("DRVCTRL4", 0xe6060310) { 5183 { PINMUX_DRIVE_REG("DRVCTRL4", 0xe6060310) {
4971 { RCAR_GP_PIN(2, 12), 28, 3 }, /* AVB_LINK */ 5184 { RCAR_GP_PIN(2, 12), 28, 3 }, /* AVB_LINK */
@@ -5008,6 +5221,7 @@ static const struct pinmux_drive_reg pinmux_drive_regs[] = {
5008 { RCAR_GP_PIN(1, 19), 0, 3 }, /* A19 */ 5221 { RCAR_GP_PIN(1, 19), 0, 3 }, /* A19 */
5009 } }, 5222 } },
5010 { PINMUX_DRIVE_REG("DRVCTRL8", 0xe6060320) { 5223 { PINMUX_DRIVE_REG("DRVCTRL8", 0xe6060320) {
5224 { PIN_NUMBER('F', 1), 28, 3 }, /* CLKOUT */
5011 { RCAR_GP_PIN(1, 20), 24, 3 }, /* CS0 */ 5225 { RCAR_GP_PIN(1, 20), 24, 3 }, /* CS0 */
5012 { RCAR_GP_PIN(1, 21), 20, 3 }, /* CS1_A26 */ 5226 { RCAR_GP_PIN(1, 21), 20, 3 }, /* CS1_A26 */
5013 { RCAR_GP_PIN(1, 22), 16, 3 }, /* BS */ 5227 { RCAR_GP_PIN(1, 22), 16, 3 }, /* BS */
@@ -5018,6 +5232,7 @@ static const struct pinmux_drive_reg pinmux_drive_regs[] = {
5018 } }, 5232 } },
5019 { PINMUX_DRIVE_REG("DRVCTRL9", 0xe6060324) { 5233 { PINMUX_DRIVE_REG("DRVCTRL9", 0xe6060324) {
5020 { RCAR_GP_PIN(1, 27), 28, 3 }, /* EX_WAIT0 */ 5234 { RCAR_GP_PIN(1, 27), 28, 3 }, /* EX_WAIT0 */
5235 { PIN_NUMBER('C', 1), 24, 3 }, /* PRESETOUT# */
5021 { RCAR_GP_PIN(0, 0), 20, 3 }, /* D0 */ 5236 { RCAR_GP_PIN(0, 0), 20, 3 }, /* D0 */
5022 { RCAR_GP_PIN(0, 1), 16, 3 }, /* D1 */ 5237 { RCAR_GP_PIN(0, 1), 16, 3 }, /* D1 */
5023 { RCAR_GP_PIN(0, 2), 12, 3 }, /* D2 */ 5238 { RCAR_GP_PIN(0, 2), 12, 3 }, /* D2 */
@@ -5036,20 +5251,30 @@ static const struct pinmux_drive_reg pinmux_drive_regs[] = {
5036 { RCAR_GP_PIN(0, 13), 0, 3 }, /* D13 */ 5251 { RCAR_GP_PIN(0, 13), 0, 3 }, /* D13 */
5037 } }, 5252 } },
5038 { PINMUX_DRIVE_REG("DRVCTRL11", 0xe606032c) { 5253 { PINMUX_DRIVE_REG("DRVCTRL11", 0xe606032c) {
5039 { RCAR_GP_PIN(0, 14), 28, 3 }, /* D14 */ 5254 { RCAR_GP_PIN(0, 14), 28, 3 }, /* D14 */
5040 { RCAR_GP_PIN(0, 15), 24, 3 }, /* D15 */ 5255 { RCAR_GP_PIN(0, 15), 24, 3 }, /* D15 */
5041 { RCAR_GP_PIN(7, 0), 20, 3 }, /* AVS1 */ 5256 { RCAR_GP_PIN(7, 0), 20, 3 }, /* AVS1 */
5042 { RCAR_GP_PIN(7, 1), 16, 3 }, /* AVS2 */ 5257 { RCAR_GP_PIN(7, 1), 16, 3 }, /* AVS2 */
5043 { RCAR_GP_PIN(7, 2), 12, 3 }, /* HDMI0_CEC */ 5258 { RCAR_GP_PIN(7, 2), 12, 3 }, /* HDMI0_CEC */
5044 { RCAR_GP_PIN(7, 3), 8, 3 }, /* HDMI1_CEC */ 5259 { RCAR_GP_PIN(7, 3), 8, 3 }, /* HDMI1_CEC */
5260 { PIN_A_NUMBER('P', 7), 4, 2 }, /* DU_DOTCLKIN0 */
5261 { PIN_A_NUMBER('P', 8), 0, 2 }, /* DU_DOTCLKIN1 */
5262 } },
5263 { PINMUX_DRIVE_REG("DRVCTRL12", 0xe6060330) {
5264 { PIN_A_NUMBER('R', 7), 28, 2 }, /* DU_DOTCLKIN2 */
5265 { PIN_A_NUMBER('R', 8), 24, 2 }, /* DU_DOTCLKIN3 */
5266 { PIN_A_NUMBER('D', 38), 20, 2 }, /* FSCLKST# */
5267 { PIN_A_NUMBER('R', 30), 4, 2 }, /* TMS */
5045 } }, 5268 } },
5046 { PINMUX_DRIVE_REG("DRVCTRL13", 0xe6060334) { 5269 { PINMUX_DRIVE_REG("DRVCTRL13", 0xe6060334) {
5047 { RCAR_GP_PIN(3, 0), 20, 3 }, /* SD0_CLK */ 5270 { PIN_A_NUMBER('T', 28), 28, 2 }, /* TDO */
5048 { RCAR_GP_PIN(3, 1), 16, 3 }, /* SD0_CMD */ 5271 { PIN_A_NUMBER('T', 30), 24, 2 }, /* ASEBRK */
5049 { RCAR_GP_PIN(3, 2), 12, 3 }, /* SD0_DAT0 */ 5272 { RCAR_GP_PIN(3, 0), 20, 3 }, /* SD0_CLK */
5050 { RCAR_GP_PIN(3, 3), 8, 3 }, /* SD0_DAT1 */ 5273 { RCAR_GP_PIN(3, 1), 16, 3 }, /* SD0_CMD */
5051 { RCAR_GP_PIN(3, 4), 4, 3 }, /* SD0_DAT2 */ 5274 { RCAR_GP_PIN(3, 2), 12, 3 }, /* SD0_DAT0 */
5052 { RCAR_GP_PIN(3, 5), 0, 3 }, /* SD0_DAT3 */ 5275 { RCAR_GP_PIN(3, 3), 8, 3 }, /* SD0_DAT1 */
5276 { RCAR_GP_PIN(3, 4), 4, 3 }, /* SD0_DAT2 */
5277 { RCAR_GP_PIN(3, 5), 0, 3 }, /* SD0_DAT3 */
5053 } }, 5278 } },
5054 { PINMUX_DRIVE_REG("DRVCTRL14", 0xe6060338) { 5279 { PINMUX_DRIVE_REG("DRVCTRL14", 0xe6060338) {
5055 { RCAR_GP_PIN(3, 6), 28, 3 }, /* SD1_CLK */ 5280 { RCAR_GP_PIN(3, 6), 28, 3 }, /* SD1_CLK */
@@ -5118,6 +5343,7 @@ static const struct pinmux_drive_reg pinmux_drive_regs[] = {
5118 { RCAR_GP_PIN(5, 23), 16, 3 }, /* MLB_CLK */ 5343 { RCAR_GP_PIN(5, 23), 16, 3 }, /* MLB_CLK */
5119 { RCAR_GP_PIN(5, 24), 12, 3 }, /* MLB_SIG */ 5344 { RCAR_GP_PIN(5, 24), 12, 3 }, /* MLB_SIG */
5120 { RCAR_GP_PIN(5, 25), 8, 3 }, /* MLB_DAT */ 5345 { RCAR_GP_PIN(5, 25), 8, 3 }, /* MLB_DAT */
5346 { PIN_NUMBER('H', 37), 4, 3 }, /* MLB_REF */
5121 { RCAR_GP_PIN(6, 0), 0, 3 }, /* SSI_SCK01239 */ 5347 { RCAR_GP_PIN(6, 0), 0, 3 }, /* SSI_SCK01239 */
5122 } }, 5348 } },
5123 { PINMUX_DRIVE_REG("DRVCTRL21", 0xe6060354) { 5349 { PINMUX_DRIVE_REG("DRVCTRL21", 0xe6060354) {
@@ -5188,206 +5414,206 @@ static int r8a7795_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *poc
5188#define PU5 0x14 5414#define PU5 0x14
5189#define PU6 0x18 5415#define PU6 0x18
5190 5416
5191static const struct { 5417static const struct sh_pfc_bias_info bias_info[] = {
5192 u16 reg : 11; 5418 { RCAR_GP_PIN(2, 11), PU0, 31 }, /* AVB_PHY_INT */
5193 u16 bit : 5; 5419 { RCAR_GP_PIN(2, 10), PU0, 30 }, /* AVB_MAGIC */
5194} pullups[] = { 5420 { RCAR_GP_PIN(2, 9), PU0, 29 }, /* AVB_MDC */
5195 [RCAR_GP_PIN(2, 11)] = { PU0, 31 }, /* AVB_PHY_INT */ 5421
5196 [RCAR_GP_PIN(2, 10)] = { PU0, 30 }, /* AVB_MAGIC */ 5422 { RCAR_GP_PIN(1, 19), PU1, 31 }, /* A19 */
5197 [RCAR_GP_PIN(2, 9)] = { PU0, 29 }, /* AVB_MDC */ 5423 { RCAR_GP_PIN(1, 18), PU1, 30 }, /* A18 */
5198 5424 { RCAR_GP_PIN(1, 17), PU1, 29 }, /* A17 */
5199 [RCAR_GP_PIN(1, 19)] = { PU1, 31 }, /* A19 */ 5425 { RCAR_GP_PIN(1, 16), PU1, 28 }, /* A16 */
5200 [RCAR_GP_PIN(1, 18)] = { PU1, 30 }, /* A18 */ 5426 { RCAR_GP_PIN(1, 15), PU1, 27 }, /* A15 */
5201 [RCAR_GP_PIN(1, 17)] = { PU1, 29 }, /* A17 */ 5427 { RCAR_GP_PIN(1, 14), PU1, 26 }, /* A14 */
5202 [RCAR_GP_PIN(1, 16)] = { PU1, 28 }, /* A16 */ 5428 { RCAR_GP_PIN(1, 13), PU1, 25 }, /* A13 */
5203 [RCAR_GP_PIN(1, 15)] = { PU1, 27 }, /* A15 */ 5429 { RCAR_GP_PIN(1, 12), PU1, 24 }, /* A12 */
5204 [RCAR_GP_PIN(1, 14)] = { PU1, 26 }, /* A14 */ 5430 { RCAR_GP_PIN(1, 11), PU1, 23 }, /* A11 */
5205 [RCAR_GP_PIN(1, 13)] = { PU1, 25 }, /* A13 */ 5431 { RCAR_GP_PIN(1, 10), PU1, 22 }, /* A10 */
5206 [RCAR_GP_PIN(1, 12)] = { PU1, 24 }, /* A12 */ 5432 { RCAR_GP_PIN(1, 9), PU1, 21 }, /* A9 */
5207 [RCAR_GP_PIN(1, 11)] = { PU1, 23 }, /* A11 */ 5433 { RCAR_GP_PIN(1, 8), PU1, 20 }, /* A8 */
5208 [RCAR_GP_PIN(1, 10)] = { PU1, 22 }, /* A10 */ 5434 { RCAR_GP_PIN(1, 7), PU1, 19 }, /* A7 */
5209 [RCAR_GP_PIN(1, 9)] = { PU1, 21 }, /* A9 */ 5435 { RCAR_GP_PIN(1, 6), PU1, 18 }, /* A6 */
5210 [RCAR_GP_PIN(1, 8)] = { PU1, 20 }, /* A8 */ 5436 { RCAR_GP_PIN(1, 5), PU1, 17 }, /* A5 */
5211 [RCAR_GP_PIN(1, 7)] = { PU1, 19 }, /* A7 */ 5437 { RCAR_GP_PIN(1, 4), PU1, 16 }, /* A4 */
5212 [RCAR_GP_PIN(1, 6)] = { PU1, 18 }, /* A6 */ 5438 { RCAR_GP_PIN(1, 3), PU1, 15 }, /* A3 */
5213 [RCAR_GP_PIN(1, 5)] = { PU1, 17 }, /* A5 */ 5439 { RCAR_GP_PIN(1, 2), PU1, 14 }, /* A2 */
5214 [RCAR_GP_PIN(1, 4)] = { PU1, 16 }, /* A4 */ 5440 { RCAR_GP_PIN(1, 1), PU1, 13 }, /* A1 */
5215 [RCAR_GP_PIN(1, 3)] = { PU1, 15 }, /* A3 */ 5441 { RCAR_GP_PIN(1, 0), PU1, 12 }, /* A0 */
5216 [RCAR_GP_PIN(1, 2)] = { PU1, 14 }, /* A2 */ 5442 { RCAR_GP_PIN(2, 8), PU1, 11 }, /* PWM2_A */
5217 [RCAR_GP_PIN(1, 1)] = { PU1, 13 }, /* A1 */ 5443 { RCAR_GP_PIN(2, 7), PU1, 10 }, /* PWM1_A */
5218 [RCAR_GP_PIN(1, 0)] = { PU1, 12 }, /* A0 */ 5444 { RCAR_GP_PIN(2, 6), PU1, 9 }, /* PWM0 */
5219 [RCAR_GP_PIN(2, 8)] = { PU1, 11 }, /* PWM2_A */ 5445 { RCAR_GP_PIN(2, 5), PU1, 8 }, /* IRQ5 */
5220 [RCAR_GP_PIN(2, 7)] = { PU1, 10 }, /* PWM1_A */ 5446 { RCAR_GP_PIN(2, 4), PU1, 7 }, /* IRQ4 */
5221 [RCAR_GP_PIN(2, 6)] = { PU1, 9 }, /* PWM0 */ 5447 { RCAR_GP_PIN(2, 3), PU1, 6 }, /* IRQ3 */
5222 [RCAR_GP_PIN(2, 5)] = { PU1, 8 }, /* IRQ5 */ 5448 { RCAR_GP_PIN(2, 2), PU1, 5 }, /* IRQ2 */
5223 [RCAR_GP_PIN(2, 4)] = { PU1, 7 }, /* IRQ4 */ 5449 { RCAR_GP_PIN(2, 1), PU1, 4 }, /* IRQ1 */
5224 [RCAR_GP_PIN(2, 3)] = { PU1, 6 }, /* IRQ3 */ 5450 { RCAR_GP_PIN(2, 0), PU1, 3 }, /* IRQ0 */
5225 [RCAR_GP_PIN(2, 2)] = { PU1, 5 }, /* IRQ2 */ 5451 { RCAR_GP_PIN(2, 14), PU1, 2 }, /* AVB_AVTP_CAPTURE_A */
5226 [RCAR_GP_PIN(2, 1)] = { PU1, 4 }, /* IRQ1 */ 5452 { RCAR_GP_PIN(2, 13), PU1, 1 }, /* AVB_AVTP_MATCH_A */
5227 [RCAR_GP_PIN(2, 0)] = { PU1, 3 }, /* IRQ0 */ 5453 { RCAR_GP_PIN(2, 12), PU1, 0 }, /* AVB_LINK */
5228 [RCAR_GP_PIN(2, 14)] = { PU1, 2 }, /* AVB_AVTP_CAPTURE_A */ 5454
5229 [RCAR_GP_PIN(2, 13)] = { PU1, 1 }, /* AVB_AVTP_MATCH_A */ 5455 { RCAR_GP_PIN(7, 3), PU2, 29 }, /* HDMI1_CEC */
5230 [RCAR_GP_PIN(2, 12)] = { PU1, 0 }, /* AVB_LINK */ 5456 { RCAR_GP_PIN(7, 2), PU2, 28 }, /* HDMI0_CEC */
5231 5457 { RCAR_GP_PIN(7, 1), PU2, 27 }, /* AVS2 */
5232 [RCAR_GP_PIN(7, 3)] = { PU2, 29 }, /* HDMI1_CEC */ 5458 { RCAR_GP_PIN(7, 0), PU2, 26 }, /* AVS1 */
5233 [RCAR_GP_PIN(7, 2)] = { PU2, 28 }, /* HDMI0_CEC */ 5459 { RCAR_GP_PIN(0, 15), PU2, 25 }, /* D15 */
5234 [RCAR_GP_PIN(7, 1)] = { PU2, 27 }, /* AVS2 */ 5460 { RCAR_GP_PIN(0, 14), PU2, 24 }, /* D14 */
5235 [RCAR_GP_PIN(7, 0)] = { PU2, 26 }, /* AVS1 */ 5461 { RCAR_GP_PIN(0, 13), PU2, 23 }, /* D13 */
5236 [RCAR_GP_PIN(0, 15)] = { PU2, 25 }, /* D15 */ 5462 { RCAR_GP_PIN(0, 12), PU2, 22 }, /* D12 */
5237 [RCAR_GP_PIN(0, 14)] = { PU2, 24 }, /* D14 */ 5463 { RCAR_GP_PIN(0, 11), PU2, 21 }, /* D11 */
5238 [RCAR_GP_PIN(0, 13)] = { PU2, 23 }, /* D13 */ 5464 { RCAR_GP_PIN(0, 10), PU2, 20 }, /* D10 */
5239 [RCAR_GP_PIN(0, 12)] = { PU2, 22 }, /* D12 */ 5465 { RCAR_GP_PIN(0, 9), PU2, 19 }, /* D9 */
5240 [RCAR_GP_PIN(0, 11)] = { PU2, 21 }, /* D11 */ 5466 { RCAR_GP_PIN(0, 8), PU2, 18 }, /* D8 */
5241 [RCAR_GP_PIN(0, 10)] = { PU2, 20 }, /* D10 */ 5467 { RCAR_GP_PIN(0, 7), PU2, 17 }, /* D7 */
5242 [RCAR_GP_PIN(0, 9)] = { PU2, 19 }, /* D9 */ 5468 { RCAR_GP_PIN(0, 6), PU2, 16 }, /* D6 */
5243 [RCAR_GP_PIN(0, 8)] = { PU2, 18 }, /* D8 */ 5469 { RCAR_GP_PIN(0, 5), PU2, 15 }, /* D5 */
5244 [RCAR_GP_PIN(0, 7)] = { PU2, 17 }, /* D7 */ 5470 { RCAR_GP_PIN(0, 4), PU2, 14 }, /* D4 */
5245 [RCAR_GP_PIN(0, 6)] = { PU2, 16 }, /* D6 */ 5471 { RCAR_GP_PIN(0, 3), PU2, 13 }, /* D3 */
5246 [RCAR_GP_PIN(0, 5)] = { PU2, 15 }, /* D5 */ 5472 { RCAR_GP_PIN(0, 2), PU2, 12 }, /* D2 */
5247 [RCAR_GP_PIN(0, 4)] = { PU2, 14 }, /* D4 */ 5473 { RCAR_GP_PIN(0, 1), PU2, 11 }, /* D1 */
5248 [RCAR_GP_PIN(0, 3)] = { PU2, 13 }, /* D3 */ 5474 { RCAR_GP_PIN(0, 0), PU2, 10 }, /* D0 */
5249 [RCAR_GP_PIN(0, 2)] = { PU2, 12 }, /* D2 */ 5475 { RCAR_GP_PIN(1, 27), PU2, 8 }, /* EX_WAIT0_A */
5250 [RCAR_GP_PIN(0, 1)] = { PU2, 11 }, /* D1 */ 5476 { RCAR_GP_PIN(1, 26), PU2, 7 }, /* WE1_N */
5251 [RCAR_GP_PIN(0, 0)] = { PU2, 10 }, /* D0 */ 5477 { RCAR_GP_PIN(1, 25), PU2, 6 }, /* WE0_N */
5252 [RCAR_GP_PIN(1, 27)] = { PU2, 8 }, /* EX_WAIT0_A */ 5478 { RCAR_GP_PIN(1, 24), PU2, 5 }, /* RD_WR_N */
5253 [RCAR_GP_PIN(1, 26)] = { PU2, 7 }, /* WE1_N */ 5479 { RCAR_GP_PIN(1, 23), PU2, 4 }, /* RD_N */
5254 [RCAR_GP_PIN(1, 25)] = { PU2, 6 }, /* WE0_N */ 5480 { RCAR_GP_PIN(1, 22), PU2, 3 }, /* BS_N */
5255 [RCAR_GP_PIN(1, 24)] = { PU2, 5 }, /* RD_WR_N */ 5481 { RCAR_GP_PIN(1, 21), PU2, 2 }, /* CS1_N_A26 */
5256 [RCAR_GP_PIN(1, 23)] = { PU2, 4 }, /* RD_N */ 5482 { RCAR_GP_PIN(1, 20), PU2, 1 }, /* CS0_N */
5257 [RCAR_GP_PIN(1, 22)] = { PU2, 3 }, /* BS_N */ 5483
5258 [RCAR_GP_PIN(1, 21)] = { PU2, 2 }, /* CS1_N_A26 */ 5484 { RCAR_GP_PIN(4, 9), PU3, 31 }, /* SD3_DAT0 */
5259 [RCAR_GP_PIN(1, 20)] = { PU2, 1 }, /* CS0_N */ 5485 { RCAR_GP_PIN(4, 8), PU3, 30 }, /* SD3_CMD */
5260 5486 { RCAR_GP_PIN(4, 7), PU3, 29 }, /* SD3_CLK */
5261 [RCAR_GP_PIN(4, 9)] = { PU3, 31 }, /* SD3_DAT0 */ 5487 { RCAR_GP_PIN(4, 6), PU3, 28 }, /* SD2_DS */
5262 [RCAR_GP_PIN(4, 8)] = { PU3, 30 }, /* SD3_CMD */ 5488 { RCAR_GP_PIN(4, 5), PU3, 27 }, /* SD2_DAT3 */
5263 [RCAR_GP_PIN(4, 7)] = { PU3, 29 }, /* SD3_CLK */ 5489 { RCAR_GP_PIN(4, 4), PU3, 26 }, /* SD2_DAT2 */
5264 [RCAR_GP_PIN(4, 6)] = { PU3, 28 }, /* SD2_DS */ 5490 { RCAR_GP_PIN(4, 3), PU3, 25 }, /* SD2_DAT1 */
5265 [RCAR_GP_PIN(4, 5)] = { PU3, 27 }, /* SD2_DAT3 */ 5491 { RCAR_GP_PIN(4, 2), PU3, 24 }, /* SD2_DAT0 */
5266 [RCAR_GP_PIN(4, 4)] = { PU3, 26 }, /* SD2_DAT2 */ 5492 { RCAR_GP_PIN(4, 1), PU3, 23 }, /* SD2_CMD */
5267 [RCAR_GP_PIN(4, 3)] = { PU3, 25 }, /* SD2_DAT1 */ 5493 { RCAR_GP_PIN(4, 0), PU3, 22 }, /* SD2_CLK */
5268 [RCAR_GP_PIN(4, 2)] = { PU3, 24 }, /* SD2_DAT0 */ 5494 { RCAR_GP_PIN(3, 11), PU3, 21 }, /* SD1_DAT3 */
5269 [RCAR_GP_PIN(4, 1)] = { PU3, 23 }, /* SD2_CMD */ 5495 { RCAR_GP_PIN(3, 10), PU3, 20 }, /* SD1_DAT2 */
5270 [RCAR_GP_PIN(4, 0)] = { PU3, 22 }, /* SD2_CLK */ 5496 { RCAR_GP_PIN(3, 9), PU3, 19 }, /* SD1_DAT1 */
5271 [RCAR_GP_PIN(3, 11)] = { PU3, 21 }, /* SD1_DAT3 */ 5497 { RCAR_GP_PIN(3, 8), PU3, 18 }, /* SD1_DAT0 */
5272 [RCAR_GP_PIN(3, 10)] = { PU3, 20 }, /* SD1_DAT2 */ 5498 { RCAR_GP_PIN(3, 7), PU3, 17 }, /* SD1_CMD */
5273 [RCAR_GP_PIN(3, 9)] = { PU3, 19 }, /* SD1_DAT1 */ 5499 { RCAR_GP_PIN(3, 6), PU3, 16 }, /* SD1_CLK */
5274 [RCAR_GP_PIN(3, 8)] = { PU3, 18 }, /* SD1_DAT0 */ 5500 { RCAR_GP_PIN(3, 5), PU3, 15 }, /* SD0_DAT3 */
5275 [RCAR_GP_PIN(3, 7)] = { PU3, 17 }, /* SD1_CMD */ 5501 { RCAR_GP_PIN(3, 4), PU3, 14 }, /* SD0_DAT2 */
5276 [RCAR_GP_PIN(3, 6)] = { PU3, 16 }, /* SD1_CLK */ 5502 { RCAR_GP_PIN(3, 3), PU3, 13 }, /* SD0_DAT1 */
5277 [RCAR_GP_PIN(3, 5)] = { PU3, 15 }, /* SD0_DAT3 */ 5503 { RCAR_GP_PIN(3, 2), PU3, 12 }, /* SD0_DAT0 */
5278 [RCAR_GP_PIN(3, 4)] = { PU3, 14 }, /* SD0_DAT2 */ 5504 { RCAR_GP_PIN(3, 1), PU3, 11 }, /* SD0_CMD */
5279 [RCAR_GP_PIN(3, 3)] = { PU3, 13 }, /* SD0_DAT1 */ 5505 { RCAR_GP_PIN(3, 0), PU3, 10 }, /* SD0_CLK */
5280 [RCAR_GP_PIN(3, 2)] = { PU3, 12 }, /* SD0_DAT0 */ 5506
5281 [RCAR_GP_PIN(3, 1)] = { PU3, 11 }, /* SD0_CMD */ 5507 { RCAR_GP_PIN(5, 19), PU4, 31 }, /* MSIOF0_SS1 */
5282 [RCAR_GP_PIN(3, 0)] = { PU3, 10 }, /* SD0_CLK */ 5508 { RCAR_GP_PIN(5, 18), PU4, 30 }, /* MSIOF0_SYNC */
5283 5509 { RCAR_GP_PIN(5, 17), PU4, 29 }, /* MSIOF0_SCK */
5284 [RCAR_GP_PIN(5, 19)] = { PU4, 31 }, /* MSIOF0_SS1 */ 5510 { RCAR_GP_PIN(5, 16), PU4, 28 }, /* HRTS0_N */
5285 [RCAR_GP_PIN(5, 18)] = { PU4, 30 }, /* MSIOF0_SYNC */ 5511 { RCAR_GP_PIN(5, 15), PU4, 27 }, /* HCTS0_N */
5286 [RCAR_GP_PIN(5, 17)] = { PU4, 29 }, /* MSIOF0_SCK */ 5512 { RCAR_GP_PIN(5, 14), PU4, 26 }, /* HTX0 */
5287 [RCAR_GP_PIN(5, 16)] = { PU4, 28 }, /* HRTS0_N */ 5513 { RCAR_GP_PIN(5, 13), PU4, 25 }, /* HRX0 */
5288 [RCAR_GP_PIN(5, 15)] = { PU4, 27 }, /* HCTS0_N */ 5514 { RCAR_GP_PIN(5, 12), PU4, 24 }, /* HSCK0 */
5289 [RCAR_GP_PIN(5, 14)] = { PU4, 26 }, /* HTX0 */ 5515 { RCAR_GP_PIN(5, 11), PU4, 23 }, /* RX2_A */
5290 [RCAR_GP_PIN(5, 13)] = { PU4, 25 }, /* HRX0 */ 5516 { RCAR_GP_PIN(5, 10), PU4, 22 }, /* TX2_A */
5291 [RCAR_GP_PIN(5, 12)] = { PU4, 24 }, /* HSCK0 */ 5517 { RCAR_GP_PIN(5, 9), PU4, 21 }, /* SCK2 */
5292 [RCAR_GP_PIN(5, 11)] = { PU4, 23 }, /* RX2_A */ 5518 { RCAR_GP_PIN(5, 8), PU4, 20 }, /* RTS1_N_TANS */
5293 [RCAR_GP_PIN(5, 10)] = { PU4, 22 }, /* TX2_A */ 5519 { RCAR_GP_PIN(5, 7), PU4, 19 }, /* CTS1_N */
5294 [RCAR_GP_PIN(5, 9)] = { PU4, 21 }, /* SCK2 */ 5520 { RCAR_GP_PIN(5, 6), PU4, 18 }, /* TX1_A */
5295 [RCAR_GP_PIN(5, 8)] = { PU4, 20 }, /* RTS1_N_TANS */ 5521 { RCAR_GP_PIN(5, 5), PU4, 17 }, /* RX1_A */
5296 [RCAR_GP_PIN(5, 7)] = { PU4, 19 }, /* CTS1_N */ 5522 { RCAR_GP_PIN(5, 4), PU4, 16 }, /* RTS0_N_TANS */
5297 [RCAR_GP_PIN(5, 6)] = { PU4, 18 }, /* TX1_A */ 5523 { RCAR_GP_PIN(5, 3), PU4, 15 }, /* CTS0_N */
5298 [RCAR_GP_PIN(5, 5)] = { PU4, 17 }, /* RX1_A */ 5524 { RCAR_GP_PIN(5, 2), PU4, 14 }, /* TX0 */
5299 [RCAR_GP_PIN(5, 4)] = { PU4, 16 }, /* RTS0_N_TANS */ 5525 { RCAR_GP_PIN(5, 1), PU4, 13 }, /* RX0 */
5300 [RCAR_GP_PIN(5, 3)] = { PU4, 15 }, /* CTS0_N */ 5526 { RCAR_GP_PIN(5, 0), PU4, 12 }, /* SCK0 */
5301 [RCAR_GP_PIN(5, 2)] = { PU4, 14 }, /* TX0 */ 5527 { RCAR_GP_PIN(3, 15), PU4, 11 }, /* SD1_WP */
5302 [RCAR_GP_PIN(5, 1)] = { PU4, 13 }, /* RX0 */ 5528 { RCAR_GP_PIN(3, 14), PU4, 10 }, /* SD1_CD */
5303 [RCAR_GP_PIN(5, 0)] = { PU4, 12 }, /* SCK0 */ 5529 { RCAR_GP_PIN(3, 13), PU4, 9 }, /* SD0_WP */
5304 [RCAR_GP_PIN(3, 15)] = { PU4, 11 }, /* SD1_WP */ 5530 { RCAR_GP_PIN(3, 12), PU4, 8 }, /* SD0_CD */
5305 [RCAR_GP_PIN(3, 14)] = { PU4, 10 }, /* SD1_CD */ 5531 { RCAR_GP_PIN(4, 17), PU4, 7 }, /* SD3_DS */
5306 [RCAR_GP_PIN(3, 13)] = { PU4, 9 }, /* SD0_WP */ 5532 { RCAR_GP_PIN(4, 16), PU4, 6 }, /* SD3_DAT7 */
5307 [RCAR_GP_PIN(3, 12)] = { PU4, 8 }, /* SD0_CD */ 5533 { RCAR_GP_PIN(4, 15), PU4, 5 }, /* SD3_DAT6 */
5308 [RCAR_GP_PIN(4, 17)] = { PU4, 7 }, /* SD3_DS */ 5534 { RCAR_GP_PIN(4, 14), PU4, 4 }, /* SD3_DAT5 */
5309 [RCAR_GP_PIN(4, 16)] = { PU4, 6 }, /* SD3_DAT7 */ 5535 { RCAR_GP_PIN(4, 13), PU4, 3 }, /* SD3_DAT4 */
5310 [RCAR_GP_PIN(4, 15)] = { PU4, 5 }, /* SD3_DAT6 */ 5536 { RCAR_GP_PIN(4, 12), PU4, 2 }, /* SD3_DAT3 */
5311 [RCAR_GP_PIN(4, 14)] = { PU4, 4 }, /* SD3_DAT5 */ 5537 { RCAR_GP_PIN(4, 11), PU4, 1 }, /* SD3_DAT2 */
5312 [RCAR_GP_PIN(4, 13)] = { PU4, 3 }, /* SD3_DAT4 */ 5538 { RCAR_GP_PIN(4, 10), PU4, 0 }, /* SD3_DAT1 */
5313 [RCAR_GP_PIN(4, 12)] = { PU4, 2 }, /* SD3_DAT3 */ 5539
5314 [RCAR_GP_PIN(4, 11)] = { PU4, 1 }, /* SD3_DAT2 */ 5540 { RCAR_GP_PIN(6, 24), PU5, 31 }, /* USB0_PWEN */
5315 [RCAR_GP_PIN(4, 10)] = { PU4, 0 }, /* SD3_DAT1 */ 5541 { RCAR_GP_PIN(6, 23), PU5, 30 }, /* AUDIO_CLKB_B */
5316 5542 { RCAR_GP_PIN(6, 22), PU5, 29 }, /* AUDIO_CLKA_A */
5317 [RCAR_GP_PIN(6, 24)] = { PU5, 31 }, /* USB0_PWEN */ 5543 { RCAR_GP_PIN(6, 21), PU5, 28 }, /* SSI_SDATA9_A */
5318 [RCAR_GP_PIN(6, 23)] = { PU5, 30 }, /* AUDIO_CLKB_B */ 5544 { RCAR_GP_PIN(6, 20), PU5, 27 }, /* SSI_SDATA8 */
5319 [RCAR_GP_PIN(6, 22)] = { PU5, 29 }, /* AUDIO_CLKA_A */ 5545 { RCAR_GP_PIN(6, 19), PU5, 26 }, /* SSI_SDATA7 */
5320 [RCAR_GP_PIN(6, 21)] = { PU5, 28 }, /* SSI_SDATA9_A */ 5546 { RCAR_GP_PIN(6, 18), PU5, 25 }, /* SSI_WS78 */
5321 [RCAR_GP_PIN(6, 20)] = { PU5, 27 }, /* SSI_SDATA8 */ 5547 { RCAR_GP_PIN(6, 17), PU5, 24 }, /* SSI_SCK78 */
5322 [RCAR_GP_PIN(6, 19)] = { PU5, 26 }, /* SSI_SDATA7 */ 5548 { RCAR_GP_PIN(6, 16), PU5, 23 }, /* SSI_SDATA6 */
5323 [RCAR_GP_PIN(6, 18)] = { PU5, 25 }, /* SSI_WS78 */ 5549 { RCAR_GP_PIN(6, 15), PU5, 22 }, /* SSI_WS6 */
5324 [RCAR_GP_PIN(6, 17)] = { PU5, 24 }, /* SSI_SCK78 */ 5550 { RCAR_GP_PIN(6, 14), PU5, 21 }, /* SSI_SCK6 */
5325 [RCAR_GP_PIN(6, 16)] = { PU5, 23 }, /* SSI_SDATA6 */ 5551 { RCAR_GP_PIN(6, 13), PU5, 20 }, /* SSI_SDATA5 */
5326 [RCAR_GP_PIN(6, 15)] = { PU5, 22 }, /* SSI_WS6 */ 5552 { RCAR_GP_PIN(6, 12), PU5, 19 }, /* SSI_WS5 */
5327 [RCAR_GP_PIN(6, 14)] = { PU5, 21 }, /* SSI_SCK6 */ 5553 { RCAR_GP_PIN(6, 11), PU5, 18 }, /* SSI_SCK5 */
5328 [RCAR_GP_PIN(6, 13)] = { PU5, 20 }, /* SSI_SDATA5 */ 5554 { RCAR_GP_PIN(6, 10), PU5, 17 }, /* SSI_SDATA4 */
5329 [RCAR_GP_PIN(6, 12)] = { PU5, 19 }, /* SSI_WS5 */ 5555 { RCAR_GP_PIN(6, 9), PU5, 16 }, /* SSI_WS4 */
5330 [RCAR_GP_PIN(6, 11)] = { PU5, 18 }, /* SSI_SCK5 */ 5556 { RCAR_GP_PIN(6, 8), PU5, 15 }, /* SSI_SCK4 */
5331 [RCAR_GP_PIN(6, 10)] = { PU5, 17 }, /* SSI_SDATA4 */ 5557 { RCAR_GP_PIN(6, 7), PU5, 14 }, /* SSI_SDATA3 */
5332 [RCAR_GP_PIN(6, 9)] = { PU5, 16 }, /* SSI_WS4 */ 5558 { RCAR_GP_PIN(6, 6), PU5, 13 }, /* SSI_WS34 */
5333 [RCAR_GP_PIN(6, 8)] = { PU5, 15 }, /* SSI_SCK4 */ 5559 { RCAR_GP_PIN(6, 5), PU5, 12 }, /* SSI_SCK34 */
5334 [RCAR_GP_PIN(6, 7)] = { PU5, 14 }, /* SSI_SDATA3 */ 5560 { RCAR_GP_PIN(6, 4), PU5, 11 }, /* SSI_SDATA2_A */
5335 [RCAR_GP_PIN(6, 6)] = { PU5, 13 }, /* SSI_WS34 */ 5561 { RCAR_GP_PIN(6, 3), PU5, 10 }, /* SSI_SDATA1_A */
5336 [RCAR_GP_PIN(6, 5)] = { PU5, 12 }, /* SSI_SCK34 */ 5562 { RCAR_GP_PIN(6, 2), PU5, 9 }, /* SSI_SDATA0 */
5337 [RCAR_GP_PIN(6, 4)] = { PU5, 11 }, /* SSI_SDATA2_A */ 5563 { RCAR_GP_PIN(6, 1), PU5, 8 }, /* SSI_WS01239 */
5338 [RCAR_GP_PIN(6, 3)] = { PU5, 10 }, /* SSI_SDATA1_A */ 5564 { RCAR_GP_PIN(6, 0), PU5, 7 }, /* SSI_SCK01239 */
5339 [RCAR_GP_PIN(6, 2)] = { PU5, 9 }, /* SSI_SDATA0 */ 5565 { RCAR_GP_PIN(5, 25), PU5, 5 }, /* MLB_DAT */
5340 [RCAR_GP_PIN(6, 1)] = { PU5, 8 }, /* SSI_WS01239 */ 5566 { RCAR_GP_PIN(5, 24), PU5, 4 }, /* MLB_SIG */
5341 [RCAR_GP_PIN(6, 0)] = { PU5, 7 }, /* SSI_SCK01239 */ 5567 { RCAR_GP_PIN(5, 23), PU5, 3 }, /* MLB_CLK */
5342 [RCAR_GP_PIN(5, 25)] = { PU5, 5 }, /* MLB_DAT */ 5568 { RCAR_GP_PIN(5, 22), PU5, 2 }, /* MSIOF0_RXD */
5343 [RCAR_GP_PIN(5, 24)] = { PU5, 4 }, /* MLB_SIG */ 5569 { RCAR_GP_PIN(5, 21), PU5, 1 }, /* MSIOF0_SS2 */
5344 [RCAR_GP_PIN(5, 23)] = { PU5, 3 }, /* MLB_CLK */ 5570 { RCAR_GP_PIN(5, 20), PU5, 0 }, /* MSIOF0_TXD */
5345 [RCAR_GP_PIN(5, 22)] = { PU5, 2 }, /* MSIOF0_RXD */ 5571
5346 [RCAR_GP_PIN(5, 21)] = { PU5, 1 }, /* MSIOF0_SS2 */ 5572 { RCAR_GP_PIN(6, 31), PU6, 6 }, /* USB31_OVC */
5347 [RCAR_GP_PIN(5, 20)] = { PU5, 0 }, /* MSIOF0_TXD */ 5573 { RCAR_GP_PIN(6, 30), PU6, 5 }, /* USB31_PWEN */
5348 5574 { RCAR_GP_PIN(6, 29), PU6, 4 }, /* USB30_OVC */
5349 [RCAR_GP_PIN(6, 31)] = { PU6, 6 }, /* USB31_OVC */ 5575 { RCAR_GP_PIN(6, 28), PU6, 3 }, /* USB30_PWEN */
5350 [RCAR_GP_PIN(6, 30)] = { PU6, 5 }, /* USB31_PWEN */ 5576 { RCAR_GP_PIN(6, 27), PU6, 2 }, /* USB1_OVC */
5351 [RCAR_GP_PIN(6, 29)] = { PU6, 4 }, /* USB30_OVC */ 5577 { RCAR_GP_PIN(6, 26), PU6, 1 }, /* USB1_PWEN */
5352 [RCAR_GP_PIN(6, 28)] = { PU6, 3 }, /* USB30_PWEN */ 5578 { RCAR_GP_PIN(6, 25), PU6, 0 }, /* USB0_OVC */
5353 [RCAR_GP_PIN(6, 27)] = { PU6, 2 }, /* USB1_OVC */
5354 [RCAR_GP_PIN(6, 26)] = { PU6, 1 }, /* USB1_PWEN */
5355 [RCAR_GP_PIN(6, 25)] = { PU6, 0 }, /* USB0_OVC */
5356}; 5579};
5357 5580
5358static unsigned int r8a7795_pinmux_get_bias(struct sh_pfc *pfc, 5581static unsigned int r8a7795_pinmux_get_bias(struct sh_pfc *pfc,
5359 unsigned int pin) 5582 unsigned int pin)
5360{ 5583{
5584 const struct sh_pfc_bias_info *info;
5361 u32 reg; 5585 u32 reg;
5362 u32 bit; 5586 u32 bit;
5363 5587
5364 if (WARN_ON_ONCE(!pullups[pin].reg)) 5588 info = sh_pfc_pin_to_bias_info(bias_info, ARRAY_SIZE(bias_info), pin);
5589 if (!info)
5365 return PIN_CONFIG_BIAS_DISABLE; 5590 return PIN_CONFIG_BIAS_DISABLE;
5366 5591
5367 reg = pullups[pin].reg; 5592 reg = info->reg;
5368 bit = BIT(pullups[pin].bit); 5593 bit = BIT(info->bit);
5369 5594
5370 if (sh_pfc_read_reg(pfc, PUEN + reg, 32) & bit) { 5595 if (!(sh_pfc_read_reg(pfc, PUEN + reg, 32) & bit))
5371 if (sh_pfc_read_reg(pfc, PUD + reg, 32) & bit)
5372 return PIN_CONFIG_BIAS_PULL_UP;
5373 else
5374 return PIN_CONFIG_BIAS_PULL_DOWN;
5375 } else
5376 return PIN_CONFIG_BIAS_DISABLE; 5596 return PIN_CONFIG_BIAS_DISABLE;
5597 else if (sh_pfc_read_reg(pfc, PUD + reg, 32) & bit)
5598 return PIN_CONFIG_BIAS_PULL_UP;
5599 else
5600 return PIN_CONFIG_BIAS_PULL_DOWN;
5377} 5601}
5378 5602
5379static void r8a7795_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin, 5603static void r8a7795_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
5380 unsigned int bias) 5604 unsigned int bias)
5381{ 5605{
5606 const struct sh_pfc_bias_info *info;
5382 u32 enable, updown; 5607 u32 enable, updown;
5383 u32 reg; 5608 u32 reg;
5384 u32 bit; 5609 u32 bit;
5385 5610
5386 if (WARN_ON_ONCE(!pullups[pin].reg)) 5611 info = sh_pfc_pin_to_bias_info(bias_info, ARRAY_SIZE(bias_info), pin);
5612 if (!info)
5387 return; 5613 return;
5388 5614
5389 reg = pullups[pin].reg; 5615 reg = info->reg;
5390 bit = BIT(pullups[pin].bit); 5616 bit = BIT(info->bit);
5391 5617
5392 enable = sh_pfc_read_reg(pfc, PUEN + reg, 32) & ~bit; 5618 enable = sh_pfc_read_reg(pfc, PUEN + reg, 32) & ~bit;
5393 if (bias != PIN_CONFIG_BIAS_DISABLE) 5619 if (bias != PIN_CONFIG_BIAS_DISABLE)
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7796.c b/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
index dc9b671ccf2e..7e16545a2c3c 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
@@ -122,22 +122,22 @@
122#define GPSR3_0 F_(SD0_CLK, IP7_19_16) 122#define GPSR3_0 F_(SD0_CLK, IP7_19_16)
123 123
124/* GPSR4 */ 124/* GPSR4 */
125#define GPSR4_17 F_(SD3_DS, IP11_11_8) 125#define GPSR4_17 F_(SD3_DS, IP11_7_4)
126#define GPSR4_16 F_(SD3_DAT7, IP10_7_4) 126#define GPSR4_16 F_(SD3_DAT7, IP11_3_0)
127#define GPSR4_15 F_(SD3_DAT6, IP10_3_0) 127#define GPSR4_15 F_(SD3_DAT6, IP10_31_28)
128#define GPSR4_14 F_(SD3_DAT5, IP9_31_28) 128#define GPSR4_14 F_(SD3_DAT5, IP10_27_24)
129#define GPSR4_13 F_(SD3_DAT4, IP9_27_24) 129#define GPSR4_13 F_(SD3_DAT4, IP10_23_20)
130#define GPSR4_12 F_(SD3_DAT3, IP10_19_16) 130#define GPSR4_12 F_(SD3_DAT3, IP10_19_16)
131#define GPSR4_11 F_(SD3_DAT2, IP10_15_12) 131#define GPSR4_11 F_(SD3_DAT2, IP10_15_12)
132#define GPSR4_10 F_(SD3_DAT1, IP10_11_8) 132#define GPSR4_10 F_(SD3_DAT1, IP10_11_8)
133#define GPSR4_9 F_(SD3_DAT0, IP10_7_4) 133#define GPSR4_9 F_(SD3_DAT0, IP10_7_4)
134#define GPSR4_8 F_(SD3_CMD, IP10_3_0) 134#define GPSR4_8 F_(SD3_CMD, IP10_3_0)
135#define GPSR4_7 F_(SD3_CLK, IP9_31_28) 135#define GPSR4_7 F_(SD3_CLK, IP9_31_28)
136#define GPSR4_6 F_(SD2_DS, IP9_23_20) 136#define GPSR4_6 F_(SD2_DS, IP9_27_24)
137#define GPSR4_5 F_(SD2_DAT3, IP9_19_16) 137#define GPSR4_5 F_(SD2_DAT3, IP9_23_20)
138#define GPSR4_4 F_(SD2_DAT2, IP9_15_12) 138#define GPSR4_4 F_(SD2_DAT2, IP9_19_16)
139#define GPSR4_3 F_(SD2_DAT1, IP9_11_8) 139#define GPSR4_3 F_(SD2_DAT1, IP9_15_12)
140#define GPSR4_2 F_(SD2_DAT0, IP9_7_4) 140#define GPSR4_2 F_(SD2_DAT0, IP9_11_8)
141#define GPSR4_1 F_(SD2_CMD, IP9_7_4) 141#define GPSR4_1 F_(SD2_CMD, IP9_7_4)
142#define GPSR4_0 F_(SD2_CLK, IP9_3_0) 142#define GPSR4_0 F_(SD2_CLK, IP9_3_0)
143 143
@@ -1490,6 +1490,418 @@ static const struct sh_pfc_pin pinmux_pins[] = {
1490 PINMUX_GPIO_GP_ALL(), 1490 PINMUX_GPIO_GP_ALL(),
1491}; 1491};
1492 1492
1493/* - EtherAVB --------------------------------------------------------------- */
1494static const unsigned int avb_link_pins[] = {
1495 /* AVB_LINK */
1496 RCAR_GP_PIN(2, 12),
1497};
1498static const unsigned int avb_link_mux[] = {
1499 AVB_LINK_MARK,
1500};
1501static const unsigned int avb_magic_pins[] = {
1502 /* AVB_MAGIC_ */
1503 RCAR_GP_PIN(2, 10),
1504};
1505static const unsigned int avb_magic_mux[] = {
1506 AVB_MAGIC_MARK,
1507};
1508static const unsigned int avb_phy_int_pins[] = {
1509 /* AVB_PHY_INT */
1510 RCAR_GP_PIN(2, 11),
1511};
1512static const unsigned int avb_phy_int_mux[] = {
1513 AVB_PHY_INT_MARK,
1514};
1515static const unsigned int avb_mdc_pins[] = {
1516 /* AVB_MDC */
1517 RCAR_GP_PIN(2, 9),
1518};
1519static const unsigned int avb_mdc_mux[] = {
1520 AVB_MDC_MARK,
1521};
1522static const unsigned int avb_avtp_pps_pins[] = {
1523 /* AVB_AVTP_PPS */
1524 RCAR_GP_PIN(2, 6),
1525};
1526static const unsigned int avb_avtp_pps_mux[] = {
1527 AVB_AVTP_PPS_MARK,
1528};
1529static const unsigned int avb_avtp_match_a_pins[] = {
1530 /* AVB_AVTP_MATCH_A */
1531 RCAR_GP_PIN(2, 13),
1532};
1533static const unsigned int avb_avtp_match_a_mux[] = {
1534 AVB_AVTP_MATCH_A_MARK,
1535};
1536static const unsigned int avb_avtp_capture_a_pins[] = {
1537 /* AVB_AVTP_CAPTURE_A */
1538 RCAR_GP_PIN(2, 14),
1539};
1540static const unsigned int avb_avtp_capture_a_mux[] = {
1541 AVB_AVTP_CAPTURE_A_MARK,
1542};
1543static const unsigned int avb_avtp_match_b_pins[] = {
1544 /* AVB_AVTP_MATCH_B */
1545 RCAR_GP_PIN(1, 8),
1546};
1547static const unsigned int avb_avtp_match_b_mux[] = {
1548 AVB_AVTP_MATCH_B_MARK,
1549};
1550static const unsigned int avb_avtp_capture_b_pins[] = {
1551 /* AVB_AVTP_CAPTURE_B */
1552 RCAR_GP_PIN(1, 11),
1553};
1554static const unsigned int avb_avtp_capture_b_mux[] = {
1555 AVB_AVTP_CAPTURE_B_MARK,
1556};
1557
1558/* - DRIF0 --------------------------------------------------------------- */
1559static const unsigned int drif0_ctrl_a_pins[] = {
1560 /* CLK, SYNC */
1561 RCAR_GP_PIN(6, 8), RCAR_GP_PIN(6, 9),
1562};
1563static const unsigned int drif0_ctrl_a_mux[] = {
1564 RIF0_CLK_A_MARK, RIF0_SYNC_A_MARK,
1565};
1566static const unsigned int drif0_data0_a_pins[] = {
1567 /* D0 */
1568 RCAR_GP_PIN(6, 10),
1569};
1570static const unsigned int drif0_data0_a_mux[] = {
1571 RIF0_D0_A_MARK,
1572};
1573static const unsigned int drif0_data1_a_pins[] = {
1574 /* D1 */
1575 RCAR_GP_PIN(6, 7),
1576};
1577static const unsigned int drif0_data1_a_mux[] = {
1578 RIF0_D1_A_MARK,
1579};
1580static const unsigned int drif0_ctrl_b_pins[] = {
1581 /* CLK, SYNC */
1582 RCAR_GP_PIN(5, 0), RCAR_GP_PIN(5, 4),
1583};
1584static const unsigned int drif0_ctrl_b_mux[] = {
1585 RIF0_CLK_B_MARK, RIF0_SYNC_B_MARK,
1586};
1587static const unsigned int drif0_data0_b_pins[] = {
1588 /* D0 */
1589 RCAR_GP_PIN(5, 1),
1590};
1591static const unsigned int drif0_data0_b_mux[] = {
1592 RIF0_D0_B_MARK,
1593};
1594static const unsigned int drif0_data1_b_pins[] = {
1595 /* D1 */
1596 RCAR_GP_PIN(5, 2),
1597};
1598static const unsigned int drif0_data1_b_mux[] = {
1599 RIF0_D1_B_MARK,
1600};
1601static const unsigned int drif0_ctrl_c_pins[] = {
1602 /* CLK, SYNC */
1603 RCAR_GP_PIN(5, 12), RCAR_GP_PIN(5, 15),
1604};
1605static const unsigned int drif0_ctrl_c_mux[] = {
1606 RIF0_CLK_C_MARK, RIF0_SYNC_C_MARK,
1607};
1608static const unsigned int drif0_data0_c_pins[] = {
1609 /* D0 */
1610 RCAR_GP_PIN(5, 13),
1611};
1612static const unsigned int drif0_data0_c_mux[] = {
1613 RIF0_D0_C_MARK,
1614};
1615static const unsigned int drif0_data1_c_pins[] = {
1616 /* D1 */
1617 RCAR_GP_PIN(5, 14),
1618};
1619static const unsigned int drif0_data1_c_mux[] = {
1620 RIF0_D1_C_MARK,
1621};
1622/* - DRIF1 --------------------------------------------------------------- */
1623static const unsigned int drif1_ctrl_a_pins[] = {
1624 /* CLK, SYNC */
1625 RCAR_GP_PIN(6, 17), RCAR_GP_PIN(6, 18),
1626};
1627static const unsigned int drif1_ctrl_a_mux[] = {
1628 RIF1_CLK_A_MARK, RIF1_SYNC_A_MARK,
1629};
1630static const unsigned int drif1_data0_a_pins[] = {
1631 /* D0 */
1632 RCAR_GP_PIN(6, 19),
1633};
1634static const unsigned int drif1_data0_a_mux[] = {
1635 RIF1_D0_A_MARK,
1636};
1637static const unsigned int drif1_data1_a_pins[] = {
1638 /* D1 */
1639 RCAR_GP_PIN(6, 20),
1640};
1641static const unsigned int drif1_data1_a_mux[] = {
1642 RIF1_D1_A_MARK,
1643};
1644static const unsigned int drif1_ctrl_b_pins[] = {
1645 /* CLK, SYNC */
1646 RCAR_GP_PIN(5, 9), RCAR_GP_PIN(5, 3),
1647};
1648static const unsigned int drif1_ctrl_b_mux[] = {
1649 RIF1_CLK_B_MARK, RIF1_SYNC_B_MARK,
1650};
1651static const unsigned int drif1_data0_b_pins[] = {
1652 /* D0 */
1653 RCAR_GP_PIN(5, 7),
1654};
1655static const unsigned int drif1_data0_b_mux[] = {
1656 RIF1_D0_B_MARK,
1657};
1658static const unsigned int drif1_data1_b_pins[] = {
1659 /* D1 */
1660 RCAR_GP_PIN(5, 8),
1661};
1662static const unsigned int drif1_data1_b_mux[] = {
1663 RIF1_D1_B_MARK,
1664};
1665static const unsigned int drif1_ctrl_c_pins[] = {
1666 /* CLK, SYNC */
1667 RCAR_GP_PIN(5, 5), RCAR_GP_PIN(5, 11),
1668};
1669static const unsigned int drif1_ctrl_c_mux[] = {
1670 RIF1_CLK_C_MARK, RIF1_SYNC_C_MARK,
1671};
1672static const unsigned int drif1_data0_c_pins[] = {
1673 /* D0 */
1674 RCAR_GP_PIN(5, 6),
1675};
1676static const unsigned int drif1_data0_c_mux[] = {
1677 RIF1_D0_C_MARK,
1678};
1679static const unsigned int drif1_data1_c_pins[] = {
1680 /* D1 */
1681 RCAR_GP_PIN(5, 10),
1682};
1683static const unsigned int drif1_data1_c_mux[] = {
1684 RIF1_D1_C_MARK,
1685};
1686/* - DRIF2 --------------------------------------------------------------- */
1687static const unsigned int drif2_ctrl_a_pins[] = {
1688 /* CLK, SYNC */
1689 RCAR_GP_PIN(6, 8), RCAR_GP_PIN(6, 9),
1690};
1691static const unsigned int drif2_ctrl_a_mux[] = {
1692 RIF2_CLK_A_MARK, RIF2_SYNC_A_MARK,
1693};
1694static const unsigned int drif2_data0_a_pins[] = {
1695 /* D0 */
1696 RCAR_GP_PIN(6, 7),
1697};
1698static const unsigned int drif2_data0_a_mux[] = {
1699 RIF2_D0_A_MARK,
1700};
1701static const unsigned int drif2_data1_a_pins[] = {
1702 /* D1 */
1703 RCAR_GP_PIN(6, 10),
1704};
1705static const unsigned int drif2_data1_a_mux[] = {
1706 RIF2_D1_A_MARK,
1707};
1708static const unsigned int drif2_ctrl_b_pins[] = {
1709 /* CLK, SYNC */
1710 RCAR_GP_PIN(6, 26), RCAR_GP_PIN(6, 27),
1711};
1712static const unsigned int drif2_ctrl_b_mux[] = {
1713 RIF2_CLK_B_MARK, RIF2_SYNC_B_MARK,
1714};
1715static const unsigned int drif2_data0_b_pins[] = {
1716 /* D0 */
1717 RCAR_GP_PIN(6, 30),
1718};
1719static const unsigned int drif2_data0_b_mux[] = {
1720 RIF2_D0_B_MARK,
1721};
1722static const unsigned int drif2_data1_b_pins[] = {
1723 /* D1 */
1724 RCAR_GP_PIN(6, 31),
1725};
1726static const unsigned int drif2_data1_b_mux[] = {
1727 RIF2_D1_B_MARK,
1728};
1729/* - DRIF3 --------------------------------------------------------------- */
1730static const unsigned int drif3_ctrl_a_pins[] = {
1731 /* CLK, SYNC */
1732 RCAR_GP_PIN(6, 17), RCAR_GP_PIN(6, 18),
1733};
1734static const unsigned int drif3_ctrl_a_mux[] = {
1735 RIF3_CLK_A_MARK, RIF3_SYNC_A_MARK,
1736};
1737static const unsigned int drif3_data0_a_pins[] = {
1738 /* D0 */
1739 RCAR_GP_PIN(6, 19),
1740};
1741static const unsigned int drif3_data0_a_mux[] = {
1742 RIF3_D0_A_MARK,
1743};
1744static const unsigned int drif3_data1_a_pins[] = {
1745 /* D1 */
1746 RCAR_GP_PIN(6, 20),
1747};
1748static const unsigned int drif3_data1_a_mux[] = {
1749 RIF3_D1_A_MARK,
1750};
1751static const unsigned int drif3_ctrl_b_pins[] = {
1752 /* CLK, SYNC */
1753 RCAR_GP_PIN(6, 24), RCAR_GP_PIN(6, 25),
1754};
1755static const unsigned int drif3_ctrl_b_mux[] = {
1756 RIF3_CLK_B_MARK, RIF3_SYNC_B_MARK,
1757};
1758static const unsigned int drif3_data0_b_pins[] = {
1759 /* D0 */
1760 RCAR_GP_PIN(6, 28),
1761};
1762static const unsigned int drif3_data0_b_mux[] = {
1763 RIF3_D0_B_MARK,
1764};
1765static const unsigned int drif3_data1_b_pins[] = {
1766 /* D1 */
1767 RCAR_GP_PIN(6, 29),
1768};
1769static const unsigned int drif3_data1_b_mux[] = {
1770 RIF3_D1_B_MARK,
1771};
1772
1773/* - DU --------------------------------------------------------------------- */
1774static const unsigned int du_rgb666_pins[] = {
1775 /* R[7:2], G[7:2], B[7:2] */
1776 RCAR_GP_PIN(0, 15), RCAR_GP_PIN(0, 14), RCAR_GP_PIN(0, 13),
1777 RCAR_GP_PIN(0, 12), RCAR_GP_PIN(0, 11), RCAR_GP_PIN(0, 10),
1778 RCAR_GP_PIN(1, 15), RCAR_GP_PIN(1, 14), RCAR_GP_PIN(1, 13),
1779 RCAR_GP_PIN(1, 12), RCAR_GP_PIN(1, 19), RCAR_GP_PIN(1, 18),
1780 RCAR_GP_PIN(1, 7), RCAR_GP_PIN(1, 6), RCAR_GP_PIN(1, 5),
1781 RCAR_GP_PIN(1, 4), RCAR_GP_PIN(1, 3), RCAR_GP_PIN(1, 2),
1782};
1783static const unsigned int du_rgb666_mux[] = {
1784 DU_DR7_MARK, DU_DR6_MARK, DU_DR5_MARK, DU_DR4_MARK,
1785 DU_DR3_MARK, DU_DR2_MARK,
1786 DU_DG7_MARK, DU_DG6_MARK, DU_DG5_MARK, DU_DG4_MARK,
1787 DU_DG3_MARK, DU_DG2_MARK,
1788 DU_DB7_MARK, DU_DB6_MARK, DU_DB5_MARK, DU_DB4_MARK,
1789 DU_DB3_MARK, DU_DB2_MARK,
1790};
1791static const unsigned int du_rgb888_pins[] = {
1792 /* R[7:0], G[7:0], B[7:0] */
1793 RCAR_GP_PIN(0, 15), RCAR_GP_PIN(0, 14), RCAR_GP_PIN(0, 13),
1794 RCAR_GP_PIN(0, 12), RCAR_GP_PIN(0, 11), RCAR_GP_PIN(0, 10),
1795 RCAR_GP_PIN(0, 9), RCAR_GP_PIN(0, 8),
1796 RCAR_GP_PIN(1, 15), RCAR_GP_PIN(1, 14), RCAR_GP_PIN(1, 13),
1797 RCAR_GP_PIN(1, 12), RCAR_GP_PIN(1, 19), RCAR_GP_PIN(1, 18),
1798 RCAR_GP_PIN(1, 17), RCAR_GP_PIN(1, 16),
1799 RCAR_GP_PIN(1, 7), RCAR_GP_PIN(1, 6), RCAR_GP_PIN(1, 5),
1800 RCAR_GP_PIN(1, 4), RCAR_GP_PIN(1, 3), RCAR_GP_PIN(1, 2),
1801 RCAR_GP_PIN(1, 1), RCAR_GP_PIN(1, 0),
1802};
1803static const unsigned int du_rgb888_mux[] = {
1804 DU_DR7_MARK, DU_DR6_MARK, DU_DR5_MARK, DU_DR4_MARK,
1805 DU_DR3_MARK, DU_DR2_MARK, DU_DR1_MARK, DU_DR0_MARK,
1806 DU_DG7_MARK, DU_DG6_MARK, DU_DG5_MARK, DU_DG4_MARK,
1807 DU_DG3_MARK, DU_DG2_MARK, DU_DG1_MARK, DU_DG0_MARK,
1808 DU_DB7_MARK, DU_DB6_MARK, DU_DB5_MARK, DU_DB4_MARK,
1809 DU_DB3_MARK, DU_DB2_MARK, DU_DB1_MARK, DU_DB0_MARK,
1810};
1811static const unsigned int du_clk_out_0_pins[] = {
1812 /* CLKOUT */
1813 RCAR_GP_PIN(1, 27),
1814};
1815static const unsigned int du_clk_out_0_mux[] = {
1816 DU_DOTCLKOUT0_MARK
1817};
1818static const unsigned int du_clk_out_1_pins[] = {
1819 /* CLKOUT */
1820 RCAR_GP_PIN(2, 3),
1821};
1822static const unsigned int du_clk_out_1_mux[] = {
1823 DU_DOTCLKOUT1_MARK
1824};
1825static const unsigned int du_sync_pins[] = {
1826 /* EXVSYNC/VSYNC, EXHSYNC/HSYNC */
1827 RCAR_GP_PIN(2, 5), RCAR_GP_PIN(2, 4),
1828};
1829static const unsigned int du_sync_mux[] = {
1830 DU_EXVSYNC_DU_VSYNC_MARK, DU_EXHSYNC_DU_HSYNC_MARK
1831};
1832static const unsigned int du_oddf_pins[] = {
1833 /* EXDISP/EXODDF/EXCDE */
1834 RCAR_GP_PIN(2, 2),
1835};
1836static const unsigned int du_oddf_mux[] = {
1837 DU_EXODDF_DU_ODDF_DISP_CDE_MARK,
1838};
1839static const unsigned int du_cde_pins[] = {
1840 /* CDE */
1841 RCAR_GP_PIN(2, 0),
1842};
1843static const unsigned int du_cde_mux[] = {
1844 DU_CDE_MARK,
1845};
1846static const unsigned int du_disp_pins[] = {
1847 /* DISP */
1848 RCAR_GP_PIN(2, 1),
1849};
1850static const unsigned int du_disp_mux[] = {
1851 DU_DISP_MARK,
1852};
1853
1854/* - I2C -------------------------------------------------------------------- */
1855static const unsigned int i2c1_a_pins[] = {
1856 /* SDA, SCL */
1857 RCAR_GP_PIN(5, 11), RCAR_GP_PIN(5, 10),
1858};
1859static const unsigned int i2c1_a_mux[] = {
1860 SDA1_A_MARK, SCL1_A_MARK,
1861};
1862static const unsigned int i2c1_b_pins[] = {
1863 /* SDA, SCL */
1864 RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 23),
1865};
1866static const unsigned int i2c1_b_mux[] = {
1867 SDA1_B_MARK, SCL1_B_MARK,
1868};
1869static const unsigned int i2c2_a_pins[] = {
1870 /* SDA, SCL */
1871 RCAR_GP_PIN(5, 0), RCAR_GP_PIN(5, 4),
1872};
1873static const unsigned int i2c2_a_mux[] = {
1874 SDA2_A_MARK, SCL2_A_MARK,
1875};
1876static const unsigned int i2c2_b_pins[] = {
1877 /* SDA, SCL */
1878 RCAR_GP_PIN(3, 13), RCAR_GP_PIN(3, 12),
1879};
1880static const unsigned int i2c2_b_mux[] = {
1881 SDA2_B_MARK, SCL2_B_MARK,
1882};
1883static const unsigned int i2c6_a_pins[] = {
1884 /* SDA, SCL */
1885 RCAR_GP_PIN(1, 8), RCAR_GP_PIN(1, 11),
1886};
1887static const unsigned int i2c6_a_mux[] = {
1888 SDA6_A_MARK, SCL6_A_MARK,
1889};
1890static const unsigned int i2c6_b_pins[] = {
1891 /* SDA, SCL */
1892 RCAR_GP_PIN(1, 26), RCAR_GP_PIN(1, 25),
1893};
1894static const unsigned int i2c6_b_mux[] = {
1895 SDA6_B_MARK, SCL6_B_MARK,
1896};
1897static const unsigned int i2c6_c_pins[] = {
1898 /* SDA, SCL */
1899 RCAR_GP_PIN(0, 15), RCAR_GP_PIN(0, 14),
1900};
1901static const unsigned int i2c6_c_mux[] = {
1902 SDA6_C_MARK, SCL6_C_MARK,
1903};
1904
1493/* - SCIF0 ------------------------------------------------------------------ */ 1905/* - SCIF0 ------------------------------------------------------------------ */
1494static const unsigned int scif0_data_pins[] = { 1906static const unsigned int scif0_data_pins[] = {
1495 /* RX, TX */ 1907 /* RX, TX */
@@ -1912,6 +2324,60 @@ static const unsigned int sdhi3_ds_mux[] = {
1912}; 2324};
1913 2325
1914static const struct sh_pfc_pin_group pinmux_groups[] = { 2326static const struct sh_pfc_pin_group pinmux_groups[] = {
2327 SH_PFC_PIN_GROUP(avb_link),
2328 SH_PFC_PIN_GROUP(avb_magic),
2329 SH_PFC_PIN_GROUP(avb_phy_int),
2330 SH_PFC_PIN_GROUP(avb_mdc),
2331 SH_PFC_PIN_GROUP(avb_avtp_pps),
2332 SH_PFC_PIN_GROUP(avb_avtp_match_a),
2333 SH_PFC_PIN_GROUP(avb_avtp_capture_a),
2334 SH_PFC_PIN_GROUP(avb_avtp_match_b),
2335 SH_PFC_PIN_GROUP(avb_avtp_capture_b),
2336 SH_PFC_PIN_GROUP(drif0_ctrl_a),
2337 SH_PFC_PIN_GROUP(drif0_data0_a),
2338 SH_PFC_PIN_GROUP(drif0_data1_a),
2339 SH_PFC_PIN_GROUP(drif0_ctrl_b),
2340 SH_PFC_PIN_GROUP(drif0_data0_b),
2341 SH_PFC_PIN_GROUP(drif0_data1_b),
2342 SH_PFC_PIN_GROUP(drif0_ctrl_c),
2343 SH_PFC_PIN_GROUP(drif0_data0_c),
2344 SH_PFC_PIN_GROUP(drif0_data1_c),
2345 SH_PFC_PIN_GROUP(drif1_ctrl_a),
2346 SH_PFC_PIN_GROUP(drif1_data0_a),
2347 SH_PFC_PIN_GROUP(drif1_data1_a),
2348 SH_PFC_PIN_GROUP(drif1_ctrl_b),
2349 SH_PFC_PIN_GROUP(drif1_data0_b),
2350 SH_PFC_PIN_GROUP(drif1_data1_b),
2351 SH_PFC_PIN_GROUP(drif1_ctrl_c),
2352 SH_PFC_PIN_GROUP(drif1_data0_c),
2353 SH_PFC_PIN_GROUP(drif1_data1_c),
2354 SH_PFC_PIN_GROUP(drif2_ctrl_a),
2355 SH_PFC_PIN_GROUP(drif2_data0_a),
2356 SH_PFC_PIN_GROUP(drif2_data1_a),
2357 SH_PFC_PIN_GROUP(drif2_ctrl_b),
2358 SH_PFC_PIN_GROUP(drif2_data0_b),
2359 SH_PFC_PIN_GROUP(drif2_data1_b),
2360 SH_PFC_PIN_GROUP(drif3_ctrl_a),
2361 SH_PFC_PIN_GROUP(drif3_data0_a),
2362 SH_PFC_PIN_GROUP(drif3_data1_a),
2363 SH_PFC_PIN_GROUP(drif3_ctrl_b),
2364 SH_PFC_PIN_GROUP(drif3_data0_b),
2365 SH_PFC_PIN_GROUP(drif3_data1_b),
2366 SH_PFC_PIN_GROUP(du_rgb666),
2367 SH_PFC_PIN_GROUP(du_rgb888),
2368 SH_PFC_PIN_GROUP(du_clk_out_0),
2369 SH_PFC_PIN_GROUP(du_clk_out_1),
2370 SH_PFC_PIN_GROUP(du_sync),
2371 SH_PFC_PIN_GROUP(du_oddf),
2372 SH_PFC_PIN_GROUP(du_cde),
2373 SH_PFC_PIN_GROUP(du_disp),
2374 SH_PFC_PIN_GROUP(i2c1_a),
2375 SH_PFC_PIN_GROUP(i2c1_b),
2376 SH_PFC_PIN_GROUP(i2c2_a),
2377 SH_PFC_PIN_GROUP(i2c2_b),
2378 SH_PFC_PIN_GROUP(i2c6_a),
2379 SH_PFC_PIN_GROUP(i2c6_b),
2380 SH_PFC_PIN_GROUP(i2c6_c),
1915 SH_PFC_PIN_GROUP(scif0_data), 2381 SH_PFC_PIN_GROUP(scif0_data),
1916 SH_PFC_PIN_GROUP(scif0_clk), 2382 SH_PFC_PIN_GROUP(scif0_clk),
1917 SH_PFC_PIN_GROUP(scif0_ctrl), 2383 SH_PFC_PIN_GROUP(scif0_ctrl),
@@ -1969,6 +2435,87 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
1969 SH_PFC_PIN_GROUP(sdhi3_ds), 2435 SH_PFC_PIN_GROUP(sdhi3_ds),
1970}; 2436};
1971 2437
2438static const char * const avb_groups[] = {
2439 "avb_link",
2440 "avb_magic",
2441 "avb_phy_int",
2442 "avb_mdc",
2443 "avb_avtp_pps",
2444 "avb_avtp_match_a",
2445 "avb_avtp_capture_a",
2446 "avb_avtp_match_b",
2447 "avb_avtp_capture_b",
2448};
2449
2450static const char * const drif0_groups[] = {
2451 "drif0_ctrl_a",
2452 "drif0_data0_a",
2453 "drif0_data1_a",
2454 "drif0_ctrl_b",
2455 "drif0_data0_b",
2456 "drif0_data1_b",
2457 "drif0_ctrl_c",
2458 "drif0_data0_c",
2459 "drif0_data1_c",
2460};
2461
2462static const char * const drif1_groups[] = {
2463 "drif1_ctrl_a",
2464 "drif1_data0_a",
2465 "drif1_data1_a",
2466 "drif1_ctrl_b",
2467 "drif1_data0_b",
2468 "drif1_data1_b",
2469 "drif1_ctrl_c",
2470 "drif1_data0_c",
2471 "drif1_data1_c",
2472};
2473
2474static const char * const drif2_groups[] = {
2475 "drif2_ctrl_a",
2476 "drif2_data0_a",
2477 "drif2_data1_a",
2478 "drif2_ctrl_b",
2479 "drif2_data0_b",
2480 "drif2_data1_b",
2481};
2482
2483static const char * const drif3_groups[] = {
2484 "drif3_ctrl_a",
2485 "drif3_data0_a",
2486 "drif3_data1_a",
2487 "drif3_ctrl_b",
2488 "drif3_data0_b",
2489 "drif3_data1_b",
2490};
2491
2492static const char * const du_groups[] = {
2493 "du_rgb666",
2494 "du_rgb888",
2495 "du_clk_out_0",
2496 "du_clk_out_1",
2497 "du_sync",
2498 "du_oddf",
2499 "du_cde",
2500 "du_disp",
2501};
2502
2503static const char * const i2c1_groups[] = {
2504 "i2c1_a",
2505 "i2c1_b",
2506};
2507
2508static const char * const i2c2_groups[] = {
2509 "i2c2_a",
2510 "i2c2_b",
2511};
2512
2513static const char * const i2c6_groups[] = {
2514 "i2c6_a",
2515 "i2c6_b",
2516 "i2c6_c",
2517};
2518
1972static const char * const scif0_groups[] = { 2519static const char * const scif0_groups[] = {
1973 "scif0_data", 2520 "scif0_data",
1974 "scif0_clk", 2521 "scif0_clk",
@@ -2058,6 +2605,15 @@ static const char * const sdhi3_groups[] = {
2058}; 2605};
2059 2606
2060static const struct sh_pfc_function pinmux_functions[] = { 2607static const struct sh_pfc_function pinmux_functions[] = {
2608 SH_PFC_FUNCTION(avb),
2609 SH_PFC_FUNCTION(drif0),
2610 SH_PFC_FUNCTION(drif1),
2611 SH_PFC_FUNCTION(drif2),
2612 SH_PFC_FUNCTION(drif3),
2613 SH_PFC_FUNCTION(du),
2614 SH_PFC_FUNCTION(i2c1),
2615 SH_PFC_FUNCTION(i2c2),
2616 SH_PFC_FUNCTION(i2c6),
2061 SH_PFC_FUNCTION(scif0), 2617 SH_PFC_FUNCTION(scif0),
2062 SH_PFC_FUNCTION(scif1), 2618 SH_PFC_FUNCTION(scif1),
2063 SH_PFC_FUNCTION(scif2), 2619 SH_PFC_FUNCTION(scif2),
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index c5772584594c..fcacfa73ef6e 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -570,7 +570,8 @@ static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin,
570 570
571 switch (param) { 571 switch (param) {
572 case PIN_CONFIG_BIAS_DISABLE: 572 case PIN_CONFIG_BIAS_DISABLE:
573 return true; 573 return pin->configs &
574 (SH_PFC_PIN_CFG_PULL_UP | SH_PFC_PIN_CFG_PULL_DOWN);
574 575
575 case PIN_CONFIG_BIAS_PULL_UP: 576 case PIN_CONFIG_BIAS_PULL_UP:
576 return pin->configs & SH_PFC_PIN_CFG_PULL_UP; 577 return pin->configs & SH_PFC_PIN_CFG_PULL_UP;
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h
index 2345421103db..e42cc7a8d10e 100644
--- a/drivers/pinctrl/sh-pfc/sh_pfc.h
+++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
@@ -189,6 +189,12 @@ struct sh_pfc_window {
189 unsigned long size; 189 unsigned long size;
190}; 190};
191 191
192struct sh_pfc_bias_info {
193 u16 pin;
194 u16 reg : 11;
195 u16 bit : 5;
196};
197
192struct sh_pfc_pin_range; 198struct sh_pfc_pin_range;
193 199
194struct sh_pfc { 200struct sh_pfc {
@@ -540,6 +546,14 @@ extern const struct sh_pfc_soc_info shx3_pinmux_info;
540 .configs = SH_PFC_PIN_CFG_NO_GPIO, \ 546 .configs = SH_PFC_PIN_CFG_NO_GPIO, \
541 } 547 }
542 548
549/* SH_PFC_PIN_NAMED_CFG - Expand to a sh_pfc_pin entry with the given name */
550#define SH_PFC_PIN_NAMED_CFG(row, col, _name, cfgs) \
551 { \
552 .pin = PIN_NUMBER(row, col), \
553 .name = __stringify(PIN_##_name), \
554 .configs = SH_PFC_PIN_CFG_NO_GPIO | cfgs, \
555 }
556
543/* PINMUX_DATA_ALL - Expand to a list of PORT_name_DATA, PORT_name_FN0, 557/* PINMUX_DATA_ALL - Expand to a list of PORT_name_DATA, PORT_name_FN0,
544 * PORT_name_OUT, PORT_name_IN marks 558 * PORT_name_OUT, PORT_name_IN marks
545 */ 559 */
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32f429.c b/drivers/pinctrl/stm32/pinctrl-stm32f429.c
index e9b15dc0654b..990b867b9625 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32f429.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32f429.c
@@ -1584,8 +1584,4 @@ static struct platform_driver stm32f429_pinctrl_driver = {
1584 }, 1584 },
1585}; 1585};
1586 1586
1587static int __init stm32f429_pinctrl_init(void) 1587builtin_platform_driver(stm32f429_pinctrl_driver);
1588{
1589 return platform_driver_register(&stm32f429_pinctrl_driver);
1590}
1591device_initcall(stm32f429_pinctrl_init);
diff --git a/drivers/pinctrl/sunxi/pinctrl-gr8.c b/drivers/pinctrl/sunxi/pinctrl-gr8.c
index 2904d2b7378b..2f232c3a0579 100644
--- a/drivers/pinctrl/sunxi/pinctrl-gr8.c
+++ b/drivers/pinctrl/sunxi/pinctrl-gr8.c
@@ -12,7 +12,7 @@
12 * warranty of any kind, whether express or implied. 12 * warranty of any kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_device.h> 18#include <linux/of_device.h>
@@ -525,7 +525,6 @@ static const struct of_device_id sun5i_gr8_pinctrl_match[] = {
525 { .compatible = "nextthing,gr8-pinctrl", }, 525 { .compatible = "nextthing,gr8-pinctrl", },
526 {} 526 {}
527}; 527};
528MODULE_DEVICE_TABLE(of, sun5i_gr8_pinctrl_match);
529 528
530static struct platform_driver sun5i_gr8_pinctrl_driver = { 529static struct platform_driver sun5i_gr8_pinctrl_driver = {
531 .probe = sun5i_gr8_pinctrl_probe, 530 .probe = sun5i_gr8_pinctrl_probe,
@@ -534,8 +533,4 @@ static struct platform_driver sun5i_gr8_pinctrl_driver = {
534 .of_match_table = sun5i_gr8_pinctrl_match, 533 .of_match_table = sun5i_gr8_pinctrl_match,
535 }, 534 },
536}; 535};
537module_platform_driver(sun5i_gr8_pinctrl_driver); 536builtin_platform_driver(sun5i_gr8_pinctrl_driver);
538
539MODULE_AUTHOR("Mylene Josserand <mylene.josserand@free-electrons.com");
540MODULE_DESCRIPTION("NextThing GR8 pinctrl driver");
541MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
index 862a096c5dba..fb30b86a97ee 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -1035,7 +1035,6 @@ static const struct of_device_id sun4i_a10_pinctrl_match[] = {
1035 { .compatible = "allwinner,sun4i-a10-pinctrl", }, 1035 { .compatible = "allwinner,sun4i-a10-pinctrl", },
1036 {} 1036 {}
1037}; 1037};
1038MODULE_DEVICE_TABLE(of, sun4i_a10_pinctrl_match);
1039 1038
1040static struct platform_driver sun4i_a10_pinctrl_driver = { 1039static struct platform_driver sun4i_a10_pinctrl_driver = {
1041 .probe = sun4i_a10_pinctrl_probe, 1040 .probe = sun4i_a10_pinctrl_probe,
@@ -1044,8 +1043,4 @@ static struct platform_driver sun4i_a10_pinctrl_driver = {
1044 .of_match_table = sun4i_a10_pinctrl_match, 1043 .of_match_table = sun4i_a10_pinctrl_match,
1045 }, 1044 },
1046}; 1045};
1047module_platform_driver(sun4i_a10_pinctrl_driver); 1046builtin_platform_driver(sun4i_a10_pinctrl_driver);
1048
1049MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
1050MODULE_DESCRIPTION("Allwinner A10 pinctrl driver");
1051MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun5i-a10s.c b/drivers/pinctrl/sunxi/pinctrl-sun5i-a10s.c
index f9a3f8f446f7..a5b57fdff9e1 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun5i-a10s.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun5i-a10s.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -674,7 +674,6 @@ static const struct of_device_id sun5i_a10s_pinctrl_match[] = {
674 { .compatible = "allwinner,sun5i-a10s-pinctrl", }, 674 { .compatible = "allwinner,sun5i-a10s-pinctrl", },
675 {} 675 {}
676}; 676};
677MODULE_DEVICE_TABLE(of, sun5i_a10s_pinctrl_match);
678 677
679static struct platform_driver sun5i_a10s_pinctrl_driver = { 678static struct platform_driver sun5i_a10s_pinctrl_driver = {
680 .probe = sun5i_a10s_pinctrl_probe, 679 .probe = sun5i_a10s_pinctrl_probe,
@@ -683,8 +682,4 @@ static struct platform_driver sun5i_a10s_pinctrl_driver = {
683 .of_match_table = sun5i_a10s_pinctrl_match, 682 .of_match_table = sun5i_a10s_pinctrl_match,
684 }, 683 },
685}; 684};
686module_platform_driver(sun5i_a10s_pinctrl_driver); 685builtin_platform_driver(sun5i_a10s_pinctrl_driver);
687
688MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
689MODULE_DESCRIPTION("Allwinner A10s pinctrl driver");
690MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun5i-a13.c b/drivers/pinctrl/sunxi/pinctrl-sun5i-a13.c
index 2bb07b38834f..8575f3f6d3dd 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun5i-a13.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun5i-a13.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -392,7 +392,6 @@ static const struct of_device_id sun5i_a13_pinctrl_match[] = {
392 { .compatible = "allwinner,sun5i-a13-pinctrl", }, 392 { .compatible = "allwinner,sun5i-a13-pinctrl", },
393 {} 393 {}
394}; 394};
395MODULE_DEVICE_TABLE(of, sun5i_a13_pinctrl_match);
396 395
397static struct platform_driver sun5i_a13_pinctrl_driver = { 396static struct platform_driver sun5i_a13_pinctrl_driver = {
398 .probe = sun5i_a13_pinctrl_probe, 397 .probe = sun5i_a13_pinctrl_probe,
@@ -401,8 +400,4 @@ static struct platform_driver sun5i_a13_pinctrl_driver = {
401 .of_match_table = sun5i_a13_pinctrl_match, 400 .of_match_table = sun5i_a13_pinctrl_match,
402 }, 401 },
403}; 402};
404module_platform_driver(sun5i_a13_pinctrl_driver); 403builtin_platform_driver(sun5i_a13_pinctrl_driver);
405
406MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
407MODULE_DESCRIPTION("Allwinner A13 pinctrl driver");
408MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31-r.c b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31-r.c
index d4bc4f0e8be0..a22bd88a1f03 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31-r.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31-r.c
@@ -12,7 +12,7 @@
12 * warranty of any kind, whether express or implied. 12 * warranty of any kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_device.h> 18#include <linux/of_device.h>
@@ -136,7 +136,6 @@ static const struct of_device_id sun6i_a31_r_pinctrl_match[] = {
136 { .compatible = "allwinner,sun6i-a31-r-pinctrl", }, 136 { .compatible = "allwinner,sun6i-a31-r-pinctrl", },
137 {} 137 {}
138}; 138};
139MODULE_DEVICE_TABLE(of, sun6i_a31_r_pinctrl_match);
140 139
141static struct platform_driver sun6i_a31_r_pinctrl_driver = { 140static struct platform_driver sun6i_a31_r_pinctrl_driver = {
142 .probe = sun6i_a31_r_pinctrl_probe, 141 .probe = sun6i_a31_r_pinctrl_probe,
@@ -145,9 +144,4 @@ static struct platform_driver sun6i_a31_r_pinctrl_driver = {
145 .of_match_table = sun6i_a31_r_pinctrl_match, 144 .of_match_table = sun6i_a31_r_pinctrl_match,
146 }, 145 },
147}; 146};
148module_platform_driver(sun6i_a31_r_pinctrl_driver); 147builtin_platform_driver(sun6i_a31_r_pinctrl_driver);
149
150MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com");
151MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
152MODULE_DESCRIPTION("Allwinner A31 R_PIO pinctrl driver");
153MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c
index a70b52957e24..9e58926bef37 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -934,7 +934,6 @@ static const struct of_device_id sun6i_a31_pinctrl_match[] = {
934 { .compatible = "allwinner,sun6i-a31-pinctrl", }, 934 { .compatible = "allwinner,sun6i-a31-pinctrl", },
935 {} 935 {}
936}; 936};
937MODULE_DEVICE_TABLE(of, sun6i_a31_pinctrl_match);
938 937
939static struct platform_driver sun6i_a31_pinctrl_driver = { 938static struct platform_driver sun6i_a31_pinctrl_driver = {
940 .probe = sun6i_a31_pinctrl_probe, 939 .probe = sun6i_a31_pinctrl_probe,
@@ -943,8 +942,4 @@ static struct platform_driver sun6i_a31_pinctrl_driver = {
943 .of_match_table = sun6i_a31_pinctrl_match, 942 .of_match_table = sun6i_a31_pinctrl_match,
944 }, 943 },
945}; 944};
946module_platform_driver(sun6i_a31_pinctrl_driver); 945builtin_platform_driver(sun6i_a31_pinctrl_driver);
947
948MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
949MODULE_DESCRIPTION("Allwinner A31 pinctrl driver");
950MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31s.c b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31s.c
index e570d5c93ecc..231a746a5356 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun6i-a31s.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun6i-a31s.c
@@ -11,7 +11,7 @@
11 * warranty of any kind, whether express or implied. 11 * warranty of any kind, whether express or implied.
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/of_device.h> 17#include <linux/of_device.h>
@@ -798,7 +798,6 @@ static const struct of_device_id sun6i_a31s_pinctrl_match[] = {
798 { .compatible = "allwinner,sun6i-a31s-pinctrl", }, 798 { .compatible = "allwinner,sun6i-a31s-pinctrl", },
799 {} 799 {}
800}; 800};
801MODULE_DEVICE_TABLE(of, sun6i_a31s_pinctrl_match);
802 801
803static struct platform_driver sun6i_a31s_pinctrl_driver = { 802static struct platform_driver sun6i_a31s_pinctrl_driver = {
804 .probe = sun6i_a31s_pinctrl_probe, 803 .probe = sun6i_a31s_pinctrl_probe,
@@ -807,8 +806,4 @@ static struct platform_driver sun6i_a31s_pinctrl_driver = {
807 .of_match_table = sun6i_a31s_pinctrl_match, 806 .of_match_table = sun6i_a31s_pinctrl_match,
808 }, 807 },
809}; 808};
810module_platform_driver(sun6i_a31s_pinctrl_driver); 809builtin_platform_driver(sun6i_a31s_pinctrl_driver);
811
812MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
813MODULE_DESCRIPTION("Allwinner A31s pinctrl driver");
814MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun7i-a20.c b/drivers/pinctrl/sunxi/pinctrl-sun7i-a20.c
index 435ad30f45db..b6f4c68ffb39 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun7i-a20.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun7i-a20.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -1045,7 +1045,6 @@ static const struct of_device_id sun7i_a20_pinctrl_match[] = {
1045 { .compatible = "allwinner,sun7i-a20-pinctrl", }, 1045 { .compatible = "allwinner,sun7i-a20-pinctrl", },
1046 {} 1046 {}
1047}; 1047};
1048MODULE_DEVICE_TABLE(of, sun7i_a20_pinctrl_match);
1049 1048
1050static struct platform_driver sun7i_a20_pinctrl_driver = { 1049static struct platform_driver sun7i_a20_pinctrl_driver = {
1051 .probe = sun7i_a20_pinctrl_probe, 1050 .probe = sun7i_a20_pinctrl_probe,
@@ -1054,8 +1053,4 @@ static struct platform_driver sun7i_a20_pinctrl_driver = {
1054 .of_match_table = sun7i_a20_pinctrl_match, 1053 .of_match_table = sun7i_a20_pinctrl_match,
1055 }, 1054 },
1056}; 1055};
1057module_platform_driver(sun7i_a20_pinctrl_driver); 1056builtin_platform_driver(sun7i_a20_pinctrl_driver);
1058
1059MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
1060MODULE_DESCRIPTION("Allwinner A20 pinctrl driver");
1061MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23-r.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23-r.c
index 056287635873..2292e05a397b 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23-r.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23-r.c
@@ -15,7 +15,7 @@
15 * warranty of any kind, whether express or implied. 15 * warranty of any kind, whether express or implied.
16 */ 16 */
17 17
18#include <linux/module.h> 18#include <linux/init.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/of_device.h> 21#include <linux/of_device.h>
@@ -123,7 +123,6 @@ static const struct of_device_id sun8i_a23_r_pinctrl_match[] = {
123 { .compatible = "allwinner,sun8i-a23-r-pinctrl", }, 123 { .compatible = "allwinner,sun8i-a23-r-pinctrl", },
124 {} 124 {}
125}; 125};
126MODULE_DEVICE_TABLE(of, sun8i_a23_r_pinctrl_match);
127 126
128static struct platform_driver sun8i_a23_r_pinctrl_driver = { 127static struct platform_driver sun8i_a23_r_pinctrl_driver = {
129 .probe = sun8i_a23_r_pinctrl_probe, 128 .probe = sun8i_a23_r_pinctrl_probe,
@@ -132,10 +131,4 @@ static struct platform_driver sun8i_a23_r_pinctrl_driver = {
132 .of_match_table = sun8i_a23_r_pinctrl_match, 131 .of_match_table = sun8i_a23_r_pinctrl_match,
133 }, 132 },
134}; 133};
135module_platform_driver(sun8i_a23_r_pinctrl_driver); 134builtin_platform_driver(sun8i_a23_r_pinctrl_driver);
136
137MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
138MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com");
139MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
140MODULE_DESCRIPTION("Allwinner A23 R_PIO pinctrl driver");
141MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
index f9d661e5c14a..721b6935baf3 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
@@ -14,7 +14,7 @@
14 * warranty of any kind, whether express or implied. 14 * warranty of any kind, whether express or implied.
15 */ 15 */
16 16
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/of_device.h> 20#include <linux/of_device.h>
@@ -575,7 +575,6 @@ static const struct of_device_id sun8i_a23_pinctrl_match[] = {
575 { .compatible = "allwinner,sun8i-a23-pinctrl", }, 575 { .compatible = "allwinner,sun8i-a23-pinctrl", },
576 {} 576 {}
577}; 577};
578MODULE_DEVICE_TABLE(of, sun8i_a23_pinctrl_match);
579 578
580static struct platform_driver sun8i_a23_pinctrl_driver = { 579static struct platform_driver sun8i_a23_pinctrl_driver = {
581 .probe = sun8i_a23_pinctrl_probe, 580 .probe = sun8i_a23_pinctrl_probe,
@@ -584,9 +583,4 @@ static struct platform_driver sun8i_a23_pinctrl_driver = {
584 .of_match_table = sun8i_a23_pinctrl_match, 583 .of_match_table = sun8i_a23_pinctrl_match,
585 }, 584 },
586}; 585};
587module_platform_driver(sun8i_a23_pinctrl_driver); 586builtin_platform_driver(sun8i_a23_pinctrl_driver);
588
589MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
590MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com");
591MODULE_DESCRIPTION("Allwinner A23 pinctrl driver");
592MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
index 3131cac2b76f..ef1e0bef4099 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
@@ -12,7 +12,7 @@
12 * warranty of any kind, whether express or implied. 12 * warranty of any kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_device.h> 18#include <linux/of_device.h>
@@ -498,7 +498,6 @@ static const struct of_device_id sun8i_a33_pinctrl_match[] = {
498 { .compatible = "allwinner,sun8i-a33-pinctrl", }, 498 { .compatible = "allwinner,sun8i-a33-pinctrl", },
499 {} 499 {}
500}; 500};
501MODULE_DEVICE_TABLE(of, sun8i_a33_pinctrl_match);
502 501
503static struct platform_driver sun8i_a33_pinctrl_driver = { 502static struct platform_driver sun8i_a33_pinctrl_driver = {
504 .probe = sun8i_a33_pinctrl_probe, 503 .probe = sun8i_a33_pinctrl_probe,
@@ -507,8 +506,4 @@ static struct platform_driver sun8i_a33_pinctrl_driver = {
507 .of_match_table = sun8i_a33_pinctrl_match, 506 .of_match_table = sun8i_a33_pinctrl_match,
508 }, 507 },
509}; 508};
510module_platform_driver(sun8i_a33_pinctrl_driver); 509builtin_platform_driver(sun8i_a33_pinctrl_driver);
511
512MODULE_AUTHOR("Vishnu Patekar <vishnupatekar0510@gmail.com>");
513MODULE_DESCRIPTION("Allwinner a33 pinctrl driver");
514MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c
index 90b973e15982..9aec1d2232dd 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a83t.c
@@ -12,7 +12,7 @@
12 * warranty of any kind, whether express or implied. 12 * warranty of any kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_device.h> 18#include <linux/of_device.h>
@@ -587,7 +587,6 @@ static const struct of_device_id sun8i_a83t_pinctrl_match[] = {
587 { .compatible = "allwinner,sun8i-a83t-pinctrl", }, 587 { .compatible = "allwinner,sun8i-a83t-pinctrl", },
588 {} 588 {}
589}; 589};
590MODULE_DEVICE_TABLE(of, sun8i_a83t_pinctrl_match);
591 590
592static struct platform_driver sun8i_a83t_pinctrl_driver = { 591static struct platform_driver sun8i_a83t_pinctrl_driver = {
593 .probe = sun8i_a83t_pinctrl_probe, 592 .probe = sun8i_a83t_pinctrl_probe,
@@ -596,8 +595,4 @@ static struct platform_driver sun8i_a83t_pinctrl_driver = {
596 .of_match_table = sun8i_a83t_pinctrl_match, 595 .of_match_table = sun8i_a83t_pinctrl_match,
597 }, 596 },
598}; 597};
599module_platform_driver(sun8i_a83t_pinctrl_driver); 598builtin_platform_driver(sun8i_a83t_pinctrl_driver);
600
601MODULE_AUTHOR("Vishnu Patekar <vishnupatekar0510@gmail.com>");
602MODULE_DESCRIPTION("Allwinner a83t pinctrl driver");
603MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c b/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c
index 1b580ba76453..bc14e954d7a2 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c
@@ -10,7 +10,7 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -733,7 +733,6 @@ static const struct of_device_id sun9i_a80_pinctrl_match[] = {
733 { .compatible = "allwinner,sun9i-a80-pinctrl", }, 733 { .compatible = "allwinner,sun9i-a80-pinctrl", },
734 {} 734 {}
735}; 735};
736MODULE_DEVICE_TABLE(of, sun9i_a80_pinctrl_match);
737 736
738static struct platform_driver sun9i_a80_pinctrl_driver = { 737static struct platform_driver sun9i_a80_pinctrl_driver = {
739 .probe = sun9i_a80_pinctrl_probe, 738 .probe = sun9i_a80_pinctrl_probe,
@@ -742,8 +741,4 @@ static struct platform_driver sun9i_a80_pinctrl_driver = {
742 .of_match_table = sun9i_a80_pinctrl_match, 741 .of_match_table = sun9i_a80_pinctrl_match,
743 }, 742 },
744}; 743};
745module_platform_driver(sun9i_a80_pinctrl_driver); 744builtin_platform_driver(sun9i_a80_pinctrl_driver);
746
747MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
748MODULE_DESCRIPTION("Allwinner A80 pinctrl driver");
749MODULE_LICENSE("GPL");
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 0facbea5f465..0eb51e33cb1b 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -28,6 +28,8 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30 30
31#include <dt-bindings/pinctrl/sun4i-a10.h>
32
31#include "../core.h" 33#include "../core.h"
32#include "pinctrl-sunxi.h" 34#include "pinctrl-sunxi.h"
33 35
@@ -145,6 +147,171 @@ static int sunxi_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
145 return 0; 147 return 0;
146} 148}
147 149
150static bool sunxi_pctrl_has_bias_prop(struct device_node *node)
151{
152 return of_find_property(node, "bias-pull-up", NULL) ||
153 of_find_property(node, "bias-pull-down", NULL) ||
154 of_find_property(node, "bias-disable", NULL) ||
155 of_find_property(node, "allwinner,pull", NULL);
156}
157
158static bool sunxi_pctrl_has_drive_prop(struct device_node *node)
159{
160 return of_find_property(node, "drive-strength", NULL) ||
161 of_find_property(node, "allwinner,drive", NULL);
162}
163
164static int sunxi_pctrl_parse_bias_prop(struct device_node *node)
165{
166 u32 val;
167
168 /* Try the new style binding */
169 if (of_find_property(node, "bias-pull-up", NULL))
170 return PIN_CONFIG_BIAS_PULL_UP;
171
172 if (of_find_property(node, "bias-pull-down", NULL))
173 return PIN_CONFIG_BIAS_PULL_DOWN;
174
175 if (of_find_property(node, "bias-disable", NULL))
176 return PIN_CONFIG_BIAS_DISABLE;
177
178 /* And fall back to the old binding */
179 if (of_property_read_u32(node, "allwinner,pull", &val))
180 return -EINVAL;
181
182 switch (val) {
183 case SUN4I_PINCTRL_NO_PULL:
184 return PIN_CONFIG_BIAS_DISABLE;
185 case SUN4I_PINCTRL_PULL_UP:
186 return PIN_CONFIG_BIAS_PULL_UP;
187 case SUN4I_PINCTRL_PULL_DOWN:
188 return PIN_CONFIG_BIAS_PULL_DOWN;
189 }
190
191 return -EINVAL;
192}
193
194static int sunxi_pctrl_parse_drive_prop(struct device_node *node)
195{
196 u32 val;
197
198 /* Try the new style binding */
199 if (!of_property_read_u32(node, "drive-strength", &val)) {
200 /* We can't go below 10mA ... */
201 if (val < 10)
202 return -EINVAL;
203
204 /* ... and only up to 40 mA ... */
205 if (val > 40)
206 val = 40;
207
208 /* by steps of 10 mA */
209 return rounddown(val, 10);
210 }
211
212 /* And then fall back to the old binding */
213 if (of_property_read_u32(node, "allwinner,drive", &val))
214 return -EINVAL;
215
216 return (val + 1) * 10;
217}
218
219static const char *sunxi_pctrl_parse_function_prop(struct device_node *node)
220{
221 const char *function;
222 int ret;
223
224 /* Try the generic binding */
225 ret = of_property_read_string(node, "function", &function);
226 if (!ret)
227 return function;
228
229 /* And fall back to our legacy one */
230 ret = of_property_read_string(node, "allwinner,function", &function);
231 if (!ret)
232 return function;
233
234 return NULL;
235}
236
237static const char *sunxi_pctrl_find_pins_prop(struct device_node *node,
238 int *npins)
239{
240 int count;
241
242 /* Try the generic binding */
243 count = of_property_count_strings(node, "pins");
244 if (count > 0) {
245 *npins = count;
246 return "pins";
247 }
248
249 /* And fall back to our legacy one */
250 count = of_property_count_strings(node, "allwinner,pins");
251 if (count > 0) {
252 *npins = count;
253 return "allwinner,pins";
254 }
255
256 return NULL;
257}
258
259static unsigned long *sunxi_pctrl_build_pin_config(struct device_node *node,
260 unsigned int *len)
261{
262 unsigned long *pinconfig;
263 unsigned int configlen = 0, idx = 0;
264 int ret;
265
266 if (sunxi_pctrl_has_drive_prop(node))
267 configlen++;
268 if (sunxi_pctrl_has_bias_prop(node))
269 configlen++;
270
271 /*
272 * If we don't have any configuration, bail out
273 */
274 if (!configlen)
275 return NULL;
276
277 pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
278 if (!pinconfig)
279 return ERR_PTR(-ENOMEM);
280
281 if (sunxi_pctrl_has_drive_prop(node)) {
282 int drive = sunxi_pctrl_parse_drive_prop(node);
283 if (drive < 0) {
284 ret = drive;
285 goto err_free;
286 }
287
288 pinconfig[idx++] = pinconf_to_config_packed(PIN_CONFIG_DRIVE_STRENGTH,
289 drive);
290 }
291
292 if (sunxi_pctrl_has_bias_prop(node)) {
293 int pull = sunxi_pctrl_parse_bias_prop(node);
294 int arg = 0;
295 if (pull < 0) {
296 ret = pull;
297 goto err_free;
298 }
299
300 if (pull != PIN_CONFIG_BIAS_DISABLE)
301 arg = 1; /* hardware uses weak pull resistors */
302
303 pinconfig[idx++] = pinconf_to_config_packed(pull, arg);
304 }
305
306
307 *len = configlen;
308 return pinconfig;
309
310err_free:
311 kfree(pinconfig);
312 return ERR_PTR(ret);
313}
314
148static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, 315static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
149 struct device_node *node, 316 struct device_node *node,
150 struct pinctrl_map **map, 317 struct pinctrl_map **map,
@@ -153,38 +320,48 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
153 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 320 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
154 unsigned long *pinconfig; 321 unsigned long *pinconfig;
155 struct property *prop; 322 struct property *prop;
156 const char *function; 323 const char *function, *pin_prop;
157 const char *group; 324 const char *group;
158 int ret, nmaps, i = 0; 325 int ret, npins, nmaps, configlen = 0, i = 0;
159 u32 val;
160 326
161 *map = NULL; 327 *map = NULL;
162 *num_maps = 0; 328 *num_maps = 0;
163 329
164 ret = of_property_read_string(node, "allwinner,function", &function); 330 function = sunxi_pctrl_parse_function_prop(node);
165 if (ret) { 331 if (!function) {
166 dev_err(pctl->dev, 332 dev_err(pctl->dev, "missing function property in node %s\n",
167 "missing allwinner,function property in node %s\n",
168 node->name); 333 node->name);
169 return -EINVAL; 334 return -EINVAL;
170 } 335 }
171 336
172 nmaps = of_property_count_strings(node, "allwinner,pins") * 2; 337 pin_prop = sunxi_pctrl_find_pins_prop(node, &npins);
173 if (nmaps < 0) { 338 if (!pin_prop) {
174 dev_err(pctl->dev, 339 dev_err(pctl->dev, "missing pins property in node %s\n",
175 "missing allwinner,pins property in node %s\n",
176 node->name); 340 node->name);
177 return -EINVAL; 341 return -EINVAL;
178 } 342 }
179 343
344 /*
345 * We have two maps for each pin: one for the function, one
346 * for the configuration (bias, strength, etc).
347 *
348 * We might be slightly overshooting, since we might not have
349 * any configuration.
350 */
351 nmaps = npins * 2;
180 *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL); 352 *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
181 if (!*map) 353 if (!*map)
182 return -ENOMEM; 354 return -ENOMEM;
183 355
184 of_property_for_each_string(node, "allwinner,pins", prop, group) { 356 pinconfig = sunxi_pctrl_build_pin_config(node, &configlen);
357 if (IS_ERR(pinconfig)) {
358 ret = PTR_ERR(pinconfig);
359 goto err_free_map;
360 }
361
362 of_property_for_each_string(node, pin_prop, prop, group) {
185 struct sunxi_pinctrl_group *grp = 363 struct sunxi_pinctrl_group *grp =
186 sunxi_pinctrl_find_group_by_name(pctl, group); 364 sunxi_pinctrl_find_group_by_name(pctl, group);
187 int j = 0, configlen = 0;
188 365
189 if (!grp) { 366 if (!grp) {
190 dev_err(pctl->dev, "unknown pin %s", group); 367 dev_err(pctl->dev, "unknown pin %s", group);
@@ -205,45 +382,31 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
205 382
206 i++; 383 i++;
207 384
208 (*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP; 385 if (pinconfig) {
209 (*map)[i].data.configs.group_or_pin = group; 386 (*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
210 387 (*map)[i].data.configs.group_or_pin = group;
211 if (of_find_property(node, "allwinner,drive", NULL)) 388 (*map)[i].data.configs.configs = pinconfig;
212 configlen++; 389 (*map)[i].data.configs.num_configs = configlen;
213 if (of_find_property(node, "allwinner,pull", NULL)) 390 i++;
214 configlen++;
215
216 pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
217 if (!pinconfig) {
218 kfree(*map);
219 return -ENOMEM;
220 } 391 }
221
222 if (!of_property_read_u32(node, "allwinner,drive", &val)) {
223 u16 strength = (val + 1) * 10;
224 pinconfig[j++] =
225 pinconf_to_config_packed(PIN_CONFIG_DRIVE_STRENGTH,
226 strength);
227 }
228
229 if (!of_property_read_u32(node, "allwinner,pull", &val)) {
230 enum pin_config_param pull = PIN_CONFIG_END;
231 if (val == 1)
232 pull = PIN_CONFIG_BIAS_PULL_UP;
233 else if (val == 2)
234 pull = PIN_CONFIG_BIAS_PULL_DOWN;
235 pinconfig[j++] = pinconf_to_config_packed(pull, 0);
236 }
237
238 (*map)[i].data.configs.configs = pinconfig;
239 (*map)[i].data.configs.num_configs = configlen;
240
241 i++;
242 } 392 }
243 393
244 *num_maps = nmaps; 394 *num_maps = i;
395
396 /*
397 * We know have the number of maps we need, we can resize our
398 * map array
399 */
400 *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL);
401 if (!*map)
402 return -ENOMEM;
245 403
246 return 0; 404 return 0;
405
406err_free_map:
407 kfree(*map);
408 *map = NULL;
409 return ret;
247} 410}
248 411
249static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev, 412static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev,
@@ -252,9 +415,17 @@ static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev,
252{ 415{
253 int i; 416 int i;
254 417
255 for (i = 0; i < num_maps; i++) { 418 /* pin config is never in the first map */
256 if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP) 419 for (i = 1; i < num_maps; i++) {
257 kfree(map[i].data.configs.configs); 420 if (map[i].type != PIN_MAP_TYPE_CONFIGS_GROUP)
421 continue;
422
423 /*
424 * All the maps share the same pin config,
425 * free only the first one we find.
426 */
427 kfree(map[i].data.configs.configs);
428 break;
258 } 429 }
259 430
260 kfree(map); 431 kfree(map);
@@ -268,15 +439,91 @@ static const struct pinctrl_ops sunxi_pctrl_ops = {
268 .get_group_pins = sunxi_pctrl_get_group_pins, 439 .get_group_pins = sunxi_pctrl_get_group_pins,
269}; 440};
270 441
442static int sunxi_pconf_reg(unsigned pin, enum pin_config_param param,
443 u32 *offset, u32 *shift, u32 *mask)
444{
445 switch (param) {
446 case PIN_CONFIG_DRIVE_STRENGTH:
447 *offset = sunxi_dlevel_reg(pin);
448 *shift = sunxi_dlevel_offset(pin);
449 *mask = DLEVEL_PINS_MASK;
450 break;
451
452 case PIN_CONFIG_BIAS_PULL_UP:
453 case PIN_CONFIG_BIAS_PULL_DOWN:
454 case PIN_CONFIG_BIAS_DISABLE:
455 *offset = sunxi_pull_reg(pin);
456 *shift = sunxi_pull_offset(pin);
457 *mask = PULL_PINS_MASK;
458 break;
459
460 default:
461 return -ENOTSUPP;
462 }
463
464 return 0;
465}
466
467static int sunxi_pconf_get(struct pinctrl_dev *pctldev, unsigned pin,
468 unsigned long *config)
469{
470 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
471 enum pin_config_param param = pinconf_to_config_param(*config);
472 u32 offset, shift, mask, val;
473 u16 arg;
474 int ret;
475
476 pin -= pctl->desc->pin_base;
477
478 ret = sunxi_pconf_reg(pin, param, &offset, &shift, &mask);
479 if (ret < 0)
480 return ret;
481
482 val = (readl(pctl->membase + offset) >> shift) & mask;
483
484 switch (pinconf_to_config_param(*config)) {
485 case PIN_CONFIG_DRIVE_STRENGTH:
486 arg = (val + 1) * 10;
487 break;
488
489 case PIN_CONFIG_BIAS_PULL_UP:
490 if (val != SUN4I_PINCTRL_PULL_UP)
491 return -EINVAL;
492 arg = 1; /* hardware is weak pull-up */
493 break;
494
495 case PIN_CONFIG_BIAS_PULL_DOWN:
496 if (val != SUN4I_PINCTRL_PULL_DOWN)
497 return -EINVAL;
498 arg = 1; /* hardware is weak pull-down */
499 break;
500
501 case PIN_CONFIG_BIAS_DISABLE:
502 if (val != SUN4I_PINCTRL_NO_PULL)
503 return -EINVAL;
504 arg = 0;
505 break;
506
507 default:
508 /* sunxi_pconf_reg should catch anything unsupported */
509 WARN_ON(1);
510 return -ENOTSUPP;
511 }
512
513 *config = pinconf_to_config_packed(param, arg);
514
515 return 0;
516}
517
271static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev, 518static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev,
272 unsigned group, 519 unsigned group,
273 unsigned long *config) 520 unsigned long *config)
274{ 521{
275 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 522 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
523 struct sunxi_pinctrl_group *g = &pctl->groups[group];
276 524
277 *config = pctl->groups[group].config; 525 /* We only support 1 pin per group. Chain it to the pin callback */
278 526 return sunxi_pconf_get(pctldev, g->pin, config);
279 return 0;
280} 527}
281 528
282static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev, 529static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
@@ -286,23 +533,27 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
286{ 533{
287 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 534 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
288 struct sunxi_pinctrl_group *g = &pctl->groups[group]; 535 struct sunxi_pinctrl_group *g = &pctl->groups[group];
289 unsigned long flags;
290 unsigned pin = g->pin - pctl->desc->pin_base; 536 unsigned pin = g->pin - pctl->desc->pin_base;
291 u32 val, mask;
292 u16 strength;
293 u8 dlevel;
294 int i; 537 int i;
295 538
296 spin_lock_irqsave(&pctl->lock, flags);
297
298 for (i = 0; i < num_configs; i++) { 539 for (i = 0; i < num_configs; i++) {
299 switch (pinconf_to_config_param(configs[i])) { 540 enum pin_config_param param;
541 unsigned long flags;
542 u32 offset, shift, mask, reg;
543 u16 arg, val;
544 int ret;
545
546 param = pinconf_to_config_param(configs[i]);
547 arg = pinconf_to_config_argument(configs[i]);
548
549 ret = sunxi_pconf_reg(pin, param, &offset, &shift, &mask);
550 if (ret < 0)
551 return ret;
552
553 switch (param) {
300 case PIN_CONFIG_DRIVE_STRENGTH: 554 case PIN_CONFIG_DRIVE_STRENGTH:
301 strength = pinconf_to_config_argument(configs[i]); 555 if (arg < 10 || arg > 40)
302 if (strength > 40) {
303 spin_unlock_irqrestore(&pctl->lock, flags);
304 return -EINVAL; 556 return -EINVAL;
305 }
306 /* 557 /*
307 * We convert from mA to what the register expects: 558 * We convert from mA to what the register expects:
308 * 0: 10mA 559 * 0: 10mA
@@ -310,38 +561,40 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
310 * 2: 30mA 561 * 2: 30mA
311 * 3: 40mA 562 * 3: 40mA
312 */ 563 */
313 dlevel = strength / 10 - 1; 564 val = arg / 10 - 1;
314 val = readl(pctl->membase + sunxi_dlevel_reg(pin)); 565 break;
315 mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(pin); 566 case PIN_CONFIG_BIAS_DISABLE:
316 writel((val & ~mask) 567 val = 0;
317 | dlevel << sunxi_dlevel_offset(pin),
318 pctl->membase + sunxi_dlevel_reg(pin));
319 break; 568 break;
320 case PIN_CONFIG_BIAS_PULL_UP: 569 case PIN_CONFIG_BIAS_PULL_UP:
321 val = readl(pctl->membase + sunxi_pull_reg(pin)); 570 if (arg == 0)
322 mask = PULL_PINS_MASK << sunxi_pull_offset(pin); 571 return -EINVAL;
323 writel((val & ~mask) | 1 << sunxi_pull_offset(pin), 572 val = 1;
324 pctl->membase + sunxi_pull_reg(pin));
325 break; 573 break;
326 case PIN_CONFIG_BIAS_PULL_DOWN: 574 case PIN_CONFIG_BIAS_PULL_DOWN:
327 val = readl(pctl->membase + sunxi_pull_reg(pin)); 575 if (arg == 0)
328 mask = PULL_PINS_MASK << sunxi_pull_offset(pin); 576 return -EINVAL;
329 writel((val & ~mask) | 2 << sunxi_pull_offset(pin), 577 val = 2;
330 pctl->membase + sunxi_pull_reg(pin));
331 break; 578 break;
332 default: 579 default:
333 break; 580 /* sunxi_pconf_reg should catch anything unsupported */
581 WARN_ON(1);
582 return -ENOTSUPP;
334 } 583 }
335 /* cache the config value */
336 g->config = configs[i];
337 } /* for each config */
338 584
339 spin_unlock_irqrestore(&pctl->lock, flags); 585 spin_lock_irqsave(&pctl->lock, flags);
586 reg = readl(pctl->membase + offset);
587 reg &= ~(mask << shift);
588 writel(reg | val << shift, pctl->membase + offset);
589 spin_unlock_irqrestore(&pctl->lock, flags);
590 } /* for each config */
340 591
341 return 0; 592 return 0;
342} 593}
343 594
344static const struct pinconf_ops sunxi_pconf_ops = { 595static const struct pinconf_ops sunxi_pconf_ops = {
596 .is_generic = true,
597 .pin_config_get = sunxi_pconf_get,
345 .pin_config_group_get = sunxi_pconf_group_get, 598 .pin_config_group_get = sunxi_pconf_group_get,
346 .pin_config_group_set = sunxi_pconf_group_set, 599 .pin_config_group_set = sunxi_pconf_group_set,
347}; 600};
@@ -870,6 +1123,91 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
870 return 0; 1123 return 0;
871} 1124}
872 1125
1126static int sunxi_pinctrl_get_debounce_div(struct clk *clk, int freq, int *diff)
1127{
1128 unsigned long clock = clk_get_rate(clk);
1129 unsigned int best_diff, best_div;
1130 int i;
1131
1132 best_diff = abs(freq - clock);
1133 best_div = 0;
1134
1135 for (i = 1; i < 8; i++) {
1136 int cur_diff = abs(freq - (clock >> i));
1137
1138 if (cur_diff < best_diff) {
1139 best_diff = cur_diff;
1140 best_div = i;
1141 }
1142 }
1143
1144 *diff = best_diff;
1145 return best_div;
1146}
1147
1148static int sunxi_pinctrl_setup_debounce(struct sunxi_pinctrl *pctl,
1149 struct device_node *node)
1150{
1151 unsigned int hosc_diff, losc_diff;
1152 unsigned int hosc_div, losc_div;
1153 struct clk *hosc, *losc;
1154 u8 div, src;
1155 int i, ret;
1156
1157 /* Deal with old DTs that didn't have the oscillators */
1158 if (of_count_phandle_with_args(node, "clocks", "#clock-cells") != 3)
1159 return 0;
1160
1161 /* If we don't have any setup, bail out */
1162 if (!of_find_property(node, "input-debounce", NULL))
1163 return 0;
1164
1165 losc = devm_clk_get(pctl->dev, "losc");
1166 if (IS_ERR(losc))
1167 return PTR_ERR(losc);
1168
1169 hosc = devm_clk_get(pctl->dev, "hosc");
1170 if (IS_ERR(hosc))
1171 return PTR_ERR(hosc);
1172
1173 for (i = 0; i < pctl->desc->irq_banks; i++) {
1174 unsigned long debounce_freq;
1175 u32 debounce;
1176
1177 ret = of_property_read_u32_index(node, "input-debounce",
1178 i, &debounce);
1179 if (ret)
1180 return ret;
1181
1182 if (!debounce)
1183 continue;
1184
1185 debounce_freq = DIV_ROUND_CLOSEST(USEC_PER_SEC, debounce);
1186 losc_div = sunxi_pinctrl_get_debounce_div(losc,
1187 debounce_freq,
1188 &losc_diff);
1189
1190 hosc_div = sunxi_pinctrl_get_debounce_div(hosc,
1191 debounce_freq,
1192 &hosc_diff);
1193
1194 if (hosc_diff < losc_diff) {
1195 div = hosc_div;
1196 src = 1;
1197 } else {
1198 div = losc_div;
1199 src = 0;
1200 }
1201
1202 writel(src | div << 4,
1203 pctl->membase +
1204 sunxi_irq_debounce_reg_from_bank(i,
1205 pctl->desc->irq_bank_base));
1206 }
1207
1208 return 0;
1209}
1210
873int sunxi_pinctrl_init(struct platform_device *pdev, 1211int sunxi_pinctrl_init(struct platform_device *pdev,
874 const struct sunxi_pinctrl_desc *desc) 1212 const struct sunxi_pinctrl_desc *desc)
875{ 1213{
@@ -1032,6 +1370,8 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
1032 pctl); 1370 pctl);
1033 } 1371 }
1034 1372
1373 sunxi_pinctrl_setup_debounce(pctl, node);
1374
1035 dev_info(&pdev->dev, "initialized sunXi PIO driver\n"); 1375 dev_info(&pdev->dev, "initialized sunXi PIO driver\n");
1036 1376
1037 return 0; 1377 return 0;
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
index 0afce1ab12d0..f78a44a03189 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h
@@ -69,6 +69,8 @@
69#define IRQ_STATUS_IRQ_BITS 1 69#define IRQ_STATUS_IRQ_BITS 1
70#define IRQ_STATUS_IRQ_MASK ((1 << IRQ_STATUS_IRQ_BITS) - 1) 70#define IRQ_STATUS_IRQ_MASK ((1 << IRQ_STATUS_IRQ_BITS) - 1)
71 71
72#define IRQ_DEBOUNCE_REG 0x218
73
72#define IRQ_MEM_SIZE 0x20 74#define IRQ_MEM_SIZE 0x20
73 75
74#define IRQ_EDGE_RISING 0x00 76#define IRQ_EDGE_RISING 0x00
@@ -109,7 +111,6 @@ struct sunxi_pinctrl_function {
109 111
110struct sunxi_pinctrl_group { 112struct sunxi_pinctrl_group {
111 const char *name; 113 const char *name;
112 unsigned long config;
113 unsigned pin; 114 unsigned pin;
114}; 115};
115 116
@@ -266,6 +267,11 @@ static inline u32 sunxi_irq_ctrl_offset(u16 irq)
266 return irq_num * IRQ_CTRL_IRQ_BITS; 267 return irq_num * IRQ_CTRL_IRQ_BITS;
267} 268}
268 269
270static inline u32 sunxi_irq_debounce_reg_from_bank(u8 bank, unsigned bank_base)
271{
272 return IRQ_DEBOUNCE_REG + (bank_base + bank) * IRQ_MEM_SIZE;
273}
274
269static inline u32 sunxi_irq_status_reg_from_bank(u8 bank, unsigned bank_base) 275static inline u32 sunxi_irq_status_reg_from_bank(u8 bank, unsigned bank_base)
270{ 276{
271 return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE; 277 return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE;
diff --git a/drivers/pinctrl/vt8500/pinctrl-vt8500.c b/drivers/pinctrl/vt8500/pinctrl-vt8500.c
index ca946b3dbdb4..767f340d6b11 100644
--- a/drivers/pinctrl/vt8500/pinctrl-vt8500.c
+++ b/drivers/pinctrl/vt8500/pinctrl-vt8500.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/pinctrl/pinctrl.h> 18#include <linux/pinctrl/pinctrl.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
@@ -473,11 +473,6 @@ static int vt8500_pinctrl_probe(struct platform_device *pdev)
473 return wmt_pinctrl_probe(pdev, data); 473 return wmt_pinctrl_probe(pdev, data);
474} 474}
475 475
476static int vt8500_pinctrl_remove(struct platform_device *pdev)
477{
478 return wmt_pinctrl_remove(pdev);
479}
480
481static const struct of_device_id wmt_pinctrl_of_match[] = { 476static const struct of_device_id wmt_pinctrl_of_match[] = {
482 { .compatible = "via,vt8500-pinctrl" }, 477 { .compatible = "via,vt8500-pinctrl" },
483 { /* sentinel */ }, 478 { /* sentinel */ },
@@ -485,16 +480,10 @@ static const struct of_device_id wmt_pinctrl_of_match[] = {
485 480
486static struct platform_driver wmt_pinctrl_driver = { 481static struct platform_driver wmt_pinctrl_driver = {
487 .probe = vt8500_pinctrl_probe, 482 .probe = vt8500_pinctrl_probe,
488 .remove = vt8500_pinctrl_remove,
489 .driver = { 483 .driver = {
490 .name = "pinctrl-vt8500", 484 .name = "pinctrl-vt8500",
491 .of_match_table = wmt_pinctrl_of_match, 485 .of_match_table = wmt_pinctrl_of_match,
486 .suppress_bind_attrs = true,
492 }, 487 },
493}; 488};
494 489builtin_platform_driver(wmt_pinctrl_driver);
495module_platform_driver(wmt_pinctrl_driver);
496
497MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
498MODULE_DESCRIPTION("VIA VT8500 Pincontrol driver");
499MODULE_LICENSE("GPL v2");
500MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
diff --git a/drivers/pinctrl/vt8500/pinctrl-wm8505.c b/drivers/pinctrl/vt8500/pinctrl-wm8505.c
index 626fc7ec0174..a56fdbd87e42 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wm8505.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wm8505.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/pinctrl/pinctrl.h> 18#include <linux/pinctrl/pinctrl.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
@@ -504,11 +504,6 @@ static int wm8505_pinctrl_probe(struct platform_device *pdev)
504 return wmt_pinctrl_probe(pdev, data); 504 return wmt_pinctrl_probe(pdev, data);
505} 505}
506 506
507static int wm8505_pinctrl_remove(struct platform_device *pdev)
508{
509 return wmt_pinctrl_remove(pdev);
510}
511
512static const struct of_device_id wmt_pinctrl_of_match[] = { 507static const struct of_device_id wmt_pinctrl_of_match[] = {
513 { .compatible = "wm,wm8505-pinctrl" }, 508 { .compatible = "wm,wm8505-pinctrl" },
514 { /* sentinel */ }, 509 { /* sentinel */ },
@@ -516,16 +511,10 @@ static const struct of_device_id wmt_pinctrl_of_match[] = {
516 511
517static struct platform_driver wmt_pinctrl_driver = { 512static struct platform_driver wmt_pinctrl_driver = {
518 .probe = wm8505_pinctrl_probe, 513 .probe = wm8505_pinctrl_probe,
519 .remove = wm8505_pinctrl_remove,
520 .driver = { 514 .driver = {
521 .name = "pinctrl-wm8505", 515 .name = "pinctrl-wm8505",
522 .of_match_table = wmt_pinctrl_of_match, 516 .of_match_table = wmt_pinctrl_of_match,
517 .suppress_bind_attrs = true,
523 }, 518 },
524}; 519};
525 520builtin_platform_driver(wmt_pinctrl_driver);
526module_platform_driver(wmt_pinctrl_driver);
527
528MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
529MODULE_DESCRIPTION("Wondermedia WM8505 Pincontrol driver");
530MODULE_LICENSE("GPL v2");
531MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
diff --git a/drivers/pinctrl/vt8500/pinctrl-wm8650.c b/drivers/pinctrl/vt8500/pinctrl-wm8650.c
index 8953aba8bfc2..270dd491f5a1 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wm8650.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wm8650.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/pinctrl/pinctrl.h> 18#include <linux/pinctrl/pinctrl.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
@@ -342,11 +342,6 @@ static int wm8650_pinctrl_probe(struct platform_device *pdev)
342 return wmt_pinctrl_probe(pdev, data); 342 return wmt_pinctrl_probe(pdev, data);
343} 343}
344 344
345static int wm8650_pinctrl_remove(struct platform_device *pdev)
346{
347 return wmt_pinctrl_remove(pdev);
348}
349
350static const struct of_device_id wmt_pinctrl_of_match[] = { 345static const struct of_device_id wmt_pinctrl_of_match[] = {
351 { .compatible = "wm,wm8650-pinctrl" }, 346 { .compatible = "wm,wm8650-pinctrl" },
352 { /* sentinel */ }, 347 { /* sentinel */ },
@@ -354,16 +349,10 @@ static const struct of_device_id wmt_pinctrl_of_match[] = {
354 349
355static struct platform_driver wmt_pinctrl_driver = { 350static struct platform_driver wmt_pinctrl_driver = {
356 .probe = wm8650_pinctrl_probe, 351 .probe = wm8650_pinctrl_probe,
357 .remove = wm8650_pinctrl_remove,
358 .driver = { 352 .driver = {
359 .name = "pinctrl-wm8650", 353 .name = "pinctrl-wm8650",
360 .of_match_table = wmt_pinctrl_of_match, 354 .of_match_table = wmt_pinctrl_of_match,
355 .suppress_bind_attrs = true,
361 }, 356 },
362}; 357};
363 358builtin_platform_driver(wmt_pinctrl_driver);
364module_platform_driver(wmt_pinctrl_driver);
365
366MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
367MODULE_DESCRIPTION("Wondermedia WM8650 Pincontrol driver");
368MODULE_LICENSE("GPL v2");
369MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
diff --git a/drivers/pinctrl/vt8500/pinctrl-wm8750.c b/drivers/pinctrl/vt8500/pinctrl-wm8750.c
index c79053d430db..74f7b3a18f3a 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wm8750.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wm8750.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/pinctrl/pinctrl.h> 18#include <linux/pinctrl/pinctrl.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
@@ -381,11 +381,6 @@ static int wm8750_pinctrl_probe(struct platform_device *pdev)
381 return wmt_pinctrl_probe(pdev, data); 381 return wmt_pinctrl_probe(pdev, data);
382} 382}
383 383
384static int wm8750_pinctrl_remove(struct platform_device *pdev)
385{
386 return wmt_pinctrl_remove(pdev);
387}
388
389static const struct of_device_id wmt_pinctrl_of_match[] = { 384static const struct of_device_id wmt_pinctrl_of_match[] = {
390 { .compatible = "wm,wm8750-pinctrl" }, 385 { .compatible = "wm,wm8750-pinctrl" },
391 { /* sentinel */ }, 386 { /* sentinel */ },
@@ -393,16 +388,10 @@ static const struct of_device_id wmt_pinctrl_of_match[] = {
393 388
394static struct platform_driver wmt_pinctrl_driver = { 389static struct platform_driver wmt_pinctrl_driver = {
395 .probe = wm8750_pinctrl_probe, 390 .probe = wm8750_pinctrl_probe,
396 .remove = wm8750_pinctrl_remove,
397 .driver = { 391 .driver = {
398 .name = "pinctrl-wm8750", 392 .name = "pinctrl-wm8750",
399 .of_match_table = wmt_pinctrl_of_match, 393 .of_match_table = wmt_pinctrl_of_match,
394 .suppress_bind_attrs = true,
400 }, 395 },
401}; 396};
402 397builtin_platform_driver(wmt_pinctrl_driver);
403module_platform_driver(wmt_pinctrl_driver);
404
405MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
406MODULE_DESCRIPTION("Wondermedia WM8750 Pincontrol driver");
407MODULE_LICENSE("GPL v2");
408MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
diff --git a/drivers/pinctrl/vt8500/pinctrl-wm8850.c b/drivers/pinctrl/vt8500/pinctrl-wm8850.c
index f232b163c735..45792aa7a06e 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wm8850.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wm8850.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/init.h>
18#include <linux/pinctrl/pinctrl.h> 18#include <linux/pinctrl/pinctrl.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
@@ -360,11 +360,6 @@ static int wm8850_pinctrl_probe(struct platform_device *pdev)
360 return wmt_pinctrl_probe(pdev, data); 360 return wmt_pinctrl_probe(pdev, data);
361} 361}
362 362
363static int wm8850_pinctrl_remove(struct platform_device *pdev)
364{
365 return wmt_pinctrl_remove(pdev);
366}
367
368static const struct of_device_id wmt_pinctrl_of_match[] = { 363static const struct of_device_id wmt_pinctrl_of_match[] = {
369 { .compatible = "wm,wm8850-pinctrl" }, 364 { .compatible = "wm,wm8850-pinctrl" },
370 { /* sentinel */ }, 365 { /* sentinel */ },
@@ -372,16 +367,10 @@ static const struct of_device_id wmt_pinctrl_of_match[] = {
372 367
373static struct platform_driver wmt_pinctrl_driver = { 368static struct platform_driver wmt_pinctrl_driver = {
374 .probe = wm8850_pinctrl_probe, 369 .probe = wm8850_pinctrl_probe,
375 .remove = wm8850_pinctrl_remove,
376 .driver = { 370 .driver = {
377 .name = "pinctrl-wm8850", 371 .name = "pinctrl-wm8850",
378 .of_match_table = wmt_pinctrl_of_match, 372 .of_match_table = wmt_pinctrl_of_match,
373 .suppress_bind_attrs = true,
379 }, 374 },
380}; 375};
381 376builtin_platform_driver(wmt_pinctrl_driver);
382module_platform_driver(wmt_pinctrl_driver);
383
384MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
385MODULE_DESCRIPTION("Wondermedia WM8850 Pincontrol driver");
386MODULE_LICENSE("GPL v2");
387MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c
index cbc638631678..270ca2a47a8c 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wmt.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c
@@ -18,7 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/module.h>
22#include <linux/of.h> 21#include <linux/of.h>
23#include <linux/of_irq.h> 22#include <linux/of_irq.h>
24#include <linux/pinctrl/consumer.h> 23#include <linux/pinctrl/consumer.h>
@@ -608,12 +607,3 @@ fail_range:
608 gpiochip_remove(&data->gpio_chip); 607 gpiochip_remove(&data->gpio_chip);
609 return err; 608 return err;
610} 609}
611
612int wmt_pinctrl_remove(struct platform_device *pdev)
613{
614 struct wmt_pinctrl_data *data = platform_get_drvdata(pdev);
615
616 gpiochip_remove(&data->gpio_chip);
617
618 return 0;
619}
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.h b/drivers/pinctrl/vt8500/pinctrl-wmt.h
index 41f5f2deb5d6..885613396fe7 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wmt.h
+++ b/drivers/pinctrl/vt8500/pinctrl-wmt.h
@@ -76,4 +76,3 @@ struct wmt_pinctrl_data {
76 76
77int wmt_pinctrl_probe(struct platform_device *pdev, 77int wmt_pinctrl_probe(struct platform_device *pdev,
78 struct wmt_pinctrl_data *data); 78 struct wmt_pinctrl_data *data);
79int wmt_pinctrl_remove(struct platform_device *pdev);
diff --git a/include/dt-bindings/gpio/meson-gxl-gpio.h b/include/dt-bindings/gpio/meson-gxl-gpio.h
new file mode 100644
index 000000000000..684d0d7add1c
--- /dev/null
+++ b/include/dt-bindings/gpio/meson-gxl-gpio.h
@@ -0,0 +1,131 @@
1/*
2 * GPIO definitions for Amlogic Meson GXL SoCs
3 *
4 * Copyright (C) 2016 Endless Mobile, Inc.
5 * Author: Carlo Caione <carlo@endlessm.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14
15#ifndef _DT_BINDINGS_MESON_GXL_GPIO_H
16#define _DT_BINDINGS_MESON_GXL_GPIO_H
17
18#define GPIOAO_0 0
19#define GPIOAO_1 1
20#define GPIOAO_2 2
21#define GPIOAO_3 3
22#define GPIOAO_4 4
23#define GPIOAO_5 5
24#define GPIOAO_6 6
25#define GPIOAO_7 7
26#define GPIOAO_8 8
27#define GPIOAO_9 9
28
29#define GPIOZ_0 0
30#define GPIOZ_1 1
31#define GPIOZ_2 2
32#define GPIOZ_3 3
33#define GPIOZ_4 4
34#define GPIOZ_5 5
35#define GPIOZ_6 6
36#define GPIOZ_7 7
37#define GPIOZ_8 8
38#define GPIOZ_9 9
39#define GPIOZ_10 10
40#define GPIOZ_11 11
41#define GPIOZ_12 12
42#define GPIOZ_13 13
43#define GPIOZ_14 14
44#define GPIOZ_15 15
45#define GPIOH_0 16
46#define GPIOH_1 17
47#define GPIOH_2 18
48#define GPIOH_3 19
49#define GPIOH_4 20
50#define GPIOH_5 21
51#define GPIOH_6 22
52#define GPIOH_7 23
53#define GPIOH_8 24
54#define GPIOH_9 25
55#define BOOT_0 26
56#define BOOT_1 27
57#define BOOT_2 28
58#define BOOT_3 29
59#define BOOT_4 30
60#define BOOT_5 31
61#define BOOT_6 32
62#define BOOT_7 33
63#define BOOT_8 34
64#define BOOT_9 35
65#define BOOT_10 36
66#define BOOT_11 37
67#define BOOT_12 38
68#define BOOT_13 39
69#define BOOT_14 40
70#define BOOT_15 41
71#define CARD_0 42
72#define CARD_1 43
73#define CARD_2 44
74#define CARD_3 45
75#define CARD_4 46
76#define CARD_5 47
77#define CARD_6 48
78#define GPIODV_0 49
79#define GPIODV_1 50
80#define GPIODV_2 51
81#define GPIODV_3 52
82#define GPIODV_4 53
83#define GPIODV_5 54
84#define GPIODV_6 55
85#define GPIODV_7 56
86#define GPIODV_8 57
87#define GPIODV_9 58
88#define GPIODV_10 59
89#define GPIODV_11 60
90#define GPIODV_12 61
91#define GPIODV_13 62
92#define GPIODV_14 63
93#define GPIODV_15 64
94#define GPIODV_16 65
95#define GPIODV_17 66
96#define GPIODV_18 67
97#define GPIODV_19 68
98#define GPIODV_20 69
99#define GPIODV_21 70
100#define GPIODV_22 71
101#define GPIODV_23 72
102#define GPIODV_24 73
103#define GPIODV_25 74
104#define GPIODV_26 75
105#define GPIODV_27 76
106#define GPIODV_28 77
107#define GPIODV_29 78
108#define GPIOX_0 79
109#define GPIOX_1 80
110#define GPIOX_2 81
111#define GPIOX_3 82
112#define GPIOX_4 83
113#define GPIOX_5 84
114#define GPIOX_6 85
115#define GPIOX_7 86
116#define GPIOX_8 87
117#define GPIOX_9 88
118#define GPIOX_10 89
119#define GPIOX_11 90
120#define GPIOX_12 91
121#define GPIOX_13 92
122#define GPIOX_14 93
123#define GPIOX_15 94
124#define GPIOX_16 95
125#define GPIOX_17 96
126#define GPIOX_18 97
127#define GPIOCLK_0 98
128#define GPIOCLK_1 99
129#define GPIO_TEST_N 100
130
131#endif
diff --git a/include/dt-bindings/pinctrl/at91.h b/include/dt-bindings/pinctrl/at91.h
index bbca3d038900..2732d6c0fb39 100644
--- a/include/dt-bindings/pinctrl/at91.h
+++ b/include/dt-bindings/pinctrl/at91.h
@@ -15,6 +15,8 @@
15#define AT91_PINCTRL_DEGLITCH (1 << 2) 15#define AT91_PINCTRL_DEGLITCH (1 << 2)
16#define AT91_PINCTRL_PULL_DOWN (1 << 3) 16#define AT91_PINCTRL_PULL_DOWN (1 << 3)
17#define AT91_PINCTRL_DIS_SCHMIT (1 << 4) 17#define AT91_PINCTRL_DIS_SCHMIT (1 << 4)
18#define AT91_PINCTRL_OUTPUT (1 << 7)
19#define AT91_PINCTRL_OUTPUT_VAL(x) ((x & 0x1) << 8)
18#define AT91_PINCTRL_DEBOUNCE (1 << 16) 20#define AT91_PINCTRL_DEBOUNCE (1 << 16)
19#define AT91_PINCTRL_DEBOUNCE_VAL(x) (x << 17) 21#define AT91_PINCTRL_DEBOUNCE_VAL(x) (x << 17)
20 22