Skip to content
  • Maciej W. Rozycki's avatar
    drivers/rtc/rtc-cmos.c: drivers/char/rtc.c features for DECstation support · 31632dbd
    Maciej W. Rozycki authored
    
    
    This brings in drivers/char/rtc.c functionality required for DECstation
    and, should the maintainers decide to switch, Alpha systems to use
    rtc-cmos.
    
    Specifically these features are made available:
    
    * RTC iomem rather than x86/PCI port I/O mapping, controlled with the
      RTC_IOMAPPED macro as with the original driver.  The DS1287A chip in all
      DECstation systems is mapped in the host bus address space as a
      contiguous block of 64 32-bit words of which the least significant byte
      accesses the RTC chip for both reads and writes.  All the address and
      data window register accesses are made transparently by the chipset glue
      logic so that the device appears directly mapped on the host bus.
    
    * A way to set the size of the address space explicitly with the
      newly-added `address_space' member of the platform part of the RTC
      device structure.  This avoids the unreliable heuristics that does not
      work in a setup where the RTC is not explicitly accessed with the usual
      address and data window register pair.
    
    * The ability to use the RTC periodic interrupt as a system clock
      device, which is implemented by arch/mips/kernel/cevt-ds1287.c for
      DECstation systems and takes the RTC interrupt away from the RTC driver.
       Eventually hooking back to the clock device's interrupt handler should
      be possible for the purpose of the alarm clock and possibly also
      update-in-progress interrupt, but this is not done by this change.
    
      o To avoid interfering with the clock interrupt all the places where
        the RTC interrupt mask is fiddled with are only executed if and IRQ
        has been assigned to the RTC driver.
    
      o To avoid changing the clock setup Register A is not fiddled with
        if CMOS_RTC_FLAGS_NOFREQ is set in the newly-added `flags' member of
        the platform part of the RTC device structure.  Originally, in
        drivers/char/rtc.c, this was keyed with the absence of the RTC
        interrupt, just like the interrupt mask, but there only the periodic
        interrupt frequency is set, whereas rtc-cmos also sets the divider
        bits.  Therefore a new flag is introduced so that systems where the
        RTC interrupt is not usable rather than used as a system clock device
        can fully initialise the RTC.
    
    * A small clean-up is made to the IRQ assignment code that makes the IRQ
      number hardcoded to -1 rather than arbitrary -ENXIO (or whatever error
      happens to be returned by platform_get_irq) where no IRQ has been
      assigned to the RTC driver (NO_IRQ might be another candidate, but it
      looks like this macro has inconsistent or missing definitions and
      limited use and might therefore be unsafe).
    
    Verified to work correctly with a DECstation 5000/240 system.
    
    [akpm@linux-foundation.org: fix weird code layout]
    Signed-off-by: default avatarMaciej W. Rozycki <macro@linux-mips.org>
    Cc: Alessandro Zummo <a.zummo@towertech.it>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    31632dbd