1 /* Driver for Calypso RTC controller */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <calypso/irq.h>
32 #define BASE_ADDR_RTC 0xfffe1800
33 #define RTC_REG(x) ((void *)BASE_ADDR_RTC + (x))
44 ALARM_SECOND_REG = 0x08,
45 ALARM_MINUTES_REG = 0x09,
46 ALARM_HOURS_REG = 0x0a,
47 ALARM_DAYS_REG = 0x0b,
48 ALARM_MONTHS_REG = 0x0c,
49 ALARM_YEARS_REG = 0x0d,
62 static void rtc_irq_tick(__unused enum irq_nr nr)
65 display_set_attr(DISP_ATTR_INVERT);
67 display_unset_attr(DISP_ATTR_INVERT);
73 irq_register_handler(IRQ_RTC_TIMER, &rtc_irq_tick);
74 irq_config(IRQ_RTC_TIMER, 0, 1, 0);
75 irq_enable(IRQ_RTC_TIMER);
77 /* clear power-up reset */
78 writeb(0x80, RTC_REG(STATUS_REG));
79 /* enable RTC running */
80 writeb(0x01, RTC_REG(CTRL_REG));
81 /* enable periodic interrupts every second */
82 writeb(0x04, RTC_REG(INT_REG));