diff options
Diffstat (limited to 'drivers/usb/gadget/langwell_udc.c')
-rw-r--r-- | drivers/usb/gadget/langwell_udc.c | 1058 |
1 files changed, 632 insertions, 426 deletions
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index c2d2a201f84b..b8ec954c0692 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | 20 | ||
21 | /* #undef DEBUG */ | 21 | /* #undef DEBUG */ |
22 | /* #undef VERBOSE */ | 22 | /* #undef VERBOSE_DEBUG */ |
23 | 23 | ||
24 | #if defined(CONFIG_USB_LANGWELL_OTG) | 24 | #if defined(CONFIG_USB_LANGWELL_OTG) |
25 | #define OTG_TRANSCEIVER | 25 | #define OTG_TRANSCEIVER |
@@ -77,141 +77,110 @@ langwell_ep0_desc = { | |||
77 | /*-------------------------------------------------------------------------*/ | 77 | /*-------------------------------------------------------------------------*/ |
78 | /* debugging */ | 78 | /* debugging */ |
79 | 79 | ||
80 | #ifdef DEBUG | 80 | #ifdef VERBOSE_DEBUG |
81 | #define DBG(dev, fmt, args...) \ | ||
82 | pr_debug("%s %s: " fmt , driver_name, \ | ||
83 | pci_name(dev->pdev), ## args) | ||
84 | #else | ||
85 | #define DBG(dev, fmt, args...) \ | ||
86 | do { } while (0) | ||
87 | #endif /* DEBUG */ | ||
88 | |||
89 | |||
90 | #ifdef VERBOSE | ||
91 | #define VDBG DBG | ||
92 | #else | ||
93 | #define VDBG(dev, fmt, args...) \ | ||
94 | do { } while (0) | ||
95 | #endif /* VERBOSE */ | ||
96 | |||
97 | |||
98 | #define ERROR(dev, fmt, args...) \ | ||
99 | pr_err("%s %s: " fmt , driver_name, \ | ||
100 | pci_name(dev->pdev), ## args) | ||
101 | |||
102 | #define WARNING(dev, fmt, args...) \ | ||
103 | pr_warning("%s %s: " fmt , driver_name, \ | ||
104 | pci_name(dev->pdev), ## args) | ||
105 | |||
106 | #define INFO(dev, fmt, args...) \ | ||
107 | pr_info("%s %s: " fmt , driver_name, \ | ||
108 | pci_name(dev->pdev), ## args) | ||
109 | |||
110 | |||
111 | #ifdef VERBOSE | ||
112 | static inline void print_all_registers(struct langwell_udc *dev) | 81 | static inline void print_all_registers(struct langwell_udc *dev) |
113 | { | 82 | { |
114 | int i; | 83 | int i; |
115 | 84 | ||
116 | /* Capability Registers */ | 85 | /* Capability Registers */ |
117 | printk(KERN_DEBUG "Capability Registers (offset: " | 86 | dev_dbg(&dev->pdev->dev, |
118 | "0x%04x, length: 0x%08x)\n", | 87 | "Capability Registers (offset: 0x%04x, length: 0x%08x)\n", |
119 | CAP_REG_OFFSET, | 88 | CAP_REG_OFFSET, (u32)sizeof(struct langwell_cap_regs)); |
120 | (u32)sizeof(struct langwell_cap_regs)); | 89 | dev_dbg(&dev->pdev->dev, "caplength=0x%02x\n", |
121 | printk(KERN_DEBUG "caplength=0x%02x\n", | ||
122 | readb(&dev->cap_regs->caplength)); | 90 | readb(&dev->cap_regs->caplength)); |
123 | printk(KERN_DEBUG "hciversion=0x%04x\n", | 91 | dev_dbg(&dev->pdev->dev, "hciversion=0x%04x\n", |
124 | readw(&dev->cap_regs->hciversion)); | 92 | readw(&dev->cap_regs->hciversion)); |
125 | printk(KERN_DEBUG "hcsparams=0x%08x\n", | 93 | dev_dbg(&dev->pdev->dev, "hcsparams=0x%08x\n", |
126 | readl(&dev->cap_regs->hcsparams)); | 94 | readl(&dev->cap_regs->hcsparams)); |
127 | printk(KERN_DEBUG "hccparams=0x%08x\n", | 95 | dev_dbg(&dev->pdev->dev, "hccparams=0x%08x\n", |
128 | readl(&dev->cap_regs->hccparams)); | 96 | readl(&dev->cap_regs->hccparams)); |
129 | printk(KERN_DEBUG "dciversion=0x%04x\n", | 97 | dev_dbg(&dev->pdev->dev, "dciversion=0x%04x\n", |
130 | readw(&dev->cap_regs->dciversion)); | 98 | readw(&dev->cap_regs->dciversion)); |
131 | printk(KERN_DEBUG "dccparams=0x%08x\n", | 99 | dev_dbg(&dev->pdev->dev, "dccparams=0x%08x\n", |
132 | readl(&dev->cap_regs->dccparams)); | 100 | readl(&dev->cap_regs->dccparams)); |
133 | 101 | ||
134 | /* Operational Registers */ | 102 | /* Operational Registers */ |
135 | printk(KERN_DEBUG "Operational Registers (offset: " | 103 | dev_dbg(&dev->pdev->dev, |
136 | "0x%04x, length: 0x%08x)\n", | 104 | "Operational Registers (offset: 0x%04x, length: 0x%08x)\n", |
137 | OP_REG_OFFSET, | 105 | OP_REG_OFFSET, (u32)sizeof(struct langwell_op_regs)); |
138 | (u32)sizeof(struct langwell_op_regs)); | 106 | dev_dbg(&dev->pdev->dev, "extsts=0x%08x\n", |
139 | printk(KERN_DEBUG "extsts=0x%08x\n", | ||
140 | readl(&dev->op_regs->extsts)); | 107 | readl(&dev->op_regs->extsts)); |
141 | printk(KERN_DEBUG "extintr=0x%08x\n", | 108 | dev_dbg(&dev->pdev->dev, "extintr=0x%08x\n", |
142 | readl(&dev->op_regs->extintr)); | 109 | readl(&dev->op_regs->extintr)); |
143 | printk(KERN_DEBUG "usbcmd=0x%08x\n", | 110 | dev_dbg(&dev->pdev->dev, "usbcmd=0x%08x\n", |
144 | readl(&dev->op_regs->usbcmd)); | 111 | readl(&dev->op_regs->usbcmd)); |
145 | printk(KERN_DEBUG "usbsts=0x%08x\n", | 112 | dev_dbg(&dev->pdev->dev, "usbsts=0x%08x\n", |
146 | readl(&dev->op_regs->usbsts)); | 113 | readl(&dev->op_regs->usbsts)); |
147 | printk(KERN_DEBUG "usbintr=0x%08x\n", | 114 | dev_dbg(&dev->pdev->dev, "usbintr=0x%08x\n", |
148 | readl(&dev->op_regs->usbintr)); | 115 | readl(&dev->op_regs->usbintr)); |
149 | printk(KERN_DEBUG "frindex=0x%08x\n", | 116 | dev_dbg(&dev->pdev->dev, "frindex=0x%08x\n", |
150 | readl(&dev->op_regs->frindex)); | 117 | readl(&dev->op_regs->frindex)); |
151 | printk(KERN_DEBUG "ctrldssegment=0x%08x\n", | 118 | dev_dbg(&dev->pdev->dev, "ctrldssegment=0x%08x\n", |
152 | readl(&dev->op_regs->ctrldssegment)); | 119 | readl(&dev->op_regs->ctrldssegment)); |
153 | printk(KERN_DEBUG "deviceaddr=0x%08x\n", | 120 | dev_dbg(&dev->pdev->dev, "deviceaddr=0x%08x\n", |
154 | readl(&dev->op_regs->deviceaddr)); | 121 | readl(&dev->op_regs->deviceaddr)); |
155 | printk(KERN_DEBUG "endpointlistaddr=0x%08x\n", | 122 | dev_dbg(&dev->pdev->dev, "endpointlistaddr=0x%08x\n", |
156 | readl(&dev->op_regs->endpointlistaddr)); | 123 | readl(&dev->op_regs->endpointlistaddr)); |
157 | printk(KERN_DEBUG "ttctrl=0x%08x\n", | 124 | dev_dbg(&dev->pdev->dev, "ttctrl=0x%08x\n", |
158 | readl(&dev->op_regs->ttctrl)); | 125 | readl(&dev->op_regs->ttctrl)); |
159 | printk(KERN_DEBUG "burstsize=0x%08x\n", | 126 | dev_dbg(&dev->pdev->dev, "burstsize=0x%08x\n", |
160 | readl(&dev->op_regs->burstsize)); | 127 | readl(&dev->op_regs->burstsize)); |
161 | printk(KERN_DEBUG "txfilltuning=0x%08x\n", | 128 | dev_dbg(&dev->pdev->dev, "txfilltuning=0x%08x\n", |
162 | readl(&dev->op_regs->txfilltuning)); | 129 | readl(&dev->op_regs->txfilltuning)); |
163 | printk(KERN_DEBUG "txttfilltuning=0x%08x\n", | 130 | dev_dbg(&dev->pdev->dev, "txttfilltuning=0x%08x\n", |
164 | readl(&dev->op_regs->txttfilltuning)); | 131 | readl(&dev->op_regs->txttfilltuning)); |
165 | printk(KERN_DEBUG "ic_usb=0x%08x\n", | 132 | dev_dbg(&dev->pdev->dev, "ic_usb=0x%08x\n", |
166 | readl(&dev->op_regs->ic_usb)); | 133 | readl(&dev->op_regs->ic_usb)); |
167 | printk(KERN_DEBUG "ulpi_viewport=0x%08x\n", | 134 | dev_dbg(&dev->pdev->dev, "ulpi_viewport=0x%08x\n", |
168 | readl(&dev->op_regs->ulpi_viewport)); | 135 | readl(&dev->op_regs->ulpi_viewport)); |
169 | printk(KERN_DEBUG "configflag=0x%08x\n", | 136 | dev_dbg(&dev->pdev->dev, "configflag=0x%08x\n", |
170 | readl(&dev->op_regs->configflag)); | 137 | readl(&dev->op_regs->configflag)); |
171 | printk(KERN_DEBUG "portsc1=0x%08x\n", | 138 | dev_dbg(&dev->pdev->dev, "portsc1=0x%08x\n", |
172 | readl(&dev->op_regs->portsc1)); | 139 | readl(&dev->op_regs->portsc1)); |
173 | printk(KERN_DEBUG "devlc=0x%08x\n", | 140 | dev_dbg(&dev->pdev->dev, "devlc=0x%08x\n", |
174 | readl(&dev->op_regs->devlc)); | 141 | readl(&dev->op_regs->devlc)); |
175 | printk(KERN_DEBUG "otgsc=0x%08x\n", | 142 | dev_dbg(&dev->pdev->dev, "otgsc=0x%08x\n", |
176 | readl(&dev->op_regs->otgsc)); | 143 | readl(&dev->op_regs->otgsc)); |
177 | printk(KERN_DEBUG "usbmode=0x%08x\n", | 144 | dev_dbg(&dev->pdev->dev, "usbmode=0x%08x\n", |
178 | readl(&dev->op_regs->usbmode)); | 145 | readl(&dev->op_regs->usbmode)); |
179 | printk(KERN_DEBUG "endptnak=0x%08x\n", | 146 | dev_dbg(&dev->pdev->dev, "endptnak=0x%08x\n", |
180 | readl(&dev->op_regs->endptnak)); | 147 | readl(&dev->op_regs->endptnak)); |
181 | printk(KERN_DEBUG "endptnaken=0x%08x\n", | 148 | dev_dbg(&dev->pdev->dev, "endptnaken=0x%08x\n", |
182 | readl(&dev->op_regs->endptnaken)); | 149 | readl(&dev->op_regs->endptnaken)); |
183 | printk(KERN_DEBUG "endptsetupstat=0x%08x\n", | 150 | dev_dbg(&dev->pdev->dev, "endptsetupstat=0x%08x\n", |
184 | readl(&dev->op_regs->endptsetupstat)); | 151 | readl(&dev->op_regs->endptsetupstat)); |
185 | printk(KERN_DEBUG "endptprime=0x%08x\n", | 152 | dev_dbg(&dev->pdev->dev, "endptprime=0x%08x\n", |
186 | readl(&dev->op_regs->endptprime)); | 153 | readl(&dev->op_regs->endptprime)); |
187 | printk(KERN_DEBUG "endptflush=0x%08x\n", | 154 | dev_dbg(&dev->pdev->dev, "endptflush=0x%08x\n", |
188 | readl(&dev->op_regs->endptflush)); | 155 | readl(&dev->op_regs->endptflush)); |
189 | printk(KERN_DEBUG "endptstat=0x%08x\n", | 156 | dev_dbg(&dev->pdev->dev, "endptstat=0x%08x\n", |
190 | readl(&dev->op_regs->endptstat)); | 157 | readl(&dev->op_regs->endptstat)); |
191 | printk(KERN_DEBUG "endptcomplete=0x%08x\n", | 158 | dev_dbg(&dev->pdev->dev, "endptcomplete=0x%08x\n", |
192 | readl(&dev->op_regs->endptcomplete)); | 159 | readl(&dev->op_regs->endptcomplete)); |
193 | 160 | ||
194 | for (i = 0; i < dev->ep_max / 2; i++) { | 161 | for (i = 0; i < dev->ep_max / 2; i++) { |
195 | printk(KERN_DEBUG "endptctrl[%d]=0x%08x\n", | 162 | dev_dbg(&dev->pdev->dev, "endptctrl[%d]=0x%08x\n", |
196 | i, readl(&dev->op_regs->endptctrl[i])); | 163 | i, readl(&dev->op_regs->endptctrl[i])); |
197 | } | 164 | } |
198 | } | 165 | } |
199 | #endif /* VERBOSE */ | 166 | #else |
167 | |||
168 | #define print_all_registers(dev) do { } while (0) | ||
169 | |||
170 | #endif /* VERBOSE_DEBUG */ | ||
200 | 171 | ||
201 | 172 | ||
202 | /*-------------------------------------------------------------------------*/ | 173 | /*-------------------------------------------------------------------------*/ |
203 | 174 | ||
204 | #define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out") | 175 | #define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \ |
176 | USB_DIR_IN) : (usb_endpoint_dir_in((ep)->desc))) | ||
205 | 177 | ||
206 | #define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \ | 178 | #define DIR_STRING(ep) (is_in(ep) ? "in" : "out") |
207 | USB_DIR_IN) : ((ep)->desc->bEndpointAddress \ | ||
208 | & USB_DIR_IN) == USB_DIR_IN) | ||
209 | 179 | ||
210 | 180 | ||
211 | #ifdef DEBUG | 181 | static char *type_string(const struct usb_endpoint_descriptor *desc) |
212 | static char *type_string(u8 bmAttributes) | ||
213 | { | 182 | { |
214 | switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) { | 183 | switch (usb_endpoint_type(desc)) { |
215 | case USB_ENDPOINT_XFER_BULK: | 184 | case USB_ENDPOINT_XFER_BULK: |
216 | return "bulk"; | 185 | return "bulk"; |
217 | case USB_ENDPOINT_XFER_ISOC: | 186 | case USB_ENDPOINT_XFER_ISOC: |
@@ -222,7 +191,6 @@ static char *type_string(u8 bmAttributes) | |||
222 | 191 | ||
223 | return "control"; | 192 | return "control"; |
224 | } | 193 | } |
225 | #endif | ||
226 | 194 | ||
227 | 195 | ||
228 | /* configure endpoint control registers */ | 196 | /* configure endpoint control registers */ |
@@ -233,7 +201,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num, | |||
233 | u32 endptctrl; | 201 | u32 endptctrl; |
234 | 202 | ||
235 | dev = ep->dev; | 203 | dev = ep->dev; |
236 | VDBG(dev, "---> %s()\n", __func__); | 204 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
237 | 205 | ||
238 | endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); | 206 | endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); |
239 | if (is_in) { /* TX */ | 207 | if (is_in) { /* TX */ |
@@ -250,7 +218,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num, | |||
250 | 218 | ||
251 | writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); | 219 | writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); |
252 | 220 | ||
253 | VDBG(dev, "<--- %s()\n", __func__); | 221 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
254 | } | 222 | } |
255 | 223 | ||
256 | 224 | ||
@@ -260,7 +228,7 @@ static void ep0_reset(struct langwell_udc *dev) | |||
260 | struct langwell_ep *ep; | 228 | struct langwell_ep *ep; |
261 | int i; | 229 | int i; |
262 | 230 | ||
263 | VDBG(dev, "---> %s()\n", __func__); | 231 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
264 | 232 | ||
265 | /* ep0 in and out */ | 233 | /* ep0 in and out */ |
266 | for (i = 0; i < 2; i++) { | 234 | for (i = 0; i < 2; i++) { |
@@ -274,17 +242,18 @@ static void ep0_reset(struct langwell_udc *dev) | |||
274 | ep->dqh->dqh_ios = 1; | 242 | ep->dqh->dqh_ios = 1; |
275 | ep->dqh->dqh_mpl = EP0_MAX_PKT_SIZE; | 243 | ep->dqh->dqh_mpl = EP0_MAX_PKT_SIZE; |
276 | 244 | ||
277 | /* FIXME: enable ep0-in HW zero length termination select */ | 245 | /* enable ep0-in HW zero length termination select */ |
278 | if (is_in(ep)) | 246 | if (is_in(ep)) |
279 | ep->dqh->dqh_zlt = 0; | 247 | ep->dqh->dqh_zlt = 0; |
280 | ep->dqh->dqh_mult = 0; | 248 | ep->dqh->dqh_mult = 0; |
281 | 249 | ||
250 | ep->dqh->dtd_next = DTD_TERM; | ||
251 | |||
282 | /* configure ep0 control registers */ | 252 | /* configure ep0 control registers */ |
283 | ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL); | 253 | ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL); |
284 | } | 254 | } |
285 | 255 | ||
286 | VDBG(dev, "<--- %s()\n", __func__); | 256 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
287 | return; | ||
288 | } | 257 | } |
289 | 258 | ||
290 | 259 | ||
@@ -300,12 +269,12 @@ static int langwell_ep_enable(struct usb_ep *_ep, | |||
300 | struct langwell_ep *ep; | 269 | struct langwell_ep *ep; |
301 | u16 max = 0; | 270 | u16 max = 0; |
302 | unsigned long flags; | 271 | unsigned long flags; |
303 | int retval = 0; | 272 | int i, retval = 0; |
304 | unsigned char zlt, ios = 0, mult = 0; | 273 | unsigned char zlt, ios = 0, mult = 0; |
305 | 274 | ||
306 | ep = container_of(_ep, struct langwell_ep, ep); | 275 | ep = container_of(_ep, struct langwell_ep, ep); |
307 | dev = ep->dev; | 276 | dev = ep->dev; |
308 | VDBG(dev, "---> %s()\n", __func__); | 277 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
309 | 278 | ||
310 | if (!_ep || !desc || ep->desc | 279 | if (!_ep || !desc || ep->desc |
311 | || desc->bDescriptorType != USB_DT_ENDPOINT) | 280 | || desc->bDescriptorType != USB_DT_ENDPOINT) |
@@ -326,7 +295,7 @@ static int langwell_ep_enable(struct usb_ep *_ep, | |||
326 | * sanity check type, direction, address, and then | 295 | * sanity check type, direction, address, and then |
327 | * initialize the endpoint capabilities fields in dQH | 296 | * initialize the endpoint capabilities fields in dQH |
328 | */ | 297 | */ |
329 | switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | 298 | switch (usb_endpoint_type(desc)) { |
330 | case USB_ENDPOINT_XFER_CONTROL: | 299 | case USB_ENDPOINT_XFER_CONTROL: |
331 | ios = 1; | 300 | ios = 1; |
332 | break; | 301 | break; |
@@ -386,33 +355,36 @@ static int langwell_ep_enable(struct usb_ep *_ep, | |||
386 | 355 | ||
387 | spin_lock_irqsave(&dev->lock, flags); | 356 | spin_lock_irqsave(&dev->lock, flags); |
388 | 357 | ||
389 | /* configure endpoint capabilities in dQH */ | ||
390 | ep->dqh->dqh_ios = ios; | ||
391 | ep->dqh->dqh_mpl = cpu_to_le16(max); | ||
392 | ep->dqh->dqh_zlt = zlt; | ||
393 | ep->dqh->dqh_mult = mult; | ||
394 | |||
395 | ep->ep.maxpacket = max; | 358 | ep->ep.maxpacket = max; |
396 | ep->desc = desc; | 359 | ep->desc = desc; |
397 | ep->stopped = 0; | 360 | ep->stopped = 0; |
398 | ep->ep_num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | 361 | ep->ep_num = usb_endpoint_num(desc); |
399 | 362 | ||
400 | /* ep_type */ | 363 | /* ep_type */ |
401 | ep->ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | 364 | ep->ep_type = usb_endpoint_type(desc); |
402 | 365 | ||
403 | /* configure endpoint control registers */ | 366 | /* configure endpoint control registers */ |
404 | ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type); | 367 | ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type); |
405 | 368 | ||
406 | DBG(dev, "enabled %s (ep%d%s-%s), max %04x\n", | 369 | /* configure endpoint capabilities in dQH */ |
370 | i = ep->ep_num * 2 + is_in(ep); | ||
371 | ep->dqh = &dev->ep_dqh[i]; | ||
372 | ep->dqh->dqh_ios = ios; | ||
373 | ep->dqh->dqh_mpl = cpu_to_le16(max); | ||
374 | ep->dqh->dqh_zlt = zlt; | ||
375 | ep->dqh->dqh_mult = mult; | ||
376 | ep->dqh->dtd_next = DTD_TERM; | ||
377 | |||
378 | dev_dbg(&dev->pdev->dev, "enabled %s (ep%d%s-%s), max %04x\n", | ||
407 | _ep->name, | 379 | _ep->name, |
408 | ep->ep_num, | 380 | ep->ep_num, |
409 | DIR_STRING(desc->bEndpointAddress), | 381 | DIR_STRING(ep), |
410 | type_string(desc->bmAttributes), | 382 | type_string(desc), |
411 | max); | 383 | max); |
412 | 384 | ||
413 | spin_unlock_irqrestore(&dev->lock, flags); | 385 | spin_unlock_irqrestore(&dev->lock, flags); |
414 | done: | 386 | done: |
415 | VDBG(dev, "<--- %s()\n", __func__); | 387 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
416 | return retval; | 388 | return retval; |
417 | } | 389 | } |
418 | 390 | ||
@@ -428,7 +400,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
428 | struct langwell_dtd *curr_dtd, *next_dtd; | 400 | struct langwell_dtd *curr_dtd, *next_dtd; |
429 | int i; | 401 | int i; |
430 | 402 | ||
431 | VDBG(dev, "---> %s()\n", __func__); | 403 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
432 | 404 | ||
433 | /* remove the req from ep->queue */ | 405 | /* remove the req from ep->queue */ |
434 | list_del_init(&req->queue); | 406 | list_del_init(&req->queue); |
@@ -448,7 +420,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
448 | } | 420 | } |
449 | 421 | ||
450 | if (req->mapped) { | 422 | if (req->mapped) { |
451 | dma_unmap_single(&dev->pdev->dev, req->req.dma, req->req.length, | 423 | dma_unmap_single(&dev->pdev->dev, |
424 | req->req.dma, req->req.length, | ||
452 | is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 425 | is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); |
453 | req->req.dma = DMA_ADDR_INVALID; | 426 | req->req.dma = DMA_ADDR_INVALID; |
454 | req->mapped = 0; | 427 | req->mapped = 0; |
@@ -458,9 +431,10 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
458 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 431 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
459 | 432 | ||
460 | if (status != -ESHUTDOWN) | 433 | if (status != -ESHUTDOWN) |
461 | DBG(dev, "complete %s, req %p, stat %d, len %u/%u\n", | 434 | dev_dbg(&dev->pdev->dev, |
462 | ep->ep.name, &req->req, status, | 435 | "complete %s, req %p, stat %d, len %u/%u\n", |
463 | req->req.actual, req->req.length); | 436 | ep->ep.name, &req->req, status, |
437 | req->req.actual, req->req.length); | ||
464 | 438 | ||
465 | /* don't modify queue heads during completion callback */ | 439 | /* don't modify queue heads during completion callback */ |
466 | ep->stopped = 1; | 440 | ep->stopped = 1; |
@@ -473,7 +447,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
473 | spin_lock(&dev->lock); | 447 | spin_lock(&dev->lock); |
474 | ep->stopped = stopped; | 448 | ep->stopped = stopped; |
475 | 449 | ||
476 | VDBG(dev, "<--- %s()\n", __func__); | 450 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
477 | } | 451 | } |
478 | 452 | ||
479 | 453 | ||
@@ -511,7 +485,7 @@ static int langwell_ep_disable(struct usb_ep *_ep) | |||
511 | 485 | ||
512 | ep = container_of(_ep, struct langwell_ep, ep); | 486 | ep = container_of(_ep, struct langwell_ep, ep); |
513 | dev = ep->dev; | 487 | dev = ep->dev; |
514 | VDBG(dev, "---> %s()\n", __func__); | 488 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
515 | 489 | ||
516 | if (!_ep || !ep->desc) | 490 | if (!_ep || !ep->desc) |
517 | return -EINVAL; | 491 | return -EINVAL; |
@@ -535,8 +509,8 @@ static int langwell_ep_disable(struct usb_ep *_ep) | |||
535 | 509 | ||
536 | spin_unlock_irqrestore(&dev->lock, flags); | 510 | spin_unlock_irqrestore(&dev->lock, flags); |
537 | 511 | ||
538 | DBG(dev, "disabled %s\n", _ep->name); | 512 | dev_dbg(&dev->pdev->dev, "disabled %s\n", _ep->name); |
539 | VDBG(dev, "<--- %s()\n", __func__); | 513 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
540 | 514 | ||
541 | return 0; | 515 | return 0; |
542 | } | 516 | } |
@@ -555,7 +529,7 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep, | |||
555 | 529 | ||
556 | ep = container_of(_ep, struct langwell_ep, ep); | 530 | ep = container_of(_ep, struct langwell_ep, ep); |
557 | dev = ep->dev; | 531 | dev = ep->dev; |
558 | VDBG(dev, "---> %s()\n", __func__); | 532 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
559 | 533 | ||
560 | req = kzalloc(sizeof(*req), gfp_flags); | 534 | req = kzalloc(sizeof(*req), gfp_flags); |
561 | if (!req) | 535 | if (!req) |
@@ -564,8 +538,8 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep, | |||
564 | req->req.dma = DMA_ADDR_INVALID; | 538 | req->req.dma = DMA_ADDR_INVALID; |
565 | INIT_LIST_HEAD(&req->queue); | 539 | INIT_LIST_HEAD(&req->queue); |
566 | 540 | ||
567 | VDBG(dev, "alloc request for %s\n", _ep->name); | 541 | dev_vdbg(&dev->pdev->dev, "alloc request for %s\n", _ep->name); |
568 | VDBG(dev, "<--- %s()\n", __func__); | 542 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
569 | return &req->req; | 543 | return &req->req; |
570 | } | 544 | } |
571 | 545 | ||
@@ -580,7 +554,7 @@ static void langwell_free_request(struct usb_ep *_ep, | |||
580 | 554 | ||
581 | ep = container_of(_ep, struct langwell_ep, ep); | 555 | ep = container_of(_ep, struct langwell_ep, ep); |
582 | dev = ep->dev; | 556 | dev = ep->dev; |
583 | VDBG(dev, "---> %s()\n", __func__); | 557 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
584 | 558 | ||
585 | if (!_ep || !_req) | 559 | if (!_ep || !_req) |
586 | return; | 560 | return; |
@@ -591,8 +565,8 @@ static void langwell_free_request(struct usb_ep *_ep, | |||
591 | if (_req) | 565 | if (_req) |
592 | kfree(req); | 566 | kfree(req); |
593 | 567 | ||
594 | VDBG(dev, "free request for %s\n", _ep->name); | 568 | dev_vdbg(&dev->pdev->dev, "free request for %s\n", _ep->name); |
595 | VDBG(dev, "<--- %s()\n", __func__); | 569 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
596 | } | 570 | } |
597 | 571 | ||
598 | 572 | ||
@@ -608,23 +582,24 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req) | |||
608 | struct langwell_udc *dev; | 582 | struct langwell_udc *dev; |
609 | 583 | ||
610 | dev = ep->dev; | 584 | dev = ep->dev; |
611 | VDBG(dev, "---> %s()\n", __func__); | 585 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
612 | 586 | ||
613 | i = ep->ep_num * 2 + is_in(ep); | 587 | i = ep->ep_num * 2 + is_in(ep); |
614 | dqh = &dev->ep_dqh[i]; | 588 | dqh = &dev->ep_dqh[i]; |
615 | 589 | ||
616 | if (ep->ep_num) | 590 | if (ep->ep_num) |
617 | VDBG(dev, "%s\n", ep->name); | 591 | dev_vdbg(&dev->pdev->dev, "%s\n", ep->name); |
618 | else | 592 | else |
619 | /* ep0 */ | 593 | /* ep0 */ |
620 | VDBG(dev, "%s-%s\n", ep->name, is_in(ep) ? "in" : "out"); | 594 | dev_vdbg(&dev->pdev->dev, "%s-%s\n", ep->name, DIR_STRING(ep)); |
621 | 595 | ||
622 | VDBG(dev, "ep_dqh[%d] addr: 0x%08x\n", i, (u32)&(dev->ep_dqh[i])); | 596 | dev_vdbg(&dev->pdev->dev, "ep_dqh[%d] addr: 0x%08x\n", |
597 | i, (u32)&(dev->ep_dqh[i])); | ||
623 | 598 | ||
624 | bit_mask = is_in(ep) ? | 599 | bit_mask = is_in(ep) ? |
625 | (1 << (ep->ep_num + 16)) : (1 << (ep->ep_num)); | 600 | (1 << (ep->ep_num + 16)) : (1 << (ep->ep_num)); |
626 | 601 | ||
627 | VDBG(dev, "bit_mask = 0x%08x\n", bit_mask); | 602 | dev_vdbg(&dev->pdev->dev, "bit_mask = 0x%08x\n", bit_mask); |
628 | 603 | ||
629 | /* check if the pipe is empty */ | 604 | /* check if the pipe is empty */ |
630 | if (!(list_empty(&ep->queue))) { | 605 | if (!(list_empty(&ep->queue))) { |
@@ -665,14 +640,17 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req) | |||
665 | /* clear active and halt bit */ | 640 | /* clear active and halt bit */ |
666 | dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED); | 641 | dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED); |
667 | dqh->dtd_status &= dtd_status; | 642 | dqh->dtd_status &= dtd_status; |
668 | VDBG(dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status); | 643 | dev_vdbg(&dev->pdev->dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status); |
644 | |||
645 | /* ensure that updates to the dQH will occure before priming */ | ||
646 | wmb(); | ||
669 | 647 | ||
670 | /* write 1 to endptprime register to PRIME endpoint */ | 648 | /* write 1 to endptprime register to PRIME endpoint */ |
671 | bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num); | 649 | bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num); |
672 | VDBG(dev, "endprime bit_mask = 0x%08x\n", bit_mask); | 650 | dev_vdbg(&dev->pdev->dev, "endprime bit_mask = 0x%08x\n", bit_mask); |
673 | writel(bit_mask, &dev->op_regs->endptprime); | 651 | writel(bit_mask, &dev->op_regs->endptprime); |
674 | out: | 652 | out: |
675 | VDBG(dev, "<--- %s()\n", __func__); | 653 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
676 | return 0; | 654 | return 0; |
677 | } | 655 | } |
678 | 656 | ||
@@ -687,7 +665,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, | |||
687 | int i; | 665 | int i; |
688 | 666 | ||
689 | dev = req->ep->dev; | 667 | dev = req->ep->dev; |
690 | VDBG(dev, "---> %s()\n", __func__); | 668 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
691 | 669 | ||
692 | /* the maximum transfer length, up to 16k bytes */ | 670 | /* the maximum transfer length, up to 16k bytes */ |
693 | *length = min(req->req.length - req->req.actual, | 671 | *length = min(req->req.length - req->req.actual, |
@@ -708,7 +686,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, | |||
708 | 686 | ||
709 | /* fill in total bytes with transfer size */ | 687 | /* fill in total bytes with transfer size */ |
710 | dtd->dtd_total = cpu_to_le16(*length); | 688 | dtd->dtd_total = cpu_to_le16(*length); |
711 | VDBG(dev, "dtd->dtd_total = %d\n", dtd->dtd_total); | 689 | dev_vdbg(&dev->pdev->dev, "dtd->dtd_total = %d\n", dtd->dtd_total); |
712 | 690 | ||
713 | /* set is_last flag if req->req.zero is set or not */ | 691 | /* set is_last flag if req->req.zero is set or not */ |
714 | if (req->req.zero) { | 692 | if (req->req.zero) { |
@@ -722,7 +700,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, | |||
722 | *is_last = 0; | 700 | *is_last = 0; |
723 | 701 | ||
724 | if (*is_last == 0) | 702 | if (*is_last == 0) |
725 | VDBG(dev, "multi-dtd request!\n"); | 703 | dev_vdbg(&dev->pdev->dev, "multi-dtd request!\n"); |
726 | 704 | ||
727 | /* set interrupt on complete bit for the last dTD */ | 705 | /* set interrupt on complete bit for the last dTD */ |
728 | if (*is_last && !req->req.no_interrupt) | 706 | if (*is_last && !req->req.no_interrupt) |
@@ -733,10 +711,12 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, | |||
733 | 711 | ||
734 | /* set the active bit of status field to 1 */ | 712 | /* set the active bit of status field to 1 */ |
735 | dtd->dtd_status = DTD_STS_ACTIVE; | 713 | dtd->dtd_status = DTD_STS_ACTIVE; |
736 | VDBG(dev, "dtd->dtd_status = 0x%02x\n", dtd->dtd_status); | 714 | dev_vdbg(&dev->pdev->dev, "dtd->dtd_status = 0x%02x\n", |
715 | dtd->dtd_status); | ||
737 | 716 | ||
738 | VDBG(dev, "length = %d, dma addr= 0x%08x\n", *length, (int)*dma); | 717 | dev_vdbg(&dev->pdev->dev, "length = %d, dma addr= 0x%08x\n", |
739 | VDBG(dev, "<--- %s()\n", __func__); | 718 | *length, (int)*dma); |
719 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
740 | return dtd; | 720 | return dtd; |
741 | } | 721 | } |
742 | 722 | ||
@@ -751,7 +731,7 @@ static int req_to_dtd(struct langwell_request *req) | |||
751 | dma_addr_t dma; | 731 | dma_addr_t dma; |
752 | 732 | ||
753 | dev = req->ep->dev; | 733 | dev = req->ep->dev; |
754 | VDBG(dev, "---> %s()\n", __func__); | 734 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
755 | do { | 735 | do { |
756 | dtd = build_dtd(req, &count, &dma, &is_last); | 736 | dtd = build_dtd(req, &count, &dma, &is_last); |
757 | if (dtd == NULL) | 737 | if (dtd == NULL) |
@@ -773,7 +753,7 @@ static int req_to_dtd(struct langwell_request *req) | |||
773 | 753 | ||
774 | req->tail = dtd; | 754 | req->tail = dtd; |
775 | 755 | ||
776 | VDBG(dev, "<--- %s()\n", __func__); | 756 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
777 | return 0; | 757 | return 0; |
778 | } | 758 | } |
779 | 759 | ||
@@ -803,9 +783,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
803 | 783 | ||
804 | dev = ep->dev; | 784 | dev = ep->dev; |
805 | req->ep = ep; | 785 | req->ep = ep; |
806 | VDBG(dev, "---> %s()\n", __func__); | 786 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
807 | 787 | ||
808 | if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { | 788 | if (usb_endpoint_xfer_isoc(ep->desc)) { |
809 | if (req->req.length > ep->ep.maxpacket) | 789 | if (req->req.length > ep->ep.maxpacket) |
810 | return -EMSGSIZE; | 790 | return -EMSGSIZE; |
811 | is_iso = 1; | 791 | is_iso = 1; |
@@ -818,7 +798,7 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
818 | if (_req->dma == DMA_ADDR_INVALID) { | 798 | if (_req->dma == DMA_ADDR_INVALID) { |
819 | /* WORKAROUND: WARN_ON(size == 0) */ | 799 | /* WORKAROUND: WARN_ON(size == 0) */ |
820 | if (_req->length == 0) { | 800 | if (_req->length == 0) { |
821 | VDBG(dev, "req->length: 0->1\n"); | 801 | dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n"); |
822 | zlflag = 1; | 802 | zlflag = 1; |
823 | _req->length++; | 803 | _req->length++; |
824 | } | 804 | } |
@@ -827,24 +807,25 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
827 | _req->buf, _req->length, | 807 | _req->buf, _req->length, |
828 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 808 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
829 | if (zlflag && (_req->length == 1)) { | 809 | if (zlflag && (_req->length == 1)) { |
830 | VDBG(dev, "req->length: 1->0\n"); | 810 | dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n"); |
831 | zlflag = 0; | 811 | zlflag = 0; |
832 | _req->length = 0; | 812 | _req->length = 0; |
833 | } | 813 | } |
834 | 814 | ||
835 | req->mapped = 1; | 815 | req->mapped = 1; |
836 | VDBG(dev, "req->mapped = 1\n"); | 816 | dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n"); |
837 | } else { | 817 | } else { |
838 | dma_sync_single_for_device(&dev->pdev->dev, | 818 | dma_sync_single_for_device(&dev->pdev->dev, |
839 | _req->dma, _req->length, | 819 | _req->dma, _req->length, |
840 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 820 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
841 | req->mapped = 0; | 821 | req->mapped = 0; |
842 | VDBG(dev, "req->mapped = 0\n"); | 822 | dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n"); |
843 | } | 823 | } |
844 | 824 | ||
845 | DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08llx\n", | 825 | dev_dbg(&dev->pdev->dev, |
846 | _ep->name, | 826 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", |
847 | _req, _req->length, _req->buf, (unsigned long long)_req->dma); | 827 | _ep->name, |
828 | _req, _req->length, _req->buf, (int)_req->dma); | ||
848 | 829 | ||
849 | _req->status = -EINPROGRESS; | 830 | _req->status = -EINPROGRESS; |
850 | _req->actual = 0; | 831 | _req->actual = 0; |
@@ -866,12 +847,12 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
866 | 847 | ||
867 | if (likely(req != NULL)) { | 848 | if (likely(req != NULL)) { |
868 | list_add_tail(&req->queue, &ep->queue); | 849 | list_add_tail(&req->queue, &ep->queue); |
869 | VDBG(dev, "list_add_tail() \n"); | 850 | dev_vdbg(&dev->pdev->dev, "list_add_tail()\n"); |
870 | } | 851 | } |
871 | 852 | ||
872 | spin_unlock_irqrestore(&dev->lock, flags); | 853 | spin_unlock_irqrestore(&dev->lock, flags); |
873 | 854 | ||
874 | VDBG(dev, "<--- %s()\n", __func__); | 855 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
875 | return 0; | 856 | return 0; |
876 | } | 857 | } |
877 | 858 | ||
@@ -888,7 +869,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
888 | 869 | ||
889 | ep = container_of(_ep, struct langwell_ep, ep); | 870 | ep = container_of(_ep, struct langwell_ep, ep); |
890 | dev = ep->dev; | 871 | dev = ep->dev; |
891 | VDBG(dev, "---> %s()\n", __func__); | 872 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
892 | 873 | ||
893 | if (!_ep || !ep->desc || !_req) | 874 | if (!_ep || !ep->desc || !_req) |
894 | return -EINVAL; | 875 | return -EINVAL; |
@@ -924,7 +905,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
924 | 905 | ||
925 | /* queue head may be partially complete. */ | 906 | /* queue head may be partially complete. */ |
926 | if (ep->queue.next == &req->queue) { | 907 | if (ep->queue.next == &req->queue) { |
927 | DBG(dev, "unlink (%s) dma\n", _ep->name); | 908 | dev_dbg(&dev->pdev->dev, "unlink (%s) dma\n", _ep->name); |
928 | _req->status = -ECONNRESET; | 909 | _req->status = -ECONNRESET; |
929 | langwell_ep_fifo_flush(&ep->ep); | 910 | langwell_ep_fifo_flush(&ep->ep); |
930 | 911 | ||
@@ -963,7 +944,7 @@ done: | |||
963 | ep->stopped = stopped; | 944 | ep->stopped = stopped; |
964 | spin_unlock_irqrestore(&dev->lock, flags); | 945 | spin_unlock_irqrestore(&dev->lock, flags); |
965 | 946 | ||
966 | VDBG(dev, "<--- %s()\n", __func__); | 947 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
967 | return retval; | 948 | return retval; |
968 | } | 949 | } |
969 | 950 | ||
@@ -976,7 +957,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value) | |||
976 | u32 endptctrl = 0; | 957 | u32 endptctrl = 0; |
977 | int ep_num; | 958 | int ep_num; |
978 | struct langwell_udc *dev = ep->dev; | 959 | struct langwell_udc *dev = ep->dev; |
979 | VDBG(dev, "---> %s()\n", __func__); | 960 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
980 | 961 | ||
981 | ep_num = ep->ep_num; | 962 | ep_num = ep->ep_num; |
982 | endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); | 963 | endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); |
@@ -1001,7 +982,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value) | |||
1001 | 982 | ||
1002 | writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); | 983 | writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); |
1003 | 984 | ||
1004 | VDBG(dev, "<--- %s()\n", __func__); | 985 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1005 | } | 986 | } |
1006 | 987 | ||
1007 | 988 | ||
@@ -1016,7 +997,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) | |||
1016 | ep = container_of(_ep, struct langwell_ep, ep); | 997 | ep = container_of(_ep, struct langwell_ep, ep); |
1017 | dev = ep->dev; | 998 | dev = ep->dev; |
1018 | 999 | ||
1019 | VDBG(dev, "---> %s()\n", __func__); | 1000 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1020 | 1001 | ||
1021 | if (!_ep || !ep->desc) | 1002 | if (!_ep || !ep->desc) |
1022 | return -EINVAL; | 1003 | return -EINVAL; |
@@ -1024,8 +1005,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) | |||
1024 | if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) | 1005 | if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) |
1025 | return -ESHUTDOWN; | 1006 | return -ESHUTDOWN; |
1026 | 1007 | ||
1027 | if (ep->desc && (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | 1008 | if (usb_endpoint_xfer_isoc(ep->desc)) |
1028 | == USB_ENDPOINT_XFER_ISOC) | ||
1029 | return -EOPNOTSUPP; | 1009 | return -EOPNOTSUPP; |
1030 | 1010 | ||
1031 | spin_lock_irqsave(&dev->lock, flags); | 1011 | spin_lock_irqsave(&dev->lock, flags); |
@@ -1036,7 +1016,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) | |||
1036 | */ | 1016 | */ |
1037 | if (!list_empty(&ep->queue) && is_in(ep) && value) { | 1017 | if (!list_empty(&ep->queue) && is_in(ep) && value) { |
1038 | /* IN endpoint FIFO holds bytes */ | 1018 | /* IN endpoint FIFO holds bytes */ |
1039 | DBG(dev, "%s FIFO holds bytes\n", _ep->name); | 1019 | dev_dbg(&dev->pdev->dev, "%s FIFO holds bytes\n", _ep->name); |
1040 | retval = -EAGAIN; | 1020 | retval = -EAGAIN; |
1041 | goto done; | 1021 | goto done; |
1042 | } | 1022 | } |
@@ -1050,8 +1030,9 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) | |||
1050 | } | 1030 | } |
1051 | done: | 1031 | done: |
1052 | spin_unlock_irqrestore(&dev->lock, flags); | 1032 | spin_unlock_irqrestore(&dev->lock, flags); |
1053 | DBG(dev, "%s %s halt\n", _ep->name, value ? "set" : "clear"); | 1033 | dev_dbg(&dev->pdev->dev, "%s %s halt\n", |
1054 | VDBG(dev, "<--- %s()\n", __func__); | 1034 | _ep->name, value ? "set" : "clear"); |
1035 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
1055 | return retval; | 1036 | return retval; |
1056 | } | 1037 | } |
1057 | 1038 | ||
@@ -1065,12 +1046,12 @@ static int langwell_ep_set_wedge(struct usb_ep *_ep) | |||
1065 | ep = container_of(_ep, struct langwell_ep, ep); | 1046 | ep = container_of(_ep, struct langwell_ep, ep); |
1066 | dev = ep->dev; | 1047 | dev = ep->dev; |
1067 | 1048 | ||
1068 | VDBG(dev, "---> %s()\n", __func__); | 1049 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1069 | 1050 | ||
1070 | if (!_ep || !ep->desc) | 1051 | if (!_ep || !ep->desc) |
1071 | return -EINVAL; | 1052 | return -EINVAL; |
1072 | 1053 | ||
1073 | VDBG(dev, "<--- %s()\n", __func__); | 1054 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1074 | return usb_ep_set_halt(_ep); | 1055 | return usb_ep_set_halt(_ep); |
1075 | } | 1056 | } |
1076 | 1057 | ||
@@ -1086,15 +1067,16 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep) | |||
1086 | ep = container_of(_ep, struct langwell_ep, ep); | 1067 | ep = container_of(_ep, struct langwell_ep, ep); |
1087 | dev = ep->dev; | 1068 | dev = ep->dev; |
1088 | 1069 | ||
1089 | VDBG(dev, "---> %s()\n", __func__); | 1070 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1090 | 1071 | ||
1091 | if (!_ep || !ep->desc) { | 1072 | if (!_ep || !ep->desc) { |
1092 | VDBG(dev, "ep or ep->desc is NULL\n"); | 1073 | dev_vdbg(&dev->pdev->dev, "ep or ep->desc is NULL\n"); |
1093 | VDBG(dev, "<--- %s()\n", __func__); | 1074 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1094 | return; | 1075 | return; |
1095 | } | 1076 | } |
1096 | 1077 | ||
1097 | VDBG(dev, "%s-%s fifo flush\n", _ep->name, is_in(ep) ? "in" : "out"); | 1078 | dev_vdbg(&dev->pdev->dev, "%s-%s fifo flush\n", |
1079 | _ep->name, DIR_STRING(ep)); | ||
1098 | 1080 | ||
1099 | /* flush endpoint buffer */ | 1081 | /* flush endpoint buffer */ |
1100 | if (ep->ep_num == 0) | 1082 | if (ep->ep_num == 0) |
@@ -1110,14 +1092,14 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep) | |||
1110 | writel(flush_bit, &dev->op_regs->endptflush); | 1092 | writel(flush_bit, &dev->op_regs->endptflush); |
1111 | while (readl(&dev->op_regs->endptflush)) { | 1093 | while (readl(&dev->op_regs->endptflush)) { |
1112 | if (time_after(jiffies, timeout)) { | 1094 | if (time_after(jiffies, timeout)) { |
1113 | ERROR(dev, "ep flush timeout\n"); | 1095 | dev_err(&dev->pdev->dev, "ep flush timeout\n"); |
1114 | goto done; | 1096 | goto done; |
1115 | } | 1097 | } |
1116 | cpu_relax(); | 1098 | cpu_relax(); |
1117 | } | 1099 | } |
1118 | } while (readl(&dev->op_regs->endptstat) & flush_bit); | 1100 | } while (readl(&dev->op_regs->endptstat) & flush_bit); |
1119 | done: | 1101 | done: |
1120 | VDBG(dev, "<--- %s()\n", __func__); | 1102 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1121 | } | 1103 | } |
1122 | 1104 | ||
1123 | 1105 | ||
@@ -1167,31 +1149,59 @@ static int langwell_get_frame(struct usb_gadget *_gadget) | |||
1167 | return -ENODEV; | 1149 | return -ENODEV; |
1168 | 1150 | ||
1169 | dev = container_of(_gadget, struct langwell_udc, gadget); | 1151 | dev = container_of(_gadget, struct langwell_udc, gadget); |
1170 | VDBG(dev, "---> %s()\n", __func__); | 1152 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1171 | 1153 | ||
1172 | retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK; | 1154 | retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK; |
1173 | 1155 | ||
1174 | VDBG(dev, "<--- %s()\n", __func__); | 1156 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1175 | return retval; | 1157 | return retval; |
1176 | } | 1158 | } |
1177 | 1159 | ||
1178 | 1160 | ||
1161 | /* enter or exit PHY low power state */ | ||
1162 | static void langwell_phy_low_power(struct langwell_udc *dev, bool flag) | ||
1163 | { | ||
1164 | u32 devlc; | ||
1165 | u8 devlc_byte2; | ||
1166 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); | ||
1167 | |||
1168 | devlc = readl(&dev->op_regs->devlc); | ||
1169 | dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc); | ||
1170 | |||
1171 | if (flag) | ||
1172 | devlc |= LPM_PHCD; | ||
1173 | else | ||
1174 | devlc &= ~LPM_PHCD; | ||
1175 | |||
1176 | /* FIXME: workaround for Langwell A1/A2/A3 sighting */ | ||
1177 | devlc_byte2 = (devlc >> 16) & 0xff; | ||
1178 | writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2); | ||
1179 | |||
1180 | devlc = readl(&dev->op_regs->devlc); | ||
1181 | dev_vdbg(&dev->pdev->dev, | ||
1182 | "%s PHY low power suspend, devlc = 0x%08x\n", | ||
1183 | flag ? "enter" : "exit", devlc); | ||
1184 | } | ||
1185 | |||
1186 | |||
1179 | /* tries to wake up the host connected to this gadget */ | 1187 | /* tries to wake up the host connected to this gadget */ |
1180 | static int langwell_wakeup(struct usb_gadget *_gadget) | 1188 | static int langwell_wakeup(struct usb_gadget *_gadget) |
1181 | { | 1189 | { |
1182 | struct langwell_udc *dev; | 1190 | struct langwell_udc *dev; |
1183 | u32 portsc1, devlc; | 1191 | u32 portsc1; |
1184 | unsigned long flags; | 1192 | unsigned long flags; |
1185 | 1193 | ||
1186 | if (!_gadget) | 1194 | if (!_gadget) |
1187 | return 0; | 1195 | return 0; |
1188 | 1196 | ||
1189 | dev = container_of(_gadget, struct langwell_udc, gadget); | 1197 | dev = container_of(_gadget, struct langwell_udc, gadget); |
1190 | VDBG(dev, "---> %s()\n", __func__); | 1198 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1191 | 1199 | ||
1192 | /* Remote Wakeup feature not enabled by host */ | 1200 | /* remote wakeup feature not enabled by host */ |
1193 | if (!dev->remote_wakeup) | 1201 | if (!dev->remote_wakeup) { |
1202 | dev_info(&dev->pdev->dev, "remote wakeup is disabled\n"); | ||
1194 | return -ENOTSUPP; | 1203 | return -ENOTSUPP; |
1204 | } | ||
1195 | 1205 | ||
1196 | spin_lock_irqsave(&dev->lock, flags); | 1206 | spin_lock_irqsave(&dev->lock, flags); |
1197 | 1207 | ||
@@ -1201,27 +1211,23 @@ static int langwell_wakeup(struct usb_gadget *_gadget) | |||
1201 | return 0; | 1211 | return 0; |
1202 | } | 1212 | } |
1203 | 1213 | ||
1204 | /* LPM L1 to L0, remote wakeup */ | 1214 | /* LPM L1 to L0 or legacy remote wakeup */ |
1205 | if (dev->lpm && dev->lpm_state == LPM_L1) { | 1215 | if (dev->lpm && dev->lpm_state == LPM_L1) |
1206 | portsc1 |= PORTS_SLP; | 1216 | dev_info(&dev->pdev->dev, "LPM L1 to L0 remote wakeup\n"); |
1207 | writel(portsc1, &dev->op_regs->portsc1); | 1217 | else |
1208 | } | 1218 | dev_info(&dev->pdev->dev, "device remote wakeup\n"); |
1209 | |||
1210 | /* force port resume */ | ||
1211 | if (dev->usb_state == USB_STATE_SUSPENDED) { | ||
1212 | portsc1 |= PORTS_FPR; | ||
1213 | writel(portsc1, &dev->op_regs->portsc1); | ||
1214 | } | ||
1215 | 1219 | ||
1216 | /* exit PHY low power suspend */ | 1220 | /* exit PHY low power suspend */ |
1217 | devlc = readl(&dev->op_regs->devlc); | 1221 | if (dev->pdev->device != 0x0829) |
1218 | VDBG(dev, "devlc = 0x%08x\n", devlc); | 1222 | langwell_phy_low_power(dev, 0); |
1219 | devlc &= ~LPM_PHCD; | 1223 | |
1220 | writel(devlc, &dev->op_regs->devlc); | 1224 | /* force port resume */ |
1225 | portsc1 |= PORTS_FPR; | ||
1226 | writel(portsc1, &dev->op_regs->portsc1); | ||
1221 | 1227 | ||
1222 | spin_unlock_irqrestore(&dev->lock, flags); | 1228 | spin_unlock_irqrestore(&dev->lock, flags); |
1223 | 1229 | ||
1224 | VDBG(dev, "<--- %s()\n", __func__); | 1230 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1225 | return 0; | 1231 | return 0; |
1226 | } | 1232 | } |
1227 | 1233 | ||
@@ -1231,16 +1237,17 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active) | |||
1231 | { | 1237 | { |
1232 | struct langwell_udc *dev; | 1238 | struct langwell_udc *dev; |
1233 | unsigned long flags; | 1239 | unsigned long flags; |
1234 | u32 usbcmd; | 1240 | u32 usbcmd; |
1235 | 1241 | ||
1236 | if (!_gadget) | 1242 | if (!_gadget) |
1237 | return -ENODEV; | 1243 | return -ENODEV; |
1238 | 1244 | ||
1239 | dev = container_of(_gadget, struct langwell_udc, gadget); | 1245 | dev = container_of(_gadget, struct langwell_udc, gadget); |
1240 | VDBG(dev, "---> %s()\n", __func__); | 1246 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1241 | 1247 | ||
1242 | spin_lock_irqsave(&dev->lock, flags); | 1248 | spin_lock_irqsave(&dev->lock, flags); |
1243 | VDBG(dev, "VBUS status: %s\n", is_active ? "on" : "off"); | 1249 | dev_vdbg(&dev->pdev->dev, "VBUS status: %s\n", |
1250 | is_active ? "on" : "off"); | ||
1244 | 1251 | ||
1245 | dev->vbus_active = (is_active != 0); | 1252 | dev->vbus_active = (is_active != 0); |
1246 | if (dev->driver && dev->softconnected && dev->vbus_active) { | 1253 | if (dev->driver && dev->softconnected && dev->vbus_active) { |
@@ -1255,7 +1262,7 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active) | |||
1255 | 1262 | ||
1256 | spin_unlock_irqrestore(&dev->lock, flags); | 1263 | spin_unlock_irqrestore(&dev->lock, flags); |
1257 | 1264 | ||
1258 | VDBG(dev, "<--- %s()\n", __func__); | 1265 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1259 | return 0; | 1266 | return 0; |
1260 | } | 1267 | } |
1261 | 1268 | ||
@@ -1269,15 +1276,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1269 | return -ENODEV; | 1276 | return -ENODEV; |
1270 | 1277 | ||
1271 | dev = container_of(_gadget, struct langwell_udc, gadget); | 1278 | dev = container_of(_gadget, struct langwell_udc, gadget); |
1272 | VDBG(dev, "---> %s()\n", __func__); | 1279 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1273 | 1280 | ||
1274 | if (dev->transceiver) { | 1281 | if (dev->transceiver) { |
1275 | VDBG(dev, "otg_set_power\n"); | 1282 | dev_vdbg(&dev->pdev->dev, "otg_set_power\n"); |
1276 | VDBG(dev, "<--- %s()\n", __func__); | 1283 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1277 | return otg_set_power(dev->transceiver, mA); | 1284 | return otg_set_power(dev->transceiver, mA); |
1278 | } | 1285 | } |
1279 | 1286 | ||
1280 | VDBG(dev, "<--- %s()\n", __func__); | 1287 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1281 | return -ENOTSUPP; | 1288 | return -ENOTSUPP; |
1282 | } | 1289 | } |
1283 | 1290 | ||
@@ -1286,15 +1293,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1286 | static int langwell_pullup(struct usb_gadget *_gadget, int is_on) | 1293 | static int langwell_pullup(struct usb_gadget *_gadget, int is_on) |
1287 | { | 1294 | { |
1288 | struct langwell_udc *dev; | 1295 | struct langwell_udc *dev; |
1289 | u32 usbcmd; | 1296 | u32 usbcmd; |
1290 | unsigned long flags; | 1297 | unsigned long flags; |
1291 | 1298 | ||
1292 | if (!_gadget) | 1299 | if (!_gadget) |
1293 | return -ENODEV; | 1300 | return -ENODEV; |
1294 | 1301 | ||
1295 | dev = container_of(_gadget, struct langwell_udc, gadget); | 1302 | dev = container_of(_gadget, struct langwell_udc, gadget); |
1296 | 1303 | ||
1297 | VDBG(dev, "---> %s()\n", __func__); | 1304 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1298 | 1305 | ||
1299 | spin_lock_irqsave(&dev->lock, flags); | 1306 | spin_lock_irqsave(&dev->lock, flags); |
1300 | dev->softconnected = (is_on != 0); | 1307 | dev->softconnected = (is_on != 0); |
@@ -1310,7 +1317,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on) | |||
1310 | } | 1317 | } |
1311 | spin_unlock_irqrestore(&dev->lock, flags); | 1318 | spin_unlock_irqrestore(&dev->lock, flags); |
1312 | 1319 | ||
1313 | VDBG(dev, "<--- %s()\n", __func__); | 1320 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1314 | return 0; | 1321 | return 0; |
1315 | } | 1322 | } |
1316 | 1323 | ||
@@ -1346,12 +1353,13 @@ static const struct usb_gadget_ops langwell_ops = { | |||
1346 | static int langwell_udc_reset(struct langwell_udc *dev) | 1353 | static int langwell_udc_reset(struct langwell_udc *dev) |
1347 | { | 1354 | { |
1348 | u32 usbcmd, usbmode, devlc, endpointlistaddr; | 1355 | u32 usbcmd, usbmode, devlc, endpointlistaddr; |
1356 | u8 devlc_byte0, devlc_byte2; | ||
1349 | unsigned long timeout; | 1357 | unsigned long timeout; |
1350 | 1358 | ||
1351 | if (!dev) | 1359 | if (!dev) |
1352 | return -EINVAL; | 1360 | return -EINVAL; |
1353 | 1361 | ||
1354 | DBG(dev, "---> %s()\n", __func__); | 1362 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1355 | 1363 | ||
1356 | /* set controller to stop state */ | 1364 | /* set controller to stop state */ |
1357 | usbcmd = readl(&dev->op_regs->usbcmd); | 1365 | usbcmd = readl(&dev->op_regs->usbcmd); |
@@ -1367,7 +1375,7 @@ static int langwell_udc_reset(struct langwell_udc *dev) | |||
1367 | timeout = jiffies + RESET_TIMEOUT; | 1375 | timeout = jiffies + RESET_TIMEOUT; |
1368 | while (readl(&dev->op_regs->usbcmd) & CMD_RST) { | 1376 | while (readl(&dev->op_regs->usbcmd) & CMD_RST) { |
1369 | if (time_after(jiffies, timeout)) { | 1377 | if (time_after(jiffies, timeout)) { |
1370 | ERROR(dev, "device reset timeout\n"); | 1378 | dev_err(&dev->pdev->dev, "device reset timeout\n"); |
1371 | return -ETIMEDOUT; | 1379 | return -ETIMEDOUT; |
1372 | } | 1380 | } |
1373 | cpu_relax(); | 1381 | cpu_relax(); |
@@ -1382,7 +1390,7 @@ static int langwell_udc_reset(struct langwell_udc *dev) | |||
1382 | 1390 | ||
1383 | writel(usbmode, &dev->op_regs->usbmode); | 1391 | writel(usbmode, &dev->op_regs->usbmode); |
1384 | usbmode = readl(&dev->op_regs->usbmode); | 1392 | usbmode = readl(&dev->op_regs->usbmode); |
1385 | VDBG(dev, "usbmode=0x%08x\n", usbmode); | 1393 | dev_vdbg(&dev->pdev->dev, "usbmode=0x%08x\n", usbmode); |
1386 | 1394 | ||
1387 | /* Write-Clear setup status */ | 1395 | /* Write-Clear setup status */ |
1388 | writel(0, &dev->op_regs->usbsts); | 1396 | writel(0, &dev->op_regs->usbsts); |
@@ -1390,9 +1398,17 @@ static int langwell_udc_reset(struct langwell_udc *dev) | |||
1390 | /* if support USB LPM, ACK all LPM token */ | 1398 | /* if support USB LPM, ACK all LPM token */ |
1391 | if (dev->lpm) { | 1399 | if (dev->lpm) { |
1392 | devlc = readl(&dev->op_regs->devlc); | 1400 | devlc = readl(&dev->op_regs->devlc); |
1401 | dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc); | ||
1402 | /* FIXME: workaround for Langwell A1/A2/A3 sighting */ | ||
1393 | devlc &= ~LPM_STL; /* don't STALL LPM token */ | 1403 | devlc &= ~LPM_STL; /* don't STALL LPM token */ |
1394 | devlc &= ~LPM_NYT_ACK; /* ACK LPM token */ | 1404 | devlc &= ~LPM_NYT_ACK; /* ACK LPM token */ |
1395 | writel(devlc, &dev->op_regs->devlc); | 1405 | devlc_byte0 = devlc & 0xff; |
1406 | devlc_byte2 = (devlc >> 16) & 0xff; | ||
1407 | writeb(devlc_byte0, (u8 *)&dev->op_regs->devlc); | ||
1408 | writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2); | ||
1409 | devlc = readl(&dev->op_regs->devlc); | ||
1410 | dev_vdbg(&dev->pdev->dev, | ||
1411 | "ACK LPM token, devlc = 0x%08x\n", devlc); | ||
1396 | } | 1412 | } |
1397 | 1413 | ||
1398 | /* fill endpointlistaddr register */ | 1414 | /* fill endpointlistaddr register */ |
@@ -1400,10 +1416,11 @@ static int langwell_udc_reset(struct langwell_udc *dev) | |||
1400 | endpointlistaddr &= ENDPOINTLISTADDR_MASK; | 1416 | endpointlistaddr &= ENDPOINTLISTADDR_MASK; |
1401 | writel(endpointlistaddr, &dev->op_regs->endpointlistaddr); | 1417 | writel(endpointlistaddr, &dev->op_regs->endpointlistaddr); |
1402 | 1418 | ||
1403 | VDBG(dev, "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n", | 1419 | dev_vdbg(&dev->pdev->dev, |
1404 | dev->ep_dqh, endpointlistaddr, | 1420 | "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n", |
1405 | readl(&dev->op_regs->endpointlistaddr)); | 1421 | dev->ep_dqh, endpointlistaddr, |
1406 | DBG(dev, "<--- %s()\n", __func__); | 1422 | readl(&dev->op_regs->endpointlistaddr)); |
1423 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
1407 | return 0; | 1424 | return 0; |
1408 | } | 1425 | } |
1409 | 1426 | ||
@@ -1415,7 +1432,7 @@ static int eps_reinit(struct langwell_udc *dev) | |||
1415 | char name[14]; | 1432 | char name[14]; |
1416 | int i; | 1433 | int i; |
1417 | 1434 | ||
1418 | VDBG(dev, "---> %s()\n", __func__); | 1435 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1419 | 1436 | ||
1420 | /* initialize ep0 */ | 1437 | /* initialize ep0 */ |
1421 | ep = &dev->ep[0]; | 1438 | ep = &dev->ep[0]; |
@@ -1449,11 +1466,9 @@ static int eps_reinit(struct langwell_udc *dev) | |||
1449 | 1466 | ||
1450 | INIT_LIST_HEAD(&ep->queue); | 1467 | INIT_LIST_HEAD(&ep->queue); |
1451 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); | 1468 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); |
1452 | |||
1453 | ep->dqh = &dev->ep_dqh[i]; | ||
1454 | } | 1469 | } |
1455 | 1470 | ||
1456 | VDBG(dev, "<--- %s()\n", __func__); | 1471 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1457 | return 0; | 1472 | return 0; |
1458 | } | 1473 | } |
1459 | 1474 | ||
@@ -1462,7 +1477,7 @@ static int eps_reinit(struct langwell_udc *dev) | |||
1462 | static void langwell_udc_start(struct langwell_udc *dev) | 1477 | static void langwell_udc_start(struct langwell_udc *dev) |
1463 | { | 1478 | { |
1464 | u32 usbintr, usbcmd; | 1479 | u32 usbintr, usbcmd; |
1465 | DBG(dev, "---> %s()\n", __func__); | 1480 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1466 | 1481 | ||
1467 | /* enable interrupts */ | 1482 | /* enable interrupts */ |
1468 | usbintr = INTR_ULPIE /* ULPI */ | 1483 | usbintr = INTR_ULPIE /* ULPI */ |
@@ -1485,8 +1500,7 @@ static void langwell_udc_start(struct langwell_udc *dev) | |||
1485 | usbcmd |= CMD_RUNSTOP; | 1500 | usbcmd |= CMD_RUNSTOP; |
1486 | writel(usbcmd, &dev->op_regs->usbcmd); | 1501 | writel(usbcmd, &dev->op_regs->usbcmd); |
1487 | 1502 | ||
1488 | DBG(dev, "<--- %s()\n", __func__); | 1503 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1489 | return; | ||
1490 | } | 1504 | } |
1491 | 1505 | ||
1492 | 1506 | ||
@@ -1495,7 +1509,7 @@ static void langwell_udc_stop(struct langwell_udc *dev) | |||
1495 | { | 1509 | { |
1496 | u32 usbcmd; | 1510 | u32 usbcmd; |
1497 | 1511 | ||
1498 | DBG(dev, "---> %s()\n", __func__); | 1512 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1499 | 1513 | ||
1500 | /* disable all interrupts */ | 1514 | /* disable all interrupts */ |
1501 | writel(0, &dev->op_regs->usbintr); | 1515 | writel(0, &dev->op_regs->usbintr); |
@@ -1508,8 +1522,7 @@ static void langwell_udc_stop(struct langwell_udc *dev) | |||
1508 | usbcmd &= ~CMD_RUNSTOP; | 1522 | usbcmd &= ~CMD_RUNSTOP; |
1509 | writel(usbcmd, &dev->op_regs->usbcmd); | 1523 | writel(usbcmd, &dev->op_regs->usbcmd); |
1510 | 1524 | ||
1511 | DBG(dev, "<--- %s()\n", __func__); | 1525 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1512 | return; | ||
1513 | } | 1526 | } |
1514 | 1527 | ||
1515 | 1528 | ||
@@ -1518,7 +1531,7 @@ static void stop_activity(struct langwell_udc *dev, | |||
1518 | struct usb_gadget_driver *driver) | 1531 | struct usb_gadget_driver *driver) |
1519 | { | 1532 | { |
1520 | struct langwell_ep *ep; | 1533 | struct langwell_ep *ep; |
1521 | DBG(dev, "---> %s()\n", __func__); | 1534 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1522 | 1535 | ||
1523 | nuke(&dev->ep[0], -ESHUTDOWN); | 1536 | nuke(&dev->ep[0], -ESHUTDOWN); |
1524 | 1537 | ||
@@ -1533,7 +1546,7 @@ static void stop_activity(struct langwell_udc *dev, | |||
1533 | spin_lock(&dev->lock); | 1546 | spin_lock(&dev->lock); |
1534 | } | 1547 | } |
1535 | 1548 | ||
1536 | DBG(dev, "<--- %s()\n", __func__); | 1549 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1537 | } | 1550 | } |
1538 | 1551 | ||
1539 | 1552 | ||
@@ -1659,13 +1672,15 @@ static ssize_t show_langwell_udc(struct device *_dev, | |||
1659 | "Over-current Change: %s\n" | 1672 | "Over-current Change: %s\n" |
1660 | "Port Enable/Disable Change: %s\n" | 1673 | "Port Enable/Disable Change: %s\n" |
1661 | "Port Enabled/Disabled: %s\n" | 1674 | "Port Enabled/Disabled: %s\n" |
1662 | "Current Connect Status: %s\n\n", | 1675 | "Current Connect Status: %s\n" |
1676 | "LPM Suspend Status: %s\n\n", | ||
1663 | (tmp_reg & PORTS_PR) ? "Reset" : "Not Reset", | 1677 | (tmp_reg & PORTS_PR) ? "Reset" : "Not Reset", |
1664 | (tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend", | 1678 | (tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend", |
1665 | (tmp_reg & PORTS_OCC) ? "Detected" : "No", | 1679 | (tmp_reg & PORTS_OCC) ? "Detected" : "No", |
1666 | (tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed", | 1680 | (tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed", |
1667 | (tmp_reg & PORTS_PE) ? "Enable" : "Not Correct", | 1681 | (tmp_reg & PORTS_PE) ? "Enable" : "Not Correct", |
1668 | (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached"); | 1682 | (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached", |
1683 | (tmp_reg & PORTS_SLP) ? "LPM L1" : "LPM L0"); | ||
1669 | size -= t; | 1684 | size -= t; |
1670 | next += t; | 1685 | next += t; |
1671 | 1686 | ||
@@ -1676,7 +1691,7 @@ static ssize_t show_langwell_udc(struct device *_dev, | |||
1676 | "Serial Transceiver : %d\n" | 1691 | "Serial Transceiver : %d\n" |
1677 | "Port Speed: %s\n" | 1692 | "Port Speed: %s\n" |
1678 | "Port Force Full Speed Connenct: %s\n" | 1693 | "Port Force Full Speed Connenct: %s\n" |
1679 | "PHY Low Power Suspend Clock Disable: %s\n" | 1694 | "PHY Low Power Suspend Clock: %s\n" |
1680 | "BmAttributes: %d\n\n", | 1695 | "BmAttributes: %d\n\n", |
1681 | LPM_PTS(tmp_reg), | 1696 | LPM_PTS(tmp_reg), |
1682 | (tmp_reg & LPM_STS) ? 1 : 0, | 1697 | (tmp_reg & LPM_STS) ? 1 : 0, |
@@ -1797,6 +1812,36 @@ static ssize_t show_langwell_udc(struct device *_dev, | |||
1797 | static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL); | 1812 | static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL); |
1798 | 1813 | ||
1799 | 1814 | ||
1815 | /* device "remote_wakeup" sysfs attribute file */ | ||
1816 | static ssize_t store_remote_wakeup(struct device *_dev, | ||
1817 | struct device_attribute *attr, const char *buf, size_t count) | ||
1818 | { | ||
1819 | struct langwell_udc *dev = the_controller; | ||
1820 | unsigned long flags; | ||
1821 | ssize_t rc = count; | ||
1822 | |||
1823 | if (count > 2) | ||
1824 | return -EINVAL; | ||
1825 | |||
1826 | if (count > 0 && buf[count-1] == '\n') | ||
1827 | ((char *) buf)[count-1] = 0; | ||
1828 | |||
1829 | if (buf[0] != '1') | ||
1830 | return -EINVAL; | ||
1831 | |||
1832 | /* force remote wakeup enabled in case gadget driver doesn't support */ | ||
1833 | spin_lock_irqsave(&dev->lock, flags); | ||
1834 | dev->remote_wakeup = 1; | ||
1835 | dev->dev_status |= (1 << USB_DEVICE_REMOTE_WAKEUP); | ||
1836 | spin_unlock_irqrestore(&dev->lock, flags); | ||
1837 | |||
1838 | langwell_wakeup(&dev->gadget); | ||
1839 | |||
1840 | return rc; | ||
1841 | } | ||
1842 | static DEVICE_ATTR(remote_wakeup, S_IWUSR, NULL, store_remote_wakeup); | ||
1843 | |||
1844 | |||
1800 | /*-------------------------------------------------------------------------*/ | 1845 | /*-------------------------------------------------------------------------*/ |
1801 | 1846 | ||
1802 | /* | 1847 | /* |
@@ -1807,7 +1852,8 @@ static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL); | |||
1807 | * the driver might get unbound. | 1852 | * the driver might get unbound. |
1808 | */ | 1853 | */ |
1809 | 1854 | ||
1810 | int usb_gadget_register_driver(struct usb_gadget_driver *driver) | 1855 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver, |
1856 | int (*bind)(struct usb_gadget *)) | ||
1811 | { | 1857 | { |
1812 | struct langwell_udc *dev = the_controller; | 1858 | struct langwell_udc *dev = the_controller; |
1813 | unsigned long flags; | 1859 | unsigned long flags; |
@@ -1816,7 +1862,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1816 | if (!dev) | 1862 | if (!dev) |
1817 | return -ENODEV; | 1863 | return -ENODEV; |
1818 | 1864 | ||
1819 | DBG(dev, "---> %s()\n", __func__); | 1865 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1820 | 1866 | ||
1821 | if (dev->driver) | 1867 | if (dev->driver) |
1822 | return -EBUSY; | 1868 | return -EBUSY; |
@@ -1830,9 +1876,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1830 | 1876 | ||
1831 | spin_unlock_irqrestore(&dev->lock, flags); | 1877 | spin_unlock_irqrestore(&dev->lock, flags); |
1832 | 1878 | ||
1833 | retval = driver->bind(&dev->gadget); | 1879 | retval = bind(&dev->gadget); |
1834 | if (retval) { | 1880 | if (retval) { |
1835 | DBG(dev, "bind to driver %s --> %d\n", | 1881 | dev_dbg(&dev->pdev->dev, "bind to driver %s --> %d\n", |
1836 | driver->driver.name, retval); | 1882 | driver->driver.name, retval); |
1837 | dev->driver = NULL; | 1883 | dev->driver = NULL; |
1838 | dev->gadget.dev.driver = NULL; | 1884 | dev->gadget.dev.driver = NULL; |
@@ -1851,13 +1897,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1851 | if (dev->got_irq) | 1897 | if (dev->got_irq) |
1852 | langwell_udc_start(dev); | 1898 | langwell_udc_start(dev); |
1853 | 1899 | ||
1854 | VDBG(dev, "After langwell_udc_start(), print all registers:\n"); | 1900 | dev_vdbg(&dev->pdev->dev, |
1855 | #ifdef VERBOSE | 1901 | "After langwell_udc_start(), print all registers:\n"); |
1856 | print_all_registers(dev); | 1902 | print_all_registers(dev); |
1857 | #endif | ||
1858 | 1903 | ||
1859 | INFO(dev, "register driver: %s\n", driver->driver.name); | 1904 | dev_info(&dev->pdev->dev, "register driver: %s\n", |
1860 | VDBG(dev, "<--- %s()\n", __func__); | 1905 | driver->driver.name); |
1906 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
1861 | return 0; | 1907 | return 0; |
1862 | 1908 | ||
1863 | err_unbind: | 1909 | err_unbind: |
@@ -1865,10 +1911,10 @@ err_unbind: | |||
1865 | dev->gadget.dev.driver = NULL; | 1911 | dev->gadget.dev.driver = NULL; |
1866 | dev->driver = NULL; | 1912 | dev->driver = NULL; |
1867 | 1913 | ||
1868 | DBG(dev, "<--- %s()\n", __func__); | 1914 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1869 | return retval; | 1915 | return retval; |
1870 | } | 1916 | } |
1871 | EXPORT_SYMBOL(usb_gadget_register_driver); | 1917 | EXPORT_SYMBOL(usb_gadget_probe_driver); |
1872 | 1918 | ||
1873 | 1919 | ||
1874 | /* unregister gadget driver */ | 1920 | /* unregister gadget driver */ |
@@ -1880,11 +1926,15 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1880 | if (!dev) | 1926 | if (!dev) |
1881 | return -ENODEV; | 1927 | return -ENODEV; |
1882 | 1928 | ||
1883 | DBG(dev, "---> %s()\n", __func__); | 1929 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1884 | 1930 | ||
1885 | if (unlikely(!driver || !driver->bind || !driver->unbind)) | 1931 | if (unlikely(!driver || !driver->unbind)) |
1886 | return -EINVAL; | 1932 | return -EINVAL; |
1887 | 1933 | ||
1934 | /* exit PHY low power suspend */ | ||
1935 | if (dev->pdev->device != 0x0829) | ||
1936 | langwell_phy_low_power(dev, 0); | ||
1937 | |||
1888 | /* unbind OTG transceiver */ | 1938 | /* unbind OTG transceiver */ |
1889 | if (dev->transceiver) | 1939 | if (dev->transceiver) |
1890 | (void)otg_set_peripheral(dev->transceiver, 0); | 1940 | (void)otg_set_peripheral(dev->transceiver, 0); |
@@ -1910,8 +1960,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1910 | 1960 | ||
1911 | device_remove_file(&dev->pdev->dev, &dev_attr_function); | 1961 | device_remove_file(&dev->pdev->dev, &dev_attr_function); |
1912 | 1962 | ||
1913 | INFO(dev, "unregistered driver '%s'\n", driver->driver.name); | 1963 | dev_info(&dev->pdev->dev, "unregistered driver '%s'\n", |
1914 | DBG(dev, "<--- %s()\n", __func__); | 1964 | driver->driver.name); |
1965 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
1915 | return 0; | 1966 | return 0; |
1916 | } | 1967 | } |
1917 | EXPORT_SYMBOL(usb_gadget_unregister_driver); | 1968 | EXPORT_SYMBOL(usb_gadget_unregister_driver); |
@@ -1930,7 +1981,7 @@ static void setup_tripwire(struct langwell_udc *dev) | |||
1930 | unsigned long timeout; | 1981 | unsigned long timeout; |
1931 | struct langwell_dqh *dqh; | 1982 | struct langwell_dqh *dqh; |
1932 | 1983 | ||
1933 | VDBG(dev, "---> %s()\n", __func__); | 1984 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1934 | 1985 | ||
1935 | /* ep0 OUT dQH */ | 1986 | /* ep0 OUT dQH */ |
1936 | dqh = &dev->ep_dqh[EP_DIR_OUT]; | 1987 | dqh = &dev->ep_dqh[EP_DIR_OUT]; |
@@ -1943,7 +1994,7 @@ static void setup_tripwire(struct langwell_udc *dev) | |||
1943 | timeout = jiffies + SETUPSTAT_TIMEOUT; | 1994 | timeout = jiffies + SETUPSTAT_TIMEOUT; |
1944 | while (readl(&dev->op_regs->endptsetupstat)) { | 1995 | while (readl(&dev->op_regs->endptsetupstat)) { |
1945 | if (time_after(jiffies, timeout)) { | 1996 | if (time_after(jiffies, timeout)) { |
1946 | ERROR(dev, "setup_tripwire timeout\n"); | 1997 | dev_err(&dev->pdev->dev, "setup_tripwire timeout\n"); |
1947 | break; | 1998 | break; |
1948 | } | 1999 | } |
1949 | cpu_relax(); | 2000 | cpu_relax(); |
@@ -1963,7 +2014,7 @@ static void setup_tripwire(struct langwell_udc *dev) | |||
1963 | usbcmd = readl(&dev->op_regs->usbcmd); | 2014 | usbcmd = readl(&dev->op_regs->usbcmd); |
1964 | writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd); | 2015 | writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd); |
1965 | 2016 | ||
1966 | VDBG(dev, "<--- %s()\n", __func__); | 2017 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1967 | } | 2018 | } |
1968 | 2019 | ||
1969 | 2020 | ||
@@ -1972,7 +2023,7 @@ static void ep0_stall(struct langwell_udc *dev) | |||
1972 | { | 2023 | { |
1973 | u32 endptctrl; | 2024 | u32 endptctrl; |
1974 | 2025 | ||
1975 | VDBG(dev, "---> %s()\n", __func__); | 2026 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1976 | 2027 | ||
1977 | /* set TX and RX to stall */ | 2028 | /* set TX and RX to stall */ |
1978 | endptctrl = readl(&dev->op_regs->endptctrl[0]); | 2029 | endptctrl = readl(&dev->op_regs->endptctrl[0]); |
@@ -1983,7 +2034,7 @@ static void ep0_stall(struct langwell_udc *dev) | |||
1983 | dev->ep0_state = WAIT_FOR_SETUP; | 2034 | dev->ep0_state = WAIT_FOR_SETUP; |
1984 | dev->ep0_dir = USB_DIR_OUT; | 2035 | dev->ep0_dir = USB_DIR_OUT; |
1985 | 2036 | ||
1986 | VDBG(dev, "<--- %s()\n", __func__); | 2037 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1987 | } | 2038 | } |
1988 | 2039 | ||
1989 | 2040 | ||
@@ -1994,7 +2045,7 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) | |||
1994 | struct langwell_ep *ep; | 2045 | struct langwell_ep *ep; |
1995 | int status = 0; | 2046 | int status = 0; |
1996 | 2047 | ||
1997 | VDBG(dev, "---> %s()\n", __func__); | 2048 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1998 | 2049 | ||
1999 | if (dir == EP_DIR_IN) | 2050 | if (dir == EP_DIR_IN) |
2000 | dev->ep0_dir = USB_DIR_IN; | 2051 | dev->ep0_dir = USB_DIR_IN; |
@@ -2019,11 +2070,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) | |||
2019 | return -ENOMEM; | 2070 | return -ENOMEM; |
2020 | 2071 | ||
2021 | if (status) | 2072 | if (status) |
2022 | ERROR(dev, "can't queue ep0 status request\n"); | 2073 | dev_err(&dev->pdev->dev, "can't queue ep0 status request\n"); |
2023 | 2074 | ||
2024 | list_add_tail(&req->queue, &ep->queue); | 2075 | list_add_tail(&req->queue, &ep->queue); |
2025 | 2076 | ||
2026 | VDBG(dev, "<--- %s()\n", __func__); | 2077 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2027 | return status; | 2078 | return status; |
2028 | } | 2079 | } |
2029 | 2080 | ||
@@ -2032,11 +2083,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) | |||
2032 | static void set_address(struct langwell_udc *dev, u16 value, | 2083 | static void set_address(struct langwell_udc *dev, u16 value, |
2033 | u16 index, u16 length) | 2084 | u16 index, u16 length) |
2034 | { | 2085 | { |
2035 | VDBG(dev, "---> %s()\n", __func__); | 2086 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2036 | 2087 | ||
2037 | /* save the new address to device struct */ | 2088 | /* save the new address to device struct */ |
2038 | dev->dev_addr = (u8) value; | 2089 | dev->dev_addr = (u8) value; |
2039 | VDBG(dev, "dev->dev_addr = %d\n", dev->dev_addr); | 2090 | dev_vdbg(&dev->pdev->dev, "dev->dev_addr = %d\n", dev->dev_addr); |
2040 | 2091 | ||
2041 | /* update usb state */ | 2092 | /* update usb state */ |
2042 | dev->usb_state = USB_STATE_ADDRESS; | 2093 | dev->usb_state = USB_STATE_ADDRESS; |
@@ -2045,7 +2096,7 @@ static void set_address(struct langwell_udc *dev, u16 value, | |||
2045 | if (prime_status_phase(dev, EP_DIR_IN)) | 2096 | if (prime_status_phase(dev, EP_DIR_IN)) |
2046 | ep0_stall(dev); | 2097 | ep0_stall(dev); |
2047 | 2098 | ||
2048 | VDBG(dev, "<--- %s()\n", __func__); | 2099 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2049 | } | 2100 | } |
2050 | 2101 | ||
2051 | 2102 | ||
@@ -2054,7 +2105,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev, | |||
2054 | u16 wIndex) | 2105 | u16 wIndex) |
2055 | { | 2106 | { |
2056 | struct langwell_ep *ep; | 2107 | struct langwell_ep *ep; |
2057 | VDBG(dev, "---> %s()\n", __func__); | 2108 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2058 | 2109 | ||
2059 | if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0) | 2110 | if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0) |
2060 | return &dev->ep[0]; | 2111 | return &dev->ep[0]; |
@@ -2073,7 +2124,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev, | |||
2073 | return ep; | 2124 | return ep; |
2074 | } | 2125 | } |
2075 | 2126 | ||
2076 | VDBG(dev, "<--- %s()\n", __func__); | 2127 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2077 | return NULL; | 2128 | return NULL; |
2078 | } | 2129 | } |
2079 | 2130 | ||
@@ -2085,7 +2136,7 @@ static int ep_is_stall(struct langwell_ep *ep) | |||
2085 | u32 endptctrl; | 2136 | u32 endptctrl; |
2086 | int retval; | 2137 | int retval; |
2087 | 2138 | ||
2088 | VDBG(dev, "---> %s()\n", __func__); | 2139 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2089 | 2140 | ||
2090 | endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]); | 2141 | endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]); |
2091 | if (is_in(ep)) | 2142 | if (is_in(ep)) |
@@ -2093,7 +2144,7 @@ static int ep_is_stall(struct langwell_ep *ep) | |||
2093 | else | 2144 | else |
2094 | retval = endptctrl & EPCTRL_RXS ? 1 : 0; | 2145 | retval = endptctrl & EPCTRL_RXS ? 1 : 0; |
2095 | 2146 | ||
2096 | VDBG(dev, "<--- %s()\n", __func__); | 2147 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2097 | return retval; | 2148 | return retval; |
2098 | } | 2149 | } |
2099 | 2150 | ||
@@ -2107,14 +2158,13 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, | |||
2107 | u16 status_data = 0; /* 16 bits cpu view status data */ | 2158 | u16 status_data = 0; /* 16 bits cpu view status data */ |
2108 | int status = 0; | 2159 | int status = 0; |
2109 | 2160 | ||
2110 | VDBG(dev, "---> %s()\n", __func__); | 2161 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2111 | 2162 | ||
2112 | ep = &dev->ep[0]; | 2163 | ep = &dev->ep[0]; |
2113 | 2164 | ||
2114 | if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) { | 2165 | if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) { |
2115 | /* get device status */ | 2166 | /* get device status */ |
2116 | status_data = 1 << USB_DEVICE_SELF_POWERED; | 2167 | status_data = dev->dev_status; |
2117 | status_data |= dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP; | ||
2118 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { | 2168 | } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) { |
2119 | /* get interface status */ | 2169 | /* get interface status */ |
2120 | status_data = 0; | 2170 | status_data = 0; |
@@ -2129,6 +2179,8 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, | |||
2129 | status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT; | 2179 | status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT; |
2130 | } | 2180 | } |
2131 | 2181 | ||
2182 | dev_dbg(&dev->pdev->dev, "get status data: 0x%04x\n", status_data); | ||
2183 | |||
2132 | dev->ep0_dir = USB_DIR_IN; | 2184 | dev->ep0_dir = USB_DIR_IN; |
2133 | 2185 | ||
2134 | /* borrow the per device status_req */ | 2186 | /* borrow the per device status_req */ |
@@ -2150,18 +2202,19 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, | |||
2150 | goto stall; | 2202 | goto stall; |
2151 | 2203 | ||
2152 | if (status) { | 2204 | if (status) { |
2153 | ERROR(dev, "response error on GET_STATUS request\n"); | 2205 | dev_err(&dev->pdev->dev, |
2206 | "response error on GET_STATUS request\n"); | ||
2154 | goto stall; | 2207 | goto stall; |
2155 | } | 2208 | } |
2156 | 2209 | ||
2157 | list_add_tail(&req->queue, &ep->queue); | 2210 | list_add_tail(&req->queue, &ep->queue); |
2158 | dev->ep0_state = DATA_STATE_XMIT; | 2211 | dev->ep0_state = DATA_STATE_XMIT; |
2159 | 2212 | ||
2160 | VDBG(dev, "<--- %s()\n", __func__); | 2213 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2161 | return; | 2214 | return; |
2162 | stall: | 2215 | stall: |
2163 | ep0_stall(dev); | 2216 | ep0_stall(dev); |
2164 | VDBG(dev, "<--- %s()\n", __func__); | 2217 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2165 | } | 2218 | } |
2166 | 2219 | ||
2167 | 2220 | ||
@@ -2173,12 +2226,12 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2173 | u16 wIndex = le16_to_cpu(setup->wIndex); | 2226 | u16 wIndex = le16_to_cpu(setup->wIndex); |
2174 | u16 wLength = le16_to_cpu(setup->wLength); | 2227 | u16 wLength = le16_to_cpu(setup->wLength); |
2175 | 2228 | ||
2176 | VDBG(dev, "---> %s()\n", __func__); | 2229 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2177 | 2230 | ||
2178 | /* ep0 fifo flush */ | 2231 | /* ep0 fifo flush */ |
2179 | nuke(&dev->ep[0], -ESHUTDOWN); | 2232 | nuke(&dev->ep[0], -ESHUTDOWN); |
2180 | 2233 | ||
2181 | DBG(dev, "SETUP %02x.%02x v%04x i%04x l%04x\n", | 2234 | dev_dbg(&dev->pdev->dev, "SETUP %02x.%02x v%04x i%04x l%04x\n", |
2182 | setup->bRequestType, setup->bRequest, | 2235 | setup->bRequestType, setup->bRequest, |
2183 | wValue, wIndex, wLength); | 2236 | wValue, wIndex, wLength); |
2184 | 2237 | ||
@@ -2197,7 +2250,7 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2197 | /* We process some stardard setup requests here */ | 2250 | /* We process some stardard setup requests here */ |
2198 | switch (setup->bRequest) { | 2251 | switch (setup->bRequest) { |
2199 | case USB_REQ_GET_STATUS: | 2252 | case USB_REQ_GET_STATUS: |
2200 | DBG(dev, "SETUP: USB_REQ_GET_STATUS\n"); | 2253 | dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_GET_STATUS\n"); |
2201 | /* get status, DATA and STATUS phase */ | 2254 | /* get status, DATA and STATUS phase */ |
2202 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) | 2255 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) |
2203 | != (USB_DIR_IN | USB_TYPE_STANDARD)) | 2256 | != (USB_DIR_IN | USB_TYPE_STANDARD)) |
@@ -2206,7 +2259,7 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2206 | goto end; | 2259 | goto end; |
2207 | 2260 | ||
2208 | case USB_REQ_SET_ADDRESS: | 2261 | case USB_REQ_SET_ADDRESS: |
2209 | DBG(dev, "SETUP: USB_REQ_SET_ADDRESS\n"); | 2262 | dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_SET_ADDRESS\n"); |
2210 | /* STATUS phase */ | 2263 | /* STATUS phase */ |
2211 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD | 2264 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD |
2212 | | USB_RECIP_DEVICE)) | 2265 | | USB_RECIP_DEVICE)) |
@@ -2220,9 +2273,11 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2220 | { | 2273 | { |
2221 | int rc = -EOPNOTSUPP; | 2274 | int rc = -EOPNOTSUPP; |
2222 | if (setup->bRequest == USB_REQ_SET_FEATURE) | 2275 | if (setup->bRequest == USB_REQ_SET_FEATURE) |
2223 | DBG(dev, "SETUP: USB_REQ_SET_FEATURE\n"); | 2276 | dev_dbg(&dev->pdev->dev, |
2277 | "SETUP: USB_REQ_SET_FEATURE\n"); | ||
2224 | else if (setup->bRequest == USB_REQ_CLEAR_FEATURE) | 2278 | else if (setup->bRequest == USB_REQ_CLEAR_FEATURE) |
2225 | DBG(dev, "SETUP: USB_REQ_CLEAR_FEATURE\n"); | 2279 | dev_dbg(&dev->pdev->dev, |
2280 | "SETUP: USB_REQ_CLEAR_FEATURE\n"); | ||
2226 | 2281 | ||
2227 | if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK)) | 2282 | if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK)) |
2228 | == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) { | 2283 | == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) { |
@@ -2240,13 +2295,29 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2240 | 2295 | ||
2241 | spin_unlock(&dev->lock); | 2296 | spin_unlock(&dev->lock); |
2242 | rc = langwell_ep_set_halt(&epn->ep, | 2297 | rc = langwell_ep_set_halt(&epn->ep, |
2243 | (setup->bRequest == USB_REQ_SET_FEATURE) | 2298 | (setup->bRequest == USB_REQ_SET_FEATURE) |
2244 | ? 1 : 0); | 2299 | ? 1 : 0); |
2245 | spin_lock(&dev->lock); | 2300 | spin_lock(&dev->lock); |
2246 | 2301 | ||
2247 | } else if ((setup->bRequestType & (USB_RECIP_MASK | 2302 | } else if ((setup->bRequestType & (USB_RECIP_MASK |
2248 | | USB_TYPE_MASK)) == (USB_RECIP_DEVICE | 2303 | | USB_TYPE_MASK)) == (USB_RECIP_DEVICE |
2249 | | USB_TYPE_STANDARD)) { | 2304 | | USB_TYPE_STANDARD)) { |
2305 | rc = 0; | ||
2306 | switch (wValue) { | ||
2307 | case USB_DEVICE_REMOTE_WAKEUP: | ||
2308 | if (setup->bRequest == USB_REQ_SET_FEATURE) { | ||
2309 | dev->remote_wakeup = 1; | ||
2310 | dev->dev_status |= (1 << wValue); | ||
2311 | } else { | ||
2312 | dev->remote_wakeup = 0; | ||
2313 | dev->dev_status &= ~(1 << wValue); | ||
2314 | } | ||
2315 | break; | ||
2316 | default: | ||
2317 | rc = -EOPNOTSUPP; | ||
2318 | break; | ||
2319 | } | ||
2320 | |||
2250 | if (!gadget_is_otg(&dev->gadget)) | 2321 | if (!gadget_is_otg(&dev->gadget)) |
2251 | break; | 2322 | break; |
2252 | else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { | 2323 | else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { |
@@ -2262,7 +2333,6 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2262 | dev->gadget.a_alt_hnp_support = 1; | 2333 | dev->gadget.a_alt_hnp_support = 1; |
2263 | else | 2334 | else |
2264 | break; | 2335 | break; |
2265 | rc = 0; | ||
2266 | } else | 2336 | } else |
2267 | break; | 2337 | break; |
2268 | 2338 | ||
@@ -2274,31 +2344,38 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
2274 | } | 2344 | } |
2275 | 2345 | ||
2276 | case USB_REQ_GET_DESCRIPTOR: | 2346 | case USB_REQ_GET_DESCRIPTOR: |
2277 | DBG(dev, "SETUP: USB_REQ_GET_DESCRIPTOR\n"); | 2347 | dev_dbg(&dev->pdev->dev, |
2348 | "SETUP: USB_REQ_GET_DESCRIPTOR\n"); | ||
2278 | goto delegate; | 2349 | goto delegate; |
2279 | 2350 | ||
2280 | case USB_REQ_SET_DESCRIPTOR: | 2351 | case USB_REQ_SET_DESCRIPTOR: |
2281 | DBG(dev, "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n"); | 2352 | dev_dbg(&dev->pdev->dev, |
2353 | "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n"); | ||
2282 | goto delegate; | 2354 | goto delegate; |
2283 | 2355 | ||
2284 | case USB_REQ_GET_CONFIGURATION: | 2356 | case USB_REQ_GET_CONFIGURATION: |
2285 | DBG(dev, "SETUP: USB_REQ_GET_CONFIGURATION\n"); | 2357 | dev_dbg(&dev->pdev->dev, |
2358 | "SETUP: USB_REQ_GET_CONFIGURATION\n"); | ||
2286 | goto delegate; | 2359 | goto delegate; |
2287 | 2360 | ||
2288 | case USB_REQ_SET_CONFIGURATION: | 2361 | case USB_REQ_SET_CONFIGURATION: |
2289 | DBG(dev, "SETUP: USB_REQ_SET_CONFIGURATION\n"); | 2362 | dev_dbg(&dev->pdev->dev, |
2363 | "SETUP: USB_REQ_SET_CONFIGURATION\n"); | ||
2290 | goto delegate; | 2364 | goto delegate; |
2291 | 2365 | ||
2292 | case USB_REQ_GET_INTERFACE: | 2366 | case USB_REQ_GET_INTERFACE: |
2293 | DBG(dev, "SETUP: USB_REQ_GET_INTERFACE\n"); | 2367 | dev_dbg(&dev->pdev->dev, |
2368 | "SETUP: USB_REQ_GET_INTERFACE\n"); | ||
2294 | goto delegate; | 2369 | goto delegate; |
2295 | 2370 | ||
2296 | case USB_REQ_SET_INTERFACE: | 2371 | case USB_REQ_SET_INTERFACE: |
2297 | DBG(dev, "SETUP: USB_REQ_SET_INTERFACE\n"); | 2372 | dev_dbg(&dev->pdev->dev, |
2373 | "SETUP: USB_REQ_SET_INTERFACE\n"); | ||
2298 | goto delegate; | 2374 | goto delegate; |
2299 | 2375 | ||
2300 | case USB_REQ_SYNCH_FRAME: | 2376 | case USB_REQ_SYNCH_FRAME: |
2301 | DBG(dev, "SETUP: USB_REQ_SYNCH_FRAME unsupported\n"); | 2377 | dev_dbg(&dev->pdev->dev, |
2378 | "SETUP: USB_REQ_SYNCH_FRAME unsupported\n"); | ||
2302 | goto delegate; | 2379 | goto delegate; |
2303 | 2380 | ||
2304 | default: | 2381 | default: |
@@ -2310,7 +2387,8 @@ delegate: | |||
2310 | /* DATA phase from gadget, STATUS phase from udc */ | 2387 | /* DATA phase from gadget, STATUS phase from udc */ |
2311 | dev->ep0_dir = (setup->bRequestType & USB_DIR_IN) | 2388 | dev->ep0_dir = (setup->bRequestType & USB_DIR_IN) |
2312 | ? USB_DIR_IN : USB_DIR_OUT; | 2389 | ? USB_DIR_IN : USB_DIR_OUT; |
2313 | VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", | 2390 | dev_vdbg(&dev->pdev->dev, |
2391 | "dev->ep0_dir = 0x%x, wLength = %d\n", | ||
2314 | dev->ep0_dir, wLength); | 2392 | dev->ep0_dir, wLength); |
2315 | spin_unlock(&dev->lock); | 2393 | spin_unlock(&dev->lock); |
2316 | if (dev->driver->setup(&dev->gadget, | 2394 | if (dev->driver->setup(&dev->gadget, |
@@ -2322,7 +2400,8 @@ delegate: | |||
2322 | } else { | 2400 | } else { |
2323 | /* no DATA phase, IN STATUS phase from gadget */ | 2401 | /* no DATA phase, IN STATUS phase from gadget */ |
2324 | dev->ep0_dir = USB_DIR_IN; | 2402 | dev->ep0_dir = USB_DIR_IN; |
2325 | VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", | 2403 | dev_vdbg(&dev->pdev->dev, |
2404 | "dev->ep0_dir = 0x%x, wLength = %d\n", | ||
2326 | dev->ep0_dir, wLength); | 2405 | dev->ep0_dir, wLength); |
2327 | spin_unlock(&dev->lock); | 2406 | spin_unlock(&dev->lock); |
2328 | if (dev->driver->setup(&dev->gadget, | 2407 | if (dev->driver->setup(&dev->gadget, |
@@ -2334,8 +2413,7 @@ delegate: | |||
2334 | break; | 2413 | break; |
2335 | } | 2414 | } |
2336 | end: | 2415 | end: |
2337 | VDBG(dev, "<--- %s()\n", __func__); | 2416 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2338 | return; | ||
2339 | } | 2417 | } |
2340 | 2418 | ||
2341 | 2419 | ||
@@ -2359,23 +2437,27 @@ static int process_ep_req(struct langwell_udc *dev, int index, | |||
2359 | td_complete = 0; | 2437 | td_complete = 0; |
2360 | actual = curr_req->req.length; | 2438 | actual = curr_req->req.length; |
2361 | 2439 | ||
2362 | VDBG(dev, "---> %s()\n", __func__); | 2440 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2363 | 2441 | ||
2364 | for (i = 0; i < curr_req->dtd_count; i++) { | 2442 | for (i = 0; i < curr_req->dtd_count; i++) { |
2365 | remaining_length = le16_to_cpu(curr_dtd->dtd_total); | ||
2366 | actual -= remaining_length; | ||
2367 | 2443 | ||
2368 | /* command execution states by dTD */ | 2444 | /* command execution states by dTD */ |
2369 | dtd_status = curr_dtd->dtd_status; | 2445 | dtd_status = curr_dtd->dtd_status; |
2370 | 2446 | ||
2447 | barrier(); | ||
2448 | remaining_length = le16_to_cpu(curr_dtd->dtd_total); | ||
2449 | actual -= remaining_length; | ||
2450 | |||
2371 | if (!dtd_status) { | 2451 | if (!dtd_status) { |
2372 | /* transfers completed successfully */ | 2452 | /* transfers completed successfully */ |
2373 | if (!remaining_length) { | 2453 | if (!remaining_length) { |
2374 | td_complete++; | 2454 | td_complete++; |
2375 | VDBG(dev, "dTD transmitted successfully\n"); | 2455 | dev_vdbg(&dev->pdev->dev, |
2456 | "dTD transmitted successfully\n"); | ||
2376 | } else { | 2457 | } else { |
2377 | if (dir) { | 2458 | if (dir) { |
2378 | VDBG(dev, "TX dTD remains data\n"); | 2459 | dev_vdbg(&dev->pdev->dev, |
2460 | "TX dTD remains data\n"); | ||
2379 | retval = -EPROTO; | 2461 | retval = -EPROTO; |
2380 | break; | 2462 | break; |
2381 | 2463 | ||
@@ -2387,27 +2469,32 @@ static int process_ep_req(struct langwell_udc *dev, int index, | |||
2387 | } else { | 2469 | } else { |
2388 | /* transfers completed with errors */ | 2470 | /* transfers completed with errors */ |
2389 | if (dtd_status & DTD_STS_ACTIVE) { | 2471 | if (dtd_status & DTD_STS_ACTIVE) { |
2390 | DBG(dev, "request not completed\n"); | 2472 | dev_dbg(&dev->pdev->dev, |
2473 | "dTD status ACTIVE dQH[%d]\n", index); | ||
2391 | retval = 1; | 2474 | retval = 1; |
2392 | return retval; | 2475 | return retval; |
2393 | } else if (dtd_status & DTD_STS_HALTED) { | 2476 | } else if (dtd_status & DTD_STS_HALTED) { |
2394 | ERROR(dev, "dTD error %08x dQH[%d]\n", | 2477 | dev_err(&dev->pdev->dev, |
2395 | dtd_status, index); | 2478 | "dTD error %08x dQH[%d]\n", |
2479 | dtd_status, index); | ||
2396 | /* clear the errors and halt condition */ | 2480 | /* clear the errors and halt condition */ |
2397 | curr_dqh->dtd_status = 0; | 2481 | curr_dqh->dtd_status = 0; |
2398 | retval = -EPIPE; | 2482 | retval = -EPIPE; |
2399 | break; | 2483 | break; |
2400 | } else if (dtd_status & DTD_STS_DBE) { | 2484 | } else if (dtd_status & DTD_STS_DBE) { |
2401 | DBG(dev, "data buffer (overflow) error\n"); | 2485 | dev_dbg(&dev->pdev->dev, |
2486 | "data buffer (overflow) error\n"); | ||
2402 | retval = -EPROTO; | 2487 | retval = -EPROTO; |
2403 | break; | 2488 | break; |
2404 | } else if (dtd_status & DTD_STS_TRE) { | 2489 | } else if (dtd_status & DTD_STS_TRE) { |
2405 | DBG(dev, "transaction(ISO) error\n"); | 2490 | dev_dbg(&dev->pdev->dev, |
2491 | "transaction(ISO) error\n"); | ||
2406 | retval = -EILSEQ; | 2492 | retval = -EILSEQ; |
2407 | break; | 2493 | break; |
2408 | } else | 2494 | } else |
2409 | ERROR(dev, "unknown error (0x%x)!\n", | 2495 | dev_err(&dev->pdev->dev, |
2410 | dtd_status); | 2496 | "unknown error (0x%x)!\n", |
2497 | dtd_status); | ||
2411 | } | 2498 | } |
2412 | 2499 | ||
2413 | if (i != curr_req->dtd_count - 1) | 2500 | if (i != curr_req->dtd_count - 1) |
@@ -2420,7 +2507,7 @@ static int process_ep_req(struct langwell_udc *dev, int index, | |||
2420 | 2507 | ||
2421 | curr_req->req.actual = actual; | 2508 | curr_req->req.actual = actual; |
2422 | 2509 | ||
2423 | VDBG(dev, "<--- %s()\n", __func__); | 2510 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2424 | return 0; | 2511 | return 0; |
2425 | } | 2512 | } |
2426 | 2513 | ||
@@ -2430,7 +2517,7 @@ static void ep0_req_complete(struct langwell_udc *dev, | |||
2430 | struct langwell_ep *ep0, struct langwell_request *req) | 2517 | struct langwell_ep *ep0, struct langwell_request *req) |
2431 | { | 2518 | { |
2432 | u32 new_addr; | 2519 | u32 new_addr; |
2433 | VDBG(dev, "---> %s()\n", __func__); | 2520 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2434 | 2521 | ||
2435 | if (dev->usb_state == USB_STATE_ADDRESS) { | 2522 | if (dev->usb_state == USB_STATE_ADDRESS) { |
2436 | /* set the new address */ | 2523 | /* set the new address */ |
@@ -2438,7 +2525,7 @@ static void ep0_req_complete(struct langwell_udc *dev, | |||
2438 | writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr); | 2525 | writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr); |
2439 | 2526 | ||
2440 | new_addr = USBADR(readl(&dev->op_regs->deviceaddr)); | 2527 | new_addr = USBADR(readl(&dev->op_regs->deviceaddr)); |
2441 | VDBG(dev, "new_addr = %d\n", new_addr); | 2528 | dev_vdbg(&dev->pdev->dev, "new_addr = %d\n", new_addr); |
2442 | } | 2529 | } |
2443 | 2530 | ||
2444 | done(ep0, req, 0); | 2531 | done(ep0, req, 0); |
@@ -2458,14 +2545,14 @@ static void ep0_req_complete(struct langwell_udc *dev, | |||
2458 | dev->ep0_state = WAIT_FOR_SETUP; | 2545 | dev->ep0_state = WAIT_FOR_SETUP; |
2459 | break; | 2546 | break; |
2460 | case WAIT_FOR_SETUP: | 2547 | case WAIT_FOR_SETUP: |
2461 | ERROR(dev, "unexpect ep0 packets\n"); | 2548 | dev_err(&dev->pdev->dev, "unexpect ep0 packets\n"); |
2462 | break; | 2549 | break; |
2463 | default: | 2550 | default: |
2464 | ep0_stall(dev); | 2551 | ep0_stall(dev); |
2465 | break; | 2552 | break; |
2466 | } | 2553 | } |
2467 | 2554 | ||
2468 | VDBG(dev, "<--- %s()\n", __func__); | 2555 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2469 | } | 2556 | } |
2470 | 2557 | ||
2471 | 2558 | ||
@@ -2477,16 +2564,17 @@ static void handle_trans_complete(struct langwell_udc *dev) | |||
2477 | struct langwell_ep *epn; | 2564 | struct langwell_ep *epn; |
2478 | struct langwell_request *curr_req, *temp_req; | 2565 | struct langwell_request *curr_req, *temp_req; |
2479 | 2566 | ||
2480 | VDBG(dev, "---> %s()\n", __func__); | 2567 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2481 | 2568 | ||
2482 | complete_bits = readl(&dev->op_regs->endptcomplete); | 2569 | complete_bits = readl(&dev->op_regs->endptcomplete); |
2483 | VDBG(dev, "endptcomplete register: 0x%08x\n", complete_bits); | 2570 | dev_vdbg(&dev->pdev->dev, "endptcomplete register: 0x%08x\n", |
2571 | complete_bits); | ||
2484 | 2572 | ||
2485 | /* Write-Clear the bits in endptcomplete register */ | 2573 | /* Write-Clear the bits in endptcomplete register */ |
2486 | writel(complete_bits, &dev->op_regs->endptcomplete); | 2574 | writel(complete_bits, &dev->op_regs->endptcomplete); |
2487 | 2575 | ||
2488 | if (!complete_bits) { | 2576 | if (!complete_bits) { |
2489 | DBG(dev, "complete_bits = 0\n"); | 2577 | dev_dbg(&dev->pdev->dev, "complete_bits = 0\n"); |
2490 | goto done; | 2578 | goto done; |
2491 | } | 2579 | } |
2492 | 2580 | ||
@@ -2506,23 +2594,25 @@ static void handle_trans_complete(struct langwell_udc *dev) | |||
2506 | epn = &dev->ep[i]; | 2594 | epn = &dev->ep[i]; |
2507 | 2595 | ||
2508 | if (epn->name == NULL) { | 2596 | if (epn->name == NULL) { |
2509 | WARNING(dev, "invalid endpoint\n"); | 2597 | dev_warn(&dev->pdev->dev, "invalid endpoint\n"); |
2510 | continue; | 2598 | continue; |
2511 | } | 2599 | } |
2512 | 2600 | ||
2513 | if (i < 2) | 2601 | if (i < 2) |
2514 | /* ep0 in and out */ | 2602 | /* ep0 in and out */ |
2515 | DBG(dev, "%s-%s transfer completed\n", | 2603 | dev_dbg(&dev->pdev->dev, "%s-%s transfer completed\n", |
2516 | epn->name, | 2604 | epn->name, |
2517 | is_in(epn) ? "in" : "out"); | 2605 | is_in(epn) ? "in" : "out"); |
2518 | else | 2606 | else |
2519 | DBG(dev, "%s transfer completed\n", epn->name); | 2607 | dev_dbg(&dev->pdev->dev, "%s transfer completed\n", |
2608 | epn->name); | ||
2520 | 2609 | ||
2521 | /* process the req queue until an uncomplete request */ | 2610 | /* process the req queue until an uncomplete request */ |
2522 | list_for_each_entry_safe(curr_req, temp_req, | 2611 | list_for_each_entry_safe(curr_req, temp_req, |
2523 | &epn->queue, queue) { | 2612 | &epn->queue, queue) { |
2524 | status = process_ep_req(dev, i, curr_req); | 2613 | status = process_ep_req(dev, i, curr_req); |
2525 | VDBG(dev, "%s req status: %d\n", epn->name, status); | 2614 | dev_vdbg(&dev->pdev->dev, "%s req status: %d\n", |
2615 | epn->name, status); | ||
2526 | 2616 | ||
2527 | if (status) | 2617 | if (status) |
2528 | break; | 2618 | break; |
@@ -2540,8 +2630,7 @@ static void handle_trans_complete(struct langwell_udc *dev) | |||
2540 | } | 2630 | } |
2541 | } | 2631 | } |
2542 | done: | 2632 | done: |
2543 | VDBG(dev, "<--- %s()\n", __func__); | 2633 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2544 | return; | ||
2545 | } | 2634 | } |
2546 | 2635 | ||
2547 | 2636 | ||
@@ -2551,14 +2640,14 @@ static void handle_port_change(struct langwell_udc *dev) | |||
2551 | u32 portsc1, devlc; | 2640 | u32 portsc1, devlc; |
2552 | u32 speed; | 2641 | u32 speed; |
2553 | 2642 | ||
2554 | VDBG(dev, "---> %s()\n", __func__); | 2643 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2555 | 2644 | ||
2556 | if (dev->bus_reset) | 2645 | if (dev->bus_reset) |
2557 | dev->bus_reset = 0; | 2646 | dev->bus_reset = 0; |
2558 | 2647 | ||
2559 | portsc1 = readl(&dev->op_regs->portsc1); | 2648 | portsc1 = readl(&dev->op_regs->portsc1); |
2560 | devlc = readl(&dev->op_regs->devlc); | 2649 | devlc = readl(&dev->op_regs->devlc); |
2561 | VDBG(dev, "portsc1 = 0x%08x, devlc = 0x%08x\n", | 2650 | dev_vdbg(&dev->pdev->dev, "portsc1 = 0x%08x, devlc = 0x%08x\n", |
2562 | portsc1, devlc); | 2651 | portsc1, devlc); |
2563 | 2652 | ||
2564 | /* bus reset is finished */ | 2653 | /* bus reset is finished */ |
@@ -2579,25 +2668,22 @@ static void handle_port_change(struct langwell_udc *dev) | |||
2579 | dev->gadget.speed = USB_SPEED_UNKNOWN; | 2668 | dev->gadget.speed = USB_SPEED_UNKNOWN; |
2580 | break; | 2669 | break; |
2581 | } | 2670 | } |
2582 | VDBG(dev, "speed = %d, dev->gadget.speed = %d\n", | 2671 | dev_vdbg(&dev->pdev->dev, |
2672 | "speed = %d, dev->gadget.speed = %d\n", | ||
2583 | speed, dev->gadget.speed); | 2673 | speed, dev->gadget.speed); |
2584 | } | 2674 | } |
2585 | 2675 | ||
2586 | /* LPM L0 to L1 */ | 2676 | /* LPM L0 to L1 */ |
2587 | if (dev->lpm && dev->lpm_state == LPM_L0) | 2677 | if (dev->lpm && dev->lpm_state == LPM_L0) |
2588 | if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) { | 2678 | if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) { |
2589 | INFO(dev, "LPM L0 to L1\n"); | 2679 | dev_info(&dev->pdev->dev, "LPM L0 to L1\n"); |
2590 | dev->lpm_state = LPM_L1; | 2680 | dev->lpm_state = LPM_L1; |
2591 | } | 2681 | } |
2592 | 2682 | ||
2593 | /* LPM L1 to L0, force resume or remote wakeup finished */ | 2683 | /* LPM L1 to L0, force resume or remote wakeup finished */ |
2594 | if (dev->lpm && dev->lpm_state == LPM_L1) | 2684 | if (dev->lpm && dev->lpm_state == LPM_L1) |
2595 | if (!(portsc1 & PORTS_SUSP)) { | 2685 | if (!(portsc1 & PORTS_SUSP)) { |
2596 | if (portsc1 & PORTS_SLP) | 2686 | dev_info(&dev->pdev->dev, "LPM L1 to L0\n"); |
2597 | INFO(dev, "LPM L1 to L0, force resume\n"); | ||
2598 | else | ||
2599 | INFO(dev, "LPM L1 to L0, remote wakeup\n"); | ||
2600 | |||
2601 | dev->lpm_state = LPM_L0; | 2687 | dev->lpm_state = LPM_L0; |
2602 | } | 2688 | } |
2603 | 2689 | ||
@@ -2605,7 +2691,7 @@ static void handle_port_change(struct langwell_udc *dev) | |||
2605 | if (!dev->resume_state) | 2691 | if (!dev->resume_state) |
2606 | dev->usb_state = USB_STATE_DEFAULT; | 2692 | dev->usb_state = USB_STATE_DEFAULT; |
2607 | 2693 | ||
2608 | VDBG(dev, "<--- %s()\n", __func__); | 2694 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2609 | } | 2695 | } |
2610 | 2696 | ||
2611 | 2697 | ||
@@ -2617,7 +2703,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2617 | endptcomplete; | 2703 | endptcomplete; |
2618 | unsigned long timeout; | 2704 | unsigned long timeout; |
2619 | 2705 | ||
2620 | VDBG(dev, "---> %s()\n", __func__); | 2706 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2621 | 2707 | ||
2622 | /* Write-Clear the device address */ | 2708 | /* Write-Clear the device address */ |
2623 | deviceaddr = readl(&dev->op_regs->deviceaddr); | 2709 | deviceaddr = readl(&dev->op_regs->deviceaddr); |
@@ -2634,7 +2720,10 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2634 | 2720 | ||
2635 | dev->ep0_dir = USB_DIR_OUT; | 2721 | dev->ep0_dir = USB_DIR_OUT; |
2636 | dev->ep0_state = WAIT_FOR_SETUP; | 2722 | dev->ep0_state = WAIT_FOR_SETUP; |
2637 | dev->remote_wakeup = 0; /* default to 0 on reset */ | 2723 | |
2724 | /* remote wakeup reset to 0 when the device is reset */ | ||
2725 | dev->remote_wakeup = 0; | ||
2726 | dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; | ||
2638 | dev->gadget.b_hnp_enable = 0; | 2727 | dev->gadget.b_hnp_enable = 0; |
2639 | dev->gadget.a_hnp_support = 0; | 2728 | dev->gadget.a_hnp_support = 0; |
2640 | dev->gadget.a_alt_hnp_support = 0; | 2729 | dev->gadget.a_alt_hnp_support = 0; |
@@ -2651,7 +2740,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2651 | timeout = jiffies + PRIME_TIMEOUT; | 2740 | timeout = jiffies + PRIME_TIMEOUT; |
2652 | while (readl(&dev->op_regs->endptprime)) { | 2741 | while (readl(&dev->op_regs->endptprime)) { |
2653 | if (time_after(jiffies, timeout)) { | 2742 | if (time_after(jiffies, timeout)) { |
2654 | ERROR(dev, "USB reset timeout\n"); | 2743 | dev_err(&dev->pdev->dev, "USB reset timeout\n"); |
2655 | break; | 2744 | break; |
2656 | } | 2745 | } |
2657 | cpu_relax(); | 2746 | cpu_relax(); |
@@ -2661,7 +2750,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2661 | writel((u32) ~0, &dev->op_regs->endptflush); | 2750 | writel((u32) ~0, &dev->op_regs->endptflush); |
2662 | 2751 | ||
2663 | if (readl(&dev->op_regs->portsc1) & PORTS_PR) { | 2752 | if (readl(&dev->op_regs->portsc1) & PORTS_PR) { |
2664 | VDBG(dev, "USB bus reset\n"); | 2753 | dev_vdbg(&dev->pdev->dev, "USB bus reset\n"); |
2665 | /* bus is reseting */ | 2754 | /* bus is reseting */ |
2666 | dev->bus_reset = 1; | 2755 | dev->bus_reset = 1; |
2667 | 2756 | ||
@@ -2669,7 +2758,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2669 | stop_activity(dev, dev->driver); | 2758 | stop_activity(dev, dev->driver); |
2670 | dev->usb_state = USB_STATE_DEFAULT; | 2759 | dev->usb_state = USB_STATE_DEFAULT; |
2671 | } else { | 2760 | } else { |
2672 | VDBG(dev, "device controller reset\n"); | 2761 | dev_vdbg(&dev->pdev->dev, "device controller reset\n"); |
2673 | /* controller reset */ | 2762 | /* controller reset */ |
2674 | langwell_udc_reset(dev); | 2763 | langwell_udc_reset(dev); |
2675 | 2764 | ||
@@ -2691,15 +2780,14 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
2691 | dev->lotg->hsm.b_hnp_enable = 0; | 2780 | dev->lotg->hsm.b_hnp_enable = 0; |
2692 | #endif | 2781 | #endif |
2693 | 2782 | ||
2694 | VDBG(dev, "<--- %s()\n", __func__); | 2783 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2695 | } | 2784 | } |
2696 | 2785 | ||
2697 | 2786 | ||
2698 | /* USB bus suspend/resume interrupt */ | 2787 | /* USB bus suspend/resume interrupt */ |
2699 | static void handle_bus_suspend(struct langwell_udc *dev) | 2788 | static void handle_bus_suspend(struct langwell_udc *dev) |
2700 | { | 2789 | { |
2701 | u32 devlc; | 2790 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2702 | DBG(dev, "---> %s()\n", __func__); | ||
2703 | 2791 | ||
2704 | dev->resume_state = dev->usb_state; | 2792 | dev->resume_state = dev->usb_state; |
2705 | dev->usb_state = USB_STATE_SUSPENDED; | 2793 | dev->usb_state = USB_STATE_SUSPENDED; |
@@ -2733,33 +2821,29 @@ static void handle_bus_suspend(struct langwell_udc *dev) | |||
2733 | spin_unlock(&dev->lock); | 2821 | spin_unlock(&dev->lock); |
2734 | dev->driver->suspend(&dev->gadget); | 2822 | dev->driver->suspend(&dev->gadget); |
2735 | spin_lock(&dev->lock); | 2823 | spin_lock(&dev->lock); |
2736 | DBG(dev, "suspend %s\n", dev->driver->driver.name); | 2824 | dev_dbg(&dev->pdev->dev, "suspend %s\n", |
2825 | dev->driver->driver.name); | ||
2737 | } | 2826 | } |
2738 | } | 2827 | } |
2739 | 2828 | ||
2740 | /* enter PHY low power suspend */ | 2829 | /* enter PHY low power suspend */ |
2741 | devlc = readl(&dev->op_regs->devlc); | 2830 | if (dev->pdev->device != 0x0829) |
2742 | VDBG(dev, "devlc = 0x%08x\n", devlc); | 2831 | langwell_phy_low_power(dev, 0); |
2743 | devlc |= LPM_PHCD; | ||
2744 | writel(devlc, &dev->op_regs->devlc); | ||
2745 | 2832 | ||
2746 | DBG(dev, "<--- %s()\n", __func__); | 2833 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2747 | } | 2834 | } |
2748 | 2835 | ||
2749 | 2836 | ||
2750 | static void handle_bus_resume(struct langwell_udc *dev) | 2837 | static void handle_bus_resume(struct langwell_udc *dev) |
2751 | { | 2838 | { |
2752 | u32 devlc; | 2839 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2753 | DBG(dev, "---> %s()\n", __func__); | ||
2754 | 2840 | ||
2755 | dev->usb_state = dev->resume_state; | 2841 | dev->usb_state = dev->resume_state; |
2756 | dev->resume_state = 0; | 2842 | dev->resume_state = 0; |
2757 | 2843 | ||
2758 | /* exit PHY low power suspend */ | 2844 | /* exit PHY low power suspend */ |
2759 | devlc = readl(&dev->op_regs->devlc); | 2845 | if (dev->pdev->device != 0x0829) |
2760 | VDBG(dev, "devlc = 0x%08x\n", devlc); | 2846 | langwell_phy_low_power(dev, 0); |
2761 | devlc &= ~LPM_PHCD; | ||
2762 | writel(devlc, &dev->op_regs->devlc); | ||
2763 | 2847 | ||
2764 | #ifdef OTG_TRANSCEIVER | 2848 | #ifdef OTG_TRANSCEIVER |
2765 | if (dev->lotg->otg.default_a == 0) | 2849 | if (dev->lotg->otg.default_a == 0) |
@@ -2772,11 +2856,12 @@ static void handle_bus_resume(struct langwell_udc *dev) | |||
2772 | spin_unlock(&dev->lock); | 2856 | spin_unlock(&dev->lock); |
2773 | dev->driver->resume(&dev->gadget); | 2857 | dev->driver->resume(&dev->gadget); |
2774 | spin_lock(&dev->lock); | 2858 | spin_lock(&dev->lock); |
2775 | DBG(dev, "resume %s\n", dev->driver->driver.name); | 2859 | dev_dbg(&dev->pdev->dev, "resume %s\n", |
2860 | dev->driver->driver.name); | ||
2776 | } | 2861 | } |
2777 | } | 2862 | } |
2778 | 2863 | ||
2779 | DBG(dev, "<--- %s()\n", __func__); | 2864 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2780 | } | 2865 | } |
2781 | 2866 | ||
2782 | 2867 | ||
@@ -2789,11 +2874,11 @@ static irqreturn_t langwell_irq(int irq, void *_dev) | |||
2789 | irq_sts, | 2874 | irq_sts, |
2790 | portsc1; | 2875 | portsc1; |
2791 | 2876 | ||
2792 | VDBG(dev, "---> %s()\n", __func__); | 2877 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2793 | 2878 | ||
2794 | if (dev->stopped) { | 2879 | if (dev->stopped) { |
2795 | VDBG(dev, "handle IRQ_NONE\n"); | 2880 | dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n"); |
2796 | VDBG(dev, "<--- %s()\n", __func__); | 2881 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2797 | return IRQ_NONE; | 2882 | return IRQ_NONE; |
2798 | } | 2883 | } |
2799 | 2884 | ||
@@ -2806,12 +2891,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev) | |||
2806 | usbintr = readl(&dev->op_regs->usbintr); | 2891 | usbintr = readl(&dev->op_regs->usbintr); |
2807 | 2892 | ||
2808 | irq_sts = usbsts & usbintr; | 2893 | irq_sts = usbsts & usbintr; |
2809 | VDBG(dev, "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n", | 2894 | dev_vdbg(&dev->pdev->dev, |
2895 | "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n", | ||
2810 | usbsts, usbintr, irq_sts); | 2896 | usbsts, usbintr, irq_sts); |
2811 | 2897 | ||
2812 | if (!irq_sts) { | 2898 | if (!irq_sts) { |
2813 | VDBG(dev, "handle IRQ_NONE\n"); | 2899 | dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n"); |
2814 | VDBG(dev, "<--- %s()\n", __func__); | 2900 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2815 | spin_unlock(&dev->lock); | 2901 | spin_unlock(&dev->lock); |
2816 | return IRQ_NONE; | 2902 | return IRQ_NONE; |
2817 | } | 2903 | } |
@@ -2827,12 +2913,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev) | |||
2827 | 2913 | ||
2828 | /* USB interrupt */ | 2914 | /* USB interrupt */ |
2829 | if (irq_sts & STS_UI) { | 2915 | if (irq_sts & STS_UI) { |
2830 | VDBG(dev, "USB interrupt\n"); | 2916 | dev_vdbg(&dev->pdev->dev, "USB interrupt\n"); |
2831 | 2917 | ||
2832 | /* setup packet received from ep0 */ | 2918 | /* setup packet received from ep0 */ |
2833 | if (readl(&dev->op_regs->endptsetupstat) | 2919 | if (readl(&dev->op_regs->endptsetupstat) |
2834 | & EP0SETUPSTAT_MASK) { | 2920 | & EP0SETUPSTAT_MASK) { |
2835 | VDBG(dev, "USB SETUP packet received interrupt\n"); | 2921 | dev_vdbg(&dev->pdev->dev, |
2922 | "USB SETUP packet received interrupt\n"); | ||
2836 | /* setup tripwire semaphone */ | 2923 | /* setup tripwire semaphone */ |
2837 | setup_tripwire(dev); | 2924 | setup_tripwire(dev); |
2838 | handle_setup_packet(dev, &dev->local_setup_buff); | 2925 | handle_setup_packet(dev, &dev->local_setup_buff); |
@@ -2840,7 +2927,8 @@ static irqreturn_t langwell_irq(int irq, void *_dev) | |||
2840 | 2927 | ||
2841 | /* USB transfer completion */ | 2928 | /* USB transfer completion */ |
2842 | if (readl(&dev->op_regs->endptcomplete)) { | 2929 | if (readl(&dev->op_regs->endptcomplete)) { |
2843 | VDBG(dev, "USB transfer completion interrupt\n"); | 2930 | dev_vdbg(&dev->pdev->dev, |
2931 | "USB transfer completion interrupt\n"); | ||
2844 | handle_trans_complete(dev); | 2932 | handle_trans_complete(dev); |
2845 | } | 2933 | } |
2846 | } | 2934 | } |
@@ -2848,36 +2936,36 @@ static irqreturn_t langwell_irq(int irq, void *_dev) | |||
2848 | /* SOF received interrupt (for ISO transfer) */ | 2936 | /* SOF received interrupt (for ISO transfer) */ |
2849 | if (irq_sts & STS_SRI) { | 2937 | if (irq_sts & STS_SRI) { |
2850 | /* FIXME */ | 2938 | /* FIXME */ |
2851 | /* VDBG(dev, "SOF received interrupt\n"); */ | 2939 | /* dev_vdbg(&dev->pdev->dev, "SOF received interrupt\n"); */ |
2852 | } | 2940 | } |
2853 | 2941 | ||
2854 | /* port change detect interrupt */ | 2942 | /* port change detect interrupt */ |
2855 | if (irq_sts & STS_PCI) { | 2943 | if (irq_sts & STS_PCI) { |
2856 | VDBG(dev, "port change detect interrupt\n"); | 2944 | dev_vdbg(&dev->pdev->dev, "port change detect interrupt\n"); |
2857 | handle_port_change(dev); | 2945 | handle_port_change(dev); |
2858 | } | 2946 | } |
2859 | 2947 | ||
2860 | /* suspend interrrupt */ | 2948 | /* suspend interrrupt */ |
2861 | if (irq_sts & STS_SLI) { | 2949 | if (irq_sts & STS_SLI) { |
2862 | VDBG(dev, "suspend interrupt\n"); | 2950 | dev_vdbg(&dev->pdev->dev, "suspend interrupt\n"); |
2863 | handle_bus_suspend(dev); | 2951 | handle_bus_suspend(dev); |
2864 | } | 2952 | } |
2865 | 2953 | ||
2866 | /* USB reset interrupt */ | 2954 | /* USB reset interrupt */ |
2867 | if (irq_sts & STS_URI) { | 2955 | if (irq_sts & STS_URI) { |
2868 | VDBG(dev, "USB reset interrupt\n"); | 2956 | dev_vdbg(&dev->pdev->dev, "USB reset interrupt\n"); |
2869 | handle_usb_reset(dev); | 2957 | handle_usb_reset(dev); |
2870 | } | 2958 | } |
2871 | 2959 | ||
2872 | /* USB error or system error interrupt */ | 2960 | /* USB error or system error interrupt */ |
2873 | if (irq_sts & (STS_UEI | STS_SEI)) { | 2961 | if (irq_sts & (STS_UEI | STS_SEI)) { |
2874 | /* FIXME */ | 2962 | /* FIXME */ |
2875 | WARNING(dev, "error IRQ, irq_sts: %x\n", irq_sts); | 2963 | dev_warn(&dev->pdev->dev, "error IRQ, irq_sts: %x\n", irq_sts); |
2876 | } | 2964 | } |
2877 | 2965 | ||
2878 | spin_unlock(&dev->lock); | 2966 | spin_unlock(&dev->lock); |
2879 | 2967 | ||
2880 | VDBG(dev, "<--- %s()\n", __func__); | 2968 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2881 | return IRQ_HANDLED; | 2969 | return IRQ_HANDLED; |
2882 | } | 2970 | } |
2883 | 2971 | ||
@@ -2889,15 +2977,59 @@ static void gadget_release(struct device *_dev) | |||
2889 | { | 2977 | { |
2890 | struct langwell_udc *dev = the_controller; | 2978 | struct langwell_udc *dev = the_controller; |
2891 | 2979 | ||
2892 | DBG(dev, "---> %s()\n", __func__); | 2980 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2893 | 2981 | ||
2894 | complete(dev->done); | 2982 | complete(dev->done); |
2895 | 2983 | ||
2896 | DBG(dev, "<--- %s()\n", __func__); | 2984 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2897 | kfree(dev); | 2985 | kfree(dev); |
2898 | } | 2986 | } |
2899 | 2987 | ||
2900 | 2988 | ||
2989 | /* enable SRAM caching if SRAM detected */ | ||
2990 | static void sram_init(struct langwell_udc *dev) | ||
2991 | { | ||
2992 | struct pci_dev *pdev = dev->pdev; | ||
2993 | |||
2994 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); | ||
2995 | |||
2996 | dev->sram_addr = pci_resource_start(pdev, 1); | ||
2997 | dev->sram_size = pci_resource_len(pdev, 1); | ||
2998 | dev_info(&dev->pdev->dev, "Found private SRAM at %x size:%x\n", | ||
2999 | dev->sram_addr, dev->sram_size); | ||
3000 | dev->got_sram = 1; | ||
3001 | |||
3002 | if (pci_request_region(pdev, 1, kobject_name(&pdev->dev.kobj))) { | ||
3003 | dev_warn(&dev->pdev->dev, "SRAM request failed\n"); | ||
3004 | dev->got_sram = 0; | ||
3005 | } else if (!dma_declare_coherent_memory(&pdev->dev, dev->sram_addr, | ||
3006 | dev->sram_addr, dev->sram_size, DMA_MEMORY_MAP)) { | ||
3007 | dev_warn(&dev->pdev->dev, "SRAM DMA declare failed\n"); | ||
3008 | pci_release_region(pdev, 1); | ||
3009 | dev->got_sram = 0; | ||
3010 | } | ||
3011 | |||
3012 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
3013 | } | ||
3014 | |||
3015 | |||
3016 | /* release SRAM caching */ | ||
3017 | static void sram_deinit(struct langwell_udc *dev) | ||
3018 | { | ||
3019 | struct pci_dev *pdev = dev->pdev; | ||
3020 | |||
3021 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); | ||
3022 | |||
3023 | dma_release_declared_memory(&pdev->dev); | ||
3024 | pci_release_region(pdev, 1); | ||
3025 | |||
3026 | dev->got_sram = 0; | ||
3027 | |||
3028 | dev_info(&dev->pdev->dev, "release SRAM caching\n"); | ||
3029 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
3030 | } | ||
3031 | |||
3032 | |||
2901 | /* tear down the binding between this driver and the pci device */ | 3033 | /* tear down the binding between this driver and the pci device */ |
2902 | static void langwell_udc_remove(struct pci_dev *pdev) | 3034 | static void langwell_udc_remove(struct pci_dev *pdev) |
2903 | { | 3035 | { |
@@ -2906,23 +3038,29 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
2906 | DECLARE_COMPLETION(done); | 3038 | DECLARE_COMPLETION(done); |
2907 | 3039 | ||
2908 | BUG_ON(dev->driver); | 3040 | BUG_ON(dev->driver); |
2909 | DBG(dev, "---> %s()\n", __func__); | 3041 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
2910 | 3042 | ||
2911 | dev->done = &done; | 3043 | dev->done = &done; |
2912 | 3044 | ||
2913 | /* free memory allocated in probe */ | 3045 | #ifndef OTG_TRANSCEIVER |
3046 | /* free dTD dma_pool and dQH */ | ||
2914 | if (dev->dtd_pool) | 3047 | if (dev->dtd_pool) |
2915 | dma_pool_destroy(dev->dtd_pool); | 3048 | dma_pool_destroy(dev->dtd_pool); |
2916 | 3049 | ||
3050 | if (dev->ep_dqh) | ||
3051 | dma_free_coherent(&pdev->dev, dev->ep_dqh_size, | ||
3052 | dev->ep_dqh, dev->ep_dqh_dma); | ||
3053 | |||
3054 | /* release SRAM caching */ | ||
3055 | if (dev->has_sram && dev->got_sram) | ||
3056 | sram_deinit(dev); | ||
3057 | #endif | ||
3058 | |||
2917 | if (dev->status_req) { | 3059 | if (dev->status_req) { |
2918 | kfree(dev->status_req->req.buf); | 3060 | kfree(dev->status_req->req.buf); |
2919 | kfree(dev->status_req); | 3061 | kfree(dev->status_req); |
2920 | } | 3062 | } |
2921 | 3063 | ||
2922 | if (dev->ep_dqh) | ||
2923 | dma_free_coherent(&pdev->dev, dev->ep_dqh_size, | ||
2924 | dev->ep_dqh, dev->ep_dqh_dma); | ||
2925 | |||
2926 | kfree(dev->ep); | 3064 | kfree(dev->ep); |
2927 | 3065 | ||
2928 | /* diable IRQ handler */ | 3066 | /* diable IRQ handler */ |
@@ -2949,11 +3087,12 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
2949 | 3087 | ||
2950 | dev->cap_regs = NULL; | 3088 | dev->cap_regs = NULL; |
2951 | 3089 | ||
2952 | INFO(dev, "unbind\n"); | 3090 | dev_info(&dev->pdev->dev, "unbind\n"); |
2953 | DBG(dev, "<--- %s()\n", __func__); | 3091 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
2954 | 3092 | ||
2955 | device_unregister(&dev->gadget.dev); | 3093 | device_unregister(&dev->gadget.dev); |
2956 | device_remove_file(&pdev->dev, &dev_attr_langwell_udc); | 3094 | device_remove_file(&pdev->dev, &dev_attr_langwell_udc); |
3095 | device_remove_file(&pdev->dev, &dev_attr_remote_wakeup); | ||
2957 | 3096 | ||
2958 | #ifndef OTG_TRANSCEIVER | 3097 | #ifndef OTG_TRANSCEIVER |
2959 | pci_set_drvdata(pdev, NULL); | 3098 | pci_set_drvdata(pdev, NULL); |
@@ -2997,7 +3136,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
2997 | spin_lock_init(&dev->lock); | 3136 | spin_lock_init(&dev->lock); |
2998 | 3137 | ||
2999 | dev->pdev = pdev; | 3138 | dev->pdev = pdev; |
3000 | DBG(dev, "---> %s()\n", __func__); | 3139 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
3001 | 3140 | ||
3002 | #ifdef OTG_TRANSCEIVER | 3141 | #ifdef OTG_TRANSCEIVER |
3003 | /* PCI device is already enabled by otg_transceiver driver */ | 3142 | /* PCI device is already enabled by otg_transceiver driver */ |
@@ -3022,7 +3161,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3022 | resource = pci_resource_start(pdev, 0); | 3161 | resource = pci_resource_start(pdev, 0); |
3023 | len = pci_resource_len(pdev, 0); | 3162 | len = pci_resource_len(pdev, 0); |
3024 | if (!request_mem_region(resource, len, driver_name)) { | 3163 | if (!request_mem_region(resource, len, driver_name)) { |
3025 | ERROR(dev, "controller already in use\n"); | 3164 | dev_err(&dev->pdev->dev, "controller already in use\n"); |
3026 | retval = -EBUSY; | 3165 | retval = -EBUSY; |
3027 | goto error; | 3166 | goto error; |
3028 | } | 3167 | } |
@@ -3031,33 +3170,43 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3031 | base = ioremap_nocache(resource, len); | 3170 | base = ioremap_nocache(resource, len); |
3032 | #endif | 3171 | #endif |
3033 | if (base == NULL) { | 3172 | if (base == NULL) { |
3034 | ERROR(dev, "can't map memory\n"); | 3173 | dev_err(&dev->pdev->dev, "can't map memory\n"); |
3035 | retval = -EFAULT; | 3174 | retval = -EFAULT; |
3036 | goto error; | 3175 | goto error; |
3037 | } | 3176 | } |
3038 | 3177 | ||
3039 | dev->cap_regs = (struct langwell_cap_regs __iomem *) base; | 3178 | dev->cap_regs = (struct langwell_cap_regs __iomem *) base; |
3040 | VDBG(dev, "dev->cap_regs: %p\n", dev->cap_regs); | 3179 | dev_vdbg(&dev->pdev->dev, "dev->cap_regs: %p\n", dev->cap_regs); |
3041 | dev->op_regs = (struct langwell_op_regs __iomem *) | 3180 | dev->op_regs = (struct langwell_op_regs __iomem *) |
3042 | (base + OP_REG_OFFSET); | 3181 | (base + OP_REG_OFFSET); |
3043 | VDBG(dev, "dev->op_regs: %p\n", dev->op_regs); | 3182 | dev_vdbg(&dev->pdev->dev, "dev->op_regs: %p\n", dev->op_regs); |
3044 | 3183 | ||
3045 | /* irq setup after old hardware is cleaned up */ | 3184 | /* irq setup after old hardware is cleaned up */ |
3046 | if (!pdev->irq) { | 3185 | if (!pdev->irq) { |
3047 | ERROR(dev, "No IRQ. Check PCI setup!\n"); | 3186 | dev_err(&dev->pdev->dev, "No IRQ. Check PCI setup!\n"); |
3048 | retval = -ENODEV; | 3187 | retval = -ENODEV; |
3049 | goto error; | 3188 | goto error; |
3050 | } | 3189 | } |
3051 | 3190 | ||
3191 | dev->has_sram = 1; | ||
3192 | dev->got_sram = 0; | ||
3193 | dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram); | ||
3194 | |||
3052 | #ifndef OTG_TRANSCEIVER | 3195 | #ifndef OTG_TRANSCEIVER |
3053 | INFO(dev, "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n", | 3196 | /* enable SRAM caching if detected */ |
3197 | if (dev->has_sram && !dev->got_sram) | ||
3198 | sram_init(dev); | ||
3199 | |||
3200 | dev_info(&dev->pdev->dev, | ||
3201 | "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n", | ||
3054 | pdev->irq, resource, len, base); | 3202 | pdev->irq, resource, len, base); |
3055 | /* enables bus-mastering for device dev */ | 3203 | /* enables bus-mastering for device dev */ |
3056 | pci_set_master(pdev); | 3204 | pci_set_master(pdev); |
3057 | 3205 | ||
3058 | if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, | 3206 | if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, |
3059 | driver_name, dev) != 0) { | 3207 | driver_name, dev) != 0) { |
3060 | ERROR(dev, "request interrupt %d failed\n", pdev->irq); | 3208 | dev_err(&dev->pdev->dev, |
3209 | "request interrupt %d failed\n", pdev->irq); | ||
3061 | retval = -EBUSY; | 3210 | retval = -EBUSY; |
3062 | goto error; | 3211 | goto error; |
3063 | } | 3212 | } |
@@ -3071,32 +3220,34 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3071 | dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0; | 3220 | dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0; |
3072 | dev->dciversion = readw(&dev->cap_regs->dciversion); | 3221 | dev->dciversion = readw(&dev->cap_regs->dciversion); |
3073 | dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0; | 3222 | dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0; |
3074 | VDBG(dev, "dev->lpm: %d\n", dev->lpm); | 3223 | dev_vdbg(&dev->pdev->dev, "dev->lpm: %d\n", dev->lpm); |
3075 | VDBG(dev, "dev->dciversion: 0x%04x\n", dev->dciversion); | 3224 | dev_vdbg(&dev->pdev->dev, "dev->dciversion: 0x%04x\n", |
3076 | VDBG(dev, "dccparams: 0x%08x\n", readl(&dev->cap_regs->dccparams)); | 3225 | dev->dciversion); |
3077 | VDBG(dev, "dev->devcap: %d\n", dev->devcap); | 3226 | dev_vdbg(&dev->pdev->dev, "dccparams: 0x%08x\n", |
3227 | readl(&dev->cap_regs->dccparams)); | ||
3228 | dev_vdbg(&dev->pdev->dev, "dev->devcap: %d\n", dev->devcap); | ||
3078 | if (!dev->devcap) { | 3229 | if (!dev->devcap) { |
3079 | ERROR(dev, "can't support device mode\n"); | 3230 | dev_err(&dev->pdev->dev, "can't support device mode\n"); |
3080 | retval = -ENODEV; | 3231 | retval = -ENODEV; |
3081 | goto error; | 3232 | goto error; |
3082 | } | 3233 | } |
3083 | 3234 | ||
3084 | /* a pair of endpoints (out/in) for each address */ | 3235 | /* a pair of endpoints (out/in) for each address */ |
3085 | dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2; | 3236 | dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2; |
3086 | VDBG(dev, "dev->ep_max: %d\n", dev->ep_max); | 3237 | dev_vdbg(&dev->pdev->dev, "dev->ep_max: %d\n", dev->ep_max); |
3087 | 3238 | ||
3088 | /* allocate endpoints memory */ | 3239 | /* allocate endpoints memory */ |
3089 | dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max, | 3240 | dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max, |
3090 | GFP_KERNEL); | 3241 | GFP_KERNEL); |
3091 | if (!dev->ep) { | 3242 | if (!dev->ep) { |
3092 | ERROR(dev, "allocate endpoints memory failed\n"); | 3243 | dev_err(&dev->pdev->dev, "allocate endpoints memory failed\n"); |
3093 | retval = -ENOMEM; | 3244 | retval = -ENOMEM; |
3094 | goto error; | 3245 | goto error; |
3095 | } | 3246 | } |
3096 | 3247 | ||
3097 | /* allocate device dQH memory */ | 3248 | /* allocate device dQH memory */ |
3098 | size = dev->ep_max * sizeof(struct langwell_dqh); | 3249 | size = dev->ep_max * sizeof(struct langwell_dqh); |
3099 | VDBG(dev, "orig size = %d\n", size); | 3250 | dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size); |
3100 | if (size < DQH_ALIGNMENT) | 3251 | if (size < DQH_ALIGNMENT) |
3101 | size = DQH_ALIGNMENT; | 3252 | size = DQH_ALIGNMENT; |
3102 | else if ((size % DQH_ALIGNMENT) != 0) { | 3253 | else if ((size % DQH_ALIGNMENT) != 0) { |
@@ -3106,17 +3257,18 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3106 | dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size, | 3257 | dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size, |
3107 | &dev->ep_dqh_dma, GFP_KERNEL); | 3258 | &dev->ep_dqh_dma, GFP_KERNEL); |
3108 | if (!dev->ep_dqh) { | 3259 | if (!dev->ep_dqh) { |
3109 | ERROR(dev, "allocate dQH memory failed\n"); | 3260 | dev_err(&dev->pdev->dev, "allocate dQH memory failed\n"); |
3110 | retval = -ENOMEM; | 3261 | retval = -ENOMEM; |
3111 | goto error; | 3262 | goto error; |
3112 | } | 3263 | } |
3113 | dev->ep_dqh_size = size; | 3264 | dev->ep_dqh_size = size; |
3114 | VDBG(dev, "ep_dqh_size = %d\n", dev->ep_dqh_size); | 3265 | dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size); |
3115 | 3266 | ||
3116 | /* initialize ep0 status request structure */ | 3267 | /* initialize ep0 status request structure */ |
3117 | dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL); | 3268 | dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL); |
3118 | if (!dev->status_req) { | 3269 | if (!dev->status_req) { |
3119 | ERROR(dev, "allocate status_req memory failed\n"); | 3270 | dev_err(&dev->pdev->dev, |
3271 | "allocate status_req memory failed\n"); | ||
3120 | retval = -ENOMEM; | 3272 | retval = -ENOMEM; |
3121 | goto error; | 3273 | goto error; |
3122 | } | 3274 | } |
@@ -3129,7 +3281,10 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3129 | dev->resume_state = USB_STATE_NOTATTACHED; | 3281 | dev->resume_state = USB_STATE_NOTATTACHED; |
3130 | dev->usb_state = USB_STATE_POWERED; | 3282 | dev->usb_state = USB_STATE_POWERED; |
3131 | dev->ep0_dir = USB_DIR_OUT; | 3283 | dev->ep0_dir = USB_DIR_OUT; |
3132 | dev->remote_wakeup = 0; /* default to 0 on reset */ | 3284 | |
3285 | /* remote wakeup reset to 0 when the device is reset */ | ||
3286 | dev->remote_wakeup = 0; | ||
3287 | dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; | ||
3133 | 3288 | ||
3134 | #ifndef OTG_TRANSCEIVER | 3289 | #ifndef OTG_TRANSCEIVER |
3135 | /* reset device controller */ | 3290 | /* reset device controller */ |
@@ -3174,18 +3329,20 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3174 | } | 3329 | } |
3175 | 3330 | ||
3176 | /* done */ | 3331 | /* done */ |
3177 | INFO(dev, "%s\n", driver_desc); | 3332 | dev_info(&dev->pdev->dev, "%s\n", driver_desc); |
3178 | INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base); | 3333 | dev_info(&dev->pdev->dev, "irq %d, pci mem %p\n", pdev->irq, base); |
3179 | INFO(dev, "Driver version: " DRIVER_VERSION "\n"); | 3334 | dev_info(&dev->pdev->dev, "Driver version: " DRIVER_VERSION "\n"); |
3180 | INFO(dev, "Support (max) %d endpoints\n", dev->ep_max); | 3335 | dev_info(&dev->pdev->dev, "Support (max) %d endpoints\n", dev->ep_max); |
3181 | INFO(dev, "Device interface version: 0x%04x\n", dev->dciversion); | 3336 | dev_info(&dev->pdev->dev, "Device interface version: 0x%04x\n", |
3182 | INFO(dev, "Controller mode: %s\n", dev->devcap ? "Device" : "Host"); | 3337 | dev->dciversion); |
3183 | INFO(dev, "Support USB LPM: %s\n", dev->lpm ? "Yes" : "No"); | 3338 | dev_info(&dev->pdev->dev, "Controller mode: %s\n", |
3184 | 3339 | dev->devcap ? "Device" : "Host"); | |
3185 | VDBG(dev, "After langwell_udc_probe(), print all registers:\n"); | 3340 | dev_info(&dev->pdev->dev, "Support USB LPM: %s\n", |
3186 | #ifdef VERBOSE | 3341 | dev->lpm ? "Yes" : "No"); |
3342 | |||
3343 | dev_vdbg(&dev->pdev->dev, | ||
3344 | "After langwell_udc_probe(), print all registers:\n"); | ||
3187 | print_all_registers(dev); | 3345 | print_all_registers(dev); |
3188 | #endif | ||
3189 | 3346 | ||
3190 | the_controller = dev; | 3347 | the_controller = dev; |
3191 | 3348 | ||
@@ -3197,12 +3354,18 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
3197 | if (retval) | 3354 | if (retval) |
3198 | goto error; | 3355 | goto error; |
3199 | 3356 | ||
3200 | VDBG(dev, "<--- %s()\n", __func__); | 3357 | retval = device_create_file(&pdev->dev, &dev_attr_remote_wakeup); |
3358 | if (retval) | ||
3359 | goto error_attr1; | ||
3360 | |||
3361 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | ||
3201 | return 0; | 3362 | return 0; |
3202 | 3363 | ||
3364 | error_attr1: | ||
3365 | device_remove_file(&pdev->dev, &dev_attr_langwell_udc); | ||
3203 | error: | 3366 | error: |
3204 | if (dev) { | 3367 | if (dev) { |
3205 | DBG(dev, "<--- %s()\n", __func__); | 3368 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
3206 | langwell_udc_remove(pdev); | 3369 | langwell_udc_remove(pdev); |
3207 | } | 3370 | } |
3208 | 3371 | ||
@@ -3214,9 +3377,8 @@ error: | |||
3214 | static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) | 3377 | static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) |
3215 | { | 3378 | { |
3216 | struct langwell_udc *dev = the_controller; | 3379 | struct langwell_udc *dev = the_controller; |
3217 | u32 devlc; | ||
3218 | 3380 | ||
3219 | DBG(dev, "---> %s()\n", __func__); | 3381 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
3220 | 3382 | ||
3221 | /* disable interrupt and set controller to stop state */ | 3383 | /* disable interrupt and set controller to stop state */ |
3222 | langwell_udc_stop(dev); | 3384 | langwell_udc_stop(dev); |
@@ -3226,20 +3388,34 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3226 | free_irq(pdev->irq, dev); | 3388 | free_irq(pdev->irq, dev); |
3227 | dev->got_irq = 0; | 3389 | dev->got_irq = 0; |
3228 | 3390 | ||
3229 | |||
3230 | /* save PCI state */ | 3391 | /* save PCI state */ |
3231 | pci_save_state(pdev); | 3392 | pci_save_state(pdev); |
3232 | 3393 | ||
3394 | spin_lock_irq(&dev->lock); | ||
3395 | /* stop all usb activities */ | ||
3396 | stop_activity(dev, dev->driver); | ||
3397 | spin_unlock_irq(&dev->lock); | ||
3398 | |||
3399 | /* free dTD dma_pool and dQH */ | ||
3400 | if (dev->dtd_pool) | ||
3401 | dma_pool_destroy(dev->dtd_pool); | ||
3402 | |||
3403 | if (dev->ep_dqh) | ||
3404 | dma_free_coherent(&pdev->dev, dev->ep_dqh_size, | ||
3405 | dev->ep_dqh, dev->ep_dqh_dma); | ||
3406 | |||
3407 | /* release SRAM caching */ | ||
3408 | if (dev->has_sram && dev->got_sram) | ||
3409 | sram_deinit(dev); | ||
3410 | |||
3233 | /* set device power state */ | 3411 | /* set device power state */ |
3234 | pci_set_power_state(pdev, PCI_D3hot); | 3412 | pci_set_power_state(pdev, PCI_D3hot); |
3235 | 3413 | ||
3236 | /* enter PHY low power suspend */ | 3414 | /* enter PHY low power suspend */ |
3237 | devlc = readl(&dev->op_regs->devlc); | 3415 | if (dev->pdev->device != 0x0829) |
3238 | VDBG(dev, "devlc = 0x%08x\n", devlc); | 3416 | langwell_phy_low_power(dev, 1); |
3239 | devlc |= LPM_PHCD; | ||
3240 | writel(devlc, &dev->op_regs->devlc); | ||
3241 | 3417 | ||
3242 | DBG(dev, "<--- %s()\n", __func__); | 3418 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
3243 | return 0; | 3419 | return 0; |
3244 | } | 3420 | } |
3245 | 3421 | ||
@@ -3248,27 +3424,58 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3248 | static int langwell_udc_resume(struct pci_dev *pdev) | 3424 | static int langwell_udc_resume(struct pci_dev *pdev) |
3249 | { | 3425 | { |
3250 | struct langwell_udc *dev = the_controller; | 3426 | struct langwell_udc *dev = the_controller; |
3251 | u32 devlc; | 3427 | size_t size; |
3252 | 3428 | ||
3253 | DBG(dev, "---> %s()\n", __func__); | 3429 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
3254 | 3430 | ||
3255 | /* exit PHY low power suspend */ | 3431 | /* exit PHY low power suspend */ |
3256 | devlc = readl(&dev->op_regs->devlc); | 3432 | if (dev->pdev->device != 0x0829) |
3257 | VDBG(dev, "devlc = 0x%08x\n", devlc); | 3433 | langwell_phy_low_power(dev, 0); |
3258 | devlc &= ~LPM_PHCD; | ||
3259 | writel(devlc, &dev->op_regs->devlc); | ||
3260 | 3434 | ||
3261 | /* set device D0 power state */ | 3435 | /* set device D0 power state */ |
3262 | pci_set_power_state(pdev, PCI_D0); | 3436 | pci_set_power_state(pdev, PCI_D0); |
3263 | 3437 | ||
3438 | /* enable SRAM caching if detected */ | ||
3439 | if (dev->has_sram && !dev->got_sram) | ||
3440 | sram_init(dev); | ||
3441 | |||
3442 | /* allocate device dQH memory */ | ||
3443 | size = dev->ep_max * sizeof(struct langwell_dqh); | ||
3444 | dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size); | ||
3445 | if (size < DQH_ALIGNMENT) | ||
3446 | size = DQH_ALIGNMENT; | ||
3447 | else if ((size % DQH_ALIGNMENT) != 0) { | ||
3448 | size += DQH_ALIGNMENT + 1; | ||
3449 | size &= ~(DQH_ALIGNMENT - 1); | ||
3450 | } | ||
3451 | dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size, | ||
3452 | &dev->ep_dqh_dma, GFP_KERNEL); | ||
3453 | if (!dev->ep_dqh) { | ||
3454 | dev_err(&dev->pdev->dev, "allocate dQH memory failed\n"); | ||
3455 | return -ENOMEM; | ||
3456 | } | ||
3457 | dev->ep_dqh_size = size; | ||
3458 | dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size); | ||
3459 | |||
3460 | /* create dTD dma_pool resource */ | ||
3461 | dev->dtd_pool = dma_pool_create("langwell_dtd", | ||
3462 | &dev->pdev->dev, | ||
3463 | sizeof(struct langwell_dtd), | ||
3464 | DTD_ALIGNMENT, | ||
3465 | DMA_BOUNDARY); | ||
3466 | |||
3467 | if (!dev->dtd_pool) | ||
3468 | return -ENOMEM; | ||
3469 | |||
3264 | /* restore PCI state */ | 3470 | /* restore PCI state */ |
3265 | pci_restore_state(pdev); | 3471 | pci_restore_state(pdev); |
3266 | 3472 | ||
3267 | /* enable IRQ handler */ | 3473 | /* enable IRQ handler */ |
3268 | if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, driver_name, dev) | 3474 | if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, |
3269 | != 0) { | 3475 | driver_name, dev) != 0) { |
3270 | ERROR(dev, "request interrupt %d failed\n", pdev->irq); | 3476 | dev_err(&dev->pdev->dev, "request interrupt %d failed\n", |
3271 | return -1; | 3477 | pdev->irq); |
3478 | return -EBUSY; | ||
3272 | } | 3479 | } |
3273 | dev->got_irq = 1; | 3480 | dev->got_irq = 1; |
3274 | 3481 | ||
@@ -3290,7 +3497,7 @@ static int langwell_udc_resume(struct pci_dev *pdev) | |||
3290 | dev->ep0_state = WAIT_FOR_SETUP; | 3497 | dev->ep0_state = WAIT_FOR_SETUP; |
3291 | dev->ep0_dir = USB_DIR_OUT; | 3498 | dev->ep0_dir = USB_DIR_OUT; |
3292 | 3499 | ||
3293 | DBG(dev, "<--- %s()\n", __func__); | 3500 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
3294 | return 0; | 3501 | return 0; |
3295 | } | 3502 | } |
3296 | 3503 | ||
@@ -3301,15 +3508,15 @@ static void langwell_udc_shutdown(struct pci_dev *pdev) | |||
3301 | struct langwell_udc *dev = the_controller; | 3508 | struct langwell_udc *dev = the_controller; |
3302 | u32 usbmode; | 3509 | u32 usbmode; |
3303 | 3510 | ||
3304 | DBG(dev, "---> %s()\n", __func__); | 3511 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
3305 | 3512 | ||
3306 | /* reset controller mode to IDLE */ | 3513 | /* reset controller mode to IDLE */ |
3307 | usbmode = readl(&dev->op_regs->usbmode); | 3514 | usbmode = readl(&dev->op_regs->usbmode); |
3308 | DBG(dev, "usbmode = 0x%08x\n", usbmode); | 3515 | dev_dbg(&dev->pdev->dev, "usbmode = 0x%08x\n", usbmode); |
3309 | usbmode &= (~3 | MODE_IDLE); | 3516 | usbmode &= (~3 | MODE_IDLE); |
3310 | writel(usbmode, &dev->op_regs->usbmode); | 3517 | writel(usbmode, &dev->op_regs->usbmode); |
3311 | 3518 | ||
3312 | DBG(dev, "<--- %s()\n", __func__); | 3519 | dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
3313 | } | 3520 | } |
3314 | 3521 | ||
3315 | /*-------------------------------------------------------------------------*/ | 3522 | /*-------------------------------------------------------------------------*/ |
@@ -3324,7 +3531,6 @@ static const struct pci_device_id pci_ids[] = { { | |||
3324 | }, { /* end: all zeroes */ } | 3531 | }, { /* end: all zeroes */ } |
3325 | }; | 3532 | }; |
3326 | 3533 | ||
3327 | |||
3328 | MODULE_DEVICE_TABLE(pci, pci_ids); | 3534 | MODULE_DEVICE_TABLE(pci, pci_ids); |
3329 | 3535 | ||
3330 | 3536 | ||
@@ -3343,12 +3549,6 @@ static struct pci_driver langwell_pci_driver = { | |||
3343 | }; | 3549 | }; |
3344 | 3550 | ||
3345 | 3551 | ||
3346 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
3347 | MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>"); | ||
3348 | MODULE_VERSION(DRIVER_VERSION); | ||
3349 | MODULE_LICENSE("GPL"); | ||
3350 | |||
3351 | |||
3352 | static int __init init(void) | 3552 | static int __init init(void) |
3353 | { | 3553 | { |
3354 | #ifdef OTG_TRANSCEIVER | 3554 | #ifdef OTG_TRANSCEIVER |
@@ -3370,3 +3570,9 @@ static void __exit cleanup(void) | |||
3370 | } | 3570 | } |
3371 | module_exit(cleanup); | 3571 | module_exit(cleanup); |
3372 | 3572 | ||
3573 | |||
3574 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
3575 | MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>"); | ||
3576 | MODULE_VERSION(DRIVER_VERSION); | ||
3577 | MODULE_LICENSE("GPL"); | ||
3578 | |||