sead3-console.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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) 2012 MIPS Technologies, Inc. All rights reserved.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/console.h>
  10. #include <linux/serial_reg.h>
  11. #include <linux/io.h>
  12. #define SEAD_UART1_REGS_BASE 0xbf000800 /* ttyS1 = DB9 port */
  13. #define SEAD_UART0_REGS_BASE 0xbf000900 /* ttyS0 = USB port */
  14. #define PORT(base_addr, offset) ((unsigned int __iomem *)(base_addr+(offset)*4))
  15. static char console_port = 1;
  16. static inline unsigned int serial_in(int offset, unsigned int base_addr)
  17. {
  18. return __raw_readl(PORT(base_addr, offset)) & 0xff;
  19. }
  20. static inline void serial_out(int offset, int value, unsigned int base_addr)
  21. {
  22. __raw_writel(value, PORT(base_addr, offset));
  23. }
  24. void __init fw_init_early_console(char port)
  25. {
  26. console_port = port;
  27. }
  28. int prom_putchar(char c)
  29. {
  30. unsigned int base_addr;
  31. base_addr = console_port ? SEAD_UART1_REGS_BASE : SEAD_UART0_REGS_BASE;
  32. while ((serial_in(UART_LSR, base_addr) & UART_LSR_THRE) == 0)
  33. ;
  34. serial_out(UART_TX, c, base_addr);
  35. return 1;
  36. }