2 * linux/drivers/serial/cpm_uart.h
4 * Driver for CPM (SCC/SMC) serial ports
6 * Copyright (C) 2004 Freescale Semiconductor, Inc.
12 #include <linux/config.h>
13 #include <linux/platform_device.h>
14 #include <linux/fs_uart_pd.h>
16 #if defined(CONFIG_CPM2)
17 #include "cpm_uart_cpm2.h"
18 #elif defined(CONFIG_8xx)
19 #include "cpm_uart_cpm1.h"
22 #define SERIAL_CPM_MAJOR 204
23 #define SERIAL_CPM_MINOR 46
25 #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
26 #define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
27 #define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
28 #define FLAG_SMC 0x00000002
29 #define FLAG_CONSOLE 0x00000001
31 #define UART_SMC1 fsid_smc1_uart
32 #define UART_SMC2 fsid_smc2_uart
33 #define UART_SCC1 fsid_scc1_uart
34 #define UART_SCC2 fsid_scc2_uart
35 #define UART_SCC3 fsid_scc3_uart
36 #define UART_SCC4 fsid_scc4_uart
38 #define UART_NR fs_uart_nr
41 #define RX_BUF_SIZE 32
43 #define TX_BUF_SIZE 32
45 #define SCC_WAIT_CLOSING 100
47 struct uart_cpm_port {
48 struct uart_port port;
57 volatile cbd_t *rx_bd_base;
58 volatile cbd_t *rx_cur;
59 volatile cbd_t *tx_bd_base;
60 volatile cbd_t *tx_cur;
61 unsigned char *tx_buf;
62 unsigned char *rx_buf;
64 void (*set_lineif)(struct uart_cpm_port *);
73 /* Keep track of 'odd' SMC2 wirings */
75 /* wait on close if needed */
79 extern int cpm_uart_port_map[UART_NR];
80 extern int cpm_uart_nr;
81 extern struct uart_cpm_port cpm_uart_ports[UART_NR];
83 /* these are located in their respective files */
84 void cpm_line_cr_cmd(int line, int cmd);
85 int cpm_uart_init_portdesc(void);
86 int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
87 void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
89 void smc1_lineif(struct uart_cpm_port *pinfo);
90 void smc2_lineif(struct uart_cpm_port *pinfo);
91 void scc1_lineif(struct uart_cpm_port *pinfo);
92 void scc2_lineif(struct uart_cpm_port *pinfo);
93 void scc3_lineif(struct uart_cpm_port *pinfo);
94 void scc4_lineif(struct uart_cpm_port *pinfo);
97 virtual to phys transtalion
99 static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo)
104 if ((val >= (u32)pinfo->mem_addr) &&
105 (val<((u32)pinfo->mem_addr + pinfo->mem_size))) {
106 offset = val - (u32)pinfo->mem_addr;
107 return pinfo->dma_addr+offset;
109 printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val);
113 static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo)
118 if ((val >= pinfo->dma_addr) &&
119 (val<(pinfo->dma_addr + pinfo->mem_size))) {
120 offset = val - (u32)pinfo->dma_addr;
121 return (void*)(pinfo->mem_addr+offset);
123 printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val);
128 #endif /* CPM_UART_H */