uart-16550.c 856 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * 16550 compatible uart based serial debug support for zboot
  3. */
  4. #include <linux/types.h>
  5. #include <linux/serial_reg.h>
  6. #include <linux/init.h>
  7. #include <asm/addrspace.h>
  8. #if defined(CONFIG_MACH_LOONGSON) || defined(CONFIG_MIPS_MALTA)
  9. #define UART_BASE 0x1fd003f8
  10. #define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
  11. #endif
  12. #ifdef CONFIG_AR7
  13. #include <ar7.h>
  14. #define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
  15. #endif
  16. #ifndef PORT
  17. #error please define the serial port address for your own machine
  18. #endif
  19. static inline unsigned int serial_in(int offset)
  20. {
  21. return *((char *)PORT(offset));
  22. }
  23. static inline void serial_out(int offset, int value)
  24. {
  25. *((char *)PORT(offset)) = value;
  26. }
  27. void putc(char c)
  28. {
  29. int timeout = 1024;
  30. while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
  31. ;
  32. serial_out(UART_TX, c);
  33. }