Release 4.14 arch/mips/kernel/cevt-ds1287.c
/*
* DS1287 clockevent driver
*
* Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <linux/clockchips.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/mc146818rtc.h>
#include <linux/irq.h>
#include <asm/time.h>
int ds1287_timer_state(void)
{
return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 19 | 100.00% | 1 | 100.00% |
Total | 19 | 100.00% | 1 | 100.00% |
int ds1287_set_base_clock(unsigned int hz)
{
u8 rate;
switch (hz) {
case 128:
rate = 0x9;
break;
case 256:
rate = 0x8;
break;
case 1024:
rate = 0x6;
break;
default:
return -EINVAL;
}
CMOS_WRITE(RTC_REF_CLCK_32KHZ | rate, RTC_REG_A);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 59 | 100.00% | 1 | 100.00% |
Total | 59 | 100.00% | 1 | 100.00% |
static int ds1287_set_next_event(unsigned long delta,
struct clock_event_device *evt)
{
return -EINVAL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 19 | 100.00% | 1 | 100.00% |
Total | 19 | 100.00% | 1 | 100.00% |
static int ds1287_shutdown(struct clock_event_device *evt)
{
u8 val;
spin_lock(&rtc_lock);
val = CMOS_READ(RTC_REG_B);
val &= ~RTC_PIE;
CMOS_WRITE(val, RTC_REG_B);
spin_unlock(&rtc_lock);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 30 | 62.50% | 1 | 50.00% |
Viresh Kumar | 18 | 37.50% | 1 | 50.00% |
Total | 48 | 100.00% | 2 | 100.00% |
static int ds1287_set_periodic(struct clock_event_device *evt)
{
u8 val;
spin_lock(&rtc_lock);
val = CMOS_READ(RTC_REG_B);
val |= RTC_PIE;
CMOS_WRITE(val, RTC_REG_B);
spin_unlock(&rtc_lock);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Viresh Kumar | 33 | 70.21% | 1 | 50.00% |
Yoichi Yuasa | 14 | 29.79% | 1 | 50.00% |
Total | 47 | 100.00% | 2 | 100.00% |
static void ds1287_event_handler(struct clock_event_device *dev)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 10 | 100.00% | 1 | 100.00% |
Total | 10 | 100.00% | 1 | 100.00% |
static struct clock_event_device ds1287_clockevent = {
.name = "ds1287",
.features = CLOCK_EVT_FEAT_PERIODIC,
.set_next_event = ds1287_set_next_event,
.set_state_shutdown = ds1287_shutdown,
.set_state_periodic = ds1287_set_periodic,
.tick_resume = ds1287_shutdown,
.event_handler = ds1287_event_handler,
};
static irqreturn_t ds1287_interrupt(int irq, void *dev_id)
{
struct clock_event_device *cd = &ds1287_clockevent;
/* Ack the RTC interrupt. */
CMOS_READ(RTC_REG_C);
cd->event_handler(cd);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 37 | 100.00% | 1 | 100.00% |
Total | 37 | 100.00% | 1 | 100.00% |
static struct irqaction ds1287_irqaction = {
.handler = ds1287_interrupt,
.flags = IRQF_PERCPU | IRQF_TIMER,
.name = "ds1287",
};
int __init ds1287_clockevent_init(int irq)
{
struct clock_event_device *cd;
cd = &ds1287_clockevent;
cd->rating = 100;
cd->irq = irq;
clockevent_set_clock(cd, 32768);
cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd);
cd->max_delta_ticks = 0x7fffffff;
cd->min_delta_ns = clockevent_delta2ns(0x300, cd);
cd->min_delta_ticks = 0x300;
cd->cpumask = cpumask_of(0);
clockevents_register_device(&ds1287_clockevent);
return setup_irq(irq, &ds1287_irqaction);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 75 | 78.12% | 1 | 33.33% |
Nicolai Stange | 12 | 12.50% | 1 | 33.33% |
Rusty Russell | 9 | 9.38% | 1 | 33.33% |
Total | 96 | 100.00% | 3 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yoichi Yuasa | 330 | 78.57% | 1 | 14.29% |
Viresh Kumar | 63 | 15.00% | 1 | 14.29% |
Nicolai Stange | 12 | 2.86% | 1 | 14.29% |
Rusty Russell | 9 | 2.14% | 1 | 14.29% |
David Howells | 3 | 0.71% | 1 | 14.29% |
Wu Zhangjin | 2 | 0.48% | 1 | 14.29% |
Ralf Bächle | 1 | 0.24% | 1 | 14.29% |
Total | 420 | 100.00% | 7 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.