Add support for SA8255P in the qcom-qmp-usb phy driver
v5 cover Add support for SA8255P in the qcom-qmp-usb phy driver
The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The driver requests resources operations over SCMI using power protocols.
The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power on/off.
Power domain "core" controls the GDSC, resets, and TLMM (GPIOs) whereas power domain "transfer" controls clocks and interconnects.
Patch 1 adds the binding for sa8255p. Similarly to what has been done for I2C [1], this is a separate binding.
Patch 2 adds the driver change, which is based on a public vendor patch from qualcomm [2].
I did the following changes on top of that:
* Use devm_add_action_or_reset() for dev_pm_domain_detach_list() instead of implementing a driver .remove()
* Drop the .lanes struct member since it no longer exists.
* Re-order some functions
This has been tested on next-20260706 with a Ride4 SA8775P board that has SCMI firmware (which is compatible).
[1] https://lore.kernel.org/all/20260617-enable-i2c-on-sa8255p-v7-1-ad736dbeab57@oss.qualcomm.com/
[2] https://git.codelinaro.org/clo/le/meta-qti-auto-kernel/-/blob/LY.AU.0.1.0.r1-16800-gen4meta.0/recipes-kernel/linux/files/usb/0011-PENDING-phy-qcom-qmp-usb-Add-support-for-SA8255P.patch
---
Changes in v5:
- Move 'core' as first domain, before 'transfer' (Krzysztof)
- Reworded binding commit message to be more precise about the various
domains ('core', 'transfer' and 'perf') (Krzysztof)
- Dropped Krzysztof review due to the above binding changes
- Set .num_vregs=0 since regulators are managed by firmware
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
* bindings: Use additionalProperties: instead of unevaluatedProperties:
(Krzysztof)
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
* Binding changes:
* Use a separate binding file (Krzysztof)
* Remove 'usb_' prefix from power-domain-names (Krzysztof)
* Driver changes:
* Remove 'usb_' prefix from power-domain-names
* Moved sa8255p_usb3_uniphy_cfg before sa8775p_usb3_uniphy_cfg
* Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
* Driver changes:
* Fix comment typo tranfer -> transfer
* Fix print statement to add a missing '(' in the string
* Use dev_err_probe() in qmp_usb_domain_attach() to reduce log noise
* Fix pm_runtime_put_sync() order in qmp_usb_d0_to_d3 (Sashiko)
* Fix runtime PM reference leak on usb_transfer (Sashiko)
* Fix runtime PM reference leak on error in qmp_usb_init (Sashiko)
* Reorder qmp_usb_d0_to_d3() to mirror init ordering in qmp_usb_exit()
(Sashiko)
* Reorder qmp_usb_d0_to_d3() to mirror resume ordering in qmp_usb_runtime_suspend() (Sashiko)
* Fix error handling in qmp_usb_runtime_resume() (Sashiko)
* Link to v1: https://patch.msgid.link/[email protected]
---
Mattijs Korpershoek (1):
dt-bindings: phy: Add sa8255p USB PHY
Sriram Dash (1):
phy: qcom: qmp-usb: Add support for SA8255P
.../phy/qcom,sa8255p-qmp-usb3-uni-phy.yaml | 52 ++++++ drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 182 ++++++++++++++++++--- 2 files changed, 212 insertions(+), 22 deletions(-)
---
base-commit: 32b6ef9a5d0eca44f9cd91f52f4faa89f145a0de
change-id: 20260708-phy-qcom-qmp-usb-8255-9986907cdbc9
Best regards,
Signature · 1 line
Mattijs Korpershoek <[email protected]>
PATCH v5 1/2 dt-bindings: phy: Add sa8255p USB PHY
SA8255p platform abstracts resources such as resets, clocks and regulators in firmware. The SCMI firmware exposes multiple protocols to control such resources which are identified by protocol_id.
For this USB phy, 2 SCMI protocols are exposed by the firmware:
* power domain management protocol (protocol_id=0x11)
* performance domain management protocol (protocol_id=0x13)
The power domain has 2 indices: 'core' and 'transfer'.
* core controls the regulators, the clocks and the reset
* transfer only controls the clocks
For example, to power on/off the PHY, we should use the 'core' domain. To disable data transfer and keeping power enabled, we should use the 'transfer' domain.
Add a new binding for the for the Qualcomm QMP Super Speed (SS) UNI PHY found in SA8255P.
Note: the performance domain (0x13) exposes opaques values (0xa to 0x11) for which we don't have any information. Since it is not mandatory for the PHY to be functional, we have ommited it from the bindings. We can document it (and make them part of the dt ABI) once we have more information.
--- .../phy/qcom,sa8255p-qmp-usb3-uni-phy.yaml | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+)
Documentation/devicetree/bindings/phy/qcom,sa8255p-qmp-usb3-uni-phy.yaml new file +52 -0
@@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,sa8255p-qmp-usb3-uni-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm SA8255p QMP PHY controller + +maintainers: + - Mattijs Korpershoek <[email protected]> + +properties: + compatible: + const: qcom,sa8255p-qmp-usb3-uni-phy + + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + power-domains: + maxItems: 2 + + power-domain-names: + items: + - const: core + - const: transfer + +required: + - compatible + - reg + - "#phy-cells" + - power-domains + - power-domain-names + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + phy@88e8000 { + compatible = "qcom,sa8255p-qmp-usb3-uni-phy"; + reg = <0x0 0x088e8000 0x0 0x2000>; + #phy-cells = <0>; + power-domains = <&scmi12_pd 3>, <&scmi12_pd 2>; + power-domain-names = "core", "transfer"; + }; + };
Signature · 1 line
2.55.0
PATCH v5 2/2 phy: qcom: qmp-usb: Add support for SA8255P
In reply to Mattijs KorpershoekFrom: Sriram Dash <[email protected]>
The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The driver requests resources operations over SCMI using power protocols.
The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power on/off.
Power domain "core" controls the GDSC, resets, and TLMM (GPIOs) whereas power domain "transfer" controls clocks and interconnects.
In this variant, two disjoint sets of resources are modeled against the power domain suppliers which can be turned on/off to achieve modeled device states. Two modeled low power states d1 and d3 are supported.
transition: d0 <--> d3 :: both core and transfer suppliers
transition: d0 <--> d1 :: only transfer supplier
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 182 ++++++++++++++++++++++++++++---- 1 file changed, 160 insertions(+), 22 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +160 -22
@@ -15,6 +15,7 @@#include <linux/of_address.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> #include <linux/slab.h>
@@ -1411,6 +1412,9 @@ struct qmp_phy_cfg {/* Offset from PCS to PCS_USB region */ unsigned int pcs_usb_offset; + +/* true, if the device resources are fw managed */ +bool fw_managed; };struct qmp_usb {
@@ -1439,6 +1443,8 @@ struct qmp_usb {struct phy *phy;struct clk_fixed_rate pipe_clk_fixed; + +struct dev_pm_domain_list *pd_list; };static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val)
@@ -1633,6 +1639,25 @@ static const struct qmp_phy_cfg qdu1000_usb3_uniphy_cfg = { .has_pwrdn_delay = true, }; +static const struct qmp_phy_cfg sa8255p_usb3_uniphy_cfg = { + .offsets = &qmp_usb_offsets_v5, + + .serdes_tbl = sc8280xp_usb3_uniphy_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_serdes_tbl), + .tx_tbl = sc8280xp_usb3_uniphy_tx_tbl, + .tx_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_tx_tbl), + .rx_tbl = sc8280xp_usb3_uniphy_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_rx_tbl), + .pcs_tbl = sa8775p_usb3_uniphy_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (sa8775p_usb3_uniphy_pcs_tbl), + .pcs_usb_tbl = sa8775p_usb3_uniphy_pcs_usb_tbl, + .pcs_usb_tbl_num =ARRAY_SIZE (sa8775p_usb3_uniphy_pcs_usb_tbl), + .vreg_list =NULL , + .num_vregs =0 ,/* Regulators are handled by the firmware */ + .regs = qmp_v5_usb3phy_regs_layout, + .fw_managed = true, +}; +static const struct qmp_phy_cfg sa8775p_usb3_uniphy_cfg = { .offsets = &qmp_usb_offsets_v5,
@@ -1867,6 +1892,77 @@ static const struct qmp_phy_cfg glymur_usb3_uniphy_cfg = { .regs = qmp_v7_usb3phy_regs_layout, }; +static int qmp_usb_domain_attach (struct qmp_usb *qmp) +{ +struct dev_pm_domain_attach_data pd_data = { + .pd_flags =PD_FLAG_NO_DEV_LINK , + .pd_names = (const char *[]) {"core" ,"transfer" }, + .num_pd_names =2 , + }; +struct device *dev = qmp->dev; +int ret; + + ret =dev_pm_domain_attach_list (dev, &pd_data, &qmp->pd_list); +if (ret <0 ) +return dev_err_probe (dev, ret,"domain attach failed\n" ); + +return 0 ; +} + +static void qmp_usb_domain_detach (void *data) +{ +struct qmp_usb *qmp = data; + +dev_pm_domain_detach_list (qmp->pd_list); +} + +/* d3_to_d0 transition by turning on all the suppliers */ +static int qmp_usb_d3_to_d0 (struct qmp_usb *qmp) +{ +int ret; + +if (!qmp->pd_list) +return 0 ; + + ret =pm_runtime_resume_and_get (qmp->pd_list->pd_devs[0 ]); +if (ret) +return ret; + + ret =pm_runtime_resume_and_get (qmp->pd_list->pd_devs[1 ]); +if (ret) +pm_runtime_put_sync (qmp->pd_list->pd_devs[0 ]); + +return ret; +} + +/* d0_to_d3 transition by turning off all the suppliers */ +static void qmp_usb_d0_to_d3 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return ; + +pm_runtime_put_sync (qmp->pd_list->pd_devs[1 ]); +pm_runtime_put_sync (qmp->pd_list->pd_devs[0 ]); +} + +/* d1_to_d0 transition by turning on the 'transfer' supplier */ +static int qmp_usb_d1_to_d0 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return 0 ; + +return pm_runtime_resume_and_get (qmp->pd_list->pd_devs[1 ]); +} + +/* d0_to_d1 transition by turning off the 'transfer' supplier */ +static void qmp_usb_d0_to_d1 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return ; + +pm_runtime_put_sync (qmp->pd_list->pd_devs[1 ]); +} +static int qmp_usb_serdes_init (struct qmp_usb *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -1886,10 +1982,16 @@ static int qmp_usb_init(struct phy *phy)void __iomem *pcs = qmp->pcs;int ret; + ret =qmp_usb_d3_to_d0 (qmp); +if (ret <0 ) { +dev_err (qmp->dev,"Failed to transition to d0 state\n" ); +return ret; + } + ret =regulator_bulk_enable (cfg->num_vregs, qmp->vregs);if (ret) {dev_err (qmp->dev,"failed to enable regulators, err=%d\n" , ret); -return ret; + goto err_transition_to_d3; } ret =reset_control_bulk_assert (qmp->num_resets, qmp->resets);
@@ -1916,6 +2018,8 @@ static int qmp_usb_init(struct phy *phy)reset_control_bulk_assert (qmp->num_resets, qmp->resets); err_disable_regulators:regulator_bulk_disable (cfg->num_vregs, qmp->vregs); +err_transition_to_d3: +qmp_usb_d0_to_d3 (qmp);return ret; }
@@ -1931,6 +2035,8 @@ static int qmp_usb_exit(struct phy *phy)regulator_bulk_disable (cfg->num_vregs, qmp->vregs); +qmp_usb_d0_to_d3 (qmp); +return 0 ; }
@@ -2119,6 +2225,8 @@ static int __maybe_unused qmp_usb_runtime_suspend(struct device *dev)clk_disable_unprepare (qmp->pipe_clk);clk_bulk_disable_unprepare (qmp->num_clks, qmp->clks); +qmp_usb_d0_to_d1 (qmp); +return 0 ; }
@@ -2134,14 +2242,23 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev)return 0 ; } + ret =qmp_usb_d1_to_d0 (qmp); +if (ret <0 ) { +dev_err (qmp->dev,"Failed to transition to d0 state\n" ); +return ret; + } + ret =clk_bulk_prepare_enable (qmp->num_clks, qmp->clks); -if (ret) +if (ret) { +qmp_usb_d0_to_d1 (qmp);return ret; + } ret =clk_prepare_enable (qmp->pipe_clk);if (ret) {dev_err (dev,"pipe_clk enable failed, err=%d\n" , ret);clk_bulk_disable_unprepare (qmp->num_clks, qmp->clks); +qmp_usb_d0_to_d1 (qmp);return ret; }
@@ -2321,10 +2438,12 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) qmp->pcs_misc =NULL ; } - qmp->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); -if (IS_ERR (qmp->pipe_clk)) { -return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), -"failed to get pipe clock\n" ); +if (!qmp->cfg->fw_managed) { + qmp->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); + } } ret =devm_clk_bulk_get_all (qmp->dev, &qmp->clks);
@@ -2333,10 +2452,12 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) qmp->num_clks = ret; - ret =qmp_usb_reset_init (qmp, usb3phy_legacy_reset_l, -ARRAY_SIZE (usb3phy_legacy_reset_l)); -if (ret) -return ret; +if (!qmp->cfg->fw_managed) { + ret =qmp_usb_reset_init (qmp, usb3phy_legacy_reset_l, +ARRAY_SIZE (usb3phy_legacy_reset_l)); +if (ret) +return ret; + }return 0 ; }
@@ -2370,17 +2491,19 @@ static int qmp_usb_parse_dt(struct qmp_usb *qmp)if (ret)return ret; - qmp->pipe_clk =devm_clk_get (dev,"pipe" ); -if (IS_ERR (qmp->pipe_clk)) { -return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), -"failed to get pipe clock\n" ); +if (!qmp->cfg->fw_managed) { + qmp->pipe_clk =devm_clk_get (dev,"pipe" ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); + } + + ret =qmp_usb_reset_init (qmp, usb3phy_reset_l, +ARRAY_SIZE (usb3phy_reset_l)); +if (ret) +return ret; } - ret =qmp_usb_reset_init (qmp, usb3phy_reset_l, -ARRAY_SIZE (usb3phy_reset_l)); -if (ret) -return ret; -return 0 ; }
@@ -2403,6 +2526,16 @@ static int qmp_usb_probe(struct platform_device *pdev)if (!qmp->cfg)return -EINVAL ; +if (qmp->cfg->fw_managed) { + ret =qmp_usb_domain_attach (qmp); +if (ret) +return ret; + + ret =devm_add_action_or_reset (dev, qmp_usb_domain_detach, qmp); +if (ret) +return ret; + } + ret =devm_regulator_bulk_get_const (dev, qmp->cfg->num_vregs, qmp->cfg->vreg_list, &qmp->vregs);if (ret)
@@ -2435,9 +2568,11 @@ static int qmp_usb_probe(struct platform_device *pdev)*/ pm_runtime_forbid (dev); - ret =phy_pipe_clk_register (qmp, np); -if (ret) - goto err_pm_put; +if (!qmp->cfg->fw_managed) { + ret =phy_pipe_clk_register (qmp, np); +if (ret) + goto err_pm_put; + } qmp->phy =devm_phy_create (dev, np, &qmp_usb_phy_ops);if (IS_ERR (qmp->phy)) {
@@ -2492,6 +2627,9 @@ static const struct of_device_id qmp_usb_of_match_table[] = { }, { .compatible = "qcom,qdu1000-qmp-usb3-uni-phy", .data = &qdu1000_usb3_uniphy_cfg, + }, { + .compatible = "qcom,sa8255p-qmp-usb3-uni-phy", + .data = &sa8255p_usb3_uniphy_cfg, }, { .compatible = "qcom,sa8775p-qmp-usb3-uni-phy", .data = &sa8775p_usb3_uniphy_cfg,
Signature · 1 line
2.55.0
Re: [PATCH v5 1/2] dt-bindings: phy: Add sa8255p USB PHY
In reply to Mattijs KorpershoekQuoted 25 lines · Mattijs Korpershoek
SA8255p platform abstracts resources such as resets, clocks and regulators in firmware. The SCMI firmware exposes multiple protocols to control such resources which are identified by
protocol_id.For this USB phy, 2 SCMI protocols are exposed by the firmware:
* power domain management protocol (protocol_id=0x11)
* performance domain management protocol (protocol_id=0x13)The power domain has 2 indices: 'core' and 'transfer'.
* core controls the regulators, the clocks and the reset
* transfer only controls the clocksFor example, to power on/off the PHY, we should use the 'core' domain. To disable data transfer and keeping power enabled, we should use the 'transfer' domain.
Add a new binding for the for the Qualcomm QMP Super Speed (SS) UNI PHY found in SA8255P.
Note: the performance domain (
0x13) exposes opaques values (0xato0x11) for which we don't have any information. Since it is not mandatory for the PHY to be functional, we have ommited it from the bindings. We can document it (and make them part of the dt ABI) once we have more information.
Quoted 4 lines
Signed-off-by Mattijs Korpershoek <[email protected]>--- .../phy/qcom,sa8255p-qmp-usb3-uni-phy.yaml | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+)
Best regards,
Krzysztof
Re: [PATCH v5 2/2] phy: qcom: qmp-usb: Add support for SA8255P
In reply to Mattijs KorpershoekQuoted 329 lines · Mattijs Korpershoek
From: Sriram Dash <[email protected]>
The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The driver requests resources operations over SCMI using power protocols.
The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power on/off.
Power domain "core" controls the GDSC, resets, and TLMM (GPIOs) whereas power domain "transfer" controls clocks and interconnects.
In this variant, two disjoint sets of resources are modeled against the power domain suppliers which can be turned on/off to achieve modeled device states. Two modeled low power states d1 and d3 are supported.
transition: d0 <--> d3 :: both core and transfer suppliers
transition: d0 <--> d1 :: only transfer supplierSigned-off-by Sriram Dash <[email protected]>Signed-off-by Shazad Hussain <[email protected]>Signed-off-by Mattijs Korpershoek <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 182 ++++++++++++++++++++++++++++---- 1 file changed, 160 insertions(+), 22 deletions(-)drivers/phy/qualcomm/phy-qcom-qmp-usb.c +157
-22@@ -15,6 +15,7 @@#include <linux/of_address.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> #include <linux/slab.h> @@ -1411,6 +1412,9 @@ struct qmp_phy_cfg {/* Offset from PCS to PCS_USB region */ unsigned int pcs_usb_offset; + +/* true, if the device resources are fw managed */ +bool fw_managed; };struct qmp_usb {@@ -1439,6 +1443,8 @@ struct qmp_usb {struct phy *phy;struct clk_fixed_rate pipe_clk_fixed; + +struct dev_pm_domain_list *pd_list; };static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val)@@ -1633,6 +1639,25 @@ static const struct qmp_phy_cfg qdu1000_usb3_uniphy_cfg = { .has_pwrdn_delay = true, }; +static const struct qmp_phy_cfg sa8255p_usb3_uniphy_cfg = { + .offsets = &qmp_usb_offsets_v5, + + .serdes_tbl = sc8280xp_usb3_uniphy_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_serdes_tbl), + .tx_tbl = sc8280xp_usb3_uniphy_tx_tbl, + .tx_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_tx_tbl), + .rx_tbl = sc8280xp_usb3_uniphy_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (sc8280xp_usb3_uniphy_rx_tbl), + .pcs_tbl = sa8775p_usb3_uniphy_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (sa8775p_usb3_uniphy_pcs_tbl), + .pcs_usb_tbl = sa8775p_usb3_uniphy_pcs_usb_tbl, + .pcs_usb_tbl_num =ARRAY_SIZE (sa8775p_usb3_uniphy_pcs_usb_tbl), + .vreg_list =NULL , + .num_vregs =0 ,/* Regulators are handled by the firmware */ + .regs = qmp_v5_usb3phy_regs_layout, + .fw_managed = true, +}; +static const struct qmp_phy_cfg sa8775p_usb3_uniphy_cfg = { .offsets = &qmp_usb_offsets_v5,@@ -1867,6 +1892,77 @@ static const struct qmp_phy_cfg glymur_usb3_uniphy_cfg = { .regs = qmp_v7_usb3phy_regs_layout, }; +static int qmp_usb_domain_attach (struct qmp_usb *qmp) +{ +struct dev_pm_domain_attach_data pd_data = { + .pd_flags =PD_FLAG_NO_DEV_LINK , + .pd_names = (const char *[]) {"core" ,"transfer" }, + .num_pd_names =2 , + }; +struct device *dev = qmp->dev; +int ret; + + ret =dev_pm_domain_attach_list (dev, &pd_data, &qmp->pd_list); +if (ret <0 ) +return dev_err_probe (dev, ret,"domain attach failed\n" ); + +return 0 ; +} + +static void qmp_usb_domain_detach (void *data) +{ +struct qmp_usb *qmp = data; + +dev_pm_domain_detach_list (qmp->pd_list); +} + +/* d3_to_d0 transition by turning on all the suppliers */ +static int qmp_usb_d3_to_d0 (struct qmp_usb *qmp) +{ +int ret; + +if (!qmp->pd_list) +return 0 ; + + ret =pm_runtime_resume_and_get (qmp->pd_list->pd_devs[0 ]); +if (ret) +return ret; + + ret =pm_runtime_resume_and_get (qmp->pd_list->pd_devs[1 ]); +if (ret) +pm_runtime_put_sync (qmp->pd_list->pd_devs[0 ]); + +return ret; +} + +/* d0_to_d3 transition by turning off all the suppliers */ +static void qmp_usb_d0_to_d3 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return ; + +pm_runtime_put_sync (qmp->pd_list->pd_devs[1 ]); +pm_runtime_put_sync (qmp->pd_list->pd_devs[0 ]); +} + +/* d1_to_d0 transition by turning on the 'transfer' supplier */ +static int qmp_usb_d1_to_d0 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return 0 ; + +return pm_runtime_resume_and_get (qmp->pd_list->pd_devs[1 ]); +} + +/* d0_to_d1 transition by turning off the 'transfer' supplier */ +static void qmp_usb_d0_to_d1 (struct qmp_usb *qmp) +{ +if (!qmp->pd_list) +return ; + +pm_runtime_put_sync (qmp->pd_list->pd_devs[1 ]); +} +static int qmp_usb_serdes_init (struct qmp_usb *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;@@ -1886,10 +1982,16 @@ static int qmp_usb_init(struct phy *phy)void __iomem *pcs = qmp->pcs;int ret; + ret =qmp_usb_d3_to_d0 (qmp); +if (ret <0 ) { +dev_err (qmp->dev,"Failed to transition to d0 state\n" ); +return ret; + } + ret =regulator_bulk_enable (cfg->num_vregs, qmp->vregs);if (ret) {dev_err (qmp->dev,"failed to enable regulators, err=%d\n" , ret); -return ret; + goto err_transition_to_d3; } ret =reset_control_bulk_assert (qmp->num_resets, qmp->resets);@@ -1916,6 +2018,8 @@ static int qmp_usb_init(struct phy *phy)reset_control_bulk_assert (qmp->num_resets, qmp->resets); err_disable_regulators:regulator_bulk_disable (cfg->num_vregs, qmp->vregs); +err_transition_to_d3: +qmp_usb_d0_to_d3 (qmp);return ret; }@@ -1931,6 +2035,8 @@ static int qmp_usb_exit(struct phy *phy)regulator_bulk_disable (cfg->num_vregs, qmp->vregs); +qmp_usb_d0_to_d3 (qmp); +return 0 ; }@@ -2119,6 +2225,8 @@ static int __maybe_unused qmp_usb_runtime_suspend(struct device *dev)clk_disable_unprepare (qmp->pipe_clk);clk_bulk_disable_unprepare (qmp->num_clks, qmp->clks); +qmp_usb_d0_to_d1 (qmp); +return 0 ; }@@ -2134,14 +2242,23 @@ static int __maybe_unused qmp_usb_runtime_resume(struct device *dev)return 0 ; } + ret =qmp_usb_d1_to_d0 (qmp); +if (ret <0 ) { +dev_err (qmp->dev,"Failed to transition to d0 state\n" ); +return ret; + } + ret =clk_bulk_prepare_enable (qmp->num_clks, qmp->clks); -if (ret) +if (ret) { +qmp_usb_d0_to_d1 (qmp);return ret; + } ret =clk_prepare_enable (qmp->pipe_clk);if (ret) {dev_err (dev,"pipe_clk enable failed, err=%d\n" , ret);clk_bulk_disable_unprepare (qmp->num_clks, qmp->clks); +qmp_usb_d0_to_d1 (qmp);return ret; }@@ -2321,10 +2438,12 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) qmp->pcs_misc =NULL ; } - qmp->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); -if (IS_ERR (qmp->pipe_clk)) { -return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), -"failed to get pipe clock\n" ); +if (!qmp->cfg->fw_managed) { + qmp->pipe_clk =devm_get_clk_from_child (dev, np,NULL ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); + } } ret =devm_clk_bulk_get_all (qmp->dev, &qmp->clks);@@ -2333,10 +2452,12 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) qmp->num_clks = ret; - ret =qmp_usb_reset_init (qmp, usb3phy_legacy_reset_l, -ARRAY_SIZE (usb3phy_legacy_reset_l)); -if (ret) -return ret; +if (!qmp->cfg->fw_managed) { + ret =qmp_usb_reset_init (qmp, usb3phy_legacy_reset_l, +ARRAY_SIZE (usb3phy_legacy_reset_l)); +if (ret) +return ret; + }return 0 ; }@@ -2370,17 +2491,19 @@ static int qmp_usb_parse_dt(struct qmp_usb *qmp)if (ret)return ret; - qmp->pipe_clk =devm_clk_get (dev,"pipe" ); -if (IS_ERR (qmp->pipe_clk)) { -return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), -"failed to get pipe clock\n" ); +if (!qmp->cfg->fw_managed) { + qmp->pipe_clk =devm_clk_get (dev,"pipe" ); +if (IS_ERR (qmp->pipe_clk)) { +return dev_err_probe (dev,PTR_ERR (qmp->pipe_clk), +"failed to get pipe clock\n" ); + } + + ret =qmp_usb_reset_init (qmp, usb3phy_reset_l, +ARRAY_SIZE (usb3phy_reset_l)); +if (ret) +return ret; } - ret =qmp_usb_reset_init (qmp, usb3phy_reset_l, -ARRAY_SIZE (usb3phy_reset_l)); -if (ret) -return ret; -return 0 ; }@@ -2403,6 +2526,16 @@ static int qmp_usb_probe(struct platform_device *pdev)if (!qmp->cfg)return -EINVAL ; +if (qmp->cfg->fw_managed) { + ret =qmp_usb_domain_attach (qmp); +if (ret) +return ret; + + ret =devm_add_action_or_reset (dev, qmp_usb_domain_detach, qmp); +if (ret) +return ret; + } + ret =devm_regulator_bulk_get_const (dev, qmp->cfg->num_vregs, qmp->cfg->vreg_list, &qmp->vregs);if (ret)@@ -2435,9 +2568,11 @@ static int qmp_usb_probe(struct platform_device *pdev)*/ pm_runtime_forbid (dev); - ret =phy_pipe_clk_register (qmp, np); -if (ret) - goto err_pm_put; +if (!qmp->cfg->fw_managed) { + ret =phy_pipe_clk_register (qmp, np); +if (ret) + goto err_pm_put; + } qmp->phy =devm_phy_create (dev, np, &qmp_usb_phy_ops);if (IS_ERR (qmp->phy)) {
drivers/phy/qualcomm/phy-qcom-qmp-usb.c static const struct of_device_id qmp_usb_of_match_table[] = { · line 2635
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +3
-0@@ -2492,6 +2627,9 @@ static const struct of_device_id qmp_usb_of_match_table[] = { }, { .compatible = "qcom,qdu1000-qmp-usb3-uni-phy", .data = &qdu1000_usb3_uniphy_cfg, + }, { + .compatible = "qcom,sa8255p-qmp-usb3-uni-phy", + .data = &sa8255p_usb3_uniphy_cfg, }, { .compatible = "qcom,sa8775p-qmp-usb3-uni-phy", .data = &sa8775p_usb3_uniphy_cfg,
Thanks,
Neil