Qualcomm platform USB support
Subsystems (8)
v5 cover Qualcomm platform USB support
This series enables USB on Qualcomm SDM845 platforms and lays the foundation for future SoCs as well.
It introduces two new high-speed PHY drivers, one for SDM845 and one for an upcoming platform. The SDM845 clock driver gains support for configuring the USB clocks, and the GPIO driver is updated to use .set_flags which fixes a strange bug where GPIOs would also be configured as input.
Support for super-speed USB modes is not currently available, however configuring the device to be high-speed only requires modifications to DT.
To improve compatibility with upstream DT, we switch Qualcomm platforms over to OF_LIVE and apply fixups to the tree to remove references to the super-speed phy, as well as configure the Qualcomm glue for high-speed only mode.
The db845c requires a vbus-supply to be hooked up for its usb type-A port. A U-Boot dtsi file is added to configure this.
With these patches, it is now also possible to run U-Boot on some SDM845 phones like the OnePlus 6 using a dtb from Linux, and access the U-Boot shell via the CDC ACM USB serial gadget.
This series depends on the ("Qualcomm DWC3 USB support") series [1], as well as Volodymyrs patches enabling power domain support [2]. A feature branch based on qcom-next with the necessary dependencies for testing the Dragonboard845c can be found at [3].
[1]: https://lore.kernel.org/u-boot/[email protected]
[2]: https://lore.kernel.org/u-boot/[email protected]
[3]: https://git.codelinaro.org/linaro/qcomlt/u-boot/-/tree/b4/qcom-livetree
---
Changes in v5:
- Call regulators_enable_boot_on() during board_init() and don't use
the vbus-supply property anymore. This is slightly more aligned with upstream.
- Minor checkpatch fixes
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Fix defconfig.
- Mark db845c vbus regulator always-on to fix a bug in Linux.
- Add a timer in qcom_of_fixup_nodes() so the boot time impact can
be easily measured.
- Drop unused macros from femto v2 phy, general cleanup, remove custom set/clrbits impl.
- Rename "7nm" phy driver to "femto-v2" to match Linux, also fix
copyright.
- Use set/clrbits() in qusb2 phy driver.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Add back missing gadget options to qcom_defconfig (thanks Neil)
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Fix incorrect order of NULL/0 parameters to of_write_prob() in fixup_qcom_dwc3()
- Move fixup_usb_nodes() to a separate file in preparation for future additions.
- Add missing break to switch case in sdm845_clk_enable()
- Remove rogue return statement in msm_gpio_set_flags()
- Rebase on Volodymyrs power domain patches.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Bhupesh Sharma (2):
phy: qcom: add Qualcomm QUSB2 USB PHY driver
phy: qcom: Add SNPS femto v2 USB HS phy
Caleb Connolly (14):
mailmap: update Bhupesh's email address
mach-snapdragon: disable power-domains for pre-reloc drivers clk/qcom: use offsets for RCG registers
clk/qcom: sdm845: add gdscs
clk/qcom: sdm845: add USB clocks
gpio: msm_gpio: add .set_flags op
serial: msm-geni: support livetree
mach-snapdragon: fixup USB nodes
mach-snapdragon: fixup power-domains
mach-snapdragon: call regulators_enable_boot_on()
dts: sdm845-db845c: add u-boot fixups
qcom_defconfig: enable livetree
qcom_defconfig: enable USB
usb: gadget: UMS: fix 64-bit division on ARM32
.mailmap | 1 + arch/arm/dts/sdm845-db845c-u-boot.dtsi | 9 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 5 + arch/arm/mach-snapdragon/of_fixup.c | 155 +++++++++++ arch/arm/mach-snapdragon/qcom-priv.h | 20 ++ configs/qcom_defconfig | 53 ++-- drivers/clk/qcom/clock-apq8016.c | 39 +-- drivers/clk/qcom/clock-apq8096.c | 28 +- drivers/clk/qcom/clock-qcom.c | 24 +- drivers/clk/qcom/clock-qcom.h | 16 +- drivers/clk/qcom/clock-qcs404.c | 122 ++------- drivers/clk/qcom/clock-sdm845.c | 61 +++-- drivers/gpio/msm_gpio.c | 27 +- drivers/phy/qcom/Kconfig | 15 ++ drivers/phy/qcom/Makefile | 2 + drivers/phy/qcom/phy-qcom-qusb2.c | 429 ++++++++++++++++++++++++++++++ drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 207 ++++++++++++++ drivers/serial/serial_msm_geni.c | 15 +- drivers/usb/gadget/f_mass_storage.c | 13 +- 20 files changed, 1001 insertions(+), 241 deletions(-)
---
base-commit: 0d08018d01afaddcee8dd1f1929a48577684110c
// Caleb (they/them)
PATCH v5 1/16 mailmap: update Bhupesh's email address
Update Bhupesh's email to his new one.
---
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -29,8 +29,9 @@ Ashok Reddy Soma <[email protected]> <[email protected]> Atish Patra <[email protected]> <[email protected]> Bharat Kumar Gogada <[email protected]> <[email protected]> Bharat Kumar Gogada <[email protected]> <[email protected]> Bhargava Sreekantappa Gayathri <[email protected]> <[email protected]> +Bhupesh Sharma <[email protected]> <[email protected]> Bin Meng <[email protected]> <[email protected]> Boris Brezillon <[email protected]> <[email protected]> Boris Brezillon <[email protected]> <[email protected]> Christian Kohn <[email protected]> <[email protected]>
Signature · 1 line
2.44.0
PATCH v5 2/16 phy: qcom: add Qualcomm QUSB2 USB PHY driver
In reply to Caleb ConnollyFrom: Bhupesh Sharma <[email protected]>
The Snapdragon 845 and several other Qualcomm SoCs feature this USB high-speed phy. Add a driver for it based on the Linux driver, with support for the SDM845, and the QCM2290 and SM6115 SoCs which will gain support in U-Boot in future patches.
--- drivers/phy/qcom/Kconfig | 7 + drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-qusb2.c | 429 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+)
drivers/phy/qcom/Kconfig +7 -0
@@ -11,8 +11,15 @@ config PHY_QCOM_IPQ4019_USB depends on PHY && ARCH_IPQ40XX help Support for the USB PHY-s on Qualcomm IPQ40xx SoC-s. +config PHY_QCOM_QUSB2 + tristate "Qualcomm USB QUSB2 PHY driver" + depends on PHY && ARCH_SNAPDRAGON + help + Enable this to support the Super-Speed USB transceiver on various + Qualcomm chipsets. + config PHY_QCOM_USB_HS_28NM tristate "Qualcomm 28nm High-Speed PHY" depends on PHY && ARCH_SNAPDRAGON help
drivers/phy/qcom/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o +obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o
drivers/phy/qcom/phy-qcom-qusb2.c new file +429 -0
429 lines not on this page · raw message
Signature · 1 line
2.44.0
Re: [PATCH v5 02/16] phy: qcom: add Qualcomm QUSB2 USB PHY driver
Quoted 8 lines · Caleb Connolly
From: Bhupesh Sharma <[email protected]>
The Snapdragon 845 and several other Qualcomm SoCs feature this USB high-speed phy. Add a driver for it based on the Linux driver, with support for the SDM845, and the QCM2290 and SM6115 SoCs which will gain support in U-Boot in future patches.
Quoted 9 lines
Signed-off-by Bhupesh Sharma <[email protected]>[code cleanup, switch to clk_bulk]Signed-off-by Caleb Connolly <[email protected]>--- drivers/phy/qcom/Kconfig | 7 + drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-qusb2.c | 429 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 437 insertions(+)
-Sumit
Quoted 469 lines
drivers/phy/qcom/Kconfig +7
-0@@ -11,8 +11,15 @@ config PHY_QCOM_IPQ4019_USB depends on PHY && ARCH_IPQ40XX help Support for the USB PHY-s on Qualcomm IPQ40xx SoC-s. +config PHY_QCOM_QUSB2 + tristate "Qualcomm USB QUSB2 PHY driver" + depends on PHY && ARCH_SNAPDRAGON + help + Enable this to support the Super-Speed USB transceiver on various + Qualcomm chipsets. + config PHY_QCOM_USB_HS_28NM tristate "Qualcomm 28nm High-Speed PHY" depends on PHY && ARCH_SNAPDRAGON helpdrivers/phy/qcom/Makefile +1
-0@@ -1,4 +1,5 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o +obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.odrivers/phy/qcom/phy-qcom-qusb2.c new file +429
-1@@ -0,0 +1,429 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2023 Bhupesh Sharma <[email protected]> +* +* Based on Linux driver +*/ + +#include <dm.h> +#include <generic-phy.h> +#include <linux/bitops.h> +#include <asm/io.h> +#include <reset.h> +#include <clk.h> +#include <linux/delay.h> + +#include <dt-bindings/phy/phy-qcom-qusb2.h> + +#define QUSB2PHY_PLL 0x0 +#define QUSB2PHY_PLL_TEST 0x04 +#define CLK_REF_SEL BIT(7) + +#define QUSB2PHY_PLL_TUNE 0x08 +#define QUSB2PHY_PLL_USER_CTL1 0x0c +#define QUSB2PHY_PLL_USER_CTL2 0x10 +#define QUSB2PHY_PLL_AUTOPGM_CTL1 0x1c +#define QUSB2PHY_PLL_PWR_CTRL 0x18 + +/* QUSB2PHY_PLL_STATUS register bits */ +#define PLL_LOCKED BIT(5) + +/* QUSB2PHY_PLL_COMMON_STATUS_ONE register bits */ +#define CORE_READY_STATUS BIT(0) + +/* QUSB2PHY_PORT_POWERDOWN register bits */ +#define CLAMP_N_EN BIT(5) +#define FREEZIO_N BIT(1) +#define POWER_DOWN BIT(0) + +/* QUSB2PHY_PWR_CTRL1 register bits */ +#define PWR_CTRL1_VREF_SUPPLY_TRIM BIT(5) +#define PWR_CTRL1_CLAMP_N_EN BIT(1) + +#define QUSB2PHY_REFCLK_ENABLE BIT(0) + +#define PHY_CLK_SCHEME_SEL BIT(0) + +/* QUSB2PHY_INTR_CTRL register bits */ +#define DMSE_INTR_HIGH_SEL BIT(4) +#define DPSE_INTR_HIGH_SEL BIT(3) +#define CHG_DET_INTR_EN BIT(2) +#define DMSE_INTR_EN BIT(1) +#define DPSE_INTR_EN BIT(0) + +/* QUSB2PHY_PLL_CORE_INPUT_OVERRIDE register bits */ +#define CORE_PLL_EN_FROM_RESET BIT(4) +#define CORE_RESET BIT(5) +#define CORE_RESET_MUX BIT(6) + +/* QUSB2PHY_IMP_CTRL1 register bits */ +#define IMP_RES_OFFSET_MASK GENMASK(5, 0) +#define IMP_RES_OFFSET_SHIFT 0x0 + +/* QUSB2PHY_PLL_BIAS_CONTROL_2 register bits */ +#define BIAS_CTRL2_RES_OFFSET_MASK GENMASK(5, 0) +#define BIAS_CTRL2_RES_OFFSET_SHIFT 0x0 + +/* QUSB2PHY_CHG_CONTROL_2 register bits */ +#define CHG_CTRL2_OFFSET_MASK GENMASK(5, 4) +#define CHG_CTRL2_OFFSET_SHIFT 0x4 + +/* QUSB2PHY_PORT_TUNE1 register bits */ +#define HSTX_TRIM_MASK GENMASK(7, 4) +#define HSTX_TRIM_SHIFT 0x4 +#define PREEMPH_WIDTH_HALF_BIT BIT(2) +#define PREEMPHASIS_EN_MASK GENMASK(1, 0) +#define PREEMPHASIS_EN_SHIFT 0x0 + +/* QUSB2PHY_PORT_TUNE2 register bits */ +#define HSDISC_TRIM_MASK GENMASK(1, 0) +#define HSDISC_TRIM_SHIFT 0x0 + +#define QUSB2PHY_PLL_ANALOG_CONTROLS_TWO 0x04 +#define QUSB2PHY_PLL_CLOCK_INVERTERS 0x18c +#define QUSB2PHY_PLL_CMODE 0x2c +#define QUSB2PHY_PLL_LOCK_DELAY 0x184 +#define QUSB2PHY_PLL_DIGITAL_TIMERS_TWO 0xb4 +#define QUSB2PHY_PLL_BIAS_CONTROL_1 0x194 +#define QUSB2PHY_PLL_BIAS_CONTROL_2 0x198 +#define QUSB2PHY_PWR_CTRL2 0x214 +#define QUSB2PHY_IMP_CTRL1 0x220 +#define QUSB2PHY_IMP_CTRL2 0x224 +#define QUSB2PHY_CHG_CTRL2 0x23c + +struct qusb2_phy_init_tbl { +unsigned int offset; +unsigned int val; +/* +* register part of layout ? +* if yes, then offset gives index in the reg-layout +*/ +int in_layout; +}; + +struct qusb2_phy_cfg { +const struct qusb2_phy_init_tbl *tbl; +/* number of entries in the table */ +unsigned int tbl_num; +/* offset to PHY_CLK_SCHEME register in TCSR map */ +unsigned int clk_scheme_offset; + +/* array of registers with different offsets */ +const unsigned int *regs; +unsigned int mask_core_ready; +unsigned int disable_ctrl; +unsigned int autoresume_en; + +/* true if PHY has PLL_TEST register to select clk_scheme */ +bool has_pll_test; + +/* true if TUNE1 register must be updated by fused value, else TUNE2 */ +bool update_tune1_with_efuse; + +/* true if PHY has PLL_CORE_INPUT_OVERRIDE register to reset PLL */ +bool has_pll_override; +}; + +/* set of registers with offsets different per-PHY */ +enum qusb2phy_reg_layout { +QUSB2PHY_PLL_CORE_INPUT_OVERRIDE , +QUSB2PHY_PLL_STATUS , +QUSB2PHY_PORT_TUNE1 , +QUSB2PHY_PORT_TUNE2 , +QUSB2PHY_PORT_TUNE3 , +QUSB2PHY_PORT_TUNE4 , +QUSB2PHY_PORT_TUNE5 , +QUSB2PHY_PORT_TEST1 , +QUSB2PHY_PORT_TEST2 , +QUSB2PHY_PORT_POWERDOWN , +QUSB2PHY_INTR_CTRL , +}; + +#define QUSB2_PHY_INIT_CFG (o, v) \ + { \ + .offset = o, .val = v, \ + } + +#define QUSB2_PHY_INIT_CFG_L (o, v) \ + { \ + .offset = o, .val = v, .in_layout = 1, \ + } + +static const struct qusb2_phy_init_tbl sm6115_init_tbl[] = { +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE1 ,0xf8 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE2 ,0x53 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE3 ,0x81 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE4 ,0x17 ), + +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_TUNE ,0x30 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_USER_CTL1 ,0x79 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_USER_CTL2 ,0x21 ), + +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TEST2 ,0x14 ), + +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_AUTOPGM_CTL1 ,0x9f ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_PWR_CTRL ,0x00 ), +}; + +static const unsigned int sm6115_regs_layout[] = { + [QUSB2PHY_PLL_STATUS ] =0x38 , [QUSB2PHY_PORT_TUNE1 ] =0x80 , + [QUSB2PHY_PORT_TUNE2 ] =0x84 , [QUSB2PHY_PORT_TUNE3 ] =0x88 , + [QUSB2PHY_PORT_TUNE4 ] =0x8c , [QUSB2PHY_PORT_TUNE5 ] =0x90 , + [QUSB2PHY_PORT_TEST1 ] =0xb8 , [QUSB2PHY_PORT_TEST2 ] =0x9c , + [QUSB2PHY_PORT_POWERDOWN ] =0xb4 , [QUSB2PHY_INTR_CTRL ] =0xbc , +}; + +static const struct qusb2_phy_init_tbl qusb2_v2_init_tbl[] = { +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_ANALOG_CONTROLS_TWO ,0x03 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_CLOCK_INVERTERS ,0x7c ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_CMODE ,0x80 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_LOCK_DELAY ,0x0a ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_DIGITAL_TIMERS_TWO ,0x19 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_BIAS_CONTROL_1 ,0x40 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_BIAS_CONTROL_2 ,0x20 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PWR_CTRL2 ,0x21 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_IMP_CTRL1 ,0x0 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_IMP_CTRL2 ,0x58 ), + +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE1 ,0x30 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE2 ,0x29 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE3 ,0xca ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE4 ,0x04 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE5 ,0x03 ), + +QUSB2_PHY_INIT_CFG (QUSB2PHY_CHG_CTRL2 ,0x0 ), +}; + +static const unsigned int qusb2_v2_regs_layout[] = { + [QUSB2PHY_PLL_CORE_INPUT_OVERRIDE ] =0xa8 , + [QUSB2PHY_PLL_STATUS ] =0x1a0 , + [QUSB2PHY_PORT_TUNE1 ] =0x240 , + [QUSB2PHY_PORT_TUNE2 ] =0x244 , + [QUSB2PHY_PORT_TUNE3 ] =0x248 , + [QUSB2PHY_PORT_TUNE4 ] =0x24c , + [QUSB2PHY_PORT_TUNE5 ] =0x250 , + [QUSB2PHY_PORT_TEST1 ] =0x254 , + [QUSB2PHY_PORT_TEST2 ] =0x258 , + [QUSB2PHY_PORT_POWERDOWN ] =0x210 , + [QUSB2PHY_INTR_CTRL ] =0x230 , +}; + +static const struct qusb2_phy_cfg sm6115_phy_cfg = { + .tbl = sm6115_init_tbl, + .tbl_num =ARRAY_SIZE (sm6115_init_tbl), + .regs = sm6115_regs_layout, + + .has_pll_test = true, + .disable_ctrl = (CLAMP_N_EN |FREEZIO_N |POWER_DOWN ), + .mask_core_ready =PLL_LOCKED , + .autoresume_en =BIT (3 ), +}; + +static const struct qusb2_phy_cfg qusb2_v2_phy_cfg = { + .tbl = qusb2_v2_init_tbl, + .tbl_num =ARRAY_SIZE (qusb2_v2_init_tbl), + .regs = qusb2_v2_regs_layout, + + .disable_ctrl = (PWR_CTRL1_VREF_SUPPLY_TRIM |PWR_CTRL1_CLAMP_N_EN | +POWER_DOWN ), + .mask_core_ready =CORE_READY_STATUS , + .has_pll_override = true, + .autoresume_en =BIT (0 ), + .update_tune1_with_efuse = true, +}; + +/** +* struct qusb2_phy - structure holding qusb2 phy attributes +* +* @phy: generic phy +* @base: iomapped memory space for qubs2 phy +* +* @cfg_ahb_clk: AHB2PHY interface clock +* @phy_rst: phy reset control +* +* @cfg: phy config data +* @has_se_clk_scheme: indicate if PHY has single-ended ref clock scheme +*/ +struct qusb2_phy { +struct phy *phy; +void __iomem *base; + +struct clk cfg_ahb_clk; +struct reset_ctl phy_rst; + +const struct qusb2_phy_cfg *cfg; +bool has_se_clk_scheme; +}; + +static inline void qusb2_phy_configure (void __iomem *base, +const unsigned int *regs, +const struct qusb2_phy_init_tbl tbl[], +int num) +{ +int i; + +for (i =0 ; i < num; i++) { +if (tbl[i].in_layout) +writel (tbl[i].val, base + regs[tbl[i].offset]); +else +writel (tbl[i].val, base + tbl[i].offset); + } +} + +static int qusb2phy_do_reset (struct qusb2_phy *qphy) +{ +int ret; + + ret =reset_assert (&qphy->phy_rst); +if (ret) +return ret; + +udelay (500 ); + + ret =reset_deassert (&qphy->phy_rst); +if (ret) +return ret; + +return 0 ; +} + +static int qusb2phy_power_on (struct phy *phy) +{ +struct qusb2_phy *qphy =dev_get_priv (phy->dev); +const struct qusb2_phy_cfg *cfg = qphy->cfg; +int ret; +u32 val; + + ret =qusb2phy_do_reset (qphy); +if (ret) +return ret; + +/* Disable the PHY */ +setbits_le32 (qphy->base + cfg->regs[QUSB2PHY_PORT_POWERDOWN ], + qphy->cfg->disable_ctrl); + +if (cfg->has_pll_test) { +/* save reset value to override reference clock scheme later */ + val =readl (qphy->base +QUSB2PHY_PLL_TEST ); + } + +qusb2_phy_configure (qphy->base, cfg->regs, cfg->tbl, cfg->tbl_num); + +/* Enable the PHY */ +clrbits_le32 (qphy->base + cfg->regs[QUSB2PHY_PORT_POWERDOWN ], +POWER_DOWN ); + +/* Required to get phy pll lock successfully */ +udelay (150 ); + +if (cfg->has_pll_test) { + val |=CLK_REF_SEL ; + +writel (val, qphy->base +QUSB2PHY_PLL_TEST ); + +/* ensure above write is through */ +readl (qphy->base +QUSB2PHY_PLL_TEST ); + } + +/* Required to get phy pll lock successfully */ +udelay (100 ); + + val =readb (qphy->base + cfg->regs[QUSB2PHY_PLL_STATUS ]); +if (!(val & cfg->mask_core_ready)) { +pr_err ("QUSB2PHY pll lock failed: status reg = %x\n" , val); + ret = -EBUSY ; +return ret; + } + +return 0 ; +} + +static int qusb2phy_power_off (struct phy *phy) +{ +struct qusb2_phy *qphy =dev_get_priv (phy->dev); + +/* Disable the PHY */ +setbits_le32 (qphy->base + qphy->cfg->regs[QUSB2PHY_PORT_POWERDOWN ], + qphy->cfg->disable_ctrl); + +reset_assert (&qphy->phy_rst); + +clk_disable (&qphy->cfg_ahb_clk); + +return 0 ; +} + +static int qusb2phy_clk_init (struct udevice *dev,struct qusb2_phy *qphy) +{ +int ret; + +/* We ignore the ref clock as we currently lack a driver for rpmcc/rpmhcc where +* it usually comes from - we assume it's always on. +*/ + ret =clk_get_by_name (dev,"cfg_ahb" , &qphy->cfg_ahb_clk); +if (ret == -ENOSYS || ret == -ENOENT ) +return 0 ; +if (ret) +return ret; + + ret =clk_enable (&qphy->cfg_ahb_clk); +if (ret) +return ret; + +return 0 ; +} + +static int qusb2phy_probe (struct udevice *dev) +{ +struct qusb2_phy *qphy =dev_get_priv (dev); +int ret; + + qphy->base = (void __iomem *)dev_read_addr (dev); +if (IS_ERR (qphy->base)) +return PTR_ERR (qphy->base); + + ret =qusb2phy_clk_init (dev, qphy); +if (ret) { +printf ("%s: Couldn't get clocks: %d\n" , __func__, ret); +return ret; + } + + ret =reset_get_by_index (dev,0 , &qphy->phy_rst); +if (ret) { +printf ("%s: Couldn't get resets: %d\n" , __func__, ret); +return ret; + } + + qphy->cfg = (const struct qusb2_phy_cfg *)dev_get_driver_data (dev); +if (!qphy->cfg) { +printf ("%s: Couldn't get driver data\n" , __func__); +return -EINVAL ; + } + +debug ("%s success qusb phy cfg %p\n" , __func__, qphy->cfg); +return 0 ; +} + +static struct phy_ops qusb2phy_ops = { + .power_on = qusb2phy_power_on, + .power_off = qusb2phy_power_off, +}; + +static const struct udevice_id qusb2phy_ids[] = { + { .compatible ="qcom,qusb2-phy" }, + { .compatible ="qcom,qcm2290-qusb2-phy" , + .data = (ulong)&sm6115_phy_cfg }, + { .compatible ="qcom,sm6115-qusb2-phy" , + .data = (ulong)&sm6115_phy_cfg }, + { .compatible ="qcom,qusb2-v2-phy" , .data = (ulong)&qusb2_v2_phy_cfg }, + {} +}; + +U_BOOT_DRIVER (qcom_qusb2_phy) = { + .name ="qcom-qusb2-phy" , + .id =UCLASS_PHY , + .of_match = qusb2phy_ids, + .ops = &qusb2phy_ops, + .probe = qusb2phy_probe, + .priv_auto =sizeof (struct qusb2_phy ), +}; --2.44.0
PATCH v5 3/16 phy: qcom: Add SNPS femto v2 USB HS phy
In reply to Caleb ConnollyFrom: Bhupesh Sharma <[email protected]>
Some Qualcomm SoCs newer than SDM845 feature a so-called "7nm phy" driver, notable the SM8250 SoC which will gain U-Boot support in upcoming patches.
Introduce a driver based on the Linux driver.
--- drivers/phy/qcom/Kconfig | 8 ++ drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 207 ++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+)
drivers/phy/qcom/Kconfig +8 -0
@@ -18,8 +18,16 @@ config PHY_QCOM_QUSB2 help Enable this to support the Super-Speed USB transceiver on various Qualcomm chipsets. +config PHY_QCOM_USB_SNPS_FEMTO_V2 + tristate "Qualcomm SNPS FEMTO USB HS PHY v2" + depends on PHY && ARCH_SNAPDRAGON + help + Enable this to support the Qualcomm Synopsys DesignWare Core 7nm + High-Speed PHY driver. This driver supports the Hi-Speed PHY which + is usually paired with Synopsys DWC3 USB IPs on MSM SOCs. + config PHY_QCOM_USB_HS_28NM tristate "Qualcomm 28nm High-Speed PHY" depends on PHY && ARCH_SNAPDRAGON help
drivers/phy/qcom/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o +obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2) += phy-qcom-snps-femto-v2.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +207 -0
207 lines not on this page · raw message
Signature · 1 line
2.44.0
Re: [PATCH v5 03/16] phy: qcom: Add SNPS femto v2 USB HS phy
Quoted 127 lines · Caleb Connolly
From: Bhupesh Sharma <[email protected]>
Some Qualcomm SoCs newer than SDM845 feature a so-called "7nm phy" driver, notable the SM8250 SoC which will gain U-Boot support in upcoming patches.
Introduce a driver based on the Linux driver.
Signed-off-by Bhupesh Sharma <[email protected]>[code cleanup, align symbol names with Linux, switch to clk/reset_bulk APIs]Signed-off-by Caleb Connolly <[email protected]>--- drivers/phy/qcom/Kconfig | 8 ++ drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 207 ++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+)drivers/phy/qcom/Kconfig +8
-0@@ -18,8 +18,16 @@ config PHY_QCOM_QUSB2 help Enable this to support the Super-Speed USB transceiver on various Qualcomm chipsets. +config PHY_QCOM_USB_SNPS_FEMTO_V2 + tristate "Qualcomm SNPS FEMTO USB HS PHY v2" + depends on PHY && ARCH_SNAPDRAGON + help + Enable this to support the Qualcomm Synopsys DesignWare Core 7nm + High-Speed PHY driver. This driver supports the Hi-Speed PHY which + is usually paired with Synopsys DWC3 USB IPs on MSM SOCs. + config PHY_QCOM_USB_HS_28NM tristate "Qualcomm 28nm High-Speed PHY" depends on PHY && ARCH_SNAPDRAGON helpdrivers/phy/qcom/Makefile +1
-0@@ -1,5 +1,6 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o +obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2) += phy-qcom-snps-femto-v2.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.odrivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +71
-0@@ -0,0 +1,207 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2020, The Linux Foundation. All rights reserved. +* Copyright (C) 2023 Bhupesh Sharma <[email protected]> +* +* 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> +#include <malloc.h> +#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) +#define SLEEPM BIT(0) +#define OPMODE_MASK GENMASK(4, 3) +#define OPMODE_NORMAL (0x00) +#define OPMODE_NONDRIVING BIT(3) +#define TERMSEL BIT(5) + +#define USB2_PHY_USB_PHY_UTMI_CTRL5 (0x50) +#define POR BIT(1) + +#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 (0x54) +#define SIDDQ BIT(2) +#define RETENABLEN BIT(3) +#define FSEL_MASK GENMASK(6, 4) +#define FSEL_DEFAULT (0x3 << 4) + +#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 (0x58) +#define VBUSVLDEXTSEL0 BIT(4) +#define PLLBTUNE BIT(5) + +#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 (0x5c) +#define VREGBYPASS BIT(0) + +#define USB2_PHY_USB_PHY_HS_PHY_CTRL1 (0x60) +#define VBUSVLDEXT0 BIT(0) + +#define USB2_PHY_USB_PHY_HS_PHY_CTRL2 (0x64) +#define USB2_AUTO_RESUME BIT(0) +#define USB2_SUSPEND_N BIT(2) +#define USB2_SUSPEND_N_SEL BIT(3) + +#define USB2_PHY_USB_PHY_CFG0 (0x94) +#define UTMI_PHY_DATAPATH_CTRL_OVERRIDE_EN BIT(0) +#define UTMI_PHY_CMN_CTRL_OVERRIDE_EN BIT(1) + +#define USB2_PHY_USB_PHY_REFCLK_CTRL (0xa0) +#define REFCLK_SEL_MASK GENMASK(1, 0) +#define REFCLK_SEL_DEFAULT (0x2 << 0) + +struct qcom_snps_hsphy { +void __iomem *base; +struct clk_bulk clks; +struct reset_ctl_bulk resets; +}; + +static inline void qcom_snps_hsphy_write_mask (void __iomem *base,u32 offset, +u32 mask,u32 val) +{
drivers/phy/qcom/phy-qcom-snps-femto-v2.c line 81
Quoted 10 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +10
-0+u32 reg; + + reg =readl_relaxed (base + offset); + + reg &= ~mask; + reg |= val & mask; +writel_relaxed (reg, base + offset); + +/* Ensure above write is completed */ +readl_relaxed (base + offset);
It looks like you have missed addressing comments related to this API. Again, why do we need this special handling in U-Boot? Why not just clrsetbits_le32()?
-Sumit
Quoted 130 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +126
-1+} + +static int qcom_snps_hsphy_usb_init (struct phy *phy) +{ +struct qcom_snps_hsphy *priv =dev_get_priv (phy->dev); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_CFG0 , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR , +POR ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,FSEL_MASK ,0 ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , +PLLBTUNE ,PLLBTUNE ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_REFCLK_CTRL , +REFCLK_SEL_DEFAULT ,REFCLK_SEL_MASK ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , +VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL1 , +VBUSVLDEXT0 ,VBUSVLDEXT0 ); + +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 , +VREGBYPASS ,VREGBYPASS ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL0 , +SLEEPM ,SLEEPM ); + +qcom_snps_hsphy_write_mask ( + priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,SIDDQ ,0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR , +0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , +USB2_SUSPEND_N_SEL ,0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_CFG0 , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,0 ); + +return 0 ; +} + +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; + + ret =qcom_snps_hsphy_usb_init (phy); +if (ret) +return ret; + +return 0 ; +} + +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 ; +} + +static int qcom_snps_hsphy_phy_probe (struct udevice *dev) +{ +struct qcom_snps_hsphy *priv =dev_get_priv (dev); +int ret; + + 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 ; +} + +static struct phy_ops qcom_snps_hsphy_phy_ops = { + .power_on = qcom_snps_hsphy_power_on, + .power_off = qcom_snps_hsphy_power_off, +}; + +static const struct udevice_id qcom_snps_hsphy_phy_ids[] = { + { .compatible ="qcom,sm8150-usb-hs-phy" }, + { .compatible ="qcom,usb-snps-hs-5nm-phy" }, + { .compatible ="qcom,usb-snps-hs-7nm-phy" }, + { .compatible ="qcom,usb-snps-femto-v2-phy" }, + {} +}; + +U_BOOT_DRIVER (qcom_usb_qcom_snps_hsphy) = { + .name ="qcom-snps-hsphy" , + .id =UCLASS_PHY , + .of_match = qcom_snps_hsphy_phy_ids, + .ops = &qcom_snps_hsphy_phy_ops, + .probe = qcom_snps_hsphy_phy_probe, + .priv_auto =sizeof (struct qcom_snps_hsphy ), +}; --2.44.0
Re: [PATCH v5 03/16] phy: qcom: Add SNPS femto v2 USB HS phy
Hi Sumit,
Quoted 19 lines · Sumit Garg
Quoted 18 lines · Caleb Connolly
From: Bhupesh Sharma <[email protected]>
Some Qualcomm SoCs newer than SDM845 feature a so-called "7nm phy" driver, notable the SM8250 SoC which will gain U-Boot support in upcoming patches.
Introduce a driver based on the Linux driver.
Signed-off-by Bhupesh Sharma <[email protected]>[code cleanup, align symbol names with Linux, switch to clk/reset_bulk APIs]Signed-off-by Caleb Connolly <[email protected]>--- drivers/phy/qcom/Kconfig | 8 ++ drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 207 ++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+)
...
Quoted 5 lines
Quoted 5 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +0
-0
...
Quoted 9 lines
Quoted 9 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +9
-0+static inline void qcom_snps_hsphy_write_mask (void __iomem *base,u32 offset, +u32 mask,u32 val) +{ +u32 reg; + + reg =readl_relaxed (base + offset); + + reg &= ~mask; + reg |= val & mask;
Quoted 8 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c line 81
Quoted 4 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +4
-0+writel_relaxed (reg, base + offset); + +/* Ensure above write is completed */ +readl_relaxed (base + offset);It looks like you have missed addressing comments related to this API. Again, why do we need this special handling in U-Boot? Why not just
clrsetbits_le32()?
I have tried to find more info about this, but from what I can tell it's important (my guess is that it's a weird bus arbitration thing with the QMP phy's).
If I replace this with clrsetbits_le32() then my SM8250 board crashdumps while probing USB. So it is needed (and I'm wondering now if I ought to switch back to this for the dwc3 qcom glue as well).
Quoted 133 lines
-Sumit
Quoted 130 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +126
-1+} + +static int qcom_snps_hsphy_usb_init (struct phy *phy) +{ +struct qcom_snps_hsphy *priv =dev_get_priv (phy->dev); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_CFG0 , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR , +POR ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,FSEL_MASK ,0 ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , +PLLBTUNE ,PLLBTUNE ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_REFCLK_CTRL , +REFCLK_SEL_DEFAULT ,REFCLK_SEL_MASK ); +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , +VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 ); +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL1 , +VBUSVLDEXT0 ,VBUSVLDEXT0 ); + +qcom_snps_hsphy_write_mask (priv->base, +USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 , +VREGBYPASS ,VREGBYPASS ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL0 , +SLEEPM ,SLEEPM ); + +qcom_snps_hsphy_write_mask ( + priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,SIDDQ ,0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR , +0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , +USB2_SUSPEND_N_SEL ,0 ); + +qcom_snps_hsphy_write_mask (priv->base,USB2_PHY_USB_PHY_CFG0 , +UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,0 ); + +return 0 ; +} + +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; + + ret =qcom_snps_hsphy_usb_init (phy); +if (ret) +return ret; + +return 0 ; +} + +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 ; +} + +static int qcom_snps_hsphy_phy_probe (struct udevice *dev) +{ +struct qcom_snps_hsphy *priv =dev_get_priv (dev); +int ret; + + 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 ; +} + +static struct phy_ops qcom_snps_hsphy_phy_ops = { + .power_on = qcom_snps_hsphy_power_on, + .power_off = qcom_snps_hsphy_power_off, +}; + +static const struct udevice_id qcom_snps_hsphy_phy_ids[] = { + { .compatible ="qcom,sm8150-usb-hs-phy" }, + { .compatible ="qcom,usb-snps-hs-5nm-phy" }, + { .compatible ="qcom,usb-snps-hs-7nm-phy" }, + { .compatible ="qcom,usb-snps-femto-v2-phy" }, + {} +}; + +U_BOOT_DRIVER (qcom_usb_qcom_snps_hsphy) = { + .name ="qcom-snps-hsphy" , + .id =UCLASS_PHY , + .of_match = qcom_snps_hsphy_phy_ids, + .ops = &qcom_snps_hsphy_phy_ops, + .probe = qcom_snps_hsphy_phy_probe, + .priv_auto =sizeof (struct qcom_snps_hsphy ), +}; --2.44.0
Signature · 1 line
// Caleb (they/them)
Sumit Garg
Acked-byRe: [PATCH v5 03/16] phy: qcom: Add SNPS femto v2 USB HS phy
Quoted 48 lines · Caleb Connolly
Hi Sumit,
Quoted 19 lines · Sumit Garg
Quoted 18 lines · Caleb Connolly
From: Bhupesh Sharma <[email protected]>
Some Qualcomm SoCs newer than SDM845 feature a so-called "7nm phy" driver, notable the SM8250 SoC which will gain U-Boot support in upcoming patches.
Introduce a driver based on the Linux driver.
Signed-off-by Bhupesh Sharma <[email protected]>[code cleanup, align symbol names with Linux, switch to clk/reset_bulk APIs]Signed-off-by Caleb Connolly <[email protected]>--- drivers/phy/qcom/Kconfig | 8 ++ drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 207 ++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+)...
Quoted 5 lines
Quoted 5 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +0
-0...
Quoted 9 lines
Quoted 9 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +9
-0+static inline void qcom_snps_hsphy_write_mask (void __iomem *base,u32 offset, +u32 mask,u32 val) +{ +u32 reg; + + reg =readl_relaxed (base + offset); + + reg &= ~mask; + reg |= val & mask;Quoted 8 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c line 81
Quoted 4 lines
drivers/phy/qcom/phy-qcom-snps-femto-v2.c new file +4
-0+writel_relaxed (reg, base + offset); + +/* Ensure above write is completed */ +readl_relaxed (base + offset);It looks like you have missed addressing comments related to this API. Again, why do we need this special handling in U-Boot? Why not just
clrsetbits_le32()?
Quoted 7 lines
I have tried to find more info about this, but from what I can tell it's important (my guess is that it's a weird bus arbitration thing with the QMP phy's).
If I replace this with
clrsetbits_le32()then my SM8250 board crashdumps while probing USB. So it is needed (and I'm wondering now if I ought to switch back to this for the dwc3 qcom glue as well).
Strange, probably it's due to some strict device memory ordering rules. If you can add some reasoning in comments for this API then feel free to add:
-Sumit
PATCH v5 4/16 mach-snapdragon: disable power-domains for pre-reloc drivers
In reply to Caleb ConnollySome devices like the UART and clock controller reference an RPM(h) power domain. We don't support this device in U-Boot, so add DM_FLAG_DEFAULT_PD_CTRL_OFF to tell DM core not to try and enable the power domain.
--- drivers/clk/qcom/clock-qcom.c | 2 ++ drivers/clk/qcom/clock-sdm845.c | 2 +- drivers/serial/serial_msm_geni.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/clk/qcom/clock-qcom.c +2 -0
@@ -226,8 +226,9 @@ U_BOOT_DRIVER(qcom_clk) = { .id = UCLASS_CLK, .ops = &msm_clk_ops, .priv_auto = sizeof(struct msm_clk_priv), .probe = msm_clk_probe, + .flags = DM_FLAG_PRE_RELOC | DM_FLAG_DEFAULT_PD_CTRL_OFF, };int qcom_cc_bind (struct udevice *parent) {
@@ -410,5 +411,6 @@ U_BOOT_DRIVER(qcom_power) = { .name = "qcom_power", .id = UCLASS_POWER_DOMAIN, .ops = &qcom_power_ops, .probe = qcom_power_probe, + .flags = DM_FLAG_PRE_RELOC, };
drivers/clk/qcom/clock-sdm845.c +1 -1
@@ -182,6 +182,6 @@ U_BOOT_DRIVER(gcc_sdm845) = { .name = "gcc_sdm845", .id = UCLASS_NOP, .of_match = gcc_sdm845_of_match, .bind = qcom_cc_bind, - .flags = DM_FLAG_PRE_RELOC, + .flags = DM_FLAG_PRE_RELOC | DM_FLAG_DEFAULT_PD_CTRL_OFF, };
drivers/serial/serial_msm_geni.c +1 -1
@@ -602,9 +602,9 @@ U_BOOT_DRIVER(serial_msm_geni) = { .of_to_plat = msm_serial_ofdata_to_platdata, .priv_auto = sizeof(struct msm_serial_data), .probe = msm_serial_probe, .ops = &msm_serial_ops, - .flags = DM_FLAG_PRE_RELOC, + .flags = DM_FLAG_PRE_RELOC | DM_FLAG_DEFAULT_PD_CTRL_OFF, };#ifdef CONFIG_DEBUG_UART_MSM_GENI
Signature · 1 line
2.44.0
PATCH v5 5/16 clk/qcom: use offsets for RCG registers
In reply to Caleb ConnollyThe RCG registers always have the same offsets, so only store the base CMD register address and calculate the others relative to that.
--- drivers/clk/qcom/clock-apq8016.c | 39 +------------ drivers/clk/qcom/clock-apq8096.c | 28 +-------- drivers/clk/qcom/clock-qcom.c | 22 +++---- drivers/clk/qcom/clock-qcom.h | 16 +++-- drivers/clk/qcom/clock-qcs404.c | 122 +++++---------------------------------- drivers/clk/qcom/clock-sdm845.c | 16 +---- 6 files changed, 39 insertions(+), 204 deletions(-)
drivers/clk/qcom/clock-apq8016.c +3 -36
@@ -22,13 +22,9 @@#define APCS_GPLL_ENA_VOTE (0x45000)#define APCS_CLOCK_BRANCH_ENA_VOTE (0x45004)#define SDCC_BCR (n) ((n * 0x1000) + 0x41000) -#define SDCC_CMD_RCGR (n) ((n * 0x1000) + 0x41004) -#define SDCC_CFG_RCGR (n) ((n * 0x1000) + 0x41008) -#define SDCC_M (n) ((n * 0x1000) + 0x4100C) -#define SDCC_N (n) ((n * 0x1000) + 0x41010) -#define SDCC_D (n) ((n * 0x1000) + 0x41014) +#define SDCC_CMD_RCGR (n) (((n + 1) * 0x1000) + 0x41004)#define SDCC_APPS_CBCR (n) ((n * 0x1000) + 0x41018)#define SDCC_AHB_CBCR (n) ((n * 0x1000) + 0x4101C)/* BLSP1 AHB clock (root clock for BLSP) */
@@ -37,33 +33,12 @@/* Uart clock control registers */ #define BLSP1_UART2_BCR (0x3028)#define BLSP1_UART2_APPS_CBCR (0x302C)#define BLSP1_UART2_APPS_CMD_RCGR (0x3034) -#define BLSP1_UART2_APPS_CFG_RCGR (0x3038) -#define BLSP1_UART2_APPS_M (0x303C) -#define BLSP1_UART2_APPS_N (0x3040) -#define BLSP1_UART2_APPS_D (0x3044)/* GPLL0 clock control registers */ #define GPLL0_STATUS_ACTIVE BIT(17) -static const struct bcr_regs sdc_regs[] = { - { - .cfg_rcgr =SDCC_CFG_RCGR (1 ), - .cmd_rcgr =SDCC_CMD_RCGR (1 ), - .M =SDCC_M (1 ), - .N =SDCC_N (1 ), - .D =SDCC_D (1 ), - }, - { - .cfg_rcgr =SDCC_CFG_RCGR (2 ), - .cmd_rcgr =SDCC_CMD_RCGR (2 ), - .M =SDCC_M (2 ), - .N =SDCC_N (2 ), - .D =SDCC_D (2 ), - } -}; -static struct pll_vote_clk gpll0_vote_clk = { .status =GPLL0_STATUS , .status_bit =GPLL0_STATUS_ACTIVE , .ena_vote =APCS_GPLL_ENA_VOTE ,
@@ -85,32 +60,24 @@ static int clk_init_sdc(struct msm_clk_priv *priv, int slot, uint rate) div =4 ;clk_enable_cbc (priv->base +SDCC_AHB_CBCR (slot));/* 800Mhz/div, gpll0 */ -clk_rcg_set_rate_mnd (priv->base, &sdc_regs[slot], div,0 ,0 , +clk_rcg_set_rate_mnd (priv->base,SDCC_CMD_RCGR (slot), div,0 ,0 ,CFG_CLK_SRC_GPLL0 ,8 );clk_enable_gpll0 (priv->base, &gpll0_vote_clk);clk_enable_cbc (priv->base +SDCC_APPS_CBCR (slot));return rate; } -static const struct bcr_regs uart2_regs = { - .cfg_rcgr =BLSP1_UART2_APPS_CFG_RCGR , - .cmd_rcgr =BLSP1_UART2_APPS_CMD_RCGR , - .M =BLSP1_UART2_APPS_M , - .N =BLSP1_UART2_APPS_N , - .D =BLSP1_UART2_APPS_D , -}; -/* UART: 115200 */ int apq8016_clk_init_uart (phys_addr_t base) {/* Enable AHB clock */ clk_enable_vote_clk (base, &gcc_blsp1_ahb_clk);/* 7372800 uart block clock @ GPLL0 */ -clk_rcg_set_rate_mnd (base, &uart2_regs,1 ,144 ,15625 , +clk_rcg_set_rate_mnd (base,BLSP1_UART2_APPS_CMD_RCGR ,1 ,144 ,15625 ,CFG_CLK_SRC_GPLL0 ,16 );/* Vote for gpll0 clock */ clk_enable_gpll0 (base, &gpll0_vote_clk);
drivers/clk/qcom/clock-apq8096.c +2 -26
@@ -25,33 +25,17 @@#define SDCC2_BCR (0x14000)/* block reset */ #define SDCC2_APPS_CBCR (0x14004)/* branch control */ #define SDCC2_AHB_CBCR (0x14008)#define SDCC2_CMD_RCGR (0x14010) -#define SDCC2_CFG_RCGR (0x14014) -#define SDCC2_M (0x14018) -#define SDCC2_N (0x1401C) -#define SDCC2_D (0x14020)#define BLSP2_AHB_CBCR (0x25004)#define BLSP2_UART2_APPS_CBCR (0x29004)#define BLSP2_UART2_APPS_CMD_RCGR (0x2900C) -#define BLSP2_UART2_APPS_CFG_RCGR (0x29010) -#define BLSP2_UART2_APPS_M (0x29014) -#define BLSP2_UART2_APPS_N (0x29018) -#define BLSP2_UART2_APPS_D (0x2901C)/* GPLL0 clock control registers */ #define GPLL0_STATUS_ACTIVE BIT(30)#define APCS_GPLL_ENA_VOTE_GPLL0 BIT(0) -static const struct bcr_regs sdc_regs = { - .cfg_rcgr =SDCC2_CFG_RCGR , - .cmd_rcgr =SDCC2_CMD_RCGR , - .M =SDCC2_M , - .N =SDCC2_N , - .D =SDCC2_D , -}; -static const struct pll_vote_clk gpll0_vote_clk = { .status =GPLL0_STATUS , .status_bit =GPLL0_STATUS_ACTIVE , .ena_vote =APCS_GPLL_ENA_VOTE ,
@@ -68,31 +52,23 @@ static int clk_init_sdc(struct msm_clk_priv *priv, uint rate) {int div =5 ;clk_enable_cbc (priv->base +SDCC2_AHB_CBCR ); -clk_rcg_set_rate_mnd (priv->base, &sdc_regs, div,0 ,0 , +clk_rcg_set_rate_mnd (priv->base,SDCC2_CMD_RCGR , div,0 ,0 ,CFG_CLK_SRC_GPLL0 ,8 );clk_enable_gpll0 (priv->base, &gpll0_vote_clk);clk_enable_cbc (priv->base +SDCC2_APPS_CBCR );return rate; } -static const struct bcr_regs uart2_regs = { - .cfg_rcgr =BLSP2_UART2_APPS_CFG_RCGR , - .cmd_rcgr =BLSP2_UART2_APPS_CMD_RCGR , - .M =BLSP2_UART2_APPS_M , - .N =BLSP2_UART2_APPS_N , - .D =BLSP2_UART2_APPS_D , -}; -static int clk_init_uart (struct msm_clk_priv *priv) {/* Enable AHB clock */ clk_enable_vote_clk (priv->base, &gcc_blsp2_ahb_clk);/* 7372800 uart block clock @ GPLL0 */ -clk_rcg_set_rate_mnd (priv->base, &uart2_regs,1 ,192 ,15625 , +clk_rcg_set_rate_mnd (priv->base,BLSP2_UART2_APPS_CMD_RCGR ,1 ,192 ,15625 ,CFG_CLK_SRC_GPLL0 ,16 );/* Vote for gpll0 clock */ clk_enable_gpll0 (priv->base, &gpll0_vote_clk);
drivers/clk/qcom/clock-qcom.c +11 -11
@@ -103,9 +103,9 @@ void clk_bcr_update(phys_addr_t apps_cmd_rcgr)/* * root set rate for clocks with half integer and MND divider * div should be pre-calculated ((div * 2) - 1) */ -void clk_rcg_set_rate_mnd (phys_addr_t base,const struct bcr_regs *regs, +void clk_rcg_set_rate_mnd (phys_addr_t base,uint32_t cmd_rcgr,int div,int m,int n,int source,u8 mnd_width) {u32 cfg;/* M value for MND divider. */
@@ -119,14 +119,14 @@ void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs,debug ("m %#x n %#x d %#x div %#x mask %#x\n" , m_val, n_val, d_val, div, mask);/* Program MND values */ -writel (m_val & mask, base + regs->M); -writel (n_val & mask, base + regs->N); -writel (d_val & mask, base + regs->D); +writel (m_val & mask, base + cmd_rcgr +RCG_M_REG ); +writel (n_val & mask, base + cmd_rcgr +RCG_N_REG ); +writel (d_val & mask, base + cmd_rcgr +RCG_D_REG );/* setup src select and divider */ - cfg =readl (base + regs->cfg_rcgr); + cfg =readl (base + cmd_rcgr +RCG_CFG_REG ); cfg &= ~(CFG_SRC_SEL_MASK |CFG_MODE_MASK |CFG_HW_CLK_CTRL_MASK |CFG_SRC_DIV_MASK ); cfg |= source &CFG_SRC_SEL_MASK ;/* Select clock source */
@@ -135,22 +135,22 @@ void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs,if (n && n != m) cfg |=CFG_MODE_DUAL_EDGE ; -writel (cfg, base + regs->cfg_rcgr);/* Write new clock configuration */ +writel (cfg, base + cmd_rcgr +RCG_CFG_REG );/* Write new clock configuration */ /* Inform h/w to start using the new config. */ -clk_bcr_update (base + regs->cmd_rcgr); +clk_bcr_update (base + cmd_rcgr); }/* root set rate for clocks with half integer and mnd_width=0 */ -void clk_rcg_set_rate (phys_addr_t base,const struct bcr_regs *regs,int div, +void clk_rcg_set_rate (phys_addr_t base,uint32_t cmd_rcgr,int div,int source) {u32 cfg;/* setup src select and divider */ - cfg =readl (base + regs->cfg_rcgr); + cfg =readl (base + cmd_rcgr +RCG_CFG_REG ); cfg &= ~(CFG_SRC_SEL_MASK |CFG_MODE_MASK |CFG_HW_CLK_CTRL_MASK ); cfg |= source &CFG_CLK_SRC_MASK ;/* Select clock source */ /*
@@ -159,12 +159,12 @@ void clk_rcg_set_rate(phys_addr_t base, const struct bcr_regs *regs, int div,*/ if (div) cfg |= (2 * div -1 ) &CFG_SRC_DIV_MASK ; -writel (cfg, base + regs->cfg_rcgr);/* Write new clock configuration */ +writel (cfg, base + cmd_rcgr +RCG_CFG_REG );/* Write new clock configuration */ /* Inform h/w to start using the new config. */ -clk_bcr_update (base + regs->cmd_rcgr); +clk_bcr_update (base + cmd_rcgr); }const struct freq_tbl *qcom_find_freq (const struct freq_tbl *f,uint rate) {
drivers/clk/qcom/clock-qcom.h +7 -9
@@ -11,8 +11,13 @@#define CFG_CLK_SRC_GPLL0 (1 << 8)#define CFG_CLK_SRC_GPLL0_EVEN (6 << 8)#define CFG_CLK_SRC_MASK (7 << 8) +#define RCG_CFG_REG 0x4 +#define RCG_M_REG 0x8 +#define RCG_N_REG 0xc +#define RCG_D_REG 0x10 +struct pll_vote_clk {uintptr_t status;int status_bit;uintptr_t ena_vote;
@@ -23,15 +28,8 @@ struct vote_clk {uintptr_t cbcr_reg;uintptr_t ena_vote;int vote_bit; }; -struct bcr_regs { -uintptr_t cfg_rcgr; -uintptr_t cmd_rcgr; -uintptr_t M; -uintptr_t N; -uintptr_t D; -};struct freq_tbl {uint freq;uint src;
@@ -87,11 +85,11 @@ void clk_enable_gpll0(phys_addr_t base, const struct pll_vote_clk *gpll0);void clk_bcr_update (phys_addr_t apps_cmd_rgcr);void clk_enable_cbc (phys_addr_t cbcr);void clk_enable_vote_clk (phys_addr_t base,const struct vote_clk *vclk);const struct freq_tbl *qcom_find_freq (const struct freq_tbl *f,uint rate); -void clk_rcg_set_rate_mnd (phys_addr_t base,const struct bcr_regs *regs, +void clk_rcg_set_rate_mnd (phys_addr_t base,uint32_t cmd_rcgr,int div,int m,int n,int source,u8 mnd_width); -void clk_rcg_set_rate (phys_addr_t base,const struct bcr_regs *regs,int div, +void clk_rcg_set_rate (phys_addr_t base,uint32_t cmd_rcgr,int div,int source);static inline void qcom_gate_clk_en (const struct msm_clk_priv *priv,unsigned long id) {
drivers/clk/qcom/clock-qcs404.c +15 -107
248 lines not on this page · raw message
drivers/clk/qcom/clock-sdm845.c +1 -15
@@ -18,15 +18,9 @@#include <dt-bindings/clock/qcom,gcc-sdm845.h> #include "clock-qcom.h" -#define SE9_AHB_CBCR 0x25004 -#define SE9_UART_APPS_CBCR 0x29004#define SE9_UART_APPS_CMD_RCGR 0x18148 -#define SE9_UART_APPS_CFG_RCGR 0x1814C -#define SE9_UART_APPS_M 0x18150 -#define SE9_UART_APPS_N 0x18154 -#define SE9_UART_APPS_D 0x18158static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {F (7372800 ,CFG_CLK_SRC_GPLL0_EVEN ,1 ,384 ,15625 ),F (14745600 ,CFG_CLK_SRC_GPLL0_EVEN ,1 ,768 ,15625 ),
@@ -45,25 +39,17 @@ static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s0_clk_src[] = { F(128000000, CFG_CLK_SRC_GPLL0, 1, 16, 75), { } }; -static const struct bcr_regs uart2_regs = { - .cfg_rcgr =SE9_UART_APPS_CFG_RCGR , - .cmd_rcgr =SE9_UART_APPS_CMD_RCGR , - .M =SE9_UART_APPS_M , - .N =SE9_UART_APPS_N , - .D =SE9_UART_APPS_D , -}; -static ulong sdm845_clk_set_rate (struct clk *clk,ulong rate) {struct msm_clk_priv *priv =dev_get_priv (clk->dev);const struct freq_tbl *freq;switch (clk->id) {case GCC_QUPV3_WRAP1_S1_CLK :/* UART9 */ freq =qcom_find_freq (ftbl_gcc_qupv3_wrap0_s0_clk_src, rate); -clk_rcg_set_rate_mnd (priv->base, &uart2_regs, +clk_rcg_set_rate_mnd (priv->base,SE9_UART_APPS_CMD_RCGR , freq->pre_div, freq->m, freq->n, freq->src,16 );return freq->freq;default :return 0 ;
Signature · 1 line
2.44.0
PATCH v5 6/16 clk/qcom: sdm845: add gdscs
In reply to Caleb ConnollyDefine the GDSC power domains for SDM845.
--- drivers/clk/qcom/clock-sdm845.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/clk/qcom/clock-sdm845.c +18 -0
@@ -145,13 +145,31 @@ static const struct qcom_reset_map sdm845_gcc_resets[] = { [GCC_USB3_DP_PHY_SEC_BCR] = { 0x50014 }, [GCC_USB_PHY_CFG_AHB2PHY_BCR] = { 0x6a000 }, }; +static const struct qcom_power_map sdm845_gdscs[] = { + [PCIE_0_GDSC ] = {0x6b004 }, + [PCIE_1_GDSC ] = {0x8d004 }, + [UFS_CARD_GDSC ] = {0x75004 }, + [UFS_PHY_GDSC ] = {0x77004 }, + [USB30_PRIM_GDSC ] = {0xf004 }, + [USB30_SEC_GDSC ] = {0x10004 }, + [HLOS1_VOTE_AGGRE_NOC_MMU_AUDIO_TBU_GDSC ] = {0x7d030 }, + [HLOS1_VOTE_AGGRE_NOC_MMU_PCIE_TBU_GDSC ] = {0x7d03c }, + [HLOS1_VOTE_AGGRE_NOC_MMU_TBU1_GDSC ] = {0x7d034 }, + [HLOS1_VOTE_AGGRE_NOC_MMU_TBU2_GDSC ] = {0x7d038 }, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF0_GDSC ] = {0x7d040 }, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF1_GDSC ] = {0x7d048 }, + [HLOS1_VOTE_MMNOC_MMU_TBU_SF_GDSC ] = {0x7d044 }, +}; +static struct msm_clk_data sdm845_clk_data = { .resets = sdm845_gcc_resets, .num_resets =ARRAY_SIZE (sdm845_gcc_resets), .clks = sdm845_clks, .num_clks =ARRAY_SIZE (sdm845_clks), + .power_domains = sdm845_gdscs, + .num_power_domains =ARRAY_SIZE (sdm845_gdscs), .enable = sdm845_clk_enable, .set_rate = sdm845_clk_set_rate, };
Signature · 1 line
2.44.0
PATCH v5 7/16 clk/qcom: sdm845: add USB clocks
In reply to Caleb ConnollyMost devices only initialise the USB clocks for us if we boot via "fastboot boot", add the missing clock configuration to get both USB ports working regardless of the bootloader state.
--- drivers/clk/qcom/clock-sdm845.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/clk/qcom/clock-sdm845.c +25 -0
@@ -20,8 +20,12 @@#include "clock-qcom.h" #define SE9_UART_APPS_CMD_RCGR 0x18148 +#define USB30_PRIM_MASTER_CLK_CMD_RCGR 0xf018 +#define USB30_PRIM_MOCK_UTMI_CLK_CMD_RCGR 0xf030 +#define USB3_PRIM_PHY_AUX_CMD_RCGR 0xf05c +static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {F (7372800 ,CFG_CLK_SRC_GPLL0_EVEN ,1 ,384 ,15625 ),F (14745600 ,CFG_CLK_SRC_GPLL0_EVEN ,1 ,768 ,15625 ),F (19200000 ,CFG_CLK_SRC_CXO ,1 ,0 ,0 ),
@@ -56,8 +60,10 @@ static ulong sdm845_clk_set_rate(struct clk *clk, ulong rate) } }static const struct gate_clk sdm845_clks[] = { +GATE_CLK (GCC_AGGRE_USB3_SEC_AXI_CLK ,0x82020 ,0x00000001 ), +GATE_CLK (GCC_CFG_NOC_USB3_SEC_AXI_CLK ,0x05030 ,0x00000001 ),GATE_CLK (GCC_QUPV3_WRAP0_S0_CLK ,0x5200c ,0x00000400 ),GATE_CLK (GCC_QUPV3_WRAP0_S1_CLK ,0x5200c ,0x00000800 ),GATE_CLK (GCC_QUPV3_WRAP0_S2_CLK ,0x5200c ,0x00001000 ),GATE_CLK (GCC_QUPV3_WRAP0_S3_CLK ,0x5200c ,0x00002000 ),
@@ -120,8 +126,27 @@ static int sdm845_clk_enable(struct clk *clk)struct msm_clk_priv *priv =dev_get_priv (clk->dev);debug ("%s: clk %s\n" , __func__, sdm845_clks[clk->id].name); +switch (clk->id) { +case GCC_USB30_PRIM_MASTER_CLK : +qcom_gate_clk_en (priv,GCC_USB_PHY_CFG_AHB2PHY_CLK ); +/* These numbers are just pulled from the frequency tables in the Linux driver */ +clk_rcg_set_rate_mnd (priv->base,USB30_PRIM_MASTER_CLK_CMD_RCGR , + (4.5 *2 ) -1 ,0 ,0 ,1 <<8 ,8 ); +clk_rcg_set_rate_mnd (priv->base,USB30_PRIM_MOCK_UTMI_CLK_CMD_RCGR , +1 ,0 ,0 ,0 ,8 ); +clk_rcg_set_rate_mnd (priv->base,USB3_PRIM_PHY_AUX_CMD_RCGR , +1 ,0 ,0 ,0 ,8 ); +break ; +case GCC_USB30_SEC_MASTER_CLK : +qcom_gate_clk_en (priv,GCC_USB3_SEC_PHY_AUX_CLK ); + +qcom_gate_clk_en (priv,GCC_USB3_SEC_CLKREF_CLK ); +qcom_gate_clk_en (priv,GCC_USB3_SEC_PHY_COM_AUX_CLK ); +break ; + } +qcom_gate_clk_en (priv, clk->id);return 0 ; }
Signature · 1 line
2.44.0
PATCH v5 8/16 gpio: msm_gpio: add .set_flags op
In reply to Caleb ConnollyThe .direction_input and .direction_output ops are deprecated, and don't seem to behave properly for us. Implement our own .set_flags op to handle this correctly.
--- drivers/gpio/msm_gpio.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/gpio/msm_gpio.c +21 -6
@@ -34,21 +34,21 @@ struct msm_gpio_bank {#define GPIO_IN_OUT_REG (dev, x) \ (GPIO_CONFIG_REG(dev, x) + 0x4) -static int msm_gpio_direction_input (struct udevice *dev,unsigned int gpio) +static void msm_gpio_direction_input (struct udevice *dev,unsigned int gpio) {struct msm_gpio_bank *priv =dev_get_priv (dev);/* Always NOP for special pins, assume they're in the correct state */ if (qcom_is_special_pin (priv->pin_data, gpio)) -return 0 ; +return ;/* Disable OE bit */ clrsetbits_le32 (priv->base +GPIO_CONFIG_REG (dev, gpio),GPIO_OE_MASK ,GPIO_OE_DISABLE ); -return 0 ; +return ; }static int msm_gpio_set_value (struct udevice *dev,unsigned int gpio,int value) {
@@ -83,8 +83,25 @@ static int msm_gpio_direction_output(struct udevice *dev, unsigned int gpio,return 0 ; } +static int msm_gpio_set_flags (struct udevice *dev,unsigned int gpio,ulong flags) +{ +if (flags &GPIOD_IS_OUT_ACTIVE ) { +return msm_gpio_direction_output (dev, gpio,1 ); + }else if (flags &GPIOD_IS_OUT ) { +return msm_gpio_direction_output (dev, gpio,0 ); + }else if (flags &GPIOD_IS_IN ) { +msm_gpio_direction_input (dev, gpio); +if (flags &GPIOD_PULL_UP ) +return msm_gpio_set_value (dev, gpio,1 ); +else if (flags &GPIOD_PULL_DOWN ) +return msm_gpio_set_value (dev, gpio,0 ); + } + +return 0 ; +} +static int msm_gpio_get_value (struct udevice *dev,unsigned int gpio) {struct msm_gpio_bank *priv =dev_get_priv (dev);
@@ -109,12 +126,10 @@ static int msm_gpio_get_function(struct udevice *dev, unsigned int gpio)return GPIOF_INPUT ; }static const struct dm_gpio_ops gpio_msm_ops = { - .direction_input = msm_gpio_direction_input, - .direction_output = msm_gpio_direction_output, + .set_flags = msm_gpio_set_flags, .get_value = msm_gpio_get_value, - .set_value = msm_gpio_set_value, .get_function = msm_gpio_get_function, };static int msm_gpio_probe (struct udevice *dev)
Signature · 1 line
2.44.0
PATCH v5 9/16 serial: msm-geni: support livetree
In reply to Caleb ConnollyWhen using OF_LIVE, the debug UART driver won't be probed if it's a subnode of the geni-se-qup controller. Add a NOP driver for the controller to correctly discover its child nodes.
--- drivers/serial/serial_msm_geni.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/serial/serial_msm_geni.c +13 -0
@@ -605,8 +605,21 @@ U_BOOT_DRIVER(serial_msm_geni) = { .ops = &msm_serial_ops, .flags = DM_FLAG_PRE_RELOC | DM_FLAG_DEFAULT_PD_CTRL_OFF, }; +static const struct udevice_id geniqup_ids[] = { + { .compatible ="qcom,geni-se-qup" }, + { } +}; + +U_BOOT_DRIVER (geni_se_qup) = { + .name ="geni-se-qup" , + .id =UCLASS_NOP , + .of_match = geniqup_ids, + .bind = dm_scan_fdt_dev, + .flags =DM_FLAG_PRE_RELOC |DM_FLAG_DEFAULT_PD_CTRL_OFF , +}; +#ifdef CONFIG_DEBUG_UART_MSM_GENI static struct msm_serial_data init_serial_data = { .base = CONFIG_VAL(DEBUG_UART_BASE)
Signature · 1 line
2.44.0
PATCH v5 10/16 mach-snapdragon: fixup USB nodes
In reply to Caleb ConnollyWe don't support USB super-speed in U-Boot yet, we lack the SS PHY drivers, however from my testing even with a PHY driver there seem to be other issues when talking to super-speed peripherals.
In pursuit of maintaining upstream DT compatibility, and simplifying porting for new devices, let's implement the DT fixups necessary to configure USB in high-speed only mode at runtime. The pattern is identical for all Qualcomm boards that use the Synaptics DWC3 controller:
* Add an additional property on the Qualcomm wrapper node
* Remove the super-speed phy phandle and phy-name entries.
--- arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 3 + arch/arm/mach-snapdragon/of_fixup.c | 123 +++++++++++++++++++++++++++++++++++ arch/arm/mach-snapdragon/qcom-priv.h | 20 ++++++ 4 files changed, 147 insertions(+)
arch/arm/mach-snapdragon/Makefile +1 -0
@@ -2,4 +2,5 @@ # # (C) Copyright 2015 Mateusz Kulikowski <[email protected]> obj-y += board.o +obj-$(CONFIG_OF_LIVE) += of_fixup.o
arch/arm/mach-snapdragon/board.c +3 -0
@@ -27,8 +27,10 @@#include <fdt_support.h> #include <usb.h> #include <sort.h> +#include "qcom-priv.h" +DECLARE_GLOBAL_DATA_PTR ;static struct mm_region rbx_mem_map[CONFIG_NR_DRAM_BANKS +2 ] = { {0 } };
@@ -159,8 +161,9 @@ void __weak qcom_board_init(void)int board_init (void ) {show_psci_version (); +qcom_of_fixup_nodes ();qcom_board_init ();return 0 ; }
arch/arm/mach-snapdragon/of_fixup.c new file +123 -0
123 lines not on this page · raw message
arch/arm/mach-snapdragon/qcom-priv.h new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef __QCOM_PRIV_H__ +#define __QCOM_PRIV_H__ + +#if CONFIG_IS_ENABLED (OF_LIVE ) +/** +* qcom_of_fixup_nodes() - Fixup Qualcomm DT nodes +* +* Adjusts nodes in the live tree to improve compatibility with U-Boot. +*/ +void qcom_of_fixup_nodes (void ); +#else +static inline void qcom_of_fixup_nodes (void ) +{ +log_debug ("Unable to dynamically fixup USB nodes, please enable CONFIG_OF_LIVE\n" ); +} +#endif /* OF_LIVE */ + +#endif /* __QCOM_PRIV_H__ */
Signature · 1 line
2.44.0
Re: [PATCH v5 10/16] mach-snapdragon: fixup USB nodes
Quoted 14 lines · Caleb Connolly
We don't support USB super-speed in U-Boot yet, we lack the SS PHY drivers, however from my testing even with a PHY driver there seem to be other issues when talking to super-speed peripherals.
In pursuit of maintaining upstream DT compatibility, and simplifying porting for new devices, let's implement the DT fixups necessary to configure USB in high-speed only mode at runtime. The pattern is identical for all Qualcomm boards that use the Synaptics DWC3 controller:
* Add an additional property on the Qualcomm wrapper node
* Remove the super-speed phy phandle and phy-name entries.
Quoted 8 lines
Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 3 + arch/arm/mach-snapdragon/of_fixup.c | 123 +++++++++++++++++++++++++++++++++++ arch/arm/mach-snapdragon/qcom-priv.h | 20 ++++++ 4 files changed, 147 insertions(+)
-Sumit
Quoted 194 lines
arch/arm/mach-snapdragon/Makefile +1
-0@@ -2,4 +2,5 @@ # # (C) Copyright 2015 Mateusz Kulikowski <[email protected]> obj-y += board.o +obj-$(CONFIG_OF_LIVE) += of_fixup.oarch/arm/mach-snapdragon/board.c +3
-0@@ -27,8 +27,10 @@#include <fdt_support.h> #include <usb.h> #include <sort.h> +#include "qcom-priv.h" +DECLARE_GLOBAL_DATA_PTR ;static struct mm_region rbx_mem_map[CONFIG_NR_DRAM_BANKS +2 ] = { {0 } };@@ -159,8 +161,9 @@ void __weak qcom_board_init(void)int board_init (void ) {show_psci_version (); +qcom_of_fixup_nodes ();qcom_board_init ();return 0 ; }arch/arm/mach-snapdragon/of_fixup.c new file +123
-0@@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* OF_LIVE devicetree fixup. +* +* This file implements runtime fixups for Qualcomm DT to improve +* compatibility with U-Boot. This includes adjusting the USB nodes +* to only use USB high-speed, as well as remapping volume buttons +* to behave as up/down for navigating U-Boot. +* +* We use OF_LIVE for this rather than early FDT fixup for a couple +* of reasons: it has a much nicer API, is most likely more efficient, +* and our changes are only applied to U-Boot. This allows us to use a +* DT designed for Linux, run U-Boot with a modified version, and then +* boot Linux with the original FDT. +* +* Copyright (c) 2024 Linaro Ltd. +* Author: Caleb Connolly <[email protected]> +*/ + +#include <dt-bindings/input/linux-event-codes.h> +#include <dm/of_access.h> +#include <dm/of.h> +#include <fdt_support.h> +#include <linux/errno.h> +#include <time.h> + +/* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 +* USB controllers. Rather than requiring source level DT changes, we fix up +* DT here. This improves compatibility with upstream DT and simplifies the +* porting process for new devices. +*/ +static int fixup_qcom_dwc3 (struct device_node *glue_np) +{ +struct device_node *dwc3; +int ret, len, hsphy_idx =1 ; +const __be32 *phandles; +const char *second_phy_name; + +debug ("Fixing up %s\n" , glue_np->name); + +/* Tell the glue driver to configure the wrapper for high-speed only operation */ + ret =of_write_prop (glue_np,"qcom,select-utmi-as-pipe-clk" ,0 ,NULL ); +if (ret) { +log_err ("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n" , ret); +return ret; + } + +/* Find the DWC3 node itself */ + dwc3 =of_find_compatible_node (glue_np,NULL ,"snps,dwc3" ); +if (!dwc3) { +log_err ("Failed to find dwc3 node\n" ); +return -ENOENT ; + } + + phandles =of_get_property (dwc3,"phys" , &len); + len /=sizeof (*phandles); +if (len ==1 ) { +log_debug ("Only one phy, not a superspeed controller\n" ); +return 0 ; + } + +/* Figure out if the superspeed phy is present and if so then which phy is it? */ + ret =of_property_read_string_index (dwc3,"phy-names" ,1 , &second_phy_name); +if (ret == -ENODATA ) { +log_debug ("Only one phy, not a super-speed controller\n" ); +return 0 ; + }else if (ret) { +log_err ("Failed to read second phy name: %d\n" , ret); +return ret; + } + +if (!strncmp ("usb3-phy" , second_phy_name,strlen ("usb3-phy" ))) { +log_debug ("Second phy isn't superspeed (is '%s') assuming first phy is SS\n" , + second_phy_name); + hsphy_idx =0 ; + } + +/* Overwrite the "phys" property to only contain the high-speed phy */ + ret =of_write_prop (dwc3,"phys" ,sizeof (*phandles), phandles + hsphy_idx); +if (ret) { +log_err ("Failed to overwrite 'phys' property: %d\n" , ret); +return ret; + } + +/* Overwrite "phy-names" to only contain a single entry */ + ret =of_write_prop (dwc3,"phy-names" ,strlen ("usb2-phy" ),"usb2-phy" ); +if (ret) { +log_err ("Failed to overwrite 'phy-names' property: %d\n" , ret); +return ret; + } + + ret =of_write_prop (dwc3,"maximum-speed" ,strlen ("high-speed" ),"high-speed" ); +if (ret) { +log_err ("Failed to set 'maximum-speed' property: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static void fixup_usb_nodes (void ) +{ +struct device_node *glue_np =NULL ; +int ret; + +while ((glue_np =of_find_compatible_node (glue_np,NULL ,"qcom,dwc3" ))) { + ret =fixup_qcom_dwc3 (glue_np); +if (ret) +log_warning ("Failed to fixup node %s: %d\n" , glue_np->name, ret); + } +} + +#define time_call (func, ...) \ + do { \ + u64 start = timer_get_us(); \ + func(__VA_ARGS__); \ + debug(#func " took %lluus\n", timer_get_us() - start); \ + } while (0) + +void qcom_of_fixup_nodes (void ) +{ +time_call (fixup_usb_nodes); +}arch/arm/mach-snapdragon/qcom-priv.h new file +20
-1@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef __QCOM_PRIV_H__ +#define __QCOM_PRIV_H__ + +#if CONFIG_IS_ENABLED (OF_LIVE ) +/** +* qcom_of_fixup_nodes() - Fixup Qualcomm DT nodes +* +* Adjusts nodes in the live tree to improve compatibility with U-Boot. +*/ +void qcom_of_fixup_nodes (void ); +#else +static inline void qcom_of_fixup_nodes (void ) +{ +log_debug ("Unable to dynamically fixup USB nodes, please enable CONFIG_OF_LIVE\n" ); +} +#endif /* OF_LIVE */ + +#endif /* __QCOM_PRIV_H__ */ --2.44.0
Re: [PATCH v5 10/16] mach-snapdragon: fixup USB nodes
In reply to Caleb ConnollyQuoted 202 lines · Caleb Connolly
We don't support USB super-speed in U-Boot yet, we lack the SS PHY drivers, however from my testing even with a PHY driver there seem to be other issues when talking to super-speed peripherals.
In pursuit of maintaining upstream DT compatibility, and simplifying porting for new devices, let's implement the DT fixups necessary to configure USB in high-speed only mode at runtime. The pattern is identical for all Qualcomm boards that use the Synaptics DWC3 controller:
* Add an additional property on the Qualcomm wrapper node
* Remove the super-speed phy phandle and phy-name entries.Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 3 + arch/arm/mach-snapdragon/of_fixup.c | 123 +++++++++++++++++++++++++++++++++++ arch/arm/mach-snapdragon/qcom-priv.h | 20 ++++++ 4 files changed, 147 insertions(+)arch/arm/mach-snapdragon/Makefile +1
-0@@ -2,4 +2,5 @@ # # (C) Copyright 2015 Mateusz Kulikowski <[email protected]> obj-y += board.o +obj-$(CONFIG_OF_LIVE) += of_fixup.oarch/arm/mach-snapdragon/board.c +3
-0@@ -27,8 +27,10 @@#include <fdt_support.h> #include <usb.h> #include <sort.h> +#include "qcom-priv.h" +DECLARE_GLOBAL_DATA_PTR ;static struct mm_region rbx_mem_map[CONFIG_NR_DRAM_BANKS +2 ] = { {0 } };@@ -159,8 +161,9 @@ void __weak qcom_board_init(void)int board_init (void ) {show_psci_version (); +qcom_of_fixup_nodes ();qcom_board_init ();return 0 ; }arch/arm/mach-snapdragon/of_fixup.c new file +123
-0@@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* OF_LIVE devicetree fixup. +* +* This file implements runtime fixups for Qualcomm DT to improve +* compatibility with U-Boot. This includes adjusting the USB nodes +* to only use USB high-speed, as well as remapping volume buttons +* to behave as up/down for navigating U-Boot. +* +* We use OF_LIVE for this rather than early FDT fixup for a couple +* of reasons: it has a much nicer API, is most likely more efficient, +* and our changes are only applied to U-Boot. This allows us to use a +* DT designed for Linux, run U-Boot with a modified version, and then +* boot Linux with the original FDT. +* +* Copyright (c) 2024 Linaro Ltd. +* Author: Caleb Connolly <[email protected]> +*/ + +#include <dt-bindings/input/linux-event-codes.h> +#include <dm/of_access.h> +#include <dm/of.h> +#include <fdt_support.h> +#include <linux/errno.h> +#include <time.h> + +/* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 +* USB controllers. Rather than requiring source level DT changes, we fix up +* DT here. This improves compatibility with upstream DT and simplifies the +* porting process for new devices. +*/ +static int fixup_qcom_dwc3 (struct device_node *glue_np) +{ +struct device_node *dwc3; +int ret, len, hsphy_idx =1 ; +const __be32 *phandles; +const char *second_phy_name; + +debug ("Fixing up %s\n" , glue_np->name); + +/* Tell the glue driver to configure the wrapper for high-speed only operation */ + ret =of_write_prop (glue_np,"qcom,select-utmi-as-pipe-clk" ,0 ,NULL ); +if (ret) { +log_err ("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n" , ret); +return ret; + } + +/* Find the DWC3 node itself */ + dwc3 =of_find_compatible_node (glue_np,NULL ,"snps,dwc3" ); +if (!dwc3) { +log_err ("Failed to find dwc3 node\n" ); +return -ENOENT ; + } + + phandles =of_get_property (dwc3,"phys" , &len); + len /=sizeof (*phandles); +if (len ==1 ) { +log_debug ("Only one phy, not a superspeed controller\n" ); +return 0 ; + } + +/* Figure out if the superspeed phy is present and if so then which phy is it? */ + ret =of_property_read_string_index (dwc3,"phy-names" ,1 , &second_phy_name); +if (ret == -ENODATA ) { +log_debug ("Only one phy, not a super-speed controller\n" ); +return 0 ; + }else if (ret) { +log_err ("Failed to read second phy name: %d\n" , ret); +return ret; + } + +if (!strncmp ("usb3-phy" , second_phy_name,strlen ("usb3-phy" ))) { +log_debug ("Second phy isn't superspeed (is '%s') assuming first phy is SS\n" , + second_phy_name); + hsphy_idx =0 ; + } + +/* Overwrite the "phys" property to only contain the high-speed phy */ + ret =of_write_prop (dwc3,"phys" ,sizeof (*phandles), phandles + hsphy_idx); +if (ret) { +log_err ("Failed to overwrite 'phys' property: %d\n" , ret); +return ret; + } + +/* Overwrite "phy-names" to only contain a single entry */ + ret =of_write_prop (dwc3,"phy-names" ,strlen ("usb2-phy" ),"usb2-phy" ); +if (ret) { +log_err ("Failed to overwrite 'phy-names' property: %d\n" , ret); +return ret; + } + + ret =of_write_prop (dwc3,"maximum-speed" ,strlen ("high-speed" ),"high-speed" ); +if (ret) { +log_err ("Failed to set 'maximum-speed' property: %d\n" , ret); +return ret; + } + +return 0 ; +} + +static void fixup_usb_nodes (void ) +{ +struct device_node *glue_np =NULL ; +int ret; + +while ((glue_np =of_find_compatible_node (glue_np,NULL ,"qcom,dwc3" ))) { + ret =fixup_qcom_dwc3 (glue_np); +if (ret) +log_warning ("Failed to fixup node %s: %d\n" , glue_np->name, ret); + } +} + +#define time_call (func, ...) \ + do { \ + u64 start = timer_get_us(); \ + func(__VA_ARGS__); \ + debug(#func " took %lluus\n", timer_get_us() - start); \ + } while (0) + +void qcom_of_fixup_nodes (void ) +{ +time_call (fixup_usb_nodes); +}arch/arm/mach-snapdragon/qcom-priv.h new file +10
-0@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef __QCOM_PRIV_H__ +#define __QCOM_PRIV_H__ + +#if CONFIG_IS_ENABLED (OF_LIVE ) +/** +* qcom_of_fixup_nodes() - Fixup Qualcomm DT nodes +* +* Adjusts nodes in the live tree to improve compatibility with U-Boot.
arch/arm/mach-snapdragon/qcom-priv.h line 20
Quoted 10 lines
arch/arm/mach-snapdragon/qcom-priv.h new file +10
-0+*/ +void qcom_of_fixup_nodes (void ); +#else +static inline void qcom_of_fixup_nodes (void ) +{ +log_debug ("Unable to dynamically fixup USB nodes, please enable CONFIG_OF_LIVE\n" ); +} +#endif /* OF_LIVE */ + +#endif /* __QCOM_PRIV_H__ */
Also tested on SM8550 & SM8650, so:
PATCH v5 11/16 mach-snapdragon: fixup power-domains
In reply to Caleb ConnollyWe don't support the RPM(h)PD power domains in U-Boot, and we don't need to - the necessary resources are on, and we aren't going to enter any low power modes.
We could try using a no-op device, but this requires adding a compatible for every platform, and just pollutes the driver model. So instead let's just remove every "power-domains" property that references the RPM(h)pd power controller. This takes <1ms as we're using OF_LIVE.
Of note, this only applies to drivers which are loading post-relocation. Drivers loaded pre-reloc that reference the rpm(h)pd still need DM_FLAG_DEFAULT_PD_CTRL_OFF in their flags.
--- arch/arm/mach-snapdragon/of_fixup.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
arch/arm/mach-snapdragon/of_fixup.c +32 -0
@@ -21,8 +21,9 @@#include <dm/of_access.h> #include <dm/of.h> #include <fdt_support.h> #include <linux/errno.h> +#include <stdlib.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 * USB controllers. Rather than requiring source level DT changes, we fix up
@@ -109,8 +110,38 @@ static void fixup_usb_nodes(void)log_warning ("Failed to fixup node %s: %d\n" , glue_np->name, ret); } } +/* Remove all references to the rpmhpd device */ +static void fixup_power_domains (void ) +{ +struct device_node *pd =NULL , *np =NULL ; +struct property *prop; +const __be32 *val; + +/* All Qualcomm platforms name the rpm(h)pd "power-controller" */ +for_each_of_allnodes (pd) { +if (pd->name && !strcmp ("power-controller" , pd->name)) +break ; + } + +/* Sanity check that this is indeed a power domain controller */ +if (!of_find_property (pd,"#power-domain-cells" ,NULL )) { +log_err ("Found power-controller but it doesn't have #power-domain-cells\n" ); +return ; + } + +/* Remove all references to the power domain controller */ +for_each_of_allnodes (np) { +if (!(prop =of_find_property (np,"power-domains" ,NULL ))) +continue ; + + val = prop->value; +if (val[0 ] ==cpu_to_fdt32 (pd->phandle)) +of_remove_property (np, prop); + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \ func(__VA_ARGS__); \
@@ -119,5 +150,6 @@ static void fixup_usb_nodes(void)void qcom_of_fixup_nodes (void ) {time_call (fixup_usb_nodes); +time_call (fixup_power_domains); }
Signature · 1 line
2.44.0
Re: [PATCH v5 11/16] mach-snapdragon: fixup power-domains
Quoted 10 lines · Caleb Connolly
We don't support the RPM(h)PD power domains in U-Boot, and we don't need to - the necessary resources are on, and we aren't going to enter any low power modes.
We could try using a no-op device, but this requires adding a compatible for every platform, and just pollutes the driver model. So instead let's just remove every "power-domains" property that references the RPM(h)pd power controller. This takes <1ms as we're using
OF_LIVE.
Quoted 9 lines
Of note, this only applies to drivers which are loading post-relocation. Drivers loaded pre-reloc that reference the rpm(h)pd still need
DM_FLAG_DEFAULT_PD_CTRL_OFFin their flags.Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/of_fixup.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
-Sumit
Quoted 64 lines
arch/arm/mach-snapdragon/of_fixup.c +32
-1@@ -21,8 +21,9 @@#include <dm/of_access.h> #include <dm/of.h> #include <fdt_support.h> #include <linux/errno.h> +#include <stdlib.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 * USB controllers. Rather than requiring source level DT changes, we fix up @@ -109,8 +110,38 @@ static void fixup_usb_nodes(void)log_warning ("Failed to fixup node %s: %d\n" , glue_np->name, ret); } } +/* Remove all references to the rpmhpd device */ +static void fixup_power_domains (void ) +{ +struct device_node *pd =NULL , *np =NULL ; +struct property *prop; +const __be32 *val; + +/* All Qualcomm platforms name the rpm(h)pd "power-controller" */ +for_each_of_allnodes (pd) { +if (pd->name && !strcmp ("power-controller" , pd->name)) +break ; + } + +/* Sanity check that this is indeed a power domain controller */ +if (!of_find_property (pd,"#power-domain-cells" ,NULL )) { +log_err ("Found power-controller but it doesn't have #power-domain-cells\n" ); +return ; + } + +/* Remove all references to the power domain controller */ +for_each_of_allnodes (np) { +if (!(prop =of_find_property (np,"power-domains" ,NULL ))) +continue ; + + val = prop->value; +if (val[0 ] ==cpu_to_fdt32 (pd->phandle)) +of_remove_property (np, prop); + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \ func(__VA_ARGS__); \@@ -119,5 +150,6 @@ static void fixup_usb_nodes(void)void qcom_of_fixup_nodes (void ) {time_call (fixup_usb_nodes); +time_call (fixup_power_domains); } --2.44.0
Re: [PATCH v5 11/16] mach-snapdragon: fixup power-domains
In reply to Caleb ConnollyQuoted 73 lines · Caleb Connolly
We don't support the RPM(h)PD power domains in U-Boot, and we don't need to - the necessary resources are on, and we aren't going to enter any low power modes.
We could try using a no-op device, but this requires adding a compatible for every platform, and just pollutes the driver model. So instead let's just remove every "power-domains" property that references the RPM(h)pd power controller. This takes <1ms as we're using
OF_LIVE.Of note, this only applies to drivers which are loading post-relocation. Drivers loaded pre-reloc that reference the rpm(h)pd still need
DM_FLAG_DEFAULT_PD_CTRL_OFFin their flags.Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/of_fixup.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)arch/arm/mach-snapdragon/of_fixup.c +31
-0@@ -21,8 +21,9 @@#include <dm/of_access.h> #include <dm/of.h> #include <fdt_support.h> #include <linux/errno.h> +#include <stdlib.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 * USB controllers. Rather than requiring source level DT changes, we fix up @@ -109,8 +110,38 @@ static void fixup_usb_nodes(void)log_warning ("Failed to fixup node %s: %d\n" , glue_np->name, ret); } } +/* Remove all references to the rpmhpd device */ +static void fixup_power_domains (void ) +{ +struct device_node *pd =NULL , *np =NULL ; +struct property *prop; +const __be32 *val; + +/* All Qualcomm platforms name the rpm(h)pd "power-controller" */ +for_each_of_allnodes (pd) { +if (pd->name && !strcmp ("power-controller" , pd->name)) +break ; + } + +/* Sanity check that this is indeed a power domain controller */ +if (!of_find_property (pd,"#power-domain-cells" ,NULL )) { +log_err ("Found power-controller but it doesn't have #power-domain-cells\n" ); +return ; + } + +/* Remove all references to the power domain controller */ +for_each_of_allnodes (np) { +if (!(prop =of_find_property (np,"power-domains" ,NULL ))) +continue ; + + val = prop->value; +if (val[0 ] ==cpu_to_fdt32 (pd->phandle)) +of_remove_property (np, prop); + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \ func(__VA_ARGS__); \
arch/arm/mach-snapdragon/of_fixup.c static void fixup_usb_nodes(void) · line 155
Quoted 6 lines
arch/arm/mach-snapdragon/of_fixup.c +1
-0@@ -119,5 +150,6 @@ static void fixup_usb_nodes(void)void qcom_of_fixup_nodes (void ) {time_call (fixup_usb_nodes); +time_call (fixup_power_domains); }
Also tested on SM8550 & SM8650, so:
PATCH v5 12/16 mach-snapdragon: call regulators_enable_boot_on()
In reply to Caleb ConnollyMake sure we power on any boot-on or always-on regulators. These are used for peripherals like USB on some platforms.
--- arch/arm/mach-snapdragon/board.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-snapdragon/board.c +2 -0
@@ -15,8 +15,9 @@#include <dm/device.h> #include <dm/pinctrl.h> #include <dm/uclass-internal.h> #include <dm/read.h> +#include <power/regulator.h> #include <env.h> #include <init.h> #include <linux/arm-smccc.h> #include <linux/bug.h>
@@ -160,8 +161,9 @@ void __weak qcom_board_init(void) }int board_init (void ) { +regulators_enable_boot_on (false);show_psci_version ();qcom_of_fixup_nodes ();qcom_board_init ();return 0 ;
Signature · 1 line
2.44.0
Re: [PATCH v5 12/16] mach-snapdragon: call regulators_enable_boot_on()
Quoted 9 lines · Caleb Connolly
Make sure we power on any boot-on or always-on regulators. These are used for peripherals like USB on some platforms.
Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/board.c | 2 ++ 1 file changed, 2 insertions(+)
-Sumit
Quoted 28 lines
arch/arm/mach-snapdragon/board.c +2
-1@@ -15,8 +15,9 @@#include <dm/device.h> #include <dm/pinctrl.h> #include <dm/uclass-internal.h> #include <dm/read.h> +#include <power/regulator.h> #include <env.h> #include <init.h> #include <linux/arm-smccc.h> #include <linux/bug.h> @@ -160,8 +161,9 @@ void __weak qcom_board_init(void) }int board_init (void ) { +regulators_enable_boot_on (false);show_psci_version ();qcom_of_fixup_nodes ();qcom_board_init ();return 0 ; --2.44.0
Re: [PATCH v5 12/16] mach-snapdragon: call regulators_enable_boot_on()
In reply to Caleb ConnollyQuoted 24 lines · Caleb Connolly
Make sure we power on any boot-on or always-on regulators. These are used for peripherals like USB on some platforms.
Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/mach-snapdragon/board.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-snapdragon/board.c +1
-0@@ -15,8 +15,9 @@#include <dm/device.h> #include <dm/pinctrl.h> #include <dm/uclass-internal.h> #include <dm/read.h> +#include <power/regulator.h> #include <env.h> #include <init.h> #include <linux/arm-smccc.h> #include <linux/bug.h>
arch/arm/mach-snapdragon/board.c void __weak qcom_board_init(void) · line 169
Quoted 9 lines
arch/arm/mach-snapdragon/board.c +1
-0@@ -160,8 +161,9 @@ void __weak qcom_board_init(void) }int board_init (void ) { +regulators_enable_boot_on (false);show_psci_version ();qcom_of_fixup_nodes ();qcom_board_init ();return 0 ;
PATCH v5 13/16 dts: sdm845-db845c: add u-boot fixups
In reply to Caleb ConnollyThe USB VBUS supply for the type-A port is enabled via a GPIO regulator. This is incorrectly modelled in Linux where only the PCIe dependency is expressed. The correct way to handle this will be through a usb-connector node, but for now we'll just mark the regulator as always-on so that it will be enabled automatically during boot.
--- arch/arm/dts/sdm845-db845c-u-boot.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/dts/sdm845-db845c-u-boot.dtsi new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Needed for Linux to boot from USB, otherwise if PCIe driver is not in initramfs + * the VBUS supply will never get turned on. + * https://lore.kernel.org/linux-arm-msm/[email protected]/ + */ +&pcie0_3p3v_dual { + regulator-always-on; +};
Signature · 1 line
2.44.0
Re: [PATCH v5 13/16] dts: sdm845-db845c: add u-boot fixups
Quoted 7 lines · Caleb Connolly
The USB VBUS supply for the type-A port is enabled via a GPIO regulator. This is incorrectly modelled in Linux where only the PCIe dependency is expressed. The correct way to handle this will be through a usb-connector node, but for now we'll just mark the regulator as always-on so that it will be enabled automatically during boot.
Quoted 5 lines
Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/dts/sdm845-db845c-u-boot.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
-Sumit
Quoted 19 lines
arch/arm/dts/sdm845-db845c-u-boot.dtsi new file +9
-1@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Needed for Linux to boot from USB, otherwise if PCIe driver is not in initramfs + * the VBUS supply will never get turned on. + * https://lore.kernel.org/linux-arm-msm/[email protected]/ + */ +&pcie0_3p3v_dual { + regulator-always-on; +}; --2.44.0
Re: [PATCH v5 13/16] dts: sdm845-db845c: add u-boot fixups
In reply to Caleb ConnollyQuoted 18 lines · Caleb Connolly
The USB VBUS supply for the type-A port is enabled via a GPIO regulator. This is incorrectly modelled in Linux where only the PCIe dependency is expressed. The correct way to handle this will be through a usb-connector node, but for now we'll just mark the regulator as always-on so that it will be enabled automatically during boot.
Signed-off-by Caleb Connolly <[email protected]>--- arch/arm/dts/sdm845-db845c-u-boot.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm/dts/sdm845-db845c-u-boot.dtsi new file +0
-0
arch/arm/dts/sdm845-db845c-u-boot.dtsi line 9
Quoted 9 lines
arch/arm/dts/sdm845-db845c-u-boot.dtsi new file +9
-0@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Needed for Linux to boot from USB, otherwise if PCIe driver is not in initramfs + * the VBUS supply will never get turned on. + * https://lore.kernel.org/linux-arm-msm/[email protected]/ + */ +&pcie0_3p3v_dual { + regulator-always-on; +};
PATCH v5 14/16 qcom_defconfig: enable livetree
In reply to Caleb ConnollyQualcomm FDTs are on the larger size, and with the addition of DT modifications during board_init() it makes sense to enable OF_LIVE globally. The cost of building the tree should be offset by the increased efficiency at which we can walk it.
Some rough measurements with CONFIG_BOOTSTAGE suggests that this might add 0.1-0.2ms to the boot-to-console time. However the reset-to-reset timer difference is in the range of 0.5ms so this could just be noise.
Suffice to say, no significant slow down.
--- configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/qcom_defconfig +1 -0
@@ -25,8 +25,9 @@ CONFIG_CMD_UFS=y CONFIG_CMD_USB=y CONFIG_CMD_CAT=y CONFIG_CMD_BMP=y CONFIG_CMD_LOG=y +CONFIG_OF_LIVE=y CONFIG_BUTTON_QCOM_PMIC=y CONFIG_CLK=y CONFIG_CLK_QCOM_QCS404=y CONFIG_CLK_QCOM_SDM845=y
Signature · 1 line
2.44.0
Re: [PATCH v5 14/16] qcom_defconfig: enable livetree
Quoted 10 lines · Caleb Connolly
Qualcomm FDTs are on the larger size, and with the addition of DT modifications during
board_init()it makes sense to enableOF_LIVEglobally. The cost of building the tree should be offset by the increased efficiency at which we can walk it.Some rough measurements with
CONFIG_BOOTSTAGEsuggests that this might add 0.1-0.2ms to the boot-to-console time. However the reset-to-reset timer difference is in the range of 0.5ms so this could just be noise.
Quoted 8 lines
Suffice to say, no significant slow down.
Reviewed-by Neil Armstrong <[email protected]>Signed-off-by Caleb Connolly <[email protected]>--- configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+)
-Sumit
Quoted 18 lines
configs/qcom_defconfig +1
-1@@ -25,8 +25,9 @@ CONFIG_CMD_UFS=y CONFIG_CMD_USB=y CONFIG_CMD_CAT=y CONFIG_CMD_BMP=y CONFIG_CMD_LOG=y +CONFIG_OF_LIVE=y CONFIG_BUTTON_QCOM_PMIC=y CONFIG_CLK=y CONFIG_CLK_QCOM_QCS404=y CONFIG_CLK_QCOM_SDM845=y --2.44.0
PATCH v5 15/16 qcom_defconfig: enable USB
In reply to Caleb ConnollyEnable support for the DWC3 USB controller and required dependencies for Qualcomm boards, specifically the DB845c:
* IOMMU / SMMU
* USB high-speed PHYs
* Mass storage and ACM gadgets
--- configs/qcom_defconfig | 52 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-)
configs/qcom_defconfig +29 -23
@@ -17,10 +17,16 @@ CONFIG_LOG_MAX_LEVEL=9 CONFIG_LOG_DEFAULT_LEVEL=4 # CONFIG_DISPLAY_CPUINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_CMD_BOOTMENU=y +CONFIG_CMD_EEPROM=y +CONFIG_SYS_I2C_EEPROM_BUS=2 +CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2 +CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=5 +# CONFIG_CMD_BIND is not set CONFIG_CMD_CLK=y CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_UFS=y CONFIG_CMD_USB=y CONFIG_CMD_CAT=y
@@ -32,20 +38,39 @@ CONFIG_CLK=y CONFIG_CLK_QCOM_QCS404=y CONFIG_CLK_QCOM_SDM845=y CONFIG_MSM_GPIO=y CONFIG_QCOM_PMIC_GPIO=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_QUP=y +CONFIG_I2C_MUX=y CONFIG_DM_KEYBOARD=y CONFIG_BUTTON_KEYBOARD=y +CONFIG_IOMMU=y +CONFIG_QCOM_HYP_SMMU=y +CONFIG_MISC=y +CONFIG_NVMEM=y +CONFIG_I2C_EEPROM=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_MSM=y +CONFIG_PHY_MICREL=y +CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y +CONFIG_DWC_ETH_QOS=y +CONFIG_DWC_ETH_QOS_QCOM=y +CONFIG_RGMII=y CONFIG_PHY=y +CONFIG_PHY_QCOM_QUSB2=y +CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=y CONFIG_PINCTRL=y CONFIG_PINCTRL_QCOM_QCS404=y CONFIG_PINCTRL_QCOM_SDM845=y CONFIG_DM_PMIC=y CONFIG_PMIC_QCOM=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_FIXED=y CONFIG_SCSI=y CONFIG_MSM_SERIAL=y CONFIG_MSM_GENI_SERIAL=y CONFIG_SPMI_MSM=y
@@ -54,8 +79,12 @@ CONFIG_SYSINFO_SMBIOS=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_UFS=y CONFIG_VIDEO=y # CONFIG_VIDEO_FONT_8X16 is not set CONFIG_VIDEO_FONT_16X32=y
@@ -64,27 +93,4 @@ CONFIG_NO_FB_CLEAR=y CONFIG_VIDEO_SIMPLE=y CONFIG_HEXDUMP=y # CONFIG_GENERATE_SMBIOS_TABLE is not set CONFIG_LMB_MAX_REGIONS=64 -CONFIG_CMD_DHCP=y -CONFIG_CMD_EEPROM=y -CONFIG_CMD_I2C=y -CONFIG_CMD_PING=y -CONFIG_DM_ETH=y -CONFIG_DM_ETH_PHY=y -CONFIG_DM_MDIO=y -CONFIG_DWC_ETH_QOS=y -CONFIG_DWC_ETH_QOS_QCOM=y -CONFIG_RGMII=y -CONFIG_PHY_MICREL=y -CONFIG_PHY_MICREL_KSZ90X1=y -CONFIG_MISC=y -CONFIG_NVMEM=y -CONFIG_DM_I2C=y -CONFIG_I2C_SUPPORT=y -CONFIG_I2C_MUX=y -CONFIG_I2C_EEPROM=y -CONFIG_SYS_I2C=y -CONFIG_SYS_I2C_QUP=y -CONFIG_SYS_I2C_EEPROM_BUS=2 -CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2 -CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=5
Signature · 1 line
2.44.0
Re: [PATCH v5 15/16] qcom_defconfig: enable USB
Quoted 7 lines · Caleb Connolly
Enable support for the DWC3 USB controller and required dependencies for Qualcomm boards, specifically the DB845c:
* IOMMU / SMMU
* USB high-speed PHYs
* Mass storage and ACM gadgets
Quoted 5 lines
Signed-off-by Caleb Connolly <[email protected]>--- configs/qcom_defconfig | 52 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-)
-Sumit
Quoted 106 lines
configs/qcom_defconfig +29
-24@@ -17,10 +17,16 @@ CONFIG_LOG_MAX_LEVEL=9 CONFIG_LOG_DEFAULT_LEVEL=4 # CONFIG_DISPLAY_CPUINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_CMD_BOOTMENU=y +CONFIG_CMD_EEPROM=y +CONFIG_SYS_I2C_EEPROM_BUS=2 +CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2 +CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=5 +# CONFIG_CMD_BIND is not set CONFIG_CMD_CLK=y CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_UFS=y CONFIG_CMD_USB=y CONFIG_CMD_CAT=y@@ -32,20 +38,39 @@ CONFIG_CLK=y CONFIG_CLK_QCOM_QCS404=y CONFIG_CLK_QCOM_SDM845=y CONFIG_MSM_GPIO=y CONFIG_QCOM_PMIC_GPIO=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_QUP=y +CONFIG_I2C_MUX=y CONFIG_DM_KEYBOARD=y CONFIG_BUTTON_KEYBOARD=y +CONFIG_IOMMU=y +CONFIG_QCOM_HYP_SMMU=y +CONFIG_MISC=y +CONFIG_NVMEM=y +CONFIG_I2C_EEPROM=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_MSM=y +CONFIG_PHY_MICREL=y +CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y +CONFIG_DWC_ETH_QOS=y +CONFIG_DWC_ETH_QOS_QCOM=y +CONFIG_RGMII=y CONFIG_PHY=y +CONFIG_PHY_QCOM_QUSB2=y +CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=y CONFIG_PINCTRL=y CONFIG_PINCTRL_QCOM_QCS404=y CONFIG_PINCTRL_QCOM_SDM845=y CONFIG_DM_PMIC=y CONFIG_PMIC_QCOM=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_FIXED=y CONFIG_SCSI=y CONFIG_MSM_SERIAL=y CONFIG_MSM_GENI_SERIAL=y CONFIG_SPMI_MSM=y@@ -54,8 +79,12 @@ CONFIG_SYSINFO_SMBIOS=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_UFS=y CONFIG_VIDEO=y # CONFIG_VIDEO_FONT_8X16 is not set CONFIG_VIDEO_FONT_16X32=y@@ -64,27 +93,4 @@ CONFIG_NO_FB_CLEAR=y CONFIG_VIDEO_SIMPLE=y CONFIG_HEXDUMP=y # CONFIG_GENERATE_SMBIOS_TABLE is not set CONFIG_LMB_MAX_REGIONS=64 -CONFIG_CMD_DHCP=y -CONFIG_CMD_EEPROM=y -CONFIG_CMD_I2C=y -CONFIG_CMD_PING=y -CONFIG_DM_ETH=y -CONFIG_DM_ETH_PHY=y -CONFIG_DM_MDIO=y -CONFIG_DWC_ETH_QOS=y -CONFIG_DWC_ETH_QOS_QCOM=y -CONFIG_RGMII=y -CONFIG_PHY_MICREL=y -CONFIG_PHY_MICREL_KSZ90X1=y -CONFIG_MISC=y -CONFIG_NVMEM=y -CONFIG_DM_I2C=y -CONFIG_I2C_SUPPORT=y -CONFIG_I2C_MUX=y -CONFIG_I2C_EEPROM=y -CONFIG_SYS_I2C=y -CONFIG_SYS_I2C_QUP=y -CONFIG_SYS_I2C_EEPROM_BUS=2 -CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2 -CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=5 --2.44.0
PATCH v5 16/16 usb: gadget: UMS: fix 64-bit division on ARM32
In reply to Caleb ConnollyThe patch introducing support for dynamic sector sizes changed the types used in some divisions, resulting in the compiler attempting to use libgcc helpers (__aeabi_ldivmod). Replace these divisions with calls to lldiv() to handle this correctly.
---
Cc: Mattijs Korpershoek <[email protected]>
--- drivers/usb/gadget/f_mass_storage.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/gadget/f_mass_storage.c +7 -6
@@ -239,8 +239,9 @@/* #define VERBOSE_DEBUG */ /* #define DUMP_MSGS */ #include <config.h> +#include <div64.h> #include <hexdump.h> #include <log.h> #include <malloc.h> #include <common.h>
@@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ;
@@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) amount = bh->outreq->actual;/* Perform the write */ rc = ums[common->lun].write_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nwritten = rc * curlun->blksize;
@@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nread = rc * curlun->blksize;
Signature · 1 line
2.44.0
Re: [PATCH v5 16/16] usb: gadget: UMS: fix 64-bit division on ARM32
Hi Caleb,
Thank you for the patch.
Quoted 7 lines · Caleb Connolly
The patch introducing support for dynamic sector sizes changed the types used in some divisions, resulting in the compiler attempting to use libgcc helpers (
__aeabi_ldivmod). Replace these divisions with calls tolldiv()to handle this correctly.Fixes 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes")Signed-off-by Caleb Connolly <[email protected]>
I believe I applied this already via [1]
I plan to send your work to Tom this week.
Sorry for the delay!
[1] https://lore.kernel.org/r/[email protected]
Quoted 62 lines
---
Cc: Mattijs Korpershoek <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/usb/gadget/f_mass_storage.c +7
-6@@ -239,8 +239,9 @@/* #define VERBOSE_DEBUG */ /* #define DUMP_MSGS */ #include <config.h> +#include <div64.h> #include <hexdump.h> #include <log.h> #include <malloc.h> #include <common.h> @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ;@@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) amount = bh->outreq->actual;/* Perform the write */ rc = ums[common->lun].write_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nwritten = rc * curlun->blksize;@@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nread = rc * curlun->blksize;Signature · 2 lines
-- 2.44.0
Re: [PATCH v5 16/16] usb: gadget: UMS: fix 64-bit division on ARM32
Hi Mattijs,
Quoted 11 lines · Mattijs Korpershoek
Hi Caleb,
Thank you for the patch.
Quoted 5 lines · Caleb Connolly
The patch introducing support for dynamic sector sizes changed the types used in some divisions, resulting in the compiler attempting to use libgcc helpers (
__aeabi_ldivmod). Replace these divisions with calls tolldiv()to handle this correctly.
Quoted 4 lines
Quoted 2 lines
Fixes 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes")Signed-off-by Caleb Connolly <[email protected]>I believe I applied this already via [1]
Oh yes of course, I'm not sure quite how this patch ended up in my outbox, apologies for any confusion.
Quoted 4 lines
I plan to send your work to Tom this week.
Sorry for the delay!
No problem at all.
Thanks,
Quoted 65 lines
[1] https://lore.kernel.org/r/[email protected]
Quoted 62 lines
---
Cc: Mattijs Korpershoek <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/usb/gadget/f_mass_storage.c +7
-6@@ -239,8 +239,9 @@/* #define VERBOSE_DEBUG */ /* #define DUMP_MSGS */ #include <config.h> +#include <div64.h> #include <hexdump.h> #include <log.h> #include <malloc.h> #include <common.h> @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ;@@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) amount = bh->outreq->actual;/* Perform the write */ rc = ums[common->lun].write_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nwritten = rc * curlun->blksize;@@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) }/* Perform the read */ rc = ums[common->lun].read_sector (&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, +lldiv (file_offset, curlun->blksize), +lldiv (amount, curlun->blksize), (char __user *)bh->buf);if (!rc)return -EIO ; nread = rc * curlun->blksize;Signature · 2 lines
-- 2.44.0
Signature · 1 line
// Caleb (they/them)