1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Pinctrl data for Wondermedia WM8750 SoC 4 * 5 * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz> 6 */ 7 8 #include <linux/io.h> 9 #include <linux/init.h> 10 #include <linux/pinctrl/pinctrl.h> 11 #include <linux/platform_device.h> 12 #include <linux/slab.h> 13 14 #include "pinctrl-wmt.h" 15 16 /* 17 * Describe the register offsets within the GPIO memory space 18 * The dedicated external GPIO's should always be listed in bank 0 19 * so they are exported in the 0..31 range which is what users 20 * expect. 21 * 22 * Do not reorder these banks as it will change the pin numbering 23 */ 24 static const struct wmt_pinctrl_bank_registers wm8750_banks[] = { 25 WMT_PINCTRL_BANK(0x40, 0x80, 0xC0, 0x00, 0x480, 0x4C0), /* 0 */ 26 WMT_PINCTRL_BANK(0x44, 0x84, 0xC4, 0x04, 0x484, 0x4C4), /* 1 */ 27 WMT_PINCTRL_BANK(0x48, 0x88, 0xC8, 0x08, 0x488, 0x4C8), /* 2 */ 28 WMT_PINCTRL_BANK(0x4C, 0x8C, 0xCC, 0x0C, 0x48C, 0x4CC), /* 3 */ 29 WMT_PINCTRL_BANK(0x50, 0x90, 0xD0, 0x10, 0x490, 0x4D0), /* 4 */ 30 WMT_PINCTRL_BANK(0x54, 0x94, 0xD4, 0x14, 0x494, 0x4D4), /* 5 */ 31 WMT_PINCTRL_BANK(0x58, 0x98, 0xD8, 0x18, 0x498, 0x4D8), /* 6 */ 32 WMT_PINCTRL_BANK(0x5C, 0x9C, 0xDC, 0x1C, 0x49C, 0x4DC), /* 7 */ 33 WMT_PINCTRL_BANK(0x60, 0xA0, 0xE0, 0x20, 0x4A0, 0x4E0), /* 8 */ 34 WMT_PINCTRL_BANK(0x70, 0xB0, 0xF0, 0x30, 0x4B0, 0x4F0), /* 9 */ 35 WMT_PINCTRL_BANK(0x7C, 0xBC, 0xDC, 0x3C, 0x4BC, 0x4FC), /* 10 */ 36 }; 37 38 /* Please keep sorted by bank/bit */ 39 #define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0) 40 #define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1) 41 #define WMT_PIN_EXTGPIO2 WMT_PIN(0, 2) 42 #define WMT_PIN_EXTGPIO3 WMT_PIN(0, 3) 43 #define WMT_PIN_EXTGPIO4 WMT_PIN(0, 4) 44 #define WMT_PIN_EXTGPIO5 WMT_PIN(0, 5) 45 #define WMT_PIN_EXTGPIO6 WMT_PIN(0, 6) 46 #define WMT_PIN_EXTGPIO7 WMT_PIN(0, 7) 47 #define WMT_PIN_WAKEUP0 WMT_PIN(0, 16) 48 #define WMT_PIN_WAKEUP1 WMT_PIN(0, 17) 49 #define WMT_PIN_SD0CD WMT_PIN(0, 28) 50 #define WMT_PIN_VDOUT0 WMT_PIN(1, 0) 51 #define WMT_PIN_VDOUT1 WMT_PIN(1, 1) 52 #define WMT_PIN_VDOUT2 WMT_PIN(1, 2) 53 #define WMT_PIN_VDOUT3 WMT_PIN(1, 3) 54 #define WMT_PIN_VDOUT4 WMT_PIN(1, 4) 55 #define WMT_PIN_VDOUT5 WMT_PIN(1, 5) 56 #define WMT_PIN_VDOUT6 WMT_PIN(1, 6) 57 #define WMT_PIN_VDOUT7 WMT_PIN(1, 7) 58 #define WMT_PIN_VDOUT8 WMT_PIN(1, 8) 59 #define WMT_PIN_VDOUT9 WMT_PIN(1, 9) 60 #define WMT_PIN_VDOUT10 WMT_PIN(1, 10) 61 #define WMT_PIN_VDOUT11 WMT_PIN(1, 11) 62 #define WMT_PIN_VDOUT12 WMT_PIN(1, 12) 63 #define WMT_PIN_VDOUT13 WMT_PIN(1, 13) 64 #define WMT_PIN_VDOUT14 WMT_PIN(1, 14) 65 #define WMT_PIN_VDOUT15 WMT_PIN(1, 15) 66 #define WMT_PIN_VDOUT16 WMT_PIN(1, 16) 67 #define WMT_PIN_VDOUT17 WMT_PIN(1, 17) 68 #define WMT_PIN_VDOUT18 WMT_PIN(1, 18) 69 #define WMT_PIN_VDOUT19 WMT_PIN(1, 19) 70 #define WMT_PIN_VDOUT20 WMT_PIN(1, 20) 71 #define WMT_PIN_VDOUT21 WMT_PIN(1, 21) 72 #define WMT_PIN_VDOUT22 WMT_PIN(1, 22) 73 #define WMT_PIN_VDOUT23 WMT_PIN(1, 23) 74 #define WMT_PIN_VDIN0 WMT_PIN(2, 0) 75 #define WMT_PIN_VDIN1 WMT_PIN(2, 1) 76 #define WMT_PIN_VDIN2 WMT_PIN(2, 2) 77 #define WMT_PIN_VDIN3 WMT_PIN(2, 3) 78 #define WMT_PIN_VDIN4 WMT_PIN(2, 4) 79 #define WMT_PIN_VDIN5 WMT_PIN(2, 5) 80 #define WMT_PIN_VDIN6 WMT_PIN(2, 6) 81 #define WMT_PIN_VDIN7 WMT_PIN(2, 7) 82 #define WMT_PIN_SPI0_MOSI WMT_PIN(2, 24) 83 #define WMT_PIN_SPI0_MISO WMT_PIN(2, 25) 84 #define WMT_PIN_SPI0_SS WMT_PIN(2, 26) 85 #define WMT_PIN_SPI0_CLK WMT_PIN(2, 27) 86 #define WMT_PIN_SPI0_SSB WMT_PIN(2, 28) 87 #define WMT_PIN_SD0CLK WMT_PIN(3, 17) 88 #define WMT_PIN_SD0CMD WMT_PIN(3, 18) 89 #define WMT_PIN_SD0WP WMT_PIN(3, 19) 90 #define WMT_PIN_SD0DATA0 WMT_PIN(3, 20) 91 #define WMT_PIN_SD0DATA1 WMT_PIN(3, 21) 92 #define WMT_PIN_SD0DATA2 WMT_PIN(3, 22) 93 #define WMT_PIN_SD0DATA3 WMT_PIN(3, 23) 94 #define WMT_PIN_SD1DATA0 WMT_PIN(3, 24) 95 #define WMT_PIN_SD1DATA1 WMT_PIN(3, 25) 96 #define WMT_PIN_SD1DATA2 WMT_PIN(3, 26) 97 #define WMT_PIN_SD1DATA3 WMT_PIN(3, 27) 98 #define WMT_PIN_SD1DATA4 WMT_PIN(3, 28) 99 #define WMT_PIN_SD1DATA5 WMT_PIN(3, 29) 100 #define WMT_PIN_SD1DATA6 WMT_PIN(3, 30) 101 #define WMT_PIN_SD1DATA7 WMT_PIN(3, 31) 102 #define WMT_PIN_I2C0_SCL WMT_PIN(5, 8) 103 #define WMT_PIN_I2C0_SDA WMT_PIN(5, 9) 104 #define WMT_PIN_I2C1_SCL WMT_PIN(5, 10) 105 #define WMT_PIN_I2C1_SDA WMT_PIN(5, 11) 106 #define WMT_PIN_I2C2_SCL WMT_PIN(5, 12) 107 #define WMT_PIN_I2C2_SDA WMT_PIN(5, 13) 108 #define WMT_PIN_UART0_RTS WMT_PIN(5, 16) 109 #define WMT_PIN_UART0_TXD WMT_PIN(5, 17) 110 #define WMT_PIN_UART0_CTS WMT_PIN(5, 18) 111 #define WMT_PIN_UART0_RXD WMT_PIN(5, 19) 112 #define WMT_PIN_UART1_RTS WMT_PIN(5, 20) 113 #define WMT_PIN_UART1_TXD WMT_PIN(5, 21) 114 #define WMT_PIN_UART1_CTS WMT_PIN(5, 22) 115 #define WMT_PIN_UART1_RXD WMT_PIN(5, 23) 116 #define WMT_PIN_UART2_RTS WMT_PIN(5, 24) 117 #define WMT_PIN_UART2_TXD WMT_PIN(5, 25) 118 #define WMT_PIN_UART2_CTS WMT_PIN(5, 26) 119 #define WMT_PIN_UART2_RXD WMT_PIN(5, 27) 120 #define WMT_PIN_UART3_RTS WMT_PIN(5, 28) 121 #define WMT_PIN_UART3_TXD WMT_PIN(5, 29) 122 #define WMT_PIN_UART3_CTS WMT_PIN(5, 30) 123 #define WMT_PIN_UART3_RXD WMT_PIN(5, 31) 124 #define WMT_PIN_SD2CD WMT_PIN(6, 0) 125 #define WMT_PIN_SD2DATA3 WMT_PIN(6, 1) 126 #define WMT_PIN_SD2DATA0 WMT_PIN(6, 2) 127 #define WMT_PIN_SD2WP WMT_PIN(6, 3) 128 #define WMT_PIN_SD2DATA1 WMT_PIN(6, 4) 129 #define WMT_PIN_SD2DATA2 WMT_PIN(6, 5) 130 #define WMT_PIN_SD2CMD WMT_PIN(6, 6) 131 #define WMT_PIN_SD2CLK WMT_PIN(6, 7) 132 #define WMT_PIN_SD2PWR WMT_PIN(6, 9) 133 #define WMT_PIN_SD1CLK WMT_PIN(7, 0) 134 #define WMT_PIN_SD1CMD WMT_PIN(7, 1) 135 #define WMT_PIN_SD1PWR WMT_PIN(7, 10) 136 #define WMT_PIN_SD1WP WMT_PIN(7, 11) 137 #define WMT_PIN_SD1CD WMT_PIN(7, 12) 138 #define WMT_PIN_SPI0SS3 WMT_PIN(7, 24) 139 #define WMT_PIN_SPI0SS2 WMT_PIN(7, 25) 140 #define WMT_PIN_PWMOUT1 WMT_PIN(7, 26) 141 #define WMT_PIN_PWMOUT0 WMT_PIN(7, 27) 142 143 static const struct pinctrl_pin_desc wm8750_pins[] = { 144 PINCTRL_PIN(WMT_PIN_EXTGPIO0, "extgpio0"), 145 PINCTRL_PIN(WMT_PIN_EXTGPIO1, "extgpio1"), 146 PINCTRL_PIN(WMT_PIN_EXTGPIO2, "extgpio2"), 147 PINCTRL_PIN(WMT_PIN_EXTGPIO3, "extgpio3"), 148 PINCTRL_PIN(WMT_PIN_EXTGPIO4, "extgpio4"), 149 PINCTRL_PIN(WMT_PIN_EXTGPIO5, "extgpio5"), 150 PINCTRL_PIN(WMT_PIN_EXTGPIO6, "extgpio6"), 151 PINCTRL_PIN(WMT_PIN_EXTGPIO7, "extgpio7"), 152 PINCTRL_PIN(WMT_PIN_WAKEUP0, "wakeup0"), 153 PINCTRL_PIN(WMT_PIN_WAKEUP1, "wakeup1"), 154 PINCTRL_PIN(WMT_PIN_SD0CD, "sd0_cd"), 155 PINCTRL_PIN(WMT_PIN_VDOUT0, "vdout0"), 156 PINCTRL_PIN(WMT_PIN_VDOUT1, "vdout1"), 157 PINCTRL_PIN(WMT_PIN_VDOUT2, "vdout2"), 158 PINCTRL_PIN(WMT_PIN_VDOUT3, "vdout3"), 159 PINCTRL_PIN(WMT_PIN_VDOUT4, "vdout4"), 160 PINCTRL_PIN(WMT_PIN_VDOUT5, "vdout5"), 161 PINCTRL_PIN(WMT_PIN_VDOUT6, "vdout6"), 162 PINCTRL_PIN(WMT_PIN_VDOUT7, "vdout7"), 163 PINCTRL_PIN(WMT_PIN_VDOUT8, "vdout8"), 164 PINCTRL_PIN(WMT_PIN_VDOUT9, "vdout9"), 165 PINCTRL_PIN(WMT_PIN_VDOUT10, "vdout10"), 166 PINCTRL_PIN(WMT_PIN_VDOUT11, "vdout11"), 167 PINCTRL_PIN(WMT_PIN_VDOUT12, "vdout12"), 168 PINCTRL_PIN(WMT_PIN_VDOUT13, "vdout13"), 169 PINCTRL_PIN(WMT_PIN_VDOUT14, "vdout14"), 170 PINCTRL_PIN(WMT_PIN_VDOUT15, "vdout15"), 171 PINCTRL_PIN(WMT_PIN_VDOUT16, "vdout16"), 172 PINCTRL_PIN(WMT_PIN_VDOUT17, "vdout17"), 173 PINCTRL_PIN(WMT_PIN_VDOUT18, "vdout18"), 174 PINCTRL_PIN(WMT_PIN_VDOUT19, "vdout19"), 175 PINCTRL_PIN(WMT_PIN_VDOUT20, "vdout20"), 176 PINCTRL_PIN(WMT_PIN_VDOUT21, "vdout21"), 177 PINCTRL_PIN(WMT_PIN_VDOUT22, "vdout22"), 178 PINCTRL_PIN(WMT_PIN_VDOUT23, "vdout23"), 179 PINCTRL_PIN(WMT_PIN_VDIN0, "vdin0"), 180 PINCTRL_PIN(WMT_PIN_VDIN1, "vdin1"), 181 PINCTRL_PIN(WMT_PIN_VDIN2, "vdin2"), 182 PINCTRL_PIN(WMT_PIN_VDIN3, "vdin3"), 183 PINCTRL_PIN(WMT_PIN_VDIN4, "vdin4"), 184 PINCTRL_PIN(WMT_PIN_VDIN5, "vdin5"), 185 PINCTRL_PIN(WMT_PIN_VDIN6, "vdin6"), 186 PINCTRL_PIN(WMT_PIN_VDIN7, "vdin7"), 187 PINCTRL_PIN(WMT_PIN_SPI0_MOSI, "spi0_mosi"), 188 PINCTRL_PIN(WMT_PIN_SPI0_MISO, "spi0_miso"), 189 PINCTRL_PIN(WMT_PIN_SPI0_SS, "spi0_ss"), 190 PINCTRL_PIN(WMT_PIN_SPI0_CLK, "spi0_clk"), 191 PINCTRL_PIN(WMT_PIN_SPI0_SSB, "spi0_ssb"), 192 PINCTRL_PIN(WMT_PIN_SD0CLK, "sd0_clk"), 193 PINCTRL_PIN(WMT_PIN_SD0CMD, "sd0_cmd"), 194 PINCTRL_PIN(WMT_PIN_SD0WP, "sd0_wp"), 195 PINCTRL_PIN(WMT_PIN_SD0DATA0, "sd0_data0"), 196 PINCTRL_PIN(WMT_PIN_SD0DATA1, "sd0_data1"), 197 PINCTRL_PIN(WMT_PIN_SD0DATA2, "sd0_data2"), 198 PINCTRL_PIN(WMT_PIN_SD0DATA3, "sd0_data3"), 199 PINCTRL_PIN(WMT_PIN_SD1DATA0, "sd1_data0"), 200 PINCTRL_PIN(WMT_PIN_SD1DATA1, "sd1_data1"), 201 PINCTRL_PIN(WMT_PIN_SD1DATA2, "sd1_data2"), 202 PINCTRL_PIN(WMT_PIN_SD1DATA3, "sd1_data3"), 203 PINCTRL_PIN(WMT_PIN_SD1DATA4, "sd1_data4"), 204 PINCTRL_PIN(WMT_PIN_SD1DATA5, "sd1_data5"), 205 PINCTRL_PIN(WMT_PIN_SD1DATA6, "sd1_data6"), 206 PINCTRL_PIN(WMT_PIN_SD1DATA7, "sd1_data7"), 207 PINCTRL_PIN(WMT_PIN_I2C0_SCL, "i2c0_scl"), 208 PINCTRL_PIN(WMT_PIN_I2C0_SDA, "i2c0_sda"), 209 PINCTRL_PIN(WMT_PIN_I2C1_SCL, "i2c1_scl"), 210 PINCTRL_PIN(WMT_PIN_I2C1_SDA, "i2c1_sda"), 211 PINCTRL_PIN(WMT_PIN_I2C2_SCL, "i2c2_scl"), 212 PINCTRL_PIN(WMT_PIN_I2C2_SDA, "i2c2_sda"), 213 PINCTRL_PIN(WMT_PIN_UART0_RTS, "uart0_rts"), 214 PINCTRL_PIN(WMT_PIN_UART0_TXD, "uart0_txd"), 215 PINCTRL_PIN(WMT_PIN_UART0_CTS, "uart0_cts"), 216 PINCTRL_PIN(WMT_PIN_UART0_RXD, "uart0_rxd"), 217 PINCTRL_PIN(WMT_PIN_UART1_RTS, "uart1_rts"), 218 PINCTRL_PIN(WMT_PIN_UART1_TXD, "uart1_txd"), 219 PINCTRL_PIN(WMT_PIN_UART1_CTS, "uart1_cts"), 220 PINCTRL_PIN(WMT_PIN_UART1_RXD, "uart1_rxd"), 221 PINCTRL_PIN(WMT_PIN_UART2_RTS, "uart2_rts"), 222 PINCTRL_PIN(WMT_PIN_UART2_TXD, "uart2_txd"), 223 PINCTRL_PIN(WMT_PIN_UART2_CTS, "uart2_cts"), 224 PINCTRL_PIN(WMT_PIN_UART2_RXD, "uart2_rxd"), 225 PINCTRL_PIN(WMT_PIN_UART3_RTS, "uart3_rts"), 226 PINCTRL_PIN(WMT_PIN_UART3_TXD, "uart3_txd"), 227 PINCTRL_PIN(WMT_PIN_UART3_CTS, "uart3_cts"), 228 PINCTRL_PIN(WMT_PIN_UART3_RXD, "uart3_rxd"), 229 PINCTRL_PIN(WMT_PIN_SD2CD, "sd2_cd"), 230 PINCTRL_PIN(WMT_PIN_SD2DATA3, "sd2_data3"), 231 PINCTRL_PIN(WMT_PIN_SD2DATA0, "sd2_data0"), 232 PINCTRL_PIN(WMT_PIN_SD2WP, "sd2_wp"), 233 PINCTRL_PIN(WMT_PIN_SD2DATA1, "sd2_data1"), 234 PINCTRL_PIN(WMT_PIN_SD2DATA2, "sd2_data2"), 235 PINCTRL_PIN(WMT_PIN_SD2CMD, "sd2_cmd"), 236 PINCTRL_PIN(WMT_PIN_SD2CLK, "sd2_clk"), 237 PINCTRL_PIN(WMT_PIN_SD2PWR, "sd2_pwr"), 238 PINCTRL_PIN(WMT_PIN_SD1CLK, "sd1_clk"), 239 PINCTRL_PIN(WMT_PIN_SD1CMD, "sd1_cmd"), 240 PINCTRL_PIN(WMT_PIN_SD1PWR, "sd1_pwr"), 241 PINCTRL_PIN(WMT_PIN_SD1WP, "sd1_wp"), 242 PINCTRL_PIN(WMT_PIN_SD1CD, "sd1_cd"), 243 PINCTRL_PIN(WMT_PIN_SPI0SS3, "spi0_ss3"), 244 PINCTRL_PIN(WMT_PIN_SPI0SS2, "spi0_ss2"), 245 PINCTRL_PIN(WMT_PIN_PWMOUT1, "pwmout1"), 246 PINCTRL_PIN(WMT_PIN_PWMOUT0, "pwmout0"), 247 }; 248 249 /* Order of these names must match the above list */ 250 static const char * const wm8750_groups[] = { 251 "extgpio0", 252 "extgpio1", 253 "extgpio2", 254 "extgpio3", 255 "extgpio4", 256 "extgpio5", 257 "extgpio6", 258 "extgpio7", 259 "wakeup0", 260 "wakeup1", 261 "sd0_cd", 262 "vdout0", 263 "vdout1", 264 "vdout2", 265 "vdout3", 266 "vdout4", 267 "vdout5", 268 "vdout6", 269 "vdout7", 270 "vdout8", 271 "vdout9", 272 "vdout10", 273 "vdout11", 274 "vdout12", 275 "vdout13", 276 "vdout14", 277 "vdout15", 278 "vdout16", 279 "vdout17", 280 "vdout18", 281 "vdout19", 282 "vdout20", 283 "vdout21", 284 "vdout22", 285 "vdout23", 286 "vdin0", 287 "vdin1", 288 "vdin2", 289 "vdin3", 290 "vdin4", 291 "vdin5", 292 "vdin6", 293 "vdin7", 294 "spi0_mosi", 295 "spi0_miso", 296 "spi0_ss", 297 "spi0_clk", 298 "spi0_ssb", 299 "sd0_clk", 300 "sd0_cmd", 301 "sd0_wp", 302 "sd0_data0", 303 "sd0_data1", 304 "sd0_data2", 305 "sd0_data3", 306 "sd1_data0", 307 "sd1_data1", 308 "sd1_data2", 309 "sd1_data3", 310 "sd1_data4", 311 "sd1_data5", 312 "sd1_data6", 313 "sd1_data7", 314 "i2c0_scl", 315 "i2c0_sda", 316 "i2c1_scl", 317 "i2c1_sda", 318 "i2c2_scl", 319 "i2c2_sda", 320 "uart0_rts", 321 "uart0_txd", 322 "uart0_cts", 323 "uart0_rxd", 324 "uart1_rts", 325 "uart1_txd", 326 "uart1_cts", 327 "uart1_rxd", 328 "uart2_rts", 329 "uart2_txd", 330 "uart2_cts", 331 "uart2_rxd", 332 "uart3_rts", 333 "uart3_txd", 334 "uart3_cts", 335 "uart3_rxd", 336 "sd2_cd", 337 "sd2_data3", 338 "sd2_data0", 339 "sd2_wp", 340 "sd2_data1", 341 "sd2_data2", 342 "sd2_cmd", 343 "sd2_clk", 344 "sd2_pwr", 345 "sd1_clk", 346 "sd1_cmd", 347 "sd1_pwr", 348 "sd1_wp", 349 "sd1_cd", 350 "spi0_ss3", 351 "spi0_ss2", 352 "pwmout1", 353 "pwmout0", 354 }; 355 356 static int wm8750_pinctrl_probe(struct platform_device *pdev) 357 { 358 struct wmt_pinctrl_data *data; 359 360 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 361 if (!data) 362 return -ENOMEM; 363 364 data->banks = wm8750_banks; 365 data->nbanks = ARRAY_SIZE(wm8750_banks); 366 data->pins = wm8750_pins; 367 data->npins = ARRAY_SIZE(wm8750_pins); 368 data->groups = wm8750_groups; 369 data->ngroups = ARRAY_SIZE(wm8750_groups); 370 371 return wmt_pinctrl_probe(pdev, data); 372 } 373 374 static const struct of_device_id wmt_pinctrl_of_match[] = { 375 { .compatible = "wm,wm8750-pinctrl" }, 376 { /* sentinel */ }, 377 }; 378 379 static struct platform_driver wmt_pinctrl_driver = { 380 .probe = wm8750_pinctrl_probe, 381 .driver = { 382 .name = "pinctrl-wm8750", 383 .of_match_table = wmt_pinctrl_of_match, 384 .suppress_bind_attrs = true, 385 }, 386 }; 387 builtin_platform_driver(wmt_pinctrl_driver); 388