early_printk.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  7. */
  8. #include <linux/mm.h>
  9. #include <linux/io.h>
  10. #include <linux/serial_reg.h>
  11. #include <asm/setup.h>
  12. #include "devices.h"
  13. #include "ar2315_regs.h"
  14. #include "ar5312_regs.h"
  15. static inline void prom_uart_wr(void __iomem *base, unsigned reg,
  16. unsigned char ch)
  17. {
  18. __raw_writel(ch, base + 4 * reg);
  19. }
  20. static inline unsigned char prom_uart_rr(void __iomem *base, unsigned reg)
  21. {
  22. return __raw_readl(base + 4 * reg);
  23. }
  24. void prom_putchar(char ch)
  25. {
  26. static void __iomem *base;
  27. if (unlikely(base == NULL)) {
  28. if (is_ar2315())
  29. base = (void __iomem *)(KSEG1ADDR(AR2315_UART0_BASE));
  30. else
  31. base = (void __iomem *)(KSEG1ADDR(AR5312_UART0_BASE));
  32. }
  33. while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
  34. ;
  35. prom_uart_wr(base, UART_TX, (unsigned char)ch);
  36. while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
  37. ;
  38. }