Skip to content

Commit

Permalink
rtc: omap: prevent disabling of clock/module during suspend
Browse files Browse the repository at this point in the history
If RTC is running from an internal clock source, the RTC module can't
be disabled; otherwise it stops ticking completely. Current suspend
handler implementation disables the clock/module unconditionally,
instead fix this by disabling the clock only if we are running on
external clock source, which is not affected by suspend.

The prevention of disabling the clock must be done via implementing
the runtime_pm handlers for the device, and returning an error code
from the runtime suspend handler; otherwise OMAP core PM will disable
the clocks for the driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
  • Loading branch information
Tero Kristo authored and Alexandre Belloni committed Nov 4, 2016
1 parent 3984903 commit efce21f
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions drivers/rtc/rtc-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ struct omap_rtc {
u8 interrupts_reg;
bool is_pmic_controller;
bool has_ext_clk;
bool is_suspending;
const struct omap_rtc_device_type *type;
struct pinctrl_dev *pctldev;
};
Expand Down Expand Up @@ -900,8 +901,7 @@ static int omap_rtc_suspend(struct device *dev)
rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
rtc->type->lock(rtc);

/* Disable the clock/module */
pm_runtime_put_sync(dev);
rtc->is_suspending = true;

return 0;
}
Expand All @@ -910,21 +910,41 @@ static int omap_rtc_resume(struct device *dev)
{
struct omap_rtc *rtc = dev_get_drvdata(dev);

/* Enable the clock/module so that we can access the registers */
pm_runtime_get_sync(dev);

rtc->type->unlock(rtc);
if (device_may_wakeup(dev))
disable_irq_wake(rtc->irq_alarm);
else
rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, rtc->interrupts_reg);
rtc->type->lock(rtc);

rtc->is_suspending = false;

return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(omap_rtc_pm_ops, omap_rtc_suspend, omap_rtc_resume);
#ifdef CONFIG_PM
static int omap_rtc_runtime_suspend(struct device *dev)
{
struct omap_rtc *rtc = dev_get_drvdata(dev);

if (rtc->is_suspending && !rtc->has_ext_clk)
return -EBUSY;

return 0;
}

static int omap_rtc_runtime_resume(struct device *dev)
{
return 0;
}
#endif

static const struct dev_pm_ops omap_rtc_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(omap_rtc_suspend, omap_rtc_resume)
SET_RUNTIME_PM_OPS(omap_rtc_runtime_suspend,
omap_rtc_runtime_resume, NULL)
};

static void omap_rtc_shutdown(struct platform_device *pdev)
{
Expand Down

0 comments on commit efce21f

Please sign in to comment.