phy: qcom-qusb2: sort out register layouts
Subsystems (3)
v3 cover phy: qcom-qusb2: sort out register layouts
IPQ6018 and MSM8996 use the same register layout, however for historical reasons ipq6018_regs_layout ended up correctly definig TEST1 register at 0x98 (because platforms using that layout didn't use autoresume), while msm8996_regs_layout used TEST_CTRL offset (0xb8) for the TEST1 layout entry. Fix handling of the autoresume register and definitions of those regs layouts.
---
Changes in v3:
- Rebased on next (Vinod)
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Reworked the series to enable autoresume on Talos
- Moved autoresume description to the regs layout, it is a property of
the regs rather than a platform.
- Link to v1: https://patch.msgid.link/[email protected]
To: Vinod Koul <[email protected]>
To: Neil Armstrong <[email protected]>
To: Krishna Kurapati <[email protected]>
To: Dmitry Baryshkov <[email protected]>
To: Kathiravan T <[email protected]>
To: Baruch Siach <[email protected]>
To: Manu Gautam <[email protected]>
To: Kishon Vijay Abraham I <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Dmitry Baryshkov (3):
phy: qcom-qusb2: enable autoresume on Talos platforms
phy: qcom-qusb2: correst PHY description for IPQ6018
phy: qcom-qusb2: describe autoresume bit
drivers/phy/qualcomm/phy-qcom-qusb2.c | 55 ++++++++++++++++------------------- 1 file changed, 25 insertions(+), 30 deletions(-)
---
base-commit: 3f2425f5b5bbbdd991ca9cdfd5502e68d8895998
change-id: 20260702-fix-qusb2-3600a65bfcae
Best regards,
Signature · 2 lines
With best wishes Dmitry
PATCH v3 1/3 phy: qcom-qusb2: enable autoresume on Talos platforms
According to Krishna, having autoresume disabled on Talos is a c&p error and it should be enabled.
--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/phy/qualcomm/phy-qcom-qusb2.c +2 -3
@@ -347,12 +347,11 @@ static const struct qusb2_phy_cfg ipq6018_phy_cfg = {static const struct qusb2_phy_cfg qcs615_phy_cfg = { .tbl = qcs615_init_tbl, .tbl_num =ARRAY_SIZE (qcs615_init_tbl), - .regs = ipq6018_regs_layout, + .regs = msm8996_regs_layout, .disable_ctrl = (CLAMP_N_EN |FREEZIO_N |POWER_DOWN ), .mask_core_ready =PLL_LOCKED , -/* autoresume not used */ - .autoresume_en =BIT (0 ), + .autoresume_en =BIT (3 ), };static const struct qusb2_phy_cfg qusb2_v2_phy_cfg = {
Signature · 1 line
2.47.3
PATCH v3 2/3 phy: qcom-qusb2: correst PHY description for IPQ6018
In reply to Dmitry BaryshkovQualcomm IPQ6018 doesn't need to reach power collapse or retention of the USB voltage rails, so autoresume is not used on that platform. Instead of programming a fake register bit (BIT(0) of TEST1, while the QUSB2 platforms on that platform should use BIT(3) of TEST_CTRL), explicitly disable autoresume programming on these devices via the flag in the platform data.
--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qusb2.c +3 -1
@@ -294,6 +294,7 @@ struct qusb2_phy_cfg {unsigned int mask_core_ready;unsigned int disable_ctrl;unsigned int autoresume_en; +bool autoresume_disable;/* true if PHY has PLL_TEST register to select clk_scheme */ bool has_pll_test;
@@ -341,6 +342,7 @@ static const struct qusb2_phy_cfg ipq6018_phy_cfg = { .disable_ctrl = POWER_DOWN, .mask_core_ready = PLL_LOCKED, /* autoresume not used */ + .autoresume_disable = true, .autoresume_en = BIT(0), };
@@ -687,7 +689,7 @@ static int __maybe_unused qusb2_phy_runtime_suspend(struct device *dev) }/* enable phy auto-resume only if device is connected on bus */ -if (qphy->mode !=PHY_MODE_INVALID ) { +if (qphy->mode !=PHY_MODE_INVALID && !cfg->autoresume_disable) {qusb2_setbits (qphy->base, cfg->regs[QUSB2PHY_PORT_TEST1 ], cfg->autoresume_en);/* Autoresume bit has to be toggled in order to enable it */
Signature · 1 line
2.47.3
PATCH v3 3/3 phy: qcom-qusb2: describe autoresume bit
In reply to Dmitry BaryshkovThere is a confusion regarding the autoresume bit. Some verions of the QUSB2 PHY have it in the TEST1 register, while on the others it is a part of the TEST_CTRL register. When adding support for autoresume bit, the code attempted to simplify the handling of those registers, putting both registers to the TEST1 layout entry. In the end, ipq6018_regs_layout ended up correctly definig TEST1 register at 0x98 (because platforms using that layout didn't use autoresume), while msm8996_regs_layout used TEST_CTRL offset (0xb8) for the TEST1 layout entry.
Update the platform data to specify the register to be used for autoresume handling, define both TEST1 and TEST_CTRL registers and merge ipq6018_regs_layout and msm8996_regs_layout which become identical afterwards.
--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 48 +++++++++++++++-------------------- 1 file changed, 21 insertions(+), 27 deletions(-)
drivers/phy/qualcomm/phy-qcom-qusb2.c +21 -27
@@ -131,8 +131,13 @@ enum qusb2phy_reg_layout {QUSB2PHY_PORT_TUNE5 ,QUSB2PHY_PORT_TEST1 ,QUSB2PHY_PORT_TEST2 , +QUSB2PHY_PORT_TEST_CTRL ,QUSB2PHY_PORT_POWERDOWN ,QUSB2PHY_INTR_CTRL , + +/* layout of the autoresume bit */ +QUSB2PHY_AUTORESUME_REG , + QUSB2PHY_AUTORESUME_BIT, }; static const struct qusb2_phy_init_tbl ipq6018_init_tbl[] = {
@@ -164,19 +169,6 @@ static const struct qusb2_phy_init_tbl qcs615_init_tbl[] = { QUSB2_PHY_INIT_CFG(QUSB2PHY_PLL_PWR_CTRL, 0x00), }; -static const unsigned int ipq6018_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 ] =0x98 , - [QUSB2PHY_PORT_TEST2 ] =0x9C , - [QUSB2PHY_PORT_POWERDOWN ] =0xB4 , - [QUSB2PHY_INTR_CTRL ] =0xBC , -}; -static const unsigned int msm8996_regs_layout[] = { [QUSB2PHY_PLL_STATUS ] =0x38 , [QUSB2PHY_PORT_TUNE1 ] =0x80 ,
@@ -184,10 +176,14 @@ static const unsigned int msm8996_regs_layout[] = { [QUSB2PHY_PORT_TUNE3] = 0x88, [QUSB2PHY_PORT_TUNE4] = 0x8c, [QUSB2PHY_PORT_TUNE5] = 0x90, - [QUSB2PHY_PORT_TEST1] = 0xb8, + [QUSB2PHY_PORT_TEST1] = 0x98, [QUSB2PHY_PORT_TEST2] = 0x9c, + [QUSB2PHY_PORT_TEST_CTRL] = 0xb8, [QUSB2PHY_PORT_POWERDOWN] = 0xb4, [QUSB2PHY_INTR_CTRL] = 0xbc, + + [QUSB2PHY_AUTORESUME_REG] = 0xb8, /* TEST_CTRL */ + [QUSB2PHY_AUTORESUME_BIT] = BIT(3), };static const struct qusb2_phy_init_tbl msm8996_init_tbl[] = {
@@ -217,6 +213,9 @@ static const unsigned int msm8998_regs_layout[] = { [QUSB2PHY_PORT_TEST2] = 0x250, [QUSB2PHY_PORT_POWERDOWN] = 0x210, [QUSB2PHY_INTR_CTRL] = 0x22c, + + [QUSB2PHY_AUTORESUME_REG] = 0x24c, /* TEST1 */ + [QUSB2PHY_AUTORESUME_BIT] = BIT(0), };static const struct qusb2_phy_init_tbl msm8998_init_tbl[] = {
@@ -259,6 +258,9 @@ static const unsigned int qusb2_v2_regs_layout[] = { [QUSB2PHY_PORT_TEST2] = 0x258, [QUSB2PHY_PORT_POWERDOWN] = 0x210, [QUSB2PHY_INTR_CTRL] = 0x230, + + [QUSB2PHY_AUTORESUME_REG] = 0x254, /* TEST1 */ + [QUSB2PHY_AUTORESUME_BIT] = BIT(0), };static const struct qusb2_phy_init_tbl qusb2_v2_init_tbl[] = {
@@ -293,7 +295,6 @@ struct qusb2_phy_cfg {const unsigned int *regs;unsigned int mask_core_ready;unsigned int disable_ctrl; -unsigned int autoresume_en;bool autoresume_disable;/* true if PHY has PLL_TEST register to select clk_scheme */
@@ -318,7 +319,6 @@ static const struct qusb2_phy_cfg msm8996_phy_cfg = { .se_clk_scheme_default = 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 msm8998_phy_cfg = {
@@ -330,20 +330,18 @@ static const struct qusb2_phy_cfg msm8998_phy_cfg = { .mask_core_ready = CORE_READY_STATUS, .has_pll_override = true, .se_clk_scheme_default = true, - .autoresume_en = BIT(0), .update_tune1_with_efuse = true, };static const struct qusb2_phy_cfg ipq6018_phy_cfg = { .tbl = ipq6018_init_tbl, .tbl_num =ARRAY_SIZE (ipq6018_init_tbl), - .regs = ipq6018_regs_layout, + .regs = msm8996_regs_layout, .disable_ctrl =POWER_DOWN , .mask_core_ready =PLL_LOCKED ,/* autoresume not used */ .autoresume_disable = true, - .autoresume_en =BIT (0 ), };static const struct qusb2_phy_cfg qcs615_phy_cfg = {
@@ -353,7 +351,6 @@ static const struct qusb2_phy_cfg qcs615_phy_cfg = { .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 = {
@@ -366,7 +363,6 @@ static const struct qusb2_phy_cfg qusb2_v2_phy_cfg = { .mask_core_ready = CORE_READY_STATUS, .has_pll_override = true, .se_clk_scheme_default = true, - .autoresume_en = BIT(0), .update_tune1_with_efuse = true, };
@@ -379,7 +375,6 @@ static const struct qusb2_phy_cfg sdm660_phy_cfg = { .se_clk_scheme_default = false, .disable_ctrl = (CLAMP_N_EN | FREEZIO_N | POWER_DOWN), .mask_core_ready = PLL_LOCKED, - .autoresume_en = BIT(3), };static const struct qusb2_phy_cfg shikra_phy_cfg = {
@@ -402,7 +397,6 @@ static const struct qusb2_phy_cfg sm6115_phy_cfg = { .se_clk_scheme_default = true, .disable_ctrl = (CLAMP_N_EN | FREEZIO_N | POWER_DOWN), .mask_core_ready = PLL_LOCKED, - .autoresume_en = BIT(3), };static const char *const qusb2_phy_vreg_names[] = {
@@ -690,11 +684,11 @@ static int __maybe_unused qusb2_phy_runtime_suspend(struct device *dev)/* enable phy auto-resume only if device is connected on bus */ if (qphy->mode !=PHY_MODE_INVALID && !cfg->autoresume_disable) { -qusb2_setbits (qphy->base, cfg->regs[QUSB2PHY_PORT_TEST1 ], - cfg->autoresume_en); +unsigned int reg = cfg->regs[QUSB2PHY_AUTORESUME_REG ]; + +qusb2_setbits (qphy->base, reg, cfg->regs[QUSB2PHY_AUTORESUME_BIT ]);/* Autoresume bit has to be toggled in order to enable it */ -qusb2_clrbits (qphy->base, cfg->regs[QUSB2PHY_PORT_TEST1 ], - cfg->autoresume_en); +qusb2_clrbits (qphy->base, reg, cfg->regs[QUSB2PHY_AUTORESUME_BIT ]); }if (!qphy->has_se_clk_scheme)
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v3 3/3] phy: qcom-qusb2: describe autoresume bit
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] phy: qcom-qusb2: unintended enablement of autoresume on shikra --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] phy: qcom-qusb2: unintended enablement of autoresume on shikra --
commit 6cea71c32d5d262ae5774576aa04ba1bbd3cb5de
Author: Dmitry Baryshkov <[email protected]>
phy: qcom-qusb2: describe autoresume bit
This patch updates the register definitions for the QUSB2 PHY autoresume bit, specifying which register to use for autoresume handling. It defines both TEST1 and TEST_CTRL registers and merges duplicate layouts.
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-qusb2.c +0
-0
[ ... ]
drivers/phy/qualcomm/phy-qcom-qusb2.c static const struct qusb2_phy_cfg sdm660_phy_cfg = { · line 380
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qusb2.c +0
-1@@ -379,7 +375,6 @@ static const struct qusb2_phy_cfg sdm660_phy_cfg = { .se_clk_scheme_default = false, .disable_ctrl = (CLAMP_N_EN | FREEZIO_N | POWER_DOWN), .mask_core_ready = PLL_LOCKED, - .autoresume_en = BIT(3), };static const struct qusb2_phy_cfg shikra_phy_cfg = {
[Severity: Medium]
Does this unintentionally enable autoresume on Shikra platforms?
Previously, shikra_phy_cfg omitted .autoresume_en, meaning it defaulted to 0. During runtime suspend, the bitwise operations in qusb2_phy_runtime_suspend() used a 0 mask, effectively not toggling any bits.
With this patch, omitting .autoresume_disable in shikra_phy_cfg defaults it to false. This causes qusb2_phy_runtime_suspend() to unconditionally enter its toggle logic and actively toggle BIT(3) at register 0xb8 (QUSB2PHY_PORT_TEST_CTRL) on Shikra.
Could this hardware state change cause undefined behavior? To preserve the previous behavior, should .autoresume_disable = true be added to shikra_phy_cfg?
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-qusb2.c +0
-1@@ -402,7 +397,6 @@ static const struct qusb2_phy_cfg sm6115_phy_cfg = { .se_clk_scheme_default = true, .disable_ctrl = (CLAMP_N_EN | FREEZIO_N | POWER_DOWN), .mask_core_ready = PLL_LOCKED, - .autoresume_en = BIT(3), };
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Re: [PATCH v3 3/3] phy: qcom-qusb2: describe autoresume bit
In reply to Dmitry BaryshkovQuoted 10 lines · Dmitry Baryshkov
There is a confusion regarding the autoresume bit. Some verions of the QUSB2 PHY have it in the TEST1 register, while on the others it is a part of the
TEST_CTRLregister. When adding support for autoresume bit, the code attempted to simplify the handling of those registers, putting both registers to the TEST1 layout entry. In the end,ipq6018_regs_layoutended up correctly definig TEST1 register at0x98(because platforms using that layout didn't use autoresume), whilemsm8996_regs_layoutusedTEST_CTRLoffset (0xb8) for the TEST1 layout entry.
Quoted 8 lines
Update the platform data to specify the register to be used for autoresume handling, define both TEST1 and
TEST_CTRLregisters and mergeipq6018_regs_layoutandmsm8996_regs_layoutwhich become identical afterwards.Fixes 891a96f65ac3 ("phy: qcom-qusb2: Add support for runtime PM")Signed-off-by Dmitry Baryshkov <[email protected]>---
GPT has a concern:
[P2] Preserve Shikra's autoresume behavior
shikra_phy_cfg uses msm8996_regs_layout but doesn't set autoresume_disable. This adds TEST_CTRL[3] to the shared layout, so runtime suspend will now toggle it for Shikra whenever the PHY mode is valid. Previously, its unset autoresume_en was zero, making these writes no-ops. Unless enabling autoresume on Shikra is intentional and verified, preserve the old behavior by disabling it for this configuration.
but I think that's fine since we *want* autoresume?
Konrad
Manivannan Sadhasivam
reviewerRe: [PATCH v3 3/3] phy: qcom-qusb2: describe autoresume bit
Quoted 24 lines · Konrad Dybcio
Quoted 10 lines · Dmitry Baryshkov
There is a confusion regarding the autoresume bit. Some verions of the QUSB2 PHY have it in the TEST1 register, while on the others it is a part of the
TEST_CTRLregister. When adding support for autoresume bit, the code attempted to simplify the handling of those registers, putting both registers to the TEST1 layout entry. In the end,ipq6018_regs_layoutended up correctly definig TEST1 register at0x98(because platforms using that layout didn't use autoresume), whilemsm8996_regs_layoutusedTEST_CTRLoffset (0xb8) for the TEST1 layout entry.Quoted 8 lines
Update the platform data to specify the register to be used for autoresume handling, define both TEST1 and
TEST_CTRLregisters and mergeipq6018_regs_layoutandmsm8996_regs_layoutwhich become identical afterwards.Fixes 891a96f65ac3 ("phy: qcom-qusb2: Add support for runtime PM")Signed-off-by Dmitry Baryshkov <[email protected]>---
GPT has a concern:
[P2] Preserve Shikra's autoresume behavior
Quoted 8 lines
shikra_phy_cfgusesmsm8996_regs_layoutbut doesn't setautoresume_disable. This adds TEST_CTRL[3] to the shared layout, so runtime suspend will now toggle it for Shikra whenever the PHY mode is valid. Previously, its unsetautoresume_enwas zero, making these writes no-ops. Unless enabling autoresume on Shikra is intentional and verified, preserve the old behavior by disabling it for this configuration.
Sashiko raised the same concern...
Quoted 2 lines
but I think that's fine since we *want* autoresume?
That should be fine, but this side effect should be mentioned in the commit message.
- Mani
Re: [PATCH v3 3/3] phy: qcom-qusb2: describe autoresume bit
In reply to Dmitry BaryshkovQuoted 10 lines · Dmitry Baryshkov
There is a confusion regarding the autoresume bit. Some verions of the QUSB2 PHY have it in the TEST1 register, while on the others it is a part of the
TEST_CTRLregister. When adding support for autoresume bit, the code attempted to simplify the handling of those registers, putting both registers to the TEST1 layout entry. In the end,ipq6018_regs_layoutended up correctly definig TEST1 register at0x98(because platforms using that layout didn't use autoresume), whilemsm8996_regs_layoutusedTEST_CTRLoffset (0xb8) for the TEST1 layout entry.
Quoted 7 lines
Update the platform data to specify the register to be used for autoresume handling, define both TEST1 and
TEST_CTRLregisters and mergeipq6018_regs_layoutandmsm8996_regs_layoutwhich become identical afterwards.Fixes 891a96f65ac3 ("phy: qcom-qusb2: Add support for runtime PM")Signed-off-by Dmitry Baryshkov <[email protected]>
With the commit message updated to mention the impact on Shikra:
- Mani