[PATCH 0/9] qcom: RBx fixes and USB support

This series is a few loosely connected patches to get the RB1 and 2 boards booting from USB with upstream U-Boot, and a few preperatory patches for rb5.
Unfortunately the RB5 board requires a regulator on the RPMh peripheral to be turned on for the USB VBUS rail. Support for this will be added in future patches.
* Add a few missing compatible strings for sm6115/sm8250 * Fix the femto-v2 HS USB phy used on sm8250 * Fix USB role selection on RB2 (without breaking Linux!) * Pick a value for CONFIG_SYS_LOAD_ADDR that won't cause a null pointer on most boards * Fix EFI booting by generating SMBIOS tables
--- Caleb Connolly (9): gpio: qcom_pmic: add pm6125 gpio: qcom_pmic: add pm8150l iommu: qcom-smmu: add qcom generic compatible phy: qcom: snps-femto-v2: drop clocks arm: dts: qrb4210-rb2-u-boot: add u-boot fixups mach-snapdragon: implement ft_board_setup() for USB role selection qcom_defconfig: enable OF_BOARD_SETUP qcom_defconfig: define safe default SYS_LOAD_ADDR qcom_defconfig: generate SMBIOS tables
arch/arm/dts/qrb4210-rb2-u-boot.dtsi | 6 ++++++ arch/arm/mach-snapdragon/of_fixup.c | 20 ++++++++++++++++++++ configs/qcom_defconfig | 5 +++-- drivers/gpio/qcom_pmic_gpio.c | 2 ++ drivers/iommu/qcom-hyp-smmu.c | 1 + drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 14 -------------- 6 files changed, 32 insertions(+), 16 deletions(-) --- base-commit: d5460b082cd6afd0e07c0ec0e5a82d1af8dc09f7
// Caleb (they/them)

As with some other modern PMICs, writing to the GPIOs seems to make the device reset.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- drivers/gpio/qcom_pmic_gpio.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index dfb70faf94b4..362d98dbf8cb 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -363,8 +363,9 @@ static const struct udevice_id qcom_gpio_ids[] = { { .compatible = "qcom,pm8916-gpio" }, { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ { .compatible = "qcom,pm8998-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { .compatible = "qcom,pms405-gpio" }, + { .compatible = "qcom,pm6125-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { .compatible = "qcom,pm8550-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { } };

This is used for the volume keys on some SM8150/SM8250 devices.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- drivers/gpio/qcom_pmic_gpio.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 362d98dbf8cb..0dd3434e9e04 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -364,8 +364,9 @@ static const struct udevice_id qcom_gpio_ids[] = { { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ { .compatible = "qcom,pm8998-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { .compatible = "qcom,pms405-gpio" }, { .compatible = "qcom,pm6125-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, + { .compatible = "qcom,pm8150-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { .compatible = "qcom,pm8550-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { } };

With the exception of SDM845, most other Qualcomm SoCs have the Qualcomm specific (but not SoC) specific SMMU compatible string. Add it here so we can match those without having to add individual SoCs to the list here.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- drivers/iommu/qcom-hyp-smmu.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/iommu/qcom-hyp-smmu.c b/drivers/iommu/qcom-hyp-smmu.c index f2b39de56f4a..7b646d840dd4 100644 --- a/drivers/iommu/qcom-hyp-smmu.c +++ b/drivers/iommu/qcom-hyp-smmu.c @@ -380,8 +380,9 @@ static struct iommu_ops qcom_smmu_ops = { };
static const struct udevice_id qcom_smmu500_ids[] = { { .compatible = "qcom,sdm845-smmu-500" }, + { .compatible = "qcom,smmu-500", }, { /* sentinel */ } };
U_BOOT_DRIVER(qcom_smmu500) = {

There is a clock associated with this phy, but it's always from the rpmhcc and isn't actually needed for the hardware to work.
Drop all the clock handling from the driver.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 14 -------------- 1 file changed, 14 deletions(-)
diff --git a/drivers/phy/qcom/phy-qcom-snps-femto-v2.c b/drivers/phy/qcom/phy-qcom-snps-femto-v2.c index a1675b664e46..04f0f0e7817d 100644 --- a/drivers/phy/qcom/phy-qcom-snps-femto-v2.c +++ b/drivers/phy/qcom/phy-qcom-snps-femto-v2.c @@ -5,10 +5,8 @@ * * Based on Linux driver */
-#include <clk.h> -#include <clk-uclass.h> #include <dm.h> #include <dm/device_compat.h> #include <dm/devres.h> #include <generic-phy.h> @@ -16,9 +14,8 @@ #include <reset.h>
#include <asm/io.h> #include <linux/bitops.h> -#include <linux/clk-provider.h> #include <linux/delay.h> #include <linux/iopoll.h>
#define USB2_PHY_USB_PHY_UTMI_CTRL0 (0x3c) @@ -61,9 +58,8 @@ #define REFCLK_SEL_DEFAULT (0x2 << 0)
struct qcom_snps_hsphy { void __iomem *base; - struct clk_bulk clks; struct reset_ctl_bulk resets; };
/* @@ -142,10 +138,8 @@ static int qcom_snps_hsphy_power_on(struct phy *phy) { struct qcom_snps_hsphy *priv = dev_get_priv(phy->dev); int ret;
- clk_enable_bulk(&priv->clks); - ret = reset_deassert_bulk(&priv->resets); if (ret) return ret;
@@ -160,9 +154,8 @@ static int qcom_snps_hsphy_power_off(struct phy *phy) { struct qcom_snps_hsphy *priv = dev_get_priv(phy->dev);
reset_assert_bulk(&priv->resets); - clk_disable_bulk(&priv->clks);
return 0; }
@@ -174,21 +167,14 @@ static int qcom_snps_hsphy_phy_probe(struct udevice *dev) priv->base = dev_read_addr_ptr(dev); if (IS_ERR(priv->base)) return PTR_ERR(priv->base);
- ret = clk_get_bulk(dev, &priv->clks); - if (ret < 0 && ret != -ENOENT) { - printf("%s: Failed to get clocks %d\n", __func__, ret); - return ret; - } - ret = reset_get_bulk(dev, &priv->resets); if (ret < 0) { printf("failed to get resets, ret = %d\n", ret); return ret; }
- clk_enable_bulk(&priv->clks); reset_deassert_bulk(&priv->resets);
return 0; }

Add a fixup to force dr_mode to host for U-Boot.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- arch/arm/dts/qrb4210-rb2-u-boot.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/arm/dts/qrb4210-rb2-u-boot.dtsi b/arch/arm/dts/qrb4210-rb2-u-boot.dtsi new file mode 100644 index 000000000000..7d1375f38c44 --- /dev/null +++ b/arch/arm/dts/qrb4210-rb2-u-boot.dtsi @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* This is usually OTG but U-Boot doesn't support that properly */ +&usb_dwc3 { + dr_mode = "host"; +};

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")) + 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; +}

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;
+}

Use our new ft_board_setup().
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index 7b589f0bf7a7..209a7ba324d0 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -33,8 +33,9 @@ CONFIG_CMD_USB=y CONFIG_CMD_CAT=y CONFIG_CMD_BMP=y CONFIG_CMD_LOG=y CONFIG_OF_LIVE=y +CONFIG_OF_BOARD_SETUP=y CONFIG_BUTTON_QCOM_PMIC=y CONFIG_CLK=y CONFIG_CLK_QCOM_QCM2290=y CONFIG_CLK_QCOM_QCS404=y

Defining this as 0 results in bootm causing a null pointer exception... Define it at a safe default which is valid RAM on most qcom boards.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- configs/qcom_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index 209a7ba324d0..41545fd72fcc 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -2,9 +2,9 @@ CONFIG_ARM=y CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_POSITION_INDEPENDENT=y CONFIG_ARCH_SNAPDRAGON=y CONFIG_DEFAULT_DEVICE_TREE="qcom/sdm845-db845c" -CONFIG_SYS_LOAD_ADDR=0x0 +CONFIG_SYS_LOAD_ADDR=0xA0000000 CONFIG_SYS_INIT_SP_BSS_OFFSET=1572864 CONFIG_BUTTON_CMD=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y

EFI initialisation fails without this, and with proper SMBIOS v3 support in (and automatic generation of useful tables) there's no reason for us not to do this on qcom platforms.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- configs/qcom_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index 41545fd72fcc..7919aeb9755d 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -104,6 +104,6 @@ CONFIG_VIDEO_FONT_16X32=y CONFIG_SYS_WHITE_ON_BLACK=y CONFIG_NO_FB_CLEAR=y CONFIG_VIDEO_SIMPLE=y CONFIG_HEXDUMP=y -# CONFIG_GENERATE_SMBIOS_TABLE is not set +CONFIG_GENERATE_SMBIOS_TABLE=y CONFIG_LMB_MAX_REGIONS=64

On Thu, 18 Apr 2024 18:25:43 +0100, Caleb Connolly wrote:
This series is a few loosely connected patches to get the RB1 and 2 boards booting from USB with upstream U-Boot, and a few preperatory patches for rb5.
Unfortunately the RB5 board requires a regulator on the RPMh peripheral to be turned on for the USB VBUS rail. Support for this will be added in future patches.
[...]
Applied, thanks!
[1/9] gpio: qcom_pmic: add pm6125 commit: 733f6d982099c639c0872ed535be9eede2765a2d [2/9] gpio: qcom_pmic: add pm8150l commit: 8bf1eb9a2e1e68ee18db084f24e8961e655926c4 [3/9] iommu: qcom-smmu: add qcom generic compatible commit: 2bd5bcaf7d23fc6ad9b2caf351fdb0b1bf712999 [4/9] phy: qcom: snps-femto-v2: drop clocks commit: 82a99b3ab8f022656a13e6dffdac93f5b1bc1d54 [5/9] arm: dts: qrb4210-rb2-u-boot: add u-boot fixups commit: 956f6e4de48f5f6c549d403a9f6db78a8deef689 [6/9] mach-snapdragon: implement ft_board_setup() for USB role selection commit: e64503f1fcdfa4e836c192ab7d16075fda864d19 [7/9] qcom_defconfig: enable OF_BOARD_SETUP commit: 9050686c1b9d9d9ac03a3f685458ab5eb2969e15 [8/9] qcom_defconfig: define safe default SYS_LOAD_ADDR commit: 9861ebac77d46674243886136275aac1deb7f982 [9/9] qcom_defconfig: generate SMBIOS tables commit: d286220078505727c8c0baf9cd9c832a1fcad805
Best regards,
participants (1)
-
Caleb Connolly