Message ID | 1629825378-8089-2-git-send-email-manish.narani@xilinx.com |
---|---|
State | New |
Headers | show |
Series | Chipidea USB driver Enhancements and Bug Fixes | expand |
On 21-08-24 22:46:13, Manish Narani 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. > > Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com> > Signed-off-by: Michal Simek <michal.simek@xilinx.com> > Signed-off-by: Manish Narani <manish.narani@xilinx.com> > --- > drivers/usb/chipidea/ci_hdrc_usb2.c | 1 + > drivers/usb/chipidea/host.c | 9 +++++++++ > drivers/usb/chipidea/otg_fsm.c | 7 +++++++ > include/linux/usb/chipidea.h | 1 + > 4 files changed, 18 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 e86d13c..578968d 100644 > --- a/drivers/usb/chipidea/host.c > +++ b/drivers/usb/chipidea/host.c > @@ -63,6 +63,14 @@ 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 && > + ci->usb_phy && ci->usb_phy->set_vbus) { Indent is needed. Otherwise: Acked-by: Peter Chen <peter.chen@kernel.org> Peter > + if (enable) > + ci->usb_phy->set_vbus(ci->usb_phy, 1); > + else > + ci->usb_phy->set_vbus(ci->usb_phy, 0); > + } > + > if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { > /* > * Marvell 28nm HSIC PHY requires forcing the port to HS mode. > @@ -71,6 +79,7 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable) > hw_port_test_set(ci, 5); > hw_port_test_set(ci, 0); > } > + > return 0; > }; > > diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c > index 6ed4b00..2f7f94d 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) > + ci->usb_phy->set_vbus(ci->usb_phy, 1); > + > /* 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) > + ci->usb_phy->set_vbus(ci->usb_phy, 0); > + > 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.1.1 > -- Thanks, Peter Chen
Manish Narani <manish.narani@xilinx.com> 于2021年8月25日周三 上午1:23写道: > > 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. > > Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com> > Signed-off-by: Michal Simek <michal.simek@xilinx.com> > Signed-off-by: Manish Narani <manish.narani@xilinx.com> > --- > drivers/usb/chipidea/ci_hdrc_usb2.c | 1 + > drivers/usb/chipidea/host.c | 9 +++++++++ > drivers/usb/chipidea/otg_fsm.c | 7 +++++++ > include/linux/usb/chipidea.h | 1 + > 4 files changed, 18 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 e86d13c..578968d 100644 > --- a/drivers/usb/chipidea/host.c > +++ b/drivers/usb/chipidea/host.c > @@ -63,6 +63,14 @@ 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 && > + ci->usb_phy && ci->usb_phy->set_vbus) { > + if (enable) > + ci->usb_phy->set_vbus(ci->usb_phy, 1); > + else > + ci->usb_phy->set_vbus(ci->usb_phy, 0); > + } > + Can existing API usb_phy_vbus_on/off() work for you? I think that helper will make it simple so you don't need a new flag and those checks. Li Jun > if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { > /* > * Marvell 28nm HSIC PHY requires forcing the port to HS mode. > @@ -71,6 +79,7 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable) > hw_port_test_set(ci, 5); > hw_port_test_set(ci, 0); > } > + > return 0; > }; > > diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c > index 6ed4b00..2f7f94d 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) > + ci->usb_phy->set_vbus(ci->usb_phy, 1); > + > /* 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) > + ci->usb_phy->set_vbus(ci->usb_phy, 0); > + > 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.1.1 >
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 e86d13c..578968d 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -63,6 +63,14 @@ 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 && + ci->usb_phy && ci->usb_phy->set_vbus) { + if (enable) + ci->usb_phy->set_vbus(ci->usb_phy, 1); + else + ci->usb_phy->set_vbus(ci->usb_phy, 0); + } + if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { /* * Marvell 28nm HSIC PHY requires forcing the port to HS mode. @@ -71,6 +79,7 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable) hw_port_test_set(ci, 5); hw_port_test_set(ci, 0); } + return 0; }; diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 6ed4b00..2f7f94d 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) + ci->usb_phy->set_vbus(ci->usb_phy, 1); + /* 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) + ci->usb_phy->set_vbus(ci->usb_phy, 0); + 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