2 * Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/addrspace.h>
10 #include <asm/types.h>
11 #include <mach/ar71xx_regs.h>
13 #include <debug_uart.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
18 void board_debug_uart_init(void)
23 regs = map_physmem(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE,
27 * GPIO9 as input, GPIO10 as output
29 val = readl(regs + AR71XX_GPIO_REG_OE);
30 val |= QCA953X_GPIO(9);
31 val &= ~QCA953X_GPIO(10);
32 writel(val, regs + AR71XX_GPIO_REG_OE);
35 * Enable GPIO10 as UART0_SOUT
37 val = readl(regs + QCA953X_GPIO_REG_OUT_FUNC2);
38 val &= ~QCA953X_GPIO_MUX_MASK(16);
39 val |= QCA953X_GPIO_OUT_MUX_UART0_SOUT << 16;
40 writel(val, regs + QCA953X_GPIO_REG_OUT_FUNC2);
43 * Enable GPIO9 as UART0_SIN
45 val = readl(regs + QCA953X_GPIO_REG_IN_ENABLE0);
46 val &= ~QCA953X_GPIO_MUX_MASK(8);
47 val |= QCA953X_GPIO_IN_MUX_UART0_SIN << 8;
48 writel(val, regs + QCA953X_GPIO_REG_IN_ENABLE0);
51 * Enable GPIO10 output
53 val = readl(regs + AR71XX_GPIO_REG_OUT);
54 val |= QCA953X_GPIO(10);
55 writel(val, regs + AR71XX_GPIO_REG_OUT);
59 int board_early_init_f(void)
61 #ifdef CONFIG_DEBUG_UART