bcm53xx: use the latest submitted version of ILP clock driver
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.4 / 081-0002-USB-bcma-separate-code-initializing-USB-2.0-core.patch
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
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
12 2.0 bcma core.
13 This will allow adding support for the USB 3.0 bcma core (handling XHCI)
14 in the future.
15
16 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 ---
19 drivers/usb/host/bcma-hcd.c | 59 ++++++++++++++++++++++++++++++---------------
20 1 file changed, 39 insertions(+), 20 deletions(-)
21
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");
26
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:
33 return ERR_PTR(ret);
34 }
35
36 -static int bcma_hcd_probe(struct bcma_device *dev)
37 +static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
38 {
39 - int err;
40 + struct bcma_device *dev = usb_dev->core;
41 + struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
42 u32 ohci_addr;
43 - struct bcma_hcd_device *usb_dev;
44 - struct bcma_chipinfo *chipinfo;
45 -
46 - chipinfo = &dev->bus->chipinfo;
47 -
48 - /* TODO: Probably need checks here; is the core connected? */
49 + int err;
50
51 if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
52 return -EOPNOTSUPP;
53
54 - usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
55 - GFP_KERNEL);
56 - if (!usb_dev)
57 - return -ENOMEM;
58 -
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);
64 -
65 switch (dev->id.id) {
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;
70 }
71
72 - bcma_set_drvdata(dev, usb_dev);
73 return 0;
74
75 err_unregister_ohci_dev:
76 @@ -353,6 +338,40 @@ err_unregister_ohci_dev:
77 return err;
78 }
79
80 +static int bcma_hcd_probe(struct bcma_device *core)
81 +{
82 + int err;
83 + struct bcma_hcd_device *usb_dev;
84 +
85 + /* TODO: Probably need checks here; is the core connected? */
86 +
87 + usb_dev = devm_kzalloc(&core->dev, sizeof(struct bcma_hcd_device),
88 + GFP_KERNEL);
89 + if (!usb_dev)
90 + return -ENOMEM;
91 + usb_dev->core = core;
92 +
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);
98 +
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);
103 + if (err)
104 + return err;
105 + break;
106 + default:
107 + return -ENODEV;
108 + }
109 +
110 + bcma_set_drvdata(core, usb_dev);
111 + return 0;
112 +}
113 +
114 static void bcma_hcd_remove(struct bcma_device *dev)
115 {
116 struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);