2 * Marvell Armada ap806 pinctrl driver based on mvebu pinctrl core
4 * Copyright (C) 2017 Marvell
6 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 * Hanna Hawa <hannah@marvell.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include <linux/err.h>
16 #include <linux/init.h>
18 #include <linux/platform_device.h>
20 #include <linux/of_device.h>
21 #include <linux/pinctrl/pinctrl.h>
23 #include "pinctrl-mvebu.h"
25 static struct mvebu_mpp_mode armada_ap806_mpp_modes
[] = {
27 MPP_FUNCTION(0, "gpio", NULL
),
28 MPP_FUNCTION(1, "sdio", "clk"),
29 MPP_FUNCTION(3, "spi0", "clk")),
31 MPP_FUNCTION(0, "gpio", NULL
),
32 MPP_FUNCTION(1, "sdio", "cmd"),
33 MPP_FUNCTION(3, "spi0", "miso")),
35 MPP_FUNCTION(0, "gpio", NULL
),
36 MPP_FUNCTION(1, "sdio", "d0"),
37 MPP_FUNCTION(3, "spi0", "mosi")),
39 MPP_FUNCTION(0, "gpio", NULL
),
40 MPP_FUNCTION(1, "sdio", "d1"),
41 MPP_FUNCTION(3, "spi0", "cs0n")),
43 MPP_FUNCTION(0, "gpio", NULL
),
44 MPP_FUNCTION(1, "sdio", "d2"),
45 MPP_FUNCTION(3, "i2c0", "sda")),
47 MPP_FUNCTION(0, "gpio", NULL
),
48 MPP_FUNCTION(1, "sdio", "d3"),
49 MPP_FUNCTION(3, "i2c0", "sdk")),
51 MPP_FUNCTION(0, "gpio", NULL
),
52 MPP_FUNCTION(1, "sdio", "ds")),
54 MPP_FUNCTION(0, "gpio", NULL
),
55 MPP_FUNCTION(1, "sdio", "d4"),
56 MPP_FUNCTION(3, "uart1", "rxd")),
58 MPP_FUNCTION(0, "gpio", NULL
),
59 MPP_FUNCTION(1, "sdio", "d5"),
60 MPP_FUNCTION(3, "uart1", "txd")),
62 MPP_FUNCTION(0, "gpio", NULL
),
63 MPP_FUNCTION(1, "sdio", "d6"),
64 MPP_FUNCTION(3, "spi0", "cs1n")),
66 MPP_FUNCTION(0, "gpio", NULL
),
67 MPP_FUNCTION(1, "sdio", "d7")),
69 MPP_FUNCTION(0, "gpio", NULL
),
70 MPP_FUNCTION(3, "uart0", "txd")),
72 MPP_FUNCTION(0, "gpio", NULL
),
73 MPP_FUNCTION(1, "sdio", "pw_off"),
74 MPP_FUNCTION(2, "sdio", "hw_rst")),
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
)),
86 MPP_FUNCTION(0, "gpio", NULL
)),
88 MPP_FUNCTION(0, "gpio", NULL
),
89 MPP_FUNCTION(3, "uart0", "rxd"),
90 MPP_FUNCTION(4, "sdio", "pw_off")),
93 static struct mvebu_pinctrl_soc_info armada_ap806_pinctrl_info
;
95 static const struct of_device_id armada_ap806_pinctrl_of_match
[] = {
97 .compatible
= "marvell,ap806-pinctrl",
102 static const struct mvebu_mpp_ctrl armada_ap806_mpp_controls
[] = {
103 MPP_FUNC_CTRL(0, 19, NULL
, mvebu_regmap_mpp_ctrl
),
106 static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges
[] = {
107 MPP_GPIO_RANGE(0, 0, 0, 20),
110 static int armada_ap806_pinctrl_probe(struct platform_device
*pdev
)
112 struct mvebu_pinctrl_soc_info
*soc
= &armada_ap806_pinctrl_info
;
113 const struct of_device_id
*match
=
114 of_match_device(armada_ap806_pinctrl_of_match
, &pdev
->dev
);
116 if (!match
|| !pdev
->dev
.parent
)
119 soc
->variant
= 0; /* no variants for Armada AP806 */
120 soc
->controls
= armada_ap806_mpp_controls
;
121 soc
->ncontrols
= ARRAY_SIZE(armada_ap806_mpp_controls
);
122 soc
->gpioranges
= armada_ap806_mpp_gpio_ranges
;
123 soc
->ngpioranges
= ARRAY_SIZE(armada_ap806_mpp_gpio_ranges
);
124 soc
->modes
= armada_ap806_mpp_modes
;
125 soc
->nmodes
= armada_ap806_mpp_controls
[0].npins
;
127 pdev
->dev
.platform_data
= soc
;
129 return mvebu_pinctrl_simple_regmap_probe(pdev
, pdev
->dev
.parent
, 0);
132 static struct platform_driver armada_ap806_pinctrl_driver
= {
134 .name
= "armada-ap806-pinctrl",
135 .of_match_table
= of_match_ptr(armada_ap806_pinctrl_of_match
),
137 .probe
= armada_ap806_pinctrl_probe
,
140 builtin_platform_driver(armada_ap806_pinctrl_driver
);