[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230103-gemini-fotg210-usb-v1-5-f2670cb4a492@linaro.org>
Date: Wed, 04 Jan 2023 00:35:21 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>
Cc: linux-usb@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Fabian Vogt <fabian@...ter-vogt.de>,
Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH 5/7] usb: fotg210: Check role register in core
Read the role register and check that we are in host/peripheral
mode and issue warnings if we're not in the right role when
probing respective driver.
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
drivers/usb/fotg210/fotg210-core.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg210-core.c
index 58d84747fb30..013a1d0112fc 100644
--- a/drivers/usb/fotg210/fotg210-core.c
+++ b/drivers/usb/fotg210/fotg210-core.c
@@ -18,6 +18,11 @@
#include "fotg210.h"
+/* Role Register 0x80 */
+#define FOTG210_RR 0x80
+#define FOTG210_RR_ID BIT(21) /* 1 = B-device, 0 = A-device */
+#define FOTG210_RR_CROLE BIT(20) /* 1 = device, 0 = host */
+
/*
* Gemini-specific initialization function, only executed on the
* Gemini SoC using the global misc control register.
@@ -95,6 +100,7 @@ static int fotg210_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
enum usb_dr_mode mode;
struct fotg210 *fotg;
+ u32 val;
int ret;
fotg = devm_kzalloc(dev, sizeof(*fotg), GFP_KERNEL);
@@ -122,10 +128,16 @@ static int fotg210_probe(struct platform_device *pdev)
return ret;
}
- if (mode == USB_DR_MODE_PERIPHERAL)
+ val = readl(fotg->base + FOTG210_RR);
+ if (mode == USB_DR_MODE_PERIPHERAL) {
+ if (!(val & FOTG210_RR_CROLE))
+ dev_err(dev, "block not in device role\n");
ret = fotg210_udc_probe(pdev, fotg);
- else
+ } else {
+ if (val & FOTG210_RR_CROLE)
+ dev_err(dev, "block not in host role\n");
ret = fotg210_hcd_probe(pdev, fotg);
+ }
return ret;
}
--
2.38.1
Powered by blists - more mailing lists