OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From e8ede0f62b39a3d3b06ae3dc04a74680a1f0a64b Mon Sep 17 00:00:00 2001 |
2 | From: Linus Walleij <linus.walleij@linaro.org> |
||
3 | Date: Fri, 21 Apr 2017 22:19:00 +0200 |
||
4 | Subject: [PATCH 30/31] usb: host: fotg2: add Gemini-specific handling |
||
5 | |||
6 | The Cortina Systems Gemini has bolted on a PHY inside the |
||
7 | silicon that can be handled by six bits in a MISC register in |
||
8 | the system controller. |
||
9 | |||
10 | If we are running on Gemini, look up a syscon regmap through |
||
11 | a phandle and enable VBUS and optionally the Mini-B connector. |
||
12 | |||
13 | If the device is flagged as "wakeup-source" using the standard |
||
14 | DT bindings, we also enable this in the global controller for |
||
15 | respective port. |
||
16 | |||
17 | Signed-off-by: Linus Walleij <linus.walleij@linaro.org> |
||
18 | --- |
||
19 | drivers/usb/host/Kconfig | 1 + |
||
20 | drivers/usb/host/fotg210-hcd.c | 76 ++++++++++++++++++++++++++++++++++++++++++ |
||
21 | 2 files changed, 77 insertions(+) |
||
22 | |||
23 | --- a/drivers/usb/host/Kconfig |
||
24 | +++ b/drivers/usb/host/Kconfig |
||
25 | @@ -375,6 +375,7 @@ config USB_ISP1362_HCD |
||
26 | config USB_FOTG210_HCD |
||
27 | tristate "FOTG210 HCD support" |
||
28 | depends on USB && HAS_DMA && HAS_IOMEM |
||
29 | + select MFD_SYSCON |
||
30 | ---help--- |
||
31 | Faraday FOTG210 is an OTG controller which can be configured as |
||
32 | an USB2.0 host. It is designed to meet USB2.0 EHCI specification |
||
33 | --- a/drivers/usb/host/fotg210-hcd.c |
||
34 | +++ b/drivers/usb/host/fotg210-hcd.c |
||
35 | @@ -46,6 +46,10 @@ |
||
36 | #include <linux/platform_device.h> |
||
37 | #include <linux/io.h> |
||
38 | #include <linux/clk.h> |
||
39 | +#include <linux/bitops.h> |
||
40 | +/* For Cortina Gemini */ |
||
41 | +#include <linux/mfd/syscon.h> |
||
42 | +#include <linux/regmap.h> |
||
43 | |||
44 | #include <asm/byteorder.h> |
||
45 | #include <asm/irq.h> |
||
46 | @@ -5583,6 +5587,72 @@ static void fotg210_init(struct fotg210_ |
||
47 | iowrite32(value, &fotg210->regs->otgcsr); |
||
48 | } |
||
49 | |||
50 | +/* |
||
51 | + * Gemini-specific initialization function, only executed on the |
||
52 | + * Gemini SoC using the global misc control register. |
||
53 | + */ |
||
54 | +#define GEMINI_GLOBAL_MISC_CTRL 0x30 |
||
55 | +#define GEMINI_MISC_USB0_WAKEUP BIT(14) |
||
56 | +#define GEMINI_MISC_USB1_WAKEUP BIT(15) |
||
57 | +#define GEMINI_MISC_USB0_VBUS_ON BIT(22) |
||
58 | +#define GEMINI_MISC_USB1_VBUS_ON BIT(23) |
||
59 | +#define GEMINI_MISC_USB0_MINI_B BIT(29) |
||
60 | +#define GEMINI_MISC_USB1_MINI_B BIT(30) |
||
61 | + |
||
62 | +static int fotg210_gemini_init(struct device *dev, struct usb_hcd *hcd) |
||
63 | +{ |
||
64 | + struct device_node *np = dev->of_node; |
||
65 | + struct regmap *map; |
||
66 | + bool mini_b; |
||
67 | + bool wakeup; |
||
68 | + u32 mask, val; |
||
69 | + int ret; |
||
70 | + |
||
71 | + map = syscon_regmap_lookup_by_phandle(np, "syscon"); |
||
72 | + if (IS_ERR(map)) { |
||
73 | + dev_err(dev, "no syscon\n"); |
||
74 | + return PTR_ERR(map); |
||
75 | + } |
||
76 | + mini_b = of_property_read_bool(np, "cortina,gemini-mini-b"); |
||
77 | + wakeup = of_property_read_bool(np, "wakeup-source"); |
||
78 | + |
||
79 | + /* |
||
80 | + * Figure out if this is USB0 or USB1 by simply checking the |
||
81 | + * physical base address. |
||
82 | + */ |
||
83 | + mask = 0; |
||
84 | + if (hcd->rsrc_start == 0x69000000) { |
||
85 | + val = GEMINI_MISC_USB1_VBUS_ON; |
||
86 | + if (mini_b) |
||
87 | + val |= GEMINI_MISC_USB1_MINI_B; |
||
88 | + else |
||
89 | + mask |= GEMINI_MISC_USB1_MINI_B; |
||
90 | + if (wakeup) |
||
91 | + val |= GEMINI_MISC_USB1_WAKEUP; |
||
92 | + else |
||
93 | + mask |= GEMINI_MISC_USB1_WAKEUP; |
||
94 | + } else { |
||
95 | + val = GEMINI_MISC_USB0_VBUS_ON; |
||
96 | + if (mini_b) |
||
97 | + val |= GEMINI_MISC_USB0_MINI_B; |
||
98 | + else |
||
99 | + mask |= GEMINI_MISC_USB0_MINI_B; |
||
100 | + if (wakeup) |
||
101 | + val |= GEMINI_MISC_USB0_WAKEUP; |
||
102 | + else |
||
103 | + mask |= GEMINI_MISC_USB0_WAKEUP; |
||
104 | + } |
||
105 | + |
||
106 | + ret = regmap_update_bits(map, GEMINI_GLOBAL_MISC_CTRL, mask, val); |
||
107 | + if (ret) { |
||
108 | + dev_err(dev, "failed to initialize Gemini PHY\n"); |
||
109 | + return ret; |
||
110 | + } |
||
111 | + |
||
112 | + dev_info(dev, "initialized Gemini PHY\n"); |
||
113 | + return 0; |
||
114 | +} |
||
115 | + |
||
116 | /** |
||
117 | * fotg210_hcd_probe - initialize faraday FOTG210 HCDs |
||
118 | * |
||
119 | @@ -5662,6 +5732,12 @@ static int fotg210_hcd_probe(struct plat |
||
120 | |||
121 | fotg210_init(fotg210); |
||
122 | |||
123 | + if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { |
||
124 | + retval = fotg210_gemini_init(dev, hcd); |
||
125 | + if (retval) |
||
126 | + goto failed_dis_clk; |
||
127 | + } |
||
128 | + |
||
129 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
||
130 | if (retval) { |
||
131 | dev_err(dev, "failed to add hcd with err %d\n", retval); |