Date:2012-09-13 00:09:20 (7 years 8 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
1515 */
1616
1717#include <linux/io.h>
18#include <linux/clk.h>
1819#include <linux/kernel.h>
1920#include <linux/module.h>
2021#include <linux/platform_device.h>
...... 
216217    struct jz4740_rtc *rtc;
217218    uint32_t scratchpad;
218219    struct resource *mem;
220    struct clk *rtc_clk;
219221
220222    rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
221223    if (!rtc)
...... 
263265        }
264266    }
265267
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
266283    return 0;
267284}
268285

Archive Download the corresponding diff file



interactive