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