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