Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105491
b: refs/heads/master
c: 4cad443
h: refs/heads/master
i:
  105489: 682abb1
  105487: d8d73fa
v: v3
  • Loading branch information
Yoichi Yuasa authored and Linus Torvalds committed Jul 24, 2008
1 parent 6de5aa1 commit b5a6e57
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7e2a31da854dcf8324012a83a31b40bc11e52589
refs/heads/master: 4cad4431fcd872a1b2efc093b0db6df943f5a898
65 changes: 34 additions & 31 deletions trunk/drivers/rtc/rtc-vr41xx.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Driver for NEC VR4100 series Real Time Clock unit.
*
* Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
* Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
*
* 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
Expand Down Expand Up @@ -34,7 +34,7 @@

MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>");
MODULE_DESCRIPTION("NEC VR4100 series RTC driver");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL v2");

/* RTC 1 registers */
#define ETIMELREG 0x00
Expand Down Expand Up @@ -82,7 +82,6 @@ static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */

static DEFINE_SPINLOCK(rtc_lock);
static char rtc_name[] = "RTC";
static unsigned long periodic_frequency;
static unsigned long periodic_count;
static unsigned int alarm_enabled;
static int aie_irq = -1;
Expand Down Expand Up @@ -207,10 +206,37 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
return 0;
}

static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq)
{
unsigned long count;

count = RTC_FREQUENCY;
do_div(count, freq);

periodic_count = count;

spin_lock_irq(&rtc_lock);

rtc1_write(RTCL1LREG, count);
rtc1_write(RTCL1HREG, count >> 16);

spin_unlock_irq(&rtc_lock);

return 0;
}

static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled)
{
if (enabled)
enable_irq(pie_irq);
else
disable_irq(pie_irq);

return 0;
}

static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
switch (cmd) {
case RTC_AIE_ON:
spin_lock_irq(&rtc_lock);
Expand All @@ -230,33 +256,6 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
alarm_enabled = 0;
}

spin_unlock_irq(&rtc_lock);
break;
case RTC_PIE_ON:
enable_irq(pie_irq);
break;
case RTC_PIE_OFF:
disable_irq(pie_irq);
break;
case RTC_IRQP_READ:
return put_user(periodic_frequency, (unsigned long __user *)arg);
break;
case RTC_IRQP_SET:
if (arg > MAX_PERIODIC_RATE)
return -EINVAL;

periodic_frequency = arg;

count = RTC_FREQUENCY;
do_div(count, arg);

periodic_count = count;

spin_lock_irq(&rtc_lock);

rtc1_write(RTCL1LREG, count);
rtc1_write(RTCL1HREG, count >> 16);

spin_unlock_irq(&rtc_lock);
break;
case RTC_EPOCH_READ:
Expand Down Expand Up @@ -309,6 +308,8 @@ static const struct rtc_class_ops vr41xx_rtc_ops = {
.set_time = vr41xx_rtc_set_time,
.read_alarm = vr41xx_rtc_read_alarm,
.set_alarm = vr41xx_rtc_set_alarm,
.irq_set_freq = vr41xx_rtc_irq_set_freq,
.irq_set_state = vr41xx_rtc_irq_set_state,
};

static int __devinit rtc_probe(struct platform_device *pdev)
Expand Down Expand Up @@ -346,6 +347,8 @@ static int __devinit rtc_probe(struct platform_device *pdev)
goto err_iounmap_all;
}

rtc->max_user_freq = MAX_PERIODIC_RATE;

spin_lock_irq(&rtc_lock);

rtc1_write(ECMPLREG, 0);
Expand Down

0 comments on commit b5a6e57

Please sign in to comment.