powerpc/pseries: Cleanup on pci_dn_reconfig_notifier()
[linux/fpc-iii.git] / arch / mn10300 / unit-asb2364 / include / unit / serial.h
blob92f224a97efcc612ba8fa2610d335d04e9cd788c
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>
16 #include <proc/irq.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
26 * for your UART.
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 \
40 { \
41 .baud_base = BASE_BAUD, \
42 .irq = SERIAL_IRQ, \
43 .flags = STD_COM_FLAGS, \
44 .iomem_base = (u8 *) SERIAL_PORT0_BASE_ADDRESS, \
45 .iomem_reg_shift = 1, \
46 .io_type = SERIAL_IO_MEM, \
49 #ifndef __ASSEMBLY__
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 * 2, u8)
63 #define GDBPORT_SERIAL_TX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_TX * 2, u8)
64 #define GDBPORT_SERIAL_DLL __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLL * 2, u8)
65 #define GDBPORT_SERIAL_DLM __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLM * 2, u8)
66 #define GDBPORT_SERIAL_IER __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IER * 2, u8)
67 #define GDBPORT_SERIAL_IIR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IIR * 2, u8)
68 #define GDBPORT_SERIAL_FCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_FCR * 2, u8)
69 #define GDBPORT_SERIAL_LCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LCR * 2, u8)
70 #define GDBPORT_SERIAL_MCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MCR * 2, u8)
71 #define GDBPORT_SERIAL_LSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LSR * 2, u8)
72 #define GDBPORT_SERIAL_MSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MSR * 2, u8)
73 #define GDBPORT_SERIAL_SCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_SCR * 2, 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
78 #endif
80 #ifndef __ASSEMBLY__
82 static inline void __debug_to_serial(const char *p, int n)
84 char ch;
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)
97 FLOWCTL_SET(DTR);
99 for (; n > 0; n--) {
100 LSR_WAIT_FOR(THRE);
101 FLOWCTL_WAIT_FOR(CTS);
103 ch = *p++;
104 if (ch == 0x0a) {
105 GDBPORT_SERIAL_TX = 0x0d;
106 LSR_WAIT_FOR(THRE);
107 FLOWCTL_WAIT_FOR(CTS);
109 GDBPORT_SERIAL_TX = ch;
112 FLOWCTL_CLEAR(DTR);
115 #endif /* !__ASSEMBLY__ */
117 #endif /* CONFIG_GDBSTUB_ON_TTYSx */
119 #define SERIAL_INITIALIZE \
120 do { \
121 /* release reset */ \
122 ASB2364_FPGA_REG_RESET_UART = 0x0001; \
123 SyncExBus(); \
124 } while (0)
126 #define SERIAL_CHECK_INTERRUPT \
127 do { \
128 if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) == 0x0001) { \
129 return IRQ_NONE; \
131 } while (0)
133 #define SERIAL_CLEAR_INTERRUPT \
134 do { \
135 ASB2364_FPGA_REG_IRQ_UART = 0x0001; \
136 SyncExBus(); \
137 } while (0)
139 #define SERIAL_SET_INT_MASK \
140 do { \
141 ASB2364_FPGA_REG_MASK_UART = 0x0001; \
142 SyncExBus(); \
143 } while (0)
145 #define SERIAL_CLEAR_INT_MASK \
146 do { \
147 ASB2364_FPGA_REG_MASK_UART = 0x0000; \
148 SyncExBus(); \
149 } while (0)
151 #endif /* _ASM_UNIT_SERIAL_H */