?? net2280.h
字號:
struct net2280_ep { struct usb_ep ep; struct net2280_ep_regs *regs; struct net2280_dma_regs *dma; struct net2280_dma *dummy; dma_addr_t td_dma; /* of dummy */ struct net2280 *dev; unsigned long irqs; /* analogous to a host-side qh */ struct list_head queue; const struct usb_endpoint_descriptor *desc; unsigned num : 8, fifo_size : 12, in_fifo_validate : 1, out_overflow : 1, stopped : 1, is_in : 1, is_iso : 1;};static inline void allow_status (struct net2280_ep *ep){ /* ep0 only */ writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) | (1 << CLEAR_NAK_OUT_PACKETS) | (1 << CLEAR_NAK_OUT_PACKETS_MODE) , &ep->regs->ep_rsp); ep->stopped = 1;}/* count (<= 4) bytes in the next fifo write will be valid */static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count){ writeb (count, 2 + (u8 *) &ep->regs->ep_cfg);}struct net2280_request { struct usb_request req; struct net2280_dma *td; dma_addr_t td_dma; struct list_head queue; unsigned mapped : 1, valid : 1;};struct net2280 { /* each pci device provides one gadget, several endpoints */ struct usb_gadget gadget; spinlock_t lock; struct net2280_ep ep [7]; struct usb_gadget_driver *driver; unsigned enabled : 1, protocol_stall : 1, softconnect : 1, got_irq : 1, region : 1; u16 chiprev; /* pci state used to access those endpoints */ struct pci_dev *pdev; struct net2280_regs *regs; struct net2280_usb_regs *usb; struct net2280_pci_regs *pci; struct net2280_dma_regs *dma; struct net2280_dep_regs *dep; struct net2280_ep_regs *epregs; struct pci_pool *requests; // statistics...};static inline void set_halt (struct net2280_ep *ep){ /* ep0 and bulk/intr endpoints */ writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) /* set NAK_OUT for erratum 0114 */ | ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS) | (1 << SET_ENDPOINT_HALT) , &ep->regs->ep_rsp);}static inline void clear_halt (struct net2280_ep *ep){ /* ep0 and bulk/intr endpoints */ writel ( (1 << CLEAR_ENDPOINT_HALT) | (1 << CLEAR_ENDPOINT_TOGGLE) /* unless the gadget driver left a short packet in the * fifo, this reverses the erratum 0114 workaround. */ | ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS) , &ep->regs->ep_rsp);}#ifdef USE_RDK_LEDSstatic inline void net2280_led_init (struct net2280 *dev){ /* LED3 (green) is on during USB activity. note erratum 0113. */ writel ((1 << GPIO3_LED_SELECT) | (1 << GPIO3_OUTPUT_ENABLE) | (1 << GPIO2_OUTPUT_ENABLE) | (1 << GPIO1_OUTPUT_ENABLE) | (1 << GPIO0_OUTPUT_ENABLE) , &dev->regs->gpioctl);}/* indicate speed with bi-color LED 0/1 */static inlinevoid net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed){ u32 val = readl (&dev->regs->gpioctl); switch (speed) { case USB_SPEED_HIGH: /* green */ val &= ~(1 << GPIO0_DATA); val |= (1 << GPIO1_DATA); break; case USB_SPEED_FULL: /* red */ val &= ~(1 << GPIO1_DATA); val |= (1 << GPIO0_DATA); break; default: /* (off/black) */ val &= ~((1 << GPIO1_DATA) | (1 << GPIO0_DATA)); break; } writel (val, &dev->regs->gpioctl);}/* indicate power with LED 2 */static inline void net2280_led_active (struct net2280 *dev, int is_active){ u32 val = readl (&dev->regs->gpioctl); // FIXME this LED never seems to turn on. if (is_active) val |= GPIO2_DATA; else val &= ~GPIO2_DATA; writel (val, &dev->regs->gpioctl);}static inline void net2280_led_shutdown (struct net2280 *dev){ /* turn off all four GPIO*_DATA bits */ writel (readl (&dev->regs->gpioctl) & ~0x0f, &dev->regs->gpioctl);}#else#define net2280_led_init(dev) do { } while (0)#define net2280_led_speed(dev, speed) do { } while (0)#define net2280_led_shutdown(dev) do { } while (0)#endif/*-------------------------------------------------------------------------*/#define xprintk(dev,level,fmt,args...) \ printk(level "%s %s: " fmt , driver_name , \ dev->pdev->slot_name , ## args)#ifdef DEBUG#undef DEBUG#define DEBUG(dev,fmt,args...) \ xprintk(dev , KERN_DEBUG , fmt , ## args)#else#define DEBUG(dev,fmt,args...) \ do { } while (0)#endif /* DEBUG */#ifdef VERBOSE#define VDEBUG DEBUG#else#define VDEBUG(dev,fmt,args...) \ do { } while (0)#endif /* VERBOSE */#define ERROR(dev,fmt,args...) \ xprintk(dev , KERN_ERR , fmt , ## args)#define WARN(dev,fmt,args...) \ xprintk(dev , KERN_WARNING , fmt , ## args)#define INFO(dev,fmt,args...) \ xprintk(dev , KERN_INFO , fmt , ## args)/*-------------------------------------------------------------------------*/static inline void start_out_naking (struct net2280_ep *ep){ /* NOTE: hardware races lurk here, and PING protocol issues */ writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); /* synch with device */ readl (&ep->regs->ep_rsp);}#ifdef DEBUGstatic inline void assert_out_naking (struct net2280_ep *ep, const char *where){ u32 tmp = readl (&ep->regs->ep_stat); if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { DEBUG (ep->dev, "%s %s %08x !NAK\n", ep->ep.name, where, tmp); writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); }}#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__FUNCTION__)#else#define ASSERT_OUT_NAKING(ep) do {} while (0)#endifstatic inline void stop_out_naking (struct net2280_ep *ep){ u32 tmp; tmp = readl (&ep->regs->ep_stat); if ((tmp & (1 << NAK_OUT_PACKETS)) != 0) writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);}/*-------------------------------------------------------------------------*//* 2.5 and 2.4.older portability changes ... */#ifndef container_of#define container_of list_entry#endif#ifndef likely#define likely(x) (x)#define unlikely(x) (x)#endif#ifndef BUG_ON#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)#endif#ifndef WARN_ON#define WARN_ON(x) do { } while (0)#endif#ifndef IRQ_NONEtypedef void irqreturn_t;#define IRQ_NONE#define IRQ_HANDLED#define IRQ_RETVAL(x)#endif#endif /* __KERNEL__ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -