Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  arch/arm/mach-footbridge/isa-rtc.c
0004  *
0005  *  Copyright (C) 1998 Russell King.
0006  *  Copyright (C) 1998 Phil Blundell
0007  *
0008  * CATS has a real-time clock, though the evaluation board doesn't.
0009  *
0010  * Changelog:
0011  *  21-Mar-1998 RMK Created
0012  *  27-Aug-1998 PJB CATS support
0013  *  28-Dec-1998 APH Made leds optional
0014  *  20-Jan-1999 RMK Started merge of EBSA285, CATS and NetWinder
0015  *  16-Mar-1999 RMK More support for EBSA285-like machines with RTCs in
0016  */
0017 
0018 #define RTC_PORT(x)     (0x70+(x))
0019 #define RTC_ALWAYS_BCD      0
0020 
0021 #include <linux/init.h>
0022 #include <linux/mc146818rtc.h>
0023 #include <linux/bcd.h>
0024 #include <linux/io.h>
0025 
0026 #include "common.h"
0027 
0028 void __init isa_rtc_init(void)
0029 {
0030     int reg_d, reg_b;
0031 
0032     /*
0033      * Probe for the RTC.
0034      */
0035     reg_d = CMOS_READ(RTC_REG_D);
0036 
0037     /*
0038      * make sure the divider is set
0039      */
0040     CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
0041 
0042     /*
0043      * Set control reg B
0044      *   (24 hour mode, update enabled)
0045      */
0046     reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
0047     reg_b |= 2;
0048     CMOS_WRITE(reg_b, RTC_REG_B);
0049 
0050     if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
0051         CMOS_READ(RTC_REG_B) == reg_b) {
0052         /*
0053          * We have a RTC.  Check the battery
0054          */
0055         if ((reg_d & 0x80) == 0)
0056             printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
0057     }
0058 }