Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: gemini: Add optional clock handling

This makes the Gemini optionally take two clock references to
the PCLK and EXTCLK. As we are adding a clock framework to the
Gemini platform we need to make sure that we get the right
references.

Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Linus Walleij and committed by
Alexandre Belloni
ac05fba3 e48585de

+28
+28
drivers/rtc/rtc-gemini.c
··· 26 26 #include <linux/platform_device.h> 27 27 #include <linux/kernel.h> 28 28 #include <linux/module.h> 29 + #include <linux/clk.h> 29 30 30 31 #define DRV_NAME "rtc-gemini" 31 32 ··· 39 38 struct rtc_device *rtc_dev; 40 39 void __iomem *rtc_base; 41 40 int rtc_irq; 41 + struct clk *pclk; 42 + struct clk *extclk; 42 43 }; 43 44 44 45 enum gemini_rtc_offsets { ··· 130 127 return -ENOMEM; 131 128 platform_set_drvdata(pdev, rtc); 132 129 130 + rtc->pclk = devm_clk_get(dev, "PCLK"); 131 + if (IS_ERR(rtc->pclk)) { 132 + dev_err(dev, "could not get PCLK\n"); 133 + } else { 134 + ret = clk_prepare_enable(rtc->pclk); 135 + if (ret) { 136 + dev_err(dev, "failed to enable PCLK\n"); 137 + return ret; 138 + } 139 + } 140 + rtc->extclk = devm_clk_get(dev, "EXTCLK"); 141 + if (IS_ERR(rtc->extclk)) { 142 + dev_err(dev, "could not get EXTCLK\n"); 143 + } else { 144 + ret = clk_prepare_enable(rtc->extclk); 145 + if (ret) { 146 + dev_err(dev, "failed to enable EXTCLK\n"); 147 + return ret; 148 + } 149 + } 150 + 133 151 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 134 152 if (!res) 135 153 return -ENODEV; ··· 180 156 { 181 157 struct gemini_rtc *rtc = platform_get_drvdata(pdev); 182 158 159 + if (!IS_ERR(rtc->extclk)) 160 + clk_disable_unprepare(rtc->extclk); 161 + if (!IS_ERR(rtc->pclk)) 162 + clk_disable_unprepare(rtc->pclk); 183 163 rtc_device_unregister(rtc->rtc_dev); 184 164 185 165 return 0;