2 * linux/drivers/serial/cpm_uart.h
4 * Driver for CPM (SCC/SMC) serial ports
6 * Copyright (C) 2004 Freescale Semiconductor, Inc.
8 * 2006 (c) MontaVista Software, Inc.
9 * Vitaly Bordug <vbordug@ru.mvista.com>
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.
19 #include <linux/platform_device.h>
20 #include <linux/fs_uart_pd.h>
22 #if defined(CONFIG_CPM2)
23 #include "cpm_uart_cpm2.h"
24 #elif defined(CONFIG_8xx)
25 #include "cpm_uart_cpm1.h"
28 #define SERIAL_CPM_MAJOR 204
29 #define SERIAL_CPM_MINOR 46
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
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
44 #define UART_NR fs_uart_nr
47 #define RX_BUF_SIZE 32
49 #define TX_BUF_SIZE 32
51 #define SCC_WAIT_CLOSING 100
60 #define NUM_GPIOS (GPIO_RI+1)
62 struct uart_cpm_port {
63 struct uart_port port;
69 smc_uart_t __iomem *smcup;
71 scc_uart_t __iomem *sccup;
72 cbd_t __iomem *rx_bd_base;
73 cbd_t __iomem *rx_cur;
74 cbd_t __iomem *tx_bd_base;
75 cbd_t __iomem *tx_cur;
76 unsigned char *tx_buf;
77 unsigned char *rx_buf;
79 void (*set_lineif)(struct uart_cpm_port *);
89 /* Keep track of 'odd' SMC2 wirings */
91 /* wait on close if needed */
93 /* value to combine with opcode to form cpm command */
98 extern int cpm_uart_nr;
99 extern struct uart_cpm_port cpm_uart_ports[UART_NR];
101 /* these are located in their respective files */
102 void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
103 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
104 struct device_node *np);
105 void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
106 int cpm_uart_init_portdesc(void);
107 int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
108 void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
110 void smc1_lineif(struct uart_cpm_port *pinfo);
111 void smc2_lineif(struct uart_cpm_port *pinfo);
112 void scc1_lineif(struct uart_cpm_port *pinfo);
113 void scc2_lineif(struct uart_cpm_port *pinfo);
114 void scc3_lineif(struct uart_cpm_port *pinfo);
115 void scc4_lineif(struct uart_cpm_port *pinfo);
118 virtual to phys transtalion
120 static inline unsigned long cpu2cpm_addr(void *addr,
121 struct uart_cpm_port *pinfo)
125 u32 mem = (u32)pinfo->mem_addr;
127 if (likely(val >= mem && val < mem + pinfo->mem_size)) {
129 return pinfo->dma_addr + offset;
131 /* something nasty happened */
136 static inline void *cpm2cpu_addr(unsigned long addr,
137 struct uart_cpm_port *pinfo)
141 u32 dma = (u32)pinfo->dma_addr;
143 if (likely(val >= dma && val < dma + pinfo->mem_size)) {
145 return pinfo->mem_addr + offset;
147 /* something nasty happened */
153 #endif /* CPM_UART_H */