diff options
author | Felipe Balbi <balbi@ti.com> | 2011-10-12 03:44:56 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-12-12 04:48:11 -0500 |
commit | 0949e99b05736946cf0ac78e37194be0807e497e (patch) | |
tree | f3719f4e0b57c49bcd47d6a0c5594e2577192f03 /drivers | |
parent | 9f622b2a407d8b34a5a7f5b4abd8b29b25cf4f32 (diff) |
usb: dwc3: fetch mode of operation from HW
There's no need to add driver_data for something
we can fetch from HW.
This also makes our id_table unnecessary - at least
for now -, so we also remove it on the same patch.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/dwc3/core.c | 57 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 11 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 2 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 4 |
4 files changed, 46 insertions, 28 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1f67606fd4fb..df151992e49d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -325,15 +325,17 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
325 | 325 | ||
326 | static int __devinit dwc3_probe(struct platform_device *pdev) | 326 | static int __devinit dwc3_probe(struct platform_device *pdev) |
327 | { | 327 | { |
328 | const struct platform_device_id *id = platform_get_device_id(pdev); | ||
329 | struct resource *res; | 328 | struct resource *res; |
330 | struct dwc3 *dwc; | 329 | struct dwc3 *dwc; |
331 | void __iomem *regs; | 330 | |
332 | unsigned int features = id->driver_data; | ||
333 | int ret = -ENOMEM; | 331 | int ret = -ENOMEM; |
334 | int irq; | 332 | int irq; |
333 | |||
334 | void __iomem *regs; | ||
335 | void *mem; | 335 | void *mem; |
336 | 336 | ||
337 | u8 mode; | ||
338 | |||
337 | mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); | 339 | mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
338 | if (!mem) { | 340 | if (!mem) { |
339 | dev_err(&pdev->dev, "not enough memory\n"); | 341 | dev_err(&pdev->dev, "not enough memory\n"); |
@@ -396,13 +398,22 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
396 | goto err3; | 398 | goto err3; |
397 | } | 399 | } |
398 | 400 | ||
399 | if (features & DWC3_HAS_PERIPHERAL) { | 401 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
402 | |||
403 | switch (mode) { | ||
404 | case DWC3_MODE_DRD: | ||
405 | case DWC3_MODE_DEVICE: | ||
400 | ret = dwc3_gadget_init(dwc); | 406 | ret = dwc3_gadget_init(dwc); |
401 | if (ret) { | 407 | if (ret) { |
402 | dev_err(&pdev->dev, "failed to initialized gadget\n"); | 408 | dev_err(&pdev->dev, "failed to initialize gadget\n"); |
403 | goto err4; | 409 | goto err4; |
404 | } | 410 | } |
411 | break; | ||
412 | default: | ||
413 | dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode); | ||
414 | goto err4; | ||
405 | } | 415 | } |
416 | dwc->mode = mode; | ||
406 | 417 | ||
407 | ret = dwc3_debugfs_init(dwc); | 418 | ret = dwc3_debugfs_init(dwc); |
408 | if (ret) { | 419 | if (ret) { |
@@ -415,8 +426,15 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
415 | return 0; | 426 | return 0; |
416 | 427 | ||
417 | err5: | 428 | err5: |
418 | if (features & DWC3_HAS_PERIPHERAL) | 429 | switch (mode) { |
430 | case DWC3_MODE_DRD: | ||
431 | case DWC3_MODE_DEVICE: | ||
419 | dwc3_gadget_exit(dwc); | 432 | dwc3_gadget_exit(dwc); |
433 | break; | ||
434 | default: | ||
435 | /* do nothing */ | ||
436 | break; | ||
437 | } | ||
420 | 438 | ||
421 | err4: | 439 | err4: |
422 | dwc3_core_exit(dwc); | 440 | dwc3_core_exit(dwc); |
@@ -436,10 +454,8 @@ err0: | |||
436 | 454 | ||
437 | static int __devexit dwc3_remove(struct platform_device *pdev) | 455 | static int __devexit dwc3_remove(struct platform_device *pdev) |
438 | { | 456 | { |
439 | const struct platform_device_id *id = platform_get_device_id(pdev); | ||
440 | struct dwc3 *dwc = platform_get_drvdata(pdev); | 457 | struct dwc3 *dwc = platform_get_drvdata(pdev); |
441 | struct resource *res; | 458 | struct resource *res; |
442 | unsigned int features = id->driver_data; | ||
443 | 459 | ||
444 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 460 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
445 | 461 | ||
@@ -448,8 +464,15 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
448 | 464 | ||
449 | dwc3_debugfs_exit(dwc); | 465 | dwc3_debugfs_exit(dwc); |
450 | 466 | ||
451 | if (features & DWC3_HAS_PERIPHERAL) | 467 | switch (dwc->mode) { |
468 | case DWC3_MODE_DRD: | ||
469 | case DWC3_MODE_DEVICE: | ||
452 | dwc3_gadget_exit(dwc); | 470 | dwc3_gadget_exit(dwc); |
471 | break; | ||
472 | default: | ||
473 | /* do nothing */ | ||
474 | break; | ||
475 | } | ||
453 | 476 | ||
454 | dwc3_core_exit(dwc); | 477 | dwc3_core_exit(dwc); |
455 | release_mem_region(res->start, resource_size(res)); | 478 | release_mem_region(res->start, resource_size(res)); |
@@ -459,28 +482,12 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
459 | return 0; | 482 | return 0; |
460 | } | 483 | } |
461 | 484 | ||
462 | static const struct platform_device_id dwc3_id_table[] __devinitconst = { | ||
463 | { | ||
464 | .name = "dwc3-omap", | ||
465 | .driver_data = (DWC3_HAS_PERIPHERAL | ||
466 | | DWC3_HAS_XHCI | ||
467 | | DWC3_HAS_OTG), | ||
468 | }, | ||
469 | { | ||
470 | .name = "dwc3-pci", | ||
471 | .driver_data = DWC3_HAS_PERIPHERAL, | ||
472 | }, | ||
473 | { }, /* Terminating Entry */ | ||
474 | }; | ||
475 | MODULE_DEVICE_TABLE(platform, dwc3_id_table); | ||
476 | |||
477 | static struct platform_driver dwc3_driver = { | 485 | static struct platform_driver dwc3_driver = { |
478 | .probe = dwc3_probe, | 486 | .probe = dwc3_probe, |
479 | .remove = __devexit_p(dwc3_remove), | 487 | .remove = __devexit_p(dwc3_remove), |
480 | .driver = { | 488 | .driver = { |
481 | .name = "dwc3", | 489 | .name = "dwc3", |
482 | }, | 490 | }, |
483 | .id_table = dwc3_id_table, | ||
484 | }; | 491 | }; |
485 | 492 | ||
486 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 493 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4b6c673ed608..a3ef8f34bf77 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -536,6 +536,15 @@ struct dwc3_hwparams { | |||
536 | u32 hwparams8; | 536 | u32 hwparams8; |
537 | }; | 537 | }; |
538 | 538 | ||
539 | /* HWPARAMS0 */ | ||
540 | #define DWC3_MODE(n) ((n) & 0x7) | ||
541 | |||
542 | #define DWC3_MODE_DEVICE 0 | ||
543 | #define DWC3_MODE_HOST 1 | ||
544 | #define DWC3_MODE_DRD 2 | ||
545 | #define DWC3_MODE_HUB 3 | ||
546 | |||
547 | /* HWPARAMS1 */ | ||
539 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) | 548 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) |
540 | 549 | ||
541 | /** | 550 | /** |
@@ -560,6 +569,7 @@ struct dwc3_hwparams { | |||
560 | * @num_event_buffers: calculated number of event buffers | 569 | * @num_event_buffers: calculated number of event buffers |
561 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | 570 | * @maximum_speed: maximum speed requested (mainly for testing purposes) |
562 | * @revision: revision register contents | 571 | * @revision: revision register contents |
572 | * @mode: mode of operation | ||
563 | * @is_selfpowered: true when we are selfpowered | 573 | * @is_selfpowered: true when we are selfpowered |
564 | * @three_stage_setup: set if we perform a three phase setup | 574 | * @three_stage_setup: set if we perform a three phase setup |
565 | * @ep0_status_pending: ep0 status response without a req is pending | 575 | * @ep0_status_pending: ep0 status response without a req is pending |
@@ -602,6 +612,7 @@ struct dwc3 { | |||
602 | u32 num_event_buffers; | 612 | u32 num_event_buffers; |
603 | u32 maximum_speed; | 613 | u32 maximum_speed; |
604 | u32 revision; | 614 | u32 revision; |
615 | u32 mode; | ||
605 | 616 | ||
606 | #define DWC3_REVISION_173A 0x5533173a | 617 | #define DWC3_REVISION_173A 0x5533173a |
607 | #define DWC3_REVISION_175A 0x5533175a | 618 | #define DWC3_REVISION_175A 0x5533175a |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 062552b5fc8a..7bcf6775a1a1 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -236,7 +236,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
236 | goto err1; | 236 | goto err1; |
237 | } | 237 | } |
238 | 238 | ||
239 | dwc3 = platform_device_alloc("dwc3-omap", -1); | 239 | dwc3 = platform_device_alloc("dwc3", -1); |
240 | if (!dwc3) { | 240 | if (!dwc3) { |
241 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 241 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
242 | goto err2; | 242 | goto err2; |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index f77c00042685..193f1bd90d59 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -118,7 +118,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
118 | if (devid < 0) | 118 | if (devid < 0) |
119 | goto err2; | 119 | goto err2; |
120 | 120 | ||
121 | dwc3 = platform_device_alloc("dwc3-pci", devid); | 121 | dwc3 = platform_device_alloc("dwc3", devid); |
122 | if (!dwc3) { | 122 | if (!dwc3) { |
123 | dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); | 123 | dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); |
124 | goto err3; | 124 | goto err3; |
@@ -196,7 +196,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { | |||
196 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); | 196 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); |
197 | 197 | ||
198 | static struct pci_driver dwc3_pci_driver = { | 198 | static struct pci_driver dwc3_pci_driver = { |
199 | .name = "pci-dwc3", | 199 | .name = "dwc3-pci", |
200 | .id_table = dwc3_pci_id_table, | 200 | .id_table = dwc3_pci_id_table, |
201 | .probe = dwc3_pci_probe, | 201 | .probe = dwc3_pci_probe, |
202 | .remove = __devexit_p(dwc3_pci_remove), | 202 | .remove = __devexit_p(dwc3_pci_remove), |