Extend qmp_usbc_offsets and qmp_phy_cfg with DP-specific fields,
including register offsets, init tables, and callback hooks. Also
update qmp_usbc struct to track DP-related resources and state.
This enables support for USB/DP switchable Type-C PHYs that operate
in either mode.
Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
---
drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 73 ++++++++++++++++++++++++--------
1 file changed, 55 insertions(+), 18 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
index 5afe090b546977a11265bbffa7c355feb8c72dfa..6b0e86ec43ded3d850f68f248a74c39f74ecb5bb 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
@@ -298,14 +298,19 @@ struct qmp_usbc_offsets {
/* for PHYs with >= 2 lanes */
u16 tx2;
u16 rx2;
+
+ u16 dp_serdes;
+ u16 dp_txa;
+ u16 dp_txb;
+ u16 dp_dp_phy;
};
-/* struct qmp_phy_cfg - per-PHY initialization config */
+struct qmp_usbc;
struct qmp_phy_cfg {
const struct qmp_usbc_offsets *offsets;
const enum qmp_phy_usbc_type type;
- /* Init sequence for PHY blocks - serdes, tx, rx, pcs */
+ /* Init sequence for USB PHY blocks - serdes, tx, rx, pcs */
const struct qmp_phy_init_tbl *serdes_tbl;
int serdes_tbl_num;
const struct qmp_phy_init_tbl *tx_tbl;
@@ -315,6 +320,27 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *pcs_tbl;
int pcs_tbl_num;
+ /* Init sequence for DP PHY blocks - serdes, tx, rbr, hbr, hbr2 */
+ const struct qmp_phy_init_tbl *dp_serdes_tbl;
+ int dp_serdes_tbl_num;
+ const struct qmp_phy_init_tbl *dp_tx_tbl;
+ int dp_tx_tbl_num;
+ const struct qmp_phy_init_tbl *serdes_tbl_rbr;
+ int serdes_tbl_rbr_num;
+ const struct qmp_phy_init_tbl *serdes_tbl_hbr;
+ int serdes_tbl_hbr_num;
+ const struct qmp_phy_init_tbl *serdes_tbl_hbr2;
+ int serdes_tbl_hbr2_num;
+
+ const u8 (*swing_tbl)[4][4];
+ const u8 (*pre_emphasis_tbl)[4][4];
+
+ /* DP PHY callbacks */
+ void (*dp_aux_init)(struct qmp_usbc *qmp);
+ void (*configure_dp_tx)(struct qmp_usbc *qmp);
+ int (*configure_dp_phy)(struct qmp_usbc *qmp);
+ int (*calibrate_dp_phy)(struct qmp_usbc *qmp);
+
/* regulators to be requested */
const char * const *vreg_list;
int num_vregs;
@@ -335,25 +361,36 @@ struct qmp_usbc {
void __iomem *rx;
void __iomem *tx2;
void __iomem *rx2;
-
- struct regmap *tcsr_map;
- u32 vls_clamp_reg;
+ void __iomem *dp_dp_phy;
+ void __iomem *dp_tx;
+ void __iomem *dp_tx2;
+ void __iomem *dp_serdes;
struct clk *pipe_clk;
+ struct clk_fixed_rate pipe_clk_fixed;
+
+ struct clk_hw dp_link_hw;
+ struct clk_hw dp_pixel_hw;
struct clk_bulk_data *clks;
int num_clks;
int num_resets;
struct reset_control_bulk_data *resets;
struct regulator_bulk_data *vregs;
+ struct regmap *tcsr_map;
+ u32 vls_clamp_reg;
+ u32 dp_phy_mode_reg;
+
struct mutex phy_mutex;
+ struct phy *usb_phy;
enum phy_mode mode;
unsigned int usb_init_count;
- struct phy *phy;
-
- struct clk_fixed_rate pipe_clk_fixed;
+ struct phy *dp_phy;
+ unsigned int dp_aux_cfg;
+ struct phy_configure_opts_dp dp_opts;
+ unsigned int dp_init_count;
struct typec_switch_dev *sw;
enum typec_orientation orientation;
@@ -699,7 +736,7 @@ static int __maybe_unused qmp_usbc_runtime_suspend(struct device *dev)
dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode);
- if (!qmp->phy->init_count) {
+ if (!qmp->usb_init_count && !qmp->dp_init_count) {
dev_vdbg(dev, "PHY not initialized, bailing out\n");
return 0;
}
@@ -719,7 +756,7 @@ static int __maybe_unused qmp_usbc_runtime_resume(struct device *dev)
dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode);
- if (!qmp->phy->init_count) {
+ if (!qmp->usb_init_count && !qmp->dp_init_count) {
dev_vdbg(dev, "PHY not initialized, bailing out\n");
return 0;
}
@@ -874,11 +911,11 @@ static int qmp_usbc_typec_switch_set(struct typec_switch_dev *sw,
qmp->orientation = orientation;
if (qmp->usb_init_count) {
- qmp_usbc_usb_power_off(qmp->phy);
- qmp_usbc_com_exit(qmp->phy);
+ qmp_usbc_usb_power_off(qmp->usb_phy);
+ qmp_usbc_com_exit(qmp->usb_phy);
- qmp_usbc_com_init(qmp->phy);
- qmp_usbc_usb_power_on(qmp->phy);
+ qmp_usbc_com_init(qmp->usb_phy);
+ qmp_usbc_usb_power_on(qmp->usb_phy);
}
mutex_unlock(&qmp->phy_mutex);
@@ -1106,14 +1143,14 @@ static int qmp_usbc_probe(struct platform_device *pdev)
if (ret)
goto err_node_put;
- qmp->phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
- if (IS_ERR(qmp->phy)) {
- ret = PTR_ERR(qmp->phy);
+ qmp->usb_phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
+ if (IS_ERR(qmp->usb_phy)) {
+ ret = PTR_ERR(qmp->usb_phy);
dev_err(dev, "failed to create PHY: %d\n", ret);
goto err_node_put;
}
- phy_set_drvdata(qmp->phy, qmp);
+ phy_set_drvdata(qmp->usb_phy, qmp);
of_node_put(np);
--
2.34.1
On Wed, Aug 20, 2025 at 05:34:47PM +0800, Xiangxu Yin wrote:
> Extend qmp_usbc_offsets and qmp_phy_cfg with DP-specific fields,
> including register offsets, init tables, and callback hooks. Also
> update qmp_usbc struct to track DP-related resources and state.
> This enables support for USB/DP switchable Type-C PHYs that operate
> in either mode.
>
> Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
> ---
> drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 73 ++++++++++++++++++++++++--------
> 1 file changed, 55 insertions(+), 18 deletions(-)
>
>
> + struct regmap *tcsr_map;
> + u32 vls_clamp_reg;
> + u32 dp_phy_mode_reg;
> +
> struct mutex phy_mutex;
>
> + struct phy *usb_phy;
Should be a part of the previous patch.
> enum phy_mode mode;
> unsigned int usb_init_count;
>
> - struct phy *phy;
Similarly.
> -
> - struct clk_fixed_rate pipe_clk_fixed;
> + struct phy *dp_phy;
> + unsigned int dp_aux_cfg;
> + struct phy_configure_opts_dp dp_opts;
> + unsigned int dp_init_count;
>
> struct typec_switch_dev *sw;
> enum typec_orientation orientation;
> @@ -874,11 +911,11 @@ static int qmp_usbc_typec_switch_set(struct typec_switch_dev *sw,
> qmp->orientation = orientation;
>
> if (qmp->usb_init_count) {
> - qmp_usbc_usb_power_off(qmp->phy);
> - qmp_usbc_com_exit(qmp->phy);
> + qmp_usbc_usb_power_off(qmp->usb_phy);
> + qmp_usbc_com_exit(qmp->usb_phy);
>
> - qmp_usbc_com_init(qmp->phy);
> - qmp_usbc_usb_power_on(qmp->phy);
> + qmp_usbc_com_init(qmp->usb_phy);
> + qmp_usbc_usb_power_on(qmp->usb_phy);
and these.
> }
>
> mutex_unlock(&qmp->phy_mutex);
> @@ -1106,14 +1143,14 @@ static int qmp_usbc_probe(struct platform_device *pdev)
> if (ret)
> goto err_node_put;
>
> - qmp->phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
> - if (IS_ERR(qmp->phy)) {
> - ret = PTR_ERR(qmp->phy);
> + qmp->usb_phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
> + if (IS_ERR(qmp->usb_phy)) {
> + ret = PTR_ERR(qmp->usb_phy);
> dev_err(dev, "failed to create PHY: %d\n", ret);
> goto err_node_put;
> }
>
> - phy_set_drvdata(qmp->phy, qmp);
> + phy_set_drvdata(qmp->usb_phy, qmp);
>
> of_node_put(np);
>
>
> --
> 2.34.1
>
--
With best wishes
Dmitry
On 8/20/2025 7:47 PM, Dmitry Baryshkov wrote:
> On Wed, Aug 20, 2025 at 05:34:47PM +0800, Xiangxu Yin wrote:
>> Extend qmp_usbc_offsets and qmp_phy_cfg with DP-specific fields,
>> including register offsets, init tables, and callback hooks. Also
>> update qmp_usbc struct to track DP-related resources and state.
>> This enables support for USB/DP switchable Type-C PHYs that operate
>> in either mode.
>>
>> Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
>> ---
>> drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 73 ++++++++++++++++++++++++--------
>> 1 file changed, 55 insertions(+), 18 deletions(-)
>>
>>
>> + struct regmap *tcsr_map;
>> + u32 vls_clamp_reg;
>> + u32 dp_phy_mode_reg;
>> +
>> struct mutex phy_mutex;
>>
>> + struct phy *usb_phy;
> Should be a part of the previous patch.
Ok, will move usb_phy rename to patch 'Rename USB-specific ops',
then shall I need drop the |Reviewed-by| tag in that patch since it will change?
>> enum phy_mode mode;
>> unsigned int usb_init_count;
>>
>> - struct phy *phy;
> Similarly.
Ack.
>> -
>> - struct clk_fixed_rate pipe_clk_fixed;
>> + struct phy *dp_phy;
>> + unsigned int dp_aux_cfg;
>> + struct phy_configure_opts_dp dp_opts;
>> + unsigned int dp_init_count;
>>
>> struct typec_switch_dev *sw;
>> enum typec_orientation orientation;
>> @@ -874,11 +911,11 @@ static int qmp_usbc_typec_switch_set(struct typec_switch_dev *sw,
>> qmp->orientation = orientation;
>>
>> if (qmp->usb_init_count) {
>> - qmp_usbc_usb_power_off(qmp->phy);
>> - qmp_usbc_com_exit(qmp->phy);
>> + qmp_usbc_usb_power_off(qmp->usb_phy);
>> + qmp_usbc_com_exit(qmp->usb_phy);
>>
>> - qmp_usbc_com_init(qmp->phy);
>> - qmp_usbc_usb_power_on(qmp->phy);
>> + qmp_usbc_com_init(qmp->usb_phy);
>> + qmp_usbc_usb_power_on(qmp->usb_phy);
> and these.
Ack.
>> }
>>
>> mutex_unlock(&qmp->phy_mutex);
>> @@ -1106,14 +1143,14 @@ static int qmp_usbc_probe(struct platform_device *pdev)
>> if (ret)
>> goto err_node_put;
>>
>> - qmp->phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
>> - if (IS_ERR(qmp->phy)) {
>> - ret = PTR_ERR(qmp->phy);
>> + qmp->usb_phy = devm_phy_create(dev, np, &qmp_usbc_usb_phy_ops);
>> + if (IS_ERR(qmp->usb_phy)) {
>> + ret = PTR_ERR(qmp->usb_phy);
>> dev_err(dev, "failed to create PHY: %d\n", ret);
>> goto err_node_put;
>> }
>>
>> - phy_set_drvdata(qmp->phy, qmp);
>> + phy_set_drvdata(qmp->usb_phy, qmp);
>>
>> of_node_put(np);
>>
>>
>> --
>> 2.34.1
>>
On 22/08/2025 09:59, Xiangxu Yin wrote: > > On 8/20/2025 7:47 PM, Dmitry Baryshkov wrote: >> On Wed, Aug 20, 2025 at 05:34:47PM +0800, Xiangxu Yin wrote: >>> Extend qmp_usbc_offsets and qmp_phy_cfg with DP-specific fields, >>> including register offsets, init tables, and callback hooks. Also >>> update qmp_usbc struct to track DP-related resources and state. >>> This enables support for USB/DP switchable Type-C PHYs that operate >>> in either mode. >>> >>> Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com> >>> --- >>> drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 73 ++++++++++++++++++++++++-------- >>> 1 file changed, 55 insertions(+), 18 deletions(-) >>> >>> >>> + struct regmap *tcsr_map; >>> + u32 vls_clamp_reg; >>> + u32 dp_phy_mode_reg; >>> + >>> struct mutex phy_mutex; >>> >>> + struct phy *usb_phy; >> Should be a part of the previous patch. > > > Ok, will move usb_phy rename to patch 'Rename USB-specific ops', > > then shall I need drop the |Reviewed-by| tag in that patch since it will change? Depends on the amount of changes. -- With best wishes Dmitry
© 2016 - 2026 Red Hat, Inc.