linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
@ 2022-05-24 12:08 Piyush Mehta
  2022-06-21 12:26 ` Mehta, Piyush
  2022-07-03  0:34 ` Peter Chen
  0 siblings, 2 replies; 5+ messages in thread
From: Piyush Mehta @ 2022-05-24 12:08 UTC (permalink / raw)
  To: peter.chen, gregkh, michal.simek
  Cc: linux-usb, linux-kernel, git, sivadur, radheys, Piyush Mehta

Some platforms make use of VBUS control over PHY which means controller
driver has to access PHY registers to turn on/off VBUS line.This patch
adds support for such platforms in chipidea.

Flag 'CI_HDRC_PHY_VBUS_CONTROL' added to support VBus control feature.

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
---
We have created this patch as RFC, as I introduced a new flag
(CI_HDRC_PHY_VBUS_CONTROL) and would like to get comment if
it's the proper way to check for VBus support for zynq.
---
 drivers/usb/chipidea/ci_hdrc_usb2.c | 1 +
 drivers/usb/chipidea/host.c         | 7 +++++++
 drivers/usb/chipidea/otg_fsm.c      | 7 +++++++
 include/linux/usb/chipidea.h        | 1 +
 4 files changed, 16 insertions(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 89e1d82..dc86b12 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -30,6 +30,7 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
 
 static const struct ci_hdrc_platform_data ci_zynq_pdata = {
 	.capoffset	= DEF_CAPOFFSET,
+	.flags          = CI_HDRC_PHY_VBUS_CONTROL,
 };
 
 static const struct ci_hdrc_platform_data ci_zevio_pdata = {
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index bdc3885..bc3634a 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -63,6 +63,13 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable)
 		priv->enabled = enable;
 	}
 
+	if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
+		if (enable)
+			usb_phy_vbus_on(ci->usb_phy);
+		else
+			usb_phy_vbus_off(ci->usb_phy);
+	}
+
 	if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) {
 		/*
 		 * Marvell 28nm HSIC PHY requires forcing the port to HS mode.
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 6ed4b00..5ed9164 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -471,6 +471,10 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
 				return;
 			}
 		}
+
+		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
+			usb_phy_vbus_on(ci->usb_phy);
+
 		/* Disable data pulse irq */
 		hw_write_otgsc(ci, OTGSC_DPIE, 0);
 
@@ -480,6 +484,9 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
 		if (ci->platdata->reg_vbus)
 			regulator_disable(ci->platdata->reg_vbus);
 
+		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
+			usb_phy_vbus_off(ci->usb_phy);
+
 		fsm->a_bus_drop = 1;
 		fsm->a_bus_req = 0;
 	}
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index edf3342..ee38835 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -62,6 +62,7 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_REQUIRES_ALIGNED_DMA	BIT(13)
 #define CI_HDRC_IMX_IS_HSIC		BIT(14)
 #define CI_HDRC_PMQOS			BIT(15)
+#define CI_HDRC_PHY_VBUS_CONTROL	BIT(16)
 	enum usb_dr_mode	dr_mode;
 #define CI_HDRC_CONTROLLER_RESET_EVENT		0
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
  2022-05-24 12:08 [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY Piyush Mehta
@ 2022-06-21 12:26 ` Mehta, Piyush
  2022-07-03  0:34 ` Peter Chen
  1 sibling, 0 replies; 5+ messages in thread
From: Mehta, Piyush @ 2022-06-21 12:26 UTC (permalink / raw)
  To: Piyush Mehta, peter.chen, gregkh, Simek, Michal
  Cc: linux-usb, linux-kernel, git, Paladugu, Siva Durga Prasad,
	Pandey, Radhey Shyam

Ping

Regards,
Piyush Mehta

> -----Original Message-----
> From: Piyush Mehta <piyush.mehta@xilinx.com>
> Sent: Tuesday, May 24, 2022 5:38 PM
> To: peter.chen@kernel.org; gregkh@linuxfoundation.org; Michal Simek
> <michals@xilinx.com>
> Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; git
> <git@xilinx.com>; Siva Durga Prasad Paladugu <sivadur@xilinx.com>; Radhey
> Shyam Pandey <radheys@xilinx.com>; Piyush Mehta <piyushm@xilinx.com>
> Subject: [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
> 
> Some platforms make use of VBUS control over PHY which means controller
> driver has to access PHY registers to turn on/off VBUS line.This patch adds
> support for such platforms in chipidea.
> 
> Flag 'CI_HDRC_PHY_VBUS_CONTROL' added to support VBus control feature.
> 
> Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
> ---
> We have created this patch as RFC, as I introduced a new flag
> (CI_HDRC_PHY_VBUS_CONTROL) and would like to get comment if it's the
> proper way to check for VBus support for zynq.
> ---
>  drivers/usb/chipidea/ci_hdrc_usb2.c | 1 +
>  drivers/usb/chipidea/host.c         | 7 +++++++
>  drivers/usb/chipidea/otg_fsm.c      | 7 +++++++
>  include/linux/usb/chipidea.h        | 1 +
>  4 files changed, 16 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c
> b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index 89e1d82..dc86b12 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -30,6 +30,7 @@ static const struct ci_hdrc_platform_data
> ci_default_pdata = {
> 
>  static const struct ci_hdrc_platform_data ci_zynq_pdata = {
>  	.capoffset	= DEF_CAPOFFSET,
> +	.flags          = CI_HDRC_PHY_VBUS_CONTROL,
>  };
> 
>  static const struct ci_hdrc_platform_data ci_zevio_pdata = { diff --git
> a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index
> bdc3885..bc3634a 100644
> --- a/drivers/usb/chipidea/host.c
> +++ b/drivers/usb/chipidea/host.c
> @@ -63,6 +63,13 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int
> portnum, bool enable)
>  		priv->enabled = enable;
>  	}
> 
> +	if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
> +		if (enable)
> +			usb_phy_vbus_on(ci->usb_phy);
> +		else
> +			usb_phy_vbus_off(ci->usb_phy);
> +	}
> +
>  	if (enable && (ci->platdata->phy_mode ==
> USBPHY_INTERFACE_MODE_HSIC)) {
>  		/*
>  		 * Marvell 28nm HSIC PHY requires forcing the port to HS
> mode.
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 6ed4b00..5ed9164 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -471,6 +471,10 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int
> on)
>  				return;
>  			}
>  		}
> +
> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> +			usb_phy_vbus_on(ci->usb_phy);
> +
>  		/* Disable data pulse irq */
>  		hw_write_otgsc(ci, OTGSC_DPIE, 0);
> 
> @@ -480,6 +484,9 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int
> on)
>  		if (ci->platdata->reg_vbus)
>  			regulator_disable(ci->platdata->reg_vbus);
> 
> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> +			usb_phy_vbus_off(ci->usb_phy);
> +
>  		fsm->a_bus_drop = 1;
>  		fsm->a_bus_req = 0;
>  	}
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index edf3342..ee38835 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -62,6 +62,7 @@ struct ci_hdrc_platform_data {
>  #define CI_HDRC_REQUIRES_ALIGNED_DMA	BIT(13)
>  #define CI_HDRC_IMX_IS_HSIC		BIT(14)
>  #define CI_HDRC_PMQOS			BIT(15)
> +#define CI_HDRC_PHY_VBUS_CONTROL	BIT(16)
>  	enum usb_dr_mode	dr_mode;
>  #define CI_HDRC_CONTROLLER_RESET_EVENT		0
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
  2022-05-24 12:08 [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY Piyush Mehta
  2022-06-21 12:26 ` Mehta, Piyush
@ 2022-07-03  0:34 ` Peter Chen
  2022-07-11 16:45   ` Mehta, Piyush
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Chen @ 2022-07-03  0:34 UTC (permalink / raw)
  To: Piyush Mehta
  Cc: gregkh, michal.simek, linux-usb, linux-kernel, git, sivadur, radheys

On 22-05-24 17:38:02, Piyush Mehta wrote:
> Some platforms make use of VBUS control over PHY which means controller
> driver has to access PHY registers to turn on/off VBUS line.This patch
> adds support for such platforms in chipidea.
> 
> Flag 'CI_HDRC_PHY_VBUS_CONTROL' added to support VBus control feature.
> 
> Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
> ---
> We have created this patch as RFC, as I introduced a new flag
> (CI_HDRC_PHY_VBUS_CONTROL) and would like to get comment if
> it's the proper way to check for VBus support for zynq.
> ---
>  drivers/usb/chipidea/ci_hdrc_usb2.c | 1 +
>  drivers/usb/chipidea/host.c         | 7 +++++++
>  drivers/usb/chipidea/otg_fsm.c      | 7 +++++++
>  include/linux/usb/chipidea.h        | 1 +
>  4 files changed, 16 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index 89e1d82..dc86b12 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -30,6 +30,7 @@ static const struct ci_hdrc_platform_data ci_default_pdata = {
>  
>  static const struct ci_hdrc_platform_data ci_zynq_pdata = {
>  	.capoffset	= DEF_CAPOFFSET,
> +	.flags          = CI_HDRC_PHY_VBUS_CONTROL,
>  };
>  
>  static const struct ci_hdrc_platform_data ci_zevio_pdata = {
> diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> index bdc3885..bc3634a 100644
> --- a/drivers/usb/chipidea/host.c
> +++ b/drivers/usb/chipidea/host.c
> @@ -63,6 +63,13 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable)
>  		priv->enabled = enable;
>  	}
>  
> +	if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
> +		if (enable)
> +			usb_phy_vbus_on(ci->usb_phy);
> +		else
> +			usb_phy_vbus_off(ci->usb_phy);
> +	}
> +
>  	if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) {
>  		/*
>  		 * Marvell 28nm HSIC PHY requires forcing the port to HS mode.
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 6ed4b00..5ed9164 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -471,6 +471,10 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
>  				return;
>  			}
>  		}
> +
> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> +			usb_phy_vbus_on(ci->usb_phy);
> +
>  		/* Disable data pulse irq */
>  		hw_write_otgsc(ci, OTGSC_DPIE, 0);
>  
> @@ -480,6 +484,9 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
>  		if (ci->platdata->reg_vbus)
>  			regulator_disable(ci->platdata->reg_vbus);
>  
> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> +			usb_phy_vbus_off(ci->usb_phy);
> +

Have your platform used OTG FSM? If not used, do not need to change it.
Otherwise, it is okay for me.

Peter

>  		fsm->a_bus_drop = 1;
>  		fsm->a_bus_req = 0;
>  	}
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index edf3342..ee38835 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -62,6 +62,7 @@ struct ci_hdrc_platform_data {
>  #define CI_HDRC_REQUIRES_ALIGNED_DMA	BIT(13)
>  #define CI_HDRC_IMX_IS_HSIC		BIT(14)
>  #define CI_HDRC_PMQOS			BIT(15)
> +#define CI_HDRC_PHY_VBUS_CONTROL	BIT(16)
>  	enum usb_dr_mode	dr_mode;
>  #define CI_HDRC_CONTROLLER_RESET_EVENT		0
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
> -- 
> 2.7.4
> 

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
  2022-07-03  0:34 ` Peter Chen
@ 2022-07-11 16:45   ` Mehta, Piyush
  2022-07-12  1:19     ` Peter Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Mehta, Piyush @ 2022-07-11 16:45 UTC (permalink / raw)
  To: Peter Chen, Piyush Mehta
  Cc: gregkh, michal.simek, linux-usb, linux-kernel, git, sivadur, radheys

Hello Peter,

Thanks for the review.
Yes, we are supporting OTG feature and have used OTG FSM platform.

Regards,
Piyush Mehta 

> -----Original Message-----
> From: Peter Chen <peter.chen@kernel.org>
> Sent: Sunday, July 3, 2022 6:05 AM
> To: Piyush Mehta <piyush.mehta@xilinx.com>
> Cc: gregkh@linuxfoundation.org; michal.simek@xilinx.com; linux-
> usb@vger.kernel.org; linux-kernel@vger.kernel.org; git@xilinx.com;
> sivadur@xilinx.com; radheys@xilinx.com
> Subject: Re: [RFC PATCH] usb: chipidea: Add support for VBUS control with
> PHY
> 
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
> 
> 
> On 22-05-24 17:38:02, Piyush Mehta wrote:
> > Some platforms make use of VBUS control over PHY which means
> > controller driver has to access PHY registers to turn on/off VBUS
> > line.This patch adds support for such platforms in chipidea.
> >
> > Flag 'CI_HDRC_PHY_VBUS_CONTROL' added to support VBus control
> feature.
> >
> > Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
> > ---
> > We have created this patch as RFC, as I introduced a new flag
> > (CI_HDRC_PHY_VBUS_CONTROL) and would like to get comment if it's the
> > proper way to check for VBus support for zynq.
> > ---
> >  drivers/usb/chipidea/ci_hdrc_usb2.c | 1 +
> >  drivers/usb/chipidea/host.c         | 7 +++++++
> >  drivers/usb/chipidea/otg_fsm.c      | 7 +++++++
> >  include/linux/usb/chipidea.h        | 1 +
> >  4 files changed, 16 insertions(+)
> >
> > diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c
> > b/drivers/usb/chipidea/ci_hdrc_usb2.c
> > index 89e1d82..dc86b12 100644
> > --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> > +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> > @@ -30,6 +30,7 @@ static const struct ci_hdrc_platform_data
> > ci_default_pdata = {
> >
> >  static const struct ci_hdrc_platform_data ci_zynq_pdata = {
> >       .capoffset      = DEF_CAPOFFSET,
> > +     .flags          = CI_HDRC_PHY_VBUS_CONTROL,
> >  };
> >
> >  static const struct ci_hdrc_platform_data ci_zevio_pdata = { diff
> > --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> > index bdc3885..bc3634a 100644
> > --- a/drivers/usb/chipidea/host.c
> > +++ b/drivers/usb/chipidea/host.c
> > @@ -63,6 +63,13 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int
> portnum, bool enable)
> >               priv->enabled = enable;
> >       }
> >
> > +     if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
> > +             if (enable)
> > +                     usb_phy_vbus_on(ci->usb_phy);
> > +             else
> > +                     usb_phy_vbus_off(ci->usb_phy);
> > +     }
> > +
> >       if (enable && (ci->platdata->phy_mode ==
> USBPHY_INTERFACE_MODE_HSIC)) {
> >               /*
> >                * Marvell 28nm HSIC PHY requires forcing the port to HS mode.
> > diff --git a/drivers/usb/chipidea/otg_fsm.c
> > b/drivers/usb/chipidea/otg_fsm.c index 6ed4b00..5ed9164 100644
> > --- a/drivers/usb/chipidea/otg_fsm.c
> > +++ b/drivers/usb/chipidea/otg_fsm.c
> > @@ -471,6 +471,10 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm,
> int on)
> >                               return;
> >                       }
> >               }
> > +
> > +             if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> > +                     usb_phy_vbus_on(ci->usb_phy);
> > +
> >               /* Disable data pulse irq */
> >               hw_write_otgsc(ci, OTGSC_DPIE, 0);
> >
> > @@ -480,6 +484,9 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int
> on)
> >               if (ci->platdata->reg_vbus)
> >                       regulator_disable(ci->platdata->reg_vbus);
> >
> > +             if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> > +                     usb_phy_vbus_off(ci->usb_phy);
> > +
> 
> Have your platform used OTG FSM? If not used, do not need to change it.
> Otherwise, it is okay for me.
> 
> Peter
> 
> >               fsm->a_bus_drop = 1;
> >               fsm->a_bus_req = 0;
> >       }
> > diff --git a/include/linux/usb/chipidea.h
> > b/include/linux/usb/chipidea.h index edf3342..ee38835 100644
> > --- a/include/linux/usb/chipidea.h
> > +++ b/include/linux/usb/chipidea.h
> > @@ -62,6 +62,7 @@ struct ci_hdrc_platform_data {  #define
> > CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13)
> >  #define CI_HDRC_IMX_IS_HSIC          BIT(14)
> >  #define CI_HDRC_PMQOS                        BIT(15)
> > +#define CI_HDRC_PHY_VBUS_CONTROL     BIT(16)
> >       enum usb_dr_mode        dr_mode;
> >  #define CI_HDRC_CONTROLLER_RESET_EVENT               0
> >  #define CI_HDRC_CONTROLLER_STOPPED_EVENT     1
> > --
> > 2.7.4
> >
> 
> --
> 
> Thanks,
> Peter Chen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY
  2022-07-11 16:45   ` Mehta, Piyush
@ 2022-07-12  1:19     ` Peter Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2022-07-12  1:19 UTC (permalink / raw)
  To: Mehta, Piyush
  Cc: Piyush Mehta, gregkh, michal.simek, linux-usb, linux-kernel, git,
	sivadur, radheys

On 22-07-11 16:45:20, Mehta, Piyush wrote:
> Hello Peter,
> 
> Thanks for the review.
> Yes, we are supporting OTG feature and have used OTG FSM platform.

Please generate the formal patch with my ack, thanks.

Acked-by: Peter Chen <peter.chen@kernel.org>

> 
> Regards,
> Piyush Mehta 
> 
> > -----Original Message-----
> > From: Peter Chen <peter.chen@kernel.org>
> > Sent: Sunday, July 3, 2022 6:05 AM
> > To: Piyush Mehta <piyush.mehta@xilinx.com>
> > Cc: gregkh@linuxfoundation.org; michal.simek@xilinx.com; linux-
> > usb@vger.kernel.org; linux-kernel@vger.kernel.org; git@xilinx.com;
> > sivadur@xilinx.com; radheys@xilinx.com
> > Subject: Re: [RFC PATCH] usb: chipidea: Add support for VBUS control with
> > PHY
> > 
> > CAUTION: This message has originated from an External Source. Please use
> > proper judgment and caution when opening attachments, clicking links, or
> > responding to this email.
> > 
> > 
> > On 22-05-24 17:38:02, Piyush Mehta wrote:
> > > Some platforms make use of VBUS control over PHY which means
> > > controller driver has to access PHY registers to turn on/off VBUS
> > > line.This patch adds support for such platforms in chipidea.
> > >
> > > Flag 'CI_HDRC_PHY_VBUS_CONTROL' added to support VBus control
> > feature.
> > >
> > > Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
> > > ---
> > > We have created this patch as RFC, as I introduced a new flag
> > > (CI_HDRC_PHY_VBUS_CONTROL) and would like to get comment if it's the
> > > proper way to check for VBus support for zynq.
> > > ---
> > >  drivers/usb/chipidea/ci_hdrc_usb2.c | 1 +
> > >  drivers/usb/chipidea/host.c         | 7 +++++++
> > >  drivers/usb/chipidea/otg_fsm.c      | 7 +++++++
> > >  include/linux/usb/chipidea.h        | 1 +
> > >  4 files changed, 16 insertions(+)
> > >
> > > diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c
> > > b/drivers/usb/chipidea/ci_hdrc_usb2.c
> > > index 89e1d82..dc86b12 100644
> > > --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> > > +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> > > @@ -30,6 +30,7 @@ static const struct ci_hdrc_platform_data
> > > ci_default_pdata = {
> > >
> > >  static const struct ci_hdrc_platform_data ci_zynq_pdata = {
> > >       .capoffset      = DEF_CAPOFFSET,
> > > +     .flags          = CI_HDRC_PHY_VBUS_CONTROL,
> > >  };
> > >
> > >  static const struct ci_hdrc_platform_data ci_zevio_pdata = { diff
> > > --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> > > index bdc3885..bc3634a 100644
> > > --- a/drivers/usb/chipidea/host.c
> > > +++ b/drivers/usb/chipidea/host.c
> > > @@ -63,6 +63,13 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int
> > portnum, bool enable)
> > >               priv->enabled = enable;
> > >       }
> > >
> > > +     if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
> > > +             if (enable)
> > > +                     usb_phy_vbus_on(ci->usb_phy);
> > > +             else
> > > +                     usb_phy_vbus_off(ci->usb_phy);
> > > +     }
> > > +
> > >       if (enable && (ci->platdata->phy_mode ==
> > USBPHY_INTERFACE_MODE_HSIC)) {
> > >               /*
> > >                * Marvell 28nm HSIC PHY requires forcing the port to HS mode.
> > > diff --git a/drivers/usb/chipidea/otg_fsm.c
> > > b/drivers/usb/chipidea/otg_fsm.c index 6ed4b00..5ed9164 100644
> > > --- a/drivers/usb/chipidea/otg_fsm.c
> > > +++ b/drivers/usb/chipidea/otg_fsm.c
> > > @@ -471,6 +471,10 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm,
> > int on)
> > >                               return;
> > >                       }
> > >               }
> > > +
> > > +             if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> > > +                     usb_phy_vbus_on(ci->usb_phy);
> > > +
> > >               /* Disable data pulse irq */
> > >               hw_write_otgsc(ci, OTGSC_DPIE, 0);
> > >
> > > @@ -480,6 +484,9 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int
> > on)
> > >               if (ci->platdata->reg_vbus)
> > >                       regulator_disable(ci->platdata->reg_vbus);
> > >
> > > +             if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
> > > +                     usb_phy_vbus_off(ci->usb_phy);
> > > +
> > 
> > Have your platform used OTG FSM? If not used, do not need to change it.
> > Otherwise, it is okay for me.
> > 
> > Peter
> > 
> > >               fsm->a_bus_drop = 1;
> > >               fsm->a_bus_req = 0;
> > >       }
> > > diff --git a/include/linux/usb/chipidea.h
> > > b/include/linux/usb/chipidea.h index edf3342..ee38835 100644
> > > --- a/include/linux/usb/chipidea.h
> > > +++ b/include/linux/usb/chipidea.h
> > > @@ -62,6 +62,7 @@ struct ci_hdrc_platform_data {  #define
> > > CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13)
> > >  #define CI_HDRC_IMX_IS_HSIC          BIT(14)
> > >  #define CI_HDRC_PMQOS                        BIT(15)
> > > +#define CI_HDRC_PHY_VBUS_CONTROL     BIT(16)
> > >       enum usb_dr_mode        dr_mode;
> > >  #define CI_HDRC_CONTROLLER_RESET_EVENT               0
> > >  #define CI_HDRC_CONTROLLER_STOPPED_EVENT     1
> > > --
> > > 2.7.4
> > >
> > 
> > --
> > 
> > Thanks,
> > Peter Chen
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-12  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 12:08 [RFC PATCH] usb: chipidea: Add support for VBUS control with PHY Piyush Mehta
2022-06-21 12:26 ` Mehta, Piyush
2022-07-03  0:34 ` Peter Chen
2022-07-11 16:45   ` Mehta, Piyush
2022-07-12  1:19     ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).