📄 isp116x.h
字号:
struct ptd ptd; u8 maxpacket; u8 epnum; u8 nextpid; u16 error_count; u16 length; /* of current packet */ unsigned char *data; /* to databuf */ /* queue of active EP's (the ones scheduled for the current frame) */ struct isp116x_ep *active; /* periodic schedule */ u16 period; u16 branch; u16 load; struct isp116x_ep *next; /* async schedule */ struct list_head schedule;};/*-------------------------------------------------------------------------*/#ifdef DEBUG#define DBG(stuff...) printk(KERN_DEBUG "116x: " stuff)#else#define DBG(stuff...) do{}while(0)#endif#ifdef VERBOSE# define VDBG DBG#else# define VDBG(stuff...) do{}while(0)#endif#define ERR(stuff...) printk(KERN_ERR "116x: " stuff)#define WARN(stuff...) printk(KERN_WARNING "116x: " stuff)#define INFO(stuff...) printk(KERN_INFO "116x: " stuff)/* ------------------------------------------------- */#if defined(USE_PLATFORM_DELAY)#if defined(USE_NDELAY)#error USE_PLATFORM_DELAY and USE_NDELAY simultaneously defined.#endif#define isp116x_delay(h,d) (h)->board->delay( \ isp116x_to_hcd(h)->self.controller,d)#define isp116x_check_platform_delay(h) ((h)->board->delay == NULL)#elif defined(USE_NDELAY)#define isp116x_delay(h,d) ndelay(d)#define isp116x_check_platform_delay(h) 0#else#define isp116x_delay(h,d) do{}while(0)#define isp116x_check_platform_delay(h) 0#endif#if defined(DEBUG)#define IRQ_TEST() BUG_ON(!irqs_disabled())#else#define IRQ_TEST() do{}while(0)#endifstatic inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg){ IRQ_TEST(); writew(reg & 0xff, isp116x->addr_reg); isp116x_delay(isp116x, 300);}static inline void isp116x_write_data16(struct isp116x *isp116x, u16 val){ writew(val, isp116x->data_reg); isp116x_delay(isp116x, 150);}static inline void isp116x_raw_write_data16(struct isp116x *isp116x, u16 val){ __raw_writew(val, isp116x->data_reg); isp116x_delay(isp116x, 150);}static inline u16 isp116x_read_data16(struct isp116x *isp116x){ u16 val; val = readw(isp116x->data_reg); isp116x_delay(isp116x, 150); return val;}static inline u16 isp116x_raw_read_data16(struct isp116x *isp116x){ u16 val; val = __raw_readw(isp116x->data_reg); isp116x_delay(isp116x, 150); return val;}static inline void isp116x_write_data32(struct isp116x *isp116x, u32 val){ writew(val & 0xffff, isp116x->data_reg); isp116x_delay(isp116x, 150); writew(val >> 16, isp116x->data_reg); isp116x_delay(isp116x, 150);}static inline u32 isp116x_read_data32(struct isp116x *isp116x){ u32 val; val = (u32) readw(isp116x->data_reg); isp116x_delay(isp116x, 150); val |= ((u32) readw(isp116x->data_reg)) << 16; isp116x_delay(isp116x, 150); return val;}/* Let's keep register access functions out of line. Hint: we wait at least 150 ns at every access.*/static u16 isp116x_read_reg16(struct isp116x *isp116x, unsigned reg){ isp116x_write_addr(isp116x, reg); return isp116x_read_data16(isp116x);}static u32 isp116x_read_reg32(struct isp116x *isp116x, unsigned reg){ isp116x_write_addr(isp116x, reg); return isp116x_read_data32(isp116x);}static void isp116x_write_reg16(struct isp116x *isp116x, unsigned reg, unsigned val){ isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET); isp116x_write_data16(isp116x, (u16) (val & 0xffff));}static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg, unsigned val){ isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET); isp116x_write_data32(isp116x, (u32) val);}#define isp116x_show_reg_log(d,r,s) { \ if ((r) < 0x20) { \ DBG("%-12s[%02x]: %08x\n", #r, \ r, isp116x_read_reg32(d, r)); \ } else { \ DBG("%-12s[%02x]: %04x\n", #r, \ r, isp116x_read_reg16(d, r)); \ } \}#define isp116x_show_reg_seq(d,r,s) { \ if ((r) < 0x20) { \ seq_printf(s, "%-12s[%02x]: %08x\n", #r, \ r, isp116x_read_reg32(d, r)); \ } else { \ seq_printf(s, "%-12s[%02x]: %04x\n", #r, \ r, isp116x_read_reg16(d, r)); \ } \}#define isp116x_show_regs(d,type,s) { \ isp116x_show_reg_##type(d, HCREVISION, s); \ isp116x_show_reg_##type(d, HCCONTROL, s); \ isp116x_show_reg_##type(d, HCCMDSTAT, s); \ isp116x_show_reg_##type(d, HCINTSTAT, s); \ isp116x_show_reg_##type(d, HCINTENB, s); \ isp116x_show_reg_##type(d, HCFMINTVL, s); \ isp116x_show_reg_##type(d, HCFMREM, s); \ isp116x_show_reg_##type(d, HCFMNUM, s); \ isp116x_show_reg_##type(d, HCLSTHRESH, s); \ isp116x_show_reg_##type(d, HCRHDESCA, s); \ isp116x_show_reg_##type(d, HCRHDESCB, s); \ isp116x_show_reg_##type(d, HCRHSTATUS, s); \ isp116x_show_reg_##type(d, HCRHPORT1, s); \ isp116x_show_reg_##type(d, HCRHPORT2, s); \ isp116x_show_reg_##type(d, HCHWCFG, s); \ isp116x_show_reg_##type(d, HCDMACFG, s); \ isp116x_show_reg_##type(d, HCXFERCTR, s); \ isp116x_show_reg_##type(d, HCuPINT, s); \ isp116x_show_reg_##type(d, HCuPINTENB, s); \ isp116x_show_reg_##type(d, HCCHIPID, s); \ isp116x_show_reg_##type(d, HCSCRATCH, s); \ isp116x_show_reg_##type(d, HCITLBUFLEN, s); \ isp116x_show_reg_##type(d, HCATLBUFLEN, s); \ isp116x_show_reg_##type(d, HCBUFSTAT, s); \ isp116x_show_reg_##type(d, HCRDITL0LEN, s); \ isp116x_show_reg_##type(d, HCRDITL1LEN, s); \}/* Dump registers for debugfs.*/static inline void isp116x_show_regs_seq(struct isp116x *isp116x, struct seq_file *s){ isp116x_show_regs(isp116x, seq, s);}/* Dump registers to syslog.*/static inline void isp116x_show_regs_log(struct isp116x *isp116x){ isp116x_show_regs(isp116x, log, NULL);}#if defined(URB_TRACE)#define PIPETYPE(pipe) ({ char *__s; \ if (usb_pipecontrol(pipe)) __s = "ctrl"; \ else if (usb_pipeint(pipe)) __s = "int"; \ else if (usb_pipebulk(pipe)) __s = "bulk"; \ else __s = "iso"; \ __s;})#define PIPEDIR(pipe) ({ usb_pipein(pipe) ? "in" : "out"; })#define URB_NOTSHORT(urb) ({ (urb)->transfer_flags & URB_SHORT_NOT_OK ? \ "short_not_ok" : ""; })/* print debug info about the URB */static void urb_dbg(struct urb *urb, char *msg){ unsigned int pipe; if (!urb) { DBG("%s: zero urb\n", msg); return; } pipe = urb->pipe; DBG("%s: FA %d ep%d%s %s: len %d/%d %s\n", msg, usb_pipedevice(pipe), usb_pipeendpoint(pipe), PIPEDIR(pipe), PIPETYPE(pipe), urb->transfer_buffer_length, urb->actual_length, URB_NOTSHORT(urb));}#else#define urb_dbg(urb,msg) do{}while(0)#endif /* ! defined(URB_TRACE) */#if defined(PTD_TRACE)#define PTD_DIR_STR(ptd) ({char __c; \ switch(PTD_GET_DIR(ptd)){ \ case 0: __c = 's'; break; \ case 1: __c = 'o'; break; \ default: __c = 'i'; break; \ }; __c;})/* Dump PTD info. The code documents the format perfectly, right :)*/static inline void dump_ptd(struct ptd *ptd){ printk("td: %x %d%c%d %d,%d,%d %x %x%x%x\n", PTD_GET_CC(ptd), PTD_GET_FA(ptd), PTD_DIR_STR(ptd), PTD_GET_EP(ptd), PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd), PTD_GET_TOGGLE(ptd), PTD_GET_ACTIVE(ptd), PTD_GET_SPD(ptd), PTD_GET_LAST(ptd));}static inline void dump_ptd_out_data(struct ptd *ptd, u8 * buf){ int k; if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) { printk("-> "); for (k = 0; k < PTD_GET_LEN(ptd); ++k) printk("%02x ", ((u8 *) buf)[k]); printk("\n"); }}static inline void dump_ptd_in_data(struct ptd *ptd, u8 * buf){ int k; if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) { printk("<- "); for (k = 0; k < PTD_GET_COUNT(ptd); ++k) printk("%02x ", ((u8 *) buf)[k]); printk("\n"); } if (PTD_GET_LAST(ptd)) printk("-\n");}#else#define dump_ptd(ptd) do{}while(0)#define dump_ptd_in_data(ptd,buf) do{}while(0)#define dump_ptd_out_data(ptd,buf) do{}while(0)#endif /* ! defined(PTD_TRACE) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -