📄 isp1362.h
字号:
{ return (struct isp1362 *)(hcd->hcd_priv);}static inline struct usb_hcd *isp1362_to_hcd(struct isp1362 *isp1362){/// return container_of((void *)isp1362, struct usb_hcd, hcd_priv);}struct isp1362_ep { struct usb_host_endpoint *hep; struct usb_device *udev; 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 isp1362_ep *active; /* periodic schedule */ u16 period; u16 branch; u16 load; struct isp1362_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 isp1362_delay(h,d) do{\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ asm("ssync;");\ }while(0)#define isp1362_check_platform_delay(h) ((h)->board->delay == NULL)#elif defined(USE_NDELAY)#define isp1362_delay(h,d) ndelay(d)#define isp1362_check_platform_delay(h) 0#else#define isp1362_delay(h,d) do{}while(0)#define isp1362_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 isp1362_write_addr(struct isp1362 *isp1362, unsigned reg){ IRQ_TEST(); writew(reg & 0xff, isp1362->addr_reg); isp1362_delay(isp1362, 300);}static inline void isp1362_write_data16(struct isp1362 *isp1362, u16 val){ writew(val, isp1362->data_reg); isp1362_delay(isp1362, 150);}static inline void isp1362_raw_write_data16(struct isp1362 *isp1362, u16 val){ __raw_writew(val, isp1362->data_reg); isp1362_delay(isp1362, 150);}static inline u16 isp1362_read_data16(struct isp1362 *isp1362){ u16 val; val = readw(isp1362->data_reg); isp1362_delay(isp1362, 150); return val;}static inline u16 isp1362_raw_read_data16(struct isp1362 *isp1362){ u16 val; val = __raw_readw(isp1362->data_reg); isp1362_delay(isp1362, 150); return val;}static inline void isp1362_write_data32(struct isp1362 *isp1362, u32 val){ writew(val & 0xffff, isp1362->data_reg); isp1362_delay(isp1362, 150); writew(val >> 16, isp1362->data_reg); isp1362_delay(isp1362, 150);}static inline u32 isp1362_read_data32(struct isp1362 *isp1362){ u32 val; val = (u32) readw(isp1362->data_reg); isp1362_delay(isp1362, 150); val |= ((u32) readw(isp1362->data_reg)) << 16; isp1362_delay(isp1362, 150); return val;}/* Let's keep register access functions out of line. Hint: we wait at least 150 ns at every access.*/static u16 isp1362_read_reg16(struct isp1362 *isp1362, unsigned reg){ isp1362_write_addr(isp1362, reg); return isp1362_read_data16(isp1362);}static u32 isp1362_read_reg32(struct isp1362 *isp1362, unsigned reg){ isp1362_write_addr(isp1362, reg); return isp1362_read_data32(isp1362);}static void isp1362_write_reg16(struct isp1362 *isp1362, unsigned reg, unsigned val){ isp1362_write_addr(isp1362, reg | ISP116x_WRITE_OFFSET); isp1362_write_data16(isp1362, (u16) (val & 0xffff));}static void isp1362_write_reg32(struct isp1362 *isp1362, unsigned reg, unsigned val){ isp1362_write_addr(isp1362, reg | ISP116x_WRITE_OFFSET); isp1362_write_data32(isp1362, (u32) val);}#define isp1362_show_reg(d,r) { \ if ((r) < 0x20) { \ DBG("%-12s[%02x]: %08x\n", #r, \ r, isp1362_read_reg32(d, r)); \ } else { \ DBG("%-12s[%02x]: %04x\n", #r, \ r, isp1362_read_reg16(d, r)); \ } \}static inline void isp1362_show_regs(struct isp1362 *isp1362){ isp1362_show_reg(isp1362, HCREVISION); isp1362_show_reg(isp1362, HCCONTROL); isp1362_show_reg(isp1362, HCCMDSTAT); isp1362_show_reg(isp1362, HCINTSTAT); isp1362_show_reg(isp1362, HCINTENB); isp1362_show_reg(isp1362, HCFMINTVL); isp1362_show_reg(isp1362, HCFMREM); isp1362_show_reg(isp1362, HCFMNUM); isp1362_show_reg(isp1362, HCLSTHRESH); isp1362_show_reg(isp1362, HCRHDESCA); isp1362_show_reg(isp1362, HCRHDESCB); isp1362_show_reg(isp1362, HCRHSTATUS); isp1362_show_reg(isp1362, HCRHPORT1); isp1362_show_reg(isp1362, HCRHPORT2); isp1362_show_reg(isp1362, HCHWCFG); isp1362_show_reg(isp1362, HCDMACFG); isp1362_show_reg(isp1362, HCXFERCTR); isp1362_show_reg(isp1362, HCuPINT); isp1362_show_reg(isp1362, HCuPINTENB); isp1362_show_reg(isp1362, HCCHIPID); isp1362_show_reg(isp1362, HCSCRATCH); isp1362_show_reg(isp1362, HCITLBUFLEN); isp1362_show_reg(isp1362, HCATLBUFLEN); isp1362_show_reg(isp1362, HCBUFSTAT); isp1362_show_reg(isp1362, HCRDITL0LEN); isp1362_show_reg(isp1362, HCRDITL1LEN);}#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 + -