Release 4.7 include/asm-generic/rtc.h
/*
* include/asm-generic/rtc.h
*
* Author: Tom Rini <trini@mvista.com>
*
* Based on:
* drivers/char/rtc.c
*
* Please read the COPYING file for all license details.
*/
#ifndef __ASM_RTC_H__
#define __ASM_RTC_H__
#include <linux/mc146818rtc.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
#include <linux/delay.h>
#ifdef CONFIG_ACPI
#include <linux/acpi.h>
#endif
#define RTC_PIE 0x40
/* periodic interrupt enable */
#define RTC_AIE 0x20
/* alarm interrupt enable */
#define RTC_UIE 0x10
/* update-finished interrupt enable */
/* some dummy definitions */
#define RTC_BATT_BAD 0x100
/* battery bad */
#define RTC_SQWE 0x08
/* enable square-wave output */
#define RTC_DM_BINARY 0x04
/* all time/date values are BCD if clear */
#define RTC_24H 0x02
/* 24 hour mode - else hours bit 7 means pm */
#define RTC_DST_EN 0x01
/* auto switch DST - works f. USA only */
/*
* Returns true if a clock update is in progress
*/
static inline unsigned char rtc_is_updating(void)
{
unsigned char uip;
unsigned long flags;
spin_lock_irqsave(&rtc_lock, flags);
uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
spin_unlock_irqrestore(&rtc_lock, flags);
return uip;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 38 | 79.17% | 1 | 50.00% |
andrew morton | andrew morton | 10 | 20.83% | 1 | 50.00% |
| Total | 48 | 100.00% | 2 | 100.00% |
static inline unsigned int __get_rtc_time(struct rtc_time *time)
{
unsigned char ctrl;
unsigned long flags;
unsigned char century = 0;
#ifdef CONFIG_MACH_DECSTATION
unsigned int real_year;
#endif
/*
* read RTC once any update in progress is done. The update
* can take just over 2ms. We wait 20ms. There is no need to
* to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.
* If you need to know *exactly* when a second has started, enable
* periodic update complete interrupts, (via ioctl) and then
* immediately read /dev/rtc which will block until you get the IRQ.
* Once the read clears, read the RTC time (again via ioctl). Easy.
*/
if (rtc_is_updating())
mdelay(20);
/*
* Only the values that we read from the RTC are set. We leave
* tm_wday, tm_yday and tm_isdst untouched. Even though the
* RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
* by the RTC when initially set to a non-zero value.
*/
spin_lock_irqsave(&rtc_lock, flags);
time->tm_sec = CMOS_READ(RTC_SECONDS);
time->tm_min = CMOS_READ(RTC_MINUTES);
time->tm_hour = CMOS_READ(RTC_HOURS);
time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
time->tm_mon = CMOS_READ(RTC_MONTH);
time->tm_year = CMOS_READ(RTC_YEAR);
#ifdef CONFIG_MACH_DECSTATION
real_year = CMOS_READ(RTC_DEC_YEAR);
#endif
#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
acpi_gbl_FADT.century)
century = CMOS_READ(acpi_gbl_FADT.century);
#endif
ctrl = CMOS_READ(RTC_CONTROL);
spin_unlock_irqrestore(&rtc_lock, flags);
if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
{
time->tm_sec = bcd2bin(time->tm_sec);
time->tm_min = bcd2bin(time->tm_min);
time->tm_hour = bcd2bin(time->tm_hour);
time->tm_mday = bcd2bin(time->tm_mday);
time->tm_mon = bcd2bin(time->tm_mon);
time->tm_year = bcd2bin(time->tm_year);
century = bcd2bin(century);
}
#ifdef CONFIG_MACH_DECSTATION
time->tm_year += real_year - 72;
#endif
if (century)
time->tm_year += (century - 19) * 100;
/*
* Account for differences between how the RTC uses the values
* and how they are defined in a struct rtc_time;
*/
if (time->tm_year <= 69)
time->tm_year += 100;
time->tm_mon--;
return RTC_24H;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 192 | 63.37% | 1 | 12.50% |
sylvain chouleur | sylvain chouleur | 57 | 18.81% | 1 | 12.50% |
adrian bunk | adrian bunk | 30 | 9.90% | 1 | 12.50% |
andrew morton | andrew morton | 15 | 4.95% | 2 | 25.00% |
ingo molnar | ingo molnar | 5 | 1.65% | 1 | 12.50% |
ralf baechle | ralf baechle | 3 | 0.99% | 1 | 12.50% |
ivan kokshaysky | ivan kokshaysky | 1 | 0.33% | 1 | 12.50% |
| Total | 303 | 100.00% | 8 | 100.00% |
#ifndef get_rtc_time
#define get_rtc_time __get_rtc_time
#endif
/* Set the current date and time in the real time clock. */
static inline int __set_rtc_time(struct rtc_time *time)
{
unsigned long flags;
unsigned char mon, day, hrs, min, sec;
unsigned char save_control, save_freq_select;
unsigned int yrs;
#ifdef CONFIG_MACH_DECSTATION
unsigned int real_yrs, leap_yr;
#endif
unsigned char century = 0;
yrs = time->tm_year;
mon = time->tm_mon + 1; /* tm_mon starts at zero */
day = time->tm_mday;
hrs = time->tm_hour;
min = time->tm_min;
sec = time->tm_sec;
if (yrs > 255) /* They are unsigned */
return -EINVAL;
spin_lock_irqsave(&rtc_lock, flags);
#ifdef CONFIG_MACH_DECSTATION
real_yrs = yrs;
leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
!((yrs + 1900) % 400));
yrs = 72;
/*
* We want to keep the year set to 73 until March
* for non-leap years, so that Feb, 29th is handled
* correctly.
*/
if (!leap_yr && mon < 3) {
real_yrs--;
yrs = 73;
}
#endif
#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
acpi_gbl_FADT.century) {
century = (yrs + 1900) / 100;
yrs %= 100;
}
#endif
/* These limits and adjustments are independent of
* whether the chip is in binary mode or not.
*/
if (yrs > 169) {
spin_unlock_irqrestore(&rtc_lock, flags);
return -EINVAL;
}
if (yrs >= 100)
yrs -= 100;
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
|| RTC_ALWAYS_BCD) {
sec = bin2bcd(sec);
min = bin2bcd(min);
hrs = bin2bcd(hrs);
day = bin2bcd(day);
mon = bin2bcd(mon);
yrs = bin2bcd(yrs);
century = bin2bcd(century);
}
save_control = CMOS_READ(RTC_CONTROL);
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
#ifdef CONFIG_MACH_DECSTATION
CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
#endif
CMOS_WRITE(yrs, RTC_YEAR);
CMOS_WRITE(mon, RTC_MONTH);
CMOS_WRITE(day, RTC_DAY_OF_MONTH);
CMOS_WRITE(hrs, RTC_HOURS);
CMOS_WRITE(min, RTC_MINUTES);
CMOS_WRITE(sec, RTC_SECONDS);
#ifdef CONFIG_ACPI
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
acpi_gbl_FADT.century)
CMOS_WRITE(century, acpi_gbl_FADT.century);
#endif
CMOS_WRITE(save_control, RTC_CONTROL);
CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
spin_unlock_irqrestore(&rtc_lock, flags);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 345 | 75.49% | 1 | 14.29% |
sylvain chouleur | sylvain chouleur | 76 | 16.63% | 1 | 14.29% |
adrian bunk | adrian bunk | 18 | 3.94% | 1 | 14.29% |
linus torvalds | linus torvalds | 13 | 2.84% | 1 | 14.29% |
ralf baechle | ralf baechle | 3 | 0.66% | 1 | 14.29% |
steven cole | steven cole | 1 | 0.22% | 1 | 14.29% |
ivan kokshaysky | ivan kokshaysky | 1 | 0.22% | 1 | 14.29% |
| Total | 457 | 100.00% | 7 | 100.00% |
#ifndef set_rtc_time
#define set_rtc_time __set_rtc_time
#endif
static inline unsigned int get_rtc_ss(void)
{
struct rtc_time h;
get_rtc_time(&h);
return h.tm_sec;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 24 | 96.00% | 1 | 50.00% |
arnd bergmann | arnd bergmann | 1 | 4.00% | 1 | 50.00% |
| Total | 25 | 100.00% | 2 | 100.00% |
static inline int get_rtc_pll(struct rtc_pll_info *pll)
{
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
static inline int set_rtc_pll(struct rtc_pll_info *pll)
{
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
#endif /* __ASM_RTC_H__ */
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tom rini | tom rini | 684 | 71.55% | 1 | 7.69% |
sylvain chouleur | sylvain chouleur | 141 | 14.75% | 1 | 7.69% |
adrian bunk | adrian bunk | 48 | 5.02% | 1 | 7.69% |
andrew morton | andrew morton | 33 | 3.45% | 3 | 23.08% |
ivan kokshaysky | ivan kokshaysky | 20 | 2.09% | 1 | 7.69% |
linus torvalds | linus torvalds | 13 | 1.36% | 1 | 7.69% |
ingo molnar | ingo molnar | 8 | 0.84% | 1 | 7.69% |
ralf baechle | ralf baechle | 6 | 0.63% | 1 | 7.69% |
steven cole | steven cole | 1 | 0.10% | 1 | 7.69% |
arnd bergmann | arnd bergmann | 1 | 0.10% | 1 | 7.69% |
uwe zeisberger | uwe zeisberger | 1 | 0.10% | 1 | 7.69% |
| Total | 956 | 100.00% | 13 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.