From: Al Cooper <alcooperx@gmail.com> To: linux-kernel@vger.kernel.org Cc: Al Cooper <alcooperx@gmail.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Felipe Balbi <balbi@kernel.org>, yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>, Florian Fainelli <f.fainelli@gmail.com>, linux-usb@vger.kernel.org (open list:USB SUBSYSTEM), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), bcm-kernel-feedback-list@broadcom.com Subject: [PATCH 6/8] usb: bdc: Add support for suspend/resume Date: Tue, 27 Jun 2017 14:23:24 -0400 [thread overview] Message-ID: <1498587806-24781-7-git-send-email-alcooperx@gmail.com> (raw) In-Reply-To: <1498587806-24781-1-git-send-email-alcooperx@gmail.com> Based on a previous commit by Danesh Petigara <dpetigara@broadcom.com> that added resume to solve the following problem: "The BDC driver will fail after resuming from S3 suspend and this will cause any upper layer gadget driver to fail." This commit also adds support for suspend and manages the clock during suspend/resume. Signed-off-by: Al Cooper <alcooperx@gmail.com> --- drivers/usb/gadget/udc/bdc/bdc.h | 1 + drivers/usb/gadget/udc/bdc/bdc_core.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h index 3664808..f838647 100644 --- a/drivers/usb/gadget/udc/bdc/bdc.h +++ b/drivers/usb/gadget/udc/bdc/bdc.h @@ -454,6 +454,7 @@ struct bdc { * Func Wake packet every 2.5 secs. Refer to USB3 spec section 8.5.6.4 */ struct delayed_work func_wake_notify; + struct clk *clk; }; static inline u32 bdc_readl(void __iomem *base, u32 offset) diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 1714bd3..021c0e7 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -473,6 +473,8 @@ static int bdc_probe(struct platform_device *pdev) if (!bdc) return -ENOMEM; + bdc->clk = clk; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); bdc->regs = devm_ioremap_resource(dev, res); if (IS_ERR(bdc->regs)) { @@ -529,10 +531,43 @@ static int bdc_remove(struct platform_device *pdev) dev_dbg(bdc->dev, "%s ()\n", __func__); bdc_udc_exit(bdc); bdc_hw_exit(bdc); + clk_disable_unprepare(bdc->clk); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int bdc_suspend(struct device *dev) +{ + struct bdc *bdc = dev_get_drvdata(dev); + + clk_disable_unprepare(bdc->clk); + return 0; +} + +static int bdc_resume(struct device *dev) +{ + struct bdc *bdc = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(bdc->clk); + if (ret) { + dev_err(bdc->dev, "err enabling the clock\n"); + return ret; + } + ret = bdc_reinit(bdc); + if (ret) { + dev_err(bdc->dev, "err in bdc reinit\n"); + return ret; + } return 0; } +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend, + bdc_resume); + static const struct of_device_id bdc_of_match[] = { { .compatible = "brcm,bdc-udc-v0.16" }, { .compatible = "brcm,bdc-udc" }, @@ -543,6 +578,7 @@ static int bdc_remove(struct platform_device *pdev) .driver = { .name = BRCM_BDC_NAME, .owner = THIS_MODULE, + .pm = &bdc_pm_ops, .of_match_table = bdc_of_match, }, .probe = bdc_probe, -- 1.9.0.138.g2de3478
WARNING: multiple messages have this Message-ID (diff)
From: Al Cooper <alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Al Cooper <alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>, Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>, Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, yuan linyu <Linyu.Yuan-cfy2TCaE7SHLM0G2K2Xlo2/U75nxZMCp@public.gmane.org>, Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, "open list:USB SUBSYSTEM" <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org Subject: [PATCH 6/8] usb: bdc: Add support for suspend/resume Date: Tue, 27 Jun 2017 14:23:24 -0400 [thread overview] Message-ID: <1498587806-24781-7-git-send-email-alcooperx@gmail.com> (raw) In-Reply-To: <1498587806-24781-1-git-send-email-alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Based on a previous commit by Danesh Petigara <dpetigara-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> that added resume to solve the following problem: "The BDC driver will fail after resuming from S3 suspend and this will cause any upper layer gadget driver to fail." This commit also adds support for suspend and manages the clock during suspend/resume. Signed-off-by: Al Cooper <alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/usb/gadget/udc/bdc/bdc.h | 1 + drivers/usb/gadget/udc/bdc/bdc_core.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h index 3664808..f838647 100644 --- a/drivers/usb/gadget/udc/bdc/bdc.h +++ b/drivers/usb/gadget/udc/bdc/bdc.h @@ -454,6 +454,7 @@ struct bdc { * Func Wake packet every 2.5 secs. Refer to USB3 spec section 8.5.6.4 */ struct delayed_work func_wake_notify; + struct clk *clk; }; static inline u32 bdc_readl(void __iomem *base, u32 offset) diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 1714bd3..021c0e7 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -473,6 +473,8 @@ static int bdc_probe(struct platform_device *pdev) if (!bdc) return -ENOMEM; + bdc->clk = clk; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); bdc->regs = devm_ioremap_resource(dev, res); if (IS_ERR(bdc->regs)) { @@ -529,10 +531,43 @@ static int bdc_remove(struct platform_device *pdev) dev_dbg(bdc->dev, "%s ()\n", __func__); bdc_udc_exit(bdc); bdc_hw_exit(bdc); + clk_disable_unprepare(bdc->clk); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int bdc_suspend(struct device *dev) +{ + struct bdc *bdc = dev_get_drvdata(dev); + + clk_disable_unprepare(bdc->clk); + return 0; +} + +static int bdc_resume(struct device *dev) +{ + struct bdc *bdc = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(bdc->clk); + if (ret) { + dev_err(bdc->dev, "err enabling the clock\n"); + return ret; + } + ret = bdc_reinit(bdc); + if (ret) { + dev_err(bdc->dev, "err in bdc reinit\n"); + return ret; + } return 0; } +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend, + bdc_resume); + static const struct of_device_id bdc_of_match[] = { { .compatible = "brcm,bdc-udc-v0.16" }, { .compatible = "brcm,bdc-udc" }, @@ -543,6 +578,7 @@ static int bdc_remove(struct platform_device *pdev) .driver = { .name = BRCM_BDC_NAME, .owner = THIS_MODULE, + .pm = &bdc_pm_ops, .of_match_table = bdc_of_match, }, .probe = bdc_probe, -- 1.9.0.138.g2de3478 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-06-27 18:24 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-27 18:23 [PATCH 0/8] Bugs fixes and improvements to Broadcom BDC driver Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-27 18:23 ` [PATCH 1/8] usb: gadget: bdc: Fix misleading register names Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-27 18:23 ` [PATCH 2/8] usb: bdc: Add Device Tree binding document for Broadcom BDC driver Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-07-06 14:18 ` Rob Herring 2017-07-06 14:18 ` Rob Herring 2017-07-07 19:03 ` Al Cooper 2017-07-07 20:15 ` Rob Herring 2017-07-07 20:15 ` Rob Herring 2017-07-11 19:47 ` Al Cooper 2017-07-06 14:19 ` Rob Herring 2017-07-06 14:19 ` Rob Herring 2017-06-27 18:23 ` [PATCH 3/8] usb: bdc: Add clock enable for new chips with a separate BDC clock Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-27 18:23 ` [PATCH 4/8] usb: bdc: Small code cleanup Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-28 8:47 ` David Laight 2017-06-28 8:47 ` David Laight 2017-06-28 14:56 ` Al Cooper 2017-06-28 14:56 ` Al Cooper 2017-06-29 14:28 ` David Laight 2017-06-29 14:28 ` David Laight 2017-06-27 18:23 ` [PATCH 5/8] usb: gadget: bdc: hook a quick Device Tree compatible string Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-28 23:44 ` kbuild test robot 2017-06-28 23:44 ` kbuild test robot 2017-06-28 23:44 ` [PATCH] usb: gadget: bdc: fix platform_no_drv_owner.cocci warnings kbuild test robot 2017-06-28 23:44 ` kbuild test robot 2017-06-27 18:23 ` Al Cooper [this message] 2017-06-27 18:23 ` [PATCH 6/8] usb: bdc: Add support for suspend/resume Al Cooper 2017-06-27 18:23 ` [PATCH 7/8] usb: bdc: fix "xsf for ep not enabled" errror Al Cooper 2017-06-27 18:23 ` Al Cooper 2017-06-27 18:23 ` [PATCH 8/8] usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems Al Cooper 2017-06-27 18:23 ` Al Cooper
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=1498587806-24781-7-git-send-email-alcooperx@gmail.com \ --to=alcooperx@gmail.com \ --cc=Linyu.Yuan@alcatel-sbell.com.cn \ --cc=balbi@kernel.org \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=devicetree@vger.kernel.org \ --cc=f.fainelli@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=robh+dt@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.