2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2006-03-27 17:16:46 +08: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 15:25:28 +08:00
|
|
|
* Nicolas Pitre <nico@fluxnic.net>
|
2006-03-27 17:16:46 +08:00
|
|
|
* Andrew Christian <andrew.christian@hp.com>
|
|
|
|
*
|
|
|
|
* Converted to the RTC subsystem and Driver Model
|
|
|
|
* by Richard Purdie <rpurdie@rpsys.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/module.h>
|
2012-02-23 23:36:37 +08:00
|
|
|
#include <linux/clk.h>
|
2006-03-27 17:16:46 +08:00
|
|
|
#include <linux/rtc.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/interrupt.h>
|
2012-02-21 11:51:13 +08:00
|
|
|
#include <linux/slab.h>
|
2012-01-19 19:55:21 +08:00
|
|
|
#include <linux/string.h>
|
2012-03-05 19:26:42 +08:00
|
|
|
#include <linux/of.h>
|
2006-03-27 17:16:46 +08:00
|
|
|
#include <linux/pm.h>
|
2012-01-19 19:55:21 +08:00
|
|
|
#include <linux/bitops.h>
|
2012-03-21 03:33:19 +08:00
|
|
|
#include <linux/io.h>
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2015-02-04 04:44:51 +08:00
|
|
|
#define RTSR_HZE BIT(3) /* HZ interrupt enable */
|
|
|
|
#define RTSR_ALE BIT(2) /* RTC alarm interrupt enable */
|
|
|
|
#define RTSR_HZ BIT(1) /* HZ rising-edge detected */
|
|
|
|
#define RTSR_AL BIT(0) /* RTC alarm detected */
|
2012-01-19 19:55:21 +08:00
|
|
|
|
2015-05-13 05:23:23 +08:00
|
|
|
#include "rtc-sa1100.h"
|
|
|
|
|
2010-10-19 05:33:53 +08:00
|
|
|
#define RTC_DEF_DIVIDER (32768 - 1)
|
2006-03-27 17:16:46 +08:00
|
|
|
#define RTC_DEF_TRIM 0
|
2012-02-21 11:51:13 +08:00
|
|
|
#define RTC_FREQ 1024
|
2012-01-19 19:55:21 +08: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 21:55:46 +08:00
|
|
|
static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
|
2006-03-27 17:16:46 +08:00
|
|
|
{
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev_id);
|
|
|
|
struct rtc_device *rtc = info->rtc;
|
2006-03-27 17:16:46 +08:00
|
|
|
unsigned int rtsr;
|
|
|
|
unsigned long events = 0;
|
|
|
|
|
2012-02-21 11:51:13 +08:00
|
|
|
spin_lock(&info->lock);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2015-02-04 04:44:51 +08:00
|
|
|
rtsr = readl_relaxed(info->rtsr);
|
2006-03-27 17:16:46 +08:00
|
|
|
/* clear interrupt sources */
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(0, info->rtsr);
|
2010-10-19 05:35:54 +08: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. */
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed((RTSR_AL | RTSR_HZ) & (rtsr >> 2), info->rtsr);
|
2010-10-19 05:35:54 +08: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(). */
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(RTSR_AL | RTSR_HZ, info->rtsr);
|
2010-10-19 05:35:54 +08:00
|
|
|
}
|
2006-03-27 17:16:46 +08:00
|
|
|
|
|
|
|
/* clear alarm interrupt if it has occurred */
|
|
|
|
if (rtsr & RTSR_AL)
|
|
|
|
rtsr &= ~RTSR_ALE;
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(rtsr & (RTSR_ALE | RTSR_HZE), info->rtsr);
|
2006-03-27 17:16:46 +08: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 19:55:21 +08:00
|
|
|
rtc_update_irq(rtc, 1, events);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2012-02-21 11:51:13 +08:00
|
|
|
spin_unlock(&info->lock);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2011-02-03 09:02:41 +08:00
|
|
|
static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
|
|
|
{
|
2015-02-04 04:44:51 +08:00
|
|
|
u32 rtsr;
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
spin_lock_irq(&info->lock);
|
2015-02-04 04:44:51 +08:00
|
|
|
rtsr = readl_relaxed(info->rtsr);
|
2011-02-03 09:02:41 +08:00
|
|
|
if (enabled)
|
2015-02-04 04:44:51 +08:00
|
|
|
rtsr |= RTSR_ALE;
|
2011-02-03 09:02:41 +08:00
|
|
|
else
|
2015-02-04 04:44:51 +08:00
|
|
|
rtsr &= ~RTSR_ALE;
|
|
|
|
writel_relaxed(rtsr, info->rtsr);
|
2012-02-21 11:51:13 +08:00
|
|
|
spin_unlock_irq(&info->lock);
|
2011-02-03 09:02:41 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-27 17:16:46 +08:00
|
|
|
static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
2015-02-04 04:44:51 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
|
2020-03-06 09:01:46 +08:00
|
|
|
rtc_time64_to_tm(readl_relaxed(info->rcnr), tm);
|
2006-03-27 17:16:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
2015-02-04 04:44:51 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2020-03-06 09:01:46 +08:00
|
|
|
writel_relaxed(rtc_tm_to_time64(tm), info->rcnr);
|
|
|
|
|
|
|
|
return 0;
|
2006-03-27 17:16:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
|
|
{
|
2012-01-19 19:55:21 +08:00
|
|
|
u32 rtsr;
|
2015-02-04 04:44:51 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2007-02-21 05:58:13 +08:00
|
|
|
|
2015-02-04 04:44:51 +08:00
|
|
|
rtsr = readl_relaxed(info->rtsr);
|
2007-02-21 05:58:13 +08:00
|
|
|
alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
|
|
|
|
alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
|
2006-03-27 17:16:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
|
|
{
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2012-02-21 11:51:13 +08:00
|
|
|
spin_lock_irq(&info->lock);
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(readl_relaxed(info->rtsr) &
|
|
|
|
(RTSR_HZE | RTSR_ALE | RTSR_AL), info->rtsr);
|
2020-03-06 09:01:46 +08:00
|
|
|
writel_relaxed(rtc_tm_to_time64(&alrm->time), info->rtar);
|
2012-02-20 19:49:30 +08:00
|
|
|
if (alrm->enabled)
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(readl_relaxed(info->rtsr) | RTSR_ALE, info->rtsr);
|
2012-02-20 19:49:30 +08:00
|
|
|
else
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(readl_relaxed(info->rtsr) & ~RTSR_ALE, info->rtsr);
|
2012-02-21 11:51:13 +08:00
|
|
|
spin_unlock_irq(&info->lock);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2020-03-06 09:01:46 +08:00
|
|
|
return 0;
|
2006-03-27 17:16:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
|
|
|
|
{
|
2015-02-04 04:44:51 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
seq_printf(seq, "trim/divider\t\t: 0x%08x\n", readl_relaxed(info->rttr));
|
|
|
|
seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", readl_relaxed(info->rtsr));
|
2006-03-27 17:16:46 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-01 14:28:17 +08:00
|
|
|
static const struct rtc_class_ops sa1100_rtc_ops = {
|
2006-03-27 17:16:46 +08:00
|
|
|
.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 09:02:41 +08:00
|
|
|
.alarm_irq_enable = sa1100_rtc_alarm_irq_enable,
|
2006-03-27 17:16:46 +08:00
|
|
|
};
|
|
|
|
|
2015-05-13 05:23:23 +08:00
|
|
|
int sa1100_rtc_init(struct platform_device *pdev, struct sa1100_rtc *info)
|
2006-03-27 17:16:46 +08:00
|
|
|
{
|
2015-05-13 05:23:23 +08:00
|
|
|
int ret;
|
2012-02-21 11:51:13 +08:00
|
|
|
|
2015-05-13 05:23:23 +08:00
|
|
|
spin_lock_init(&info->lock);
|
2012-02-21 11:51:13 +08:00
|
|
|
|
2013-04-30 07:20:54 +08:00
|
|
|
info->clk = devm_clk_get(&pdev->dev, NULL);
|
2012-02-23 23:36:37 +08:00
|
|
|
if (IS_ERR(info->clk)) {
|
|
|
|
dev_err(&pdev->dev, "failed to find rtc clock source\n");
|
2013-04-30 07:20:54 +08:00
|
|
|
return PTR_ERR(info->clk);
|
2012-02-23 23:36:37 +08:00
|
|
|
}
|
2006-03-27 17:16:46 +08:00
|
|
|
|
2013-02-22 08:45:17 +08:00
|
|
|
ret = clk_prepare_enable(info->clk);
|
|
|
|
if (ret)
|
2013-07-04 06:06:35 +08:00
|
|
|
return ret;
|
2006-03-27 17:16:46 +08: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.
|
|
|
|
*/
|
2015-02-04 04:44:51 +08:00
|
|
|
if (readl_relaxed(info->rttr) == 0) {
|
|
|
|
writel_relaxed(RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16), info->rttr);
|
2012-01-19 19:55:21 +08:00
|
|
|
dev_warn(&pdev->dev, "warning: "
|
|
|
|
"initializing default clock divider/trim value\n");
|
2006-03-27 17:16:46 +08:00
|
|
|
/* The current RTC value probably doesn't make sense either */
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(0, info->rcnr);
|
2006-03-27 17:16:46 +08:00
|
|
|
}
|
|
|
|
|
2020-03-06 09:01:44 +08:00
|
|
|
info->rtc->ops = &sa1100_rtc_ops;
|
|
|
|
info->rtc->max_user_freq = RTC_FREQ;
|
2020-03-06 09:01:45 +08:00
|
|
|
info->rtc->range_max = U32_MAX;
|
2020-03-06 09:01:44 +08:00
|
|
|
|
2020-11-10 00:34:08 +08:00
|
|
|
ret = devm_rtc_register_device(info->rtc);
|
2020-03-06 09:01:44 +08:00
|
|
|
if (ret) {
|
2015-05-13 05:23:23 +08:00
|
|
|
clk_disable_unprepare(info->clk);
|
2020-03-06 09:01:44 +08:00
|
|
|
return ret;
|
2012-02-21 11:51:13 +08:00
|
|
|
}
|
2017-08-23 07:48:35 +08:00
|
|
|
|
2010-10-19 05:35:54 +08: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. */
|
2015-02-04 04:44:51 +08:00
|
|
|
writel_relaxed(RTSR_AL | RTSR_HZ, info->rtsr);
|
2010-10-19 05:35:54 +08:00
|
|
|
|
2006-03-27 17:16:46 +08:00
|
|
|
return 0;
|
2015-05-13 05:23:23 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(sa1100_rtc_init);
|
|
|
|
|
|
|
|
static int sa1100_rtc_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct sa1100_rtc *info;
|
2015-02-04 04:44:51 +08:00
|
|
|
void __iomem *base;
|
2015-05-13 05:23:23 +08:00
|
|
|
int irq_1hz, irq_alarm;
|
2017-08-23 07:48:35 +08:00
|
|
|
int ret;
|
2015-05-13 05:23:23 +08:00
|
|
|
|
|
|
|
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 = devm_kzalloc(&pdev->dev, sizeof(struct sa1100_rtc), GFP_KERNEL);
|
|
|
|
if (!info)
|
|
|
|
return -ENOMEM;
|
|
|
|
info->irq_1hz = irq_1hz;
|
|
|
|
info->irq_alarm = irq_alarm;
|
|
|
|
|
2020-03-06 09:01:44 +08:00
|
|
|
info->rtc = devm_rtc_allocate_device(&pdev->dev);
|
|
|
|
if (IS_ERR(info->rtc))
|
|
|
|
return PTR_ERR(info->rtc);
|
|
|
|
|
2017-08-23 07:48:35 +08:00
|
|
|
ret = devm_request_irq(&pdev->dev, irq_1hz, sa1100_rtc_interrupt, 0,
|
|
|
|
"rtc 1Hz", &pdev->dev);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "IRQ %d already in use.\n", irq_1hz);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = devm_request_irq(&pdev->dev, irq_alarm, sa1100_rtc_interrupt, 0,
|
|
|
|
"rtc Alrm", &pdev->dev);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "IRQ %d already in use.\n", irq_alarm);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-10-06 18:29:20 +08:00
|
|
|
base = devm_platform_ioremap_resource(pdev, 0);
|
2015-02-04 04:44:51 +08:00
|
|
|
if (IS_ERR(base))
|
|
|
|
return PTR_ERR(base);
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_ARCH_SA1100) ||
|
|
|
|
of_device_is_compatible(pdev->dev.of_node, "mrvl,sa1100-rtc")) {
|
|
|
|
info->rcnr = base + 0x04;
|
|
|
|
info->rtsr = base + 0x10;
|
|
|
|
info->rtar = base + 0x00;
|
|
|
|
info->rttr = base + 0x08;
|
|
|
|
} else {
|
|
|
|
info->rcnr = base + 0x0;
|
|
|
|
info->rtsr = base + 0x8;
|
|
|
|
info->rtar = base + 0x4;
|
|
|
|
info->rttr = base + 0xc;
|
|
|
|
}
|
|
|
|
|
2015-05-13 05:23:23 +08:00
|
|
|
platform_set_drvdata(pdev, info);
|
|
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
|
|
|
|
|
|
return sa1100_rtc_init(pdev, info);
|
2006-03-27 17:16:46 +08:00
|
|
|
}
|
|
|
|
|
2023-03-04 21:30:17 +08:00
|
|
|
static void sa1100_rtc_remove(struct platform_device *pdev)
|
2006-03-27 17:16:46 +08:00
|
|
|
{
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = platform_get_drvdata(pdev);
|
2012-01-19 19:55:21 +08:00
|
|
|
|
2017-08-23 07:48:35 +08:00
|
|
|
if (info) {
|
|
|
|
spin_lock_irq(&info->lock);
|
|
|
|
writel_relaxed(0, info->rtsr);
|
|
|
|
spin_unlock_irq(&info->lock);
|
2013-02-22 08:45:17 +08:00
|
|
|
clk_disable_unprepare(info->clk);
|
2017-08-23 07:48:35 +08:00
|
|
|
}
|
2006-03-27 17:16:46 +08:00
|
|
|
}
|
|
|
|
|
2013-04-30 07:19:59 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2009-07-21 14:31:09 +08:00
|
|
|
static int sa1100_rtc_suspend(struct device *dev)
|
2007-11-13 06:49:58 +08:00
|
|
|
{
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2009-07-21 14:31:09 +08:00
|
|
|
if (device_may_wakeup(dev))
|
2012-02-21 11:51:13 +08:00
|
|
|
enable_irq_wake(info->irq_alarm);
|
2007-11-13 06:49:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-21 14:31:09 +08:00
|
|
|
static int sa1100_rtc_resume(struct device *dev)
|
2007-11-13 06:49:58 +08:00
|
|
|
{
|
2012-02-21 11:51:13 +08:00
|
|
|
struct sa1100_rtc *info = dev_get_drvdata(dev);
|
2009-07-21 14:31:09 +08:00
|
|
|
if (device_may_wakeup(dev))
|
2012-02-21 11:51:13 +08:00
|
|
|
disable_irq_wake(info->irq_alarm);
|
2007-11-13 06:49:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-30 07:19:59 +08:00
|
|
|
static SIMPLE_DEV_PM_OPS(sa1100_rtc_pm_ops, sa1100_rtc_suspend,
|
|
|
|
sa1100_rtc_resume);
|
|
|
|
|
2013-02-22 08:44:28 +08:00
|
|
|
#ifdef CONFIG_OF
|
2014-06-07 05:36:13 +08:00
|
|
|
static const struct of_device_id sa1100_rtc_dt_ids[] = {
|
2012-03-05 19:26:42 +08:00
|
|
|
{ .compatible = "mrvl,sa1100-rtc", },
|
|
|
|
{ .compatible = "mrvl,mmp-rtc", },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids);
|
2013-02-22 08:44:28 +08:00
|
|
|
#endif
|
2012-03-05 19:26:42 +08:00
|
|
|
|
2006-03-27 17:16:46 +08:00
|
|
|
static struct platform_driver sa1100_rtc_driver = {
|
|
|
|
.probe = sa1100_rtc_probe,
|
2023-03-04 21:30:17 +08:00
|
|
|
.remove_new = sa1100_rtc_remove,
|
2006-03-27 17:16:46 +08:00
|
|
|
.driver = {
|
2009-07-21 14:31:09 +08:00
|
|
|
.name = "sa1100-rtc",
|
|
|
|
.pm = &sa1100_rtc_pm_ops,
|
2013-02-22 08:44:28 +08:00
|
|
|
.of_match_table = of_match_ptr(sa1100_rtc_dt_ids),
|
2006-03-27 17:16:46 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-11 07:10:48 +08:00
|
|
|
module_platform_driver(sa1100_rtc_driver);
|
2006-03-27 17:16:46 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
|
|
|
|
MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-11 12:29:25 +08:00
|
|
|
MODULE_ALIAS("platform:sa1100-rtc");
|