Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Generic RTC interface.
0004  * This version contains the part of the user interface to the Real Time Clock
0005  * service. It is used with both the legacy mc146818 and also  EFI
0006  * Struct rtc_time and first 12 ioctl by Paul Gortmaker, 1996 - separated out
0007  * from <linux/mc146818rtc.h> to this file for 2.4 kernels.
0008  *
0009  * Copyright (C) 1999 Hewlett-Packard Co.
0010  * Copyright (C) 1999 Stephane Eranian <eranian@hpl.hp.com>
0011  */
0012 #ifndef _UAPI_LINUX_RTC_H_
0013 #define _UAPI_LINUX_RTC_H_
0014 
0015 #include <linux/const.h>
0016 #include <linux/ioctl.h>
0017 #include <linux/types.h>
0018 
0019 /*
0020  * The struct used to pass data via the following ioctl. Similar to the
0021  * struct tm in <time.h>, but it needs to be here so that the kernel
0022  * source is self contained, allowing cross-compiles, etc. etc.
0023  */
0024 
0025 struct rtc_time {
0026     int tm_sec;
0027     int tm_min;
0028     int tm_hour;
0029     int tm_mday;
0030     int tm_mon;
0031     int tm_year;
0032     int tm_wday;
0033     int tm_yday;
0034     int tm_isdst;
0035 };
0036 
0037 /*
0038  * This data structure is inspired by the EFI (v0.92) wakeup
0039  * alarm API.
0040  */
0041 struct rtc_wkalrm {
0042     unsigned char enabled;  /* 0 = alarm disabled, 1 = alarm enabled */
0043     unsigned char pending;  /* 0 = alarm not pending, 1 = alarm pending */
0044     struct rtc_time time;   /* time the alarm is set to */
0045 };
0046 
0047 /*
0048  * Data structure to control PLL correction some better RTC feature
0049  * pll_value is used to get or set current value of correction,
0050  * the rest of the struct is used to query HW capabilities.
0051  * This is modeled after the RTC used in Q40/Q60 computers but
0052  * should be sufficiently flexible for other devices
0053  *
0054  * +ve pll_value means clock will run faster by
0055  *   pll_value*pll_posmult/pll_clock
0056  * -ve pll_value means clock will run slower by
0057  *   pll_value*pll_negmult/pll_clock
0058  */
0059 
0060 struct rtc_pll_info {
0061     int pll_ctrl;       /* placeholder for fancier control */
0062     int pll_value;      /* get/set correction value */
0063     int pll_max;        /* max +ve (faster) adjustment value */
0064     int pll_min;        /* max -ve (slower) adjustment value */
0065     int pll_posmult;    /* factor for +ve correction */
0066     int pll_negmult;    /* factor for -ve correction */
0067     long pll_clock;     /* base PLL frequency */
0068 };
0069 
0070 struct rtc_param {
0071     __u64 param;
0072     union {
0073         __u64 uvalue;
0074         __s64 svalue;
0075         __u64 ptr;
0076     };
0077     __u32 index;
0078     __u32 __pad;
0079 };
0080 
0081 /*
0082  * ioctl calls that are permitted to the /dev/rtc interface, if
0083  * any of the RTC drivers are enabled.
0084  */
0085 
0086 #define RTC_AIE_ON  _IO('p', 0x01)  /* Alarm int. enable on     */
0087 #define RTC_AIE_OFF _IO('p', 0x02)  /* ... off          */
0088 #define RTC_UIE_ON  _IO('p', 0x03)  /* Update int. enable on    */
0089 #define RTC_UIE_OFF _IO('p', 0x04)  /* ... off          */
0090 #define RTC_PIE_ON  _IO('p', 0x05)  /* Periodic int. enable on  */
0091 #define RTC_PIE_OFF _IO('p', 0x06)  /* ... off          */
0092 #define RTC_WIE_ON  _IO('p', 0x0f)  /* Watchdog int. enable on  */
0093 #define RTC_WIE_OFF _IO('p', 0x10)  /* ... off          */
0094 
0095 #define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time  */
0096 #define RTC_ALM_READ    _IOR('p', 0x08, struct rtc_time) /* Read alarm time */
0097 #define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time   */
0098 #define RTC_SET_TIME    _IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
0099 #define RTC_IRQP_READ   _IOR('p', 0x0b, unsigned long)   /* Read IRQ rate   */
0100 #define RTC_IRQP_SET    _IOW('p', 0x0c, unsigned long)   /* Set IRQ rate    */
0101 #define RTC_EPOCH_READ  _IOR('p', 0x0d, unsigned long)   /* Read epoch      */
0102 #define RTC_EPOCH_SET   _IOW('p', 0x0e, unsigned long)   /* Set epoch       */
0103 
0104 #define RTC_WKALM_SET   _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/
0105 #define RTC_WKALM_RD    _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/
0106 
0107 #define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info)  /* Get PLL correction */
0108 #define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info)  /* Set PLL correction */
0109 
0110 #define RTC_PARAM_GET   _IOW('p', 0x13, struct rtc_param)  /* Get parameter */
0111 #define RTC_PARAM_SET   _IOW('p', 0x14, struct rtc_param)  /* Set parameter */
0112 
0113 #define RTC_VL_DATA_INVALID _BITUL(0) /* Voltage too low, RTC data is invalid */
0114 #define RTC_VL_BACKUP_LOW   _BITUL(1) /* Backup voltage is low */
0115 #define RTC_VL_BACKUP_EMPTY _BITUL(2) /* Backup empty or not present */
0116 #define RTC_VL_ACCURACY_LOW _BITUL(3) /* Voltage is low, RTC accuracy is reduced */
0117 #define RTC_VL_BACKUP_SWITCH    _BITUL(4) /* Backup switchover happened */
0118 
0119 #define RTC_VL_READ _IOR('p', 0x13, unsigned int)   /* Voltage low detection */
0120 #define RTC_VL_CLR  _IO('p', 0x14)      /* Clear voltage low information */
0121 
0122 /* interrupt flags */
0123 #define RTC_IRQF 0x80   /* Any of the following is active */
0124 #define RTC_PF 0x40 /* Periodic interrupt */
0125 #define RTC_AF 0x20 /* Alarm interrupt */
0126 #define RTC_UF 0x10 /* Update interrupt for 1Hz RTC */
0127 
0128 /* feature list */
0129 #define RTC_FEATURE_ALARM       0
0130 #define RTC_FEATURE_ALARM_RES_MINUTE    1
0131 #define RTC_FEATURE_NEED_WEEK_DAY   2
0132 #define RTC_FEATURE_ALARM_RES_2S    3
0133 #define RTC_FEATURE_UPDATE_INTERRUPT    4
0134 #define RTC_FEATURE_CORRECTION      5
0135 #define RTC_FEATURE_BACKUP_SWITCH_MODE  6
0136 #define RTC_FEATURE_ALARM_WAKEUP_ONLY   7
0137 #define RTC_FEATURE_CNT         8
0138 
0139 /* parameter list */
0140 #define RTC_PARAM_FEATURES      0
0141 #define RTC_PARAM_CORRECTION        1
0142 #define RTC_PARAM_BACKUP_SWITCH_MODE    2
0143 
0144 #define RTC_BSM_DISABLED    0
0145 #define RTC_BSM_DIRECT      1
0146 #define RTC_BSM_LEVEL       2
0147 #define RTC_BSM_STANDBY     3
0148 
0149 #define RTC_MAX_FREQ    8192
0150 
0151 
0152 #endif /* _UAPI_LINUX_RTC_H_ */