serial.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* ASB2305-specific 8250 serial ports
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_UNIT_SERIAL_H
  12. #define _ASM_UNIT_SERIAL_H
  13. #include <asm/cpu/cpu-regs.h>
  14. #include <asm/proc/irq.h>
  15. #include <linux/serial_reg.h>
  16. #define SERIAL_PORT0_BASE_ADDRESS 0xA6FB0000
  17. #define ASB2305_DEBUG_MCR __SYSREG(0xA6FB0000 + UART_MCR * 2, u8)
  18. #define SERIAL_IRQ XIRQ0 /* Dual serial (PC16552) (Hi) */
  19. /*
  20. * dispose of the /dev/ttyS0 serial port
  21. */
  22. #ifndef CONFIG_GDBSTUB_ON_TTYSx
  23. #define SERIAL_PORT_DFNS \
  24. { \
  25. .baud_base = BASE_BAUD, \
  26. .irq = SERIAL_IRQ, \
  27. .flags = STD_COM_FLAGS, \
  28. .iomem_base = (u8 *) SERIAL_PORT0_BASE_ADDRESS, \
  29. .iomem_reg_shift = 2, \
  30. .io_type = SERIAL_IO_MEM, \
  31. },
  32. #ifndef __ASSEMBLY__
  33. static inline void __debug_to_serial(const char *p, int n)
  34. {
  35. }
  36. #endif /* !__ASSEMBLY__ */
  37. #else /* CONFIG_GDBSTUB_ON_TTYSx */
  38. #define SERIAL_PORT_DFNS /* stolen by gdb-stub */
  39. #if defined(CONFIG_GDBSTUB_ON_TTYS0)
  40. #define GDBPORT_SERIAL_RX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_RX * 4, u8)
  41. #define GDBPORT_SERIAL_TX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_TX * 4, u8)
  42. #define GDBPORT_SERIAL_DLL __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLL * 4, u8)
  43. #define GDBPORT_SERIAL_DLM __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLM * 4, u8)
  44. #define GDBPORT_SERIAL_IER __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IER * 4, u8)
  45. #define GDBPORT_SERIAL_IIR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IIR * 4, u8)
  46. #define GDBPORT_SERIAL_FCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_FCR * 4, u8)
  47. #define GDBPORT_SERIAL_LCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LCR * 4, u8)
  48. #define GDBPORT_SERIAL_MCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MCR * 4, u8)
  49. #define GDBPORT_SERIAL_LSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LSR * 4, u8)
  50. #define GDBPORT_SERIAL_MSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MSR * 4, u8)
  51. #define GDBPORT_SERIAL_SCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_SCR * 4, u8)
  52. #define GDBPORT_SERIAL_IRQ SERIAL_IRQ
  53. #elif defined(CONFIG_GDBSTUB_ON_TTYS1)
  54. #error The ASB2305 doesnt have a /dev/ttyS1
  55. #endif
  56. #ifndef __ASSEMBLY__
  57. #define TTYS0_TX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_TX * 4, u8)
  58. #define TTYS0_MCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MCR * 4, u8)
  59. #define TTYS0_LSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LSR * 4, u8)
  60. #define TTYS0_MSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MSR * 4, u8)
  61. #define LSR_WAIT_FOR(STATE) \
  62. do { \
  63. while (!(TTYS0_LSR & UART_LSR_##STATE)) {} \
  64. } while (0)
  65. #define FLOWCTL_WAIT_FOR(LINE) \
  66. do { \
  67. while (!(TTYS0_MSR & UART_MSR_##LINE)) {} \
  68. } while (0)
  69. #define FLOWCTL_CLEAR(LINE) \
  70. do { \
  71. TTYS0_MCR &= ~UART_MCR_##LINE; \
  72. } while (0)
  73. #define FLOWCTL_SET(LINE) \
  74. do { \
  75. TTYS0_MCR |= UART_MCR_##LINE; \
  76. } while (0)
  77. #define FLOWCTL_QUERY(LINE) ({ TTYS0_MSR & UART_MSR_##LINE; })
  78. static inline void __debug_to_serial(const char *p, int n)
  79. {
  80. char ch;
  81. FLOWCTL_SET(DTR);
  82. for (; n > 0; n--) {
  83. LSR_WAIT_FOR(THRE);
  84. FLOWCTL_WAIT_FOR(CTS);
  85. ch = *p++;
  86. if (ch == 0x0a) {
  87. TTYS0_TX = 0x0d;
  88. LSR_WAIT_FOR(THRE);
  89. FLOWCTL_WAIT_FOR(CTS);
  90. }
  91. TTYS0_TX = ch;
  92. }
  93. FLOWCTL_CLEAR(DTR);
  94. }
  95. #endif /* !__ASSEMBLY__ */
  96. #endif /* CONFIG_GDBSTUB_ON_TTYSx */
  97. #endif /* _ASM_UNIT_SERIAL_H */