bcm53xx: add xHCI support
[openwrt.git] / target / linux / bcm53xx / patches-3.18 / 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 diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
17 index d347282..0b4d0e8 100644
18 --- a/drivers/usb/host/bcma-hcd.c
19 +++ b/drivers/usb/host/bcma-hcd.c
20 @@ -34,6 +34,7 @@ MODULE_DESCRIPTION("Common USB driver for BCMA Bus");
21  MODULE_LICENSE("GPL");
22  
23  struct bcma_hcd_device {
24 +       struct bcma_device *core;
25         struct platform_device *ehci_dev;
26         struct platform_device *ohci_dev;
27  };
28 @@ -293,27 +294,16 @@ err_alloc:
29         return ERR_PTR(ret);
30  }
31  
32 -static int bcma_hcd_probe(struct bcma_device *dev)
33 +static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
34  {
35 -       int err;
36 +       struct bcma_device *dev = usb_dev->core;
37 +       struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
38         u32 ohci_addr;
39 -       struct bcma_hcd_device *usb_dev;
40 -       struct bcma_chipinfo *chipinfo;
41 -
42 -       chipinfo = &dev->bus->chipinfo;
43 -
44 -       /* TODO: Probably need checks here; is the core connected? */
45 +       int err;
46  
47         if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
48                 return -EOPNOTSUPP;
49  
50 -       usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
51 -                              GFP_KERNEL);
52 -       if (!usb_dev)
53 -               return -ENOMEM;
54 -
55 -       bcma_hci_platform_power_gpio(dev, true);
56 -
57         switch (dev->id.id) {
58         case BCMA_CORE_NS_USB20:
59                 bcma_hcd_init_chip_arm(dev);
60 @@ -346,7 +336,6 @@ static int bcma_hcd_probe(struct bcma_device *dev)
61                 goto err_unregister_ohci_dev;
62         }
63  
64 -       bcma_set_drvdata(dev, usb_dev);
65         return 0;
66  
67  err_unregister_ohci_dev:
68 @@ -354,6 +343,36 @@ err_unregister_ohci_dev:
69         return err;
70  }
71  
72 +static int bcma_hcd_probe(struct bcma_device *dev)
73 +{
74 +       int err;
75 +       struct bcma_hcd_device *usb_dev;
76 +
77 +       /* TODO: Probably need checks here; is the core connected? */
78 +
79 +       usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
80 +                              GFP_KERNEL);
81 +       if (!usb_dev)
82 +               return -ENOMEM;
83 +       usb_dev->core = dev;
84 +
85 +       bcma_hci_platform_power_gpio(dev, true);
86 +
87 +       switch (dev->id.id) {
88 +       case BCMA_CORE_USB20_HOST:
89 +       case BCMA_CORE_NS_USB20:
90 +               err = bcma_hcd_usb20_init(usb_dev);
91 +               if (err)
92 +                       return err;
93 +               break;
94 +       default:
95 +               return -ENODEV;
96 +       }
97 +
98 +       bcma_set_drvdata(dev, usb_dev);
99 +       return 0;
100 +}
101 +
102  static void bcma_hcd_remove(struct bcma_device *dev)
103  {
104         struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
105 -- 
106 1.8.4.5
107