readclock: add support for am335x RTC

Add support for getting/setting the am335x SoC's internal real
time clock. Also, allow the power off alarm to be set.

Make readclock an "always on" driver. This is needed for setting
power-off alarms whenever the power button is pressed on the BBB.

Replace the readclock.sh script & single run driver with a
readclock program that takes the same arguments and forwards
the requests on to the always up readclock driver.

Change-Id: Ifd6c2acd80ae4b5e79d83df510df445c24e24a71
This commit is contained in:
Thomas Cort
2013-08-02 10:10:30 -04:00
parent c4f3c7d66f
commit 09db2a8c67
17 changed files with 1261 additions and 354 deletions

View File

@@ -27,6 +27,7 @@
* 0x1400 - 0x14FF VFS-FS transaction IDs
* 0x1500 - 0x15FF Block device requests and responses
* 0x1600 - 0x16FF VirtualBox (VBOX) requests (see vboxif.h)
* 0x1700 - 0x17FF Real Time Clock requests and responses
*
* Zero and negative values are widely used for OK and error responses.
*/
@@ -1305,4 +1306,33 @@
#define RU_WHO m1_i1 /* who argument in getrusage call */
#define RU_RUSAGE_ADDR m1_p1 /* pointer to struct rusage */
/*===========================================================================*
* Messages for Real Time Clocks *
*===========================================================================*/
/* Base type for real time clock requests and responses. */
#define RTCDEV_RQ_BASE 0x1700
#define RTCDEV_RS_BASE 0x1780
#define IS_RTCDEV_RQ(type) (((type) & ~0x7f) == RTCDEV_RQ_BASE)
#define IS_RTCDEV_RS(type) (((type) & ~0x7f) == RTCDEV_RS_BASE)
/* Message types for real time clock requests. */
#define RTCDEV_GET_TIME (RTCDEV_RQ_BASE + 0) /* get time from hw clock */
#define RTCDEV_SET_TIME (RTCDEV_RQ_BASE + 1) /* set time in hw clock */
#define RTCDEV_PWR_OFF (RTCDEV_RQ_BASE + 2) /* set time to cut the power */
/* Message types for real time clock responses. */
#define RTCDEV_REPLY (RTCDEV_RS_BASE + 0) /* general reply code */
/* Field names for real time clock messages */
#define RTCDEV_TM m2_p1 /* pointer to struct tm */
#define RTCDEV_FLAGS m2_s1 /* clock flags flags */
#define RTCDEV_STATUS m2_i2 /* OK or error code */
/* Bits in 'RTCDEV_FLAGS' field of real time clock requests. */
#define RTCDEV_NOFLAGS 0x00 /* no flags are set */
#define RTCDEV_Y2KBUG 0x01 /* Interpret 1980 as 2000 for RTC w/Y2K bug */
#define RTCDEV_CMOSREG 0x02 /* Also set the CMOS clock register bits. */
/* _MINIX_COM_H */