2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/serial/cpm_uart.h
|
|
|
|
*
|
|
|
|
* Driver for CPM (SCC/SMC) serial ports
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Freescale Semiconductor, Inc.
|
|
|
|
*
|
2006-04-29 19:06:00 +00:00
|
|
|
* 2006 (c) MontaVista Software, Inc.
|
2008-06-12 12:53:48 +00:00
|
|
|
* Vitaly Bordug <vbordug@ru.mvista.com>
|
2006-04-29 19:06:00 +00:00
|
|
|
*
|
|
|
|
* This file is licensed under the terms of the GNU General Public License
|
|
|
|
* version 2. This program is licensed "as is" without any warranty of any
|
|
|
|
* kind, whether express or implied.
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
#ifndef CPM_UART_H
|
|
|
|
#define CPM_UART_H
|
|
|
|
|
2006-04-25 16:26:41 +00:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/fs_uart_pd.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_CPM2)
|
|
|
|
#include "cpm_uart_cpm2.h"
|
|
|
|
#elif defined(CONFIG_8xx)
|
|
|
|
#include "cpm_uart_cpm1.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SERIAL_CPM_MAJOR 204
|
|
|
|
#define SERIAL_CPM_MINOR 46
|
|
|
|
|
2008-06-12 12:53:48 +00:00
|
|
|
#define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
|
2005-04-16 22:20:36 +00:00
|
|
|
#define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
|
|
|
|
#define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
|
|
|
|
#define FLAG_SMC 0x00000002
|
|
|
|
#define FLAG_CONSOLE 0x00000001
|
|
|
|
|
2006-04-25 16:26:41 +00:00
|
|
|
#define UART_SMC1 fsid_smc1_uart
|
|
|
|
#define UART_SMC2 fsid_smc2_uart
|
|
|
|
#define UART_SCC1 fsid_scc1_uart
|
|
|
|
#define UART_SCC2 fsid_scc2_uart
|
|
|
|
#define UART_SCC3 fsid_scc3_uart
|
|
|
|
#define UART_SCC4 fsid_scc4_uart
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-04-25 16:26:41 +00:00
|
|
|
#define UART_NR fs_uart_nr
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define RX_NUM_FIFO 4
|
|
|
|
#define RX_BUF_SIZE 32
|
|
|
|
#define TX_NUM_FIFO 4
|
|
|
|
#define TX_BUF_SIZE 32
|
|
|
|
|
2005-08-09 17:08:00 +00:00
|
|
|
#define SCC_WAIT_CLOSING 100
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
struct uart_cpm_port {
|
|
|
|
struct uart_port port;
|
2005-08-09 17:08:00 +00:00
|
|
|
u16 rx_nrfifos;
|
2005-04-16 22:20:36 +00:00
|
|
|
u16 rx_fifosize;
|
2005-08-09 17:08:00 +00:00
|
|
|
u16 tx_nrfifos;
|
2005-04-16 22:20:36 +00:00
|
|
|
u16 tx_fifosize;
|
2007-07-24 20:53:07 +00:00
|
|
|
smc_t __iomem *smcp;
|
|
|
|
smc_uart_t __iomem *smcup;
|
|
|
|
scc_t __iomem *sccp;
|
|
|
|
scc_uart_t __iomem *sccup;
|
|
|
|
cbd_t __iomem *rx_bd_base;
|
|
|
|
cbd_t __iomem *rx_cur;
|
|
|
|
cbd_t __iomem *tx_bd_base;
|
|
|
|
cbd_t __iomem *tx_cur;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char *tx_buf;
|
|
|
|
unsigned char *rx_buf;
|
|
|
|
u32 flags;
|
|
|
|
void (*set_lineif)(struct uart_cpm_port *);
|
|
|
|
u8 brg;
|
|
|
|
uint dp_addr;
|
2008-06-12 12:53:48 +00:00
|
|
|
void *mem_addr;
|
2005-04-16 22:20:36 +00:00
|
|
|
dma_addr_t dma_addr;
|
2006-04-25 16:26:46 +00:00
|
|
|
u32 mem_size;
|
2005-04-16 22:20:36 +00:00
|
|
|
/* helpers */
|
|
|
|
int baud;
|
|
|
|
int bits;
|
|
|
|
/* Keep track of 'odd' SMC2 wirings */
|
|
|
|
int is_portb;
|
2005-08-09 17:08:00 +00:00
|
|
|
/* wait on close if needed */
|
2008-06-12 12:53:48 +00:00
|
|
|
int wait_closing;
|
2007-07-17 22:59:06 +00:00
|
|
|
/* value to combine with opcode to form cpm command */
|
|
|
|
u32 command;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int cpm_uart_nr;
|
|
|
|
extern struct uart_cpm_port cpm_uart_ports[UART_NR];
|
|
|
|
|
|
|
|
/* these are located in their respective files */
|
2007-07-17 22:59:06 +00:00
|
|
|
void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
|
2008-04-10 15:01:27 +00:00
|
|
|
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
|
|
|
|
struct device_node *np);
|
|
|
|
void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
|
2007-05-10 04:44:58 +00:00
|
|
|
int cpm_uart_init_portdesc(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
|
|
|
|
void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
|
|
|
|
|
|
|
|
void smc1_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
void smc2_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
void scc1_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
void scc2_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
void scc3_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
void scc4_lineif(struct uart_cpm_port *pinfo);
|
|
|
|
|
2006-04-25 16:26:46 +00:00
|
|
|
/*
|
|
|
|
virtual to phys transtalion
|
|
|
|
*/
|
2007-07-24 20:53:07 +00:00
|
|
|
static inline unsigned long cpu2cpm_addr(void *addr,
|
|
|
|
struct uart_cpm_port *pinfo)
|
2006-04-25 16:26:46 +00:00
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
u32 val = (u32)addr;
|
2007-07-24 20:53:07 +00:00
|
|
|
u32 mem = (u32)pinfo->mem_addr;
|
2006-04-25 16:26:46 +00:00
|
|
|
/* sane check */
|
2007-07-24 20:53:07 +00:00
|
|
|
if (likely(val >= mem && val < mem + pinfo->mem_size)) {
|
|
|
|
offset = val - mem;
|
|
|
|
return pinfo->dma_addr + offset;
|
2006-04-25 16:26:46 +00:00
|
|
|
}
|
2006-04-29 19:06:00 +00:00
|
|
|
/* something nasty happened */
|
|
|
|
BUG();
|
2006-04-25 16:26:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-24 20:53:07 +00:00
|
|
|
static inline void *cpm2cpu_addr(unsigned long addr,
|
|
|
|
struct uart_cpm_port *pinfo)
|
2006-04-25 16:26:46 +00:00
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
u32 val = addr;
|
2007-07-24 20:53:07 +00:00
|
|
|
u32 dma = (u32)pinfo->dma_addr;
|
2006-04-25 16:26:46 +00:00
|
|
|
/* sane check */
|
2007-07-24 20:53:07 +00:00
|
|
|
if (likely(val >= dma && val < dma + pinfo->mem_size)) {
|
|
|
|
offset = val - dma;
|
|
|
|
return pinfo->mem_addr + offset;
|
2006-04-25 16:26:46 +00:00
|
|
|
}
|
2006-04-29 19:06:00 +00:00
|
|
|
/* something nasty happened */
|
|
|
|
BUG();
|
2007-07-24 20:53:07 +00:00
|
|
|
return NULL;
|
2006-04-25 16:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* CPM_UART_H */
|