diff mbox series

[RFC,v3,5/7] phy: qcom: phy-qcom-snps-eusb2: Add support for eUSB2 repeater

Message ID 20230202133816.4026990-6-abel.vesa@linaro.org
State Superseded
Headers show
Series sm8550: Add support for eUSB2 repeater | expand

Commit Message

Abel Vesa Feb. 2, 2023, 1:38 p.m. UTC
From: Neil Armstrong <neil.armstrong@linaro.org>

For USB 2.0 compliance, eUSB2 needs a repeater. The PHY needs to
initialize and reset it. So add repeater support

Co-developed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Vinod Koul Feb. 3, 2023, 1:49 p.m. UTC | #1
On 02-02-23, 15:38, Abel Vesa wrote:
> From: Neil Armstrong <neil.armstrong@linaro.org>
> 
> For USB 2.0 compliance, eUSB2 needs a repeater. The PHY needs to
> initialize and reset it. So add repeater support
> 
> Co-developed-by: Abel Vesa <abel.vesa@linaro.org>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> index 23ec162cc3bd..8d972d49732b 100644
> --- a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> +++ b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> @@ -128,6 +128,8 @@ struct qcom_snps_eusb2_hsphy {
>  	struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
>  
>  	enum phy_mode mode;
> +
> +	struct phy *repeater;
>  };
>  
>  static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
> @@ -136,7 +138,7 @@ static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int
>  
>  	phy->mode = mode;
>  
> -	return 0;
> +	return phy_set_mode_ext(phy->repeater, mode, submode);
>  }
>  
>  static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset,
> @@ -235,6 +237,12 @@ static int qcom_snps_eusb2_hsphy_init(struct phy *p)
>  	if (ret)
>  		return ret;
>  
> +	ret = phy_init(phy->repeater);
> +	if (ret) {
> +		dev_err(&p->dev, "repeater init failed. %d\n", ret);
> +		goto disable_vreg;
> +	}
> +
>  	ret = clk_prepare_enable(phy->ref_clk);
>  	if (ret) {
>  		dev_err(&p->dev, "failed to enable ref clock, %d\n", ret);
> @@ -342,6 +350,8 @@ static int qcom_snps_eusb2_hsphy_exit(struct phy *p)
>  
>  	regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs);
>  
> +	phy_exit(phy->repeater);
> +
>  	return 0;
>  }
>  
> @@ -386,6 +396,12 @@ static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
>  	if (ret)
>  		return dev_err_probe(dev, ret,
>  				     "failed to get regulator supplies\n");
> +
> +	phy->repeater = devm_phy_get(dev, "eusb2-repeater");
> +	if (IS_ERR(phy->repeater))
> +		return dev_err_probe(dev, PTR_ERR(phy->repeater),
> +				     "failed to get repeater\n");

That implies repeater is assumed to be there for all designs, how about
older devices, they may not have a repeater?

> +
>  	generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops);
>  	if (IS_ERR(generic_phy)) {
>  		dev_err(dev, "failed to create phy %d\n", ret);
> -- 
> 2.34.1
Abel Vesa Feb. 7, 2023, 7:11 a.m. UTC | #2
On 23-02-03 19:19:22, Vinod Koul wrote:
> On 02-02-23, 15:38, Abel Vesa wrote:
> > From: Neil Armstrong <neil.armstrong@linaro.org>
> > 
> > For USB 2.0 compliance, eUSB2 needs a repeater. The PHY needs to
> > initialize and reset it. So add repeater support
> > 
> > Co-developed-by: Abel Vesa <abel.vesa@linaro.org>
> > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> > ---
> >  drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 18 +++++++++++++++++-
> >  1 file changed, 17 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> > index 23ec162cc3bd..8d972d49732b 100644
> > --- a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> > +++ b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
> > @@ -128,6 +128,8 @@ struct qcom_snps_eusb2_hsphy {
> >  	struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
> >  
> >  	enum phy_mode mode;
> > +
> > +	struct phy *repeater;
> >  };
> >  
> >  static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
> > @@ -136,7 +138,7 @@ static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int
> >  
> >  	phy->mode = mode;
> >  
> > -	return 0;
> > +	return phy_set_mode_ext(phy->repeater, mode, submode);
> >  }
> >  
> >  static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset,
> > @@ -235,6 +237,12 @@ static int qcom_snps_eusb2_hsphy_init(struct phy *p)
> >  	if (ret)
> >  		return ret;
> >  
> > +	ret = phy_init(phy->repeater);
> > +	if (ret) {
> > +		dev_err(&p->dev, "repeater init failed. %d\n", ret);
> > +		goto disable_vreg;
> > +	}
> > +
> >  	ret = clk_prepare_enable(phy->ref_clk);
> >  	if (ret) {
> >  		dev_err(&p->dev, "failed to enable ref clock, %d\n", ret);
> > @@ -342,6 +350,8 @@ static int qcom_snps_eusb2_hsphy_exit(struct phy *p)
> >  
> >  	regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs);
> >  
> > +	phy_exit(phy->repeater);
> > +
> >  	return 0;
> >  }
> >  
> > @@ -386,6 +396,12 @@ static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
> >  	if (ret)
> >  		return dev_err_probe(dev, ret,
> >  				     "failed to get regulator supplies\n");
> > +
> > +	phy->repeater = devm_phy_get(dev, "eusb2-repeater");
> > +	if (IS_ERR(phy->repeater))
> > +		return dev_err_probe(dev, PTR_ERR(phy->repeater),
> > +				     "failed to get repeater\n");
> 
> That implies repeater is assumed to be there for all designs, how about
> older devices, they may not have a repeater?

Well, no other (older) platform has eUSB2 support, IIRC.

And the eUSB2 can't be used as USB 2.0 without the repeater.

> 
> > +
> >  	generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops);
> >  	if (IS_ERR(generic_phy)) {
> >  		dev_err(dev, "failed to create phy %d\n", ret);
> > -- 
> > 2.34.1
> 
> -- 
> ~Vinod
diff mbox series

Patch

diff --git a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
index 23ec162cc3bd..8d972d49732b 100644
--- a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
+++ b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c
@@ -128,6 +128,8 @@  struct qcom_snps_eusb2_hsphy {
 	struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
 
 	enum phy_mode mode;
+
+	struct phy *repeater;
 };
 
 static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
@@ -136,7 +138,7 @@  static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int
 
 	phy->mode = mode;
 
-	return 0;
+	return phy_set_mode_ext(phy->repeater, mode, submode);
 }
 
 static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset,
@@ -235,6 +237,12 @@  static int qcom_snps_eusb2_hsphy_init(struct phy *p)
 	if (ret)
 		return ret;
 
+	ret = phy_init(phy->repeater);
+	if (ret) {
+		dev_err(&p->dev, "repeater init failed. %d\n", ret);
+		goto disable_vreg;
+	}
+
 	ret = clk_prepare_enable(phy->ref_clk);
 	if (ret) {
 		dev_err(&p->dev, "failed to enable ref clock, %d\n", ret);
@@ -342,6 +350,8 @@  static int qcom_snps_eusb2_hsphy_exit(struct phy *p)
 
 	regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs);
 
+	phy_exit(phy->repeater);
+
 	return 0;
 }
 
@@ -386,6 +396,12 @@  static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(dev, ret,
 				     "failed to get regulator supplies\n");
+
+	phy->repeater = devm_phy_get(dev, "eusb2-repeater");
+	if (IS_ERR(phy->repeater))
+		return dev_err_probe(dev, PTR_ERR(phy->repeater),
+				     "failed to get repeater\n");
+
 	generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops);
 	if (IS_ERR(generic_phy)) {
 		dev_err(dev, "failed to create phy %d\n", ret);