[PATCH v1 3/5] board: rock5b-rk3588: add USB-C controller support
Sebastian Reichel
sebastian.reichel at collabora.com
Fri May 31 17:08:15 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.
The DT node can be sourced from the Linux kernel DT in the future,
but to get things going it makes sense to add it in the U-Boot
specific file for now. Because of the reset issue it is important
to get support in U-Boot first.
Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
---
arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 28 +++++++++++++++++++++++
board/radxa/rock5b-rk3588/Makefile | 6 +++++
board/radxa/rock5b-rk3588/rock5b-rk3588.c | 22 ++++++++++++++++++
configs/rock5b-rk3588_defconfig | 4 ++++
4 files changed, 60 insertions(+)
create mode 100644 board/radxa/rock5b-rk3588/Makefile
create mode 100644 board/radxa/rock5b-rk3588/rock5b-rk3588.c
diff --git a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
index 8e318e624a85..e93795359ece 100644
--- a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
+++ b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
@@ -3,6 +3,7 @@
* Copyright (c) 2023 Collabora Ltd.
*/
+#include <dt-bindings/usb/pd.h>
#include "rk3588-u-boot.dtsi"
&fspim2_pins {
@@ -65,3 +66,30 @@
dr_mode = "host";
status = "okay";
};
+
+&i2c4 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c4m1_xfer>;
+ status = "okay";
+
+ usbc0: usb-typec at 22 {
+ compatible = "fcs,fusb302";
+ reg = <0x22>;
+ interrupt-parent = <&gpio3>;
+ interrupts = <RK_PB4 IRQ_TYPE_LEVEL_LOW>;
+ pinctrl-names = "default";
+ status = "okay";
+
+ usb_con: connector {
+ compatible = "usb-c-connector";
+ label = "USB-C";
+ data-role = "dual";
+ power-role = "sink";
+ try-power-role = "sink";
+ op-sink-microwatt = <1000000>;
+ sink-pdos =
+ <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>,
+ <PDO_VAR(5000, 20000, 5000)>;
+ };
+ };
+};
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..75856ccb1288
--- /dev/null
+++ b/board/radxa/rock5b-rk3588/rock5b-rk3588.c
@@ -0,0 +1,22 @@
+// 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;
+
+ ret = tcpm_get("usb-typec at 22", &dev);
+ if (ret) {
+ printf("Failed to probe Type-C controller\n");
+ return 0;
+ }
+
+ return 0;
+}
+#endif
diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
index fc118cea7bae..e368b0439d1d 100644
--- a/configs/rock5b-rk3588_defconfig
+++ b/configs/rock5b-rk3588_defconfig
@@ -102,3 +102,7 @@ CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_USB_FUNCTION_ROCKUSB=y
CONFIG_ERRNO_STR=y
+CONFIG_TYPEC_TCPM=y
+CONFIG_TYPEC_FUSB302=y
+CONFIG_MISC_INIT_R=y
+CONFIG_CMD_TCPM=y
--
2.43.0
More information about the U-Boot
mailing list