Date:2012-09-13 00:09:20 (7 years 9 months ago)
Author:Paul Cercueil
Commit:c109eacb26ccee5b703ce9ee0d5d023548e3d070
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
1414 *
1515 */
1616
17#include <linux/clk.h>
1718#include <linux/kernel.h>
1819#include <linux/module.h>
1920#include <linux/platform_device.h>
...... 
215216    int ret;
216217    struct jz4740_rtc *rtc;
217218    uint32_t scratchpad;
219    struct clk *rtc_clk;
218220
219221    rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
220222    if (!rtc)
...... 
280282        }
281283    }
282284
285    rtc_clk = clk_get(&pdev->dev, "rtc");
286    if (IS_ERR(rtc_clk)) {
287        dev_err(&pdev->dev, "Failed to get RTC clock\n");
288        goto err_free_irq;
289    }
290
291    /* TODO: initialize the ADJC bits (25:16) to fine-tune
292     * the accuracy of the RTC */
293    ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_REGULATOR,
294                (clk_get_rate(rtc_clk) - 1) & 0xffff);
295    clk_put(rtc_clk);
296
297    if (ret)
298        dev_warn(&pdev->dev, "Could not update RTC regulator register\n");
299
283300    return 0;
284301
285302err_free_irq:

Archive Download the corresponding diff file



interactive