early_printk.c 862 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Atheros AR71XX/AR724X/AR913X SoC early printk support
  3. *
  4. * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/io.h>
  12. #include <linux/serial_reg.h>
  13. #include <asm/addrspace.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. static inline void prom_wait_thre(void __iomem *base)
  16. {
  17. u32 lsr;
  18. do {
  19. lsr = __raw_readl(base + UART_LSR * 4);
  20. if (lsr & UART_LSR_THRE)
  21. break;
  22. } while (1);
  23. }
  24. void prom_putchar(unsigned char ch)
  25. {
  26. void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
  27. prom_wait_thre(base);
  28. __raw_writel(ch, base + UART_TX * 4);
  29. prom_wait_thre(base);
  30. }