diff mbox series

phy: airoha: adjust initialization delay in airoha_pcie_phy_init()

Message ID 82e50875deba44e34f49bd92578b4dc24f121b01.1720508349.git.lorenzo@kernel.org
State Superseded
Headers show
Series phy: airoha: adjust initialization delay in airoha_pcie_phy_init() | expand

Commit Message

Lorenzo Bianconi July 9, 2024, 7:03 a.m. UTC
Align phy-pcie initialization delay to the vendor sdk in
airoha_pcie_phy_init routine and allow the hw to complete required
configuration before proceeding

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/phy/phy-airoha-pcie.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Vinod Koul Aug. 4, 2024, 5:31 p.m. UTC | #1
On 09-07-24, 09:03, Lorenzo Bianconi wrote:
> Align phy-pcie initialization delay to the vendor sdk in
> airoha_pcie_phy_init routine and allow the hw to complete required
> configuration before proceeding
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  drivers/phy/phy-airoha-pcie.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/phy-airoha-pcie.c b/drivers/phy/phy-airoha-pcie.c
> index bd3edaa986c8..445bacfdaaf4 100644
> --- a/drivers/phy/phy-airoha-pcie.c
> +++ b/drivers/phy/phy-airoha-pcie.c
> @@ -18,6 +18,9 @@
>  #define LEQ_LEN_CTRL_MAX_VAL	7
>  #define FREQ_LOCK_MAX_ATTEMPT	10
>  
> +/* PCIe-PHY initialization time in ms needed by the hw to complete */
> +#define PHY_HW_INIT_TIME_MS	30
> +
>  enum airoha_pcie_port_gen {
>  	PCIE_PORT_GEN1 = 1,
>  	PCIE_PORT_GEN2,
> @@ -1180,8 +1183,11 @@ static int airoha_pcie_phy_init(struct phy *phy)
>  				 PCIE_DA_XPON_CDR_PR_PWDB);
>  	airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0,
>  				 PCIE_DA_XPON_CDR_PR_PWDB);
> -
> -	usleep_range(100, 200);
> +	/*
> +	 * Wait for the time in ms needed by the hw to complete the PCIe-PHY
> +	 * initialization
> +	 */
> +	mdelay(PHY_HW_INIT_TIME_MS);

Why not use msleep()...?
Lorenzo Bianconi Aug. 5, 2024, 5:17 p.m. UTC | #2
> On 09-07-24, 09:03, Lorenzo Bianconi wrote:
> > Align phy-pcie initialization delay to the vendor sdk in
> > airoha_pcie_phy_init routine and allow the hw to complete required
> > configuration before proceeding
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  drivers/phy/phy-airoha-pcie.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/phy-airoha-pcie.c b/drivers/phy/phy-airoha-pcie.c
> > index bd3edaa986c8..445bacfdaaf4 100644
> > --- a/drivers/phy/phy-airoha-pcie.c
> > +++ b/drivers/phy/phy-airoha-pcie.c
> > @@ -18,6 +18,9 @@
> >  #define LEQ_LEN_CTRL_MAX_VAL	7
> >  #define FREQ_LOCK_MAX_ATTEMPT	10
> >  
> > +/* PCIe-PHY initialization time in ms needed by the hw to complete */
> > +#define PHY_HW_INIT_TIME_MS	30
> > +
> >  enum airoha_pcie_port_gen {
> >  	PCIE_PORT_GEN1 = 1,
> >  	PCIE_PORT_GEN2,
> > @@ -1180,8 +1183,11 @@ static int airoha_pcie_phy_init(struct phy *phy)
> >  				 PCIE_DA_XPON_CDR_PR_PWDB);
> >  	airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0,
> >  				 PCIE_DA_XPON_CDR_PR_PWDB);
> > -
> > -	usleep_range(100, 200);
> > +	/*
> > +	 * Wait for the time in ms needed by the hw to complete the PCIe-PHY
> > +	 * initialization
> > +	 */
> > +	mdelay(PHY_HW_INIT_TIME_MS);
> 
> Why not use msleep()...?

ack, you are right, it is not in an atomic context. I will fix it in v2.

Regards,
Lorenzo

> 
> -- 
> ~Vinod
diff mbox series

Patch

diff --git a/drivers/phy/phy-airoha-pcie.c b/drivers/phy/phy-airoha-pcie.c
index bd3edaa986c8..445bacfdaaf4 100644
--- a/drivers/phy/phy-airoha-pcie.c
+++ b/drivers/phy/phy-airoha-pcie.c
@@ -18,6 +18,9 @@ 
 #define LEQ_LEN_CTRL_MAX_VAL	7
 #define FREQ_LOCK_MAX_ATTEMPT	10
 
+/* PCIe-PHY initialization time in ms needed by the hw to complete */
+#define PHY_HW_INIT_TIME_MS	30
+
 enum airoha_pcie_port_gen {
 	PCIE_PORT_GEN1 = 1,
 	PCIE_PORT_GEN2,
@@ -1180,8 +1183,11 @@  static int airoha_pcie_phy_init(struct phy *phy)
 				 PCIE_DA_XPON_CDR_PR_PWDB);
 	airoha_phy_pma1_set_bits(pcie_phy, REG_PCIE_PMA_SS_DA_XPON_PWDB0,
 				 PCIE_DA_XPON_CDR_PR_PWDB);
-
-	usleep_range(100, 200);
+	/*
+	 * Wait for the time in ms needed by the hw to complete the PCIe-PHY
+	 * initialization
+	 */
+	mdelay(PHY_HW_INIT_TIME_MS);
 
 	return 0;
 }