GNU Linux-libre 5.13.14-gnu1
[releases.git] / drivers / pinctrl / sunxi / pinctrl-sun50i-h616-r.c
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 #include <linux/reset.h>
16
17 #include "pinctrl-sunxi.h"
18
19 static const struct sunxi_desc_pin sun50i_h616_r_pins[] = {
20         SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 0),
21                   SUNXI_FUNCTION(0x0, "gpio_in"),
22                   SUNXI_FUNCTION(0x1, "gpio_out"),
23                   SUNXI_FUNCTION(0x2, "s_rsb"),         /* SCK */
24                   SUNXI_FUNCTION(0x3, "s_i2c")),        /* SCK */
25         SUNXI_PIN(SUNXI_PINCTRL_PIN(L, 1),
26                   SUNXI_FUNCTION(0x0, "gpio_in"),
27                   SUNXI_FUNCTION(0x1, "gpio_out"),
28                   SUNXI_FUNCTION(0x2, "s_rsb"),         /* SDA */
29                   SUNXI_FUNCTION(0x3, "s_i2c")),        /* SDA */
30 };
31
32 static const struct sunxi_pinctrl_desc sun50i_h616_r_pinctrl_data = {
33         .pins = sun50i_h616_r_pins,
34         .npins = ARRAY_SIZE(sun50i_h616_r_pins),
35         .pin_base = PL_BASE,
36 };
37
38 static int sun50i_h616_r_pinctrl_probe(struct platform_device *pdev)
39 {
40         return sunxi_pinctrl_init(pdev,
41                                   &sun50i_h616_r_pinctrl_data);
42 }
43
44 static const struct of_device_id sun50i_h616_r_pinctrl_match[] = {
45         { .compatible = "allwinner,sun50i-h616-r-pinctrl", },
46         {}
47 };
48
49 static struct platform_driver sun50i_h616_r_pinctrl_driver = {
50         .probe  = sun50i_h616_r_pinctrl_probe,
51         .driver = {
52                 .name           = "sun50i-h616-r-pinctrl",
53                 .of_match_table = sun50i_h616_r_pinctrl_match,
54         },
55 };
56 builtin_platform_driver(sun50i_h616_r_pinctrl_driver);