Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt Attach when dr_mode is "otg" and the controller ...
details: https://anonhg.NetBSD.org/src/rev/653d927650fc
branches: trunk
changeset: 366752:653d927650fc
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Jun 12 08:04:07 2022 +0000
description:
Attach when dr_mode is "otg" and the controller has the "usb-role-switch" and
"role-switch-default-mode" as seen in the Apple M1 dts.
This assumes the controller is properly setup for host mode already.
diffstat:
sys/dev/fdt/dwc3_fdt.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diffs (51 lines):
diff -r a187a0a37b2e -r 653d927650fc sys/dev/fdt/dwc3_fdt.c
--- a/sys/dev/fdt/dwc3_fdt.c Sun Jun 12 06:57:07 2022 +0000
+++ b/sys/dev/fdt/dwc3_fdt.c Sun Jun 12 08:04:07 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $ */
+/* $NetBSD: dwc3_fdt.c,v 1.20 2022/06/12 08:04:07 skrll Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.20 2022/06/12 08:04:07 skrll Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -256,9 +256,30 @@
return;
}
- /* Only host mode is supported */
+ /*
+ * Only host mode is supported, but this includes otg devices
+ * that have 'usb-role-switch' and 'role-switch-default-mode' of
+ * 'host'
+ */
const char *dr_mode = fdtbus_get_string(dwc3_phandle, "dr_mode");
- if (dr_mode == NULL || strcmp(dr_mode, "host") != 0) {
+ if (dr_mode == NULL || strcmp(dr_mode, "otg") == 0) {
+ bool ok = false;
+ if (of_hasprop(dwc3_phandle, "usb-role-switch")) {
+ const char *rsdm = fdtbus_get_string(dwc3_phandle,
+ "role-switch-default-mode");
+ if (rsdm != NULL && strcmp(rsdm, "host") == 0)
+ ok = true;
+
+ if (!ok) {
+ aprint_error(": host is not default mode\n");
+ return;
+ }
+ }
+ if (!ok) {
+ aprint_error(": cannot switch 'otg' mode to host\n");
+ return;
+ }
+ } else if (strcmp(dr_mode, "host") != 0) {
aprint_error(": '%s' not supported\n", dr_mode);
return;
}
Home |
Main Index |
Thread Index |
Old Index