kernel: bump 5.10 to 5.10.67
[openwrt/openwrt.git] / target / linux / gemini / patches-5.10 / 0001-usb-host-fotg2-add-Gemini-specific-handling.patch
1 From ff887de2f7af17d6264eb946f6b336e6e1521222 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 1/2] 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 @@ -392,6 +392,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 @@ -34,6 +34,10 @@
36 #include <linux/io.h>
37 #include <linux/iopoll.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 @@ -5553,6 +5557,72 @@ static void fotg210_init(struct fotg210_
47 }
48
49 /*
50 + * Gemini-specific initialization function, only executed on the
51 + * Gemini SoC using the global misc control register.
52 + */
53 +#define GEMINI_GLOBAL_MISC_CTRL 0x30
54 +#define GEMINI_MISC_USB0_WAKEUP BIT(14)
55 +#define GEMINI_MISC_USB1_WAKEUP BIT(15)
56 +#define GEMINI_MISC_USB0_VBUS_ON BIT(22)
57 +#define GEMINI_MISC_USB1_VBUS_ON BIT(23)
58 +#define GEMINI_MISC_USB0_MINI_B BIT(29)
59 +#define GEMINI_MISC_USB1_MINI_B BIT(30)
60 +
61 +static int fotg210_gemini_init(struct device *dev, struct usb_hcd *hcd)
62 +{
63 + struct device_node *np = dev->of_node;
64 + struct regmap *map;
65 + bool mini_b;
66 + bool wakeup;
67 + u32 mask, val;
68 + int ret;
69 +
70 + map = syscon_regmap_lookup_by_phandle(np, "syscon");
71 + if (IS_ERR(map)) {
72 + dev_err(dev, "no syscon\n");
73 + return PTR_ERR(map);
74 + }
75 + mini_b = of_property_read_bool(np, "cortina,gemini-mini-b");
76 + wakeup = of_property_read_bool(np, "wakeup-source");
77 +
78 + /*
79 + * Figure out if this is USB0 or USB1 by simply checking the
80 + * physical base address.
81 + */
82 + mask = 0;
83 + if (hcd->rsrc_start == 0x69000000) {
84 + val = GEMINI_MISC_USB1_VBUS_ON;
85 + if (mini_b)
86 + val |= GEMINI_MISC_USB1_MINI_B;
87 + else
88 + mask |= GEMINI_MISC_USB1_MINI_B;
89 + if (wakeup)
90 + val |= GEMINI_MISC_USB1_WAKEUP;
91 + else
92 + mask |= GEMINI_MISC_USB1_WAKEUP;
93 + } else {
94 + val = GEMINI_MISC_USB0_VBUS_ON;
95 + if (mini_b)
96 + val |= GEMINI_MISC_USB0_MINI_B;
97 + else
98 + mask |= GEMINI_MISC_USB0_MINI_B;
99 + if (wakeup)
100 + val |= GEMINI_MISC_USB0_WAKEUP;
101 + else
102 + mask |= GEMINI_MISC_USB0_WAKEUP;
103 + }
104 +
105 + ret = regmap_update_bits(map, GEMINI_GLOBAL_MISC_CTRL, mask, val);
106 + if (ret) {
107 + dev_err(dev, "failed to initialize Gemini PHY\n");
108 + return ret;
109 + }
110 +
111 + dev_info(dev, "initialized Gemini PHY\n");
112 + return 0;
113 +}
114 +
115 +/**
116 * fotg210_hcd_probe - initialize faraday FOTG210 HCDs
117 *
118 * Allocates basic resources for this USB host controller, and
119 @@ -5629,6 +5699,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);