2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2010-02-16 17:47:35 +00:00
|
|
|
/*
|
|
|
|
* Real-time clock driver for MPC5121
|
|
|
|
*
|
|
|
|
* Copyright 2007, Domen Puncer <domen.puncer@telargo.com>
|
|
|
|
* Copyright 2008, Freescale Semiconductor, Inc. All rights reserved.
|
2011-07-26 00:13:30 +00:00
|
|
|
* Copyright 2011, Dmitry Eremin-Solenikov
|
2010-02-16 17:47:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/rtc.h>
|
2013-02-22 00:44:28 +00:00
|
|
|
#include <linux/of.h>
|
2013-09-17 19:28:33 +00:00
|
|
|
#include <linux/of_address.h>
|
2010-02-16 17:47:35 +00:00
|
|
|
#include <linux/of_device.h>
|
2013-09-17 19:28:33 +00:00
|
|
|
#include <linux/of_irq.h>
|
2010-02-16 17:47:35 +00:00
|
|
|
#include <linux/of_platform.h>
|
|
|
|
#include <linux/io.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2010-02-16 17:47:35 +00:00
|
|
|
|
|
|
|
struct mpc5121_rtc_regs {
|
|
|
|
u8 set_time; /* RTC + 0x00 */
|
|
|
|
u8 hour_set; /* RTC + 0x01 */
|
|
|
|
u8 minute_set; /* RTC + 0x02 */
|
|
|
|
u8 second_set; /* RTC + 0x03 */
|
|
|
|
|
|
|
|
u8 set_date; /* RTC + 0x04 */
|
|
|
|
u8 month_set; /* RTC + 0x05 */
|
|
|
|
u8 weekday_set; /* RTC + 0x06 */
|
|
|
|
u8 date_set; /* RTC + 0x07 */
|
|
|
|
|
|
|
|
u8 write_sw; /* RTC + 0x08 */
|
|
|
|
u8 sw_set; /* RTC + 0x09 */
|
|
|
|
u16 year_set; /* RTC + 0x0a */
|
|
|
|
|
|
|
|
u8 alm_enable; /* RTC + 0x0c */
|
|
|
|
u8 alm_hour_set; /* RTC + 0x0d */
|
|
|
|
u8 alm_min_set; /* RTC + 0x0e */
|
|
|
|
u8 int_enable; /* RTC + 0x0f */
|
|
|
|
|
|
|
|
u8 reserved1;
|
|
|
|
u8 hour; /* RTC + 0x11 */
|
|
|
|
u8 minute; /* RTC + 0x12 */
|
|
|
|
u8 second; /* RTC + 0x13 */
|
|
|
|
|
|
|
|
u8 month; /* RTC + 0x14 */
|
|
|
|
u8 wday_mday; /* RTC + 0x15 */
|
|
|
|
u16 year; /* RTC + 0x16 */
|
|
|
|
|
|
|
|
u8 int_alm; /* RTC + 0x18 */
|
|
|
|
u8 int_sw; /* RTC + 0x19 */
|
|
|
|
u8 alm_status; /* RTC + 0x1a */
|
|
|
|
u8 sw_minute; /* RTC + 0x1b */
|
|
|
|
|
|
|
|
u8 bus_error_1; /* RTC + 0x1c */
|
|
|
|
u8 int_day; /* RTC + 0x1d */
|
|
|
|
u8 int_min; /* RTC + 0x1e */
|
|
|
|
u8 int_sec; /* RTC + 0x1f */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* target_time:
|
|
|
|
* intended to be used for hibernation but hibernation
|
|
|
|
* does not work on silicon rev 1.5 so use it for non-volatile
|
|
|
|
* storage of offset between the actual_time register and linux
|
|
|
|
* time
|
|
|
|
*/
|
|
|
|
u32 target_time; /* RTC + 0x20 */
|
|
|
|
/*
|
|
|
|
* actual_time:
|
2013-07-03 22:05:57 +00:00
|
|
|
* readonly time since VBAT_RTC was last connected
|
2010-02-16 17:47:35 +00:00
|
|
|
*/
|
|
|
|
u32 actual_time; /* RTC + 0x24 */
|
|
|
|
u32 keep_alive; /* RTC + 0x28 */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mpc5121_rtc_data {
|
|
|
|
unsigned irq;
|
|
|
|
unsigned irq_periodic;
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs;
|
|
|
|
struct rtc_device *rtc;
|
|
|
|
struct rtc_wkalrm wkalarm;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update second/minute/hour registers.
|
|
|
|
*
|
|
|
|
* This is just so alarm will work.
|
|
|
|
*/
|
|
|
|
static void mpc5121_rtc_update_smh(struct mpc5121_rtc_regs __iomem *regs,
|
|
|
|
struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
out_8(®s->second_set, tm->tm_sec);
|
|
|
|
out_8(®s->minute_set, tm->tm_min);
|
|
|
|
out_8(®s->hour_set, tm->tm_hour);
|
|
|
|
|
|
|
|
/* set time sequence */
|
|
|
|
out_8(®s->set_time, 0x1);
|
|
|
|
out_8(®s->set_time, 0x3);
|
|
|
|
out_8(®s->set_time, 0x1);
|
|
|
|
out_8(®s->set_time, 0x0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpc5121_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
unsigned long now;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* linux time is actual_time plus the offset saved in target_time
|
|
|
|
*/
|
|
|
|
now = in_be32(®s->actual_time) + in_be32(®s->target_time);
|
|
|
|
|
|
|
|
rtc_time_to_tm(now, tm);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* update second minute hour registers
|
|
|
|
* so alarms will work
|
|
|
|
*/
|
|
|
|
mpc5121_rtc_update_smh(regs, tm);
|
|
|
|
|
2018-02-19 15:23:55 +00:00
|
|
|
return 0;
|
2010-02-16 17:47:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mpc5121_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
int ret;
|
|
|
|
unsigned long now;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The actual_time register is read only so we write the offset
|
|
|
|
* between it and linux time to the target_time register.
|
|
|
|
*/
|
|
|
|
ret = rtc_tm_to_time(tm, &now);
|
|
|
|
if (ret == 0)
|
|
|
|
out_be32(®s->target_time, now - in_be32(®s->actual_time));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* update second minute hour registers
|
|
|
|
* so alarms will work
|
|
|
|
*/
|
|
|
|
mpc5121_rtc_update_smh(regs, tm);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-26 00:13:30 +00:00
|
|
|
static int mpc5200_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
tm->tm_sec = in_8(®s->second);
|
|
|
|
tm->tm_min = in_8(®s->minute);
|
|
|
|
|
|
|
|
/* 12 hour format? */
|
|
|
|
if (in_8(®s->hour) & 0x20)
|
|
|
|
tm->tm_hour = (in_8(®s->hour) >> 1) +
|
|
|
|
(in_8(®s->hour) & 1 ? 12 : 0);
|
|
|
|
else
|
|
|
|
tm->tm_hour = in_8(®s->hour);
|
|
|
|
|
|
|
|
tmp = in_8(®s->wday_mday);
|
|
|
|
tm->tm_mday = tmp & 0x1f;
|
|
|
|
tm->tm_mon = in_8(®s->month) - 1;
|
|
|
|
tm->tm_year = in_be16(®s->year) - 1900;
|
|
|
|
tm->tm_wday = (tmp >> 5) % 7;
|
|
|
|
tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
|
|
|
|
tm->tm_isdst = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpc5200_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
mpc5121_rtc_update_smh(regs, tm);
|
|
|
|
|
|
|
|
/* date */
|
|
|
|
out_8(®s->month_set, tm->tm_mon + 1);
|
|
|
|
out_8(®s->weekday_set, tm->tm_wday ? tm->tm_wday : 7);
|
|
|
|
out_8(®s->date_set, tm->tm_mday);
|
|
|
|
out_be16(®s->year_set, tm->tm_year + 1900);
|
|
|
|
|
|
|
|
/* set date sequence */
|
|
|
|
out_8(®s->set_date, 0x1);
|
|
|
|
out_8(®s->set_date, 0x3);
|
|
|
|
out_8(®s->set_date, 0x1);
|
|
|
|
out_8(®s->set_date, 0x0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-16 17:47:35 +00:00
|
|
|
static int mpc5121_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
*alarm = rtc->wkalarm;
|
|
|
|
|
|
|
|
alarm->pending = in_8(®s->alm_status);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpc5121_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the alarm has no seconds so deal with it
|
|
|
|
*/
|
|
|
|
if (alarm->time.tm_sec) {
|
|
|
|
alarm->time.tm_sec = 0;
|
|
|
|
alarm->time.tm_min++;
|
|
|
|
if (alarm->time.tm_min >= 60) {
|
|
|
|
alarm->time.tm_min = 0;
|
|
|
|
alarm->time.tm_hour++;
|
|
|
|
if (alarm->time.tm_hour >= 24)
|
|
|
|
alarm->time.tm_hour = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
alarm->time.tm_mday = -1;
|
|
|
|
alarm->time.tm_mon = -1;
|
|
|
|
alarm->time.tm_year = -1;
|
|
|
|
|
|
|
|
out_8(®s->alm_min_set, alarm->time.tm_min);
|
|
|
|
out_8(®s->alm_hour_set, alarm->time.tm_hour);
|
|
|
|
|
|
|
|
out_8(®s->alm_enable, alarm->enabled);
|
|
|
|
|
|
|
|
rtc->wkalarm = *alarm;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mpc5121_rtc_handler(int irq, void *dev)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata((struct device *)dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
if (in_8(®s->int_alm)) {
|
|
|
|
/* acknowledge and clear status */
|
|
|
|
out_8(®s->int_alm, 1);
|
|
|
|
out_8(®s->alm_status, 1);
|
|
|
|
|
|
|
|
rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t mpc5121_rtc_handler_upd(int irq, void *dev)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata((struct device *)dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
if (in_8(®s->int_sec) && (in_8(®s->int_enable) & 0x1)) {
|
|
|
|
/* acknowledge */
|
|
|
|
out_8(®s->int_sec, 1);
|
|
|
|
|
|
|
|
rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_UF);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mpc5121_rtc_alarm_irq_enable(struct device *dev,
|
|
|
|
unsigned int enabled)
|
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev);
|
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
int val;
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
val = 1;
|
|
|
|
else
|
|
|
|
val = 0;
|
|
|
|
|
|
|
|
out_8(®s->alm_enable, val);
|
|
|
|
rtc->wkalarm.enabled = val;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct rtc_class_ops mpc5121_rtc_ops = {
|
|
|
|
.read_time = mpc5121_rtc_read_time,
|
|
|
|
.set_time = mpc5121_rtc_set_time,
|
|
|
|
.read_alarm = mpc5121_rtc_read_alarm,
|
|
|
|
.set_alarm = mpc5121_rtc_set_alarm,
|
|
|
|
.alarm_irq_enable = mpc5121_rtc_alarm_irq_enable,
|
|
|
|
};
|
|
|
|
|
2011-07-26 00:13:30 +00:00
|
|
|
static const struct rtc_class_ops mpc5200_rtc_ops = {
|
|
|
|
.read_time = mpc5200_rtc_read_time,
|
|
|
|
.set_time = mpc5200_rtc_set_time,
|
|
|
|
.read_alarm = mpc5121_rtc_read_alarm,
|
|
|
|
.set_alarm = mpc5121_rtc_set_alarm,
|
|
|
|
.alarm_irq_enable = mpc5121_rtc_alarm_irq_enable,
|
|
|
|
};
|
|
|
|
|
2012-12-21 21:09:38 +00:00
|
|
|
static int mpc5121_rtc_probe(struct platform_device *op)
|
2010-02-16 17:47:35 +00:00
|
|
|
{
|
|
|
|
struct mpc5121_rtc_data *rtc;
|
|
|
|
int err = 0;
|
|
|
|
|
2013-07-03 22:07:07 +00:00
|
|
|
rtc = devm_kzalloc(&op->dev, sizeof(*rtc), GFP_KERNEL);
|
2010-02-16 17:47:35 +00:00
|
|
|
if (!rtc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2020-03-06 07:44:00 +00:00
|
|
|
rtc->regs = devm_platform_ioremap_resource(op, 0);
|
|
|
|
if (IS_ERR(rtc->regs)) {
|
2010-02-16 17:47:35 +00:00
|
|
|
dev_err(&op->dev, "%s: couldn't map io space\n", __func__);
|
2013-07-03 22:07:07 +00:00
|
|
|
return -ENOSYS;
|
2010-02-16 17:47:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
device_init_wakeup(&op->dev, 1);
|
|
|
|
|
2013-07-03 22:07:47 +00:00
|
|
|
platform_set_drvdata(op, rtc);
|
2010-02-16 17:47:35 +00:00
|
|
|
|
2010-06-02 20:06:09 +00:00
|
|
|
rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1);
|
2020-03-06 07:44:00 +00:00
|
|
|
err = devm_request_irq(&op->dev, rtc->irq, mpc5121_rtc_handler, 0,
|
|
|
|
"mpc5121-rtc", &op->dev);
|
2010-02-16 17:47:35 +00:00
|
|
|
if (err) {
|
|
|
|
dev_err(&op->dev, "%s: could not request irq: %i\n",
|
|
|
|
__func__, rtc->irq);
|
|
|
|
goto out_dispose;
|
|
|
|
}
|
|
|
|
|
2010-06-02 20:06:09 +00:00
|
|
|
rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0);
|
2020-03-06 07:44:00 +00:00
|
|
|
err = devm_request_irq(&op->dev, rtc->irq_periodic,
|
|
|
|
mpc5121_rtc_handler_upd, 0, "mpc5121-rtc_upd",
|
|
|
|
&op->dev);
|
2010-02-16 17:47:35 +00:00
|
|
|
if (err) {
|
|
|
|
dev_err(&op->dev, "%s: could not request irq: %i\n",
|
|
|
|
__func__, rtc->irq_periodic);
|
|
|
|
goto out_dispose2;
|
|
|
|
}
|
|
|
|
|
2020-03-06 07:44:01 +00:00
|
|
|
rtc->rtc = devm_rtc_allocate_device(&op->dev);
|
|
|
|
if (IS_ERR(rtc->rtc)) {
|
|
|
|
err = PTR_ERR(rtc->rtc);
|
|
|
|
goto out_dispose2;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtc->rtc->ops = &mpc5200_rtc_ops;
|
|
|
|
rtc->rtc->uie_unsupported = 1;
|
|
|
|
|
2011-07-26 00:13:30 +00:00
|
|
|
if (of_device_is_compatible(op->dev.of_node, "fsl,mpc5121-rtc")) {
|
|
|
|
u32 ka;
|
|
|
|
ka = in_be32(&rtc->regs->keep_alive);
|
|
|
|
if (ka & 0x02) {
|
|
|
|
dev_warn(&op->dev,
|
|
|
|
"mpc5121-rtc: Battery or oscillator failure!\n");
|
|
|
|
out_be32(&rtc->regs->keep_alive, ka);
|
|
|
|
}
|
2020-03-06 07:44:01 +00:00
|
|
|
rtc->rtc->ops = &mpc5121_rtc_ops;
|
2010-02-16 17:47:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 07:44:01 +00:00
|
|
|
err = rtc_register_device(rtc->rtc);
|
|
|
|
if (err)
|
2020-03-06 07:44:00 +00:00
|
|
|
goto out_dispose2;
|
2010-02-16 17:47:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_dispose2:
|
|
|
|
irq_dispose_mapping(rtc->irq_periodic);
|
|
|
|
out_dispose:
|
|
|
|
irq_dispose_mapping(rtc->irq);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-21 21:09:38 +00:00
|
|
|
static int mpc5121_rtc_remove(struct platform_device *op)
|
2010-02-16 17:47:35 +00:00
|
|
|
{
|
2013-07-03 22:07:47 +00:00
|
|
|
struct mpc5121_rtc_data *rtc = platform_get_drvdata(op);
|
2010-02-16 17:47:35 +00:00
|
|
|
struct mpc5121_rtc_regs __iomem *regs = rtc->regs;
|
|
|
|
|
|
|
|
/* disable interrupt, so there are no nasty surprises */
|
|
|
|
out_8(®s->alm_enable, 0);
|
|
|
|
out_8(®s->int_enable, in_8(®s->int_enable) & ~0x1);
|
|
|
|
|
|
|
|
irq_dispose_mapping(rtc->irq);
|
|
|
|
irq_dispose_mapping(rtc->irq_periodic);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-22 00:44:28 +00:00
|
|
|
#ifdef CONFIG_OF
|
2014-10-13 22:52:39 +00:00
|
|
|
static const struct of_device_id mpc5121_rtc_match[] = {
|
2010-02-16 17:47:35 +00:00
|
|
|
{ .compatible = "fsl,mpc5121-rtc", },
|
2011-07-26 00:13:30 +00:00
|
|
|
{ .compatible = "fsl,mpc5200-rtc", },
|
2010-02-16 17:47:35 +00:00
|
|
|
{},
|
|
|
|
};
|
2015-08-27 11:52:02 +00:00
|
|
|
MODULE_DEVICE_TABLE(of, mpc5121_rtc_match);
|
2013-02-22 00:44:28 +00:00
|
|
|
#endif
|
2010-02-16 17:47:35 +00:00
|
|
|
|
2011-02-17 09:43:24 +00:00
|
|
|
static struct platform_driver mpc5121_rtc_driver = {
|
2010-06-02 20:06:09 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "mpc5121-rtc",
|
2013-02-22 00:44:28 +00:00
|
|
|
.of_match_table = of_match_ptr(mpc5121_rtc_match),
|
2010-06-02 20:06:09 +00:00
|
|
|
},
|
2010-02-16 17:47:35 +00:00
|
|
|
.probe = mpc5121_rtc_probe,
|
2012-12-21 21:09:38 +00:00
|
|
|
.remove = mpc5121_rtc_remove,
|
2010-02-16 17:47:35 +00:00
|
|
|
};
|
|
|
|
|
2012-01-10 23:10:48 +00:00
|
|
|
module_platform_driver(mpc5121_rtc_driver);
|
2010-02-16 17:47:35 +00:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("John Rigby <jcrigby@gmail.com>");
|