bcm53xx: use Broadcom's proposed SMP implementation
[openwrt.git] / target / linux / bcm53xx / patches-4.1 / 811-USB-bcma-use-separated-function-for-USB-2.0-initiali.patch
1 From 4aed231f49954114d5ae23e97789e9aa540a0b70 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 16 Jun 2015 12:52:07 +0200
4 Subject: [PATCH] USB: bcma: use separated function for USB 2.0 initialization
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This will allow adding USB 3.0 (XHCI) support cleanly.
10
11 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
12 ---
13  drivers/usb/host/bcma-hcd.c | 51 +++++++++++++++++++++++++++++++--------------
14  1 file changed, 35 insertions(+), 16 deletions(-)
15
16 --- a/drivers/usb/host/bcma-hcd.c
17 +++ b/drivers/usb/host/bcma-hcd.c
18 @@ -34,6 +34,7 @@ MODULE_DESCRIPTION("Common USB driver fo
19  MODULE_LICENSE("GPL");
20  
21  struct bcma_hcd_device {
22 +       struct bcma_device *core;
23         struct platform_device *ehci_dev;
24         struct platform_device *ohci_dev;
25  };
26 @@ -293,27 +294,16 @@ err_alloc:
27         return ERR_PTR(ret);
28  }
29  
30 -static int bcma_hcd_probe(struct bcma_device *dev)
31 +static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
32  {
33 -       int err;
34 +       struct bcma_device *dev = usb_dev->core;
35 +       struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
36         u32 ohci_addr;
37 -       struct bcma_hcd_device *usb_dev;
38 -       struct bcma_chipinfo *chipinfo;
39 -
40 -       chipinfo = &dev->bus->chipinfo;
41 -
42 -       /* TODO: Probably need checks here; is the core connected? */
43 +       int err;
44  
45         if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
46                 return -EOPNOTSUPP;
47  
48 -       usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
49 -                              GFP_KERNEL);
50 -       if (!usb_dev)
51 -               return -ENOMEM;
52 -
53 -       bcma_hci_platform_power_gpio(dev, true);
54 -
55         switch (dev->id.id) {
56         case BCMA_CORE_NS_USB20:
57                 bcma_hcd_init_chip_arm(dev);
58 @@ -346,7 +336,6 @@ static int bcma_hcd_probe(struct bcma_de
59                 goto err_unregister_ohci_dev;
60         }
61  
62 -       bcma_set_drvdata(dev, usb_dev);
63         return 0;
64  
65  err_unregister_ohci_dev:
66 @@ -354,6 +343,36 @@ err_unregister_ohci_dev:
67         return err;
68  }
69  
70 +static int bcma_hcd_probe(struct bcma_device *dev)
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(&dev->dev, sizeof(struct bcma_hcd_device),
78 +                              GFP_KERNEL);
79 +       if (!usb_dev)
80 +               return -ENOMEM;
81 +       usb_dev->core = dev;
82 +
83 +       bcma_hci_platform_power_gpio(dev, true);
84 +
85 +       switch (dev->id.id) {
86 +       case BCMA_CORE_USB20_HOST:
87 +       case BCMA_CORE_NS_USB20:
88 +               err = bcma_hcd_usb20_init(usb_dev);
89 +               if (err)
90 +                       return err;
91 +               break;
92 +       default:
93 +               return -ENODEV;
94 +       }
95 +
96 +       bcma_set_drvdata(dev, usb_dev);
97 +       return 0;
98 +}
99 +
100  static void bcma_hcd_remove(struct bcma_device *dev)
101  {
102         struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);