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)
102 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!"
146 * Target regular GPIO and LSUART TX line configuration
148 * After selecting GPIO as output in GPIO_OE register,
149 * the line will be set to low, which causes signal
150 * toggle on pulled-up lines
152 * To prevent this, we need to first setup desired
153 * init state for all GPIOs configured as outputs
154 * and then setup them as outputs
156 li t8, QCA_GPIO_OUT_REG
158 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
159 or t9, t9, (CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI | \
160 CONFIG_QCA_GPIO_MASK_LSUART_TX)
162 or t9, t9, CONFIG_QCA_GPIO_MASK_LSUART_TX
164 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO
165 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO)
170 * Setup GPIO type (out/in) in GPIO_OE
171 * register for all configured regular
172 * GPIOs and LSUART TX/RX lines
174 li t8, QCA_GPIO_OE_REG
176 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS
177 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS | \
178 CONFIG_QCA_GPIO_MASK_LSUART_TX)
180 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LSUART_TX)
182 #ifdef CONFIG_QCA_GPIO_MASK_INPUTS
183 or t9, t9, (CONFIG_QCA_GPIO_MASK_INPUTS | CONFIG_QCA_GPIO_MASK_LSUART_RX)
185 or t9, t9, CONFIG_QCA_GPIO_MASK_LSUART_RX
189 /* Setup GPIO number for LSUART RX in GPIO IN MUX */
190 li t8, QCA_GPIO_IN_EN0_REG
192 and t9, t9, ~(QCA_GPIO_IN_EN0_LSUART_RXD_MASK)
193 or t9, t9, (CONFIG_QCA_GPIO_LSUART_RX << QCA_GPIO_IN_EN0_LSUART_RXD_SHIFT)
197 * TODO: what with default LSUART TX line?
199 * Some of QCA WiSoCs have GPIOs for LSUART TX/RX lines
200 * set by default (10 and 9 respectively) on reset and
201 * others do not (ex. QCA953x?).
203 * Because of that we can use more than one line
204 * for TX signal if we setup other than default
205 * GPIO for it, without change default GPIO
208 * Confirmed on AR9344 with LSUART TX set on
209 * GPIO1 and GPIO10 at the same time
213 * Set GPIO mode on desired lines and GPIO number
214 * for LSUART TX using GPIO_OUT_FUNCTIONX registers:
215 * - 0 ~ 3 -> GPIO_OUT_FUNCTION0 (mask: 0x00000F)
216 * - 4 ~ 7 -> GPIO_OUT_FUNCTION1 (mask: 0x0000F0)
217 * - 8 ~ 11 -> GPIO_OUT_FUNCTION2 (mask: 0x000F00)
218 * - 12 ~ 15 -> GPIO_OUT_FUNCTION3 (mask: 0x00F000)
219 * - 16 ~ 19 -> GPIO_OUT_FUNCTION4 (mask: 0x0F0000)
220 * - 20 ~ 23 -> GPIO_OUT_FUNCTION5 (mask: 0xF00000)
222 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
223 defined(CONFIG_QCA_GPIO_MASK_INPUTS) || \
224 defined(CONFIG_QCA_GPIO_MASK_LSUART_TX)
226 /* GPIO_OUT_FUNCTION0 (GPIO 0~3) */
227 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x00000F) || \
228 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x00000F) || \
229 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00000F)
230 li t8, QCA_GPIO_OUT_FUNC0_REG
232 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO0) || \
233 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO0)
234 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO0_EN_MASK)
236 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO1) || \
237 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO1)
238 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO1_EN_MASK)
240 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO2) || \
241 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO2)
242 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO2_EN_MASK)
244 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO3) || \
245 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO3)
246 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO3_EN_MASK)
248 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00000F)
249 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
250 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
251 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
256 /* GPIO_OUT_FUNCTION1 (GPIO 4~7) */
257 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x0000F0) || \
258 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x0000F0) || \
259 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0000F0)
260 li t8, QCA_GPIO_OUT_FUNC1_REG
262 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO4) || \
263 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO4)
264 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO4_EN_MASK)
266 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO5) || \
267 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO5)
268 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO5_EN_MASK)
270 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO6) || \
271 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO6)
272 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO6_EN_MASK)
274 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO7) || \
275 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO7)
276 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO7_EN_MASK)
278 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0000F0)
279 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
280 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
281 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
286 /* GPIO_OUT_FUNCTION2 (GPIO 8~11) */
287 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x000F00) || \
288 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x000F00) || \
289 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x000F00)
290 li t8, QCA_GPIO_OUT_FUNC2_REG
292 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO8) || \
293 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO8)
294 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO8_EN_MASK)
296 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO9) || \
297 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO9)
298 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO9_EN_MASK)
300 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO10) || \
301 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO10)
302 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO10_EN_MASK)
304 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO11) || \
305 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO11)
306 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO11_EN_MASK)
308 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x000F00)
309 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
310 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
311 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
316 /* GPIO_OUT_FUNCTION3 (GPIO 12~15) */
317 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x00F000) || \
318 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x00F000) || \
319 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00F000)
320 li t8, QCA_GPIO_OUT_FUNC3_REG
322 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO12) || \
323 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO12)
324 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO12_EN_MASK)
326 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO13) || \
327 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO13)
328 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO13_EN_MASK)
330 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO14) || \
331 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO14)
332 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO14_EN_MASK)
334 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO15) || \
335 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO15)
336 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO15_EN_MASK)
338 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x00F000)
339 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
340 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
341 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
346 /* GPIO_OUT_FUNCTION4 (GPIO 16~19) */
347 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x0F0000) || \
348 (CONFIG_QCA_GPIO_MASK_INPUTS & 0x0F0000) || \
349 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0F0000)
350 li t8, QCA_GPIO_OUT_FUNC4_REG
352 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO16) || \
353 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO16)
354 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO16_EN_MASK)
356 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO17) || \
357 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO17)
358 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO17_EN_MASK)
360 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO18) || \
361 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO18)
362 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO18_EN_MASK)
364 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO19) || \
365 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO19)
366 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO19_EN_MASK)
368 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0x0F0000)
369 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
370 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
371 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
376 /* GPIO_OUT_FUNCTION5 (GPIO 20~23) */
377 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0xF00000) || \
378 (CONFIG_QCA_GPIO_MASK_INPUTS & 0xF00000) || \
379 (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0xF00000)
380 li t8, QCA_GPIO_OUT_FUNC5_REG
382 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO20) || \
383 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO20)
384 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO20_EN_MASK)
386 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO21) || \
387 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO21)
388 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO21_EN_MASK)
390 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO22) || \
391 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO22)
392 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO22_EN_MASK)
394 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO23) || \
395 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO23)
396 and t9, t9, ~(QCA_GPIO_OUT_FUNCX_GPIO23_EN_MASK)
398 #if (CONFIG_QCA_GPIO_MASK_LSUART_TX & 0xF00000)
399 and t9, t9, ~(0xFF << CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
400 or t9, t9, (QCA_GPIO_OUT_MUX_LSUART_TXD_VAL << \
401 CONFIG_QCA_GPIO_LSUART_TX_FUNCX_SHIFT)
406 #endif /* CONFIG_QCA_GPIO_MASK_OUTPUTS || CONFIG_QCA_GPIO_MASK_INPUTS || CONFIG_QCA_GPIO_MASK_LSUART_TX */
408 #endif /* (SOC_TYPE & QCA_AR934X_SOC) || (SOC_TYPE & QCA_QCA953X_SOC) || (SOC_TYPE & QCA_QCA955X_SOC) */
411 * ===============================
412 * Low level GPIO setup for AR933x
413 * ===============================
415 #if (SOC_TYPE & QCA_AR933X_SOC)
417 /* Sanity check for JTAG pins (GPIO 6~8) */
418 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
419 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
420 #if (defined(CONFIG_QCA_GPIO_MASK_INPUTS) && (CONFIG_QCA_GPIO_MASK_INPUTS & 0x1C0)) || \
421 (defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) && (CONFIG_QCA_GPIO_MASK_OUTPUTS & 0x1C0))
422 #error "Cannot use JTAG and GPIO6~8 at the same time!"
427 * On AR933x HSUART TX/RX lines are connected to
428 * GPIO10 and GPIO9 respectively, so do not allow
429 * to use those GPIOs as regular at the same time
431 #if defined(CONFIG_QCA_GPIO_MASK_INPUTS) || defined(CONFIG_QCA_GPIO_MASK_OUTPUTS)
432 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO9 | GPIO10)) || \
433 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO9 | GPIO10))
434 #error "Cannot use HSUART lines as regular GPIOs at the same time!"
439 * Workaround for hang issue,
440 * from original Atheros (Q)SDK:
442 * "Hornet 1.1 currently need a reset
443 * once we boot to let the resetb has
444 * enough time to stable, so that
445 * trigger reset at 1st boot".
447 * Read one 4 byte value from SRAM base address and compare it with
448 * known magic number (0x12345678 here), if it's the same, it means
449 * that this is not first boot and we can continue. Otherwise, make
450 * full chip reset (it's not power reset, SRAM data will survive).
452 * We need it here as it's first custom asm code executed in start{_bootstrap).S
461 bne t9, t7, full_reset
468 li t8, QCA_RST_RESET_REG
470 or t9, t9, (QCA_RST_RESET_FULL_CHIP_RST_MASK | \
471 QCA_RST_RESET_DDR_RST_MASK)
479 * GPIO configuration, using GPIO_FUNCTION_1 register:
480 * 1. Disable JTAG by default
481 * 2. Enable HSUART on GPIO9 and GPIO10 by default
482 * 3. Disable HSUART RTS/CTS on GPIO11/12 if needed
483 * 4. Disable selected Ethernet switch LEDs if needed
486 li t8, QCA_GPIO_FUNC_1_REG
488 #if defined(CONFIG_SKIP_LOWLEVEL_INIT) || \
489 defined(CONFIG_QCA_KEEP_JTAG_ENABLED)
490 and t9, t9, ~(QCA_GPIO_FUNC_1_JTAG_DIS_MASK)
491 or t9, t9, QCA_GPIO_FUNC_1_UART_EN_MASK
493 or t9, t9, (QCA_GPIO_FUNC_1_JTAG_DIS_MASK | \
494 QCA_GPIO_FUNC_1_UART_EN_MASK)
496 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO11 | GPIO12)) || \
497 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO11 | GPIO12))
498 and t9, t9, ~(QCA_GPIO_FUNC_1_UART_RTS_CTS_EN_MASK)
500 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO13) || \
501 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO13)
502 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED0_EN_MASK)
504 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO14) || \
505 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO14)
506 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED1_EN_MASK)
508 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO15) || \
509 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO15)
510 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED2_EN_MASK)
512 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO16) || \
513 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO16)
514 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED3_EN_MASK)
516 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO17) || \
517 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO17)
518 and t9, t9, ~(QCA_GPIO_FUNC_1_ETH_SW_LED4_EN_MASK)
520 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO9)
521 and t9, t9, ~(QCA_GPIO_FUNC_1_SPI_CS_EN1_MASK)
523 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO10)
524 and t9, t9, ~(QCA_GPIO_FUNC_1_SPI_CS_EN2_MASK)
526 /* From datasheet: bit 15 should be written with 1 */
527 or t9, t9, ((1 << 15) | \
528 QCA_GPIO_FUNC_1_SPI_EN_MASK)
531 /* Enable regular GPIO function on GPIO26 and/or GPIO27 if needed */
532 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
533 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
534 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO26 | GPIO27)) || \
535 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO26 | GPIO27))
536 li t8, QCA_RST_BOOTSTRAP_REG
538 or t9, t9, QCA_RST_BOOTSTRAP_MDIO_GPIO_EN_MASK
543 /* Enable regular GPIO function on GPIO11 and/or GPIO12 if needed */
544 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
545 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
546 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & (GPIO11 | GPIO12)) || \
547 (CONFIG_QCA_GPIO_MASK_INPUTS & (GPIO11 | GPIO12))
548 li t8, QCA_GPIO_FUNC_2_REG
550 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO11) || \
551 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO11)
552 or t9, t9, QCA_GPIO_FUNC_2_JUMPSTART_DIS_MASK
554 #if (CONFIG_QCA_GPIO_MASK_OUTPUTS & GPIO12) || \
555 (CONFIG_QCA_GPIO_MASK_INPUTS & GPIO12)
556 or t9, t9, QCA_GPIO_FUNC_2_WPS_DIS_MASK
562 /* Setup init states on requested GPIO lines */
563 li t8, QCA_GPIO_OUT_REG
565 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
566 or t9, t9, CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_HI
568 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO
569 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_OUTPUTS_INIT_LO)
573 /* Setup GPIOs in OE register */
574 #if defined(CONFIG_QCA_GPIO_MASK_OUTPUTS) || \
575 defined(CONFIG_QCA_GPIO_MASK_INPUTS)
576 li t8, QCA_GPIO_OE_REG
578 #ifdef CONFIG_QCA_GPIO_MASK_OUTPUTS
579 or t9, t9, CONFIG_QCA_GPIO_MASK_OUTPUTS
581 #ifdef CONFIG_QCA_GPIO_MASK_INPUTS
582 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_INPUTS)
587 #endif /* (SOC_TYPE & QCA_AR933X_SOC) */
590 * Custom, GPIO related code for boards should go here,
591 * after initial/basic GPIO configuration
597 .end lowlevel_gpio_init
600 * Set all predefined GPIO driven LEDs ON
604 .type all_led_on, @function
610 #if defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) || \
611 defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
612 li t8, QCA_GPIO_OUT_REG
614 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
615 or t9, t9, CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
617 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
618 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
631 * Set all predefined GPIO driven LEDs OFF
635 .type all_led_off, @function
641 #if defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI) || \
642 defined(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO)
643 li t8, QCA_GPIO_OUT_REG
645 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI
646 and t9, t9, ~(CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_HI)
648 #ifdef CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO
649 or t9, t9, CONFIG_QCA_GPIO_MASK_LEDS_ACTIVE_LO