aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-integrator
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2008-07-25 10:40:14 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-25 10:40:14 -0400
commitff877ea80efa2015b6263766f78ee42c2a1b32f9 (patch)
tree85205005c611ab774702148558321c6fb92f1ccd /arch/arm/mach-integrator
parent30821fee4f0cb3e6d241d9f7ddc37742212e3eb7 (diff)
parentd37e6bf68fc1eb34a4ad21d9ae8890ed37ea80e7 (diff)
Merge branch 'linux-next' of git://git.infradead.org/~dedekind/ubi-2.6
Diffstat (limited to 'arch/arm/mach-integrator')
-rw-r--r--arch/arm/mach-integrator/Makefile2
-rw-r--r--arch/arm/mach-integrator/impd1.c7
-rw-r--r--arch/arm/mach-integrator/lm.c6
-rw-r--r--arch/arm/mach-integrator/time.c223
4 files changed, 7 insertions, 231 deletions
diff --git a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile
index 158daaf9e3b0..6a5ef8d30b10 100644
--- a/arch/arm/mach-integrator/Makefile
+++ b/arch/arm/mach-integrator/Makefile
@@ -4,7 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := clock.o core.o lm.o time.o 7obj-y := clock.o core.o lm.o
8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o 8obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o
9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o 9obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o
10 10
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 62e653a3ea1a..5a1588cf8242 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -393,9 +393,7 @@ static int impd1_probe(struct lm_device *dev)
393 if (!d) 393 if (!d)
394 continue; 394 continue;
395 395
396 snprintf(d->dev.bus_id, sizeof(d->dev.bus_id), 396 dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
397 "lm%x:%5.5lx", dev->id, idev->offset >> 12);
398
399 d->dev.parent = &dev->dev; 397 d->dev.parent = &dev->dev;
400 d->res.start = dev->resource.start + idev->offset; 398 d->res.start = dev->resource.start + idev->offset;
401 d->res.end = d->res.start + SZ_4K - 1; 399 d->res.end = d->res.start + SZ_4K - 1;
@@ -407,8 +405,7 @@ static int impd1_probe(struct lm_device *dev)
407 405
408 ret = amba_device_register(d, &dev->resource); 406 ret = amba_device_register(d, &dev->resource);
409 if (ret) { 407 if (ret) {
410 printk("unable to register device %s: %d\n", 408 dev_err(&d->dev, "unable to register device: %d\n");
411 d->dev.bus_id, ret);
412 kfree(d); 409 kfree(d);
413 } 410 }
414 } 411 }
diff --git a/arch/arm/mach-integrator/lm.c b/arch/arm/mach-integrator/lm.c
index 622cdc4212dd..f939c5091405 100644
--- a/arch/arm/mach-integrator/lm.c
+++ b/arch/arm/mach-integrator/lm.c
@@ -81,8 +81,10 @@ int lm_device_register(struct lm_device *dev)
81 dev->dev.release = lm_device_release; 81 dev->dev.release = lm_device_release;
82 dev->dev.bus = &lm_bustype; 82 dev->dev.bus = &lm_bustype;
83 83
84 snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id); 84 ret = dev_set_name(&dev->dev, "lm%d", dev->id);
85 dev->resource.name = dev->dev.bus_id; 85 if (ret)
86 return ret;
87 dev->resource.name = dev_name(&dev->dev);
86 88
87 ret = request_resource(&iomem_resource, &dev->resource); 89 ret = request_resource(&iomem_resource, &dev->resource);
88 if (ret == 0) { 90 if (ret == 0) {
diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c
deleted file mode 100644
index 8508a0db3eaf..000000000000
--- a/arch/arm/mach-integrator/time.c
+++ /dev/null
@@ -1,223 +0,0 @@
1/*
2 * linux/arch/arm/mach-integrator/time.c
3 *
4 * Copyright (C) 2000-2001 Deep Blue Solutions Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/time.h>
13#include <linux/mc146818rtc.h>
14#include <linux/interrupt.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/amba/bus.h>
18
19#include <asm/hardware.h>
20#include <asm/io.h>
21#include <asm/uaccess.h>
22#include <asm/rtc.h>
23
24#include <asm/mach/time.h>
25
26#define RTC_DR (0)
27#define RTC_MR (4)
28#define RTC_STAT (8)
29#define RTC_EOI (8)
30#define RTC_LR (12)
31#define RTC_CR (16)
32#define RTC_CR_MIE (1 << 0)
33
34extern int (*set_rtc)(void);
35static void __iomem *rtc_base;
36
37static int integrator_set_rtc(void)
38{
39 __raw_writel(xtime.tv_sec, rtc_base + RTC_LR);
40 return 1;
41}
42
43static int integrator_rtc_read_alarm(struct rtc_wkalrm *alrm)
44{
45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time);
46 return 0;
47}
48
49static inline int integrator_rtc_set_alarm(struct rtc_wkalrm *alrm)
50{
51 unsigned long time;
52 int ret;
53
54 /*
55 * At the moment, we can only deal with non-wildcarded alarm times.
56 */
57 ret = rtc_valid_tm(&alrm->time);
58 if (ret == 0)
59 ret = rtc_tm_to_time(&alrm->time, &time);
60 if (ret == 0)
61 writel(time, rtc_base + RTC_MR);
62 return ret;
63}
64
65static int integrator_rtc_read_time(struct rtc_time *tm)
66{
67 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm);
68 return 0;
69}
70
71/*
72 * Set the RTC time. Unfortunately, we can't accurately set
73 * the point at which the counter updates.
74 *
75 * Also, since RTC_LR is transferred to RTC_CR on next rising
76 * edge of the 1Hz clock, we must write the time one second
77 * in advance.
78 */
79static inline int integrator_rtc_set_time(struct rtc_time *tm)
80{
81 unsigned long time;
82 int ret;
83
84 ret = rtc_tm_to_time(tm, &time);
85 if (ret == 0)
86 writel(time + 1, rtc_base + RTC_LR);
87
88 return ret;
89}
90
91static struct rtc_ops rtc_ops = {
92 .owner = THIS_MODULE,
93 .read_time = integrator_rtc_read_time,
94 .set_time = integrator_rtc_set_time,
95 .read_alarm = integrator_rtc_read_alarm,
96 .set_alarm = integrator_rtc_set_alarm,
97};
98
99static irqreturn_t arm_rtc_interrupt(int irq, void *dev_id)
100{
101 writel(0, rtc_base + RTC_EOI);
102 return IRQ_HANDLED;
103}
104
105static int rtc_probe(struct amba_device *dev, void *id)
106{
107 int ret;
108
109 if (rtc_base)
110 return -EBUSY;
111
112 ret = amba_request_regions(dev, NULL);
113 if (ret)
114 goto out;
115
116 rtc_base = ioremap(dev->res.start, SZ_4K);
117 if (!rtc_base) {
118 ret = -ENOMEM;
119 goto res_out;
120 }
121
122 __raw_writel(0, rtc_base + RTC_CR);
123 __raw_writel(0, rtc_base + RTC_EOI);
124
125 xtime.tv_sec = __raw_readl(rtc_base + RTC_DR);
126
127 /* note that 'dev' is merely used for irq disambiguation;
128 * it is not actually referenced in the irq handler
129 */
130 ret = request_irq(dev->irq[0], arm_rtc_interrupt, IRQF_DISABLED,
131 "rtc-pl030", dev);
132 if (ret)
133 goto map_out;
134
135 ret = register_rtc(&rtc_ops);
136 if (ret)
137 goto irq_out;
138
139 set_rtc = integrator_set_rtc;
140 return 0;
141
142 irq_out:
143 free_irq(dev->irq[0], dev);
144 map_out:
145 iounmap(rtc_base);
146 rtc_base = NULL;
147 res_out:
148 amba_release_regions(dev);
149 out:
150 return ret;
151}
152
153static int rtc_remove(struct amba_device *dev)
154{
155 set_rtc = NULL;
156
157 writel(0, rtc_base + RTC_CR);
158
159 free_irq(dev->irq[0], dev);
160 unregister_rtc(&rtc_ops);
161
162 iounmap(rtc_base);
163 rtc_base = NULL;
164 amba_release_regions(dev);
165
166 return 0;
167}
168
169static struct timespec rtc_delta;
170
171static int rtc_suspend(struct amba_device *dev, pm_message_t state)
172{
173 struct timespec rtc;
174
175 rtc.tv_sec = readl(rtc_base + RTC_DR);
176 rtc.tv_nsec = 0;
177 save_time_delta(&rtc_delta, &rtc);
178
179 return 0;
180}
181
182static int rtc_resume(struct amba_device *dev)
183{
184 struct timespec rtc;
185
186 rtc.tv_sec = readl(rtc_base + RTC_DR);
187 rtc.tv_nsec = 0;
188 restore_time_delta(&rtc_delta, &rtc);
189
190 return 0;
191}
192
193static struct amba_id rtc_ids[] = {
194 {
195 .id = 0x00041030,
196 .mask = 0x000fffff,
197 },
198 { 0, 0 },
199};
200
201static struct amba_driver rtc_driver = {
202 .drv = {
203 .name = "rtc-pl030",
204 },
205 .probe = rtc_probe,
206 .remove = rtc_remove,
207 .suspend = rtc_suspend,
208 .resume = rtc_resume,
209 .id_table = rtc_ids,
210};
211
212static int __init integrator_rtc_init(void)
213{
214 return amba_driver_register(&rtc_driver);
215}
216
217static void __exit integrator_rtc_exit(void)
218{
219 amba_driver_unregister(&rtc_driver);
220}
221
222module_init(integrator_rtc_init);
223module_exit(integrator_rtc_exit);