X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=Documentation%2Frtc.txt;h=8deffcd68cb8d3fc2737279e780a28bee3726f57;hb=db358b40e0674fd4079204d8e3e1c8ab3829a1b9;hp=7cf1ec5bcdd3b37854ec34ebc085cd3be4532ee7;hpb=bdbf77d6707a52bdeff223d0a60df12d086d21d7;p=linux-2.6-omap-h63xx.git diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt index 7cf1ec5bcdd..8deffcd68cb 100644 --- a/Documentation/rtc.txt +++ b/Documentation/rtc.txt @@ -147,9 +147,9 @@ RTC class framework, but can't be supported by the older driver. * RTC_AIE_ON, RTC_AIE_OFF, RTC_ALM_SET, RTC_ALM_READ ... when the RTC is connected to an IRQ line, it can often issue an alarm IRQ up to - 24 hours in the future. + 24 hours in the future. (Use RTC_WKALM_* by preference.) - * RTC_WKALM_SET, RTC_WKALM_READ ... RTCs that can issue alarms beyond + * RTC_WKALM_SET, RTC_WKALM_RD ... RTCs that can issue alarms beyond the next 24 hours use a slightly more powerful API, which supports setting the longer alarm time and enabling its IRQ using a single request (using the same model as EFI firmware). @@ -167,6 +167,26 @@ Linux out of a low power sleep state (or hibernation) back to a fully operational state. For example, a system could enter a deep power saving state until it's time to execute some scheduled tasks. +Note that many of these ioctls need not actually be implemented by your +driver. The common rtc-dev interface handles many of these nicely if your +driver returns ENOIOCTLCMD. Some common examples: + + * RTC_RD_TIME, RTC_SET_TIME: the read_time/set_time functions will be + called with appropriate values. + + * RTC_ALM_SET, RTC_ALM_READ, RTC_WKALM_SET, RTC_WKALM_RD: the + set_alarm/read_alarm functions will be called. + + * RTC_IRQP_SET, RTC_IRQP_READ: the irq_set_freq function will be called + to set the frequency while the framework will handle the read for you + since the frequency is stored in the irq_freq member of the rtc_device + structure. Your driver needs to initialize the irq_freq member during + init. Make sure you check the requested frequency is in range of your + hardware in the irq_set_freq function. If it isn't, return -EINVAL. If + you cannot actually change the frequency, do not define irq_set_freq. + +If all else fails, check out the rtc-test.c driver! + -------------------- 8< ---------------- 8< ----------------------------- @@ -237,7 +257,7 @@ int main(int argc, char **argv) "\n...Update IRQs not supported.\n"); goto test_READ; } - perror("ioctl"); + perror("RTC_UIE_ON ioctl"); exit(errno); } @@ -248,8 +268,8 @@ int main(int argc, char **argv) /* This read will block */ retval = read(fd, &data, sizeof(unsigned long)); if (retval == -1) { - perror("read"); - exit(errno); + perror("read"); + exit(errno); } fprintf(stderr, " %d",i); fflush(stderr); @@ -284,7 +304,7 @@ int main(int argc, char **argv) /* Turn off update interrupts */ retval = ioctl(fd, RTC_UIE_OFF, 0); if (retval == -1) { - perror("ioctl"); + perror("RTC_UIE_OFF ioctl"); exit(errno); } @@ -292,7 +312,7 @@ test_READ: /* Read the RTC time/date */ retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); if (retval == -1) { - perror("ioctl"); + perror("RTC_RD_TIME ioctl"); exit(errno); } @@ -306,11 +326,11 @@ test_READ: rtc_tm.tm_sec %= 60; rtc_tm.tm_min++; } - if (rtc_tm.tm_min == 60) { + if (rtc_tm.tm_min == 60) { rtc_tm.tm_min = 0; rtc_tm.tm_hour++; } - if (rtc_tm.tm_hour == 24) + if (rtc_tm.tm_hour == 24) rtc_tm.tm_hour = 0; retval = ioctl(fd, RTC_ALM_SET, &rtc_tm); @@ -320,14 +340,14 @@ test_READ: "\n...Alarm IRQs not supported.\n"); goto test_PIE; } - perror("ioctl"); + perror("RTC_ALM_SET ioctl"); exit(errno); } /* Read the current alarm settings */ retval = ioctl(fd, RTC_ALM_READ, &rtc_tm); if (retval == -1) { - perror("ioctl"); + perror("RTC_ALM_READ ioctl"); exit(errno); } @@ -337,7 +357,7 @@ test_READ: /* Enable alarm interrupts */ retval = ioctl(fd, RTC_AIE_ON, 0); if (retval == -1) { - perror("ioctl"); + perror("RTC_AIE_ON ioctl"); exit(errno); } @@ -355,7 +375,7 @@ test_READ: /* Disable alarm interrupts */ retval = ioctl(fd, RTC_AIE_OFF, 0); if (retval == -1) { - perror("ioctl"); + perror("RTC_AIE_OFF ioctl"); exit(errno); } @@ -366,9 +386,9 @@ test_PIE: /* not all RTCs support periodic IRQs */ if (errno == ENOTTY) { fprintf(stderr, "\nNo periodic IRQ support\n"); - return 0; + goto done; } - perror("ioctl"); + perror("RTC_IRQP_READ ioctl"); exit(errno); } fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp); @@ -387,8 +407,8 @@ test_PIE: "\n...Periodic IRQ rate is fixed\n"); goto done; } - perror("ioctl"); - exit(errno); + perror("RTC_IRQP_SET ioctl"); + exit(errno); } fprintf(stderr, "\n%ldHz:\t", tmp); @@ -397,27 +417,27 @@ test_PIE: /* Enable periodic interrupts */ retval = ioctl(fd, RTC_PIE_ON, 0); if (retval == -1) { - perror("ioctl"); - exit(errno); + perror("RTC_PIE_ON ioctl"); + exit(errno); } for (i=1; i<21; i++) { - /* This blocks */ - retval = read(fd, &data, sizeof(unsigned long)); - if (retval == -1) { - perror("read"); - exit(errno); - } - fprintf(stderr, " %d",i); - fflush(stderr); - irqcount++; + /* This blocks */ + retval = read(fd, &data, sizeof(unsigned long)); + if (retval == -1) { + perror("read"); + exit(errno); + } + fprintf(stderr, " %d",i); + fflush(stderr); + irqcount++; } /* Disable periodic interrupts */ retval = ioctl(fd, RTC_PIE_OFF, 0); if (retval == -1) { - perror("ioctl"); - exit(errno); + perror("RTC_PIE_OFF ioctl"); + exit(errno); } }