sunxi: driver refresh for 3.13
[openwrt.git] / target / linux / sunxi / patches-3.13 / 180-3-usb-ohci-platform-support-bigendian.patch
1 From 10d7c018269928db8487057c4c143dbd014d2262 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Tue, 21 Jan 2014 16:05:47 +0100
4 Subject: [PATCH] ohci-platform: Add support for controllers with big-endian
5  regs / descriptors
6
7 Note this commit uses the same devicetree booleans for this as the ones
8 already existing in the usb-ehci bindings, see:
9 Documentation/devicetree/bindings/usb/usb-ehci.txt
10
11 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
12 ---
13  Documentation/devicetree/bindings/usb/usb-ohci.txt |  3 +++
14  drivers/usb/host/ohci-platform.c                   | 27 ++++++++++++++++++++++
15  2 files changed, 30 insertions(+)
16
17 diff --git a/Documentation/devicetree/bindings/usb/usb-ohci.txt b/Documentation/devicetree/bindings/usb/usb-ohci.txt
18 index 6ba38d9..6933b0c 100644
19 --- a/Documentation/devicetree/bindings/usb/usb-ohci.txt
20 +++ b/Documentation/devicetree/bindings/usb/usb-ohci.txt
21 @@ -6,6 +6,9 @@ Required properties:
22  - interrupts : ohci controller interrupt
23  
24  Optional properties:
25 +- big-endian-regs : boolean, set this for hcds with big-endian registers
26 +- big-endian-desc : boolean, set this for hcds with big-endian descriptors
27 +- big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
28  - clocks : a list of phandle + clock specifier pairs
29  - phys : phandle + phy specifier pair
30  - phy-names : "usb"
31 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
32 index 49304dd..e2c28fd 100644
33 --- a/drivers/usb/host/ohci-platform.c
34 +++ b/drivers/usb/host/ohci-platform.c
35 @@ -128,6 +128,7 @@ static int ohci_platform_probe(struct platform_device *dev)
36         struct resource *res_mem;
37         struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
38         struct ohci_platform_priv *priv;
39 +       struct ohci_hcd *ohci;
40         int err, irq, clk = 0;
41  
42         if (usb_disabled())
43 @@ -164,8 +165,34 @@ static int ohci_platform_probe(struct platform_device *dev)
44         platform_set_drvdata(dev, hcd);
45         dev->dev.platform_data = pdata;
46         priv = hcd_to_ohci_priv(hcd);
47 +       ohci = hcd_to_ohci(hcd);
48  
49         if (pdata == &ohci_platform_defaults && dev->dev.of_node) {
50 +               if (of_property_read_bool(dev->dev.of_node, "big-endian-regs"))
51 +                       ohci->flags |= OHCI_QUIRK_BE_MMIO;
52 +
53 +               if (of_property_read_bool(dev->dev.of_node, "big-endian-desc"))
54 +                       ohci->flags |= OHCI_QUIRK_BE_DESC;
55 +
56 +               if (of_property_read_bool(dev->dev.of_node, "big-endian"))
57 +                       ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC;
58 +
59 +#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
60 +               if (ohci->flags & OHCI_QUIRK_BE_MMIO) {
61 +                       dev_err(&dev->dev,
62 +                               "Error big-endian-regs not compiled in\n");
63 +                       err = -EINVAL;
64 +                       goto err_put_hcd;
65 +               }
66 +#endif
67 +#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC
68 +               if (ohci->flags & OHCI_QUIRK_BE_DESC) {
69 +                       dev_err(&dev->dev,
70 +                               "Error big-endian-desc not compiled in\n");
71 +                       err = -EINVAL;
72 +                       goto err_put_hcd;
73 +               }
74 +#endif
75                 priv->phy = devm_phy_get(&dev->dev, "usb");
76                 if (IS_ERR(priv->phy)) {
77                         err = PTR_ERR(priv->phy);
78 -- 
79 1.8.5.5
80