2 * This file contains code used for lowlevel initialization
3 * of GPIO, on supported Qualcomm/Atheros platforms
5 * Copyright (C) 2016 Piotr Dymacz <piotr@dymacz.pl>
7 * SPDX-License-Identifier: GPL-2.0
12 #include <asm/regdef.h>
13 #include <asm/mipsregs.h>
14 #include <asm/addrspace.h>
15 #include <soc/qca_soc_common.h>
18 * Low level GPIO initialization:
19 * 1. Setup JTAG (disable by default, but allow to keep it up)
20 * 2. Disable all clock observation on platforms which support this
22 * 4. Setup all configured GPIO inputs/outputs
23 * 5. Set desired init values on configured GPIOs
25 * The user may use several config definitions here:
26 * 1. CONFIG_QCA_KEEP_JTAG_ENABLED
27 * - if defined, JTAG will not be disabled
28 * 2. CONFIG_QCA_GPIO_MASK_OUTPUTS,
29 * CONFIG_QCA_GPIO_MASK_INPUTS
30 * - bitmask for GPIOs to be set as outputs and inputs
31 * 3. CONFIG_QCA_GPIO_LSUART_TX,
32 * CONFIG_QCA_GPIO_LSUART_RX
33 * - GPIO number for LSUART TX (10 if empty) and RX line (9 if empty)
34 * 4. CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI,
35 * CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO
36 * - bitmask for outputs initialized to high and low state at start
37 * 5. CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI,
38 * CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
39 * - bitmask for GPIO driven LEDs, used only in leds_on/leds_off functions,
40 * GPIO numbers for LEDs MUST be defined also in CONFIG_QCA_GPIO_MASK_OUTPUTS!
43 * 1. Allow to select LS, HS, both or none UART type
44 * on platforms which support both
45 * 2. Allow to select clocks observation on chosen pins
46 * 3. Ethernet/WLAN LEDs configuration
47 * 4. Enable JTAG on request (button?)
50 /* Sanity check for GPIO driven LEDs */
51 #if (defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) || \
52 defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)) && \
53 !defined(CONFIG_QCA_GPIO_MASK_OUTPUTS)
54 #error "GPIO numbers for LEDs must be included in CONFIG_QCA_GPIO_MASK_OUTPUTS!"
57 #if (defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) && \
58 !(CONFIG_QCA_GPIO_MASK_OUTPUTS & CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI)) || \
59 (defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO) && \
60 !(CONFIG_QCA_GPIO_MASK_OUTPUTS & CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO))
61 #error "GPIO numbers for LEDs must be included in CONFIG_QCA_GPIO_MASK_OUTPUTS!"
64 .globl lowlevel_gpio_init
65 .type lowlevel_gpio_init, @function
68 .ent lowlevel_gpio_init
72 * =========================
73 * Low level GPIO setup for:
77 * =========================
79 #if (SOC_TYPE & QCA_AR934X_SOC) || \
80 (SOC_TYPE & QCA_QCA953X_SOC) || \
81 (SOC_TYPE & QCA_QCA955X_SOC)
83 /* Sanity check for JTAG pins (GPIO 0~3) */
84 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
85 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
86 #if (defined(CONFIG_QCA_GPIO_MASK_INPUTS) && (CONFIG_QCA_GPIO_MASK_INPUTS & 0xF)) || \
87 (defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) && (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0xF))
88 #error "Cannot use JTAG and GPIO0~3 at the same time!"
94 * 1. By default JTAG (bit 1 set)
95 * 2. All clock observation (bits 2~9 reset)
97 li t8, QCA_GPIO_FUNC_REG
98 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
99 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
100 li t9, QCA_GPIO_FUNC_JTAG_DIS_MASK
106 /* By default use GPIO10 for TX and GPIO9 for RX */
107 #ifndef CONFIG_QCA_GPIO_LSUART_TX
108 #define CONFIG_QCA_GPIO_LSUART_TX 10
111 #ifndef CONFIG_QCA_GPIO_LSUART_RX
112 #define CONFIG_QCA_GPIO_LSUART_RX 9
115 #define CONFIG_QCA_GPIO_MASK_LSUART_TX (1 << CONFIG_QCA_GPIO_LSUART_TX)
116 #define CONFIG_QCA_GPIO_MASK_LSUART_RX (1 << CONFIG_QCA_GPIO_LSUART_RX)
118 #define CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT \
119 (8 * (CONFIG_QCA_GPIO_LSUART_TX - \
120 ((CONFIG_QCA_GPIO_LSUART_TX / 4) * 4)))
122 /* Some sanity checks for LS UART GPIO lines */
123 #if (CONFIG_QCA_GPIO_LSUART_TX >= QCA_GPIO_COUNT) || \
124 (CONFIG_QCA_GPIO_LSUART_RX >= QCA_GPIO_COUNT)
125 #error "LSUART GPIO numbers for TX and/or RX lines are not correct!"
128 #if (CONFIG_QCA_GPIO_LSUART_TX == CONFIG_QCA_GPIO_LSUART_RX)
129 #error "LSUART TX and RX GPIO numbers cannot be the same!"
133 * Do not allow to use LSUART TX/RX lines
134 * as regular GPIO inputs/outputs at the same time
136 #if defined(CONFIG_QCA_GPIO_MASK_INPUTS) || defined(CONFIG_QCA_GPIO_MASK_OUTPUTS)
137 #if (CONFIG_QCA_GPIO_MASK_INPUTS & CONFIG_QCA_GPIO_MASK_LSUART_TX) || \
138 (CONFIG_QCA_GPIO_MASK_INPUTS & CONFIG_QCA_GPIO_MASK_LSUART_RX) || \
139 (CONFIG_QCA_GPIO_MASK_OUTPUTS & CONFIG_QCA_GPIO_MASK_LSUART_TX) || \
140 (CONFIG_QCA_GPIO_MASK_OUTPUTS & CONFIG_QCA_GPIO_MASK_LSUART_RX)
141 #error "Cannot use LSUART lines as regular GPIOs at the same time!"
145 /* Setup GPIO number for LSUART RX in GPIO IN MUX */
146 li t8, QCA_GPIO_IN_EN0_REG
148 and t9, t9, ~(QCA_GPIO_IN_EN0_LSUART_RXD_MASK)
149 or t9, t9, (CONFIG_QCA_GPIO_LSUART_RX << QCA_GPIO_IN_EN0_LSUART_RXD_SHIFT)
153 * Target regular GPIO and LSUART TX line configuration
155 * After selecting GPIO as output in GPIO_OE register,
156 * the line will be set to low, which causes signal
157 * toggle on pulled-up lines
159 * To prevent this, we need to first setup desired
160 * init state for all GPIOs configured as outputs
161 * and then setup them as outputs
163 li t8, QCA_GPIO_OUT_REG
165 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
166 or t9, t9, (CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI | \
167 CONFIG_QCA_GPIO_MASK_LSUART_TX)
169 or t9, t9, CONFIG_QCA_GPIO_MASK_LSUART_TX
171 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO
172 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO)
177 * TODO: what with default LSUART TX line?
179 * Some of QCA WiSoCs have GPIOs for LSUART TX/RX lines
180 * set by default (10 and 9 respectively) on reset and
181 * others do not (ex. QCA953x?).
183 * Because of that we can use more than one line
184 * for TX signal if we setup other than default
185 * GPIO for it, without change default GPIO
188 * Confirmed on AR9344 with LSUART TX set on
189 * GPIO1 and GPIO10 at the same time
193 * Set GPIO mode on desired lines and GPIO number
194 * for LSUART TX using GPIO_OUT_FUNCTIONX registers:
195 * - 0 ~ 3 -> GPIO_OUT_FUNCTION0 (mask: 0x00000F)
196 * - 4 ~ 7 -> GPIO_OUT_FUNCTION1 (mask: 0x0000F0)
197 * - 8 ~ 11 -> GPIO_OUT_FUNCTION2 (mask: 0x000F00)
198 * - 12 ~ 15 -> GPIO_OUT_FUNCTION3 (mask: 0x00F000)
199 * - 16 ~ 19 -> GPIO_OUT_FUNCTION4 (mask: 0x0F0000)
200 * - 20 ~ 23 -> GPIO_OUT_FUNCTION5 (mask: 0xF00000)
202 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
203 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
205 /* GPIO_OUT_FUNCTION0 (GPIO 0~3) */
206 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x00000F) || \
207 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x00000F) || \
208 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00000F)
209 li t8, QCA_GPIO_OUT_FUNC0_REG
211 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO0) || \
212 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO0)
213 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO0_EN_MASK)
215 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO1) || \
216 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO1)
217 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO1_EN_MASK)
219 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO2) || \
220 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO2)
221 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO2_EN_MASK)
223 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO3) || \
224 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO3)
225 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO3_EN_MASK)
227 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00000F)
228 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
229 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
230 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
235 /* GPIO_OUT_FUNCTION1 (GPIO 4~7) */
236 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x0000F0) || \
237 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x0000F0) || \
238 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0000F0)
239 li t8, QCA_GPIO_OUT_FUNC1_REG
241 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO4) || \
242 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO4)
243 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO4_EN_MASK)
245 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO5) || \
246 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO5)
247 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO5_EN_MASK)
249 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO6) || \
250 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO6)
251 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO6_EN_MASK)
253 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO7) || \
254 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO7)
255 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO7_EN_MASK)
257 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0000F0)
258 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
259 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
260 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
265 /* GPIO_OUT_FUNCTION2 (GPIO 8~11) */
266 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x000F00) || \
267 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x000F00) || \
268 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x000F00)
269 li t8, QCA_GPIO_OUT_FUNC2_REG
271 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO8) || \
272 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO8)
273 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO8_EN_MASK)
275 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO9) || \
276 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO9)
277 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO9_EN_MASK)
279 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO10) || \
280 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO10)
281 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO10_EN_MASK)
283 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO11) || \
284 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO11)
285 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO11_EN_MASK)
287 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x000F00)
288 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
289 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
290 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
295 /* GPIO_OUT_FUNCTION3 (GPIO 12~15) */
296 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x00F000) || \
297 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x00F000) || \
298 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00F000)
299 li t8, QCA_GPIO_OUT_FUNC3_REG
301 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO12) || \
302 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO12)
303 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO12_EN_MASK)
305 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO13) || \
306 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO13)
307 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO13_EN_MASK)
309 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO14) || \
310 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO14)
311 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO14_EN_MASK)
313 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO15) || \
314 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO15)
315 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO15_EN_MASK)
317 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00F000)
318 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
319 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
320 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
325 /* GPIO_OUT_FUNCTION4 (GPIO 16~19) */
326 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x0F0000) || \
327 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x0F0000) || \
328 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0F0000)
329 li t8, QCA_GPIO_OUT_FUNC4_REG
331 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO16) || \
332 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO16)
333 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO16_EN_MASK)
335 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO17) || \
336 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO17)
337 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO17_EN_MASK)
339 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO18) || \
340 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO18)
341 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO18_EN_MASK)
343 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO19) || \
344 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO19)
345 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO19_EN_MASK)
347 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0F0000)
348 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
349 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
350 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
355 /* GPIO_OUT_FUNCTION5 (GPIO 20~23) */
356 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0xF00000) || \
357 (CONFIG_QCA_GPIO_MASK_INPUTS & 0xF00000) || \
358 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0xF00000)
359 li t8, QCA_GPIO_OUT_FUNC5_REG
361 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO20) || \
362 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO20)
363 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO20_EN_MASK)
365 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO21) || \
366 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO21)
367 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO21_EN_MASK)
369 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO22) || \
370 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO22)
371 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO22_EN_MASK)
373 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO23) || \
374 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO23)
375 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO23_EN_MASK)
377 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0xF00000)
378 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
379 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
380 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
386 * And finally, setup GPIO type (out/in)
387 * in GPIO_OE register for all configured
388 * regular GPIOs and LSUART TX/RX lines
390 li t8, QCA_GPIO_OE_REG
392 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS
393 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS | \
394 CONFIG_QCA_GPIO_MASK_LSUART_TX)
396 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LSUART_TX)
398 #ifdef CONFIG_QCA_GPIO_MASK_INPUTS
399 or t9, t9, (CONFIG_QCA_GPIO_MASK_INPUTS | CONFIG_QCA_GPIO_MASK_LSUART_RX)
401 or t9, t9, CONFIG_QCA_GPIO_MASK_LSUART_RX
405 #endif /* CONFIG_QCA_GPIO_MASK_OUTPUTS || CONFIG_QCA_GPIO_MASK_INPUTS */
407 #endif /* (SOC_TYPE & QCA_AR934X_SOC) || (SOC_TYPE & QCA_QCA953X_SOC) || (SOC_TYPE & QCA_QCA955X_SOC) */
410 * ===============================
411 * Low level GPIO setup for AR933x
412 * ===============================
414 #if (SOC_TYPE & QCA_AR933X_SOC)
416 /* Sanity check for JTAG pins (GPIO 6~8) */
417 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
418 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
419 #if (defined(CONFIG_QCA_GPIO_MASK_INPUTS) && (CONFIG_QCA_GPIO_MASK_INPUTS & 0x1C0)) || \
420 (defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) && (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x1C0))
421 #error "Cannot use JTAG and GPIO6~8 at the same time!"
426 * On AR933x HSUART TX/RX lines are connected to
427 * GPIO10 and GPIO9 respectively, so do not allow
428 * to use those GPIOs as regular at the same time
430 #if defined(CONFIG_QCA_GPIO_MASK_INPUTS) || defined(CONFIG_QCA_GPIO_MASK_OUTPUTS)
431 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO9 | GPIO10)) || \
432 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO9 | GPIO10))
433 #error "Cannot use HSUART lines as regular GPIOs at the same time!"
438 * GPIO configuration, using GPIO_FUNCTION_1 register:
439 * 1. Disable JTAG by default
440 * 2. Enable HSUART on GPIO9 and GPIO10 by default
441 * 3. Disable HSUART RTS/CTS on GPIO11/12 if needed
442 * 4. Disable selected Ethernet switch LEDs if needed
444 li t8, QCA_GPIO_FUNC_1_REG
446 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
447 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
448 and t9, t9, ~(QCA_GPIO_FUNC_1_JTAG_DIS_MASK)
449 or t9, t9, QCA_GPIO_FUNC_1_UART_EN_MASK
451 or t9, t9, (QCA_GPIO_FUNC_1_JTAG_DIS_MASK | \
452 QCA_GPIO_FUNC_1_UART_EN_MASK)
454 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO11 | GPIO12)) || \
455 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO11 | GPIO12))
456 and t9, t9, ~(QCA_GPIO_FUNC_1_UART_RTS_CTS_EN_MASK)
458 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO13) || \
459 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO13)
460 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED0_EN_MASK)
462 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO14) || \
463 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO14)
464 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED1_EN_MASK)
466 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO15) || \
467 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO15)
468 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED2_EN_MASK)
470 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO16) || \
471 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO16)
472 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED3_EN_MASK)
474 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO17) || \
475 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO17)
476 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED4_EN_MASK)
478 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO9)
479 and t9, t9, ~(QCA_GPIO_FUNC_1_SPI_CS_EN1_MASK)
481 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO10)
482 and t9, t9, ~(QCA_GPIO_FUNC_1_SPI_CS_EN2_MASK)
484 /* From datasheet: bit 15 should be written with 1 */
485 or t9, t9, ((1 << 15) | \
486 QCA_GPIO_FUNC_1_SPI_EN_MASK)
489 /* Enable regular GPIO function on GPIO26 and/or GPIO27 if needed */
490 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
491 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
492 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO26 | GPIO27)) || \
493 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO26 | GPIO27))
494 li t8, QCA_RST_BOOTSTRAP_REG
496 or t9, t9, QCA_RST_BOOTSTRAP_MDIO_GPIO_EN_MASK
501 /* Enable regular GPIO function on GPIO11 and/or GPIO12 if needed */
502 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
503 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
504 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO11 | GPIO12)) || \
505 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO11 | GPIO12))
506 li t8, QCA_GPIO_FUNC_2_REG
508 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO11) || \
509 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO11)
510 or t9, t9, QCA_GPIO_FUNC_2_JUMPSTART_DIS_MASK
512 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO12) || \
513 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO12)
514 or t9, t9, QCA_GPIO_FUNC_2_WPS_DIS_MASK
520 /* Setup init states on requested GPIO lines */
521 li t8, QCA_GPIO_OUT_REG
523 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
524 or t9, t9, CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
526 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO
527 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO)
531 /* Setup GPIOs in OE register */
532 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
533 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
534 li t8, QCA_GPIO_OE_REG
536 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS
537 or t9, t9, CONFIG_QCA_GPIO_MASK_OUTPUTS
539 #ifdef CONFIG_QCA_GPIO_MASK_INPUTS
540 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_INPUTS)
545 #endif /* (SOC_TYPE & QCA_AR933X_SOC) */
548 * Custom, GPIO related code for boards should go here,
549 * after initial/basic GPIO configuration
555 .end lowlevel_gpio_init
558 * Set all predefined GPIO driven LEDs ON
562 .type all_led_on, @function
568 #if defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) || \
569 defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
570 li t8, QCA_GPIO_OUT_REG
572 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
573 or t9, t9, CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
575 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
576 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
589 * Set all predefined GPIO driven LEDs OFF
593 .type all_led_off, @function
599 #if defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) || \
600 defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
601 li t8, QCA_GPIO_OUT_REG
603 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
604 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI)
606 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
607 or t9, t9, CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO