xref: /OK3568_Linux_fs/kernel/drivers/rtc/rtc-sa1100.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Real Time Clock interface for StrongARM SA1x00 and XScale PXA2xx
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2000 Nils Faerber
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Based on rtc.c by Paul Gortmaker
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Original Driver by Nils Faerber <nils@kernelconcepts.de>
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Modifications from:
12*4882a593Smuzhiyun  *   CIH <cih@coventive.com>
13*4882a593Smuzhiyun  *   Nicolas Pitre <nico@fluxnic.net>
14*4882a593Smuzhiyun  *   Andrew Christian <andrew.christian@hp.com>
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * Converted to the RTC subsystem and Driver Model
17*4882a593Smuzhiyun  *   by Richard Purdie <rpurdie@rpsys.net>
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #include <linux/platform_device.h>
21*4882a593Smuzhiyun #include <linux/module.h>
22*4882a593Smuzhiyun #include <linux/clk.h>
23*4882a593Smuzhiyun #include <linux/rtc.h>
24*4882a593Smuzhiyun #include <linux/init.h>
25*4882a593Smuzhiyun #include <linux/fs.h>
26*4882a593Smuzhiyun #include <linux/interrupt.h>
27*4882a593Smuzhiyun #include <linux/slab.h>
28*4882a593Smuzhiyun #include <linux/string.h>
29*4882a593Smuzhiyun #include <linux/of.h>
30*4882a593Smuzhiyun #include <linux/pm.h>
31*4882a593Smuzhiyun #include <linux/bitops.h>
32*4882a593Smuzhiyun #include <linux/io.h>
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define RTSR_HZE		BIT(3)	/* HZ interrupt enable */
35*4882a593Smuzhiyun #define RTSR_ALE		BIT(2)	/* RTC alarm interrupt enable */
36*4882a593Smuzhiyun #define RTSR_HZ			BIT(1)	/* HZ rising-edge detected */
37*4882a593Smuzhiyun #define RTSR_AL			BIT(0)	/* RTC alarm detected */
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #include "rtc-sa1100.h"
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define RTC_DEF_DIVIDER		(32768 - 1)
42*4882a593Smuzhiyun #define RTC_DEF_TRIM		0
43*4882a593Smuzhiyun #define RTC_FREQ		1024
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 
sa1100_rtc_interrupt(int irq,void * dev_id)46*4882a593Smuzhiyun static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
47*4882a593Smuzhiyun {
48*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev_id);
49*4882a593Smuzhiyun 	struct rtc_device *rtc = info->rtc;
50*4882a593Smuzhiyun 	unsigned int rtsr;
51*4882a593Smuzhiyun 	unsigned long events = 0;
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun 	spin_lock(&info->lock);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun 	rtsr = readl_relaxed(info->rtsr);
56*4882a593Smuzhiyun 	/* clear interrupt sources */
57*4882a593Smuzhiyun 	writel_relaxed(0, info->rtsr);
58*4882a593Smuzhiyun 	/* Fix for a nasty initialization problem the in SA11xx RTSR register.
59*4882a593Smuzhiyun 	 * See also the comments in sa1100_rtc_probe(). */
60*4882a593Smuzhiyun 	if (rtsr & (RTSR_ALE | RTSR_HZE)) {
61*4882a593Smuzhiyun 		/* This is the original code, before there was the if test
62*4882a593Smuzhiyun 		 * above. This code does not clear interrupts that were not
63*4882a593Smuzhiyun 		 * enabled. */
64*4882a593Smuzhiyun 		writel_relaxed((RTSR_AL | RTSR_HZ) & (rtsr >> 2), info->rtsr);
65*4882a593Smuzhiyun 	} else {
66*4882a593Smuzhiyun 		/* For some reason, it is possible to enter this routine
67*4882a593Smuzhiyun 		 * without interruptions enabled, it has been tested with
68*4882a593Smuzhiyun 		 * several units (Bug in SA11xx chip?).
69*4882a593Smuzhiyun 		 *
70*4882a593Smuzhiyun 		 * This situation leads to an infinite "loop" of interrupt
71*4882a593Smuzhiyun 		 * routine calling and as a result the processor seems to
72*4882a593Smuzhiyun 		 * lock on its first call to open(). */
73*4882a593Smuzhiyun 		writel_relaxed(RTSR_AL | RTSR_HZ, info->rtsr);
74*4882a593Smuzhiyun 	}
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	/* clear alarm interrupt if it has occurred */
77*4882a593Smuzhiyun 	if (rtsr & RTSR_AL)
78*4882a593Smuzhiyun 		rtsr &= ~RTSR_ALE;
79*4882a593Smuzhiyun 	writel_relaxed(rtsr & (RTSR_ALE | RTSR_HZE), info->rtsr);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun 	/* update irq data & counter */
82*4882a593Smuzhiyun 	if (rtsr & RTSR_AL)
83*4882a593Smuzhiyun 		events |= RTC_AF | RTC_IRQF;
84*4882a593Smuzhiyun 	if (rtsr & RTSR_HZ)
85*4882a593Smuzhiyun 		events |= RTC_UF | RTC_IRQF;
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun 	rtc_update_irq(rtc, 1, events);
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 	spin_unlock(&info->lock);
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	return IRQ_HANDLED;
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun 
sa1100_rtc_alarm_irq_enable(struct device * dev,unsigned int enabled)94*4882a593Smuzhiyun static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun 	u32 rtsr;
97*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun 	spin_lock_irq(&info->lock);
100*4882a593Smuzhiyun 	rtsr = readl_relaxed(info->rtsr);
101*4882a593Smuzhiyun 	if (enabled)
102*4882a593Smuzhiyun 		rtsr |= RTSR_ALE;
103*4882a593Smuzhiyun 	else
104*4882a593Smuzhiyun 		rtsr &= ~RTSR_ALE;
105*4882a593Smuzhiyun 	writel_relaxed(rtsr, info->rtsr);
106*4882a593Smuzhiyun 	spin_unlock_irq(&info->lock);
107*4882a593Smuzhiyun 	return 0;
108*4882a593Smuzhiyun }
109*4882a593Smuzhiyun 
sa1100_rtc_read_time(struct device * dev,struct rtc_time * tm)110*4882a593Smuzhiyun static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun 	rtc_time64_to_tm(readl_relaxed(info->rcnr), tm);
115*4882a593Smuzhiyun 	return 0;
116*4882a593Smuzhiyun }
117*4882a593Smuzhiyun 
sa1100_rtc_set_time(struct device * dev,struct rtc_time * tm)118*4882a593Smuzhiyun static int sa1100_rtc_set_time(struct device *dev, struct rtc_time *tm)
119*4882a593Smuzhiyun {
120*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun 	writel_relaxed(rtc_tm_to_time64(tm), info->rcnr);
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 	return 0;
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun 
sa1100_rtc_read_alarm(struct device * dev,struct rtc_wkalrm * alrm)127*4882a593Smuzhiyun static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
128*4882a593Smuzhiyun {
129*4882a593Smuzhiyun 	u32	rtsr;
130*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun 	rtsr = readl_relaxed(info->rtsr);
133*4882a593Smuzhiyun 	alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
134*4882a593Smuzhiyun 	alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
135*4882a593Smuzhiyun 	return 0;
136*4882a593Smuzhiyun }
137*4882a593Smuzhiyun 
sa1100_rtc_set_alarm(struct device * dev,struct rtc_wkalrm * alrm)138*4882a593Smuzhiyun static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun 	spin_lock_irq(&info->lock);
143*4882a593Smuzhiyun 	writel_relaxed(readl_relaxed(info->rtsr) &
144*4882a593Smuzhiyun 		(RTSR_HZE | RTSR_ALE | RTSR_AL), info->rtsr);
145*4882a593Smuzhiyun 	writel_relaxed(rtc_tm_to_time64(&alrm->time), info->rtar);
146*4882a593Smuzhiyun 	if (alrm->enabled)
147*4882a593Smuzhiyun 		writel_relaxed(readl_relaxed(info->rtsr) | RTSR_ALE, info->rtsr);
148*4882a593Smuzhiyun 	else
149*4882a593Smuzhiyun 		writel_relaxed(readl_relaxed(info->rtsr) & ~RTSR_ALE, info->rtsr);
150*4882a593Smuzhiyun 	spin_unlock_irq(&info->lock);
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 	return 0;
153*4882a593Smuzhiyun }
154*4882a593Smuzhiyun 
sa1100_rtc_proc(struct device * dev,struct seq_file * seq)155*4882a593Smuzhiyun static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq)
156*4882a593Smuzhiyun {
157*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun 	seq_printf(seq, "trim/divider\t\t: 0x%08x\n", readl_relaxed(info->rttr));
160*4882a593Smuzhiyun 	seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", readl_relaxed(info->rtsr));
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun 	return 0;
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun static const struct rtc_class_ops sa1100_rtc_ops = {
166*4882a593Smuzhiyun 	.read_time = sa1100_rtc_read_time,
167*4882a593Smuzhiyun 	.set_time = sa1100_rtc_set_time,
168*4882a593Smuzhiyun 	.read_alarm = sa1100_rtc_read_alarm,
169*4882a593Smuzhiyun 	.set_alarm = sa1100_rtc_set_alarm,
170*4882a593Smuzhiyun 	.proc = sa1100_rtc_proc,
171*4882a593Smuzhiyun 	.alarm_irq_enable = sa1100_rtc_alarm_irq_enable,
172*4882a593Smuzhiyun };
173*4882a593Smuzhiyun 
sa1100_rtc_init(struct platform_device * pdev,struct sa1100_rtc * info)174*4882a593Smuzhiyun int sa1100_rtc_init(struct platform_device *pdev, struct sa1100_rtc *info)
175*4882a593Smuzhiyun {
176*4882a593Smuzhiyun 	int ret;
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun 	spin_lock_init(&info->lock);
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun 	info->clk = devm_clk_get(&pdev->dev, NULL);
181*4882a593Smuzhiyun 	if (IS_ERR(info->clk)) {
182*4882a593Smuzhiyun 		dev_err(&pdev->dev, "failed to find rtc clock source\n");
183*4882a593Smuzhiyun 		return PTR_ERR(info->clk);
184*4882a593Smuzhiyun 	}
185*4882a593Smuzhiyun 
186*4882a593Smuzhiyun 	ret = clk_prepare_enable(info->clk);
187*4882a593Smuzhiyun 	if (ret)
188*4882a593Smuzhiyun 		return ret;
189*4882a593Smuzhiyun 	/*
190*4882a593Smuzhiyun 	 * According to the manual we should be able to let RTTR be zero
191*4882a593Smuzhiyun 	 * and then a default diviser for a 32.768KHz clock is used.
192*4882a593Smuzhiyun 	 * Apparently this doesn't work, at least for my SA1110 rev 5.
193*4882a593Smuzhiyun 	 * If the clock divider is uninitialized then reset it to the
194*4882a593Smuzhiyun 	 * default value to get the 1Hz clock.
195*4882a593Smuzhiyun 	 */
196*4882a593Smuzhiyun 	if (readl_relaxed(info->rttr) == 0) {
197*4882a593Smuzhiyun 		writel_relaxed(RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16), info->rttr);
198*4882a593Smuzhiyun 		dev_warn(&pdev->dev, "warning: "
199*4882a593Smuzhiyun 			"initializing default clock divider/trim value\n");
200*4882a593Smuzhiyun 		/* The current RTC value probably doesn't make sense either */
201*4882a593Smuzhiyun 		writel_relaxed(0, info->rcnr);
202*4882a593Smuzhiyun 	}
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun 	info->rtc->ops = &sa1100_rtc_ops;
205*4882a593Smuzhiyun 	info->rtc->max_user_freq = RTC_FREQ;
206*4882a593Smuzhiyun 	info->rtc->range_max = U32_MAX;
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun 	ret = rtc_register_device(info->rtc);
209*4882a593Smuzhiyun 	if (ret) {
210*4882a593Smuzhiyun 		clk_disable_unprepare(info->clk);
211*4882a593Smuzhiyun 		return ret;
212*4882a593Smuzhiyun 	}
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun 	/* Fix for a nasty initialization problem the in SA11xx RTSR register.
215*4882a593Smuzhiyun 	 * See also the comments in sa1100_rtc_interrupt().
216*4882a593Smuzhiyun 	 *
217*4882a593Smuzhiyun 	 * Sometimes bit 1 of the RTSR (RTSR_HZ) will wake up 1, which means an
218*4882a593Smuzhiyun 	 * interrupt pending, even though interrupts were never enabled.
219*4882a593Smuzhiyun 	 * In this case, this bit it must be reset before enabling
220*4882a593Smuzhiyun 	 * interruptions to avoid a nonexistent interrupt to occur.
221*4882a593Smuzhiyun 	 *
222*4882a593Smuzhiyun 	 * In principle, the same problem would apply to bit 0, although it has
223*4882a593Smuzhiyun 	 * never been observed to happen.
224*4882a593Smuzhiyun 	 *
225*4882a593Smuzhiyun 	 * This issue is addressed both here and in sa1100_rtc_interrupt().
226*4882a593Smuzhiyun 	 * If the issue is not addressed here, in the times when the processor
227*4882a593Smuzhiyun 	 * wakes up with the bit set there will be one spurious interrupt.
228*4882a593Smuzhiyun 	 *
229*4882a593Smuzhiyun 	 * The issue is also dealt with in sa1100_rtc_interrupt() to be on the
230*4882a593Smuzhiyun 	 * safe side, once the condition that lead to this strange
231*4882a593Smuzhiyun 	 * initialization is unknown and could in principle happen during
232*4882a593Smuzhiyun 	 * normal processing.
233*4882a593Smuzhiyun 	 *
234*4882a593Smuzhiyun 	 * Notice that clearing bit 1 and 0 is accomplished by writting ONES to
235*4882a593Smuzhiyun 	 * the corresponding bits in RTSR. */
236*4882a593Smuzhiyun 	writel_relaxed(RTSR_AL | RTSR_HZ, info->rtsr);
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun 	return 0;
239*4882a593Smuzhiyun }
240*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(sa1100_rtc_init);
241*4882a593Smuzhiyun 
sa1100_rtc_probe(struct platform_device * pdev)242*4882a593Smuzhiyun static int sa1100_rtc_probe(struct platform_device *pdev)
243*4882a593Smuzhiyun {
244*4882a593Smuzhiyun 	struct sa1100_rtc *info;
245*4882a593Smuzhiyun 	void __iomem *base;
246*4882a593Smuzhiyun 	int irq_1hz, irq_alarm;
247*4882a593Smuzhiyun 	int ret;
248*4882a593Smuzhiyun 
249*4882a593Smuzhiyun 	irq_1hz = platform_get_irq_byname(pdev, "rtc 1Hz");
250*4882a593Smuzhiyun 	irq_alarm = platform_get_irq_byname(pdev, "rtc alarm");
251*4882a593Smuzhiyun 	if (irq_1hz < 0 || irq_alarm < 0)
252*4882a593Smuzhiyun 		return -ENODEV;
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun 	info = devm_kzalloc(&pdev->dev, sizeof(struct sa1100_rtc), GFP_KERNEL);
255*4882a593Smuzhiyun 	if (!info)
256*4882a593Smuzhiyun 		return -ENOMEM;
257*4882a593Smuzhiyun 	info->irq_1hz = irq_1hz;
258*4882a593Smuzhiyun 	info->irq_alarm = irq_alarm;
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	info->rtc = devm_rtc_allocate_device(&pdev->dev);
261*4882a593Smuzhiyun 	if (IS_ERR(info->rtc))
262*4882a593Smuzhiyun 		return PTR_ERR(info->rtc);
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun 	ret = devm_request_irq(&pdev->dev, irq_1hz, sa1100_rtc_interrupt, 0,
265*4882a593Smuzhiyun 			       "rtc 1Hz", &pdev->dev);
266*4882a593Smuzhiyun 	if (ret) {
267*4882a593Smuzhiyun 		dev_err(&pdev->dev, "IRQ %d already in use.\n", irq_1hz);
268*4882a593Smuzhiyun 		return ret;
269*4882a593Smuzhiyun 	}
270*4882a593Smuzhiyun 	ret = devm_request_irq(&pdev->dev, irq_alarm, sa1100_rtc_interrupt, 0,
271*4882a593Smuzhiyun 			       "rtc Alrm", &pdev->dev);
272*4882a593Smuzhiyun 	if (ret) {
273*4882a593Smuzhiyun 		dev_err(&pdev->dev, "IRQ %d already in use.\n", irq_alarm);
274*4882a593Smuzhiyun 		return ret;
275*4882a593Smuzhiyun 	}
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun 	base = devm_platform_ioremap_resource(pdev, 0);
278*4882a593Smuzhiyun 	if (IS_ERR(base))
279*4882a593Smuzhiyun 		return PTR_ERR(base);
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_ARCH_SA1100) ||
282*4882a593Smuzhiyun 	    of_device_is_compatible(pdev->dev.of_node, "mrvl,sa1100-rtc")) {
283*4882a593Smuzhiyun 		info->rcnr = base + 0x04;
284*4882a593Smuzhiyun 		info->rtsr = base + 0x10;
285*4882a593Smuzhiyun 		info->rtar = base + 0x00;
286*4882a593Smuzhiyun 		info->rttr = base + 0x08;
287*4882a593Smuzhiyun 	} else {
288*4882a593Smuzhiyun 		info->rcnr = base + 0x0;
289*4882a593Smuzhiyun 		info->rtsr = base + 0x8;
290*4882a593Smuzhiyun 		info->rtar = base + 0x4;
291*4882a593Smuzhiyun 		info->rttr = base + 0xc;
292*4882a593Smuzhiyun 	}
293*4882a593Smuzhiyun 
294*4882a593Smuzhiyun 	platform_set_drvdata(pdev, info);
295*4882a593Smuzhiyun 	device_init_wakeup(&pdev->dev, 1);
296*4882a593Smuzhiyun 
297*4882a593Smuzhiyun 	return sa1100_rtc_init(pdev, info);
298*4882a593Smuzhiyun }
299*4882a593Smuzhiyun 
sa1100_rtc_remove(struct platform_device * pdev)300*4882a593Smuzhiyun static int sa1100_rtc_remove(struct platform_device *pdev)
301*4882a593Smuzhiyun {
302*4882a593Smuzhiyun 	struct sa1100_rtc *info = platform_get_drvdata(pdev);
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun 	if (info) {
305*4882a593Smuzhiyun 		spin_lock_irq(&info->lock);
306*4882a593Smuzhiyun 		writel_relaxed(0, info->rtsr);
307*4882a593Smuzhiyun 		spin_unlock_irq(&info->lock);
308*4882a593Smuzhiyun 		clk_disable_unprepare(info->clk);
309*4882a593Smuzhiyun 	}
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun 	return 0;
312*4882a593Smuzhiyun }
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun #ifdef CONFIG_PM_SLEEP
sa1100_rtc_suspend(struct device * dev)315*4882a593Smuzhiyun static int sa1100_rtc_suspend(struct device *dev)
316*4882a593Smuzhiyun {
317*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
318*4882a593Smuzhiyun 	if (device_may_wakeup(dev))
319*4882a593Smuzhiyun 		enable_irq_wake(info->irq_alarm);
320*4882a593Smuzhiyun 	return 0;
321*4882a593Smuzhiyun }
322*4882a593Smuzhiyun 
sa1100_rtc_resume(struct device * dev)323*4882a593Smuzhiyun static int sa1100_rtc_resume(struct device *dev)
324*4882a593Smuzhiyun {
325*4882a593Smuzhiyun 	struct sa1100_rtc *info = dev_get_drvdata(dev);
326*4882a593Smuzhiyun 	if (device_may_wakeup(dev))
327*4882a593Smuzhiyun 		disable_irq_wake(info->irq_alarm);
328*4882a593Smuzhiyun 	return 0;
329*4882a593Smuzhiyun }
330*4882a593Smuzhiyun #endif
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun static SIMPLE_DEV_PM_OPS(sa1100_rtc_pm_ops, sa1100_rtc_suspend,
333*4882a593Smuzhiyun 			sa1100_rtc_resume);
334*4882a593Smuzhiyun 
335*4882a593Smuzhiyun #ifdef CONFIG_OF
336*4882a593Smuzhiyun static const struct of_device_id sa1100_rtc_dt_ids[] = {
337*4882a593Smuzhiyun 	{ .compatible = "mrvl,sa1100-rtc", },
338*4882a593Smuzhiyun 	{ .compatible = "mrvl,mmp-rtc", },
339*4882a593Smuzhiyun 	{}
340*4882a593Smuzhiyun };
341*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids);
342*4882a593Smuzhiyun #endif
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun static struct platform_driver sa1100_rtc_driver = {
345*4882a593Smuzhiyun 	.probe		= sa1100_rtc_probe,
346*4882a593Smuzhiyun 	.remove		= sa1100_rtc_remove,
347*4882a593Smuzhiyun 	.driver		= {
348*4882a593Smuzhiyun 		.name	= "sa1100-rtc",
349*4882a593Smuzhiyun 		.pm	= &sa1100_rtc_pm_ops,
350*4882a593Smuzhiyun 		.of_match_table = of_match_ptr(sa1100_rtc_dt_ids),
351*4882a593Smuzhiyun 	},
352*4882a593Smuzhiyun };
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun module_platform_driver(sa1100_rtc_driver);
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
357*4882a593Smuzhiyun MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)");
358*4882a593Smuzhiyun MODULE_LICENSE("GPL");
359*4882a593Smuzhiyun MODULE_ALIAS("platform:sa1100-rtc");
360