Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/serial/cpm_uart.h | |
3 | * | |
4 | * Driver for CPM (SCC/SMC) serial ports | |
5 | * | |
6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | |
7 | * | |
6e197696 VB |
8 | * 2006 (c) MontaVista Software, Inc. |
9 | * Vitaly Bordug <vbordug@ru.mvista.com> | |
10 | * | |
11 | * This file is licensed under the terms of the GNU General Public License | |
12 | * version 2. This program is licensed "as is" without any warranty of any | |
13 | * kind, whether express or implied. | |
14 | * | |
1da177e4 LT |
15 | */ |
16 | #ifndef CPM_UART_H | |
17 | #define CPM_UART_H | |
18 | ||
e27987cd VB |
19 | #include <linux/platform_device.h> |
20 | #include <linux/fs_uart_pd.h> | |
1da177e4 LT |
21 | |
22 | #if defined(CONFIG_CPM2) | |
23 | #include "cpm_uart_cpm2.h" | |
24 | #elif defined(CONFIG_8xx) | |
25 | #include "cpm_uart_cpm1.h" | |
26 | #endif | |
27 | ||
28 | #define SERIAL_CPM_MAJOR 204 | |
29 | #define SERIAL_CPM_MINOR 46 | |
30 | ||
31 | #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC) | |
32 | #define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING) | |
33 | #define FLAG_DISCARDING 0x00000004 /* when set, don't discard */ | |
34 | #define FLAG_SMC 0x00000002 | |
35 | #define FLAG_CONSOLE 0x00000001 | |
36 | ||
e27987cd VB |
37 | #define UART_SMC1 fsid_smc1_uart |
38 | #define UART_SMC2 fsid_smc2_uart | |
39 | #define UART_SCC1 fsid_scc1_uart | |
40 | #define UART_SCC2 fsid_scc2_uart | |
41 | #define UART_SCC3 fsid_scc3_uart | |
42 | #define UART_SCC4 fsid_scc4_uart | |
1da177e4 | 43 | |
e27987cd | 44 | #define UART_NR fs_uart_nr |
1da177e4 LT |
45 | |
46 | #define RX_NUM_FIFO 4 | |
47 | #define RX_BUF_SIZE 32 | |
48 | #define TX_NUM_FIFO 4 | |
49 | #define TX_BUF_SIZE 32 | |
50 | ||
311c4627 KG |
51 | #define SCC_WAIT_CLOSING 100 |
52 | ||
1da177e4 LT |
53 | struct uart_cpm_port { |
54 | struct uart_port port; | |
311c4627 | 55 | u16 rx_nrfifos; |
1da177e4 | 56 | u16 rx_fifosize; |
311c4627 | 57 | u16 tx_nrfifos; |
1da177e4 | 58 | u16 tx_fifosize; |
311c4627 | 59 | smc_t *smcp; |
1da177e4 LT |
60 | smc_uart_t *smcup; |
61 | scc_t *sccp; | |
62 | scc_uart_t *sccup; | |
63 | volatile cbd_t *rx_bd_base; | |
64 | volatile cbd_t *rx_cur; | |
65 | volatile cbd_t *tx_bd_base; | |
66 | volatile cbd_t *tx_cur; | |
67 | unsigned char *tx_buf; | |
68 | unsigned char *rx_buf; | |
69 | u32 flags; | |
70 | void (*set_lineif)(struct uart_cpm_port *); | |
71 | u8 brg; | |
72 | uint dp_addr; | |
73 | void *mem_addr; | |
74 | dma_addr_t dma_addr; | |
09b03b6c | 75 | u32 mem_size; |
1da177e4 LT |
76 | /* helpers */ |
77 | int baud; | |
78 | int bits; | |
79 | /* Keep track of 'odd' SMC2 wirings */ | |
80 | int is_portb; | |
311c4627 KG |
81 | /* wait on close if needed */ |
82 | int wait_closing; | |
1da177e4 LT |
83 | }; |
84 | ||
85 | extern int cpm_uart_port_map[UART_NR]; | |
86 | extern int cpm_uart_nr; | |
87 | extern struct uart_cpm_port cpm_uart_ports[UART_NR]; | |
88 | ||
89 | /* these are located in their respective files */ | |
90 | void cpm_line_cr_cmd(int line, int cmd); | |
32a56ebb | 91 | int cpm_uart_init_portdesc(void); |
1da177e4 LT |
92 | int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); |
93 | void cpm_uart_freebuf(struct uart_cpm_port *pinfo); | |
94 | ||
95 | void smc1_lineif(struct uart_cpm_port *pinfo); | |
96 | void smc2_lineif(struct uart_cpm_port *pinfo); | |
97 | void scc1_lineif(struct uart_cpm_port *pinfo); | |
98 | void scc2_lineif(struct uart_cpm_port *pinfo); | |
99 | void scc3_lineif(struct uart_cpm_port *pinfo); | |
100 | void scc4_lineif(struct uart_cpm_port *pinfo); | |
101 | ||
09b03b6c VB |
102 | /* |
103 | virtual to phys transtalion | |
104 | */ | |
105 | static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo) | |
106 | { | |
107 | int offset; | |
108 | u32 val = (u32)addr; | |
109 | /* sane check */ | |
6e197696 | 110 | if (likely((val >= (u32)pinfo->mem_addr)) && |
09b03b6c VB |
111 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { |
112 | offset = val - (u32)pinfo->mem_addr; | |
113 | return pinfo->dma_addr+offset; | |
114 | } | |
6e197696 VB |
115 | /* something nasty happened */ |
116 | BUG(); | |
09b03b6c VB |
117 | return 0; |
118 | } | |
119 | ||
120 | static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo) | |
121 | { | |
122 | int offset; | |
123 | u32 val = addr; | |
124 | /* sane check */ | |
6e197696 VB |
125 | if (likely((val >= pinfo->dma_addr) && |
126 | (val<(pinfo->dma_addr + pinfo->mem_size)))) { | |
09b03b6c VB |
127 | offset = val - (u32)pinfo->dma_addr; |
128 | return (void*)(pinfo->mem_addr+offset); | |
129 | } | |
6e197696 VB |
130 | /* something nasty happened */ |
131 | BUG(); | |
09b03b6c VB |
132 | return 0; |
133 | } | |
134 | ||
135 | ||
1da177e4 | 136 | #endif /* CPM_UART_H */ |