1 /*
2  * Intel Sunrisepoint PCH pinctrl/GPIO driver
3  *
4  * Copyright (C) 2015, Intel Corporation
5  * Authors: Mathias Nyman <mathias.nyman@linux.intel.com>
6  *          Mika Westerberg <mika.westerberg@linux.intel.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 
13 #include <linux/acpi.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/pm.h>
17 #include <linux/pinctrl/pinctrl.h>
18 
19 #include "pinctrl-intel.h"
20 
21 #define SPT_PAD_OWN	0x020
22 #define SPT_PADCFGLOCK	0x0a0
23 #define SPT_HOSTSW_OWN	0x0d0
24 #define SPT_GPI_IE	0x120
25 
26 #define SPT_COMMUNITY(b, s, e)				\
27 	{						\
28 		.barno = (b),				\
29 		.padown_offset = SPT_PAD_OWN,		\
30 		.padcfglock_offset = SPT_PADCFGLOCK,	\
31 		.hostown_offset = SPT_HOSTSW_OWN,	\
32 		.ie_offset = SPT_GPI_IE,		\
33 		.gpp_size = 24,				\
34 		.pin_base = (s),			\
35 		.npins = ((e) - (s) + 1),		\
36 	}
37 
38 /* Sunrisepoint-LP */
39 static const struct pinctrl_pin_desc sptlp_pins[] = {
40 	/* GPP_A */
41 	PINCTRL_PIN(0, "RCINB"),
42 	PINCTRL_PIN(1, "LAD_0"),
43 	PINCTRL_PIN(2, "LAD_1"),
44 	PINCTRL_PIN(3, "LAD_2"),
45 	PINCTRL_PIN(4, "LAD_3"),
46 	PINCTRL_PIN(5, "LFRAMEB"),
47 	PINCTRL_PIN(6, "SERIQ"),
48 	PINCTRL_PIN(7, "PIRQAB"),
49 	PINCTRL_PIN(8, "CLKRUNB"),
50 	PINCTRL_PIN(9, "CLKOUT_LPC_0"),
51 	PINCTRL_PIN(10, "CLKOUT_LPC_1"),
52 	PINCTRL_PIN(11, "PMEB"),
53 	PINCTRL_PIN(12, "BM_BUSYB"),
54 	PINCTRL_PIN(13, "SUSWARNB_SUS_PWRDNACK"),
55 	PINCTRL_PIN(14, "SUS_STATB"),
56 	PINCTRL_PIN(15, "SUSACKB"),
57 	PINCTRL_PIN(16, "SD_1P8_SEL"),
58 	PINCTRL_PIN(17, "SD_PWR_EN_B"),
59 	PINCTRL_PIN(18, "ISH_GP_0"),
60 	PINCTRL_PIN(19, "ISH_GP_1"),
61 	PINCTRL_PIN(20, "ISH_GP_2"),
62 	PINCTRL_PIN(21, "ISH_GP_3"),
63 	PINCTRL_PIN(22, "ISH_GP_4"),
64 	PINCTRL_PIN(23, "ISH_GP_5"),
65 	/* GPP_B */
66 	PINCTRL_PIN(24, "CORE_VID_0"),
67 	PINCTRL_PIN(25, "CORE_VID_1"),
68 	PINCTRL_PIN(26, "VRALERTB"),
69 	PINCTRL_PIN(27, "CPU_GP_2"),
70 	PINCTRL_PIN(28, "CPU_GP_3"),
71 	PINCTRL_PIN(29, "SRCCLKREQB_0"),
72 	PINCTRL_PIN(30, "SRCCLKREQB_1"),
73 	PINCTRL_PIN(31, "SRCCLKREQB_2"),
74 	PINCTRL_PIN(32, "SRCCLKREQB_3"),
75 	PINCTRL_PIN(33, "SRCCLKREQB_4"),
76 	PINCTRL_PIN(34, "SRCCLKREQB_5"),
77 	PINCTRL_PIN(35, "EXT_PWR_GATEB"),
78 	PINCTRL_PIN(36, "SLP_S0B"),
79 	PINCTRL_PIN(37, "PLTRSTB"),
80 	PINCTRL_PIN(38, "SPKR"),
81 	PINCTRL_PIN(39, "GSPI0_CSB"),
82 	PINCTRL_PIN(40, "GSPI0_CLK"),
83 	PINCTRL_PIN(41, "GSPI0_MISO"),
84 	PINCTRL_PIN(42, "GSPI0_MOSI"),
85 	PINCTRL_PIN(43, "GSPI1_CSB"),
86 	PINCTRL_PIN(44, "GSPI1_CLK"),
87 	PINCTRL_PIN(45, "GSPI1_MISO"),
88 	PINCTRL_PIN(46, "GSPI1_MOSI"),
89 	PINCTRL_PIN(47, "SML1ALERTB"),
90 	/* GPP_C */
91 	PINCTRL_PIN(48, "SMBCLK"),
92 	PINCTRL_PIN(49, "SMBDATA"),
93 	PINCTRL_PIN(50, "SMBALERTB"),
94 	PINCTRL_PIN(51, "SML0CLK"),
95 	PINCTRL_PIN(52, "SML0DATA"),
96 	PINCTRL_PIN(53, "SML0ALERTB"),
97 	PINCTRL_PIN(54, "SML1CLK"),
98 	PINCTRL_PIN(55, "SML1DATA"),
99 	PINCTRL_PIN(56, "UART0_RXD"),
100 	PINCTRL_PIN(57, "UART0_TXD"),
101 	PINCTRL_PIN(58, "UART0_RTSB"),
102 	PINCTRL_PIN(59, "UART0_CTSB"),
103 	PINCTRL_PIN(60, "UART1_RXD"),
104 	PINCTRL_PIN(61, "UART1_TXD"),
105 	PINCTRL_PIN(62, "UART1_RTSB"),
106 	PINCTRL_PIN(63, "UART1_CTSB"),
107 	PINCTRL_PIN(64, "I2C0_SDA"),
108 	PINCTRL_PIN(65, "I2C0_SCL"),
109 	PINCTRL_PIN(66, "I2C1_SDA"),
110 	PINCTRL_PIN(67, "I2C1_SCL"),
111 	PINCTRL_PIN(68, "UART2_RXD"),
112 	PINCTRL_PIN(69, "UART2_TXD"),
113 	PINCTRL_PIN(70, "UART2_RTSB"),
114 	PINCTRL_PIN(71, "UART2_CTSB"),
115 	/* GPP_D */
116 	PINCTRL_PIN(72, "SPI1_CSB"),
117 	PINCTRL_PIN(73, "SPI1_CLK"),
118 	PINCTRL_PIN(74, "SPI1_MISO_IO_1"),
119 	PINCTRL_PIN(75, "SPI1_MOSI_IO_0"),
120 	PINCTRL_PIN(76, "FLASHTRIG"),
121 	PINCTRL_PIN(77, "ISH_I2C0_SDA"),
122 	PINCTRL_PIN(78, "ISH_I2C0_SCL"),
123 	PINCTRL_PIN(79, "ISH_I2C1_SDA"),
124 	PINCTRL_PIN(80, "ISH_I2C1_SCL"),
125 	PINCTRL_PIN(81, "ISH_SPI_CSB"),
126 	PINCTRL_PIN(82, "ISH_SPI_CLK"),
127 	PINCTRL_PIN(83, "ISH_SPI_MISO"),
128 	PINCTRL_PIN(84, "ISH_SPI_MOSI"),
129 	PINCTRL_PIN(85, "ISH_UART0_RXD"),
130 	PINCTRL_PIN(86, "ISH_UART0_TXD"),
131 	PINCTRL_PIN(87, "ISH_UART0_RTSB"),
132 	PINCTRL_PIN(88, "ISH_UART0_CTSB"),
133 	PINCTRL_PIN(89, "DMIC_CLK_1"),
134 	PINCTRL_PIN(90, "DMIC_DATA_1"),
135 	PINCTRL_PIN(91, "DMIC_CLK_0"),
136 	PINCTRL_PIN(92, "DMIC_DATA_0"),
137 	PINCTRL_PIN(93, "SPI1_IO_2"),
138 	PINCTRL_PIN(94, "SPI1_IO_3"),
139 	PINCTRL_PIN(95, "SSP_MCLK"),
140 	/* GPP_E */
141 	PINCTRL_PIN(96, "SATAXPCIE_0"),
142 	PINCTRL_PIN(97, "SATAXPCIE_1"),
143 	PINCTRL_PIN(98, "SATAXPCIE_2"),
144 	PINCTRL_PIN(99, "CPU_GP_0"),
145 	PINCTRL_PIN(100, "SATA_DEVSLP_0"),
146 	PINCTRL_PIN(101, "SATA_DEVSLP_1"),
147 	PINCTRL_PIN(102, "SATA_DEVSLP_2"),
148 	PINCTRL_PIN(103, "CPU_GP_1"),
149 	PINCTRL_PIN(104, "SATA_LEDB"),
150 	PINCTRL_PIN(105, "USB2_OCB_0"),
151 	PINCTRL_PIN(106, "USB2_OCB_1"),
152 	PINCTRL_PIN(107, "USB2_OCB_2"),
153 	PINCTRL_PIN(108, "USB2_OCB_3"),
154 	PINCTRL_PIN(109, "DDSP_HPD_0"),
155 	PINCTRL_PIN(110, "DDSP_HPD_1"),
156 	PINCTRL_PIN(111, "DDSP_HPD_2"),
157 	PINCTRL_PIN(112, "DDSP_HPD_3"),
158 	PINCTRL_PIN(113, "EDP_HPD"),
159 	PINCTRL_PIN(114, "DDPB_CTRLCLK"),
160 	PINCTRL_PIN(115, "DDPB_CTRLDATA"),
161 	PINCTRL_PIN(116, "DDPC_CTRLCLK"),
162 	PINCTRL_PIN(117, "DDPC_CTRLDATA"),
163 	PINCTRL_PIN(118, "DDPD_CTRLCLK"),
164 	PINCTRL_PIN(119, "DDPD_CTRLDATA"),
165 	/* GPP_F */
166 	PINCTRL_PIN(120, "SSP2_SCLK"),
167 	PINCTRL_PIN(121, "SSP2_SFRM"),
168 	PINCTRL_PIN(122, "SSP2_TXD"),
169 	PINCTRL_PIN(123, "SSP2_RXD"),
170 	PINCTRL_PIN(124, "I2C2_SDA"),
171 	PINCTRL_PIN(125, "I2C2_SCL"),
172 	PINCTRL_PIN(126, "I2C3_SDA"),
173 	PINCTRL_PIN(127, "I2C3_SCL"),
174 	PINCTRL_PIN(128, "I2C4_SDA"),
175 	PINCTRL_PIN(129, "I2C4_SCL"),
176 	PINCTRL_PIN(130, "I2C5_SDA"),
177 	PINCTRL_PIN(131, "I2C5_SCL"),
178 	PINCTRL_PIN(132, "EMMC_CMD"),
179 	PINCTRL_PIN(133, "EMMC_DATA_0"),
180 	PINCTRL_PIN(134, "EMMC_DATA_1"),
181 	PINCTRL_PIN(135, "EMMC_DATA_2"),
182 	PINCTRL_PIN(136, "EMMC_DATA_3"),
183 	PINCTRL_PIN(137, "EMMC_DATA_4"),
184 	PINCTRL_PIN(138, "EMMC_DATA_5"),
185 	PINCTRL_PIN(139, "EMMC_DATA_6"),
186 	PINCTRL_PIN(140, "EMMC_DATA_7"),
187 	PINCTRL_PIN(141, "EMMC_RCLK"),
188 	PINCTRL_PIN(142, "EMMC_CLK"),
189 	PINCTRL_PIN(143, "GPP_F_23"),
190 	/* GPP_G */
191 	PINCTRL_PIN(144, "SD_CMD"),
192 	PINCTRL_PIN(145, "SD_DATA_0"),
193 	PINCTRL_PIN(146, "SD_DATA_1"),
194 	PINCTRL_PIN(147, "SD_DATA_2"),
195 	PINCTRL_PIN(148, "SD_DATA_3"),
196 	PINCTRL_PIN(149, "SD_CDB"),
197 	PINCTRL_PIN(150, "SD_CLK"),
198 	PINCTRL_PIN(151, "SD_WP"),
199 };
200 
201 static const unsigned sptlp_spi0_pins[] = { 39, 40, 41, 42 };
202 static const unsigned sptlp_spi1_pins[] = { 43, 44, 45, 46 };
203 static const unsigned sptlp_uart0_pins[] = { 56, 57, 58, 59 };
204 static const unsigned sptlp_uart1_pins[] = { 60, 61, 62, 63 };
205 static const unsigned sptlp_uart2_pins[] = { 68, 69, 71, 71 };
206 static const unsigned sptlp_i2c0_pins[] = { 64, 65 };
207 static const unsigned sptlp_i2c1_pins[] = { 66, 67 };
208 static const unsigned sptlp_i2c2_pins[] = { 124, 125 };
209 static const unsigned sptlp_i2c3_pins[] = { 126, 127 };
210 static const unsigned sptlp_i2c4_pins[] = { 128, 129 };
211 static const unsigned sptlp_i2c4b_pins[] = { 85, 86 };
212 static const unsigned sptlp_i2c5_pins[] = { 130, 131 };
213 static const unsigned sptlp_ssp2_pins[] = { 120, 121, 122, 123 };
214 static const unsigned sptlp_emmc_pins[] = {
215 	132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
216 };
217 static const unsigned sptlp_sd_pins[] = {
218 	144, 145, 146, 147, 148, 149, 150, 151,
219 };
220 
221 static const struct intel_pingroup sptlp_groups[] = {
222 	PIN_GROUP("spi0_grp", sptlp_spi0_pins, 1),
223 	PIN_GROUP("spi1_grp", sptlp_spi1_pins, 1),
224 	PIN_GROUP("uart0_grp", sptlp_uart0_pins, 1),
225 	PIN_GROUP("uart1_grp", sptlp_uart1_pins, 1),
226 	PIN_GROUP("uart2_grp", sptlp_uart2_pins, 1),
227 	PIN_GROUP("i2c0_grp", sptlp_i2c0_pins, 1),
228 	PIN_GROUP("i2c1_grp", sptlp_i2c1_pins, 1),
229 	PIN_GROUP("i2c2_grp", sptlp_i2c2_pins, 1),
230 	PIN_GROUP("i2c3_grp", sptlp_i2c3_pins, 1),
231 	PIN_GROUP("i2c4_grp", sptlp_i2c4_pins, 1),
232 	PIN_GROUP("i2c4b_grp", sptlp_i2c4b_pins, 3),
233 	PIN_GROUP("i2c5_grp", sptlp_i2c5_pins, 1),
234 	PIN_GROUP("ssp2_grp", sptlp_ssp2_pins, 1),
235 	PIN_GROUP("emmc_grp", sptlp_emmc_pins, 1),
236 	PIN_GROUP("sd_grp", sptlp_sd_pins, 1),
237 };
238 
239 static const char * const sptlp_spi0_groups[] = { "spi0_grp" };
240 static const char * const sptlp_spi1_groups[] = { "spi0_grp" };
241 static const char * const sptlp_uart0_groups[] = { "uart0_grp" };
242 static const char * const sptlp_uart1_groups[] = { "uart1_grp" };
243 static const char * const sptlp_uart2_groups[] = { "uart2_grp" };
244 static const char * const sptlp_i2c0_groups[] = { "i2c0_grp" };
245 static const char * const sptlp_i2c1_groups[] = { "i2c1_grp" };
246 static const char * const sptlp_i2c2_groups[] = { "i2c2_grp" };
247 static const char * const sptlp_i2c3_groups[] = { "i2c3_grp" };
248 static const char * const sptlp_i2c4_groups[] = { "i2c4_grp", "i2c4b_grp" };
249 static const char * const sptlp_i2c5_groups[] = { "i2c5_grp" };
250 static const char * const sptlp_ssp2_groups[] = { "ssp2_grp" };
251 static const char * const sptlp_emmc_groups[] = { "emmc_grp" };
252 static const char * const sptlp_sd_groups[] = { "sd_grp" };
253 
254 static const struct intel_function sptlp_functions[] = {
255 	FUNCTION("spi0", sptlp_spi0_groups),
256 	FUNCTION("spi1", sptlp_spi1_groups),
257 	FUNCTION("uart0", sptlp_uart0_groups),
258 	FUNCTION("uart1", sptlp_uart1_groups),
259 	FUNCTION("uart2", sptlp_uart2_groups),
260 	FUNCTION("i2c0", sptlp_i2c0_groups),
261 	FUNCTION("i2c1", sptlp_i2c1_groups),
262 	FUNCTION("i2c2", sptlp_i2c2_groups),
263 	FUNCTION("i2c3", sptlp_i2c3_groups),
264 	FUNCTION("i2c4", sptlp_i2c4_groups),
265 	FUNCTION("i2c5", sptlp_i2c5_groups),
266 	FUNCTION("ssp2", sptlp_ssp2_groups),
267 	FUNCTION("emmc", sptlp_emmc_groups),
268 	FUNCTION("sd", sptlp_sd_groups),
269 };
270 
271 static const struct intel_community sptlp_communities[] = {
272 	SPT_COMMUNITY(0, 0, 47),
273 	SPT_COMMUNITY(1, 48, 119),
274 	SPT_COMMUNITY(2, 120, 151),
275 };
276 
277 static const struct intel_pinctrl_soc_data sptlp_soc_data = {
278 	.pins = sptlp_pins,
279 	.npins = ARRAY_SIZE(sptlp_pins),
280 	.groups = sptlp_groups,
281 	.ngroups = ARRAY_SIZE(sptlp_groups),
282 	.functions = sptlp_functions,
283 	.nfunctions = ARRAY_SIZE(sptlp_functions),
284 	.communities = sptlp_communities,
285 	.ncommunities = ARRAY_SIZE(sptlp_communities),
286 };
287 
288 /* Sunrisepoint-H */
289 static const struct pinctrl_pin_desc spth_pins[] = {
290 	/* GPP_A */
291 	PINCTRL_PIN(0, "RCINB"),
292 	PINCTRL_PIN(1, "LAD_0"),
293 	PINCTRL_PIN(2, "LAD_1"),
294 	PINCTRL_PIN(3, "LAD_2"),
295 	PINCTRL_PIN(4, "LAD_3"),
296 	PINCTRL_PIN(5, "LFRAMEB"),
297 	PINCTRL_PIN(6, "SERIQ"),
298 	PINCTRL_PIN(7, "PIRQAB"),
299 	PINCTRL_PIN(8, "CLKRUNB"),
300 	PINCTRL_PIN(9, "CLKOUT_LPC_0"),
301 	PINCTRL_PIN(10, "CLKOUT_LPC_1"),
302 	PINCTRL_PIN(11, "PMEB"),
303 	PINCTRL_PIN(12, "BM_BUSYB"),
304 	PINCTRL_PIN(13, "SUSWARNB_SUS_PWRDNACK"),
305 	PINCTRL_PIN(14, "SUS_STATB"),
306 	PINCTRL_PIN(15, "SUSACKB"),
307 	PINCTRL_PIN(16, "CLKOUT_48"),
308 	PINCTRL_PIN(17, "ISH_GP_7"),
309 	PINCTRL_PIN(18, "ISH_GP_0"),
310 	PINCTRL_PIN(19, "ISH_GP_1"),
311 	PINCTRL_PIN(20, "ISH_GP_2"),
312 	PINCTRL_PIN(21, "ISH_GP_3"),
313 	PINCTRL_PIN(22, "ISH_GP_4"),
314 	PINCTRL_PIN(23, "ISH_GP_5"),
315 	/* GPP_B */
316 	PINCTRL_PIN(24, "CORE_VID_0"),
317 	PINCTRL_PIN(25, "CORE_VID_1"),
318 	PINCTRL_PIN(26, "VRALERTB"),
319 	PINCTRL_PIN(27, "CPU_GP_2"),
320 	PINCTRL_PIN(28, "CPU_GP_3"),
321 	PINCTRL_PIN(29, "SRCCLKREQB_0"),
322 	PINCTRL_PIN(30, "SRCCLKREQB_1"),
323 	PINCTRL_PIN(31, "SRCCLKREQB_2"),
324 	PINCTRL_PIN(32, "SRCCLKREQB_3"),
325 	PINCTRL_PIN(33, "SRCCLKREQB_4"),
326 	PINCTRL_PIN(34, "SRCCLKREQB_5"),
327 	PINCTRL_PIN(35, "EXT_PWR_GATEB"),
328 	PINCTRL_PIN(36, "SLP_S0B"),
329 	PINCTRL_PIN(37, "PLTRSTB"),
330 	PINCTRL_PIN(38, "SPKR"),
331 	PINCTRL_PIN(39, "GSPI0_CSB"),
332 	PINCTRL_PIN(40, "GSPI0_CLK"),
333 	PINCTRL_PIN(41, "GSPI0_MISO"),
334 	PINCTRL_PIN(42, "GSPI0_MOSI"),
335 	PINCTRL_PIN(43, "GSPI1_CSB"),
336 	PINCTRL_PIN(44, "GSPI1_CLK"),
337 	PINCTRL_PIN(45, "GSPI1_MISO"),
338 	PINCTRL_PIN(46, "GSPI1_MOSI"),
339 	PINCTRL_PIN(47, "SML1ALERTB"),
340 	/* GPP_C */
341 	PINCTRL_PIN(48, "SMBCLK"),
342 	PINCTRL_PIN(49, "SMBDATA"),
343 	PINCTRL_PIN(50, "SMBALERTB"),
344 	PINCTRL_PIN(51, "SML0CLK"),
345 	PINCTRL_PIN(52, "SML0DATA"),
346 	PINCTRL_PIN(53, "SML0ALERTB"),
347 	PINCTRL_PIN(54, "SML1CLK"),
348 	PINCTRL_PIN(55, "SML1DATA"),
349 	PINCTRL_PIN(56, "UART0_RXD"),
350 	PINCTRL_PIN(57, "UART0_TXD"),
351 	PINCTRL_PIN(58, "UART0_RTSB"),
352 	PINCTRL_PIN(59, "UART0_CTSB"),
353 	PINCTRL_PIN(60, "UART1_RXD"),
354 	PINCTRL_PIN(61, "UART1_TXD"),
355 	PINCTRL_PIN(62, "UART1_RTSB"),
356 	PINCTRL_PIN(63, "UART1_CTSB"),
357 	PINCTRL_PIN(64, "I2C0_SDA"),
358 	PINCTRL_PIN(65, "I2C0_SCL"),
359 	PINCTRL_PIN(66, "I2C1_SDA"),
360 	PINCTRL_PIN(67, "I2C1_SCL"),
361 	PINCTRL_PIN(68, "UART2_RXD"),
362 	PINCTRL_PIN(69, "UART2_TXD"),
363 	PINCTRL_PIN(70, "UART2_RTSB"),
364 	PINCTRL_PIN(71, "UART2_CTSB"),
365 	/* GPP_D */
366 	PINCTRL_PIN(72, "SPI1_CSB"),
367 	PINCTRL_PIN(73, "SPI1_CLK"),
368 	PINCTRL_PIN(74, "SPI1_MISO_IO_1"),
369 	PINCTRL_PIN(75, "SPI1_MOSI_IO_0"),
370 	PINCTRL_PIN(76, "ISH_I2C2_SDA"),
371 	PINCTRL_PIN(77, "SSP0_SFRM"),
372 	PINCTRL_PIN(78, "SSP0_TXD"),
373 	PINCTRL_PIN(79, "SSP0_RXD"),
374 	PINCTRL_PIN(80, "SSP0_SCLK"),
375 	PINCTRL_PIN(81, "ISH_SPI_CSB"),
376 	PINCTRL_PIN(82, "ISH_SPI_CLK"),
377 	PINCTRL_PIN(83, "ISH_SPI_MISO"),
378 	PINCTRL_PIN(84, "ISH_SPI_MOSI"),
379 	PINCTRL_PIN(85, "ISH_UART0_RXD"),
380 	PINCTRL_PIN(86, "ISH_UART0_TXD"),
381 	PINCTRL_PIN(87, "ISH_UART0_RTSB"),
382 	PINCTRL_PIN(88, "ISH_UART0_CTSB"),
383 	PINCTRL_PIN(89, "DMIC_CLK_1"),
384 	PINCTRL_PIN(90, "DMIC_DATA_1"),
385 	PINCTRL_PIN(91, "DMIC_CLK_0"),
386 	PINCTRL_PIN(92, "DMIC_DATA_0"),
387 	PINCTRL_PIN(93, "SPI1_IO_2"),
388 	PINCTRL_PIN(94, "SPI1_IO_3"),
389 	PINCTRL_PIN(95, "ISH_I2C2_SCL"),
390 	/* GPP_E */
391 	PINCTRL_PIN(96, "SATAXPCIE_0"),
392 	PINCTRL_PIN(97, "SATAXPCIE_1"),
393 	PINCTRL_PIN(98, "SATAXPCIE_2"),
394 	PINCTRL_PIN(99, "CPU_GP_0"),
395 	PINCTRL_PIN(100, "SATA_DEVSLP_0"),
396 	PINCTRL_PIN(101, "SATA_DEVSLP_1"),
397 	PINCTRL_PIN(102, "SATA_DEVSLP_2"),
398 	PINCTRL_PIN(103, "CPU_GP_1"),
399 	PINCTRL_PIN(104, "SATA_LEDB"),
400 	PINCTRL_PIN(105, "USB2_OCB_0"),
401 	PINCTRL_PIN(106, "USB2_OCB_1"),
402 	PINCTRL_PIN(107, "USB2_OCB_2"),
403 	PINCTRL_PIN(108, "USB2_OCB_3"),
404 	/* GPP_F */
405 	PINCTRL_PIN(109, "SATAXPCIE_3"),
406 	PINCTRL_PIN(110, "SATAXPCIE_4"),
407 	PINCTRL_PIN(111, "SATAXPCIE_5"),
408 	PINCTRL_PIN(112, "SATAXPCIE_6"),
409 	PINCTRL_PIN(113, "SATAXPCIE_7"),
410 	PINCTRL_PIN(114, "SATA_DEVSLP_3"),
411 	PINCTRL_PIN(115, "SATA_DEVSLP_4"),
412 	PINCTRL_PIN(116, "SATA_DEVSLP_5"),
413 	PINCTRL_PIN(117, "SATA_DEVSLP_6"),
414 	PINCTRL_PIN(118, "SATA_DEVSLP_7"),
415 	PINCTRL_PIN(119, "SATA_SCLOCK"),
416 	PINCTRL_PIN(120, "SATA_SLOAD"),
417 	PINCTRL_PIN(121, "SATA_SDATAOUT1"),
418 	PINCTRL_PIN(122, "SATA_SDATAOUT0"),
419 	PINCTRL_PIN(123, "GPP_F_14"),
420 	PINCTRL_PIN(124, "USB_OCB_4"),
421 	PINCTRL_PIN(125, "USB_OCB_5"),
422 	PINCTRL_PIN(126, "USB_OCB_6"),
423 	PINCTRL_PIN(127, "USB_OCB_7"),
424 	PINCTRL_PIN(128, "L_VDDEN"),
425 	PINCTRL_PIN(129, "L_BKLTEN"),
426 	PINCTRL_PIN(130, "L_BKLTCTL"),
427 	PINCTRL_PIN(131, "GPP_F_22"),
428 	PINCTRL_PIN(132, "GPP_F_23"),
429 	/* GPP_G */
430 	PINCTRL_PIN(133, "FAN_TACH_0"),
431 	PINCTRL_PIN(134, "FAN_TACH_1"),
432 	PINCTRL_PIN(135, "FAN_TACH_2"),
433 	PINCTRL_PIN(136, "FAN_TACH_3"),
434 	PINCTRL_PIN(137, "FAN_TACH_4"),
435 	PINCTRL_PIN(138, "FAN_TACH_5"),
436 	PINCTRL_PIN(139, "FAN_TACH_6"),
437 	PINCTRL_PIN(140, "FAN_TACH_7"),
438 	PINCTRL_PIN(141, "FAN_PWM_0"),
439 	PINCTRL_PIN(142, "FAN_PWM_1"),
440 	PINCTRL_PIN(143, "FAN_PWM_2"),
441 	PINCTRL_PIN(144, "FAN_PWM_3"),
442 	PINCTRL_PIN(145, "GSXDOUT"),
443 	PINCTRL_PIN(146, "GSXSLOAD"),
444 	PINCTRL_PIN(147, "GSXDIN"),
445 	PINCTRL_PIN(148, "GSXRESETB"),
446 	PINCTRL_PIN(149, "GSXCLK"),
447 	PINCTRL_PIN(150, "ADR_COMPLETE"),
448 	PINCTRL_PIN(151, "NMIB"),
449 	PINCTRL_PIN(152, "SMIB"),
450 	PINCTRL_PIN(153, "GPP_G_20"),
451 	PINCTRL_PIN(154, "GPP_G_21"),
452 	PINCTRL_PIN(155, "GPP_G_22"),
453 	PINCTRL_PIN(156, "GPP_G_23"),
454 	/* GPP_H */
455 	PINCTRL_PIN(157, "SRCCLKREQB_6"),
456 	PINCTRL_PIN(158, "SRCCLKREQB_7"),
457 	PINCTRL_PIN(159, "SRCCLKREQB_8"),
458 	PINCTRL_PIN(160, "SRCCLKREQB_9"),
459 	PINCTRL_PIN(161, "SRCCLKREQB_10"),
460 	PINCTRL_PIN(162, "SRCCLKREQB_11"),
461 	PINCTRL_PIN(163, "SRCCLKREQB_12"),
462 	PINCTRL_PIN(164, "SRCCLKREQB_13"),
463 	PINCTRL_PIN(165, "SRCCLKREQB_14"),
464 	PINCTRL_PIN(166, "SRCCLKREQB_15"),
465 	PINCTRL_PIN(167, "SML2CLK"),
466 	PINCTRL_PIN(168, "SML2DATA"),
467 	PINCTRL_PIN(169, "SML2ALERTB"),
468 	PINCTRL_PIN(170, "SML3CLK"),
469 	PINCTRL_PIN(171, "SML3DATA"),
470 	PINCTRL_PIN(172, "SML3ALERTB"),
471 	PINCTRL_PIN(173, "SML4CLK"),
472 	PINCTRL_PIN(174, "SML4DATA"),
473 	PINCTRL_PIN(175, "SML4ALERTB"),
474 	PINCTRL_PIN(176, "ISH_I2C0_SDA"),
475 	PINCTRL_PIN(177, "ISH_I2C0_SCL"),
476 	PINCTRL_PIN(178, "ISH_I2C1_SDA"),
477 	PINCTRL_PIN(179, "ISH_I2C1_SCL"),
478 	PINCTRL_PIN(180, "GPP_H_23"),
479 	/* GPP_I */
480 	PINCTRL_PIN(181, "DDSP_HDP_0"),
481 	PINCTRL_PIN(182, "DDSP_HDP_1"),
482 	PINCTRL_PIN(183, "DDSP_HDP_2"),
483 	PINCTRL_PIN(184, "DDSP_HDP_3"),
484 	PINCTRL_PIN(185, "EDP_HPD"),
485 	PINCTRL_PIN(186, "DDPB_CTRLCLK"),
486 	PINCTRL_PIN(187, "DDPB_CTRLDATA"),
487 	PINCTRL_PIN(188, "DDPC_CTRLCLK"),
488 	PINCTRL_PIN(189, "DDPC_CTRLDATA"),
489 	PINCTRL_PIN(190, "DDPD_CTRLCLK"),
490 	PINCTRL_PIN(191, "DDPD_CTRLDATA"),
491 };
492 
493 static const unsigned spth_spi0_pins[] = { 39, 40, 41, 42 };
494 static const unsigned spth_spi1_pins[] = { 43, 44, 45, 46 };
495 static const unsigned spth_uart0_pins[] = { 56, 57, 58, 59 };
496 static const unsigned spth_uart1_pins[] = { 60, 61, 62, 63 };
497 static const unsigned spth_uart2_pins[] = { 68, 69, 71, 71 };
498 static const unsigned spth_i2c0_pins[] = { 64, 65 };
499 static const unsigned spth_i2c1_pins[] = { 66, 67 };
500 static const unsigned spth_i2c2_pins[] = { 76, 95 };
501 
502 static const struct intel_pingroup spth_groups[] = {
503 	PIN_GROUP("spi0_grp", spth_spi0_pins, 1),
504 	PIN_GROUP("spi1_grp", spth_spi1_pins, 1),
505 	PIN_GROUP("uart0_grp", spth_uart0_pins, 1),
506 	PIN_GROUP("uart1_grp", spth_uart1_pins, 1),
507 	PIN_GROUP("uart2_grp", spth_uart2_pins, 1),
508 	PIN_GROUP("i2c0_grp", spth_i2c0_pins, 1),
509 	PIN_GROUP("i2c1_grp", spth_i2c1_pins, 1),
510 	PIN_GROUP("i2c2_grp", spth_i2c2_pins, 2),
511 };
512 
513 static const char * const spth_spi0_groups[] = { "spi0_grp" };
514 static const char * const spth_spi1_groups[] = { "spi0_grp" };
515 static const char * const spth_uart0_groups[] = { "uart0_grp" };
516 static const char * const spth_uart1_groups[] = { "uart1_grp" };
517 static const char * const spth_uart2_groups[] = { "uart2_grp" };
518 static const char * const spth_i2c0_groups[] = { "i2c0_grp" };
519 static const char * const spth_i2c1_groups[] = { "i2c1_grp" };
520 static const char * const spth_i2c2_groups[] = { "i2c2_grp" };
521 
522 static const struct intel_function spth_functions[] = {
523 	FUNCTION("spi0", spth_spi0_groups),
524 	FUNCTION("spi1", spth_spi1_groups),
525 	FUNCTION("uart0", spth_uart0_groups),
526 	FUNCTION("uart1", spth_uart1_groups),
527 	FUNCTION("uart2", spth_uart2_groups),
528 	FUNCTION("i2c0", spth_i2c0_groups),
529 	FUNCTION("i2c1", spth_i2c1_groups),
530 	FUNCTION("i2c2", spth_i2c2_groups),
531 };
532 
533 static const struct intel_community spth_communities[] = {
534 	SPT_COMMUNITY(0, 0, 47),
535 	SPT_COMMUNITY(1, 48, 180),
536 	SPT_COMMUNITY(2, 181, 191),
537 };
538 
539 static const struct intel_pinctrl_soc_data spth_soc_data = {
540 	.pins = spth_pins,
541 	.npins = ARRAY_SIZE(spth_pins),
542 	.groups = spth_groups,
543 	.ngroups = ARRAY_SIZE(spth_groups),
544 	.functions = spth_functions,
545 	.nfunctions = ARRAY_SIZE(spth_functions),
546 	.communities = spth_communities,
547 	.ncommunities = ARRAY_SIZE(spth_communities),
548 };
549 
550 static const struct acpi_device_id spt_pinctrl_acpi_match[] = {
551 	{ "INT344B", (kernel_ulong_t)&sptlp_soc_data },
552 	{ "INT345D", (kernel_ulong_t)&spth_soc_data },
553 	{ }
554 };
555 MODULE_DEVICE_TABLE(acpi, spt_pinctrl_acpi_match);
556 
557 static int spt_pinctrl_probe(struct platform_device *pdev)
558 {
559 	const struct intel_pinctrl_soc_data *soc_data;
560 	const struct acpi_device_id *id;
561 
562 	id = acpi_match_device(spt_pinctrl_acpi_match, &pdev->dev);
563 	if (!id || !id->driver_data)
564 		return -ENODEV;
565 
566 	soc_data = (const struct intel_pinctrl_soc_data *)id->driver_data;
567 	return intel_pinctrl_probe(pdev, soc_data);
568 }
569 
570 static const struct dev_pm_ops spt_pinctrl_pm_ops = {
571 	SET_LATE_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend,
572 				     intel_pinctrl_resume)
573 };
574 
575 static struct platform_driver spt_pinctrl_driver = {
576 	.probe = spt_pinctrl_probe,
577 	.remove = intel_pinctrl_remove,
578 	.driver = {
579 		.name = "sunrisepoint-pinctrl",
580 		.acpi_match_table = spt_pinctrl_acpi_match,
581 		.pm = &spt_pinctrl_pm_ops,
582 	},
583 };
584 
585 static int __init spt_pinctrl_init(void)
586 {
587 	return platform_driver_register(&spt_pinctrl_driver);
588 }
589 subsys_initcall(spt_pinctrl_init);
590 
591 static void __exit spt_pinctrl_exit(void)
592 {
593 	platform_driver_unregister(&spt_pinctrl_driver);
594 }
595 module_exit(spt_pinctrl_exit);
596 
597 MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>");
598 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
599 MODULE_DESCRIPTION("Intel Sunrisepoint PCH pinctrl/GPIO driver");
600 MODULE_LICENSE("GPL v2");
601