CC: ubox: turn logd into a separate package
[15.05/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 --- a/drivers/usb/host/bcma-hcd.c
17 +++ b/drivers/usb/host/bcma-hcd.c
18 @@ -35,6 +35,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         struct gpio_desc *gpio_desc;
26 @@ -288,31 +289,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 -       if (dev->dev.of_node)
54 -               usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
55 -                                                              &dev->dev.of_node->fwnode);
56 -       if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
57 -               gpiod_direction_output(usb_dev->gpio_desc, 1);
58 -
59         switch (dev->id.id) {
60         case BCMA_CORE_NS_USB20:
61                 bcma_hcd_init_chip_arm(dev);
62 @@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
63                 goto err_unregister_ohci_dev;
64         }
65  
66 -       bcma_set_drvdata(dev, usb_dev);
67         return 0;
68  
69  err_unregister_ohci_dev:
70 @@ -353,6 +338,40 @@ err_unregister_ohci_dev:
71         return err;
72  }
73  
74 +static int bcma_hcd_probe(struct bcma_device *dev)
75 +{
76 +       int err;
77 +       struct bcma_hcd_device *usb_dev;
78 +
79 +       /* TODO: Probably need checks here; is the core connected? */
80 +
81 +       usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
82 +                              GFP_KERNEL);
83 +       if (!usb_dev)
84 +               return -ENOMEM;
85 +       usb_dev->core = dev;
86 +
87 +       if (dev->dev.of_node)
88 +               usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
89 +                                                              &dev->dev.of_node->fwnode);
90 +       if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
91 +               gpiod_direction_output(usb_dev->gpio_desc, 1);
92 +
93 +       switch (dev->id.id) {
94 +       case BCMA_CORE_USB20_HOST:
95 +       case BCMA_CORE_NS_USB20:
96 +               err = bcma_hcd_usb20_init(usb_dev);
97 +               if (err)
98 +                       return err;
99 +               break;
100 +       default:
101 +               return -ENODEV;
102 +       }
103 +
104 +       bcma_set_drvdata(dev, usb_dev);
105 +       return 0;
106 +}
107 +
108  static void bcma_hcd_remove(struct bcma_device *dev)
109  {
110         struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);