aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-bfin.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 343f2849106d..b14a9c46f3b2 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -45,8 +45,7 @@
45 45
46#include <asm/blackfin.h> 46#include <asm/blackfin.h>
47 47
48#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args) 48#define dev_dbg_stamp(dev) dev_dbg(dev, "%s:%i: here i am\n", __func__, __LINE__)
49#define stampit() stamp("here i am")
50 49
51struct bfin_rtc { 50struct bfin_rtc {
52 struct rtc_device *rtc_dev; 51 struct rtc_device *rtc_dev;
@@ -120,7 +119,6 @@ static inline void rtc_bfin_to_tm(u32 rtc_bfin, struct rtc_time *tm)
120 */ 119 */
121static void rtc_bfin_sync_pending(void) 120static void rtc_bfin_sync_pending(void)
122{ 121{
123 stampit();
124 while (!(bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_COMPLETE)) { 122 while (!(bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_COMPLETE)) {
125 if (!(bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING)) 123 if (!(bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING))
126 break; 124 break;
@@ -128,8 +126,9 @@ static void rtc_bfin_sync_pending(void)
128 bfin_write_RTC_ISTAT(RTC_ISTAT_WRITE_COMPLETE); 126 bfin_write_RTC_ISTAT(RTC_ISTAT_WRITE_COMPLETE);
129} 127}
130 128
131static void rtc_bfin_reset(struct bfin_rtc *rtc) 129static void rtc_bfin_reset(struct device *dev)
132{ 130{
131 struct bfin_rtc *rtc = dev_get_drvdata(dev);
133 /* Initialize the RTC. Enable pre-scaler to scale RTC clock 132 /* Initialize the RTC. Enable pre-scaler to scale RTC clock
134 * to 1Hz and clear interrupt/status registers. */ 133 * to 1Hz and clear interrupt/status registers. */
135 spin_lock_irq(&rtc->lock); 134 spin_lock_irq(&rtc->lock);
@@ -149,7 +148,7 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id)
149 unsigned long events = 0; 148 unsigned long events = 0;
150 u16 rtc_istat; 149 u16 rtc_istat;
151 150
152 stampit(); 151 dev_dbg_stamp(dev);
153 152
154 spin_lock_irq(&rtc->lock); 153 spin_lock_irq(&rtc->lock);
155 154
@@ -180,10 +179,9 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id)
180 179
181static int bfin_rtc_open(struct device *dev) 180static int bfin_rtc_open(struct device *dev)
182{ 181{
183 struct bfin_rtc *rtc = dev_get_drvdata(dev);
184 int ret; 182 int ret;
185 183
186 stampit(); 184 dev_dbg_stamp(dev);
187 185
188 ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_DISABLED, "rtc-bfin", dev); 186 ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_DISABLED, "rtc-bfin", dev);
189 if (unlikely(ret)) { 187 if (unlikely(ret)) {
@@ -191,16 +189,15 @@ static int bfin_rtc_open(struct device *dev)
191 return ret; 189 return ret;
192 } 190 }
193 191
194 rtc_bfin_reset(rtc); 192 rtc_bfin_reset(dev);
195 193
196 return ret; 194 return ret;
197} 195}
198 196
199static void bfin_rtc_release(struct device *dev) 197static void bfin_rtc_release(struct device *dev)
200{ 198{
201 struct bfin_rtc *rtc = dev_get_drvdata(dev); 199 dev_dbg_stamp(dev);
202 stampit(); 200 rtc_bfin_reset(dev);
203 rtc_bfin_reset(rtc);
204 free_irq(IRQ_RTC, dev); 201 free_irq(IRQ_RTC, dev);
205} 202}
206 203
@@ -208,11 +205,11 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
208{ 205{
209 struct bfin_rtc *rtc = dev_get_drvdata(dev); 206 struct bfin_rtc *rtc = dev_get_drvdata(dev);
210 207
211 stampit(); 208 dev_dbg_stamp(dev);
212 209
213 switch (cmd) { 210 switch (cmd) {
214 case RTC_PIE_ON: 211 case RTC_PIE_ON:
215 stampit(); 212 dev_dbg_stamp(dev);
216 spin_lock_irq(&rtc->lock); 213 spin_lock_irq(&rtc->lock);
217 rtc_bfin_sync_pending(); 214 rtc_bfin_sync_pending();
218 bfin_write_RTC_ISTAT(RTC_ISTAT_STOPWATCH); 215 bfin_write_RTC_ISTAT(RTC_ISTAT_STOPWATCH);
@@ -221,7 +218,7 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
221 spin_unlock_irq(&rtc->lock); 218 spin_unlock_irq(&rtc->lock);
222 return 0; 219 return 0;
223 case RTC_PIE_OFF: 220 case RTC_PIE_OFF:
224 stampit(); 221 dev_dbg_stamp(dev);
225 spin_lock_irq(&rtc->lock); 222 spin_lock_irq(&rtc->lock);
226 rtc_bfin_sync_pending(); 223 rtc_bfin_sync_pending();
227 bfin_write_RTC_SWCNT(0); 224 bfin_write_RTC_SWCNT(0);
@@ -230,7 +227,7 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
230 return 0; 227 return 0;
231 228
232 case RTC_UIE_ON: 229 case RTC_UIE_ON:
233 stampit(); 230 dev_dbg_stamp(dev);
234 spin_lock_irq(&rtc->lock); 231 spin_lock_irq(&rtc->lock);
235 rtc_bfin_sync_pending(); 232 rtc_bfin_sync_pending();
236 bfin_write_RTC_ISTAT(RTC_ISTAT_SEC); 233 bfin_write_RTC_ISTAT(RTC_ISTAT_SEC);
@@ -238,7 +235,7 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
238 spin_unlock_irq(&rtc->lock); 235 spin_unlock_irq(&rtc->lock);
239 return 0; 236 return 0;
240 case RTC_UIE_OFF: 237 case RTC_UIE_OFF:
241 stampit(); 238 dev_dbg_stamp(dev);
242 spin_lock_irq(&rtc->lock); 239 spin_lock_irq(&rtc->lock);
243 rtc_bfin_sync_pending(); 240 rtc_bfin_sync_pending();
244 bfin_write_RTC_ICTL(bfin_read_RTC_ICTL() & ~RTC_ISTAT_SEC); 241 bfin_write_RTC_ICTL(bfin_read_RTC_ICTL() & ~RTC_ISTAT_SEC);
@@ -250,7 +247,7 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
250 u16 which_alarm; 247 u16 which_alarm;
251 int ret = 0; 248 int ret = 0;
252 249
253 stampit(); 250 dev_dbg_stamp(dev);
254 251
255 spin_lock_irq(&rtc->lock); 252 spin_lock_irq(&rtc->lock);
256 253
@@ -278,7 +275,7 @@ static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ar
278 return ret; 275 return ret;
279 } 276 }
280 case RTC_AIE_OFF: 277 case RTC_AIE_OFF:
281 stampit(); 278 dev_dbg_stamp(dev);
282 spin_lock_irq(&rtc->lock); 279 spin_lock_irq(&rtc->lock);
283 rtc_bfin_sync_pending(); 280 rtc_bfin_sync_pending();
284 bfin_write_RTC_ICTL(bfin_read_RTC_ICTL() & ~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); 281 bfin_write_RTC_ICTL(bfin_read_RTC_ICTL() & ~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY));
@@ -293,7 +290,7 @@ static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm)
293{ 290{
294 struct bfin_rtc *rtc = dev_get_drvdata(dev); 291 struct bfin_rtc *rtc = dev_get_drvdata(dev);
295 292
296 stampit(); 293 dev_dbg_stamp(dev);
297 294
298 spin_lock_irq(&rtc->lock); 295 spin_lock_irq(&rtc->lock);
299 rtc_bfin_sync_pending(); 296 rtc_bfin_sync_pending();
@@ -309,7 +306,7 @@ static int bfin_rtc_set_time(struct device *dev, struct rtc_time *tm)
309 int ret; 306 int ret;
310 unsigned long now; 307 unsigned long now;
311 308
312 stampit(); 309 dev_dbg_stamp(dev);
313 310
314 spin_lock_irq(&rtc->lock); 311 spin_lock_irq(&rtc->lock);
315 312
@@ -327,7 +324,7 @@ static int bfin_rtc_set_time(struct device *dev, struct rtc_time *tm)
327static int bfin_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 324static int bfin_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
328{ 325{
329 struct bfin_rtc *rtc = dev_get_drvdata(dev); 326 struct bfin_rtc *rtc = dev_get_drvdata(dev);
330 stampit(); 327 dev_dbg_stamp(dev);
331 memcpy(&alrm->time, &rtc->rtc_alarm, sizeof(struct rtc_time)); 328 memcpy(&alrm->time, &rtc->rtc_alarm, sizeof(struct rtc_time));
332 alrm->pending = !!(bfin_read_RTC_ICTL() & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); 329 alrm->pending = !!(bfin_read_RTC_ICTL() & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY));
333 return 0; 330 return 0;
@@ -336,7 +333,7 @@ static int bfin_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
336static int bfin_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 333static int bfin_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
337{ 334{
338 struct bfin_rtc *rtc = dev_get_drvdata(dev); 335 struct bfin_rtc *rtc = dev_get_drvdata(dev);
339 stampit(); 336 dev_dbg_stamp(dev);
340 memcpy(&rtc->rtc_alarm, &alrm->time, sizeof(struct rtc_time)); 337 memcpy(&rtc->rtc_alarm, &alrm->time, sizeof(struct rtc_time));
341 return 0; 338 return 0;
342} 339}
@@ -345,7 +342,7 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq)
345{ 342{
346#define yesno(x) ((x) ? "yes" : "no") 343#define yesno(x) ((x) ? "yes" : "no")
347 u16 ictl = bfin_read_RTC_ICTL(); 344 u16 ictl = bfin_read_RTC_ICTL();
348 stampit(); 345 dev_dbg_stamp(dev);
349 seq_printf(seq, 346 seq_printf(seq,
350 "alarm_IRQ\t: %s\n" 347 "alarm_IRQ\t: %s\n"
351 "wkalarm_IRQ\t: %s\n" 348 "wkalarm_IRQ\t: %s\n"
@@ -369,7 +366,7 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq)
369 */ 366 */
370static int bfin_irq_set_freq(struct device *dev, int freq) 367static int bfin_irq_set_freq(struct device *dev, int freq)
371{ 368{
372 stampit(); 369 dev_dbg_stamp(dev);
373 return -ENOTTY; 370 return -ENOTTY;
374} 371}
375 372
@@ -390,7 +387,7 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev)
390 struct bfin_rtc *rtc; 387 struct bfin_rtc *rtc;
391 int ret = 0; 388 int ret = 0;
392 389
393 stampit(); 390 dev_dbg_stamp(&pdev->dev);
394 391
395 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); 392 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
396 if (unlikely(!rtc)) 393 if (unlikely(!rtc))
@@ -436,7 +433,6 @@ static struct platform_driver bfin_rtc_driver = {
436 433
437static int __init bfin_rtc_init(void) 434static int __init bfin_rtc_init(void)
438{ 435{
439 stampit();
440 return platform_driver_register(&bfin_rtc_driver); 436 return platform_driver_register(&bfin_rtc_driver);
441} 437}
442 438