设备树学习之(六)RTC

开发板:tiny4412SDK + S702 + 4GB Flash
要移植的内核版本:Linux-4.4.0 (支持device tree)
u-boot版本:友善之臂自带的 U-Boot 2010.12
busybox版本:busybox 1.25

目标:
Linux4.4 中已经对 tiny4412 rtc 有了支持,但是使能设备树之后启动报错,简单修改,使 rtc 正常工作。

设备树:

    rtc: rtc@10070000 {
        compatible = "samsung,s3c6410-rtc";
        reg = <0x10070000 0x100>;
        interrupt-parent = <&pmu_system_controller>;//注释掉此行
        interrupts = <0 44 0>, <0 45 0>;
        clocks = <&clock CLK_RTC>;
        clock-names = "rtc";
        status = "disabled";
    };

启动错误信息:

[    2.193630] s3c-rtc 10070000.rtc: failed to find rtc source clock            
[    2.198950] s3c-rtc: probe of 10070000.rtc failed with error -2  

简单修改:

修改:driver/rtc/rtc-s3c.c
注释掉以下代码
/*
    if (info->data->needs_src_clk) {
        info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
        if (IS_ERR(info->rtc_src_clk)) {
            dev_err(&pdev->dev,
                "failed to find rtc source clock\n");
            clk_disable_unprepare(info->rtc_clk);
            return PTR_ERR(info->rtc_src_clk);
        }
        clk_prepare_enable(info->rtc_src_clk);
    }
*/
或者修改:
static struct s3c_rtc_data const s3c6410_rtc_data = {
    .max_user_freq      = 32768,
    .needs_src_clk      = true, //修改为false
    .irq_handler        = s3c6410_rtc_irq,
    .set_freq           = s3c6410_rtc_setfreq,
    .enable_tick        = s3c6410_rtc_enable_tick,
    .save_tick_cnt      = s3c6410_rtc_save_tick_cnt,
    .restore_tick_cnt   = s3c6410_rtc_restore_tick_cnt,
    .enable         = s3c24xx_rtc_enable,
    .disable        = s3c6410_rtc_disable,
};

linux 下更改系统时间:

date: invalid option -- 'h'                                                     
BusyBox v1.25.0 (2016-12-16 21:42:21 ULAT) multi-call binary.                   

Usage: date [OPTIONS] [+FMT] [TIME]                                             

Display time (using +FMT), or set time                                          

        [-s,--set] TIME Set time to TIME                                        
        -u,--utc        Work in UTC (don't convert to local time)               
        -R,--rfc-2822   Output RFC-2822 compliant date string                   
        -I[SPEC]        Output ISO-8601 compliant date string                   
                        SPEC='date' (default) for date only,                    
                        'hours', 'minutes', or 'seconds' for date and           
                        time to the indicated precision                         
        -r,--reference FILE     Display last modification time of FILE          
        -d,--date TIME  Display TIME, not 'now'                                 
        -D FMT          Use FMT for -d TIME conversion                          

Recognized TIME formats:                                                        
        hh:mm[:ss]                                                              
        [YYYY.]MM.DD-hh:mm[:ss]                                                 
        YYYY-MM-DD hh:mm[:ss]                                                   
        [[[[[YY]YY]MM]DD]hh]mm[.ss]                                             
        'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead                  
date -s 2017-01-01
date -s 22:50:00

系统时间和硬件rtc的同步:

/ # hwclock -h                                                                  
hwclock: invalid option -- 'h'                                                  
BusyBox v1.25.0 (2016-12-16 21:42:21 ULAT) multi-call binary.                   

Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz] [-l|--loc]

Query and set hardware clock (RTC)                                              

        -r      Show hardware clock time                                        
        -s      Set system time from hardware clock                             
        -w      Set hardware clock from system time                             
        -t      Set in-kernel timezone, correct system time                     
                if hardware clock is in local time                              
        -u      Assume hardware clock is kept in UTC                            
        -l      Assume hardware clock is kept in local time                     
        -f FILE Use specified device (e.g. /dev/rtc2) 

你可能感兴趣的:(Device,Tree,Tiny4412,DTS之Tiny4412,4412,devicetree,rtc)