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
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This splits one big probing function into two smaller ones. The main one
10 is now responsible for the generic stuff: allocating memory & enabling
11 power using GPIO. The new one contains code that is specific to the USB
13 This will allow adding support for the USB 3.0 bcma core (handling XHCI)
16 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 drivers/usb/host/bcma-hcd.c | 59 ++++++++++++++++++++++++++++++---------------
20 1 file changed, 39 insertions(+), 20 deletions(-)
22 --- a/drivers/usb/host/bcma-hcd.c
23 +++ b/drivers/usb/host/bcma-hcd.c
24 @@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Common USB driver fo
25 MODULE_LICENSE("GPL");
27 struct bcma_hcd_device {
28 + struct bcma_device *core;
29 struct platform_device *ehci_dev;
30 struct platform_device *ohci_dev;
31 struct gpio_desc *gpio_desc;
32 @@ -288,31 +289,16 @@ err_alloc:
36 -static int bcma_hcd_probe(struct bcma_device *dev)
37 +static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
40 + struct bcma_device *dev = usb_dev->core;
41 + struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
43 - struct bcma_hcd_device *usb_dev;
44 - struct bcma_chipinfo *chipinfo;
46 - chipinfo = &dev->bus->chipinfo;
48 - /* TODO: Probably need checks here; is the core connected? */
51 if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
54 - usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
59 - if (dev->dev.of_node)
60 - usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
61 - &dev->dev.of_node->fwnode);
62 - if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
63 - gpiod_direction_output(usb_dev->gpio_desc, 1);
66 case BCMA_CORE_NS_USB20:
67 bcma_hcd_init_chip_arm(dev);
68 @@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
69 goto err_unregister_ohci_dev;
72 - bcma_set_drvdata(dev, usb_dev);
75 err_unregister_ohci_dev:
76 @@ -353,6 +338,40 @@ err_unregister_ohci_dev:
80 +static int bcma_hcd_probe(struct bcma_device *core)
83 + struct bcma_hcd_device *usb_dev;
85 + /* TODO: Probably need checks here; is the core connected? */
87 + usb_dev = devm_kzalloc(&core->dev, sizeof(struct bcma_hcd_device),
91 + usb_dev->core = core;
93 + if (core->dev.of_node)
94 + usb_dev->gpio_desc = devm_get_gpiod_from_child(&core->dev, "vcc",
95 + &core->dev.of_node->fwnode);
96 + if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
97 + gpiod_direction_output(usb_dev->gpio_desc, 1);
99 + switch (core->id.id) {
100 + case BCMA_CORE_USB20_HOST:
101 + case BCMA_CORE_NS_USB20:
102 + err = bcma_hcd_usb20_init(usb_dev);
110 + bcma_set_drvdata(core, usb_dev);
114 static void bcma_hcd_remove(struct bcma_device *dev)
116 struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);