diff mbox series

[6/9] mach-snapdragon: implement ft_board_setup() for USB role selection

Message ID 20240418-b4-qcom-rbx-fixes-v1-6-f5f19d52969e@linaro.org
State Accepted
Commit e64503f1fcdfa4e836c192ab7d16075fda864d19
Headers show
Series qcom: RBx fixes and USB support | expand

Commit Message

Caleb Connolly April 18, 2024, 5:25 p.m. UTC
Some Qualcomm boards have only one USB controller which is muxed between
the type-c port and an internal USB hub for type-A and ethernet. We
modify the DT for these to force them to host mode in U-Boot. However in
Linux DRD role switching is supported (required, even). Use
ft_board_setup() to adjust the dr_mode property for these boards.

While we're here, define pr_fmt for this file so we can more easily
identify log messages.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 arch/arm/mach-snapdragon/of_fixup.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Caleb Connolly April 18, 2024, 11:19 p.m. UTC | #1
On 18/04/2024 18:25, Caleb Connolly wrote:
> Some Qualcomm boards have only one USB controller which is muxed between
> the type-c port and an internal USB hub for type-A and ethernet. We
> modify the DT for these to force them to host mode in U-Boot. However in
> Linux DRD role switching is supported (required, even). Use
> ft_board_setup() to adjust the dr_mode property for these boards.
> 
> While we're here, define pr_fmt for this file so we can more easily
> identify log messages.
> 
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>  arch/arm/mach-snapdragon/of_fixup.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
> index 3f7ac227bd09..55368dd43b66 100644
> --- a/arch/arm/mach-snapdragon/of_fixup.c
> +++ b/arch/arm/mach-snapdragon/of_fixup.c
> @@ -16,8 +16,10 @@
>   * Copyright (c) 2024 Linaro Ltd.
>   *   Author: Caleb Connolly <caleb.connolly@linaro.org>
>   */
>  
> +#define pr_fmt(fmt) "of_fixup: " fmt
> +
>  #include <dt-bindings/input/linux-event-codes.h>
>  #include <dm/of_access.h>
>  #include <dm/of.h>
>  #include <fdt_support.h>
> @@ -152,4 +154,22 @@ void qcom_of_fixup_nodes(void)
>  {
>  	time_call(fixup_usb_nodes);
>  	time_call(fixup_power_domains);
>  }
> +
> +int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
> +{
> +	struct fdt_header *fdt = blob;
> +	int node;
> +
> +	/* We only want to do this fix-up for the RB1 board, quick return for all others */
> +	if (!fdt_node_check_compatible(fdt, 0, "qcom,qrb4210-rb2"))

This if block is accidentally inverted...
> +		return 0;
> +
> +	fdt_for_each_node_by_compatible(node, blob, 0, "snps,dwc3") {
> +		log_debug("%s: Setting 'dr_mode' to OTG\n", fdt_get_name(blob, node, NULL));
> +		fdt_setprop_string(fdt, node, "dr_mode", "otg");
> +		break;
> +	}
> +
> +	return 0;
> +}
>
diff mbox series

Patch

diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
index 3f7ac227bd09..55368dd43b66 100644
--- a/arch/arm/mach-snapdragon/of_fixup.c
+++ b/arch/arm/mach-snapdragon/of_fixup.c
@@ -16,8 +16,10 @@ 
  * Copyright (c) 2024 Linaro Ltd.
  *   Author: Caleb Connolly <caleb.connolly@linaro.org>
  */
 
+#define pr_fmt(fmt) "of_fixup: " fmt
+
 #include <dt-bindings/input/linux-event-codes.h>
 #include <dm/of_access.h>
 #include <dm/of.h>
 #include <fdt_support.h>
@@ -152,4 +154,22 @@  void qcom_of_fixup_nodes(void)
 {
 	time_call(fixup_usb_nodes);
 	time_call(fixup_power_domains);
 }
+
+int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
+{
+	struct fdt_header *fdt = blob;
+	int node;
+
+	/* We only want to do this fix-up for the RB1 board, quick return for all others */
+	if (!fdt_node_check_compatible(fdt, 0, "qcom,qrb4210-rb2"))
+		return 0;
+
+	fdt_for_each_node_by_compatible(node, blob, 0, "snps,dwc3") {
+		log_debug("%s: Setting 'dr_mode' to OTG\n", fdt_get_name(blob, node, NULL));
+		fdt_setprop_string(fdt, node, "dr_mode", "otg");
+		break;
+	}
+
+	return 0;
+}