generic: 4.4: refresh patches
[openwrt.git] / target / linux / bcm53xx / patches-4.3 / 196-USB-bcma-use-separated-function-for-USB-2.0-initiali.patch
1 From fa5622c2fadae573dd6b0f5bffe436b230b411f6 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 v3 4/6] usb: bcma: use separated function for USB 2.0
5  initialization
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This will allow adding USB 3.0 (XHCI) support cleanly.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
14 ---
15  drivers/usb/host/bcma-hcd.c | 51 +++++++++++++++++++++++++++++++--------------
16  1 file changed, 35 insertions(+), 16 deletions(-)
17
18 --- a/drivers/usb/host/bcma-hcd.c
19 +++ b/drivers/usb/host/bcma-hcd.c
20 @@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Common USB driver fo
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         struct gpio_desc *gpio_desc;
28 @@ -288,31 +289,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 -       if (dev->dev.of_node)
56 -               usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
57 -                                                              &dev->dev.of_node->fwnode);
58 -       if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
59 -               gpiod_direction_output(usb_dev->gpio_desc, 1);
60 -
61         switch (dev->id.id) {
62         case BCMA_CORE_NS_USB20:
63                 bcma_hcd_init_chip_arm(dev);
64 @@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
65                 goto err_unregister_ohci_dev;
66         }
67  
68 -       bcma_set_drvdata(dev, usb_dev);
69         return 0;
70  
71  err_unregister_ohci_dev:
72 @@ -353,6 +338,40 @@ err_unregister_ohci_dev:
73         return err;
74  }
75  
76 +static int bcma_hcd_probe(struct bcma_device *dev)
77 +{
78 +       int err;
79 +       struct bcma_hcd_device *usb_dev;
80 +
81 +       /* TODO: Probably need checks here; is the core connected? */
82 +
83 +       usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
84 +                              GFP_KERNEL);
85 +       if (!usb_dev)
86 +               return -ENOMEM;
87 +       usb_dev->core = dev;
88 +
89 +       if (dev->dev.of_node)
90 +               usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
91 +                                                              &dev->dev.of_node->fwnode);
92 +       if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
93 +               gpiod_direction_output(usb_dev->gpio_desc, 1);
94 +
95 +       switch (dev->id.id) {
96 +       case BCMA_CORE_USB20_HOST:
97 +       case BCMA_CORE_NS_USB20:
98 +               err = bcma_hcd_usb20_init(usb_dev);
99 +               if (err)
100 +                       return err;
101 +               break;
102 +       default:
103 +               return -ENODEV;
104 +       }
105 +
106 +       bcma_set_drvdata(dev, usb_dev);
107 +       return 0;
108 +}
109 +
110  static void bcma_hcd_remove(struct bcma_device *dev)
111  {
112         struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);