isa-rtc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/arm/mach-footbridge/isa-rtc.c
  4. *
  5. * Copyright (C) 1998 Russell King.
  6. * Copyright (C) 1998 Phil Blundell
  7. *
  8. * CATS has a real-time clock, though the evaluation board doesn't.
  9. *
  10. * Changelog:
  11. * 21-Mar-1998 RMK Created
  12. * 27-Aug-1998 PJB CATS support
  13. * 28-Dec-1998 APH Made leds optional
  14. * 20-Jan-1999 RMK Started merge of EBSA285, CATS and NetWinder
  15. * 16-Mar-1999 RMK More support for EBSA285-like machines with RTCs in
  16. */
  17. #define RTC_PORT(x) (0x70+(x))
  18. #define RTC_ALWAYS_BCD 0
  19. #include <linux/init.h>
  20. #include <linux/mc146818rtc.h>
  21. #include <linux/bcd.h>
  22. #include <linux/io.h>
  23. #include "common.h"
  24. void __init isa_rtc_init(void)
  25. {
  26. int reg_d, reg_b;
  27. /*
  28. * Probe for the RTC.
  29. */
  30. reg_d = CMOS_READ(RTC_REG_D);
  31. /*
  32. * make sure the divider is set
  33. */
  34. CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
  35. /*
  36. * Set control reg B
  37. * (24 hour mode, update enabled)
  38. */
  39. reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
  40. reg_b |= 2;
  41. CMOS_WRITE(reg_b, RTC_REG_B);
  42. if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
  43. CMOS_READ(RTC_REG_B) == reg_b) {
  44. /*
  45. * We have a RTC. Check the battery
  46. */
  47. if ((reg_d & 0x80) == 0)
  48. printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
  49. }
  50. }