early_printk.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  7. */
  8. #include <linux/io.h>
  9. #include <linux/serial_reg.h>
  10. #include <asm/addrspace.h>
  11. #define EARLY_UART_BASE 0x10000c00
  12. #define UART_REG_RX 0x00
  13. #define UART_REG_TX 0x04
  14. #define UART_REG_IER 0x08
  15. #define UART_REG_IIR 0x0c
  16. #define UART_REG_FCR 0x10
  17. #define UART_REG_LCR 0x14
  18. #define UART_REG_MCR 0x18
  19. #define UART_REG_LSR 0x1c
  20. static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE);
  21. static inline void uart_w32(u32 val, unsigned reg)
  22. {
  23. __raw_writel(val, uart_membase + reg);
  24. }
  25. static inline u32 uart_r32(unsigned reg)
  26. {
  27. return __raw_readl(uart_membase + reg);
  28. }
  29. void prom_putchar(unsigned char ch)
  30. {
  31. while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
  32. ;
  33. uart_w32(ch, UART_REG_TX);
  34. while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
  35. ;
  36. }