Date: | 2012-09-13 00:09:20 (11 years 6 months ago) |
---|---|
Author: | Paul Cercueil |
Commit: | fdf31a720d6675c4f8af0396042f3c76b235218c |
Message: | RTC: JZ4740: Init the "regulator" register on startup. This register controls the accuracy of the RTC. uC/OS-II use the RTC as a 100Hz clock, and writes a completely wrong value on that register, that we have to overwrite if we want a working real-time clock. Signed-off-by: Paul Cercueil <paul@crapouillou.net> |
Files: |
drivers/rtc/rtc-jz4740.c (3 diffs) |
Change Details
drivers/rtc/rtc-jz4740.c | ||
---|---|---|
15 | 15 | */ |
16 | 16 | |
17 | 17 | #include <linux/io.h> |
18 | #include <linux/clk.h> | |
18 | 19 | #include <linux/kernel.h> |
19 | 20 | #include <linux/module.h> |
20 | 21 | #include <linux/platform_device.h> |
... | ... | |
216 | 217 | struct jz4740_rtc *rtc; |
217 | 218 | uint32_t scratchpad; |
218 | 219 | struct resource *mem; |
220 | struct clk *rtc_clk; | |
219 | 221 | |
220 | 222 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
221 | 223 | if (!rtc) |
... | ... | |
263 | 265 | } |
264 | 266 | } |
265 | 267 | |
268 | rtc_clk = clk_get(&pdev->dev, "rtc"); | |
269 | if (IS_ERR(rtc_clk)) { | |
270 | dev_err(&pdev->dev, "Failed to get RTC clock\n"); | |
271 | return PTR_ERR(rtc_clk); | |
272 | } | |
273 | ||
274 | /* TODO: initialize the ADJC bits (25:16) to fine-tune | |
275 | * the accuracy of the RTC */ | |
276 | ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_REGULATOR, | |
277 | (clk_get_rate(rtc_clk) - 1) & 0xffff); | |
278 | clk_put(rtc_clk); | |
279 | ||
280 | if (ret) | |
281 | dev_warn(&pdev->dev, "Could not update RTC regulator register\n"); | |
282 | ||
266 | 283 | return 0; |
267 | 284 | } |
268 | 285 |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9