r8a66597.h

来自「linux 内核源代码」· C头文件 代码 · 共 632 行 · 第 1/2 页

H
632
字号
/* Default Control Pipe Maxpacket Size Register *//* Pipe Maxpacket Size Register */#define	DEVSEL	0xF000	/* b15-14: Device address select */#define	MAXP	0x007F	/* b6-0: Maxpacket size of default control pipe *//* Default Control Pipe Control Register */#define	BSTS		0x8000	/* b15: Buffer status */#define	SUREQ		0x4000	/* b14: Send USB request  */#define	CSCLR		0x2000	/* b13: complete-split status clear */#define	CSSTS		0x1000	/* b12: complete-split status */#define	SUREQCLR	0x0800	/* b11: stop setup request */#define	SQCLR		0x0100	/* b8: Sequence toggle bit clear */#define	SQSET		0x0080	/* b7: Sequence toggle bit set */#define	SQMON		0x0040	/* b6: Sequence toggle bit monitor */#define	PBUSY		0x0020	/* b5: pipe busy */#define	PINGE		0x0010	/* b4: ping enable */#define	CCPL		0x0004	/* b2: Enable control transfer complete */#define	PID		0x0003	/* b1-0: Response PID */#define	  PID_STALL11	 0x0003	  /* STALL */#define	  PID_STALL	 0x0002	  /* STALL */#define	  PID_BUF	 0x0001	  /* BUF */#define	  PID_NAK	 0x0000	  /* NAK *//* Pipe Window Select Register */#define	PIPENM		0x0007	/* b2-0: Pipe select *//* Pipe Configuration Register */#define	R8A66597_TYP	0xC000	/* b15-14: Transfer type */#define	  R8A66597_ISO	 0xC000		  /* Isochronous */#define	  R8A66597_INT	 0x8000		  /* Interrupt */#define	  R8A66597_BULK	 0x4000		  /* Bulk */#define	R8A66597_BFRE	0x0400	/* b10: Buffer ready interrupt mode select */#define	R8A66597_DBLB	0x0200	/* b9: Double buffer mode select */#define	R8A66597_CNTMD	0x0100	/* b8: Continuous transfer mode select */#define	R8A66597_SHTNAK	0x0080	/* b7: Transfer end NAK */#define	R8A66597_DIR	0x0010	/* b4: Transfer direction select */#define	R8A66597_EPNUM	0x000F	/* b3-0: Eendpoint number select *//* Pipe Buffer Configuration Register */#define	BUFSIZE		0x7C00	/* b14-10: Pipe buffer size */#define	BUFNMB		0x007F	/* b6-0: Pipe buffer number */#define	PIPE0BUF	256#define	PIPExBUF	64/* Pipe Maxpacket Size Register */#define	MXPS		0x07FF	/* b10-0: Maxpacket size *//* Pipe Cycle Configuration Register */#define	IFIS	0x1000	/* b12: Isochronous in-buffer flush mode select */#define	IITV	0x0007	/* b2-0: Isochronous interval *//* Pipex Control Register */#define	BSTS	0x8000	/* b15: Buffer status */#define	INBUFM	0x4000	/* b14: IN buffer monitor (Only for PIPE1 to 5) */#define	CSCLR	0x2000	/* b13: complete-split status clear */#define	CSSTS	0x1000	/* b12: complete-split status */#define	ATREPM	0x0400	/* b10: Auto repeat mode */#define	ACLRM	0x0200	/* b9: Out buffer auto clear mode */#define	SQCLR	0x0100	/* b8: Sequence toggle bit clear */#define	SQSET	0x0080	/* b7: Sequence toggle bit set */#define	SQMON	0x0040	/* b6: Sequence toggle bit monitor */#define	PBUSY	0x0020	/* b5: pipe busy */#define	PID	0x0003	/* b1-0: Response PID *//* PIPExTRE */#define	TRENB		0x0200	/* b9: Transaction counter enable */#define	TRCLR		0x0100	/* b8: Transaction counter clear *//* PIPExTRN */#define	TRNCNT		0xFFFF	/* b15-0: Transaction counter *//* DEVADDx */#define	UPPHUB		0x7800#define	HUBPORT		0x0700#define	USBSPD		0x00C0#define	RTPORT		0x0001#define R8A66597_MAX_NUM_PIPE		10#define R8A66597_BUF_BSIZE		8#define R8A66597_MAX_DEVICE		10#define R8A66597_MAX_ROOT_HUB		2#define R8A66597_MAX_SAMPLING		10#define R8A66597_MAX_DMA_CHANNEL	2#define R8A66597_PIPE_NO_DMA		R8A66597_MAX_DMA_CHANNEL#define check_bulk_or_isoc(pipenum)	((pipenum >= 1 && pipenum <= 5))#define check_interrupt(pipenum)	((pipenum >= 6 && pipenum <= 9))#define make_devsel(addr)		(addr << 12)struct r8a66597_pipe_info {	u16 pipenum;	u16 address;	/* R8A66597 HCD usb addres */	u16 epnum;	u16 maxpacket;	u16 type;	u16 bufnum;	u16 buf_bsize;	u16 interval;	u16 dir_in;};struct r8a66597_pipe {	struct r8a66597_pipe_info info;	unsigned long fifoaddr;	unsigned long fifosel;	unsigned long fifoctr;	unsigned long pipectr;	unsigned long pipetre;	unsigned long pipetrn;};struct r8a66597_td {	struct r8a66597_pipe *pipe;	struct urb *urb;	struct list_head queue;	u16 type;	u16 pipenum;	int iso_cnt;	u16 address;		/* R8A66597's USB address */	u16 maxpacket;	unsigned zero_packet:1;	unsigned short_packet:1;	unsigned set_address:1;};struct r8a66597_device {	u16	address;	/* R8A66597's USB address */	u16	hub_port;	u16	root_port;	unsigned short ep_in_toggle;	unsigned short ep_out_toggle;	unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];	unsigned char dma_map;	enum usb_device_state state;	struct usb_device *udev;	int usb_address;	struct list_head device_list;};struct r8a66597_root_hub {	u32 port;	u16 old_syssts;	int scount;	struct r8a66597_device	*dev;};struct r8a66597 {	spinlock_t lock;	unsigned long reg;	struct r8a66597_device		device0;	struct r8a66597_root_hub	root_hub[R8A66597_MAX_ROOT_HUB];	struct list_head		pipe_queue[R8A66597_MAX_NUM_PIPE];	struct timer_list rh_timer;	struct timer_list td_timer[R8A66597_MAX_NUM_PIPE];	unsigned short address_map;	unsigned short timeout_map;	unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];	unsigned char dma_map;	struct list_head child_device;	unsigned long child_connect_map[4];};static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd){	return (struct r8a66597 *)(hcd->hcd_priv);}static inline struct usb_hcd *r8a66597_to_hcd(struct r8a66597 *r8a66597){	return container_of((void *)r8a66597, struct usb_hcd, hcd_priv);}static inline struct r8a66597_td *r8a66597_get_td(struct r8a66597 *r8a66597,						  u16 pipenum){	if (unlikely(list_empty(&r8a66597->pipe_queue[pipenum])))		return NULL;	return list_entry(r8a66597->pipe_queue[pipenum].next,			  struct r8a66597_td, queue);}static inline struct urb *r8a66597_get_urb(struct r8a66597 *r8a66597,					   u16 pipenum){	struct r8a66597_td *td;	td = r8a66597_get_td(r8a66597, pipenum);	return (td ? td->urb : NULL);}static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset){	return inw(r8a66597->reg + offset);}static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,				      unsigned long offset, u16 *buf,				      int len){	len = (len + 1) / 2;	insw(r8a66597->reg + offset, buf, len);}static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,				  unsigned long offset){	outw(val, r8a66597->reg + offset);}static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,				       unsigned long offset, u16 *buf,				       int len){	unsigned long fifoaddr = r8a66597->reg + offset;	int odd = len & 0x0001;	len = len / 2;	outsw(fifoaddr, buf, len);	if (unlikely(odd)) {		buf = &buf[len];		outb((unsigned char)*buf, fifoaddr);	}}static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,				 u16 val, u16 pat, unsigned long offset){	u16 tmp;	tmp = r8a66597_read(r8a66597, offset);	tmp = tmp & (~pat);	tmp = tmp | val;	r8a66597_write(r8a66597, tmp, offset);}#define r8a66597_bclr(r8a66597, val, offset)	\			r8a66597_mdfy(r8a66597, 0, val, offset)#define r8a66597_bset(r8a66597, val, offset)	\			r8a66597_mdfy(r8a66597, val, 0, offset)static inline unsigned long get_syscfg_reg(int port){	return port == 0 ? SYSCFG0 : SYSCFG1;}static inline unsigned long get_syssts_reg(int port){	return port == 0 ? SYSSTS0 : SYSSTS1;}static inline unsigned long get_dvstctr_reg(int port){	return port == 0 ? DVSTCTR0 : DVSTCTR1;}static inline unsigned long get_intenb_reg(int port){	return port == 0 ? INTENB1 : INTENB2;}static inline unsigned long get_intsts_reg(int port){	return port == 0 ? INTSTS1 : INTSTS2;}static inline u16 get_rh_usb_speed(struct r8a66597 *r8a66597, int port){	unsigned long dvstctr_reg = get_dvstctr_reg(port);	return r8a66597_read(r8a66597, dvstctr_reg) & RHST;}static inline void r8a66597_port_power(struct r8a66597 *r8a66597, int port,				       int power){	unsigned long dvstctr_reg = get_dvstctr_reg(port);	if (power)		r8a66597_bset(r8a66597, VBOUT, dvstctr_reg);	else		r8a66597_bclr(r8a66597, VBOUT, dvstctr_reg);}#define get_pipectr_addr(pipenum)	(PIPE1CTR + (pipenum - 1) * 2)#define get_pipetre_addr(pipenum)	(PIPE1TRE + (pipenum - 1) * 4)#define get_pipetrn_addr(pipenum)	(PIPE1TRN + (pipenum - 1) * 4)#define get_devadd_addr(address)	(DEVADD0 + address * 2)#define enable_irq_ready(r8a66597, pipenum)	\	enable_pipe_irq(r8a66597, pipenum, BRDYENB)#define disable_irq_ready(r8a66597, pipenum)	\	disable_pipe_irq(r8a66597, pipenum, BRDYENB)#define enable_irq_empty(r8a66597, pipenum)	\	enable_pipe_irq(r8a66597, pipenum, BEMPENB)#define disable_irq_empty(r8a66597, pipenum)	\	disable_pipe_irq(r8a66597, pipenum, BEMPENB)#define enable_irq_nrdy(r8a66597, pipenum)	\	enable_pipe_irq(r8a66597, pipenum, NRDYENB)#define disable_irq_nrdy(r8a66597, pipenum)	\	disable_pipe_irq(r8a66597, pipenum, NRDYENB)#endif	/* __R8A66597_H__ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?