1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Intel Moorefield SoC pinctrl driver
4  *
5  * Copyright (C) 2022, Intel Corporation
6  * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7  */
8 
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/mod_devicetable.h>
12 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <linux/types.h>
15 
16 #include <linux/pinctrl/pinctrl.h>
17 
18 #include "pinctrl-tangier.h"
19 
20 static const struct pinctrl_pin_desc mofld_pins[] = {
21 	/* ULPI (13 pins) */
22 	PINCTRL_PIN(0, "GP101_ULPI_CLK"),
23 	PINCTRL_PIN(1, "GP136_ULPI_D0"),
24 	PINCTRL_PIN(2, "GP143_ULPI_D1"),
25 	PINCTRL_PIN(3, "GP144_ULPI_D2"),
26 	PINCTRL_PIN(4, "GP145_ULPI_D3"),
27 	PINCTRL_PIN(5, "GP146_ULPI_D4"),
28 	PINCTRL_PIN(6, "GP147_ULPI_D5"),
29 	PINCTRL_PIN(7, "GP148_ULPI_D6"),
30 	PINCTRL_PIN(8, "GP149_ULPI_D7"),
31 	PINCTRL_PIN(9, "ULPI_DIR"),
32 	PINCTRL_PIN(10, "ULPI_NXT"),
33 	PINCTRL_PIN(11, "ULPI_REFCLK"),
34 	PINCTRL_PIN(12, "ULPI_STP"),
35 	/* eMMC (12 pins) */
36 	PINCTRL_PIN(13, "EMMC_CLK"),
37 	PINCTRL_PIN(14, "EMMC_CMD"),
38 	PINCTRL_PIN(15, "EMMC_D0"),
39 	PINCTRL_PIN(16, "EMMC_D1"),
40 	PINCTRL_PIN(17, "EMMC_D2"),
41 	PINCTRL_PIN(18, "EMMC_D3"),
42 	PINCTRL_PIN(19, "EMMC_D4"),
43 	PINCTRL_PIN(20, "EMMC_D5"),
44 	PINCTRL_PIN(21, "EMMC_D6"),
45 	PINCTRL_PIN(22, "EMMC_D7"),
46 	PINCTRL_PIN(23, "EMMC_RST_N"),
47 	PINCTRL_PIN(24, "EMMC_RCLK"),
48 	/* SDIO (20 pins) */
49 	PINCTRL_PIN(25, "GP77_SD_CD"),
50 	PINCTRL_PIN(26, "GP78_SD_CLK"),
51 	PINCTRL_PIN(27, "GP79_SD_CMD"),
52 	PINCTRL_PIN(28, "GP80_SD_D0"),
53 	PINCTRL_PIN(29, "GP81_SD_D1"),
54 	PINCTRL_PIN(30, "GP82_SD_D2"),
55 	PINCTRL_PIN(31, "GP83_SD_D3"),
56 	PINCTRL_PIN(32, "GP84_SD_LS_CLK_FB"),
57 	PINCTRL_PIN(33, "GP85_SD_LS_CMD_DIR"),
58 	PINCTRL_PIN(34, "GP86_SD_LS_D_DIR"),
59 	PINCTRL_PIN(35, "GP88_SD_LS_SEL"),
60 	PINCTRL_PIN(36, "GP87_SD_PD"),
61 	PINCTRL_PIN(37, "GP89_SD_WP"),
62 	PINCTRL_PIN(38, "GP90_SDIO_CLK"),
63 	PINCTRL_PIN(39, "GP91_SDIO_CMD"),
64 	PINCTRL_PIN(40, "GP92_SDIO_D0"),
65 	PINCTRL_PIN(41, "GP93_SDIO_D1"),
66 	PINCTRL_PIN(42, "GP94_SDIO_D2"),
67 	PINCTRL_PIN(43, "GP95_SDIO_D3"),
68 	PINCTRL_PIN(44, "GP96_SDIO_PD"),
69 	/* HSI (8 pins) */
70 	PINCTRL_PIN(45, "HSI_ACDATA"),
71 	PINCTRL_PIN(46, "HSI_ACFLAG"),
72 	PINCTRL_PIN(47, "HSI_ACREADY"),
73 	PINCTRL_PIN(48, "HSI_ACWAKE"),
74 	PINCTRL_PIN(49, "HSI_CADATA"),
75 	PINCTRL_PIN(50, "HSI_CAFLAG"),
76 	PINCTRL_PIN(51, "HSI_CAREADY"),
77 	PINCTRL_PIN(52, "HSI_CAWAKE"),
78 	/* SSP Audio (14 pins) */
79 	PINCTRL_PIN(53, "GP70"),
80 	PINCTRL_PIN(54, "GP71"),
81 	PINCTRL_PIN(55, "GP32_I2S_0_CLK"),
82 	PINCTRL_PIN(56, "GP33_I2S_0_FS"),
83 	PINCTRL_PIN(57, "GP34_I2S_0_RXD"),
84 	PINCTRL_PIN(58, "GP35_I2S_0_TXD"),
85 	PINCTRL_PIN(59, "GP36_I2S_1_CLK"),
86 	PINCTRL_PIN(60, "GP37_I2S_1_FS"),
87 	PINCTRL_PIN(61, "GP38_I2S_1_RXD"),
88 	PINCTRL_PIN(62, "GP39_I2S_1_TXD"),
89 	PINCTRL_PIN(63, "GP40_I2S_2_CLK"),
90 	PINCTRL_PIN(64, "GP41_I2S_2_FS"),
91 	PINCTRL_PIN(65, "GP42_I2S_2_RXD"),
92 	PINCTRL_PIN(66, "GP43_I2S_2_TXD"),
93 	/* GP SSP (22 pins) */
94 	PINCTRL_PIN(67, "GP120_SPI_0_CLK"),
95 	PINCTRL_PIN(68, "GP121_SPI_0_SS"),
96 	PINCTRL_PIN(69, "GP122_SPI_0_RXD"),
97 	PINCTRL_PIN(70, "GP123_SPI_0_TXD"),
98 	PINCTRL_PIN(71, "GP102_SPI_1_CLK"),
99 	PINCTRL_PIN(72, "GP103_SPI_1_SS0"),
100 	PINCTRL_PIN(73, "GP104_SPI_1_SS1"),
101 	PINCTRL_PIN(74, "GP105_SPI_1_SS2"),
102 	PINCTRL_PIN(75, "GP106_SPI_1_SS3"),
103 	PINCTRL_PIN(76, "GP107_SPI_1_RXD"),
104 	PINCTRL_PIN(77, "GP108_SPI_1_TXD"),
105 	PINCTRL_PIN(78, "GP109_SPI_2_CLK"),
106 	PINCTRL_PIN(79, "GP110_SPI_2_SS0"),
107 	PINCTRL_PIN(80, "GP111_SPI_2_SS1"),
108 	PINCTRL_PIN(81, "GP112_SPI_2_SS2"),
109 	PINCTRL_PIN(82, "GP113_SPI_2_SS3"),
110 	PINCTRL_PIN(83, "GP114_SPI_2_RXD"),
111 	PINCTRL_PIN(84, "GP115_SPI_2_TXD"),
112 	PINCTRL_PIN(85, "GP116_SPI_3_CLK"),
113 	PINCTRL_PIN(86, "GP117_SPI_3_SS"),
114 	PINCTRL_PIN(87, "GP118_SPI_3_RXD"),
115 	PINCTRL_PIN(88, "GP119_SPI_3_TXD"),
116 	/* I2C (20 pins) */
117 	PINCTRL_PIN(89, "I2C_0_SCL"),
118 	PINCTRL_PIN(90, "I2C_0_SDA"),
119 	PINCTRL_PIN(91, "GP19_I2C_1_SCL"),
120 	PINCTRL_PIN(92, "GP20_I2C_1_SDA"),
121 	PINCTRL_PIN(93, "GP21_I2C_2_SCL"),
122 	PINCTRL_PIN(94, "GP22_I2C_2_SDA"),
123 	PINCTRL_PIN(95, "GP17_I2C_3_SCL_HDMI"),
124 	PINCTRL_PIN(96, "GP18_I2C_3_SDA_HDMI"),
125 	PINCTRL_PIN(97, "GP23_I2C_4_SCL"),
126 	PINCTRL_PIN(98, "GP24_I2C_4_SDA"),
127 	PINCTRL_PIN(99, "GP25_I2C_5_SCL"),
128 	PINCTRL_PIN(100, "GP26_I2C_5_SDA"),
129 	PINCTRL_PIN(101, "GP27_I2C_6_SCL"),
130 	PINCTRL_PIN(102, "GP28_I2C_6_SDA"),
131 	PINCTRL_PIN(103, "GP29_I2C_7_SCL"),
132 	PINCTRL_PIN(104, "GP30_I2C_7_SDA"),
133 	PINCTRL_PIN(105, "I2C_8_SCL"),
134 	PINCTRL_PIN(106, "I2C_8_SDA"),
135 	PINCTRL_PIN(107, "I2C_9_SCL"),
136 	PINCTRL_PIN(108, "I2C_9_SDA"),
137 	/* UART (23 pins) */
138 	PINCTRL_PIN(109, "GP124_UART_0_CTS"),
139 	PINCTRL_PIN(110, "GP125_UART_0_RTS"),
140 	PINCTRL_PIN(111, "GP126_UART_0_RX"),
141 	PINCTRL_PIN(112, "GP127_UART_0_TX"),
142 	PINCTRL_PIN(113, "GP128_UART_1_CTS"),
143 	PINCTRL_PIN(114, "GP129_UART_1_RTS"),
144 	PINCTRL_PIN(115, "GP130_UART_1_RX"),
145 	PINCTRL_PIN(116, "GP131_UART_1_TX"),
146 	PINCTRL_PIN(117, "GP132_UART_2_CTS"),
147 	PINCTRL_PIN(118, "GP133_UART_2_RTS"),
148 	PINCTRL_PIN(119, "GP134_UART_2_RX"),
149 	PINCTRL_PIN(120, "GP135_UART_2_TX"),
150 	PINCTRL_PIN(121, "GP97"),
151 	PINCTRL_PIN(122, "GP154"),
152 	PINCTRL_PIN(123, "GP155"),
153 	PINCTRL_PIN(124, "GP156"),
154 	PINCTRL_PIN(125, "GP157"),
155 	PINCTRL_PIN(126, "GP158"),
156 	PINCTRL_PIN(127, "GP159"),
157 	PINCTRL_PIN(128, "GP160"),
158 	PINCTRL_PIN(129, "GP161"),
159 	PINCTRL_PIN(130, "GP12_PWM0"),
160 	PINCTRL_PIN(131, "GP13_PWM1"),
161 	/* GPIO South (20 pins) */
162 	PINCTRL_PIN(132, "GP176"),
163 	PINCTRL_PIN(133, "GP177"),
164 	PINCTRL_PIN(134, "GP178"),
165 	PINCTRL_PIN(135, "GP179"),
166 	PINCTRL_PIN(136, "GP180"),
167 	PINCTRL_PIN(137, "GP181"),
168 	PINCTRL_PIN(138, "GP182_PWM2"),
169 	PINCTRL_PIN(139, "GP183_PWM3"),
170 	PINCTRL_PIN(140, "GP184"),
171 	PINCTRL_PIN(141, "GP185"),
172 	PINCTRL_PIN(142, "GP186"),
173 	PINCTRL_PIN(143, "GP187"),
174 	PINCTRL_PIN(144, "GP188"),
175 	PINCTRL_PIN(145, "GP189"),
176 	PINCTRL_PIN(146, "GP190"),
177 	PINCTRL_PIN(147, "GP191"),
178 	PINCTRL_PIN(148, "GP14"),
179 	PINCTRL_PIN(149, "GP15"),
180 	PINCTRL_PIN(150, "GP162"),
181 	PINCTRL_PIN(151, "GP163"),
182 	/* Camera Sideband (15 pins) */
183 	PINCTRL_PIN(152, "GP0"),
184 	PINCTRL_PIN(153, "GP1"),
185 	PINCTRL_PIN(154, "GP2"),
186 	PINCTRL_PIN(155, "GP3"),
187 	PINCTRL_PIN(156, "GP4"),
188 	PINCTRL_PIN(157, "GP5"),
189 	PINCTRL_PIN(158, "GP6"),
190 	PINCTRL_PIN(159, "GP7"),
191 	PINCTRL_PIN(160, "GP8"),
192 	PINCTRL_PIN(161, "GP9"),
193 	PINCTRL_PIN(162, "GP10"),
194 	PINCTRL_PIN(163, "GP11"),
195 	PINCTRL_PIN(164, "GP16_HDMI_HPD"),
196 	PINCTRL_PIN(165, "GP68_DSI_A_TE"),
197 	PINCTRL_PIN(166, "GP69_DSI_C_TE"),
198 	/* Clock (14 pins) */
199 	PINCTRL_PIN(167, "GP137"),
200 	PINCTRL_PIN(168, "GP138"),
201 	PINCTRL_PIN(169, "GP139"),
202 	PINCTRL_PIN(170, "GP140"),
203 	PINCTRL_PIN(171, "GP141"),
204 	PINCTRL_PIN(172, "GP142"),
205 	PINCTRL_PIN(173, "GP98"),
206 	PINCTRL_PIN(174, "OSC_CLK_CTRL0"),
207 	PINCTRL_PIN(175, "OSC_CLK_CTRL1"),
208 	PINCTRL_PIN(176, "OSC_CLK0"),
209 	PINCTRL_PIN(177, "OSC_CLK1"),
210 	PINCTRL_PIN(178, "OSC_CLK2"),
211 	PINCTRL_PIN(179, "OSC_CLK3"),
212 	PINCTRL_PIN(180, "OSC_CLK4"),
213 	/* PMIC (15 pins) */
214 	PINCTRL_PIN(181, "PROCHOT"),
215 	PINCTRL_PIN(182, "RESETOUT"),
216 	PINCTRL_PIN(183, "RTC_CLK"),
217 	PINCTRL_PIN(184, "STANDBY"),
218 	PINCTRL_PIN(185, "SVID_ALERT"),
219 	PINCTRL_PIN(186, "SVID_CLK"),
220 	PINCTRL_PIN(187, "SVID_D"),
221 	PINCTRL_PIN(188, "THERMTRIP"),
222 	PINCTRL_PIN(189, "PREQ"),
223 	PINCTRL_PIN(190, "ZQ_A"),
224 	PINCTRL_PIN(191, "ZQ_B"),
225 	PINCTRL_PIN(192, "GP64_FAST_INT0"),
226 	PINCTRL_PIN(193, "GP65_FAST_INT1"),
227 	PINCTRL_PIN(194, "GP66_FAST_INT2"),
228 	PINCTRL_PIN(195, "GP67_FAST_INT3"),
229 	/* Keyboard (20 pins) */
230 	PINCTRL_PIN(196, "GP44"),
231 	PINCTRL_PIN(197, "GP45"),
232 	PINCTRL_PIN(198, "GP46"),
233 	PINCTRL_PIN(199, "GP47"),
234 	PINCTRL_PIN(200, "GP48"),
235 	PINCTRL_PIN(201, "GP49"),
236 	PINCTRL_PIN(202, "GP50"),
237 	PINCTRL_PIN(203, "GP51"),
238 	PINCTRL_PIN(204, "GP52"),
239 	PINCTRL_PIN(205, "GP53"),
240 	PINCTRL_PIN(206, "GP54"),
241 	PINCTRL_PIN(207, "GP55"),
242 	PINCTRL_PIN(208, "GP56"),
243 	PINCTRL_PIN(209, "GP57"),
244 	PINCTRL_PIN(210, "GP58"),
245 	PINCTRL_PIN(211, "GP59"),
246 	PINCTRL_PIN(212, "GP60"),
247 	PINCTRL_PIN(213, "GP61"),
248 	PINCTRL_PIN(214, "GP62"),
249 	PINCTRL_PIN(215, "GP63"),
250 	/* GPIO North (13 pins) */
251 	PINCTRL_PIN(216, "GP164"),
252 	PINCTRL_PIN(217, "GP165"),
253 	PINCTRL_PIN(218, "GP166"),
254 	PINCTRL_PIN(219, "GP167"),
255 	PINCTRL_PIN(220, "GP168_MJTAG_TCK"),
256 	PINCTRL_PIN(221, "GP169_MJTAG_TDI"),
257 	PINCTRL_PIN(222, "GP170_MJTAG_TDO"),
258 	PINCTRL_PIN(223, "GP171_MJTAG_TMS"),
259 	PINCTRL_PIN(224, "GP172_MJTAG_TRST"),
260 	PINCTRL_PIN(225, "GP173"),
261 	PINCTRL_PIN(226, "GP174"),
262 	PINCTRL_PIN(227, "GP175"),
263 	PINCTRL_PIN(228, "GP176"),
264 	/* PTI (22 pins) */
265 	PINCTRL_PIN(229, "GP72_PTI_CLK"),
266 	PINCTRL_PIN(230, "GP73_PTI_D0"),
267 	PINCTRL_PIN(231, "GP74_PTI_D1"),
268 	PINCTRL_PIN(232, "GP75_PTI_D2"),
269 	PINCTRL_PIN(233, "GP76_PTI_D3"),
270 	PINCTRL_PIN(234, "GP164"),
271 	PINCTRL_PIN(235, "GP165"),
272 	PINCTRL_PIN(236, "GP166"),
273 	PINCTRL_PIN(237, "GP167"),
274 	PINCTRL_PIN(238, "GP168_MJTAG_TCK"),
275 	PINCTRL_PIN(239, "GP169_MJTAG_TDI"),
276 	PINCTRL_PIN(240, "GP170_MJTAG_TDO"),
277 	PINCTRL_PIN(241, "GP171_MJTAG_TMS"),
278 	PINCTRL_PIN(242, "GP172_MJTAG_TRST"),
279 	PINCTRL_PIN(243, "GP173"),
280 	PINCTRL_PIN(244, "GP174"),
281 	PINCTRL_PIN(245, "GP175"),
282 	PINCTRL_PIN(246, "JTAG_TCK"),
283 	PINCTRL_PIN(247, "JTAG_TDI"),
284 	PINCTRL_PIN(248, "JTAG_TDO"),
285 	PINCTRL_PIN(249, "JTAG_TMS"),
286 	PINCTRL_PIN(250, "JTAG_TRST"),
287 };
288 
289 static const struct tng_family mofld_families[] = {
290 	TNG_FAMILY(0, 0, 12),
291 	TNG_FAMILY(1, 13, 24),
292 	TNG_FAMILY(2, 25, 44),
293 	TNG_FAMILY(3, 45, 52),
294 	TNG_FAMILY(4, 53, 66),
295 	TNG_FAMILY(5, 67, 88),
296 	TNG_FAMILY(6, 89, 108),
297 	TNG_FAMILY(7, 109, 131),
298 	TNG_FAMILY(8, 132, 151),
299 	TNG_FAMILY(9, 152, 166),
300 	TNG_FAMILY(10, 167, 180),
301 	TNG_FAMILY(11, 181, 195),
302 	TNG_FAMILY(12, 196, 215),
303 	TNG_FAMILY(13, 216, 228),
304 	TNG_FAMILY(14, 229, 250),
305 };
306 
307 static const struct tng_pinctrl mofld_soc_data = {
308 	.pins = mofld_pins,
309 	.npins = ARRAY_SIZE(mofld_pins),
310 	.families = mofld_families,
311 	.nfamilies = ARRAY_SIZE(mofld_families),
312 };
313 
314 static const struct acpi_device_id mofld_acpi_table[] = {
315 	{ "INTC1003", (kernel_ulong_t)&mofld_soc_data },
316 	{ }
317 };
318 MODULE_DEVICE_TABLE(acpi, mofld_acpi_table);
319 
320 static struct platform_driver mofld_pinctrl_driver = {
321 	.probe = devm_tng_pinctrl_probe,
322 	.driver = {
323 		.name = "pinctrl-moorefield",
324 		.acpi_match_table = mofld_acpi_table,
325 	},
326 };
327 
mofld_pinctrl_init(void)328 static int __init mofld_pinctrl_init(void)
329 {
330 	return platform_driver_register(&mofld_pinctrl_driver);
331 }
332 subsys_initcall(mofld_pinctrl_init);
333 
mofld_pinctrl_exit(void)334 static void __exit mofld_pinctrl_exit(void)
335 {
336 	platform_driver_unregister(&mofld_pinctrl_driver);
337 }
338 module_exit(mofld_pinctrl_exit);
339 
340 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
341 MODULE_DESCRIPTION("Intel Moorefield SoC pinctrl driver");
342 MODULE_LICENSE("GPL v2");
343 MODULE_ALIAS("platform:pinctrl-moorefield");
344 MODULE_IMPORT_NS(PINCTRL_TANGIER);
345