diff mbox series

[12/14] phy: qcom-qmp-combo: rename common-register pointers

Message ID 20221111092457.10546-13-johan+linaro@kernel.org
State Superseded
Headers show
Series phy: qcom-qmp-combo: fix sc8280xp binding (set 3/3) | expand

Commit Message

Johan Hovold Nov. 11, 2022, 9:24 a.m. UTC
The common registers are shared by the USB and DP parts of the PHY so
drop the misleading "dp" prefix from the corresponding pointers.

Note that the "DP" prefix could also be dropped from the corresponding
defines, but leave that in place for now.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 24 +++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Dmitry Baryshkov Nov. 12, 2022, 11:31 a.m. UTC | #1
On 11/11/2022 12:24, Johan Hovold wrote:
> The common registers are shared by the USB and DP parts of the PHY so
> drop the misleading "dp" prefix from the corresponding pointers.
> 
> Note that the "DP" prefix could also be dropped from the corresponding
> defines, but leave that in place for now.
> 
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>   drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 24 +++++++++++------------
>   1 file changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Note regarding the last phrase: I'd suggest leaving the DP prefix in 
register names, it makes it easier to visually note & verify the 
register block.
Johan Hovold Nov. 14, 2022, 12:54 p.m. UTC | #2
On Sat, Nov 12, 2022 at 02:31:27PM +0300, Dmitry Baryshkov wrote:
> On 11/11/2022 12:24, Johan Hovold wrote:
> > The common registers are shared by the USB and DP parts of the PHY so
> > drop the misleading "dp" prefix from the corresponding pointers.
> > 
> > Note that the "DP" prefix could also be dropped from the corresponding
> > defines, but leave that in place for now.
> > 
> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> > ---
> >   drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 24 +++++++++++------------
> >   1 file changed, 12 insertions(+), 12 deletions(-)
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> Note regarding the last phrase: I'd suggest leaving the DP prefix in 
> register names, it makes it easier to visually note & verify the 
> register block.

My point is that "DP" was never part of the COM register block name. The
confusion likely comes from the vendor driver naming these defines along
the lines of

	USB3_DP_COM_POWER_DOWN_CTRL

Here "USB3_DP" is the common prefix for all defines that apply to both
"parts" of the PHY so the corresponding Linux define

	QPHY_V3_DP_COM_POWER_DOWN_CTRL

should either include "USB3" or drop "DP".

This becomes more apparent on SC8280XP where the corresponding define
is:

	USB43DP_COM_POWER_DOWN_CTRL

Johan
Dmitry Baryshkov Nov. 14, 2022, 3:38 p.m. UTC | #3
On 14/11/2022 15:54, Johan Hovold wrote:
> On Sat, Nov 12, 2022 at 02:31:27PM +0300, Dmitry Baryshkov wrote:
>> On 11/11/2022 12:24, Johan Hovold wrote:
>>> The common registers are shared by the USB and DP parts of the PHY so
>>> drop the misleading "dp" prefix from the corresponding pointers.
>>>
>>> Note that the "DP" prefix could also be dropped from the corresponding
>>> defines, but leave that in place for now.
>>>
>>> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
>>> ---
>>>    drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 24 +++++++++++------------
>>>    1 file changed, 12 insertions(+), 12 deletions(-)
>>
>> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>
>> Note regarding the last phrase: I'd suggest leaving the DP prefix in
>> register names, it makes it easier to visually note & verify the
>> register block.
> 
> My point is that "DP" was never part of the COM register block name. The
> confusion likely comes from the vendor driver naming these defines along
> the lines of
> 
> 	USB3_DP_COM_POWER_DOWN_CTRL
> 
> Here "USB3_DP" is the common prefix for all defines that apply to both
> "parts" of the PHY so the corresponding Linux define
> 
> 	QPHY_V3_DP_COM_POWER_DOWN_CTRL
> 
> should either include "USB3" or drop "DP".

My thought was that we already have too many _COM_ defines in the qmp 
headers. Having QPHY_Vn_COM_something would make it too easy to mix it 
with QSERDES_Vn_COM_foo. Thus I'd vote to leave DP_COM prefix in place. 
While it might be not fully accurate, it serves the point of identifying 
the register block.

> 
> This becomes more apparent on SC8280XP where the corresponding define
> is:
> 
> 	USB43DP_COM_POWER_DOWN_CTRL

I'd still use something like QPHY_V10_DP_COM_POWER_DOWN_CTRL here.

> 
> Johan
Johan Hovold Nov. 14, 2022, 3:51 p.m. UTC | #4
On Mon, Nov 14, 2022 at 06:38:36PM +0300, Dmitry Baryshkov wrote:
> On 14/11/2022 15:54, Johan Hovold wrote:
> > On Sat, Nov 12, 2022 at 02:31:27PM +0300, Dmitry Baryshkov wrote:
> >> On 11/11/2022 12:24, Johan Hovold wrote:
> >>> The common registers are shared by the USB and DP parts of the PHY so
> >>> drop the misleading "dp" prefix from the corresponding pointers.
> >>>
> >>> Note that the "DP" prefix could also be dropped from the corresponding
> >>> defines, but leave that in place for now.
> >>>
> >>> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> >>> ---
> >>>    drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 24 +++++++++++------------
> >>>    1 file changed, 12 insertions(+), 12 deletions(-)
> >>
> >> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> >>
> >> Note regarding the last phrase: I'd suggest leaving the DP prefix in
> >> register names, it makes it easier to visually note & verify the
> >> register block.
> > 
> > My point is that "DP" was never part of the COM register block name. The
> > confusion likely comes from the vendor driver naming these defines along
> > the lines of
> > 
> > 	USB3_DP_COM_POWER_DOWN_CTRL
> > 
> > Here "USB3_DP" is the common prefix for all defines that apply to both
> > "parts" of the PHY so the corresponding Linux define
> > 
> > 	QPHY_V3_DP_COM_POWER_DOWN_CTRL
> > 
> > should either include "USB3" or drop "DP".
> 
> My thought was that we already have too many _COM_ defines in the qmp 
> headers. Having QPHY_Vn_COM_something would make it too easy to mix it 
> with QSERDES_Vn_COM_foo. Thus I'd vote to leave DP_COM prefix in place. 
> While it might be not fully accurate, it serves the point of identifying 
> the register block.

I don't mind terribly and I didn't even consider trying to rename the
current defines.

The lack of public conclusive documentation makes structuring this mess
much harder than it should have to be. 

That said, I don't really think that the risk of mixing up
QPHY_Vn_COM_foo with QSERDES_Vn_COM_bar is something we need to worry
about as you already have a separating "QSERDES" in there. Those sets of
registers should be disjoint too if I remember correctly.

> > This becomes more apparent on SC8280XP where the corresponding define
> > is:
> > 
> > 	USB43DP_COM_POWER_DOWN_CTRL
> 
> I'd still use something like QPHY_V10_DP_COM_POWER_DOWN_CTRL here.

Yeah, but then you're just making names up. ;)

Johan
diff mbox series

Patch

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index 5068f8674faf..ee44ed6dfaae 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -866,7 +866,7 @@  struct qmp_combo {
 
 	const struct qmp_phy_cfg *cfg;
 
-	void __iomem *dp_com;
+	void __iomem *com;
 
 	void __iomem *serdes;
 	void __iomem *tx;
@@ -1778,7 +1778,7 @@  static int qmp_combo_dp_calibrate(struct phy *phy)
 static int qmp_combo_com_init(struct qmp_combo *qmp)
 {
 	const struct qmp_phy_cfg *cfg = qmp->cfg;
-	void __iomem *dp_com = qmp->dp_com;
+	void __iomem *com = qmp->com;
 	int ret;
 
 	mutex_lock(&qmp->phy_mutex);
@@ -1809,25 +1809,25 @@  static int qmp_combo_com_init(struct qmp_combo *qmp)
 	if (ret)
 		goto err_assert_reset;
 
-	qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, SW_PWRDN);
+	qphy_setbits(com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, SW_PWRDN);
 
 	/* override hardware control for reset of qmp phy */
-	qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
+	qphy_setbits(com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
 			SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
 			SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
 
 	/* Default type-c orientation, i.e CC1 */
-	qphy_setbits(dp_com, QPHY_V3_DP_COM_TYPEC_CTRL, 0x02);
+	qphy_setbits(com, QPHY_V3_DP_COM_TYPEC_CTRL, 0x02);
 
-	qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL, USB3_MODE | DP_MODE);
+	qphy_setbits(com, QPHY_V3_DP_COM_PHY_MODE_CTRL, USB3_MODE | DP_MODE);
 
 	/* bring both QMP USB and QMP DP PHYs PCS block out of reset */
-	qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
+	qphy_clrbits(com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
 			SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
 			SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
 
-	qphy_clrbits(dp_com, QPHY_V3_DP_COM_SWI_CTRL, 0x03);
-	qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET);
+	qphy_clrbits(com, QPHY_V3_DP_COM_SWI_CTRL, 0x03);
+	qphy_clrbits(com, QPHY_V3_DP_COM_SW_RESET, SW_RESET);
 
 	qphy_setbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
 			SW_PWRDN);
@@ -2560,9 +2560,9 @@  static int qmp_combo_parse_dt_legacy(struct qmp_combo *qmp, struct device_node *
 	if (IS_ERR(qmp->serdes))
 		return PTR_ERR(qmp->serdes);
 
-	qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
-	if (IS_ERR(qmp->dp_com))
-		return PTR_ERR(qmp->dp_com);
+	qmp->com = devm_platform_ioremap_resource(pdev, 1);
+	if (IS_ERR(qmp->com))
+		return PTR_ERR(qmp->com);
 
 	qmp->dp_serdes = devm_platform_ioremap_resource(pdev, 2);
 	if (IS_ERR(qmp->dp_serdes))