1 From b331ae758123ba20ba41199e007ac33fc0f242e3 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 16/18] usb: host: fotg2: add Gemini-specific handling
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
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.
13 If the device is flagged as "wakeup-source" using the standard
14 DT bindings, we also enable this in the global controller for
17 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
19 drivers/usb/host/Kconfig | 1 +
20 drivers/usb/host/fotg210-hcd.c | 76 ++++++++++++++++++++++++++++++++++
21 2 files changed, 77 insertions(+)
23 --- a/drivers/usb/host/Kconfig
24 +++ b/drivers/usb/host/Kconfig
25 @@ -372,6 +372,7 @@ config USB_ISP1362_HCD
26 config USB_FOTG210_HCD
27 tristate "FOTG210 HCD support"
28 depends on USB && HAS_DMA && HAS_IOMEM
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
36 #include <linux/platform_device.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>
44 #include <asm/byteorder.h>
46 @@ -5554,6 +5558,72 @@ static void fotg210_init(struct fotg210_
47 iowrite32(value, &fotg210->regs->otgcsr);
51 + * Gemini-specific initialization function, only executed on the
52 + * Gemini SoC using the global misc control register.
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)
62 +static int fotg210_gemini_init(struct device *dev, struct usb_hcd *hcd)
64 + struct device_node *np = dev->of_node;
71 + map = syscon_regmap_lookup_by_phandle(np, "syscon");
73 + dev_err(dev, "no syscon\n");
74 + return PTR_ERR(map);
76 + mini_b = of_property_read_bool(np, "cortina,gemini-mini-b");
77 + wakeup = of_property_read_bool(np, "wakeup-source");
80 + * Figure out if this is USB0 or USB1 by simply checking the
81 + * physical base address.
84 + if (hcd->rsrc_start == 0x69000000) {
85 + val = GEMINI_MISC_USB1_VBUS_ON;
87 + val |= GEMINI_MISC_USB1_MINI_B;
89 + mask |= GEMINI_MISC_USB1_MINI_B;
91 + val |= GEMINI_MISC_USB1_WAKEUP;
93 + mask |= GEMINI_MISC_USB1_WAKEUP;
95 + val = GEMINI_MISC_USB0_VBUS_ON;
97 + val |= GEMINI_MISC_USB0_MINI_B;
99 + mask |= GEMINI_MISC_USB0_MINI_B;
101 + val |= GEMINI_MISC_USB0_WAKEUP;
103 + mask |= GEMINI_MISC_USB0_WAKEUP;
106 + ret = regmap_update_bits(map, GEMINI_GLOBAL_MISC_CTRL, mask, val);
108 + dev_err(dev, "failed to initialize Gemini PHY\n");
112 + dev_info(dev, "initialized Gemini PHY\n");
117 * fotg210_hcd_probe - initialize faraday FOTG210 HCDs
119 @@ -5631,6 +5701,12 @@ static int fotg210_hcd_probe(struct plat
121 fotg210_init(fotg210);
123 + if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) {
124 + retval = fotg210_gemini_init(dev, hcd);
126 + goto failed_dis_clk;
129 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
131 dev_err(dev, "failed to add hcd with err %d\n", retval);