sh-sci.h
来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 526 行 · 第 1/2 页
H
526 行
/* $Id: sh-sci.h,v 1.4 2004/02/19 16:43:56 lethal Exp $ * * linux/drivers/serial/sh-sci.h * * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO) * Copyright (C) 1999, 2000 Niibe Yutaka * Copyright (C) 2000 Greg Banks * Copyright (C) 2002, 2003 Paul Mundt * Modified to support multiple serial ports. Stuart Menefy (May 2000). * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003). * Modified to support H8/300 Series Yoshinori Sato (Feb 2004). */#include <linux/config.h>#include <linux/serial_core.h>#if defined(__H8300H__) || defined(__H8300S__)#include <asm/gpio.h>#if defined(CONFIG_H83007) || defined(CONFIG_H83068)#include <asm/regs306x.h>#endif#if defined(CONFIG_H8S2678)#include <asm/regs267x.h>#endif#endif/* Offsets into the sci_port->irqs array */#define SCIx_ERI_IRQ 0#define SCIx_RXI_IRQ 1#define SCIx_TXI_IRQ 2/* ERI, RXI, TXI, BRI */#define SCI_IRQS { 23, 24, 25, 0 }#define SH3_SCIF_IRQS { 56, 57, 59, 58 }#define SH3_IRDA_IRQS { 52, 53, 55, 54 }#define SH4_SCIF_IRQS { 40, 41, 43, 42 }#define STB1_SCIF1_IRQS {23, 24, 26, 25 }#define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }#define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }#define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }#define SH7300_SCIF0_IRQS {80, 80, 80, 80 }#define H8300H_SCI_IRQS0 {52, 53, 54, 0 }#define H8300H_SCI_IRQS1 {56, 57, 58, 0 }#define H8300H_SCI_IRQS2 {60, 61, 62, 0 }#define H8S_SCI_IRQS0 {88, 89, 90, 0 }#define H8S_SCI_IRQS1 {92, 93, 94, 0 }#define H8S_SCI_IRQS2 {96, 97, 98, 0 }#define SH5_SCIF_IRQS {39, 40, 42, 0 }#if defined(CONFIG_CPU_SUBTYPE_SH7708)# define SCI_NPORTS 1# define SCSPTR 0xffffff7c /* 8 bit */# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */# define SCI_ONLY#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)# define SCI_NPORTS 3# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */# define SCI_AND_SCIF#elif defined(CONFIG_SH_RTS7751R2D)# define SCI_NPORTS 1# define SCSPTR1 0xffe0001c /* 8 bit SCI */# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */# define SCIF_ORER 0x0001 /* overrun error bit */# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */# define SCIF_ONLY#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)# define SCI_NPORTS 2# define SCSPTR1 0xffe0001c /* 8 bit SCI */# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */# define SCIF_ORER 0x0001 /* overrun error bit */# define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )# define SCI_AND_SCIF#elif defined(CONFIG_CPU_SUBTYPE_SH7760)# define SCI_NPORTS 3# define SCSPTR0 0xfe600000 /* 16 bit SCIF */# define SCSPTR1 0xfe610000 /* 16 bit SCIF */# define SCSPTR2 0xfe620000 /* 16 bit SCIF */# define SCIF_ORER 0x0001 /* overrun error bit */# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */# define SCIF_ONLY#elif defined(CONFIG_CPU_SUBTYPE_SH7300)# define SCI_NPORTS 1# define SCPCR 0xA4050116 /* 16 bit SCIF */# define SCPDR 0xA4050136 /* 16 bit SCIF */# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */# define SCIF_ONLY#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)# define SCI_NPORTS 2# define SCSPTR1 0xffe00020 /* 16 bit SCIF */# define SCSPTR2 0xffe80020 /* 16 bit SCIF */# define SCIF_ORER 0x0001 /* overrun error bit */# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */# define SCIF_ONLY#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)# include <asm/hardware.h># define SCIF_BASE_ADDR 0x01030000# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR# define SCIF_PTR2_OFFS 0x0000020# define SCIF_LSR2_OFFS 0x0000024# define SCI_NPORTS 1# define SCI_INIT { \ { {}, PORT_SCIF, 0, \ SH5_SCIF_IRQS, sci_init_pins_scif } \}# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */# define SCIF_ONLY#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)# define SCI_NPORTS 3# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */# define SCI_ONLY# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)#elif defined(CONFIG_H8S2678)# define SCI_NPORTS 3# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */# define SCI_ONLY# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)#else# error CPU subtype not defined#endif/* SCSCR */#define SCI_CTRL_FLAGS_TIE 0x80 /* all */#define SCI_CTRL_FLAGS_RIE 0x40 /* all */#define SCI_CTRL_FLAGS_TE 0x20 /* all */#define SCI_CTRL_FLAGS_RE 0x10 /* all */#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */#else#define SCI_CTRL_FLAGS_REIE 0#endif/* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI *//* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI *//* SCI_CTRL_FLAGS_CKE1 0x02 * all *//* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI *//* SCxSR SCI */#define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI *//* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI *//* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */#define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)/* SCxSR SCIF */#define SCIF_ER 0x0080 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_TEND 0x0040 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_TDFE 0x0020 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_BRK 0x0010 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_FER 0x0008 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_PER 0x0004 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_RDF 0x0002 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#define SCIF_DR 0x0001 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */#if defined(CONFIG_CPU_SUBTYPE_SH7300)#define SCIF_ORER 0x0200#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)#define SCIF_RFDC_MASK 0x007f#define SCIF_TXROOM_MAX 64#else#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)#define SCIF_RFDC_MASK 0x001f#define SCIF_TXROOM_MAX 16#endif#if defined(SCI_ONLY)# define SCxSR_TEND(port) SCI_TEND# define SCxSR_ERRORS(port) SCI_ERRORS# define SCxSR_RDxF(port) SCI_RDRF# define SCxSR_TDxE(port) SCI_TDRE# define SCxSR_ORER(port) SCI_ORER# define SCxSR_FER(port) SCI_FER# define SCxSR_PER(port) SCI_PER# define SCxSR_BRK(port) 0x00# define SCxSR_RDxF_CLEAR(port) 0xbc# define SCxSR_ERROR_CLEAR(port) 0xc4# define SCxSR_TDxE_CLEAR(port) 0x78# define SCxSR_BREAK_CLEAR(port) 0xc4#elif defined(SCIF_ONLY)# define SCxSR_TEND(port) SCIF_TEND# define SCxSR_ERRORS(port) SCIF_ERRORS# define SCxSR_RDxF(port) SCIF_RDF# define SCxSR_TDxE(port) SCIF_TDFE#if defined(CONFIG_CPU_SUBTYPE_SH7300)# define SCxSR_ORER(port) SCIF_ORER#else# define SCxSR_ORER(port) 0x0000#endif# define SCxSR_FER(port) SCIF_FER# define SCxSR_PER(port) SCIF_PER# define SCxSR_BRK(port) SCIF_BRK#if defined(CONFIG_CPU_SUBTYPE_SH7300)# define SCxSR_RDxF_CLEAR(port) (sci_in(port,SCxSR)&0xfffc)# define SCxSR_ERROR_CLEAR(port) (sci_in(port,SCxSR)&0xfd73)# define SCxSR_TDxE_CLEAR(port) (sci_in(port,SCxSR)&0xffdf)# define SCxSR_BREAK_CLEAR(port) (sci_in(port,SCxSR)&0xffe3)#else# define SCxSR_RDxF_CLEAR(port) 0x00fc# define SCxSR_ERROR_CLEAR(port) 0x0073# define SCxSR_TDxE_CLEAR(port) 0x00df# define SCxSR_BREAK_CLEAR(port) 0x00e3#endif#else# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)# define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)# define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)# define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)# define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : 0x0000)# define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)# define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)# define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)# define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)#endif/* SCFCR */#define SCFCR_RFRST 0x0002#define SCFCR_TFRST 0x0004#define SCFCR_TCRST 0x4000#define SCFCR_MCE 0x0008#define SCI_MAJOR 204#define SCI_MINOR_START 8/* Generic serial flags */#define SCI_RX_THROTTLE 0x0000001#define SCI_MAGIC 0xbabeface/* * Events are used to schedule things to happen at timer-interrupt * time, instead of at rs interrupt time. */#define SCI_EVENT_WRITE_WAKEUP 0struct sci_port { struct uart_port port; int type; unsigned char irqs[4]; /* ERI, RXI, TXI, BRI */ void (*init_pins)(struct uart_port *port, unsigned int cflag); int break_flag; struct timer_list break_timer;};#define SCI_IN(size, offset) \ unsigned int addr = port->mapbase + (offset); \ if ((size) == 8) { \ return ctrl_inb(addr); \ } else { \ return ctrl_inw(addr); \ }#define SCI_OUT(size, offset, value) \
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?