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 Real-Time Clock definitions.
0005  *
0006  *  COPYRIGHT (c) 1989-1999.
0007  *  On-Line Applications Research Corporation (OAR).
0008  *
0009  * Redistribution and use in source and binary forms, with or without
0010  * modification, are permitted provided that the following conditions
0011  * are met:
0012  * 1. Redistributions of source code must retain the above copyright
0013  *    notice, this list of conditions and the following disclaimer.
0014  * 2. Redistributions in binary form must reproduce the above copyright
0015  *    notice, this list of conditions and the following disclaimer in the
0016  *    documentation and/or other materials provided with the distribution.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0028  * POSSIBILITY OF SUCH DAMAGE.
0029  */
0030 
0031 #ifndef __LIBCHIP_RTC_h
0032 #define __LIBCHIP_RTC_h
0033 
0034 #include <stdbool.h>
0035 #include <stdint.h>
0036 
0037 #include <rtems.h>
0038 
0039 /*
0040  *  Types for get and set register routines
0041  */
0042 
0043 typedef uint32_t (*getRegister_f)(uintptr_t  port, uint8_t reg);
0044 typedef void     (*setRegister_f)(uintptr_t  port, uint8_t reg, uint32_t value);
0045 
0046 typedef struct _rtc_fns {
0047   void    (*deviceInitialize)(int minor);
0048   int     (*deviceGetTime)(int minor, rtems_time_of_day *time);
0049   int     (*deviceSetTime)(int minor, const rtems_time_of_day *time);
0050 } rtc_fns;
0051 
0052 typedef enum {
0053   RTC_M48T08,                  /* SGS-Thomsom M48T08 or M48T18 */
0054   RTC_ICM7170,                 /* Harris ICM-7170 */
0055   RTC_CUSTOM,                  /* BSP specific driver */
0056   RTC_MC146818A                /* Motorola MC146818A */
0057 } rtc_devs;
0058 
0059 /*
0060  * Each field is interpreted thus:
0061  *
0062  * sDeviceName  This is the name of the device.
0063  *
0064  * deviceType   This indicates the chip type.
0065  *
0066  * pDeviceFns   This is a pointer to the set of driver routines to use.
0067  *
0068  * pDeviceParams This contains either device specific data or a pointer to a
0069  *              device specific information table.
0070  *
0071  * ulCtrlPort1  This is the primary control port number for the device.
0072  *
0073  * ulDataPort   This is the port number for the data port of the device
0074  *
0075  * getRegister  This is the routine used to read register values.
0076  *
0077  * setRegister  This is the routine used to write register values.
0078  */
0079 
0080 typedef struct _rtc_tbl {
0081   const char    *sDeviceName;
0082   rtc_devs       deviceType;
0083   const rtc_fns *pDeviceFns;
0084   bool           (*deviceProbe)(int minor);
0085   void          *pDeviceParams;
0086   uintptr_t      ulCtrlPort1;
0087   uintptr_t      ulDataPort;
0088   getRegister_f  getRegister;
0089   setRegister_f  setRegister;
0090 } rtc_tbl;
0091 
0092 extern rtc_tbl  RTC_Table[];
0093 extern size_t   RTC_Count;
0094 
0095 
0096 extern bool rtc_probe( int minor );
0097 
0098 #endif
0099 /* end of include file */