1 #ifndef __LINUX_SL811_H
2 #define __LINUX_SL811_H
7 #define PDEBUG(level, fmt, args...) \
8 if (debug >= (level)) info("[%s:%d] " fmt, \
9 __PRETTY_FUNCTION__, __LINE__ , ## args)
11 #define PDEBUG(level, fmt, args...) do {} while(0)
14 //#define SL811_TIMEOUT
16 /* Sl811 host control register */
17 #define SL811_CTRL_A 0x00
18 #define SL811_ADDR_A 0x01
19 #define SL811_LEN_A 0x02
20 #define SL811_STS_A 0x03 /* read */
21 #define SL811_PIDEP_A 0x03 /* write */
22 #define SL811_CNT_A 0x04 /* read */
23 #define SL811_DEV_A 0x04 /* write */
24 #define SL811_CTRL1 0x05
25 #define SL811_INTR 0x06
26 #define SL811_CTRL_B 0x08
27 #define SL811_ADDR_B 0x09
28 #define SL811_LEN_B 0x0A
29 #define SL811_STS_B 0x0B /* read */
30 #define SL811_PIDEP_B 0x0B /* write */
31 #define SL811_CNT_B 0x0C /* read */
32 #define SL811_DEV_B 0x0C /* write */
33 #define SL811_INTRSTS 0x0D /* write clears bitwise */
34 #define SL811_HWREV 0x0E /* read */
35 #define SL811_SOFLOW 0x0E /* write */
36 #define SL811_SOFCNTDIV 0x0F /* read */
37 #define SL811_CTRL2 0x0F /* write */
39 /* USB control register bits (addr 0x00 and addr 0x08) */
40 #define SL811_USB_CTRL_ARM 0x01
41 #define SL811_USB_CTRL_ENABLE 0x02
42 #define SL811_USB_CTRL_DIR_OUT 0x04
43 #define SL811_USB_CTRL_ISO 0x10
44 #define SL811_USB_CTRL_SOF 0x20
45 #define SL811_USB_CTRL_TOGGLE_1 0x40
46 #define SL811_USB_CTRL_PREAMBLE 0x80
48 /* USB status register bits (addr 0x03 and addr 0x0B) */
49 #define SL811_USB_STS_ACK 0x01
50 #define SL811_USB_STS_ERROR 0x02
51 #define SL811_USB_STS_TIMEOUT 0x04
52 #define SL811_USB_STS_TOGGLE_1 0x08
53 #define SL811_USB_STS_SETUP 0x10
54 #define SL811_USB_STS_OVERFLOW 0x20
55 #define SL811_USB_STS_NAK 0x40
56 #define SL811_USB_STS_STALL 0x80
58 /* Control register 1 bits (addr 0x05) */
59 #define SL811_CTRL1_SOF 0x01
60 #define SL811_CTRL1_RESET 0x08
61 #define SL811_CTRL1_JKSTATE 0x10
62 #define SL811_CTRL1_SPEED_LOW 0x20
63 #define SL811_CTRL1_SUSPEND 0x40
65 /* Interrut enable (addr 0x06) and interrupt status register bits (addr 0x0D) */
66 #define SL811_INTR_DONE_A 0x01
67 #define SL811_INTR_DONE_B 0x02
68 #define SL811_INTR_SOF 0x10
69 #define SL811_INTR_INSRMV 0x20
70 #define SL811_INTR_DETECT 0x40
71 #define SL811_INTR_NOTPRESENT 0x40
72 #define SL811_INTR_SPEED_FULL 0x80 /* only in status reg */
74 /* HW rev and SOF lo register bits (addr 0x0E) */
75 #define SL811_HWR_HWREV 0xF0
77 /* SOF counter and control reg 2 (addr 0x0F) */
78 #define SL811_CTL2_SOFHI 0x3F
79 #define SL811_CTL2_DSWAP 0x40
80 #define SL811_CTL2_HOST 0x80
82 /* Set up for 1-ms SOF time. */
83 #define SL811_12M_LOW 0xE0
84 #define SL811_12M_HI 0x2E
86 #define SL811_DATA_START 0x10
87 #define SL811_DATA_LIMIT 240
90 /* Requests: bRequest << 8 | bmRequestType */
91 #define RH_GET_STATUS 0x0080
92 #define RH_CLEAR_FEATURE 0x0100
93 #define RH_SET_FEATURE 0x0300
94 #define RH_SET_ADDRESS 0x0500
95 #define RH_GET_DESCRIPTOR 0x0680
96 #define RH_SET_DESCRIPTOR 0x0700
97 #define RH_GET_CONFIGURATION 0x0880
98 #define RH_SET_CONFIGURATION 0x0900
99 #define RH_GET_STATE 0x0280
100 #define RH_GET_INTERFACE 0x0A80
101 #define RH_SET_INTERFACE 0x0B00
102 #define RH_SYNC_FRAME 0x0C80
105 #define PIDEP(pid, ep) (((pid) & 0x0f) << 4 | (ep))
107 /* Virtual Root HUB */
108 struct virt_root_hub {
109 int devnum; /* Address of Root Hub endpoint */
110 void *urb; /* interrupt URB of root hub */
111 int send; /* active flag */
112 int interval; /* intervall of roothub interrupt transfers */
113 struct timer_list rh_int_timer; /* intervall timer for rh interrupt EP */
118 __u8 ctrl; /* control register */
121 __u8 addr; /* base adrress register */
122 __u8 len; /* base length register */
123 __u8 pidep; /* PId and endpoint register */
124 __u8 dev; /* device address register */
127 __u8 status; /* status register */
128 __u8 left; /* transfer count register */
131 __u8 errcnt; /* error count, begin with 3 */
132 __u8 done; /* is this td tranfer done */
133 __u8 *buf; /* point to data buffer for tranfer */
134 int bustime; /* the bus time need by this td */
135 int td_status; /* the status of this td */
136 int nakcnt; /* number of naks */
137 struct urb *urb; /* the urb this td belongs to */
138 struct list_head td_list; /* link to a list of the urb */
141 struct sl811_urb_priv {
142 struct urb *urb; /* the urb this priv beloings to */
143 struct list_head td_list; /* list of all the td of this urb */
144 struct sl811_td *cur_td; /* current td is in processing or it will be */
145 struct sl811_td *first_td; /* the first td of this urb */
146 struct sl811_td *last_td; /* the last td of this urb */
147 int interval; /* the query time value for intr urb */
148 int unlink; /* is the this urb unlinked */
149 unsigned long inserttime; /* the time when insert to list */
153 spinlock_t hc_lock; /* Lock for this structure */
155 int irq; /* IRQ number this hc use */
156 int addr_io; /* I/O address line address */
157 int data_io; /* I/O data line address */
158 struct virt_root_hub rh; /* root hub */
159 struct usb_port_status rh_status;/* root hub port status */
160 struct list_head urb_list[6]; /* set of urbs, the order is iso,intr,ctrl,bulk,inactive intr, wait */
161 struct list_head *cur_list; /* the current list is in process */
162 wait_queue_head_t waitq; /* deletion of URBs and devices needs a waitqueue */
163 struct sl811_td *cur_td; /* point to the td is in process */
164 struct list_head hc_hcd_list; /* list of all hci_hcd */
165 struct usb_bus *bus; /* our bus */
166 int active_urbs; /* total number of active usbs */
167 int frame_number; /* the current frame number, we do't use it, any one need it? */
170 #define iso_list urb_list[0] /* set of isoc urbs */
171 #define intr_list urb_list[1] /* ordered (tree) set of int urbs */
172 #define ctrl_list urb_list[2] /* set of ctrl urbs */
173 #define bulk_list urb_list[3] /* set of bulk urbs */
174 #define idle_intr_list urb_list[4] /* set of intr urbs in its idle time*/
175 #define wait_list urb_list[5] /* set of wait urbs */