1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Marvell Armada ap806 pinctrl driver based on mvebu pinctrl core
5 * Copyright (C) 2017 Marvell
7 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
8 * Hanna Hawa <hannah@marvell.com>
11 #include <linux/err.h>
12 #include <linux/init.h>
14 #include <linux/platform_device.h>
16 #include <linux/of_device.h>
17 #include <linux/pinctrl/pinctrl.h>
19 #include "pinctrl-mvebu.h"
21 static struct mvebu_mpp_mode armada_ap806_mpp_modes
[] = {
23 MPP_FUNCTION(0, "gpio", NULL
),
24 MPP_FUNCTION(1, "sdio", "clk"),
25 MPP_FUNCTION(3, "spi0", "clk")),
27 MPP_FUNCTION(0, "gpio", NULL
),
28 MPP_FUNCTION(1, "sdio", "cmd"),
29 MPP_FUNCTION(3, "spi0", "miso")),
31 MPP_FUNCTION(0, "gpio", NULL
),
32 MPP_FUNCTION(1, "sdio", "d0"),
33 MPP_FUNCTION(3, "spi0", "mosi")),
35 MPP_FUNCTION(0, "gpio", NULL
),
36 MPP_FUNCTION(1, "sdio", "d1"),
37 MPP_FUNCTION(3, "spi0", "cs0n")),
39 MPP_FUNCTION(0, "gpio", NULL
),
40 MPP_FUNCTION(1, "sdio", "d2"),
41 MPP_FUNCTION(3, "i2c0", "sda")),
43 MPP_FUNCTION(0, "gpio", NULL
),
44 MPP_FUNCTION(1, "sdio", "d3"),
45 MPP_FUNCTION(3, "i2c0", "sdk")),
47 MPP_FUNCTION(0, "gpio", NULL
),
48 MPP_FUNCTION(1, "sdio", "ds")),
50 MPP_FUNCTION(0, "gpio", NULL
),
51 MPP_FUNCTION(1, "sdio", "d4"),
52 MPP_FUNCTION(3, "uart1", "rxd")),
54 MPP_FUNCTION(0, "gpio", NULL
),
55 MPP_FUNCTION(1, "sdio", "d5"),
56 MPP_FUNCTION(3, "uart1", "txd")),
58 MPP_FUNCTION(0, "gpio", NULL
),
59 MPP_FUNCTION(1, "sdio", "d6"),
60 MPP_FUNCTION(3, "spi0", "cs1n")),
62 MPP_FUNCTION(0, "gpio", NULL
),
63 MPP_FUNCTION(1, "sdio", "d7")),
65 MPP_FUNCTION(0, "gpio", NULL
),
66 MPP_FUNCTION(3, "uart0", "txd")),
68 MPP_FUNCTION(0, "gpio", NULL
),
69 MPP_FUNCTION(1, "sdio", "pw_off"),
70 MPP_FUNCTION(2, "sdio", "hw_rst")),
72 MPP_FUNCTION(0, "gpio", NULL
)),
74 MPP_FUNCTION(0, "gpio", NULL
)),
76 MPP_FUNCTION(0, "gpio", NULL
)),
78 MPP_FUNCTION(0, "gpio", NULL
)),
80 MPP_FUNCTION(0, "gpio", NULL
)),
82 MPP_FUNCTION(0, "gpio", NULL
)),
84 MPP_FUNCTION(0, "gpio", NULL
),
85 MPP_FUNCTION(3, "uart0", "rxd"),
86 MPP_FUNCTION(4, "sdio", "pw_off")),
89 static struct mvebu_pinctrl_soc_info armada_ap806_pinctrl_info
;
91 static const struct of_device_id armada_ap806_pinctrl_of_match
[] = {
93 .compatible
= "marvell,ap806-pinctrl",
98 static const struct mvebu_mpp_ctrl armada_ap806_mpp_controls
[] = {
99 MPP_FUNC_CTRL(0, 19, NULL
, mvebu_regmap_mpp_ctrl
),
102 static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges
[] = {
103 MPP_GPIO_RANGE(0, 0, 0, 20),
106 static int armada_ap806_pinctrl_probe(struct platform_device
*pdev
)
108 struct mvebu_pinctrl_soc_info
*soc
= &armada_ap806_pinctrl_info
;
109 const struct of_device_id
*match
=
110 of_match_device(armada_ap806_pinctrl_of_match
, &pdev
->dev
);
112 if (!match
|| !pdev
->dev
.parent
)
115 soc
->variant
= 0; /* no variants for Armada AP806 */
116 soc
->controls
= armada_ap806_mpp_controls
;
117 soc
->ncontrols
= ARRAY_SIZE(armada_ap806_mpp_controls
);
118 soc
->gpioranges
= armada_ap806_mpp_gpio_ranges
;
119 soc
->ngpioranges
= ARRAY_SIZE(armada_ap806_mpp_gpio_ranges
);
120 soc
->modes
= armada_ap806_mpp_modes
;
121 soc
->nmodes
= armada_ap806_mpp_controls
[0].npins
;
123 pdev
->dev
.platform_data
= soc
;
125 return mvebu_pinctrl_simple_regmap_probe(pdev
, pdev
->dev
.parent
, 0);
128 static struct platform_driver armada_ap806_pinctrl_driver
= {
130 .name
= "armada-ap806-pinctrl",
131 .of_match_table
= of_match_ptr(armada_ap806_pinctrl_of_match
),
133 .probe
= armada_ap806_pinctrl_probe
,
136 builtin_platform_driver(armada_ap806_pinctrl_driver
);