081-0002-USB-bcma-separate-code-initializing-USB-2.0-core.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From adbff3a4f93d8501e8ae11906268e21b086d57ed Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Sat, 5 Dec 2015 13:15:07 +0100
  4. Subject: [PATCH] USB: bcma: separate code initializing USB 2.0 core
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This splits one big probing function into two smaller ones. The main one
  9. is now responsible for the generic stuff: allocating memory & enabling
  10. power using GPIO. The new one contains code that is specific to the USB
  11. 2.0 bcma core.
  12. This will allow adding support for the USB 3.0 bcma core (handling XHCI)
  13. in the future.
  14. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  15. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  16. ---
  17. drivers/usb/host/bcma-hcd.c | 59 ++++++++++++++++++++++++++++++---------------
  18. 1 file changed, 39 insertions(+), 20 deletions(-)
  19. --- a/drivers/usb/host/bcma-hcd.c
  20. +++ b/drivers/usb/host/bcma-hcd.c
  21. @@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Common USB driver fo
  22. MODULE_LICENSE("GPL");
  23. struct bcma_hcd_device {
  24. + struct bcma_device *core;
  25. struct platform_device *ehci_dev;
  26. struct platform_device *ohci_dev;
  27. struct gpio_desc *gpio_desc;
  28. @@ -288,31 +289,16 @@ err_alloc:
  29. return ERR_PTR(ret);
  30. }
  31. -static int bcma_hcd_probe(struct bcma_device *dev)
  32. +static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
  33. {
  34. - int err;
  35. + struct bcma_device *dev = usb_dev->core;
  36. + struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
  37. u32 ohci_addr;
  38. - struct bcma_hcd_device *usb_dev;
  39. - struct bcma_chipinfo *chipinfo;
  40. -
  41. - chipinfo = &dev->bus->chipinfo;
  42. -
  43. - /* TODO: Probably need checks here; is the core connected? */
  44. + int err;
  45. if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
  46. return -EOPNOTSUPP;
  47. - usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
  48. - GFP_KERNEL);
  49. - if (!usb_dev)
  50. - return -ENOMEM;
  51. -
  52. - if (dev->dev.of_node)
  53. - usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
  54. - &dev->dev.of_node->fwnode);
  55. - if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
  56. - gpiod_direction_output(usb_dev->gpio_desc, 1);
  57. -
  58. switch (dev->id.id) {
  59. case BCMA_CORE_NS_USB20:
  60. bcma_hcd_init_chip_arm(dev);
  61. @@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
  62. goto err_unregister_ohci_dev;
  63. }
  64. - bcma_set_drvdata(dev, usb_dev);
  65. return 0;
  66. err_unregister_ohci_dev:
  67. @@ -353,6 +338,40 @@ err_unregister_ohci_dev:
  68. return err;
  69. }
  70. +static int bcma_hcd_probe(struct bcma_device *core)
  71. +{
  72. + int err;
  73. + struct bcma_hcd_device *usb_dev;
  74. +
  75. + /* TODO: Probably need checks here; is the core connected? */
  76. +
  77. + usb_dev = devm_kzalloc(&core->dev, sizeof(struct bcma_hcd_device),
  78. + GFP_KERNEL);
  79. + if (!usb_dev)
  80. + return -ENOMEM;
  81. + usb_dev->core = core;
  82. +
  83. + if (core->dev.of_node)
  84. + usb_dev->gpio_desc = devm_get_gpiod_from_child(&core->dev, "vcc",
  85. + &core->dev.of_node->fwnode);
  86. + if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
  87. + gpiod_direction_output(usb_dev->gpio_desc, 1);
  88. +
  89. + switch (core->id.id) {
  90. + case BCMA_CORE_USB20_HOST:
  91. + case BCMA_CORE_NS_USB20:
  92. + err = bcma_hcd_usb20_init(usb_dev);
  93. + if (err)
  94. + return err;
  95. + break;
  96. + default:
  97. + return -ENODEV;
  98. + }
  99. +
  100. + bcma_set_drvdata(core, usb_dev);
  101. + return 0;
  102. +}
  103. +
  104. static void bcma_hcd_remove(struct bcma_device *dev)
  105. {
  106. struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);