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/pinctrl/pinctrl.h>
18 #include "pinctrl-mvebu.h"
20 static struct mvebu_mpp_mode armada_ap806_mpp_modes
[] = {
22 MPP_FUNCTION(0, "gpio", NULL
),
23 MPP_FUNCTION(1, "sdio", "clk"),
24 MPP_FUNCTION(3, "spi0", "clk")),
26 MPP_FUNCTION(0, "gpio", NULL
),
27 MPP_FUNCTION(1, "sdio", "cmd"),
28 MPP_FUNCTION(3, "spi0", "miso")),
30 MPP_FUNCTION(0, "gpio", NULL
),
31 MPP_FUNCTION(1, "sdio", "d0"),
32 MPP_FUNCTION(3, "spi0", "mosi")),
34 MPP_FUNCTION(0, "gpio", NULL
),
35 MPP_FUNCTION(1, "sdio", "d1"),
36 MPP_FUNCTION(3, "spi0", "cs0n")),
38 MPP_FUNCTION(0, "gpio", NULL
),
39 MPP_FUNCTION(1, "sdio", "d2"),
40 MPP_FUNCTION(3, "i2c0", "sda")),
42 MPP_FUNCTION(0, "gpio", NULL
),
43 MPP_FUNCTION(1, "sdio", "d3"),
44 MPP_FUNCTION(3, "i2c0", "sdk")),
46 MPP_FUNCTION(0, "gpio", NULL
),
47 MPP_FUNCTION(1, "sdio", "ds")),
49 MPP_FUNCTION(0, "gpio", NULL
),
50 MPP_FUNCTION(1, "sdio", "d4"),
51 MPP_FUNCTION(3, "uart1", "rxd")),
53 MPP_FUNCTION(0, "gpio", NULL
),
54 MPP_FUNCTION(1, "sdio", "d5"),
55 MPP_FUNCTION(3, "uart1", "txd")),
57 MPP_FUNCTION(0, "gpio", NULL
),
58 MPP_FUNCTION(1, "sdio", "d6"),
59 MPP_FUNCTION(3, "spi0", "cs1n")),
61 MPP_FUNCTION(0, "gpio", NULL
),
62 MPP_FUNCTION(1, "sdio", "d7")),
64 MPP_FUNCTION(0, "gpio", NULL
),
65 MPP_FUNCTION(3, "uart0", "txd")),
67 MPP_FUNCTION(0, "gpio", NULL
),
68 MPP_FUNCTION(1, "sdio", "pw_off"),
69 MPP_FUNCTION(2, "sdio", "hw_rst")),
71 MPP_FUNCTION(0, "gpio", NULL
)),
73 MPP_FUNCTION(0, "gpio", NULL
)),
75 MPP_FUNCTION(0, "gpio", NULL
)),
77 MPP_FUNCTION(0, "gpio", NULL
)),
79 MPP_FUNCTION(0, "gpio", NULL
)),
81 MPP_FUNCTION(0, "gpio", NULL
)),
83 MPP_FUNCTION(0, "gpio", NULL
),
84 MPP_FUNCTION(3, "uart0", "rxd"),
85 MPP_FUNCTION(4, "sdio", "pw_off")),
88 static struct mvebu_pinctrl_soc_info armada_ap806_pinctrl_info
;
90 static const struct of_device_id armada_ap806_pinctrl_of_match
[] = {
92 .compatible
= "marvell,ap806-pinctrl",
97 static const struct mvebu_mpp_ctrl armada_ap806_mpp_controls
[] = {
98 MPP_FUNC_CTRL(0, 19, NULL
, mvebu_regmap_mpp_ctrl
),
101 static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges
[] = {
102 MPP_GPIO_RANGE(0, 0, 0, 20),
105 static int armada_ap806_pinctrl_probe(struct platform_device
*pdev
)
107 struct mvebu_pinctrl_soc_info
*soc
= &armada_ap806_pinctrl_info
;
109 if (!pdev
->dev
.parent
)
112 soc
->variant
= 0; /* no variants for Armada AP806 */
113 soc
->controls
= armada_ap806_mpp_controls
;
114 soc
->ncontrols
= ARRAY_SIZE(armada_ap806_mpp_controls
);
115 soc
->gpioranges
= armada_ap806_mpp_gpio_ranges
;
116 soc
->ngpioranges
= ARRAY_SIZE(armada_ap806_mpp_gpio_ranges
);
117 soc
->modes
= armada_ap806_mpp_modes
;
118 soc
->nmodes
= armada_ap806_mpp_controls
[0].npins
;
120 pdev
->dev
.platform_data
= soc
;
122 return mvebu_pinctrl_simple_regmap_probe(pdev
, pdev
->dev
.parent
, 0);
125 static struct platform_driver armada_ap806_pinctrl_driver
= {
127 .name
= "armada-ap806-pinctrl",
128 .of_match_table
= of_match_ptr(armada_ap806_pinctrl_of_match
),
130 .probe
= armada_ap806_pinctrl_probe
,
133 builtin_platform_driver(armada_ap806_pinctrl_driver
);