1 /* Unit-specific 8250 serial ports
3 * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #ifndef _ASM_UNIT_SERIAL_H
13 #define _ASM_UNIT_SERIAL_H
15 #include <asm/cpu-regs.h>
17 #include <unit/fpga-regs.h>
18 #include <linux/serial_reg.h>
20 #define SERIAL_PORT0_BASE_ADDRESS 0xA8200000
22 #define SERIAL_IRQ XIRQ1 /* single serial (TL16C550C) (Lo) */
25 * The ASB2364 has an 12.288 MHz clock
28 * It'd be nice if someone built a serial card with a 24.576 MHz
29 * clock, since the 16550A is capable of handling a top speed of 1.5
30 * megabits/second; but this requires the faster clock.
32 #define BASE_BAUD (12288000 / 16)
35 * dispose of the /dev/ttyS0 and /dev/ttyS1 serial ports
37 #ifndef CONFIG_GDBSTUB_ON_TTYSx
39 #define SERIAL_PORT_DFNS \
41 .baud_base = BASE_BAUD, \
43 .flags = STD_COM_FLAGS, \
44 .iomem_base = (u8 *) SERIAL_PORT0_BASE_ADDRESS, \
45 .iomem_reg_shift = 1, \
46 .io_type = SERIAL_IO_MEM, \
51 static inline void __debug_to_serial(const char *p
, int n
)
55 #endif /* !__ASSEMBLY__ */
57 #else /* CONFIG_GDBSTUB_ON_TTYSx */
59 #define SERIAL_PORT_DFNS /* stolen by gdb-stub */
61 #if defined(CONFIG_GDBSTUB_ON_TTYS0)
62 #define GDBPORT_SERIAL_RX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_RX * 4, u8)
63 #define GDBPORT_SERIAL_TX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_TX * 4, u8)
64 #define GDBPORT_SERIAL_DLL __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLL * 4, u8)
65 #define GDBPORT_SERIAL_DLM __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLM * 4, u8)
66 #define GDBPORT_SERIAL_IER __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IER * 4, u8)
67 #define GDBPORT_SERIAL_IIR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IIR * 4, u8)
68 #define GDBPORT_SERIAL_FCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_FCR * 4, u8)
69 #define GDBPORT_SERIAL_LCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LCR * 4, u8)
70 #define GDBPORT_SERIAL_MCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MCR * 4, u8)
71 #define GDBPORT_SERIAL_LSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LSR * 4, u8)
72 #define GDBPORT_SERIAL_MSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MSR * 4, u8)
73 #define GDBPORT_SERIAL_SCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_SCR * 4, u8)
74 #define GDBPORT_SERIAL_IRQ SERIAL_IRQ
76 #elif defined(CONFIG_GDBSTUB_ON_TTYS1)
77 #error The ASB2364 does not have a /dev/ttyS1
82 static inline void __debug_to_serial(const char *p
, int n
)
86 #define LSR_WAIT_FOR(STATE) \
87 do {} while (!(GDBPORT_SERIAL_LSR & UART_LSR_##STATE))
88 #define FLOWCTL_QUERY(LINE) \
89 ({ GDBPORT_SERIAL_MSR & UART_MSR_##LINE; })
90 #define FLOWCTL_WAIT_FOR(LINE) \
91 do {} while (!(GDBPORT_SERIAL_MSR & UART_MSR_##LINE))
92 #define FLOWCTL_CLEAR(LINE) \
93 do { GDBPORT_SERIAL_MCR &= ~UART_MCR_##LINE; } while (0)
94 #define FLOWCTL_SET(LINE) \
95 do { GDBPORT_SERIAL_MCR |= UART_MCR_##LINE; } while (0)
101 FLOWCTL_WAIT_FOR(CTS
);
105 GDBPORT_SERIAL_TX
= 0x0d;
107 FLOWCTL_WAIT_FOR(CTS
);
109 GDBPORT_SERIAL_TX
= ch
;
115 #endif /* !__ASSEMBLY__ */
117 #endif /* CONFIG_GDBSTUB_ON_TTYSx */
119 #define SERIAL_INITIALIZE \
121 /* release reset */ \
122 ASB2364_FPGA_REG_RESET_UART = 0x0001; \
126 #define SERIAL_CHECK_INTERRUPT \
128 if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) == 0x0001) { \
133 #define SERIAL_CLEAR_INTERRUPT \
135 ASB2364_FPGA_REG_IRQ_UART = 0x0001; \
139 #define SERIAL_SET_INT_MASK \
141 ASB2364_FPGA_REG_MASK_UART = 0x0001; \
145 #define SERIAL_CLEAR_INT_MASK \
147 ASB2364_FPGA_REG_MASK_UART = 0x0000; \
151 #endif /* _ASM_UNIT_SERIAL_H */