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