1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Allwinner H616 R_PIO pin controller driver
4  *
5  * Copyright (C) 2020 Arm Ltd.
6  * Based on former work, which is:
7  *   Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
8  */
9 
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/of.h>
13 #include <linux/of_device.h>
14 #include <linux/pinctrl/pinctrl.h>
15 
16 #include "pinctrl-sunxi.h"
17 
18 static const struct sunxi_desc_pin sun50i_h616_r_pins[] = {
19 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
20 		  SUNXI_FUNCTION(0x0, "gpio_in"),
21 		  SUNXI_FUNCTION(0x1, "gpio_out"),
22 		  SUNXI_FUNCTION(0x2, "s_rsb"),		/* SCK */
23 		  SUNXI_FUNCTION(0x3, "s_i2c")),	/* SCK */
24 	SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
25 		  SUNXI_FUNCTION(0x0, "gpio_in"),
26 		  SUNXI_FUNCTION(0x1, "gpio_out"),
27 		  SUNXI_FUNCTION(0x2, "s_rsb"),		/* SDA */
28 		  SUNXI_FUNCTION(0x3, "s_i2c")),	/* SDA */
29 };
30 
31 static const struct sunxi_pinctrl_desc sun50i_h616_r_pinctrl_data = {
32 	.pins = sun50i_h616_r_pins,
33 	.npins = ARRAY_SIZE(sun50i_h616_r_pins),
34 	.pin_base = PL_BASE,
35 };
36 
37 static int sun50i_h616_r_pinctrl_probe(struct platform_device *pdev)
38 {
39 	return sunxi_pinctrl_init(pdev,
40 				  &sun50i_h616_r_pinctrl_data);
41 }
42 
43 static const struct of_device_id sun50i_h616_r_pinctrl_match[] = {
44 	{ .compatible = "allwinner,sun50i-h616-r-pinctrl", },
45 	{}
46 };
47 
48 static struct platform_driver sun50i_h616_r_pinctrl_driver = {
49 	.probe	= sun50i_h616_r_pinctrl_probe,
50 	.driver	= {
51 		.name		= "sun50i-h616-r-pinctrl",
52 		.of_match_table	= sun50i_h616_r_pinctrl_match,
53 	},
54 };
55 builtin_platform_driver(sun50i_h616_r_pinctrl_driver);
56