1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
/****************************************************************************
* (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
*
* @file s3c-otg-hcdi-hcd.c
* @brief implementation of structure hc_drive \n
* @version
* -# Jun 11,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Creating the initial version of this code \n
* -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Optimizing for performance \n
* -# Aug 18,2008 v1.3 by SeungSoo Yang (ss1.yang@samsung.com) \n
* : Modifying for successful rmmod & disconnecting \n
* @see None
****************************************************************************/
/****************************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
#include "s3c-otg-hcdi-hcd.h"
/**
* otg_hcd_init_modules(struct sec_otghost *otghost)
*
* @brief call other modules' init functions
*
* @return PASS : If success \n
* FAIL : If fail \n
*/
int otg_hcd_init_modules(struct sec_otghost *otghost)
{
unsigned long spin_lock_flag = 0;
otg_dbg(OTG_DBG_OTGHCDI_HCD, "otg_hcd_init_modules\n");
spin_lock_init(&otghost->lock);
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
init_transfer();
init_scheduler();
oci_init(otghost);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
};
/**
* void otg_hcd_deinit_modules(struct sec_otghost *otghost)
*
* @brief call other modules' de-init functions
*
* @return PASS : If success \n
* FAIL : If fail \n
*/
void otg_hcd_deinit_modules(struct sec_otghost *otghost)
{
unsigned long spin_lock_flag = 0;
otg_dbg(OTG_DBG_OTGHCDI_HCD, "otg_hcd_deinit_modules \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
deinit_transfer(otghost);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
}
/**
* irqreturn_t (*s5pc110_otghcd_irq) (struct usb_hcd *hcd)
*
* @brief interrupt handler of otg irq
*
* @param [in] hcd : pointer of usb_hcd
*
* @return IRQ_HANDLED \n
*/
irqreturn_t s5pc110_otghcd_irq(struct usb_hcd *hcd)
{
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_irq \n");
spin_lock_otg(&otghost->lock);
otg_handle_interrupt(hcd);
spin_unlock_otg(&otghost->lock);
return IRQ_HANDLED;
}
/**
* int s5pc110_otghcd_start(struct usb_hcd *hcd)
*
* @brief initialize and start otg hcd
*
* @param [in] usb_hcd_p : pointer of usb_hcd
*
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
int s5pc110_otghcd_start(struct usb_hcd *usb_hcd_p)
{
struct usb_bus *usb_bus_p;
struct sec_otghost *otghost = hcd_to_sec_otghost(usb_hcd_p);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_start \n");
usb_bus_p = hcd_to_bus(usb_hcd_p);
/* Initialize and connect root hub if one is not already attached */
if (usb_bus_p->root_hub) {
otg_dbg(OTG_DBG_OTGHCDI_HCD, "OTG HCD Has Root Hub\n");
/* Inform the HUB driver to resume. */
otg_usbcore_resume_roothub();
} else {
otg_err(OTG_DBG_OTGHCDI_HCD,
"OTG HCD Does Not Have Root Hub\n");
return USB_ERR_FAIL;
}
set_bit(HCD_FLAG_POLL_RH,&usb_hcd_p->flags);
usb_hcd_p->uses_new_polling = 1;
/* init bus state before enable irq */
usb_hcd_p->state = HC_STATE_RUNNING;
oci_start(otghost); /* enable irq */
return USB_ERR_SUCCESS;
}
/**
* void s5pc110_otghcd_stop(struct usb_hcd *hcd)
*
* @brief deinitialize and stop otg hcd
*
* @param [in] hcd : pointer of usb_hcd
*
*/
void s5pc110_otghcd_stop(struct usb_hcd *hcd)
{
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_stop \n");
otg_hcd_deinit_modules(otghost);
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
oci_stop(otghost);
root_hub_feature(hcd, 0, ClearPortFeature, USB_PORT_FEAT_POWER, NULL);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
}
/**
* void s5pc110_otghcd_shutdown(struct usb_hcd *hcd)
*
* @brief shutdown otg hcd
*
* @param [in] usb_hcd_p : pointer of usb_hcd
*
*/
void s5pc110_otghcd_shutdown(struct usb_hcd *usb_hcd_p)
{
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(usb_hcd_p);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_shutdown \n");
otg_hcd_deinit_modules(otghost);
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
oci_stop(otghost);
root_hub_feature(usb_hcd_p, 0, ClearPortFeature, USB_PORT_FEAT_POWER, NULL);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
free_irq(IRQ_OTG, usb_hcd_p);
usb_hcd_p->state = HC_STATE_HALT;
otg_usbcore_hc_died();
}
/**
* int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
*
* @brief get currnet frame number
*
* @param [in] hcd : pointer of usb_hcd
*
* @return ret : frame number \n
*/
int s5pc110_otghcd_get_frame_number(struct usb_hcd *hcd)
{
int ret = 0;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_get_frame_number \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret = oci_get_frame_num();
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return ret;
}
/**
* int s5pc110_otghcd_urb_enqueue()
*
* @brief enqueue a urb to otg hcd
*
* @param [in] hcd : pointer of usb_hcd
* [in] ep : pointer of usb_host_endpoint
* [in] urb : pointer of urb
* [in] mem_flags : type of gfp_t
*
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
int s5pc110_otghcd_urb_enqueue (struct usb_hcd *hcd,
struct urb *urb,
gfp_t mem_flags)
{
int ret_val = 0;
u32 trans_flag = 0;
u32 return_td_addr = 0;
u8 dev_speed, ed_type = 0, additional_multi_count;
u16 max_packet_size;
u8 dev_addr = 0;
u8 ep_num = 0;
bool f_is_ep_in = true;
u8 interval = 0;
u32 sched_frame = 0;
u8 hub_addr = 0;
u8 hub_port = 0;
bool f_is_do_split = false;
ed_t *target_ed = NULL;
isoch_packet_desc_t *new_isoch_packet_desc = NULL;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
if (!otghost->port_flag.b.port_connect_status) {
printk(KERN_ERR"%s %d\n", __func__, __LINE__);
return USB_ERR_NOIO;
}
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_urb_enqueue \n");
/* check ep has ed_t or not */
if(!(urb->ep->hcpriv)) {
/* for getting dev_speed */
switch (urb->dev->speed) {
case USB_SPEED_HIGH :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "HS_OTG \n");
dev_speed = HIGH_SPEED_OTG;
break;
case USB_SPEED_FULL :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "FS_OTG \n");
dev_speed = FULL_SPEED_OTG;
break;
case USB_SPEED_LOW :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "LS_OTG \n");
dev_speed = LOW_SPEED_OTG;
break;
default:
otg_err(OTG_DBG_OTGHCDI_HCD,
"unKnown Device Speed \n");
spin_unlock_irq_save_otg(&otghost->lock,
spin_lock_flag);
return USB_ERR_FAIL;
}
/* for getting ed_type */
switch (usb_pipetype(urb->pipe)) {
case PIPE_BULK :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "bulk transfer \n");
ed_type = BULK_TRANSFER;
break;
case PIPE_INTERRUPT :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "interrupt transfer \n");
ed_type = INT_TRANSFER;
break;
case PIPE_CONTROL :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "control transfer \n");
ed_type = CONTROL_TRANSFER;
break;
case PIPE_ISOCHRONOUS :
otg_dbg(OTG_DBG_OTGHCDI_HCD, "isochronous transfer \n");
ed_type = ISOCH_TRANSFER;
break;
default:
otg_err(OTG_DBG_OTGHCDI_HCD, "unKnown ep type \n");
spin_unlock_irq_save_otg(&otghost->lock,
spin_lock_flag);
return USB_ERR_FAIL;
}
max_packet_size = usb_maxpacket(urb->dev, urb->pipe,
!(usb_pipein(urb->pipe)));
additional_multi_count = ((max_packet_size) >> 11) & 0x03;
dev_addr = usb_pipedevice(urb->pipe);
ep_num = usb_pipeendpoint(urb->pipe);
f_is_ep_in = usb_pipein(urb->pipe) ? true : false;
interval = (u8)(urb->interval);
sched_frame = (u8)(urb->start_frame);
/* check */
if(urb->dev->tt == NULL) {
otg_dbg(OTG_DBG_OTGHCDI_HCD, "urb->dev->tt == NULL\n");
hub_port = 0; /* u8 hub_port */
hub_addr = 0; /* u8 hub_addr */
}
else {
hub_port = (u8)(urb->dev->ttport);
if (urb->dev->tt->hub) {
if (((dev_speed == FULL_SPEED_OTG) ||
(dev_speed == LOW_SPEED_OTG)) &&
(urb->dev->tt) && (urb->dev->tt->hub->devnum != 1)) {
if (otghost->is_hs) // only allow split transactions in HS mode
f_is_do_split = true;
}
hub_addr = (u8)(urb->dev->tt->hub->devnum);
}
if (urb->dev->tt->multi) {
hub_addr = 0x80;
}
}
otg_dbg(OTG_DBG_OTGHCDI_HCD,
"dev_spped =%d, hub_port=%d, hub_addr=%d\n",
dev_speed, hub_port, hub_addr);
ret_val = create_ed(&target_ed);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD,
"fail to create_ed() \n");
spin_unlock_irq_save_otg(&otghost->lock,
spin_lock_flag);
return ret_val;
}
ret_val = init_ed( target_ed,
dev_addr,
ep_num,
f_is_ep_in,
dev_speed,
ed_type,
max_packet_size,
additional_multi_count,
interval,
sched_frame,
hub_addr,
hub_port,
f_is_do_split,
(void *)urb->ep);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD,
"fail to init_ed() :err = %d \n",(int)ret_val);
otg_mem_free(target_ed);
spin_unlock_irq_save_otg(&otghost->lock,
spin_lock_flag);
return USB_ERR_FAIL;
}
urb->ep->hcpriv = (void *)(target_ed);
} /* if(!(ep->hcpriv)) */
else {
dev_addr = usb_pipedevice(urb->pipe);
if(((ed_t *)(urb->ep->hcpriv))->ed_desc.device_addr != dev_addr) {
((ed_t *)urb->ep->hcpriv)->ed_desc.device_addr = dev_addr;
}
}
target_ed = (ed_t *)urb->ep->hcpriv;
if(urb->transfer_flags & URB_SHORT_NOT_OK)
trans_flag += USB_TRANS_FLAG_NOT_SHORT;
if (urb->transfer_flags & URB_ISO_ASAP)
trans_flag += USB_TRANS_FLAG_ISO_ASYNCH;
if(ed_type == ISOCH_TRANSFER) {
otg_err(OTG_DBG_OTGHCDI_HCD, "ISO not yet supported \n");
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
if (!HC_IS_RUNNING(hcd->state)) {
otg_err(OTG_DBG_OTGHCDI_HCD, "!HC_IS_RUNNING(hcd->state) \n");
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return -USB_ERR_NODEV;
}
/* in case of unlink-during-submit */
if (urb->status != -EINPROGRESS) {
otg_err(OTG_DBG_OTGHCDI_HCD, "urb->status is -EINPROGRESS\n");
urb->hcpriv = NULL;
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
usb_hcd_giveback_urb(hcd, urb, urb->status);
return USB_ERR_SUCCESS;
}
ret_val = issue_transfer(otghost, target_ed, (void *)NULL, (void *)NULL,
trans_flag,
(usb_pipetype(urb->pipe) == PIPE_CONTROL)?true:false,
(u32)urb->setup_packet, (u32)urb->setup_dma,
(u32)urb->transfer_buffer, (u32)urb->transfer_dma,
(u32)urb->transfer_buffer_length,
(u32)urb->start_frame,(u32)urb->number_of_packets,
new_isoch_packet_desc, (void *)urb, &return_td_addr);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD, "fail to issue_transfer() \n");
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
urb->hcpriv = (void *)return_td_addr;
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
/**
* int s5pc110_otghcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb )
*
* @brief dequeue a urb to otg
*
* @param [in] _hcd : pointer of usb_hcd
* [in] _urb : pointer of urb
*
* @return USB_ERR_SUCCESS : If success \n
* USB_ERR_FAIL : If call fail \n
*/
int s5pc110_otghcd_urb_dequeue(
struct usb_hcd *_hcd, struct urb *_urb, int status)
{
int ret_val = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(_hcd);
unsigned long spin_lock_flag = 0;
td_t *cancel_td;
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_urb_dequeue \n");
/* Dequeue should be performed only if endpoint is enabled */
if (_urb->ep->enabled == 0) {
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
usb_hcd_giveback_urb(_hcd, _urb, status);
return USB_ERR_SUCCESS;
}
//kevinh read this from inside the spinlock
cancel_td = (td_t *)_urb->hcpriv;
if (cancel_td == NULL) {
otg_err(OTG_DBG_OTGHCDI_HCD, "cancel_td is NULL\n");
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
otg_dbg(OTG_DBG_OTGHCDI_HCD,
"s5pc110_otghcd_urb_dequeue, status = %d\n", status);
ret_val = usb_hcd_check_unlink_urb(_hcd, _urb, status);
if( (ret_val) && (ret_val != -EIDRM) ) {
otg_dbg(OTG_DBG_OTGHCDI_HCD, "ret_val = %d\n", ret_val);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
usb_hcd_giveback_urb(_hcd, _urb, status);
return ret_val;
}
if (!HC_IS_RUNNING(_hcd->state)) {
otg_err(OTG_DBG_OTGHCDI_HCD, "!HC_IS_RUNNING(hcd->state) \n");
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
otg_usbcore_giveback(cancel_td);
return USB_ERR_SUCCESS;
}
ret_val = cancel_transfer(otghost, cancel_td->parent_ed_p, cancel_td);
if(ret_val != USB_ERR_DEQUEUED && ret_val != USB_ERR_NOELEMENT) {
otg_err(OTG_DBG_OTGHCDI_HCD, "fail to cancel_transfer() \n");
otg_usbcore_giveback(cancel_td);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_FAIL;
}
otg_usbcore_giveback(cancel_td);
delete_td(otghost, cancel_td);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
/**
* void s5pc110_otghcd_endpoint_disable(
* struct usb_hcd *hcd,
* struct usb_host_endpoint *ep)
*
* @brief disable a endpoint
*
* @param [in] hcd : pointer of usb_hcd
* [in] ep : pointer of usb_host_endpoint
*/
void s5pc110_otghcd_endpoint_disable(
struct usb_hcd *hcd,
struct usb_host_endpoint *ep)
{
int ret_val = 0;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_endpoint_disable \n");
if(!((ed_t *)ep->hcpriv))
return;
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret_val = delete_ed(otghost, (ed_t *)ep->hcpriv);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD, "fail to delete_ed() \n");
return ;
}
/* ep->hcpriv = NULL; delete_ed coveres it */
}
/**
* int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
*
* @brief get status of root hub
*
* @param [in] _hcd : pointer of usb_hcd
* [inout] _buf : pointer of buffer for write a status data
*
* @return ret_val : return port status \n
*/
int s5pc110_otghcd_hub_status_data(struct usb_hcd *_hcd, char *_buf)
{
int ret_val = 0;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(_hcd);
/* otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_hub_status_data \n"); */
/* if !USB_SUSPEND, root hub timers won't get shut down ... */
if (!HC_IS_RUNNING(_hcd->state)) {
otg_dbg(OTG_DBG_OTGHCDI_HCD,
"_hcd->state is NOT HC_IS_RUNNING \n");
return 0;
}
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret_val = get_otg_port_status(_hcd, OTG_PORT_NUMBER, _buf);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return (int)ret_val;
}
/**
* int s5pc110_otghcd_hub_control()
*
* @brief control root hub
*
* @param [in] hcd : pointer of usb_hcd
* [in] typeReq : type of control request
* [in] value : value
* [in] index : index
* [in] buf_p : pointer of urb
* [in] length : type of gfp_t
*
* @return ret_val : return root_hub_feature \n
*/
int
s5pc110_otghcd_hub_control (
struct usb_hcd *hcd,
u16 typeReq,
u16 value,
u16 index,
char* buf_p,
u16 length
)
{
int ret_val = 0;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_hub_control \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret_val = root_hub_feature(hcd, OTG_PORT_NUMBER,
typeReq, value, (void *)buf_p);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD, "fail to root_hub_feature() \n");
return ret_val;
}
return (int)ret_val;
}
/**
* int s5pc110_otghcd_bus_suspend(struct usb_hcd *hcd)
*
* @brief suspend otg hcd
*
* @param [in] hcd : pointer of usb_hcd
*
* @return USB_ERR_SUCCESS \n
*/
int s5pc110_otghcd_bus_suspend(struct usb_hcd *hcd)
{
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_bus_suspend \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
bus_suspend();
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
/**
* int s5pc110_otghcd_bus_resume(struct usb_hcd *hcd)
*
* @brief resume otg hcd
*
* @param [in] hcd : pointer of usb_hcd
*
* @return USB_ERR_SUCCESS \n
*/
int s5pc110_otghcd_bus_resume(struct usb_hcd *hcd)
{
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_bus_resume \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
if(bus_resume(otghost) != USB_ERR_SUCCESS) {
return USB_ERR_FAIL;
}
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
return USB_ERR_SUCCESS;
}
/**
* int s5pc110_otghcd_start_port_reset(struct usb_hcd *hcd, unsigned port)
*
* @brief reset otg port
*
* @param [in] hcd : pointer of usb_hcd
* [in] port : number of port
*
* @return USB_ERR_SUCCESS : If success \n
* ret_val : If call fail \n
*/
int s5pc110_otghcd_start_port_reset(struct usb_hcd *hcd, unsigned port)
{
int ret_val = 0;
unsigned long spin_lock_flag = 0;
struct sec_otghost *otghost = hcd_to_sec_otghost(hcd);
otg_dbg(OTG_DBG_OTGHCDI_HCD, "s5pc110_otghcd_start_port_reset \n");
spin_lock_irq_save_otg(&otghost->lock, spin_lock_flag);
ret_val = reset_and_enable_port(hcd, OTG_PORT_NUMBER);
spin_unlock_irq_save_otg(&otghost->lock, spin_lock_flag);
if(ret_val != USB_ERR_SUCCESS) {
otg_err(OTG_DBG_OTGHCDI_HCD,
"fail to reset_and_enable_port() \n");
return ret_val;
}
return USB_ERR_SUCCESS;
}
|