diff options
Diffstat (limited to 'uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h')
-rw-r--r-- | uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h | 137 |
1 files changed, 136 insertions, 1 deletions
diff --git a/uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h b/uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h index 0f3329e..94b81ed 100644 --- a/uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h +++ b/uClinux-2.4.20-uc1/drivers/usb/usb-ohci.h @@ -6,8 +6,35 @@ * * usb-ohci.h */ - +/*define for no pci bus*/ +/* This defines the direction arg to the DMA mapping routines. */ +#define PCI_DMA_BIDIRECTIONAL 0 +#define PCI_DMA_TODEVICE 1 +#define PCI_DMA_FROMDEVICE 2 +#define PCI_DMA_NONE 3 + +#define PCI_ANY_ID (~0) +#define PCI_CLASS_SERIAL_USB 0x0c03 + +struct pci_device_id { + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */ + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */ + unsigned long driver_data; /* Data private to the driver */ +}; + +struct pci_driver { + struct list_head node; + char *name; + const struct pci_device_id *id_table; /* NULL if wants all devices */ + int (*probe) (const struct pci_device_id *id); /* New device inserted */ + void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ +}; + +/*-------------------end data struct from pci.h----------------------------------*/ + + static int cc_to_error[16] = { /* mapping of the OHCI CC status to error codes */ @@ -369,6 +396,16 @@ struct hash_list_t { * Note how the "proper" USB information is just * a subset of what the full implementation needs. (Linus) */ +struct ohci_pool { /* the pool */ + struct list_head page_list; + spinlock_t lock; + size_t blocks_per_page; + size_t size; + int flags; + size_t allocation; + char name [32]; + wait_queue_head_t waitq; +}; typedef struct ohci { @@ -402,11 +439,18 @@ typedef struct ohci { struct usb_device * dev[128]; struct virt_root_hub rh; +#ifndef CONFIG_BOARD_W90N745 /* PCI device handle, settings, ... */ struct pci_dev *ohci_dev; +#endif u8 pci_latency; +#ifndef CONFIG_BOARD_W90N745 struct pci_pool *td_cache; struct pci_pool *dev_cache; +#else + struct ohci_pool *td_cache; + struct ohci_pool *dev_cache; +#endif struct hash_list_t td_hash[TD_HASH_SIZE]; struct hash_list_t ed_hash[ED_HASH_SIZE]; @@ -424,6 +468,45 @@ struct ohci_device { // #define ohci_to_usb(ohci) ((ohci)->usb) #define usb_to_ohci(usb) ((struct ohci_device *)(usb)->hcpriv) +#ifdef CONFIG_BOARD_W90N745 +#define POOL_TIMEOUT_JIFFIES ((100 /* msec */ * HZ) / 1000) +#define POOL_POISON_BYTE 0xa7 + +struct pci_page { /* cacheable header for 'allocation' bytes */ + struct list_head page_list; + void *vaddr; + dma_addr_t dma; + unsigned long bitmap [0]; +}; + + +void *ohci_alloc_consistent(size_t size, dma_addr_t *handle); +void ohci_free_consistent(size_t size, void *vaddr, + dma_addr_t dma_handle); +inline dma_addr_t +ohci_map_single(void *ptr, size_t size, int direction); +inline void +ohci_unmap_single(dma_addr_t dma_addr, size_t size, int direction); + +struct ohci_pool * +ohci_pool_create (const char *name, + size_t size, size_t align, size_t allocation, int flags); +void ohci_pool_destroy (struct ohci_pool *pool); +void * +ohci_pool_alloc (struct ohci_pool *pool, int mem_flags, dma_addr_t *handle); +void +ohci_pool_free (struct ohci_pool *pool, void *vaddr, dma_addr_t dma); +static struct pci_page * +pool_alloc_page (struct ohci_pool *pool, int mem_flags); +static struct pci_page * +pool_alloc_page (struct ohci_pool *pool, int mem_flags); +static struct pci_page * +pool_find_page (struct ohci_pool *pool, dma_addr_t dma); +static inline int +is_page_busy (int blocks, unsigned long *bitmap); +static void +pool_free_page (struct ohci_pool *pool, struct pci_page *page); + /* hcd */ /* endpoint */ static int ep_link(ohci_t * ohci, ed_t * ed); @@ -438,6 +521,20 @@ static int rh_submit_urb(struct urb * urb); static int rh_unlink_urb(struct urb * urb); static int rh_init_int_timer(struct urb * urb); +/* hcd */ +/* endpoint */ +static int ep_link(ohci_t * ohci, ed_t * ed); +static int ep_unlink(ohci_t * ohci, ed_t * ed); +static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned int pipe, int interval, int load, int mem_flags); +static void ep_rm_ed(struct usb_device * usb_dev, ed_t * ed); +/* td */ +static void td_fill(ohci_t * ohci, unsigned int info, dma_addr_t data, int len, struct urb * urb, int index); +static void td_submit_urb(struct urb * urb); +/* root hub */ +static int rh_submit_urb(struct urb * urb); +static int rh_unlink_urb(struct urb * urb); +static int rh_init_int_timer(struct urb * urb); +#endif /*-------------------------------------------------------------------------*/ #define ALLOC_FLAGS (in_interrupt () || current->state != TASK_RUNNING ? GFP_ATOMIC : GFP_KERNEL) @@ -448,10 +545,12 @@ static int rh_init_int_timer(struct urb * urb); # define OHCI_MEM_FLAGS 0 #endif +#ifndef CONFIG_BOARD_W90N745 #ifndef CONFIG_PCI # error "usb-ohci currently requires PCI-based controllers" /* to support non-PCI OHCIs, you need custom bus/mem/... glue */ #endif +#endif /* Recover a TD/ED using its collision chain */ @@ -559,14 +658,22 @@ hash_free_td (struct ohci * hc, struct td * td) static int ohci_mem_init (struct ohci *ohci) { +#ifdef CONFIG_BOARD_W90N745 + ohci->td_cache = ohci_pool_create ("ohci_td", +#else ohci->td_cache = pci_pool_create ("ohci_td", ohci->ohci_dev, +#endif sizeof (struct td), 32 /* byte alignment */, 0 /* no page-crossing issues */, GFP_KERNEL | OHCI_MEM_FLAGS); if (!ohci->td_cache) return -ENOMEM; +#ifdef CONFIG_BOARD_W90N745 + ohci->dev_cache = ohci_pool_create ("ohci_dev", +#else ohci->dev_cache = pci_pool_create ("ohci_dev", ohci->ohci_dev, +#endif sizeof (struct ohci_device), 16 /* byte alignment */, 0 /* no page-crossing issues */, @@ -579,11 +686,19 @@ static int ohci_mem_init (struct ohci *ohci) static void ohci_mem_cleanup (struct ohci *ohci) { if (ohci->td_cache) { +#ifdef CONFIG_BOARD_W90N745 + ohci_pool_destroy (ohci->td_cache); +#else pci_pool_destroy (ohci->td_cache); +#endif ohci->td_cache = 0; } if (ohci->dev_cache) { +#ifdef CONFIG_BOARD_W90N745 + ohci_pool_destroy (ohci->td_cache); +#else pci_pool_destroy (ohci->dev_cache); +#endif ohci->dev_cache = 0; } } @@ -595,13 +710,21 @@ td_alloc (struct ohci *hc, int mem_flags) dma_addr_t dma; struct td *td; +#ifdef CONFIG_BOARD_W90N745 + td = ohci_pool_alloc (hc->td_cache, mem_flags, &dma); +#else td = pci_pool_alloc (hc->td_cache, mem_flags, &dma); +#endif if (td) { td->td_dma = dma; /* hash it for later reverse mapping */ if (!hash_add_td (hc, td)) { +#ifdef CONFIG_BOARD_W90N745 + ohci_pool_free (hc->td_cache, td, dma); +#else pci_pool_free (hc->td_cache, td, dma); +#endif return NULL; } } @@ -612,7 +735,11 @@ static inline void td_free (struct ohci *hc, struct td *td) { hash_free_td (hc, td); +#ifdef CONFIG_BOARD_W90N745 + ohci_pool_free (hc->td_cache, td, td->td_dma); +#else pci_pool_free (hc->td_cache, td, td->td_dma); +#endif } @@ -624,7 +751,11 @@ dev_alloc (struct ohci *hc, int mem_flags) struct ohci_device *dev; int i, offset; +#ifdef CONFIG_BOARD_W90N745 + dev = ohci_pool_alloc (hc->dev_cache, mem_flags, &dma); +#else dev = pci_pool_alloc (hc->dev_cache, mem_flags, &dma); +#endif if (dev) { memset (dev, 0, sizeof (*dev)); dev->dma = dma; @@ -639,6 +770,10 @@ dev_alloc (struct ohci *hc, int mem_flags) static inline void dev_free (struct ohci *hc, struct ohci_device *dev) { +#ifdef CONFIG_BOARD_W90N745 + ohci_pool_free (hc->dev_cache, dev, dev->dma); +#else pci_pool_free (hc->dev_cache, dev, dev->dma); +#endif } |