serial_xuartlite.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * (C) Copyright 2008 Michal Simek <monstr@monstr.eu>
  3. * Clean driver and add xilinx constant from header file
  4. *
  5. * (C) Copyright 2004 Atmark Techno, Inc.
  6. * Yasushi SHOJI <yashi@atmark-techno.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <config.h>
  27. #include <asm/io.h>
  28. #define RX_FIFO_OFFSET 0 /* receive FIFO, read only */
  29. #define TX_FIFO_OFFSET 4 /* transmit FIFO, write only */
  30. #define STATUS_REG_OFFSET 8 /* status register, read only */
  31. #define SR_TX_FIFO_FULL 0x08 /* transmit FIFO full */
  32. #define SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
  33. #define SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
  34. #define UARTLITE_STATUS (CONFIG_SERIAL_BASE + STATUS_REG_OFFSET)
  35. #define UARTLITE_TX_FIFO (CONFIG_SERIAL_BASE + TX_FIFO_OFFSET)
  36. #define UARTLITE_RX_FIFO (CONFIG_SERIAL_BASE + RX_FIFO_OFFSET)
  37. int serial_init(void)
  38. {
  39. /* FIXME: Nothing for now. We should initialize fifo, etc */
  40. return 0;
  41. }
  42. void serial_setbrg(void)
  43. {
  44. /* FIXME: what's this for? */
  45. }
  46. void serial_putc(const char c)
  47. {
  48. if (c == '\n')
  49. serial_putc('\r');
  50. <<<<<<< .merge_file_kaofiJ
  51. while (in_be32((void *)UARTLITE_STATUS) & SR_TX_FIFO_FULL);
  52. out_be32((void *)UARTLITE_TX_FIFO, (unsigned char) (c & 0xff));
  53. =======
  54. while (in_be32((u32 *) UARTLITE_STATUS) & SR_TX_FIFO_FULL);
  55. out_be32((u32 *) UARTLITE_TX_FIFO, (unsigned char) (c & 0xff));
  56. >>>>>>> .merge_file_zSz9BG
  57. }
  58. void serial_puts(const char * s)
  59. {
  60. while (*s) {
  61. serial_putc(*s++);
  62. }
  63. }
  64. int serial_getc(void)
  65. {
  66. <<<<<<< .merge_file_kaofiJ
  67. while (!(in_be32((void *)UARTLITE_STATUS) & SR_RX_FIFO_VALID_DATA));
  68. return in_be32((void *)UARTLITE_RX_FIFO) & 0xff;
  69. =======
  70. while (!(in_be32((u32 *) UARTLITE_STATUS) & SR_RX_FIFO_VALID_DATA));
  71. return in_be32((u32 *) UARTLITE_RX_FIFO) & 0xff;
  72. >>>>>>> .merge_file_zSz9BG
  73. }
  74. int serial_tstc(void)
  75. {
  76. <<<<<<< .merge_file_kaofiJ
  77. return (in_be32((void *)UARTLITE_STATUS) & SR_RX_FIFO_VALID_DATA);
  78. =======
  79. return (in_be32((u32 *) UARTLITE_STATUS) & SR_RX_FIFO_VALID_DATA);
  80. >>>>>>> .merge_file_zSz9BG
  81. }