[PATCH v3 3/7] board: rock5b-rk3588: add USB-C controller support

Sebastian Reichel sebastian.reichel at collabora.com
Fri Aug 2 19:59:33 CEST 2024


Enable support for the fusb302 USB Type-C controller.

This will do early USB PD (power deliver) negotiation, which must happen
within 5 seconds after the USB-C connector has plugged in according to
the specification. It takes almost 5 seconds to go through the bootchain
on Rock 5B and jump to the operating system. When the Linux initializes
the fusb302 usually 20-30 seconds have gone since the device has been
plugged, which is far too late. The USB PD power source reacts with a
hard reset, which disables VBUS for some time. This is not a problem for
a battery driven device, but Rock 5B will loose its power-supply and
reset. By initializing PD in U-Boot, this can be avoided.

Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
---
 board/radxa/rock5b-rk3588/Makefile        |  6 ++++
 board/radxa/rock5b-rk3588/rock5b-rk3588.c | 35 +++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 board/radxa/rock5b-rk3588/Makefile
 create mode 100644 board/radxa/rock5b-rk3588/rock5b-rk3588.c

diff --git a/board/radxa/rock5b-rk3588/Makefile b/board/radxa/rock5b-rk3588/Makefile
new file mode 100644
index 000000000000..95d813596da4
--- /dev/null
+++ b/board/radxa/rock5b-rk3588/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier:     GPL-2.0+
+#
+# Copyright (c) 2022 Collabora Ltd.
+#
+
+obj-y += rock5b-rk3588.o
diff --git a/board/radxa/rock5b-rk3588/rock5b-rk3588.c b/board/radxa/rock5b-rk3588/rock5b-rk3588.c
new file mode 100644
index 000000000000..1c17ae93c76c
--- /dev/null
+++ b/board/radxa/rock5b-rk3588/rock5b-rk3588.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023-2024 Collabora Ltd.
+ */
+
+#include <usb/tcpm.h>
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	/*
+	 * This will do early USB PD (power deliver) negotiation, which must
+	 * happen within 5 seconds after the USB-C connector has plugged in
+	 * according to the specification. It takes almost 5 seconds to go
+	 * through the bootchain on Rock 5B and jump to the operating system.
+	 * When the Linux initializes the fusb302 usually 20-30 seconds have
+	 * gone since the device has been plugged, which is far too late.
+	 *
+	 * The USB PD power source reacts with a hard reset, which disables
+	 * VBUS for some time. This is not a problem for a battery driven
+	 * device, but Rock 5B will loose its power-supply and reset. By
+	 * initializing PD in U-Boot, this can be avoided.
+	 */
+	ret = tcpm_get("usb-typec at 22", &dev);
+	if (ret) {
+		printf("Failed to probe Type-C controller\n");
+		return 0;
+	}
+
+	return 0;
+}
+#endif
-- 
2.43.0



More information about the U-Boot mailing list