* [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
@ 2023-12-18 6:14 Xu Yang
2023-12-18 6:14 ` [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq Xu Yang
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Xu Yang @ 2023-12-18 6:14 UTC (permalink / raw)
To: peter.chen
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
Some platform using ChipIdea IP may keep 32KHz wakeup clock always
on without usb driver intervention. And some may need driver to handle
this clock. For now only i.MX93 needs this wakeup clock. This patch will
get wakeup clock and keep it always on to make controller work properly.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- modify commit msg to make it clear
---
drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index e28bb2f2612d..4330be8240ff 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
+ struct clk *clk_wakeup;
struct imx_usbmisc_data *usbmisc_data;
bool supports_runtime_pm;
bool override_phy_control;
@@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
data->clk_ipg = devm_clk_get(dev, "ipg");
if (IS_ERR(data->clk_ipg)) {
- /* If the platform only needs one clocks */
+ /* If the platform only needs one primary clock */
data->clk = devm_clk_get(dev, NULL);
if (IS_ERR(data->clk)) {
ret = PTR_ERR(data->clk);
@@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
return ret;
}
+ /* Get wakeup clock. Not all of the platforms need to
+ * handle this clock. So make it optional.
+ */
+ data->clk_wakeup = devm_clk_get_optional(dev,
+ "usb_wakeup_clk");
+ if (IS_ERR(data->clk_wakeup)) {
+ ret = PTR_ERR(data->clk_wakeup);
+ dev_err(dev,
+ "Failed to get wakeup clk, err=%ld\n",
+ PTR_ERR(data->clk_wakeup));
+ return ret;
+ }
return ret;
}
@@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (ret)
goto disable_hsic_regulator;
+ ret = clk_prepare_enable(data->clk_wakeup);
+ if (ret)
+ goto err_wakeup_clk;
+
data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
if (IS_ERR(data->phy)) {
ret = PTR_ERR(data->phy);
@@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
disable_device:
ci_hdrc_remove_device(data->ci_pdev);
err_clk:
+ clk_disable_unprepare(data->clk_wakeup);
+err_wakeup_clk:
imx_disable_unprepare_clks(dev);
disable_hsic_regulator:
if (data->hsic_pad_regulator)
@@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
usb_phy_shutdown(data->phy);
if (data->ci_pdev) {
imx_disable_unprepare_clks(&pdev->dev);
+ clk_disable_unprepare(data->clk_wakeup);
if (data->plat_data->flags & CI_HDRC_PMQOS)
cpu_latency_qos_remove_request(&data->pm_qos_req);
if (data->hsic_pad_regulator)
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
@ 2023-12-18 6:14 ` Xu Yang
2023-12-22 3:41 ` Peter Chen
2023-12-18 6:14 ` [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host() Xu Yang
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Xu Yang @ 2023-12-18 6:14 UTC (permalink / raw)
To: peter.chen
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
After the chipidea driver introduce extcon for id and vbus, it's able
to wakeup from another irq source, in case the system with extcon ID
cable, wakeup from usb ID cable and device removal, the usb device
disconnect irq may come firstly before the extcon notifier while system
resume, so we will get 2 "wakeup" irq, one for usb device disconnect;
and one for extcon ID cable change(real wakeup event), current driver
treat them as 2 successive wakeup irq so can't handle it correctly, then
finally the usb irq can't be enabled. This patch adds a check to bypass
further usb events before controller resume finished to fix it.
Fixes: 1f874edcb731 ("usb: chipidea: add runtime power management support")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
Changes in v2:
- no changes
---
drivers/usb/chipidea/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 7ac39a281b8c..85e9c3ab66e9 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -523,6 +523,13 @@ static irqreturn_t ci_irq_handler(int irq, void *data)
u32 otgsc = 0;
if (ci->in_lpm) {
+ /*
+ * If we already have a wakeup irq pending there,
+ * let's just return to wait resume finished firstly.
+ */
+ if (ci->wakeup_int)
+ return IRQ_HANDLED;
+
disable_irq_nosync(irq);
ci->wakeup_int = true;
pm_runtime_get(ci->dev);
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host()
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
2023-12-18 6:14 ` [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq Xu Yang
@ 2023-12-18 6:14 ` Xu Yang
2023-12-22 9:28 ` Peter Chen
2023-12-22 3:40 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Peter Chen
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Xu Yang @ 2023-12-18 6:14 UTC (permalink / raw)
To: peter.chen
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
When CONFIG_USB_OTG is not set, mxs_phy_is_otg_host() will always return
false. This behaviour is wrong. Since phy.last_event will always be set
for either host or device mode. Therefore, CONFIG_USB_OTG condition
can be removed.
Fixes: 5eda42aebb76 ("usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host()")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- add fix tag and stable maillist
---
drivers/usb/phy/phy-mxs-usb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index acd46b72899e..920a32cd094d 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -388,8 +388,7 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
{
- return IS_ENABLED(CONFIG_USB_OTG) &&
- mxs_phy->phy.last_event == USB_EVENT_ID;
+ return mxs_phy->phy.last_event == USB_EVENT_ID;
}
static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
2023-12-18 6:14 ` [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq Xu Yang
2023-12-18 6:14 ` [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host() Xu Yang
@ 2023-12-22 3:40 ` Peter Chen
2023-12-22 8:24 ` [EXT] " Xu Yang
2023-12-22 9:25 ` Peter Chen
2023-12-22 12:26 ` Stefan Wahren
4 siblings, 1 reply; 10+ messages in thread
From: Peter Chen @ 2023-12-22 3:40 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
On 23-12-18 14:14:18, Xu Yang wrote:
> Some platform using ChipIdea IP may keep 32KHz wakeup clock always
> on without usb driver intervention. And some may need driver to handle
> this clock. For now only i.MX93 needs this wakeup clock. This patch will
> get wakeup clock and keep it always on to make controller work properly.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - modify commit msg to make it clear
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index e28bb2f2612d..4330be8240ff 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
> struct usb_phy *phy;
> struct platform_device *ci_pdev;
> struct clk *clk;
> + struct clk *clk_wakeup;
> struct imx_usbmisc_data *usbmisc_data;
> bool supports_runtime_pm;
> bool override_phy_control;
> @@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
>
> data->clk_ipg = devm_clk_get(dev, "ipg");
> if (IS_ERR(data->clk_ipg)) {
> - /* If the platform only needs one clocks */
> + /* If the platform only needs one primary clock */
> data->clk = devm_clk_get(dev, NULL);
> if (IS_ERR(data->clk)) {
> ret = PTR_ERR(data->clk);
> @@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
> PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
> return ret;
> }
> + /* Get wakeup clock. Not all of the platforms need to
> + * handle this clock. So make it optional.
> + */
> + data->clk_wakeup = devm_clk_get_optional(dev,
> + "usb_wakeup_clk");
> + if (IS_ERR(data->clk_wakeup)) {
> + ret = PTR_ERR(data->clk_wakeup);
> + dev_err(dev,
> + "Failed to get wakeup clk, err=%ld\n",
> + PTR_ERR(data->clk_wakeup));
> + return ret;
> + }
> return ret;
> }
>
> @@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> if (ret)
> goto disable_hsic_regulator;
>
> + ret = clk_prepare_enable(data->clk_wakeup);
> + if (ret)
> + goto err_wakeup_clk;
> +
Better add at function imx_prepare_enable_clks()
> data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> if (IS_ERR(data->phy)) {
> ret = PTR_ERR(data->phy);
> @@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> disable_device:
> ci_hdrc_remove_device(data->ci_pdev);
> err_clk:
> + clk_disable_unprepare(data->clk_wakeup);
> +err_wakeup_clk:
Better add clk_disable_unprepare for wakeup clk at function
imx_disable_unprepare_clks();
Peter
> imx_disable_unprepare_clks(dev);
> disable_hsic_regulator:
> if (data->hsic_pad_regulator)
> @@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
> usb_phy_shutdown(data->phy);
> if (data->ci_pdev) {
> imx_disable_unprepare_clks(&pdev->dev);
> + clk_disable_unprepare(data->clk_wakeup);
> if (data->plat_data->flags & CI_HDRC_PMQOS)
> cpu_latency_qos_remove_request(&data->pm_qos_req);
> if (data->hsic_pad_regulator)
> --
> 2.34.1
>
>
--
Thanks,
Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq
2023-12-18 6:14 ` [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq Xu Yang
@ 2023-12-22 3:41 ` Peter Chen
0 siblings, 0 replies; 10+ messages in thread
From: Peter Chen @ 2023-12-22 3:41 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
On 23-12-18 14:14:19, Xu Yang wrote:
> After the chipidea driver introduce extcon for id and vbus, it's able
> to wakeup from another irq source, in case the system with extcon ID
> cable, wakeup from usb ID cable and device removal, the usb device
> disconnect irq may come firstly before the extcon notifier while system
> resume, so we will get 2 "wakeup" irq, one for usb device disconnect;
> and one for extcon ID cable change(real wakeup event), current driver
> treat them as 2 successive wakeup irq so can't handle it correctly, then
> finally the usb irq can't be enabled. This patch adds a check to bypass
> further usb events before controller resume finished to fix it.
>
> Fixes: 1f874edcb731 ("usb: chipidea: add runtime power management support")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
>
> ---
> Changes in v2:
> - no changes
> ---
> drivers/usb/chipidea/core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 7ac39a281b8c..85e9c3ab66e9 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -523,6 +523,13 @@ static irqreturn_t ci_irq_handler(int irq, void *data)
> u32 otgsc = 0;
>
> if (ci->in_lpm) {
> + /*
> + * If we already have a wakeup irq pending there,
> + * let's just return to wait resume finished firstly.
> + */
> + if (ci->wakeup_int)
> + return IRQ_HANDLED;
> +
> disable_irq_nosync(irq);
> ci->wakeup_int = true;
> pm_runtime_get(ci->dev);
> --
> 2.34.1
>
--
Thanks,
Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [EXT] Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
2023-12-22 3:40 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Peter Chen
@ 2023-12-22 8:24 ` Xu Yang
0 siblings, 0 replies; 10+ messages in thread
From: Xu Yang @ 2023-12-22 8:24 UTC (permalink / raw)
To: Peter Chen
Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, festevam@gmail.com, dl-linux-imx,
luca.ceresoli@bootlin.com, Jun Li, linux-usb@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Hi Peter,
>
> On 23-12-18 14:14:18, Xu Yang wrote:
> > Some platform using ChipIdea IP may keep 32KHz wakeup clock always
> > on without usb driver intervention. And some may need driver to handle
> > this clock. For now only i.MX93 needs this wakeup clock. This patch will
> > get wakeup clock and keep it always on to make controller work properly.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >
> > ---
> > Changes in v2:
> > - modify commit msg to make it clear
> > ---
> > drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
> > 1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> > index e28bb2f2612d..4330be8240ff 100644
> > --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> > +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> > @@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
> > struct usb_phy *phy;
> > struct platform_device *ci_pdev;
> > struct clk *clk;
> > + struct clk *clk_wakeup;
> > struct imx_usbmisc_data *usbmisc_data;
> > bool supports_runtime_pm;
> > bool override_phy_control;
> > @@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
> >
> > data->clk_ipg = devm_clk_get(dev, "ipg");
> > if (IS_ERR(data->clk_ipg)) {
> > - /* If the platform only needs one clocks */
> > + /* If the platform only needs one primary clock */
> > data->clk = devm_clk_get(dev, NULL);
> > if (IS_ERR(data->clk)) {
> > ret = PTR_ERR(data->clk);
> > @@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
> > PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
> > return ret;
> > }
> > + /* Get wakeup clock. Not all of the platforms need to
> > + * handle this clock. So make it optional.
> > + */
> > + data->clk_wakeup = devm_clk_get_optional(dev,
> > + "usb_wakeup_clk");
> > + if (IS_ERR(data->clk_wakeup)) {
> > + ret = PTR_ERR(data->clk_wakeup);
> > + dev_err(dev,
> > + "Failed to get wakeup clk, err=%ld\n",
> > + PTR_ERR(data->clk_wakeup));
> > + return ret;
> > + }
> > return ret;
> > }
> >
> > @@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> > if (ret)
> > goto disable_hsic_regulator;
> >
> > + ret = clk_prepare_enable(data->clk_wakeup);
> > + if (ret)
> > + goto err_wakeup_clk;
> > +
>
> Better add at function imx_prepare_enable_clks()
>
> > data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> > if (IS_ERR(data->phy)) {
> > ret = PTR_ERR(data->phy);
> > @@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> > disable_device:
> > ci_hdrc_remove_device(data->ci_pdev);
> > err_clk:
> > + clk_disable_unprepare(data->clk_wakeup);
> > +err_wakeup_clk:
>
>
> Better add clk_disable_unprepare for wakeup clk at function
> imx_disable_unprepare_clks();
According to IC degin's suggestion, 32K clock should be enabled
all the time. Since imx_prepare_enable_clks and imx_disable_unprepare_clks()
will be dynamiclly called in runtime/system PM cases, I don't want
32K clock go though such path. Therefore, I didn't put clk_prepare_enable/
clk_disable_unprepare() in that functions.
Thanks,
Xu Yang
>
> Peter
>
> > imx_disable_unprepare_clks(dev);
> > disable_hsic_regulator:
> > if (data->hsic_pad_regulator)
> > @@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
> > usb_phy_shutdown(data->phy);
> > if (data->ci_pdev) {
> > imx_disable_unprepare_clks(&pdev->dev);
> > + clk_disable_unprepare(data->clk_wakeup);
> > if (data->plat_data->flags & CI_HDRC_PMQOS)
> > cpu_latency_qos_remove_request(&data->pm_qos_req);
> > if (data->hsic_pad_regulator)
> > --
> > 2.34.1
> >
> >
>
> --
>
> Thanks,
> Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
` (2 preceding siblings ...)
2023-12-22 3:40 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Peter Chen
@ 2023-12-22 9:25 ` Peter Chen
2023-12-22 12:26 ` Stefan Wahren
4 siblings, 0 replies; 10+ messages in thread
From: Peter Chen @ 2023-12-22 9:25 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
On 23-12-18 14:14:18, Xu Yang wrote:
> Some platform using ChipIdea IP may keep 32KHz wakeup clock always
> on without usb driver intervention. And some may need driver to handle
> this clock. For now only i.MX93 needs this wakeup clock. This patch will
> get wakeup clock and keep it always on to make controller work properly.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
>
> ---
> Changes in v2:
> - modify commit msg to make it clear
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index e28bb2f2612d..4330be8240ff 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
> struct usb_phy *phy;
> struct platform_device *ci_pdev;
> struct clk *clk;
> + struct clk *clk_wakeup;
> struct imx_usbmisc_data *usbmisc_data;
> bool supports_runtime_pm;
> bool override_phy_control;
> @@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
>
> data->clk_ipg = devm_clk_get(dev, "ipg");
> if (IS_ERR(data->clk_ipg)) {
> - /* If the platform only needs one clocks */
> + /* If the platform only needs one primary clock */
> data->clk = devm_clk_get(dev, NULL);
> if (IS_ERR(data->clk)) {
> ret = PTR_ERR(data->clk);
> @@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
> PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
> return ret;
> }
> + /* Get wakeup clock. Not all of the platforms need to
> + * handle this clock. So make it optional.
> + */
> + data->clk_wakeup = devm_clk_get_optional(dev,
> + "usb_wakeup_clk");
> + if (IS_ERR(data->clk_wakeup)) {
> + ret = PTR_ERR(data->clk_wakeup);
> + dev_err(dev,
> + "Failed to get wakeup clk, err=%ld\n",
> + PTR_ERR(data->clk_wakeup));
> + return ret;
> + }
> return ret;
> }
>
> @@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> if (ret)
> goto disable_hsic_regulator;
>
> + ret = clk_prepare_enable(data->clk_wakeup);
> + if (ret)
> + goto err_wakeup_clk;
> +
> data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> if (IS_ERR(data->phy)) {
> ret = PTR_ERR(data->phy);
> @@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> disable_device:
> ci_hdrc_remove_device(data->ci_pdev);
> err_clk:
> + clk_disable_unprepare(data->clk_wakeup);
> +err_wakeup_clk:
> imx_disable_unprepare_clks(dev);
> disable_hsic_regulator:
> if (data->hsic_pad_regulator)
> @@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
> usb_phy_shutdown(data->phy);
> if (data->ci_pdev) {
> imx_disable_unprepare_clks(&pdev->dev);
> + clk_disable_unprepare(data->clk_wakeup);
> if (data->plat_data->flags & CI_HDRC_PMQOS)
> cpu_latency_qos_remove_request(&data->pm_qos_req);
> if (data->hsic_pad_regulator)
> --
> 2.34.1
>
>
--
Thanks,
Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host()
2023-12-18 6:14 ` [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host() Xu Yang
@ 2023-12-22 9:28 ` Peter Chen
0 siblings, 0 replies; 10+ messages in thread
From: Peter Chen @ 2023-12-22 9:28 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
On 23-12-18 14:14:20, Xu Yang wrote:
> When CONFIG_USB_OTG is not set, mxs_phy_is_otg_host() will always return
> false. This behaviour is wrong. Since phy.last_event will always be set
> for either host or device mode. Therefore, CONFIG_USB_OTG condition
> can be removed.
>
> Fixes: 5eda42aebb76 ("usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host()")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
>
> ---
> Changes in v2:
> - add fix tag and stable maillist
> ---
> drivers/usb/phy/phy-mxs-usb.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index acd46b72899e..920a32cd094d 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -388,8 +388,7 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
>
> static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
> {
> - return IS_ENABLED(CONFIG_USB_OTG) &&
> - mxs_phy->phy.last_event == USB_EVENT_ID;
> + return mxs_phy->phy.last_event == USB_EVENT_ID;
> }
>
> static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
> --
> 2.34.1
>
--
Thanks,
Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
` (3 preceding siblings ...)
2023-12-22 9:25 ` Peter Chen
@ 2023-12-22 12:26 ` Stefan Wahren
2023-12-25 2:20 ` [EXT] " Xu Yang
4 siblings, 1 reply; 10+ messages in thread
From: Stefan Wahren @ 2023-12-22 12:26 UTC (permalink / raw)
To: Xu Yang, peter.chen
Cc: gregkh, shawnguo, s.hauer, festevam, linux-imx, luca.ceresoli,
jun.li, linux-usb, linux-arm-kernel
Hi Xu,
Am 18.12.23 um 07:14 schrieb Xu Yang:
> Some platform using ChipIdea IP may keep 32KHz wakeup clock always
> on without usb driver intervention. And some may need driver to handle
> this clock. For now only i.MX93 needs this wakeup clock. This patch will
> get wakeup clock and keep it always on to make controller work properly.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>
> ---
> Changes in v2:
> - modify commit msg to make it clear
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index e28bb2f2612d..4330be8240ff 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
> struct usb_phy *phy;
> struct platform_device *ci_pdev;
> struct clk *clk;
> + struct clk *clk_wakeup;
> struct imx_usbmisc_data *usbmisc_data;
> bool supports_runtime_pm;
> bool override_phy_control;
> @@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
>
> data->clk_ipg = devm_clk_get(dev, "ipg");
> if (IS_ERR(data->clk_ipg)) {
> - /* If the platform only needs one clocks */
> + /* If the platform only needs one primary clock */
> data->clk = devm_clk_get(dev, NULL);
> if (IS_ERR(data->clk)) {
> ret = PTR_ERR(data->clk);
> @@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
> PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
> return ret;
> }
> + /* Get wakeup clock. Not all of the platforms need to
> + * handle this clock. So make it optional.
> + */
> + data->clk_wakeup = devm_clk_get_optional(dev,
> + "usb_wakeup_clk");
> + if (IS_ERR(data->clk_wakeup)) {
> + ret = PTR_ERR(data->clk_wakeup);
> + dev_err(dev,
> + "Failed to get wakeup clk, err=%ld\n",
> + PTR_ERR(data->clk_wakeup));
> + return ret;
this could be simplified to:
return dev_err_probe(dev, PTR_ERR(data->clk_wakeup), "Failed to get
wakeup clk\n");
AFAIK the error code is also printed out. Another benefit is that this
handles deferred probe of the clock and avoid spamming.
> + }
> return ret;
> }
>
> @@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> if (ret)
> goto disable_hsic_regulator;
>
> + ret = clk_prepare_enable(data->clk_wakeup);
> + if (ret)
> + goto err_wakeup_clk;
> +
> data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> if (IS_ERR(data->phy)) {
> ret = PTR_ERR(data->phy);
> @@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> disable_device:
> ci_hdrc_remove_device(data->ci_pdev);
> err_clk:
> + clk_disable_unprepare(data->clk_wakeup);
> +err_wakeup_clk:
> imx_disable_unprepare_clks(dev);
> disable_hsic_regulator:
> if (data->hsic_pad_regulator)
> @@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
> usb_phy_shutdown(data->phy);
> if (data->ci_pdev) {
> imx_disable_unprepare_clks(&pdev->dev);
> + clk_disable_unprepare(data->clk_wakeup);
> if (data->plat_data->flags & CI_HDRC_PMQOS)
> cpu_latency_qos_remove_request(&data->pm_qos_req);
> if (data->hsic_pad_regulator)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [EXT] Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on
2023-12-22 12:26 ` Stefan Wahren
@ 2023-12-25 2:20 ` Xu Yang
0 siblings, 0 replies; 10+ messages in thread
From: Xu Yang @ 2023-12-25 2:20 UTC (permalink / raw)
To: Stefan Wahren, peter.chen@kernel.org
Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, festevam@gmail.com, dl-linux-imx,
luca.ceresoli@bootlin.com, Jun Li, linux-usb@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Hi Stefan,
>
> Hi Xu,
>
> Am 18.12.23 um 07:14 schrieb Xu Yang:
> > Some platform using ChipIdea IP may keep 32KHz wakeup clock always
> > on without usb driver intervention. And some may need driver to handle
> > this clock. For now only i.MX93 needs this wakeup clock. This patch will
> > get wakeup clock and keep it always on to make controller work properly.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >
> > ---
> > Changes in v2:
> > - modify commit msg to make it clear
> > ---
> > drivers/usb/chipidea/ci_hdrc_imx.c | 22 +++++++++++++++++++++-
> > 1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> > index e28bb2f2612d..4330be8240ff 100644
> > --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> > +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> > @@ -96,6 +96,7 @@ struct ci_hdrc_imx_data {
> > struct usb_phy *phy;
> > struct platform_device *ci_pdev;
> > struct clk *clk;
> > + struct clk *clk_wakeup;
> > struct imx_usbmisc_data *usbmisc_data;
> > bool supports_runtime_pm;
> > bool override_phy_control;
> > @@ -199,7 +200,7 @@ static int imx_get_clks(struct device *dev)
> >
> > data->clk_ipg = devm_clk_get(dev, "ipg");
> > if (IS_ERR(data->clk_ipg)) {
> > - /* If the platform only needs one clocks */
> > + /* If the platform only needs one primary clock */
> > data->clk = devm_clk_get(dev, NULL);
> > if (IS_ERR(data->clk)) {
> > ret = PTR_ERR(data->clk);
> > @@ -208,6 +209,18 @@ static int imx_get_clks(struct device *dev)
> > PTR_ERR(data->clk), PTR_ERR(data->clk_ipg));
> > return ret;
> > }
> > + /* Get wakeup clock. Not all of the platforms need to
> > + * handle this clock. So make it optional.
> > + */
> > + data->clk_wakeup = devm_clk_get_optional(dev,
> > + "usb_wakeup_clk");
> > + if (IS_ERR(data->clk_wakeup)) {
> > + ret = PTR_ERR(data->clk_wakeup);
> > + dev_err(dev,
> > + "Failed to get wakeup clk, err=%ld\n",
> > + PTR_ERR(data->clk_wakeup));
> > + return ret;
> this could be simplified to:
>
> return dev_err_probe(dev, PTR_ERR(data->clk_wakeup), "Failed to get
> wakeup clk\n");
>
> AFAIK the error code is also printed out. Another benefit is that this
> handles deferred probe of the clock and avoid spamming.
Okay, I will try this.
Thanks,
Xu Yang
> > + }
> > return ret;
> > }
> >
> > @@ -423,6 +436,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> > if (ret)
> > goto disable_hsic_regulator;
> >
> > + ret = clk_prepare_enable(data->clk_wakeup);
> > + if (ret)
> > + goto err_wakeup_clk;
> > +
> > data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> > if (IS_ERR(data->phy)) {
> > ret = PTR_ERR(data->phy);
> > @@ -504,6 +521,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> > disable_device:
> > ci_hdrc_remove_device(data->ci_pdev);
> > err_clk:
> > + clk_disable_unprepare(data->clk_wakeup);
> > +err_wakeup_clk:
> > imx_disable_unprepare_clks(dev);
> > disable_hsic_regulator:
> > if (data->hsic_pad_regulator)
> > @@ -530,6 +549,7 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
> > usb_phy_shutdown(data->phy);
> > if (data->ci_pdev) {
> > imx_disable_unprepare_clks(&pdev->dev);
> > + clk_disable_unprepare(data->clk_wakeup);
> > if (data->plat_data->flags & CI_HDRC_PMQOS)
> > cpu_latency_qos_remove_request(&data->pm_qos_req);
> > if (data->hsic_pad_regulator)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-12-25 2:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-18 6:14 [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Xu Yang
2023-12-18 6:14 ` [PATCH v2 2/3] usb: chipidea: wait controller resume finished for wakeup irq Xu Yang
2023-12-22 3:41 ` Peter Chen
2023-12-18 6:14 ` [PATCH v2 3/3] usb: phy: mxs: remove CONFIG_USB_OTG condition for mxs_phy_is_otg_host() Xu Yang
2023-12-22 9:28 ` Peter Chen
2023-12-22 3:40 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: add wakeup clock and keep it always on Peter Chen
2023-12-22 8:24 ` [EXT] " Xu Yang
2023-12-22 9:25 ` Peter Chen
2023-12-22 12:26 ` Stefan Wahren
2023-12-25 2:20 ` [EXT] " Xu Yang
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).