--- zzzz-none-000/linux-3.10.107/arch/mips/ath79/early_printk.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/ath79/early_printk.c 2021-11-10 11:53:53.000000000 +0000 @@ -12,11 +12,13 @@ #include #include #include +#include #include #include #include #include +#include static void (*_prom_putchar) (unsigned char); @@ -31,17 +33,20 @@ } while (1); } +#if (defined CONFIG_SOC_AR71XX || defined CONFIG_SOC_AR724X || defined CONFIG_SOC_AR913X || defined CONFIG_SOC_AR934X || defined CONFIG_SOC_QCA955X) #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) static void prom_putchar_ar71xx(unsigned char ch) { - void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE)); + void __iomem *base = (void __iomem *)(KSEG1ADDR(ATH_UART_BASE)); prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); __raw_writel(ch, base + UART_TX * 4); prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); } +#endif +#if defined CONFIG_SOC_AR933X static void prom_putchar_ar933x(unsigned char ch) { void __iomem *base = (void __iomem *)(KSEG1ADDR(AR933X_UART_BASE)); @@ -52,6 +57,7 @@ prom_putchar_wait(base + AR933X_UART_DATA_REG, AR933X_UART_DATA_TX_CSR, AR933X_UART_DATA_TX_CSR); } +#endif static void prom_putchar_dummy(unsigned char ch) { @@ -63,11 +69,12 @@ void __iomem *base; u32 id; - base = (void __iomem *)(KSEG1ADDR(AR71XX_RESET_BASE)); - id = __raw_readl(base + AR71XX_RESET_REG_REV_ID); - id &= REV_ID_MAJOR_MASK; + base = (void __iomem *)(KSEG1ADDR(ATH_RESET_BASE)); + id = __raw_readl(base + ATH_RESET_REG_REV_ID); + id &= ATH_RESET_REVISION_ID_MAJOR_MASK; switch (id) { +#if (defined CONFIG_SOC_AR71XX || defined CONFIG_SOC_AR724X || defined CONFIG_SOC_AR913X || defined CONFIG_SOC_AR934X || defined CONFIG_SOC_QCA955X) case REV_ID_MAJOR_AR71XX: case REV_ID_MAJOR_AR7240: case REV_ID_MAJOR_AR7241: @@ -80,11 +87,14 @@ case REV_ID_MAJOR_QCA9558: _prom_putchar = prom_putchar_ar71xx; break; +#endif +#if defined CONFIG_SOC_AR933X case REV_ID_MAJOR_AR9330: case REV_ID_MAJOR_AR9331: _prom_putchar = prom_putchar_ar933x; break; +#endif default: _prom_putchar = prom_putchar_dummy; @@ -92,10 +102,43 @@ } } -void prom_putchar(unsigned char ch) -{ +void prom_putchar(unsigned char ch) { + if (!_prom_putchar) prom_putchar_init(); _prom_putchar(ch); } + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +extern int vsprintf(char *buf, const char *fmt, va_list args); +static char sprint_buf[1024]; + +void writeserial(char *str, int count) { + + int i; + for (i = 0; i < count; i++) + prom_putchar(str[i]); + + prom_putchar('\r'); + memset(str, '\0', 1024); + return; +} + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +void serial_print(const char *fmt, ...) +{ + va_list args; + int n; + + va_start(args, fmt); + n = vsprintf(sprint_buf, fmt, args); + va_end(args); + writeserial(sprint_buf, n); +} + +