1d22bf40fSChen-Yu Tsai /*
2d22bf40fSChen-Yu Tsai  * Allwinner A23 SoCs special pins pinctrl driver.
3d22bf40fSChen-Yu Tsai  *
4d22bf40fSChen-Yu Tsai  * Copyright (C) 2014 Chen-Yu Tsai
5d22bf40fSChen-Yu Tsai  * Chen-Yu Tsai <wens@csie.org>
6d22bf40fSChen-Yu Tsai  *
7d22bf40fSChen-Yu Tsai  * Copyright (C) 2014 Boris Brezillon
8d22bf40fSChen-Yu Tsai  * Boris Brezillon <boris.brezillon@free-electrons.com>
9d22bf40fSChen-Yu Tsai  *
10d22bf40fSChen-Yu Tsai  * Copyright (C) 2014 Maxime Ripard
11d22bf40fSChen-Yu Tsai  * Maxime Ripard <maxime.ripard@free-electrons.com>
12d22bf40fSChen-Yu Tsai  *
13d22bf40fSChen-Yu Tsai  * This file is licensed under the terms of the GNU General Public
14d22bf40fSChen-Yu Tsai  * License version 2.  This program is licensed "as is" without any
15d22bf40fSChen-Yu Tsai  * warranty of any kind, whether express or implied.
16d22bf40fSChen-Yu Tsai  */
17d22bf40fSChen-Yu Tsai 
180c8c6ba0SPaul Gortmaker #include <linux/init.h>
19d22bf40fSChen-Yu Tsai #include <linux/platform_device.h>
20d22bf40fSChen-Yu Tsai #include <linux/of.h>
21d22bf40fSChen-Yu Tsai #include <linux/pinctrl/pinctrl.h>
22d22bf40fSChen-Yu Tsai 
23d22bf40fSChen-Yu Tsai #include "pinctrl-sunxi.h"
24d22bf40fSChen-Yu Tsai 
25d22bf40fSChen-Yu Tsai static const struct sunxi_desc_pin sun8i_a23_r_pins[] = {
26d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
27d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
28d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
29d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_rsb"),		/* SCK */
30059b0798SIcenowy Zheng 		  SUNXI_FUNCTION(0x3, "s_i2c"),		/* SCK */
31d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 0)),	/* PL_EINT0 */
32d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
33d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
34d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
35d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_rsb"),		/* SDA */
36059b0798SIcenowy Zheng 		  SUNXI_FUNCTION(0x3, "s_i2c"),		/* SDA */
37d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 1)),	/* PL_EINT1 */
38d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 2),
39d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
40d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
41d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_uart"),	/* TX */
42d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 2)),	/* PL_EINT2 */
43d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 3),
44d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
45d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
46d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_uart"),	/* RX */
47d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 3)),	/* PL_EINT3 */
48d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 4),
49d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
50d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
51d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x3, "s_jtag"),	/* MS */
52d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 4)),	/* PL_EINT4 */
53d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 5),
54d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
55d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
56d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x3, "s_jtag"),	/* CK */
57d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 5)),	/* PL_EINT5 */
58d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 6),
59d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
60d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
61d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x3, "s_jtag"),	/* DO */
62d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 6)),	/* PL_EINT6 */
63d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 7),
64d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
65d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
66d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x3, "s_jtag"),	/* DI */
67d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 7)),	/* PL_EINT7 */
68d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 8),
69d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
70d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
71d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_twi"),		/* SCK */
72d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 8)),	/* PL_EINT8 */
73d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 9),
74d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
75d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
76d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_twi"),		/* SDA */
77d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 9)),	/* PL_EINT9 */
78d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 10),
79d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
80d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
81d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x2, "s_pwm"),
82d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 10)),	/* PL_EINT10 */
83d22bf40fSChen-Yu Tsai 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 11),
84d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x0, "gpio_in"),
85d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION(0x1, "gpio_out"),
86d22bf40fSChen-Yu Tsai 		  SUNXI_FUNCTION_IRQ_BANK(0x4, 0, 11)),	/* PL_EINT11 */
87d22bf40fSChen-Yu Tsai };
88d22bf40fSChen-Yu Tsai 
89d22bf40fSChen-Yu Tsai static const struct sunxi_pinctrl_desc sun8i_a23_r_pinctrl_data = {
90d22bf40fSChen-Yu Tsai 	.pins = sun8i_a23_r_pins,
91d22bf40fSChen-Yu Tsai 	.npins = ARRAY_SIZE(sun8i_a23_r_pins),
92d22bf40fSChen-Yu Tsai 	.pin_base = PL_BASE,
93d22bf40fSChen-Yu Tsai 	.irq_banks = 1,
94cd70387fSMaxime Ripard 	.disable_strict_mode = true,
95d22bf40fSChen-Yu Tsai };
96d22bf40fSChen-Yu Tsai 
sun8i_a23_r_pinctrl_probe(struct platform_device * pdev)97d22bf40fSChen-Yu Tsai static int sun8i_a23_r_pinctrl_probe(struct platform_device *pdev)
98d22bf40fSChen-Yu Tsai {
99*59c15025SSamuel Holland 	return sunxi_pinctrl_init(pdev, &sun8i_a23_r_pinctrl_data);
100d22bf40fSChen-Yu Tsai }
101d22bf40fSChen-Yu Tsai 
102baa9946eSFabian Frederick static const struct of_device_id sun8i_a23_r_pinctrl_match[] = {
103d22bf40fSChen-Yu Tsai 	{ .compatible = "allwinner,sun8i-a23-r-pinctrl", },
104d22bf40fSChen-Yu Tsai 	{}
105d22bf40fSChen-Yu Tsai };
106d22bf40fSChen-Yu Tsai 
107d22bf40fSChen-Yu Tsai static struct platform_driver sun8i_a23_r_pinctrl_driver = {
108d22bf40fSChen-Yu Tsai 	.probe	= sun8i_a23_r_pinctrl_probe,
109d22bf40fSChen-Yu Tsai 	.driver	= {
110d22bf40fSChen-Yu Tsai 		.name		= "sun8i-a23-r-pinctrl",
111d22bf40fSChen-Yu Tsai 		.of_match_table	= sun8i_a23_r_pinctrl_match,
112d22bf40fSChen-Yu Tsai 	},
113d22bf40fSChen-Yu Tsai };
1140c8c6ba0SPaul Gortmaker builtin_platform_driver(sun8i_a23_r_pinctrl_driver);
115