Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Qualcomm IPQ40xx pinctrl |
| 4 | * |
| 5 | * Copyright (c) 2019 Sartura Ltd. |
| 6 | * |
| 7 | * Author: Robert Marko <robert.marko@sartura.hr> |
| 8 | */ |
| 9 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 10 | #include <dm.h> |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 11 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 12 | #include "pinctrl-qcom.h" |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 13 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 14 | #define MAX_PIN_NAME_LEN 32 |
| 15 | static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); |
Robert Marko | 0a41b46 | 2024-04-22 13:43:28 +0200 | [diff] [blame] | 16 | |
| 17 | enum ipq4019_functions { |
| 18 | qca_mux_gpio, |
| 19 | qca_mux_aud_pin, |
| 20 | qca_mux_audio_pwm, |
| 21 | qca_mux_blsp_i2c0, |
| 22 | qca_mux_blsp_i2c1, |
| 23 | qca_mux_blsp_spi0, |
| 24 | qca_mux_blsp_spi1, |
| 25 | qca_mux_blsp_uart0, |
| 26 | qca_mux_blsp_uart1, |
| 27 | qca_mux_chip_rst, |
| 28 | qca_mux_i2s_rx, |
| 29 | qca_mux_i2s_spdif_in, |
| 30 | qca_mux_i2s_spdif_out, |
| 31 | qca_mux_i2s_td, |
| 32 | qca_mux_i2s_tx, |
| 33 | qca_mux_jtag, |
| 34 | qca_mux_led0, |
| 35 | qca_mux_led1, |
| 36 | qca_mux_led2, |
| 37 | qca_mux_led3, |
| 38 | qca_mux_led4, |
| 39 | qca_mux_led5, |
| 40 | qca_mux_led6, |
| 41 | qca_mux_led7, |
| 42 | qca_mux_led8, |
| 43 | qca_mux_led9, |
| 44 | qca_mux_led10, |
| 45 | qca_mux_led11, |
| 46 | qca_mux_mdc, |
| 47 | qca_mux_mdio, |
| 48 | qca_mux_pcie, |
| 49 | qca_mux_pmu, |
| 50 | qca_mux_prng_rosc, |
| 51 | qca_mux_qpic, |
| 52 | qca_mux_rgmii, |
| 53 | qca_mux_rmii, |
| 54 | qca_mux_sdio, |
| 55 | qca_mux_smart0, |
| 56 | qca_mux_smart1, |
| 57 | qca_mux_smart2, |
| 58 | qca_mux_smart3, |
| 59 | qca_mux_tm, |
| 60 | qca_mux_wifi0, |
| 61 | qca_mux_wifi1, |
| 62 | qca_mux_NA, |
| 63 | }; |
| 64 | |
| 65 | #define QCA_PIN_FUNCTION(fname) \ |
| 66 | [qca_mux_##fname] = {#fname, qca_mux_##fname} |
| 67 | |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 68 | static const struct pinctrl_function msm_pinctrl_functions[] = { |
Robert Marko | 0a41b46 | 2024-04-22 13:43:28 +0200 | [diff] [blame] | 69 | QCA_PIN_FUNCTION(aud_pin), |
| 70 | QCA_PIN_FUNCTION(audio_pwm), |
| 71 | QCA_PIN_FUNCTION(blsp_i2c0), |
| 72 | QCA_PIN_FUNCTION(blsp_i2c1), |
| 73 | QCA_PIN_FUNCTION(blsp_spi0), |
| 74 | QCA_PIN_FUNCTION(blsp_spi1), |
| 75 | QCA_PIN_FUNCTION(blsp_uart0), |
| 76 | QCA_PIN_FUNCTION(blsp_uart1), |
| 77 | QCA_PIN_FUNCTION(chip_rst), |
| 78 | QCA_PIN_FUNCTION(gpio), |
| 79 | QCA_PIN_FUNCTION(i2s_rx), |
| 80 | QCA_PIN_FUNCTION(i2s_spdif_in), |
| 81 | QCA_PIN_FUNCTION(i2s_spdif_out), |
| 82 | QCA_PIN_FUNCTION(i2s_td), |
| 83 | QCA_PIN_FUNCTION(i2s_tx), |
| 84 | QCA_PIN_FUNCTION(jtag), |
| 85 | QCA_PIN_FUNCTION(led0), |
| 86 | QCA_PIN_FUNCTION(led1), |
| 87 | QCA_PIN_FUNCTION(led2), |
| 88 | QCA_PIN_FUNCTION(led3), |
| 89 | QCA_PIN_FUNCTION(led4), |
| 90 | QCA_PIN_FUNCTION(led5), |
| 91 | QCA_PIN_FUNCTION(led6), |
| 92 | QCA_PIN_FUNCTION(led7), |
| 93 | QCA_PIN_FUNCTION(led8), |
| 94 | QCA_PIN_FUNCTION(led9), |
| 95 | QCA_PIN_FUNCTION(led10), |
| 96 | QCA_PIN_FUNCTION(led11), |
| 97 | QCA_PIN_FUNCTION(mdc), |
| 98 | QCA_PIN_FUNCTION(mdio), |
| 99 | QCA_PIN_FUNCTION(pcie), |
| 100 | QCA_PIN_FUNCTION(pmu), |
| 101 | QCA_PIN_FUNCTION(prng_rosc), |
| 102 | QCA_PIN_FUNCTION(qpic), |
| 103 | QCA_PIN_FUNCTION(rgmii), |
| 104 | QCA_PIN_FUNCTION(rmii), |
| 105 | QCA_PIN_FUNCTION(sdio), |
| 106 | QCA_PIN_FUNCTION(smart0), |
| 107 | QCA_PIN_FUNCTION(smart1), |
| 108 | QCA_PIN_FUNCTION(smart2), |
| 109 | QCA_PIN_FUNCTION(smart3), |
| 110 | QCA_PIN_FUNCTION(tm), |
| 111 | QCA_PIN_FUNCTION(wifi0), |
| 112 | QCA_PIN_FUNCTION(wifi1), |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 113 | }; |
Robert Marko | 0a41b46 | 2024-04-22 13:43:28 +0200 | [diff] [blame] | 114 | |
| 115 | typedef unsigned int msm_pin_function[15]; |
| 116 | |
| 117 | #define PINGROUP(id, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14) \ |
| 118 | [id] = { qca_mux_gpio, /* gpio mode */ \ |
| 119 | qca_mux_##f1, \ |
| 120 | qca_mux_##f2, \ |
| 121 | qca_mux_##f3, \ |
| 122 | qca_mux_##f4, \ |
| 123 | qca_mux_##f5, \ |
| 124 | qca_mux_##f6, \ |
| 125 | qca_mux_##f7, \ |
| 126 | qca_mux_##f8, \ |
| 127 | qca_mux_##f9, \ |
| 128 | qca_mux_##f10, \ |
| 129 | qca_mux_##f11, \ |
| 130 | qca_mux_##f12, \ |
| 131 | qca_mux_##f13, \ |
| 132 | qca_mux_##f14 \ |
| 133 | } |
| 134 | |
| 135 | static const msm_pin_function ipq4019_pin_functions[] = { |
| 136 | PINGROUP(0, jtag, smart0, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 137 | NA, NA), |
| 138 | PINGROUP(1, jtag, smart0, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 139 | NA, NA), |
| 140 | PINGROUP(2, jtag, smart0, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 141 | NA, NA), |
| 142 | PINGROUP(3, jtag, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 143 | PINGROUP(4, jtag, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 144 | PINGROUP(5, jtag, smart0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 145 | NA), |
| 146 | PINGROUP(6, mdio, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 147 | PINGROUP(7, mdc, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 148 | PINGROUP(8, blsp_uart1, NA, NA, smart1, NA, NA, NA, NA, NA, NA, NA, |
| 149 | NA, NA, NA), |
| 150 | PINGROUP(9, blsp_uart1, NA, NA, smart1, NA, NA, NA, NA, NA, NA, NA, |
| 151 | NA, NA, NA), |
| 152 | PINGROUP(10, blsp_uart1, NA, NA, blsp_i2c0, NA, NA, NA, NA, NA, NA, NA, |
| 153 | NA, NA, NA), |
| 154 | PINGROUP(11, blsp_uart1, NA, NA, blsp_i2c0, NA, NA, NA, NA, NA, NA, NA, |
| 155 | NA, NA, NA), |
| 156 | PINGROUP(12, blsp_spi0, blsp_i2c1, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 157 | NA, NA, NA), |
| 158 | PINGROUP(13, blsp_spi0, blsp_i2c1, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 159 | NA, NA, NA), |
| 160 | PINGROUP(14, blsp_spi0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 161 | NA), |
| 162 | PINGROUP(15, blsp_spi0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 163 | NA), |
| 164 | PINGROUP(16, blsp_uart0, led0, smart1, NA, NA, NA, NA, NA, NA, NA, NA, |
| 165 | NA, NA, NA), |
| 166 | PINGROUP(17, blsp_uart0, led1, smart1, NA, NA, NA, NA, NA, NA, NA, NA, |
| 167 | NA, NA, NA), |
| 168 | PINGROUP(18, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 169 | PINGROUP(19, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 170 | PINGROUP(20, blsp_i2c0, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 171 | NA, NA), |
| 172 | PINGROUP(21, blsp_i2c0, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 173 | NA, NA), |
| 174 | PINGROUP(22, rgmii, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 175 | NA), |
| 176 | PINGROUP(23, sdio, rgmii, i2s_rx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 177 | NA, NA), |
| 178 | PINGROUP(24, sdio, rgmii, i2s_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 179 | NA, NA), |
| 180 | PINGROUP(25, sdio, rgmii, i2s_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 181 | NA, NA), |
| 182 | PINGROUP(26, sdio, rgmii, i2s_tx, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 183 | NA, NA), |
| 184 | PINGROUP(27, sdio, rgmii, i2s_td, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 185 | NA, NA), |
| 186 | PINGROUP(28, sdio, rgmii, i2s_td, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 187 | NA, NA), |
| 188 | PINGROUP(29, sdio, rgmii, i2s_td, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 189 | NA, NA), |
| 190 | PINGROUP(30, sdio, rgmii, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, |
| 191 | NA, NA, NA), |
| 192 | PINGROUP(31, sdio, rgmii, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, |
| 193 | NA, NA, NA), |
| 194 | PINGROUP(32, sdio, rgmii, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, |
| 195 | NA, NA, NA), |
| 196 | PINGROUP(33, rgmii, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 197 | NA, NA), |
| 198 | PINGROUP(34, blsp_i2c1, i2s_spdif_in, NA, NA, NA, NA, NA, NA, NA, NA, |
| 199 | NA, NA, NA, NA), |
| 200 | PINGROUP(35, blsp_i2c1, i2s_spdif_out, NA, NA, NA, NA, NA, NA, NA, NA, |
| 201 | NA, NA, NA, NA), |
| 202 | PINGROUP(36, rmii, led2, led0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 203 | NA), |
| 204 | PINGROUP(37, rmii, wifi0, wifi1, led1, NA, NA, NA, NA, NA, NA, NA, NA, |
| 205 | NA, NA), |
| 206 | PINGROUP(38, rmii, led2, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 207 | NA), |
| 208 | PINGROUP(39, rmii, pcie, led3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 209 | NA), |
| 210 | PINGROUP(40, rmii, wifi0, wifi1, smart2, led4, NA, NA, NA, NA, NA, NA, |
| 211 | NA, NA, NA), |
| 212 | PINGROUP(41, rmii, wifi0, wifi1, smart2, NA, NA, NA, NA, NA, NA, NA, |
| 213 | NA, NA, NA), |
| 214 | PINGROUP(42, rmii, wifi0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 215 | NA), |
| 216 | PINGROUP(43, rmii, wifi1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 217 | NA), |
| 218 | PINGROUP(44, rmii, blsp_spi1, smart0, led5, NA, NA, NA, NA, NA, NA, NA, |
| 219 | NA, NA, NA), |
| 220 | PINGROUP(45, rmii, blsp_spi1, blsp_spi0, smart0, led6, NA, NA, NA, NA, |
| 221 | NA, NA, NA, NA, NA), |
| 222 | PINGROUP(46, rmii, blsp_spi1, smart0, led7, NA, NA, NA, NA, NA, NA, NA, |
| 223 | NA, NA, NA), |
| 224 | PINGROUP(47, rmii, blsp_spi1, smart0, led8, NA, NA, NA, NA, NA, NA, NA, |
| 225 | NA, NA, NA), |
| 226 | PINGROUP(48, rmii, aud_pin, smart2, led9, NA, NA, NA, NA, NA, NA, NA, |
| 227 | NA, NA, NA), |
| 228 | PINGROUP(49, rmii, aud_pin, smart2, led10, NA, NA, NA, NA, NA, NA, NA, |
| 229 | NA, NA, NA), |
| 230 | PINGROUP(50, rmii, aud_pin, wifi0, wifi1, led11, NA, NA, NA, NA, NA, |
| 231 | NA, NA, NA, NA), |
| 232 | PINGROUP(51, rmii, aud_pin, wifi0, wifi1, NA, NA, NA, NA, NA, NA, NA, |
| 233 | NA, NA, NA), |
| 234 | PINGROUP(52, qpic, mdc, pcie, i2s_tx, NA, NA, NA, tm, wifi0, wifi1, NA, |
| 235 | NA, NA, NA), |
| 236 | PINGROUP(53, qpic, mdio, i2s_tx, prng_rosc, NA, tm, wifi0, wifi1, NA, |
| 237 | NA, NA, NA, NA, NA), |
| 238 | PINGROUP(54, qpic, blsp_spi0, i2s_td, NA, pmu, NA, NA, NA, tm, NA, NA, |
| 239 | NA, NA, NA), |
| 240 | PINGROUP(55, qpic, blsp_spi0, i2s_td, NA, pmu, NA, NA, NA, tm, NA, NA, |
| 241 | NA, NA, NA), |
| 242 | PINGROUP(56, qpic, blsp_spi0, i2s_td, NA, NA, tm, wifi0, wifi1, NA, NA, |
| 243 | NA, NA, NA, NA), |
| 244 | PINGROUP(57, qpic, blsp_spi0, i2s_tx, NA, NA, tm, wifi0, wifi1, NA, NA, |
| 245 | NA, NA, NA, NA), |
| 246 | PINGROUP(58, qpic, led2, blsp_i2c0, smart3, smart1, i2s_rx, NA, NA, tm, |
| 247 | wifi0, wifi1, NA, NA, NA), |
| 248 | PINGROUP(59, qpic, blsp_i2c0, smart3, smart1, i2s_spdif_in, NA, NA, NA, |
| 249 | NA, NA, tm, NA, NA, NA), |
| 250 | PINGROUP(60, qpic, blsp_uart0, smart1, smart3, led0, i2s_tx, i2s_rx, |
| 251 | NA, NA, NA, NA, NA, tm, NA), |
| 252 | PINGROUP(61, qpic, blsp_uart0, smart1, smart3, led1, i2s_tx, i2s_rx, |
| 253 | NA, NA, NA, NA, NA, tm, NA), |
| 254 | PINGROUP(62, qpic, chip_rst, NA, NA, i2s_spdif_out, NA, NA, NA, NA, NA, |
| 255 | tm, NA, NA, NA), |
| 256 | PINGROUP(63, qpic, NA, NA, NA, i2s_td, i2s_rx, i2s_spdif_out, |
| 257 | i2s_spdif_in, NA, NA, NA, NA, tm, NA), |
| 258 | PINGROUP(64, qpic, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 259 | NA, NA), |
| 260 | PINGROUP(65, qpic, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 261 | NA, NA), |
| 262 | PINGROUP(66, qpic, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 263 | NA, NA), |
| 264 | PINGROUP(67, qpic, audio_pwm, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 265 | NA, NA), |
| 266 | PINGROUP(68, qpic, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 267 | PINGROUP(69, qpic, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 268 | PINGROUP(70, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 269 | PINGROUP(71, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 270 | PINGROUP(72, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 271 | PINGROUP(73, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 272 | PINGROUP(74, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 273 | PINGROUP(75, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 274 | PINGROUP(76, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 275 | PINGROUP(77, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 276 | PINGROUP(78, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 277 | PINGROUP(79, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 278 | PINGROUP(80, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 279 | PINGROUP(81, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 280 | PINGROUP(82, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 281 | PINGROUP(83, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 282 | PINGROUP(84, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 283 | PINGROUP(85, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 284 | PINGROUP(86, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 285 | PINGROUP(87, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 286 | PINGROUP(88, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 287 | PINGROUP(89, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 288 | PINGROUP(90, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 289 | PINGROUP(91, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 290 | PINGROUP(92, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 291 | PINGROUP(93, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 292 | PINGROUP(94, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 293 | PINGROUP(95, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 294 | PINGROUP(96, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 295 | PINGROUP(97, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 296 | PINGROUP(98, wifi0, wifi1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, |
| 297 | NA), |
| 298 | PINGROUP(99, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), |
| 299 | }; |
| 300 | |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 301 | static const char *ipq4019_get_function_name(struct udevice *dev, |
| 302 | unsigned int selector) |
| 303 | { |
| 304 | return msm_pinctrl_functions[selector].name; |
| 305 | } |
| 306 | |
| 307 | static const char *ipq4019_get_pin_name(struct udevice *dev, |
| 308 | unsigned int selector) |
| 309 | { |
Robert Marko | f306113 | 2024-04-22 13:43:26 +0200 | [diff] [blame] | 310 | snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 311 | return pin_name; |
| 312 | } |
| 313 | |
Robert Marko | 0a41b46 | 2024-04-22 13:43:28 +0200 | [diff] [blame] | 314 | static unsigned int ipq4019_get_function_mux(unsigned int pin, |
Volodymyr Babchuk | c4cc979 | 2024-03-11 21:33:46 +0000 | [diff] [blame] | 315 | unsigned int selector) |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 316 | { |
Robert Marko | 0a41b46 | 2024-04-22 13:43:28 +0200 | [diff] [blame] | 317 | unsigned int i; |
| 318 | const msm_pin_function *func = ipq4019_pin_functions + pin; |
| 319 | |
| 320 | for (i = 0; i < 15; i++) |
| 321 | if ((*func)[i] == selector) |
| 322 | return i; |
| 323 | |
| 324 | pr_err("Can't find requested function for pin %u pin\n", pin); |
| 325 | return -EINVAL; |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 326 | } |
| 327 | |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 328 | static const struct msm_pinctrl_data ipq4019_data = { |
Caleb Connolly | 190005c | 2024-02-26 17:26:17 +0000 | [diff] [blame] | 329 | .pin_data = { |
| 330 | .pin_count = 100, |
| 331 | .special_pins_start = 100, /* There are no special pins */ |
| 332 | }, |
Robert Marko | e7a34f1 | 2020-07-06 10:37:54 +0200 | [diff] [blame] | 333 | .functions_count = ARRAY_SIZE(msm_pinctrl_functions), |
| 334 | .get_function_name = ipq4019_get_function_name, |
| 335 | .get_function_mux = ipq4019_get_function_mux, |
| 336 | .get_pin_name = ipq4019_get_pin_name, |
| 337 | }; |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 338 | |
| 339 | static const struct udevice_id msm_pinctrl_ids[] = { |
| 340 | { .compatible = "qcom,ipq4019-pinctrl", .data = (ulong)&ipq4019_data }, |
| 341 | { /* Sentinal */ } |
| 342 | }; |
| 343 | |
| 344 | U_BOOT_DRIVER(pinctrl_ipq4019) = { |
| 345 | .name = "pinctrl_ipq4019", |
| 346 | .id = UCLASS_NOP, |
| 347 | .of_match = msm_pinctrl_ids, |
| 348 | .ops = &msm_pinctrl_ops, |
| 349 | .bind = msm_pinctrl_bind, |
Robert Marko | fcda95d | 2024-04-22 13:43:27 +0200 | [diff] [blame] | 350 | .flags = DM_FLAG_PRE_RELOC, |
Caleb Connolly | cdc0d08 | 2023-11-14 12:55:41 +0000 | [diff] [blame] | 351 | }; |