2006-03-27 09:16:46 +00:00
|
|
|
/*
|
|
|
|
* Real Time Clock interface for StrongARM SA1x00 and XScale PXA2xx
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 Nils Faerber
|
|
|
|
*
|
|
|
|
* Based on rtc.c by Paul Gortmaker
|
|
|
|
*
|
|
|
|
* Original Driver by Nils Faerber <nils@kernelconcepts.de>
|
|
|
|
*
|
|
|
|
* Modifications from:
|
|
|
|
* CIH <cih@coventive.com>
|
2009-09-14 07:25:28 +00:00
|
|
|
* Nicolas Pitre <nico@fluxnic.net>
|
2006-03-27 09:16:46 +00:00
|
|
|
* Andrew Christian <andrew.christian@hp.com>
|
|
|
|
*
|
|
|
|
* Converted to the RTC subsystem and Driver Model
|
|
|
|
* by Richard Purdie <rpurdie@rpsys.net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/module.h>
|
2012-02-23 15:36:37 +00:00
|
|
|
#include <linux/clk.h>
|
2006-03-27 09:16:46 +00:00
|
|
|
#include <linux/rtc.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/interrupt.h>
|
2012-02-21 03:51:13 +00:00
|
|
|
#include <linux/slab.h>
|
2012-01-19 11:55:21 +00:00
|
|
|
#include <linux/string.h>
|
2012-03-05 11:26:42 +00:00
|
|
|
#include <linux/of.h>
|
2006-03-27 09:16:46 +00:00
|
|
|
#include <linux/pm.h>
|
2012-01-19 11:55:21 +00:00
|
|
|
#include <linux/bitops.h>
|
2012-03-20 19:33:19 +00:00
|
|
|
#include <linux/io.h>
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2008-08-05 15:14:15 +00:00
|
|
|
#include <mach/hardware.h>
|
2012-02-23 13:27:58 +00:00
|
|
|
#include <mach/irqs.h>
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
#if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
|
2012-01-19 11:55:21 +00:00
|
|
|
#include <mach/regs-rtc.h>
|
|
|
|
#endif
|
|
|
|
|
2010-10-18 21:33:53 +00:00
|
|
|
#define RTC_DEF_DIVIDER (32768 - 1)
|
2006-03-27 09:16:46 +00:00
|
|
|
#define RTC_DEF_TRIM 0
|
2012-02-21 03:51:13 +00:00
|
|
|
#define RTC_FREQ 1024
|
2012-01-19 11:55:21 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc {
|
|
|
|
spinlock_t lock;
|
|
|
|
int irq_1hz;
|
|
|
|
int irq_alarm;
|
|
|
|
struct rtc_device *rtc;
|
2012-02-23 15:36:37 +00:00
|
|
|
struct clk *clk;
|
2012-02-21 03:51:13 +00:00
|
|
|
};
|
2012-01-19 11:55:21 +00:00
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
|
2006-03-27 09:16:46 +00:00
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev_id);
|
|
|
|
struct rtc_device *rtc = info->rtc;
|
2006-03-27 09:16:46 +00:00
|
|
|
unsigned int rtsr;
|
|
|
|
unsigned long events = 0;
|
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_lock(&info->lock);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-01-19 11:55:21 +00:00
|
|
|
rtsr = RTSR;
|
2006-03-27 09:16:46 +00:00
|
|
|
/* clear interrupt sources */
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = 0;
|
2010-10-18 21:35:54 +00:00
|
|
|
/* Fix for a nasty initialization problem the in SA11xx RTSR register.
|
|
|
|
* See also the comments in sa1100_rtc_probe(). */
|
|
|
|
if (rtsr & (RTSR_ALE | RTSR_HZE)) {
|
|
|
|
/* This is the original code, before there was the if test
|
|
|
|
* above. This code does not clear interrupts that were not
|
|
|
|
* enabled. */
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = (RTSR_AL | RTSR_HZ) & (rtsr >> 2);
|
2010-10-18 21:35:54 +00:00
|
|
|
} else {
|
|
|
|
/* For some reason, it is possible to enter this routine
|
|
|
|
* without interruptions enabled, it has been tested with
|
|
|
|
* several units (Bug in SA11xx chip?).
|
|
|
|
*
|
|
|
|
* This situation leads to an infinite "loop" of interrupt
|
|
|
|
* routine calling and as a result the processor seems to
|
|
|
|
* lock on its first call to open(). */
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = RTSR_AL | RTSR_HZ;
|
2010-10-18 21:35:54 +00:00
|
|
|
}
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
/* clear alarm interrupt if it has occurred */
|
|
|
|
if (rtsr & RTSR_AL)
|
|
|
|
rtsr &= ~RTSR_ALE;
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = rtsr & (RTSR_ALE | RTSR_HZE);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
/* update irq data & counter */
|
|
|
|
if (rtsr & RTSR_AL)
|
|
|
|
events |= RTC_AF | RTC_IRQF;
|
|
|
|
if (rtsr & RTSR_HZ)
|
|
|
|
events |= RTC_UF | RTC_IRQF;
|
|
|
|
|
2012-01-19 11:55:21 +00:00
|
|
|
rtc_update_irq(rtc, 1, events);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_unlock(&info->lock);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_open(struct device *dev)
|
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
struct rtc_device *rtc = info->rtc;
|
2006-03-27 09:16:46 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-02-23 15:36:37 +00:00
|
|
|
ret = clk_prepare_enable(info->clk);
|
|
|
|
if (ret)
|
|
|
|
goto fail_clk;
|
2012-03-27 23:41:24 +00:00
|
|
|
ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev);
|
2006-03-27 09:16:46 +00:00
|
|
|
if (ret) {
|
2012-02-21 03:51:13 +00:00
|
|
|
dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz);
|
2006-03-27 09:16:46 +00:00
|
|
|
goto fail_ui;
|
|
|
|
}
|
2012-03-27 23:41:24 +00:00
|
|
|
ret = request_irq(info->irq_alarm, sa1100_rtc_interrupt, 0, "rtc Alrm", dev);
|
2006-03-27 09:16:46 +00:00
|
|
|
if (ret) {
|
2012-02-21 03:51:13 +00:00
|
|
|
dev_err(dev, "IRQ %d already in use.\n", info->irq_alarm);
|
2006-03-27 09:16:46 +00:00
|
|
|
goto fail_ai;
|
|
|
|
}
|
2012-01-19 11:55:21 +00:00
|
|
|
rtc->max_user_freq = RTC_FREQ;
|
|
|
|
rtc_irq_set_freq(rtc, NULL, RTC_FREQ);
|
2010-12-16 20:31:32 +00:00
|
|
|
|
2006-03-27 09:16:46 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail_ai:
|
2012-02-21 03:51:13 +00:00
|
|
|
free_irq(info->irq_1hz, dev);
|
2006-03-27 09:16:46 +00:00
|
|
|
fail_ui:
|
2012-02-23 15:36:37 +00:00
|
|
|
clk_disable_unprepare(info->clk);
|
|
|
|
fail_clk:
|
2006-03-27 09:16:46 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sa1100_rtc_release(struct device *dev)
|
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
spin_lock_irq(&info->lock);
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = 0;
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_unlock_irq(&info->lock);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
free_irq(info->irq_alarm, dev);
|
|
|
|
free_irq(info->irq_1hz, dev);
|
2012-02-23 15:36:37 +00:00
|
|
|
clk_disable_unprepare(info->clk);
|
2006-03-27 09:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 01:02:41 +00:00
|
|
|
static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
spin_lock_irq(&info->lock);
|
2011-02-03 01:02:41 +00:00
|
|
|
if (enabled)
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR |= RTSR_ALE;
|
2011-02-03 01:02:41 +00:00
|
|
|
else
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR &= ~RTSR_ALE;
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_unlock_irq(&info->lock);
|
2011-02-03 01:02:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-27 09:16:46 +00:00
|
|
|
static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
2012-01-19 11:55:21 +00:00
|
|
|
rtc_time_to_tm(RCNR, tm);
|
2006-03-27 09:16:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
unsigned long time;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = rtc_tm_to_time(tm, &time);
|
|
|
|
if (ret == 0)
|
2012-01-19 11:55:21 +00:00
|
|
|
RCNR = time;
|
2006-03-27 09:16:46 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
|
|
{
|
2012-01-19 11:55:21 +00:00
|
|
|
u32 rtsr;
|
2007-02-20 21:58:13 +00:00
|
|
|
|
2012-01-19 11:55:21 +00:00
|
|
|
rtsr = RTSR;
|
2007-02-20 21:58:13 +00:00
|
|
|
alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
|
|
|
|
alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
|
2006-03-27 09:16:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2012-02-20 11:49:30 +00:00
|
|
|
unsigned long time;
|
2012-01-19 11:55:21 +00:00
|
|
|
int ret;
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_lock_irq(&info->lock);
|
2012-02-20 11:49:30 +00:00
|
|
|
ret = rtc_tm_to_time(&alrm->time, &time);
|
|
|
|
if (ret != 0)
|
|
|
|
goto out;
|
|
|
|
RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
|
|
|
|
RTAR = time;
|
|
|
|
if (alrm->enabled)
|
|
|
|
RTSR |= RTSR_ALE;
|
|
|
|
else
|
|
|
|
RTSR &= ~RTSR_ALE;
|
|
|
|
out:
|
2012-02-21 03:51:13 +00:00
|
|
|
spin_unlock_irq(&info->lock);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
2012-01-19 11:55:21 +00:00
|
|
|
return ret;
|
2006-03-27 09:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
|
|
|
|
{
|
2012-01-19 11:55:21 +00:00
|
|
|
seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR);
|
|
|
|
seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-01 06:28:17 +00:00
|
|
|
static const struct rtc_class_ops sa1100_rtc_ops = {
|
2006-03-27 09:16:46 +00:00
|
|
|
.open = sa1100_rtc_open,
|
|
|
|
.release = sa1100_rtc_release,
|
|
|
|
.read_time = sa1100_rtc_read_time,
|
|
|
|
.set_time = sa1100_rtc_set_time,
|
|
|
|
.read_alarm = sa1100_rtc_read_alarm,
|
|
|
|
.set_alarm = sa1100_rtc_set_alarm,
|
|
|
|
.proc = sa1100_rtc_proc,
|
2011-02-03 01:02:41 +00:00
|
|
|
.alarm_irq_enable = sa1100_rtc_alarm_irq_enable,
|
2006-03-27 09:16:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int sa1100_rtc_probe(struct platform_device *pdev)
|
|
|
|
{
|
2012-01-19 11:55:21 +00:00
|
|
|
struct rtc_device *rtc;
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info;
|
|
|
|
int irq_1hz, irq_alarm, ret = 0;
|
|
|
|
|
|
|
|
irq_1hz = platform_get_irq_byname(pdev, "rtc 1Hz");
|
|
|
|
irq_alarm = platform_get_irq_byname(pdev, "rtc alarm");
|
|
|
|
if (irq_1hz < 0 || irq_alarm < 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
|
|
|
|
if (!info)
|
|
|
|
return -ENOMEM;
|
2012-02-23 15:36:37 +00:00
|
|
|
info->clk = clk_get(&pdev->dev, NULL);
|
|
|
|
if (IS_ERR(info->clk)) {
|
|
|
|
dev_err(&pdev->dev, "failed to find rtc clock source\n");
|
|
|
|
ret = PTR_ERR(info->clk);
|
|
|
|
goto err_clk;
|
|
|
|
}
|
2012-02-21 03:51:13 +00:00
|
|
|
info->irq_1hz = irq_1hz;
|
|
|
|
info->irq_alarm = irq_alarm;
|
|
|
|
spin_lock_init(&info->lock);
|
|
|
|
platform_set_drvdata(pdev, info);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* According to the manual we should be able to let RTTR be zero
|
|
|
|
* and then a default diviser for a 32.768KHz clock is used.
|
|
|
|
* Apparently this doesn't work, at least for my SA1110 rev 5.
|
|
|
|
* If the clock divider is uninitialized then reset it to the
|
|
|
|
* default value to get the 1Hz clock.
|
|
|
|
*/
|
2012-01-19 11:55:21 +00:00
|
|
|
if (RTTR == 0) {
|
|
|
|
RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
|
|
|
|
dev_warn(&pdev->dev, "warning: "
|
|
|
|
"initializing default clock divider/trim value\n");
|
2006-03-27 09:16:46 +00:00
|
|
|
/* The current RTC value probably doesn't make sense either */
|
2012-01-19 11:55:21 +00:00
|
|
|
RCNR = 0;
|
2006-03-27 09:16:46 +00:00
|
|
|
}
|
|
|
|
|
2008-06-18 08:54:03 +00:00
|
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
|
|
|
2012-01-19 11:55:21 +00:00
|
|
|
rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops,
|
|
|
|
THIS_MODULE);
|
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
if (IS_ERR(rtc)) {
|
|
|
|
ret = PTR_ERR(rtc);
|
|
|
|
goto err_dev;
|
|
|
|
}
|
|
|
|
info->rtc = rtc;
|
2012-01-19 11:55:21 +00:00
|
|
|
|
2010-10-18 21:35:54 +00:00
|
|
|
/* Fix for a nasty initialization problem the in SA11xx RTSR register.
|
|
|
|
* See also the comments in sa1100_rtc_interrupt().
|
|
|
|
*
|
|
|
|
* Sometimes bit 1 of the RTSR (RTSR_HZ) will wake up 1, which means an
|
|
|
|
* interrupt pending, even though interrupts were never enabled.
|
|
|
|
* In this case, this bit it must be reset before enabling
|
|
|
|
* interruptions to avoid a nonexistent interrupt to occur.
|
|
|
|
*
|
|
|
|
* In principle, the same problem would apply to bit 0, although it has
|
|
|
|
* never been observed to happen.
|
|
|
|
*
|
|
|
|
* This issue is addressed both here and in sa1100_rtc_interrupt().
|
|
|
|
* If the issue is not addressed here, in the times when the processor
|
|
|
|
* wakes up with the bit set there will be one spurious interrupt.
|
|
|
|
*
|
|
|
|
* The issue is also dealt with in sa1100_rtc_interrupt() to be on the
|
|
|
|
* safe side, once the condition that lead to this strange
|
|
|
|
* initialization is unknown and could in principle happen during
|
|
|
|
* normal processing.
|
|
|
|
*
|
|
|
|
* Notice that clearing bit 1 and 0 is accomplished by writting ONES to
|
|
|
|
* the corresponding bits in RTSR. */
|
2012-01-19 11:55:21 +00:00
|
|
|
RTSR = RTSR_AL | RTSR_HZ;
|
2010-10-18 21:35:54 +00:00
|
|
|
|
2006-03-27 09:16:46 +00:00
|
|
|
return 0;
|
2012-02-21 03:51:13 +00:00
|
|
|
err_dev:
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
2012-02-23 15:36:37 +00:00
|
|
|
clk_put(info->clk);
|
|
|
|
err_clk:
|
2012-02-21 03:51:13 +00:00
|
|
|
kfree(info);
|
|
|
|
return ret;
|
2006-03-27 09:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_remove(struct platform_device *pdev)
|
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = platform_get_drvdata(pdev);
|
2012-01-19 11:55:21 +00:00
|
|
|
|
2012-02-21 03:51:13 +00:00
|
|
|
if (info) {
|
|
|
|
rtc_device_unregister(info->rtc);
|
2012-02-23 15:36:37 +00:00
|
|
|
clk_put(info->clk);
|
2012-02-21 03:51:13 +00:00
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
kfree(info);
|
|
|
|
}
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-12 22:49:58 +00:00
|
|
|
#ifdef CONFIG_PM
|
2009-07-21 06:31:09 +00:00
|
|
|
static int sa1100_rtc_suspend(struct device *dev)
|
2007-11-12 22:49:58 +00:00
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2009-07-21 06:31:09 +00:00
|
|
|
if (device_may_wakeup(dev))
|
2012-02-21 03:51:13 +00:00
|
|
|
enable_irq_wake(info->irq_alarm);
|
2007-11-12 22:49:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-21 06:31:09 +00:00
|
|
|
static int sa1100_rtc_resume(struct device *dev)
|
2007-11-12 22:49:58 +00:00
|
|
|
{
|
2012-02-21 03:51:13 +00:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2009-07-21 06:31:09 +00:00
|
|
|
if (device_may_wakeup(dev))
|
2012-02-21 03:51:13 +00:00
|
|
|
disable_irq_wake(info->irq_alarm);
|
2007-11-12 22:49:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-07-21 06:31:09 +00:00
|
|
|
|
2009-12-15 02:00:08 +00:00
|
|
|
static const struct dev_pm_ops sa1100_rtc_pm_ops = {
|
2009-07-21 06:31:09 +00:00
|
|
|
.suspend = sa1100_rtc_suspend,
|
|
|
|
.resume = sa1100_rtc_resume,
|
|
|
|
};
|
2007-11-12 22:49:58 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-05 11:26:42 +00:00
|
|
|
static struct of_device_id sa1100_rtc_dt_ids[] = {
|
|
|
|
{ .compatible = "mrvl,sa1100-rtc", },
|
|
|
|
{ .compatible = "mrvl,mmp-rtc", },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids);
|
|
|
|
|
2006-03-27 09:16:46 +00:00
|
|
|
static struct platform_driver sa1100_rtc_driver = {
|
|
|
|
.probe = sa1100_rtc_probe,
|
|
|
|
.remove = sa1100_rtc_remove,
|
|
|
|
.driver = {
|
2009-07-21 06:31:09 +00:00
|
|
|
.name = "sa1100-rtc",
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.pm = &sa1100_rtc_pm_ops,
|
|
|
|
#endif
|
2012-03-05 11:26:42 +00:00
|
|
|
.of_match_table = sa1100_rtc_dt_ids,
|
2006-03-27 09:16:46 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-10 23:10:48 +00:00
|
|
|
module_platform_driver(sa1100_rtc_driver);
|
2006-03-27 09:16:46 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
|
|
|
|
MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-11 04:29:25 +00:00
|
|
|
MODULE_ALIAS("platform:sa1100-rtc");
|