uartlite_tty.c 975 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Xilinx UARTLITE bootloader driver
  3. *
  4. * Copyright (c) 2007 Secret Lab Technologies Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/types.h>
  12. #include <asm/serial.h>
  13. #include <asm/io.h>
  14. #include <platforms/4xx/xparameters/xparameters.h>
  15. #define UARTLITE_BASEADDR ((void*)(XPAR_UARTLITE_0_BASEADDR))
  16. void
  17. serial_putc(unsigned long com_port, unsigned char c)
  18. {
  19. while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x08) != 0); /* spin */
  20. out_be32(UARTLITE_BASEADDR + 0x4, c);
  21. }
  22. unsigned char
  23. serial_getc(unsigned long com_port)
  24. {
  25. while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) == 0); /* spin */
  26. return in_be32(UARTLITE_BASEADDR);
  27. }
  28. int
  29. serial_tstc(unsigned long com_port)
  30. {
  31. return ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) != 0);
  32. }