Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  This file contains the definitions for the following real-time clocks:
0005  *
0006  *    + Motorola MC146818A
0007  *
0008  *  COPYRIGHT (c) 1989-1999.
0009  *  On-Line Applications Research Corporation (OAR).
0010  *
0011  * Redistribution and use in source and binary forms, with or without
0012  * modification, are permitted provided that the following conditions
0013  * are met:
0014  * 1. Redistributions of source code must retain the above copyright
0015  *    notice, this list of conditions and the following disclaimer.
0016  * 2. Redistributions in binary form must reproduce the above copyright
0017  *    notice, this list of conditions and the following disclaimer in the
0018  *    documentation and/or other materials provided with the distribution.
0019  *
0020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0023  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0030  * POSSIBILITY OF SUCH DAMAGE.
0031  */
0032 
0033 #ifndef __LIBCHIP_MC146818A_h
0034 #define __LIBCHIP_MC146818A_h
0035 
0036 /*
0037  *  Register addresses within chip
0038  */
0039 #define MC146818A_SEC         0x00    /* seconds */
0040 #define MC146818A_SECALRM     0x01    /* seconds alarm */
0041 #define MC146818A_MIN         0x02    /* minutes */
0042 #define MC146818A_MINALRM     0x03    /* minutes alarm */
0043 #define MC146818A_HRS         0x04    /* hours */
0044 #define MC146818A_HRSALRM     0x05    /* hours alarm */
0045 #define MC146818A_WDAY        0x06    /* week day */
0046 #define MC146818A_DAY         0x07    /* day of month */
0047 #define MC146818A_MONTH       0x08    /* month of year */
0048 #define MC146818A_YEAR        0x09    /* month of year */
0049 
0050 #define MC146818A_STATUSA     0x0a    /* status register A */
0051 #define  MC146818ASA_TUP       0x80   /* time update in progress */
0052 #define  MC146818ASA_DIVIDER   0x20   /* divider for 32768 crystal */
0053 #define  MC146818ASA_1024      0x06   /* divide to 1024 Hz */
0054 
0055 #define MC146818A_STATUSB     0x0b    /* status register B */
0056 #define  MC146818ASB_DST       0x01   /* Daylight Savings Time */
0057 #define  MC146818ASB_24HR      0x02   /* 0 = 12 hours, 1 = 24 hours */
0058 #define  MC146818ASB_HALT      0x80   /* stop clock updates */
0059 
0060 #define MC146818A_STATUSD     0x0d    /* status register D */
0061 #define  MC146818ASD_PWR       0x80   /* clock lost power */
0062 
0063 
0064 /*
0065  *  Driver function table
0066  */
0067 extern rtc_fns mc146818a_fns;
0068 bool mc146818a_probe(
0069   int minor
0070 );
0071 
0072 /*
0073  * Default register access routines
0074  */
0075 uint32_t mc146818a_get_register(
0076   uintptr_t  ulCtrlPort,
0077   uint8_t    ucRegNum
0078 );
0079 
0080 void  mc146818a_set_register(
0081   uintptr_t  ulCtrlPort,
0082   uint8_t    ucRegNum,
0083   uint32_t   ucData
0084 );
0085 
0086 #endif
0087 /* end of include file */