aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLevin Du <djw@t-chip.com.cn>2018-07-31 01:59:19 -0400
committerLinus Walleij <linus.walleij@linaro.org>2018-08-06 17:46:55 -0400
commitcf2ff877a4eea5f5ad959050284eb93d5d2f803a (patch)
tree9bc792a851fe0f965bf1b530dbe12082ea45f818
parent442af1403a2886f8f6d43f2f67f8a8b001e048d8 (diff)
gpio: syscon: rockchip: add GRF GPIO support for rk3328
In Rockchip RK3328, the output only GPIO_MUTE pin, originally for codec mute control, can also be used for general purpose. It is manipulated by the GRF_SOC_CON10 register in GRF. Aside from the GPIO_MUTE pin, the HDMI pins can also be set in the same way. Currently this GRF GPIO controller only supports the mute pin. If needed in the future, the HDMI pins support can also be added. Signed-off-by: Levin Du <djw@t-chip.com.cn> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.txt32
-rw-r--r--drivers/gpio/gpio-syscon.c31
2 files changed, 63 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.txt b/Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.txt
new file mode 100644
index 000000000000..f9231df17c2b
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.txt
@@ -0,0 +1,32 @@
1Rockchip RK3328 GRF (General Register Files) GPIO controller.
2
3In Rockchip RK3328, the output only GPIO_MUTE pin, originally for codec mute
4control, can also be used for general purpose. It is manipulated by the
5GRF_SOC_CON10 register in GRF. Aside from the GPIO_MUTE pin, the HDMI pins can
6also be set in the same way.
7
8Currently this GPIO controller only supports the mute pin. If needed in the
9future, the HDMI pins support can also be added.
10
11Required properties:
12- compatible: Should contain "rockchip,rk3328-grf-gpio".
13- gpio-controller: Marks the device node as a gpio controller.
14- #gpio-cells: Should be 2. The first cell is the pin number and
15 the second cell is used to specify the gpio polarity:
16 0 = Active high,
17 1 = Active low.
18
19Example:
20
21 grf: syscon@ff100000 {
22 compatible = "rockchip,rk3328-grf", "syscon", "simple-mfd";
23
24 grf_gpio: grf-gpio {
25 compatible = "rockchip,rk3328-grf-gpio";
26 gpio-controller;
27 #gpio-cells = <2>;
28 };
29 };
30
31Note: The grf_gpio node should be declared as the child of the GRF (General
32Register File) node. The GPIO_MUTE pin is referred to as <&grf_gpio 0>.
diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index d40cabd15e9e..87c18a544513 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -135,6 +135,33 @@ static const struct syscon_gpio_data clps711x_mctrl_gpio = {
135 .dat_bit_offset = 0x40 * 8 + 8, 135 .dat_bit_offset = 0x40 * 8 + 8,
136}; 136};
137 137
138static void rockchip_gpio_set(struct gpio_chip *chip, unsigned int offset,
139 int val)
140{
141 struct syscon_gpio_priv *priv = gpiochip_get_data(chip);
142 unsigned int offs;
143 u8 bit;
144 u32 data;
145 int ret;
146
147 offs = priv->dreg_offset + priv->data->dat_bit_offset + offset;
148 bit = offs % SYSCON_REG_BITS;
149 data = (val ? BIT(bit) : 0) | BIT(bit + 16);
150 ret = regmap_write(priv->syscon,
151 (offs / SYSCON_REG_BITS) * SYSCON_REG_SIZE,
152 data);
153 if (ret < 0)
154 dev_err(chip->parent, "gpio write failed ret(%d)\n", ret);
155}
156
157static const struct syscon_gpio_data rockchip_rk3328_gpio_mute = {
158 /* RK3328 GPIO_MUTE is an output only pin at GRF_SOC_CON10[1] */
159 .flags = GPIO_SYSCON_FEAT_OUT,
160 .bit_count = 1,
161 .dat_bit_offset = 0x0428 * 8 + 1,
162 .set = rockchip_gpio_set,
163};
164
138#define KEYSTONE_LOCK_BIT BIT(0) 165#define KEYSTONE_LOCK_BIT BIT(0)
139 166
140static void keystone_gpio_set(struct gpio_chip *chip, unsigned offset, int val) 167static void keystone_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
@@ -175,6 +202,10 @@ static const struct of_device_id syscon_gpio_ids[] = {
175 .compatible = "ti,keystone-dsp-gpio", 202 .compatible = "ti,keystone-dsp-gpio",
176 .data = &keystone_dsp_gpio, 203 .data = &keystone_dsp_gpio,
177 }, 204 },
205 {
206 .compatible = "rockchip,rk3328-grf-gpio",
207 .data = &rockchip_rk3328_gpio_mute,
208 },
178 { } 209 { }
179}; 210};
180MODULE_DEVICE_TABLE(of, syscon_gpio_ids); 211MODULE_DEVICE_TABLE(of, syscon_gpio_ids);