2 * drivers/serial/mpsc.h
4 * Author: Mark A. Greer <mgreer@mvista.com>
6 * 2004 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
15 #include <linux/config.h>
17 #if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
21 #include <linux/module.h>
22 #include <linux/moduleparam.h>
23 #include <linux/tty.h>
24 #include <linux/tty_flip.h>
25 #include <linux/ioport.h>
26 #include <linux/init.h>
27 #include <linux/console.h>
28 #include <linux/sysrq.h>
29 #include <linux/serial.h>
30 #include <linux/serial_core.h>
31 #include <linux/delay.h>
32 #include <linux/device.h>
33 #include <linux/dma-mapping.h>
34 #include <linux/mv643xx.h>
39 #define MPSC_NUM_CTLRS 2
42 * Descriptors and buffers must be cache line aligned.
43 * Buffers lengths must be multiple of cache line size.
44 * Number of Tx & Rx descriptors must be powers of 2.
46 #define MPSC_RXR_ENTRIES 32
47 #define MPSC_RXRE_SIZE dma_get_cache_alignment()
48 #define MPSC_RXR_SIZE (MPSC_RXR_ENTRIES * MPSC_RXRE_SIZE)
49 #define MPSC_RXBE_SIZE dma_get_cache_alignment()
50 #define MPSC_RXB_SIZE (MPSC_RXR_ENTRIES * MPSC_RXBE_SIZE)
52 #define MPSC_TXR_ENTRIES 32
53 #define MPSC_TXRE_SIZE dma_get_cache_alignment()
54 #define MPSC_TXR_SIZE (MPSC_TXR_ENTRIES * MPSC_TXRE_SIZE)
55 #define MPSC_TXBE_SIZE dma_get_cache_alignment()
56 #define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
58 #define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \
59 MPSC_TXR_SIZE + MPSC_TXB_SIZE + \
60 dma_get_cache_alignment() /* for alignment */)
62 /* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
69 } __attribute((packed
));
77 } __attribute((packed
));
80 * Some regs that have the erratum that you can't read them are are shared
81 * between the two MPSC controllers. This struct contains those shared regs.
83 struct mpsc_shared_regs
{
84 phys_addr_t mpsc_routing_base_p
;
85 phys_addr_t sdma_intr_base_p
;
87 void __iomem
*mpsc_routing_base
;
88 void __iomem
*sdma_intr_base
;
93 u32 SDMA_INTR_CAUSE_m
;
97 /* The main driver data structure */
98 struct mpsc_port_info
{
99 struct uart_port port
; /* Overlay uart_port structure */
101 /* Internal driver state for this ctlr */
104 tcflag_t c_iflag
; /* save termios->c_iflag */
105 tcflag_t c_cflag
; /* save termios->c_cflag */
107 /* Info passed in from platform */
108 u8 mirror_regs
; /* Need to mirror regs? */
109 u8 cache_mgmt
; /* Need manual cache mgmt? */
110 u8 brg_can_tune
; /* BRG has baud tuning? */
118 /* Physical addresses of various blocks of registers (from platform) */
119 phys_addr_t mpsc_base_p
;
120 phys_addr_t sdma_base_p
;
121 phys_addr_t brg_base_p
;
123 /* Virtual addresses of various blocks of registers (from platform) */
124 void __iomem
*mpsc_base
;
125 void __iomem
*sdma_base
;
126 void __iomem
*brg_base
;
128 /* Descriptor ring and buffer allocations */
130 dma_addr_t dma_region_p
;
132 dma_addr_t rxr
; /* Rx descriptor ring */
133 dma_addr_t rxr_p
; /* Phys addr of rxr */
134 u8
*rxb
; /* Rx Ring I/O buf */
135 u8
*rxb_p
; /* Phys addr of rxb */
136 u32 rxr_posn
; /* First desc w/ Rx data */
138 dma_addr_t txr
; /* Tx descriptor ring */
139 dma_addr_t txr_p
; /* Phys addr of txr */
140 u8
*txb
; /* Tx Ring I/O buf */
141 u8
*txb_p
; /* Phys addr of txb */
142 int txr_head
; /* Where new data goes */
143 int txr_tail
; /* Where sent data comes off */
145 /* Mirrored values of regs we can't read (if 'mirror_regs' set) */
151 struct mpsc_shared_regs
*shared_regs
;
154 /* Hooks to platform-specific code */
155 int mpsc_platform_register_driver(void);
156 void mpsc_platform_unregister_driver(void);
158 /* Hooks back in to mpsc common to be called by platform-specific code */
159 struct mpsc_port_info
*mpsc_device_probe(int index
);
160 struct mpsc_port_info
*mpsc_device_remove(int index
);
163 *****************************************************************************
165 * Multi-Protocol Serial Controller Interface Registers
167 *****************************************************************************
170 /* Main Configuratino Register Offsets */
171 #define MPSC_MMCRL 0x0000
172 #define MPSC_MMCRH 0x0004
173 #define MPSC_MPCR 0x0008
174 #define MPSC_CHR_1 0x000c
175 #define MPSC_CHR_2 0x0010
176 #define MPSC_CHR_3 0x0014
177 #define MPSC_CHR_4 0x0018
178 #define MPSC_CHR_5 0x001c
179 #define MPSC_CHR_6 0x0020
180 #define MPSC_CHR_7 0x0024
181 #define MPSC_CHR_8 0x0028
182 #define MPSC_CHR_9 0x002c
183 #define MPSC_CHR_10 0x0030
184 #define MPSC_CHR_11 0x0034
186 #define MPSC_MPCR_FRZ (1 << 9)
187 #define MPSC_MPCR_CL_5 0
188 #define MPSC_MPCR_CL_6 1
189 #define MPSC_MPCR_CL_7 2
190 #define MPSC_MPCR_CL_8 3
191 #define MPSC_MPCR_SBL_1 0
192 #define MPSC_MPCR_SBL_2 1
194 #define MPSC_CHR_2_TEV (1<<1)
195 #define MPSC_CHR_2_TA (1<<7)
196 #define MPSC_CHR_2_TTCS (1<<9)
197 #define MPSC_CHR_2_REV (1<<17)
198 #define MPSC_CHR_2_RA (1<<23)
199 #define MPSC_CHR_2_CRD (1<<25)
200 #define MPSC_CHR_2_EH (1<<31)
201 #define MPSC_CHR_2_PAR_ODD 0
202 #define MPSC_CHR_2_PAR_SPACE 1
203 #define MPSC_CHR_2_PAR_EVEN 2
204 #define MPSC_CHR_2_PAR_MARK 3
206 /* MPSC Signal Routing */
207 #define MPSC_MRR 0x0000
208 #define MPSC_RCRR 0x0004
209 #define MPSC_TCRR 0x0008
212 *****************************************************************************
214 * Serial DMA Controller Interface Registers
216 *****************************************************************************
219 #define SDMA_SDC 0x0000
220 #define SDMA_SDCM 0x0008
221 #define SDMA_RX_DESC 0x0800
222 #define SDMA_RX_BUF_PTR 0x0808
223 #define SDMA_SCRDP 0x0810
224 #define SDMA_TX_DESC 0x0c00
225 #define SDMA_SCTDP 0x0c10
226 #define SDMA_SFTDP 0x0c14
228 #define SDMA_DESC_CMDSTAT_PE (1<<0)
229 #define SDMA_DESC_CMDSTAT_CDL (1<<1)
230 #define SDMA_DESC_CMDSTAT_FR (1<<3)
231 #define SDMA_DESC_CMDSTAT_OR (1<<6)
232 #define SDMA_DESC_CMDSTAT_BR (1<<9)
233 #define SDMA_DESC_CMDSTAT_MI (1<<10)
234 #define SDMA_DESC_CMDSTAT_A (1<<11)
235 #define SDMA_DESC_CMDSTAT_AM (1<<12)
236 #define SDMA_DESC_CMDSTAT_CT (1<<13)
237 #define SDMA_DESC_CMDSTAT_C (1<<14)
238 #define SDMA_DESC_CMDSTAT_ES (1<<15)
239 #define SDMA_DESC_CMDSTAT_L (1<<16)
240 #define SDMA_DESC_CMDSTAT_F (1<<17)
241 #define SDMA_DESC_CMDSTAT_P (1<<18)
242 #define SDMA_DESC_CMDSTAT_EI (1<<23)
243 #define SDMA_DESC_CMDSTAT_O (1<<31)
245 #define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \
246 SDMA_DESC_CMDSTAT_EI)
248 #define SDMA_SDC_RFT (1<<0)
249 #define SDMA_SDC_SFM (1<<1)
250 #define SDMA_SDC_BLMR (1<<6)
251 #define SDMA_SDC_BLMT (1<<7)
252 #define SDMA_SDC_POVR (1<<8)
253 #define SDMA_SDC_RIFB (1<<9)
255 #define SDMA_SDCM_ERD (1<<7)
256 #define SDMA_SDCM_AR (1<<15)
257 #define SDMA_SDCM_STD (1<<16)
258 #define SDMA_SDCM_TXD (1<<23)
259 #define SDMA_SDCM_AT (1<<31)
261 #define SDMA_0_CAUSE_RXBUF (1<<0)
262 #define SDMA_0_CAUSE_RXERR (1<<1)
263 #define SDMA_0_CAUSE_TXBUF (1<<2)
264 #define SDMA_0_CAUSE_TXEND (1<<3)
265 #define SDMA_1_CAUSE_RXBUF (1<<8)
266 #define SDMA_1_CAUSE_RXERR (1<<9)
267 #define SDMA_1_CAUSE_TXBUF (1<<10)
268 #define SDMA_1_CAUSE_TXEND (1<<11)
270 #define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \
271 SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
272 #define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \
273 SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
275 /* SDMA Interrupt registers */
276 #define SDMA_INTR_CAUSE 0x0000
277 #define SDMA_INTR_MASK 0x0080
280 *****************************************************************************
282 * Baud Rate Generator Interface Registers
284 *****************************************************************************
287 #define BRG_BCR 0x0000
288 #define BRG_BTR 0x0004
290 #endif /* __MPSC_H__ */