Advertisement
Guest User

Untitled

a guest
Mar 11th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.76 KB | None | 0 0
  1. /* OMAP_RTC_OSC_REG bit fields: */
  2. #define OMAP_RTC_OSC_32KCLK_EN          BIT(6)
  3. #define OMAP_RTC_OSC_SEL_32KCLK_SRC     BIT(3)
  4. #define OMAP_RTC_OSC_OSC32K_GZ_DISABLE  BIT(4)
  5.  
  6. static int omap_rtc_probe(struct platform_device *pdev)
  7. {
  8.         ...
  9.         rtc->clk = devm_clk_get(&pdev->dev, "ext-clk");
  10.         if (!IS_ERR(rtc->clk))
  11.                 rtc->has_ext_clk = true;
  12.         else
  13.                 rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
  14.         if (!IS_ERR(rtc->clk))
  15.                 clk_prepare_enable(rtc->clk);
  16.         ...
  17.         /* enable RTC functional clock */
  18.         if (rtc->type->has_32kclk_en) {
  19.                 reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
  20.                 rtc_writel(rtc, OMAP_RTC_OSC_REG, reg | OMAP_RTC_OSC_32KCLK_EN);
  21.         }
  22.         ...
  23.         /* If we have the external clock then switch to it so we can keep ticking across suspend. */
  24.         if (rtc->has_ext_clk) {
  25.                 reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
  26.                 reg &= ~OMAP_RTC_OSC_OSC32K_GZ_DISABLE;
  27.                 reg |= OMAP_RTC_OSC_32KCLK_EN | OMAP_RTC_OSC_SEL_32KCLK_SRC;
  28.                 rtc_writel(rtc, OMAP_RTC_OSC_REG, reg);
  29.         }
  30.         ...
  31. }
  32.  
  33. static int omap_rtc_remove(struct platform_device *pdev)
  34. {
  35.         ...
  36.         if (!IS_ERR(rtc->clk))
  37.                 clk_disable_unprepare(rtc->clk);
  38.         ...
  39.         if (rtc->has_ext_clk) {
  40.                 reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
  41.                 reg &= ~OMAP_RTC_OSC_SEL_32KCLK_SRC;
  42.                 rtc_write(rtc, OMAP_RTC_OSC_REG, reg);
  43.         }
  44.         ...
  45. }
  46.  
  47. static int __maybe_unused omap_rtc_runtime_suspend(struct device *dev)
  48. {
  49.         ...
  50.         if (rtc->is_suspending && !rtc->has_ext_clk)
  51.                 return -EBUSY;
  52.         return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement