From: Peter Chen <peter.chen@nxp.com>
To: Jun Li <jun.li@nxp.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
"festevam@gmail.com" <festevam@gmail.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
dl-linux-imx <linux-imx@nxp.com>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/6] usb: dwc3: add imx8mp dwc3 glue layer driver
Date: Wed, 10 Jun 2020 02:59:31 +0000 [thread overview]
Message-ID: <20200610025955.GB18494@b29397-desktop> (raw)
In-Reply-To: <1591701165-12872-4-git-send-email-jun.li@nxp.com>
On 20-06-09 19:12:42, Li Jun wrote:
> +
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + err = pm_runtime_get_sync(dev);
> + if (err < 0)
> + goto disable_rpm;
> +
> + dwc3_np = of_get_child_by_name(node, "dwc3");
> + if (!dwc3_np) {
> + dev_err(dev, "failed to find dwc3 core child\n");
> + goto disable_rpm;
> + }
You may call of_node_put() for dwc3_np after using.
> +
> + err = of_platform_populate(node, NULL, NULL, dev);
> + if (err) {
> + dev_err(&pdev->dev, "failed to create dwc3 core\n");
> + goto disable_rpm;
> + }
> +
> + dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np);
> + if (!dwc3_imx->dwc3) {
> + dev_err(dev, "failed to get dwc3 platform device\n");
> + err = -ENODEV;
> + goto depopulate;
> + }
> +
> + device_set_wakeup_capable(dev, true);
> + pm_runtime_put(dev);
> +
> + return 0;
> +
> +depopulate:
> + of_platform_depopulate(dev);
> +disable_rpm:
> + pm_runtime_disable(dev);
> + pm_runtime_put_noidle(dev);
> +disable_clks:
> + clk_disable_unprepare(dwc3_imx->clks[dwc3_imx->num_clks-1].clk);
> +disable_bulk_clk:
> + clk_bulk_disable_unprepare(dwc3_imx->num_clks, dwc3_imx->clks);
> +
> + return err;
> +}
> +
> +static int dwc3_imx8mp_remove(struct platform_device *pdev)
> +{
> + struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
> + struct device *dev = &pdev->dev;
> +
> + pm_runtime_get_sync(dev);
> + of_platform_depopulate(dev);
> +
> + clk_bulk_disable_unprepare(dwc3_imx->num_clks, dwc3_imx->clks);
> + clk_disable_unprepare(dwc3_imx->clks[dwc3_imx->num_clks-1].clk);
> +
> + pm_runtime_disable(dev);
> + pm_runtime_put_noidle(dev);
> + platform_set_drvdata(pdev, NULL);
> +
> + return 0;
> +}
> +
> +static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
> +{
> + if (dwc3_imx->pm_suspended)
> + return 0;
> +
> + /* Wakeup enable */
> + if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev))
> + dwc3_imx8mp_wakeup_enable(dwc3_imx);
> +
> + clk_bulk_disable_unprepare(dwc3_imx->num_clks, dwc3_imx->clks);
> + dwc3_imx->pm_suspended = true;
> +
> + return 0;
> +}
> +
> +static int dwc3_imx8mp_resume(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg)
> +{
> + struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3);
> + int ret = 0;
> +
> + if (!dwc3_imx->pm_suspended)
> + return 0;
> +
> + ret = clk_bulk_prepare_enable(dwc3_imx->num_clks, dwc3_imx->clks);
> + if (ret)
> + return ret;
> +
> + /* Wakeup disable */
> + dwc3_imx8mp_wakeup_disable(dwc3_imx);
> + dwc3_imx->pm_suspended = false;
> +
> + if (dwc3_imx->wakeup_pending) {
> + dwc3_imx->wakeup_pending = false;
> + if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) {
> + pm_runtime_mark_last_busy(dwc->dev);
> + pm_runtime_put_autosuspend(dwc->dev);
> + } else {
> + /*
> + * Add wait for xhci switch from suspend
> + * clock to normal clock to detect connection.
> + */
> + usleep_range(9000, 10000);
> + }
> + enable_irq(dwc3_imx->irq);
> + }
> +
> + return ret;
> +}
> +
You may need to add __maybe_unused for above two functions.
Peter
> +static int __maybe_unused dwc3_imx8mp_pm_suspend(struct device *dev)
> +{
> + struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = dwc3_imx8mp_suspend(dwc3_imx, PMSG_SUSPEND);
> +
> + if (device_may_wakeup(dwc3_imx->dev))
> + enable_irq_wake(dwc3_imx->irq);
> +
> + dev_dbg(dev, "dwc3 imx8mp pm suspend.\n");
> +
> + return ret;
> +}
> +
> +static int __maybe_unused dwc3_imx8mp_pm_resume(struct device *dev)
> +{
> + struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev);
> + int ret;
> +
> + if (device_may_wakeup(dwc3_imx->dev))
> + disable_irq_wake(dwc3_imx->irq);
> +
> + ret = dwc3_imx8mp_resume(dwc3_imx, PMSG_RESUME);
> +
> + pm_runtime_disable(dev);
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> +
> + dev_dbg(dev, "dwc3 imx8mp pm resume.\n");
> +
> + return ret;
> +}
> +
> +static int __maybe_unused dwc3_imx8mp_runtime_suspend(struct device *dev)
> +{
> + struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev);
> +
> + dev_dbg(dev, "dwc3 imx8mp runtime suspend.\n");
> +
> + return dwc3_imx8mp_suspend(dwc3_imx, PMSG_AUTO_SUSPEND);
> +}
> +
> +static int __maybe_unused dwc3_imx8mp_runtime_resume(struct device *dev)
> +{
> + struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev);
> +
> + dev_dbg(dev, "dwc3 imx8mp runtime resume.\n");
> +
> + return dwc3_imx8mp_resume(dwc3_imx, PMSG_AUTO_RESUME);
> +}
> +
> +static const struct dev_pm_ops dwc3_imx8mp_dev_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(dwc3_imx8mp_pm_suspend, dwc3_imx8mp_pm_resume)
> + SET_RUNTIME_PM_OPS(dwc3_imx8mp_runtime_suspend,
> + dwc3_imx8mp_runtime_resume, NULL)
> +};
> +
> +static const struct of_device_id dwc3_imx8mp_of_match[] = {
> + { .compatible = "fsl,imx8mp-dwc3", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, dwc3_imx8mp_of_match);
> +
> +static struct platform_driver dwc3_imx8mp_driver = {
> + .probe = dwc3_imx8mp_probe,
> + .remove = dwc3_imx8mp_remove,
> + .driver = {
> + .name = "imx8mp-dwc3",
> + .pm = &dwc3_imx8mp_dev_pm_ops,
> + .of_match_table = dwc3_imx8mp_of_match,
> + },
> +};
> +
> +module_platform_driver(dwc3_imx8mp_driver);
> +
> +MODULE_ALIAS("platform:imx8mp-dwc3");
> +MODULE_AUTHOR("jun.li@nxp.com");
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("DesignWare USB3 imx8mp Glue Layer");
> --
> 2.7.4
>
--
Thanks,
Peter Chen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-06-10 2:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 11:12 [PATCH 0/6] add NXP imx8mp usb support Li Jun
2020-06-09 11:12 ` [PATCH 1/6] dt-bindings: usb: dwc3: add property to disable xhci 64bit support Li Jun
2020-06-10 2:47 ` Peter Chen
2020-06-10 4:22 ` Florian Fainelli
2020-07-06 9:56 ` Jun Li
2020-06-09 11:12 ` [PATCH 2/6] usb: host: xhci-plat: add quirk for XHCI_NO_64BIT_SUPPORT Li Jun
2020-06-09 11:12 ` [PATCH 3/6] usb: dwc3: add imx8mp dwc3 glue layer driver Li Jun
2020-06-10 2:59 ` Peter Chen [this message]
2020-06-09 11:12 ` [PATCH 4/6] arm64: dtsi: imx8mp: add usb nodes Li Jun
2020-06-09 11:12 ` [PATCH 5/6] arm64: dts: imx8mp-evk: enable usb1 as host mode Li Jun
2020-06-09 11:12 ` [PATCH 6/6] dt-bindings: usb: dwc3-imx8mp: add imx8mp dwc3 glue bindings Li Jun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200610025955.GB18494@b29397-desktop \
--to=peter.chen@nxp.com \
--cc=balbi@kernel.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jun.li@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).