-MODULE_DESCRIPTION("ADM5120 USB Host Controller Driver");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)");
-
-#define PFX "adm5120-hcd: "
-
-#define ADMHCD_REG_CONTROL 0x00
-#define ADMHCD_SW_RESET 0x00000008 /* Reset */
-#define ADMHCD_DMAA 0x00000004 /* DMA arbitration control */
-#define ADMHCD_SW_INTREQ 0x00000002 /* request software int */
-#define ADMHCD_HOST_EN 0x00000001 /* Host enable */
-#define ADMHCD_REG_INTSTATUS 0x04
-#define ADMHCD_INT_ACT 0x80000000 /* Interrupt active */
-#define ADMHCD_INT_FATAL 0x40000000 /* Fatal interrupt */
-#define ADMHCD_INT_SW 0x20000000 /* software interrupt */
-#define ADMHCD_INT_TD 0x00100000 /* TD completed */
-#define ADMHCD_FNO 0x00000800 /* Frame number overaflow */
-#define ADMHCD_SO 0x00000400 /* Scheduling overrun */
-#define ADMHCD_INSMI 0x00000200 /* Root hub status change */
-#define ADMHCD_BABI 0x00000100 /* Babble detected, host mode */
-#define ADMHCD_RESI 0x00000020 /* Resume detected */
-#define ADMHCD_SOFI 0x00000010 /* SOF transmitted/received, host mode */
-#define ADMHCD_REG_INTENABLE 0x08
-#define ADMHCD_INT_EN 0x80000000 /* Interrupt enable */
-#define ADMHCD_INTMASK 0x00000001 /* Interrupt mask */
-#define ADMHCD_REG_HOSTCONTROL 0x10
-#define ADMHCD_DMA_EN 0x00000004 /* USB host DMA enable */
-#define ADMHCD_STATE_MASK 0x00000003
-#define ADMHCD_STATE_RST 0x00000000 /* bus state reset */
-#define ADMHCD_STATE_RES 0x00000001 /* bus state resume */
-#define ADMHCD_STATE_OP 0x00000002 /* bus state operational */
-#define ADMHCD_STATE_SUS 0x00000003 /* bus state suspended */
-#define ADMHCD_REG_FMINTERVAL 0x18
-#define ADMHCD_REG_FMNUMBER 0x1c
-#define ADMHCD_REG_LSTHRESH 0x70
-#define ADMHCD_REG_RHDESCR 0x74
-#define ADMHCD_CRWE 0x20000000 /* Clear wakeup enable */
-#define ADMHCD_DRWE 0x10000000 /* Device remote wakeup enable */
-#define ADMHCD_HW_OCIC 0x08000000 /* Over current indication change */
-#define ADMHCD_LPSC 0x04000000 /* Local power switch change */
-#define ADMHCD_OCI 0x02000000 /* Over current indication */
-#define ADMHCD_LPS 0x01000000 /* Local power switch/global power switch */
-#define ADMHCD_NOCP 0x00000800 /* No over current protect mode */
-#define ADMHCD_OPCM 0x00000400 /* Over current protect mode */
-#define ADMHCD_NPS 0x00000200 /* No Power Switch */
-#define ADMHCD_PSM 0x00000100 /* Power switch mode */
-#define ADMHCD_REG_PORTSTATUS0 0x78
-#define ADMHCD_CCS 0x00000001 /* current connect status */
-#define ADMHCD_PES 0x00000002 /* port enable status */
-#define ADMHCD_PSS 0x00000004 /* port suspend status */
-#define ADMHCD_POCI 0x00000008 /* port overcurrent indicator */
-#define ADMHCD_PRS 0x00000010 /* port reset status */
-#define ADMHCD_PPS 0x00000100 /* port power status */
-#define ADMHCD_LSDA 0x00000200 /* low speed device attached */
-#define ADMHCD_CSC 0x00010000 /* connect status change */
-#define ADMHCD_PESC 0x00020000 /* enable status change */
-#define ADMHCD_PSSC 0x00040000 /* suspend status change */
-#define ADMHCD_OCIC 0x00080000 /* overcurrent change*/
-#define ADMHCD_PRSC 0x00100000 /* reset status change */
-#define ADMHCD_REG_PORTSTATUS1 0x7c
-#define ADMHCD_REG_HOSTHEAD 0x80
-
-#define ADMHCD_NUMPORTS 1
-#define ADMHCD_DESC_ALIGN 16
-
-struct admhcd_ed {
- /* Don't change first four, they used for DMA */
- u32 control;
- struct admhcd_td *tail;
- struct admhcd_td *head;
- struct admhcd_ed *next;
- /* the rest is for the driver only: */
- struct admhcd_td *cur;
- struct usb_host_endpoint *ep;
- struct urb *urb;
- struct admhcd_ed *real;
-} __attribute__ ((packed));
-
-#define ADMHCD_ED_EPSHIFT 7 /* Shift for endpoint number */
-#define ADMHCD_ED_INT 0x00000800 /* Is this an int endpoint */
-#define ADMHCD_ED_SPEED 0x00002000 /* Is it a high speed dev? */
-#define ADMHCD_ED_SKIP 0x00004000 /* Skip this ED */
-#define ADMHCD_ED_FORMAT 0x00008000 /* Is this an isoc endpoint */
-#define ADMHCD_ED_MAXSHIFT 16 /* Shift for max packet size */
-
-struct admhcd_td {
- /* Don't change first four, they are used for DMA */
- u32 control;
- u32 buffer;
- u32 buflen;
- struct admhcd_td *next;
- /* the rest is for the driver only: */
- struct urb *urb;
- struct admhcd_td *real;
-} __attribute__ ((packed));
-
-#define ADMHCD_TD_OWN 0x80000000
-#define ADMHCD_TD_TOGGLE 0x00000000
-#define ADMHCD_TD_DATA0 0x01000000
-#define ADMHCD_TD_DATA1 0x01800000
-#define ADMHCD_TD_OUT 0x00200000
-#define ADMHCD_TD_IN 0x00400000
-#define ADMHCD_TD_SETUP 0x00000000
-#define ADMHCD_TD_ISO 0x00010000
-#define ADMHCD_TD_R 0x00040000
-#define ADMHCD_TD_INTEN 0x00010000
-
-static int admhcd_td_err[16] = {
- 0, /* No */
- -EREMOTEIO, /* CRC */
- -EREMOTEIO, /* bit stuff */
- -EREMOTEIO, /* data toggle */
- -EPIPE, /* stall */
- -ETIMEDOUT, /* timeout */
- -EPROTO, /* pid err */
- -EPROTO, /* unexpected pid */
- -EREMOTEIO, /* data overrun */
- -EREMOTEIO, /* data underrun */
- -ETIMEDOUT, /* 1010 */
- -ETIMEDOUT, /* 1011 */
- -EREMOTEIO, /* buffer overrun */
- -EREMOTEIO, /* buffer underrun */
- -ETIMEDOUT, /* 1110 */
- -ETIMEDOUT, /* 1111 */
-};
-
-#define ADMHCD_TD_ERRMASK 0x38000000
-#define ADMHCD_TD_ERRSHIFT 27
-
-#define TD(td) ((struct admhcd_td *)(((u32)(td)) & ~(ADMHCD_DESC_ALIGN-1)))
-#define ED(ed) ((struct admhcd_ed *)(((u32)(ed)) & ~(ADMHCD_DESC_ALIGN-1)))
-
-struct admhcd {
- spinlock_t lock;
-
- /* Root hub registers */
- u32 rhdesca;
- u32 rhdescb;
- u32 rhstatus;
- u32 rhport[2];
-
- /* async schedule: control, bulk */
- struct list_head async;
- u32 base;
- u32 dma_en;
- unsigned long flags;
-};