1b016d1bdSAntoine Tenart /*
2b016d1bdSAntoine Tenart  * Marvell Berlin BG2 pinctrl driver.
3b016d1bdSAntoine Tenart  *
4b016d1bdSAntoine Tenart  * Copyright (C) 2014 Marvell Technology Group Ltd.
5b016d1bdSAntoine Tenart  *
6b016d1bdSAntoine Tenart  * Antoine Ténart <antoine.tenart@free-electrons.com>
7b016d1bdSAntoine Tenart  *
8b016d1bdSAntoine Tenart  * This file is licensed under the terms of the GNU General Public
9b016d1bdSAntoine Tenart  * License version 2. This program is licensed "as is" without any
10b016d1bdSAntoine Tenart  * warranty of any kind, whether express or implied.
11b016d1bdSAntoine Tenart  */
12b016d1bdSAntoine Tenart 
13b016d1bdSAntoine Tenart #include <linux/module.h>
14b016d1bdSAntoine Tenart #include <linux/of_device.h>
15b016d1bdSAntoine Tenart #include <linux/platform_device.h>
16b016d1bdSAntoine Tenart #include <linux/regmap.h>
17b016d1bdSAntoine Tenart 
18b016d1bdSAntoine Tenart #include "berlin.h"
19b016d1bdSAntoine Tenart 
20b016d1bdSAntoine Tenart static const struct berlin_desc_group berlin2_soc_pinctrl_groups[] = {
21b016d1bdSAntoine Tenart 	/* G */
22b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G0", 0x00, 0x1, 0x00,
232e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */
24b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "gpio")),
25b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G1", 0x00, 0x2, 0x01,
262e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */
27b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "gpio"),
28b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "usb1")),
29b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G2", 0x00, 0x2, 0x02,
30b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
312e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS2n */
32b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "pwm"),
33b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "i2s0")),
34b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G3", 0x00, 0x2, 0x04,
35b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "soc"),
362e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS3n */
37b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "gpio"),
38b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "i2s1")),
39b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G4", 0x00, 0x2, 0x06,
402e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* CLK/SDI/SDO */
41b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "gpio"),
42b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "pwm")),
43b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G5", 0x00, 0x3, 0x08,
44b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
45b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sts1"),
46b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et"),
47b016d1bdSAntoine Tenart 		/*
48b016d1bdSAntoine Tenart 		 * Mode 0x3 mux i2s2 mclk *and* i2s3 mclk:
49b016d1bdSAntoine Tenart 		 * add two functions so it can be used with other groups
50b016d1bdSAntoine Tenart 		 * within the same subnode in the device tree
51b016d1bdSAntoine Tenart 		 */
52b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "i2s2"),
53b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "i2s3")),
54b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G6", 0x00, 0x2, 0x0b,
55b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
56b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sts0"),
57b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et")),
58b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G7", 0x00, 0x3, 0x0d,
59b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
60b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sts0"),
61b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et"),
62b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "vdac")),
63b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G8", 0x00, 0x3, 0x10,
64b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
65b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sd0"),
66b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et"),
67b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"),
68b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "sata_dbg"),
69b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")),
70b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G9", 0x00, 0x3, 0x13,
71b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
72b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sd0"),
73b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et"),
74b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"),
75b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "sata_dbg"),
76b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")),
77b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G10", 0x00, 0x2, 0x16,
78b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "soc"),
79b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "twsi0"),
80b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "gpio"),
81b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "ptp")),
82b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G11", 0x00, 0x2, 0x18,
83b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "soc"),
84b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "twsi1"),
85b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "gpio"),
86b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "eddc")),
87b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G12", 0x00, 0x3, 0x1a,
88b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "sts2"),
89b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sata"),
90b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "sd1"),
91b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"),
92b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "sts1"),
93b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")),
94b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G13", 0x04, 0x3, 0x00,
95b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
96b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "sata"),
97b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "sd1"),
98b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"),
99b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "sts1"),
100b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")),
101b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G14", 0x04, 0x1, 0x03,
102b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION_UNKNOWN),
103b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G15", 0x04, 0x2, 0x04,
104b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
105b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "et"),
106b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "osco")),
107b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G16", 0x04, 0x3, 0x06,
108b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
109b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "dvio"),
110b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "fp")),
111b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G17", 0x04, 0x3, 0x09,
112b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
113b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "dvio"),
114b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "fp")),
115b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G18", 0x04, 0x1, 0x0c,
116b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "pll"),
117b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "i2s0")),
118b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G19", 0x04, 0x1, 0x0d,
119b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "i2s0"),
120b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "pwm")),
121b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G20", 0x04, 0x1, 0x0e,
122b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "spdif"),
123b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "arc")),
124b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G21", 0x04, 0x3, 0x0f,
125b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
126b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "dvio"),
127b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "fp"),
128b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "adac_dbg"),
129b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "pdm_a"),	/* gpio17..19,pdm */
130b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "pdm_b")),	/* gpio12..14,pdm */
131b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G22", 0x04, 0x3, 0x12,
132b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
133b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "dv0"),
134b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "fp"),
135b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "twsi0"),
136b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "pwm")),
137b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G23", 0x04, 0x3, 0x15,
138b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "vclki"),
139b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "dv0"),
140b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "fp"),
141b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "i2s0"),
142b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x4, "pwm"),
143b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x7, "pdm")),
144b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G24", 0x04, 0x2, 0x18,
145b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "i2s2"),
146b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "i2s1")),
147b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G25", 0x04, 0x2, 0x1a,
148b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
149b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "nand"),
150b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "i2s2")),
151b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G26", 0x04, 0x1, 0x1c,
152b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "nand"),
153b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "emmc")),
154b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G27", 0x04, 0x1, 0x1d,
155b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
156b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "nand")),
157b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("G28", 0x04, 0x2, 0x1e,
158b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "dvo"),
159b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "sp")),
160b016d1bdSAntoine Tenart };
161b016d1bdSAntoine Tenart 
162b016d1bdSAntoine Tenart static const struct berlin_desc_group berlin2_sysmgr_pinctrl_groups[] = {
163b016d1bdSAntoine Tenart 	/* GSM */
164b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM0", 0x40, 0x2, 0x00,
165b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
1662e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS0n */
167b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "eth1")),
168b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM1", 0x40, 0x2, 0x02,
169b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
1702e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS1n */
171b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "eth1")),
172b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM2", 0x40, 0x2, 0x04,
173b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "twsi2"),
1742e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi2")), /* SS2n/SS3n */
175b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM3", 0x40, 0x2, 0x06,
176b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
177b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "uart0"),	/* CTS/RTS */
178b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "uart2"),	/* RX/TX */
179b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "twsi2")),
180b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM4", 0x40, 0x2, 0x08,
181b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "uart0"),	/* RX/TX */
182b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "irda0")),
183b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM5", 0x40, 0x2, 0x0a,
184b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
185b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "uart1"),	/* RX/TX */
186b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x2, "irda1"),
187b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x3, "twsi3")),
188b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM6", 0x40, 0x2, 0x0c,
189b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
1902e89f4c3SAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* CLK/SDO */
191b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "clki")),
192b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM7", 0x40, 0x1, 0x0e,
193b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
194b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")),
195b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM8", 0x40, 0x1, 0x0f,
196b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
197b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")),
198b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM9", 0x40, 0x1, 0x10,
199b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
200b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "led")),
201b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM10", 0x40, 0x1, 0x11,
202b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
203b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "led")),
204b016d1bdSAntoine Tenart 	BERLIN_PINCTRL_GROUP("GSM11", 0x40, 0x1, 0x12,
205b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x0, "gpio"),
206b016d1bdSAntoine Tenart 		BERLIN_PINCTRL_FUNCTION(0x1, "led")),
207b016d1bdSAntoine Tenart };
208b016d1bdSAntoine Tenart 
209b016d1bdSAntoine Tenart static const struct berlin_pinctrl_desc berlin2_soc_pinctrl_data = {
210b016d1bdSAntoine Tenart 	.groups = berlin2_soc_pinctrl_groups,
211b016d1bdSAntoine Tenart 	.ngroups = ARRAY_SIZE(berlin2_soc_pinctrl_groups),
212b016d1bdSAntoine Tenart };
213b016d1bdSAntoine Tenart 
214b016d1bdSAntoine Tenart static const struct berlin_pinctrl_desc berlin2_sysmgr_pinctrl_data = {
215b016d1bdSAntoine Tenart 	.groups = berlin2_sysmgr_pinctrl_groups,
216b016d1bdSAntoine Tenart 	.ngroups = ARRAY_SIZE(berlin2_sysmgr_pinctrl_groups),
217b016d1bdSAntoine Tenart };
218b016d1bdSAntoine Tenart 
219b016d1bdSAntoine Tenart static const struct of_device_id berlin2_pinctrl_match[] = {
220b016d1bdSAntoine Tenart 	{
221b016d1bdSAntoine Tenart 		.compatible = "marvell,berlin2-chip-ctrl",
222b016d1bdSAntoine Tenart 		.data = &berlin2_soc_pinctrl_data
223b016d1bdSAntoine Tenart 	},
224b016d1bdSAntoine Tenart 	{
225b016d1bdSAntoine Tenart 		.compatible = "marvell,berlin2-system-ctrl",
226b016d1bdSAntoine Tenart 		.data = &berlin2_sysmgr_pinctrl_data
227b016d1bdSAntoine Tenart 	},
228b016d1bdSAntoine Tenart 	{}
229b016d1bdSAntoine Tenart };
230b016d1bdSAntoine Tenart MODULE_DEVICE_TABLE(of, berlin2_pinctrl_match);
231b016d1bdSAntoine Tenart 
232b016d1bdSAntoine Tenart static int berlin2_pinctrl_probe(struct platform_device *pdev)
233b016d1bdSAntoine Tenart {
234b016d1bdSAntoine Tenart 	const struct of_device_id *match =
235b016d1bdSAntoine Tenart 		of_match_device(berlin2_pinctrl_match, &pdev->dev);
236b016d1bdSAntoine Tenart 	struct regmap_config *rmconfig;
237b016d1bdSAntoine Tenart 	struct regmap *regmap;
238b016d1bdSAntoine Tenart 	struct resource *res;
239b016d1bdSAntoine Tenart 	void __iomem *base;
240b016d1bdSAntoine Tenart 
241b016d1bdSAntoine Tenart 	rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL);
242b016d1bdSAntoine Tenart 	if (!rmconfig)
243b016d1bdSAntoine Tenart 		return -ENOMEM;
244b016d1bdSAntoine Tenart 
245b016d1bdSAntoine Tenart 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
24649cfabc2SJingoo Han 	base = devm_ioremap_resource(&pdev->dev, res);
24749cfabc2SJingoo Han 	if (IS_ERR(base))
24849cfabc2SJingoo Han 		return PTR_ERR(base);
249b016d1bdSAntoine Tenart 
250b016d1bdSAntoine Tenart 	rmconfig->reg_bits = 32,
251b016d1bdSAntoine Tenart 	rmconfig->val_bits = 32,
252b016d1bdSAntoine Tenart 	rmconfig->reg_stride = 4,
253b016d1bdSAntoine Tenart 	rmconfig->max_register = resource_size(res);
254b016d1bdSAntoine Tenart 
255b016d1bdSAntoine Tenart 	regmap = devm_regmap_init_mmio(&pdev->dev, base, rmconfig);
256b016d1bdSAntoine Tenart 	if (IS_ERR(regmap))
257b016d1bdSAntoine Tenart 		return PTR_ERR(regmap);
258b016d1bdSAntoine Tenart 
259b016d1bdSAntoine Tenart 	return berlin_pinctrl_probe(pdev, match->data);
260b016d1bdSAntoine Tenart }
261b016d1bdSAntoine Tenart 
262b016d1bdSAntoine Tenart static struct platform_driver berlin2_pinctrl_driver = {
263b016d1bdSAntoine Tenart 	.probe	= berlin2_pinctrl_probe,
264b016d1bdSAntoine Tenart 	.driver	= {
265b016d1bdSAntoine Tenart 		.name = "berlin-bg2-pinctrl",
266b016d1bdSAntoine Tenart 		.of_match_table = berlin2_pinctrl_match,
267b016d1bdSAntoine Tenart 	},
268b016d1bdSAntoine Tenart };
269b016d1bdSAntoine Tenart module_platform_driver(berlin2_pinctrl_driver);
270b016d1bdSAntoine Tenart 
271b016d1bdSAntoine Tenart MODULE_AUTHOR("Antoine Ténart <antoine.tenart@free-electrons.com>");
272b016d1bdSAntoine Tenart MODULE_DESCRIPTION("Marvell Berlin BG2 pinctrl driver");
273b016d1bdSAntoine Tenart MODULE_LICENSE("GPL");
274