mirror of
https://github.com/torvalds/linux.git
synced 2024-12-19 17:41:29 +00:00
USB: host: ehci-atmel: Add suspend/resume support
This patch add suspend/resume support for Atmel EHCI, mostly about disabling and unpreparing clocks so USB PLL is stopped before entering sleep state. Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fbaecff06a
commit
ca2c1dc04b
@ -37,6 +37,8 @@ static int clocked;
|
|||||||
|
|
||||||
static void atmel_start_clock(void)
|
static void atmel_start_clock(void)
|
||||||
{
|
{
|
||||||
|
if (clocked)
|
||||||
|
return;
|
||||||
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
|
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
|
||||||
clk_set_rate(uclk, 48000000);
|
clk_set_rate(uclk, 48000000);
|
||||||
clk_prepare_enable(uclk);
|
clk_prepare_enable(uclk);
|
||||||
@ -48,6 +50,8 @@ static void atmel_start_clock(void)
|
|||||||
|
|
||||||
static void atmel_stop_clock(void)
|
static void atmel_stop_clock(void)
|
||||||
{
|
{
|
||||||
|
if (!clocked)
|
||||||
|
return;
|
||||||
clk_disable_unprepare(fclk);
|
clk_disable_unprepare(fclk);
|
||||||
clk_disable_unprepare(iclk);
|
clk_disable_unprepare(iclk);
|
||||||
if (IS_ENABLED(CONFIG_COMMON_CLK))
|
if (IS_ENABLED(CONFIG_COMMON_CLK))
|
||||||
@ -174,6 +178,29 @@ static int ehci_atmel_drv_remove(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static int ehci_atmel_drv_suspend(struct device *dev)
|
||||||
|
{
|
||||||
|
struct usb_hcd *hcd = dev_get_drvdata(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = ehci_suspend(hcd, false);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
atmel_stop_clock();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ehci_atmel_drv_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct usb_hcd *hcd = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
atmel_start_clock();
|
||||||
|
return ehci_resume(hcd, false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
static const struct of_device_id atmel_ehci_dt_ids[] = {
|
static const struct of_device_id atmel_ehci_dt_ids[] = {
|
||||||
{ .compatible = "atmel,at91sam9g45-ehci" },
|
{ .compatible = "atmel,at91sam9g45-ehci" },
|
||||||
@ -183,12 +210,16 @@ static const struct of_device_id atmel_ehci_dt_ids[] = {
|
|||||||
MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
|
MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend,
|
||||||
|
ehci_atmel_drv_resume);
|
||||||
|
|
||||||
static struct platform_driver ehci_atmel_driver = {
|
static struct platform_driver ehci_atmel_driver = {
|
||||||
.probe = ehci_atmel_drv_probe,
|
.probe = ehci_atmel_drv_probe,
|
||||||
.remove = ehci_atmel_drv_remove,
|
.remove = ehci_atmel_drv_remove,
|
||||||
.shutdown = usb_hcd_platform_shutdown,
|
.shutdown = usb_hcd_platform_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "atmel-ehci",
|
.name = "atmel-ehci",
|
||||||
|
.pm = &ehci_atmel_pm_ops,
|
||||||
.of_match_table = of_match_ptr(atmel_ehci_dt_ids),
|
.of_match_table = of_match_ptr(atmel_ehci_dt_ids),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user