xref: /OK3568_Linux_fs/kernel/drivers/pinctrl/sunxi/pinctrl-sun50i-a100-r.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2020 Yangtao Li <frank@allwinnertech.com>
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Based on:
6*4882a593Smuzhiyun  * huangshuosheng <huangshuosheng@allwinnertech.com>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/module.h>
10*4882a593Smuzhiyun #include <linux/of.h>
11*4882a593Smuzhiyun #include <linux/of_device.h>
12*4882a593Smuzhiyun #include <linux/pinctrl/pinctrl.h>
13*4882a593Smuzhiyun #include <linux/platform_device.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include "pinctrl-sunxi.h"
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun static const struct sunxi_desc_pin a100_r_pins[] = {
18*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
19*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
20*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
21*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_i2c0"),	/* SCK */
22*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 0)),
23*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
24*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
25*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
26*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_i2c0"),	/* SDA */
27*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 1)),
28*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 2),
29*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
30*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
31*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_uart0"),	/* TX */
32*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 2)),
33*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 3),
34*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
35*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
36*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_uart0"),	/* RX */
37*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 3)),
38*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 4),
39*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
40*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
41*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_jtag"),	/* MS */
42*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 4)),
43*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 5),
44*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
45*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
46*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_jtag"),	/* CK */
47*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 5)),
48*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 6),
49*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
50*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
51*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_jtag"),	/* DO */
52*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 6)),
53*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 7),
54*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
55*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
56*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_jtag"),	/* DI */
57*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 7)),
58*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 8),
59*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
60*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
61*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_i2c1"),	/* SCK */
62*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 8)),
63*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 9),
64*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
65*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
66*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_i2c1"),	/* SDA */
67*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 9)),
68*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 10),
69*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
70*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
71*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x2, "s_pwm"),
72*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 10)),
73*4882a593Smuzhiyun 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 11),
74*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x0, "gpio_in"),
75*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x1, "gpio_out"),
76*4882a593Smuzhiyun 		  SUNXI_FUNCTION(0x3, "s_cir"),		/* IN */
77*4882a593Smuzhiyun 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 11)),
78*4882a593Smuzhiyun };
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun static const struct sunxi_pinctrl_desc a100_r_pinctrl_data = {
81*4882a593Smuzhiyun 	.pins = a100_r_pins,
82*4882a593Smuzhiyun 	.npins = ARRAY_SIZE(a100_r_pins),
83*4882a593Smuzhiyun 	.pin_base = PL_BASE,
84*4882a593Smuzhiyun 	.irq_banks = 1,
85*4882a593Smuzhiyun };
86*4882a593Smuzhiyun 
a100_r_pinctrl_probe(struct platform_device * pdev)87*4882a593Smuzhiyun static int a100_r_pinctrl_probe(struct platform_device *pdev)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun 	return sunxi_pinctrl_init(pdev, &a100_r_pinctrl_data);
90*4882a593Smuzhiyun }
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun static const struct of_device_id a100_r_pinctrl_match[] = {
93*4882a593Smuzhiyun 	{ .compatible = "allwinner,sun50i-a100-r-pinctrl", },
94*4882a593Smuzhiyun 	{}
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, a100_r_pinctrl_match);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun static struct platform_driver a100_r_pinctrl_driver = {
99*4882a593Smuzhiyun 	.probe	= a100_r_pinctrl_probe,
100*4882a593Smuzhiyun 	.driver	= {
101*4882a593Smuzhiyun 		.name		= "sun50i-a100-r-pinctrl",
102*4882a593Smuzhiyun 		.of_match_table	= a100_r_pinctrl_match,
103*4882a593Smuzhiyun 	},
104*4882a593Smuzhiyun };
105*4882a593Smuzhiyun module_platform_driver(a100_r_pinctrl_driver);
106