diff options
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/Kconfig | 19 | ||||
| -rw-r--r-- | drivers/rtc/Makefile | 1 | ||||
| -rw-r--r-- | drivers/rtc/interface.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-at32ap700x.c | 3 | ||||
| -rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 4 | ||||
| -rw-r--r-- | drivers/rtc/rtc-at91sam9.c | 1 | ||||
| -rw-r--r-- | drivers/rtc/rtc-dev.c | 12 | ||||
| -rw-r--r-- | drivers/rtc/rtc-fm3130.c | 2 | ||||
| -rw-r--r-- | drivers/rtc/rtc-m41t80.c | 7 | ||||
| -rw-r--r-- | drivers/rtc/rtc-omap.c | 1 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 1 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pl030.c | 217 | ||||
| -rw-r--r-- | drivers/rtc/rtc-pl031.c | 36 | ||||
| -rw-r--r-- | drivers/rtc/rtc-s3c.c | 4 | ||||
| -rw-r--r-- | drivers/rtc/rtc-sa1100.c | 37 |
15 files changed, 305 insertions, 42 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4949dc4859be..fc85bf2e4a97 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
| @@ -469,6 +469,16 @@ config RTC_DRV_VR41XX | |||
| 469 | To compile this driver as a module, choose M here: the | 469 | To compile this driver as a module, choose M here: the |
| 470 | module will be called rtc-vr41xx. | 470 | module will be called rtc-vr41xx. |
| 471 | 471 | ||
| 472 | config RTC_DRV_PL030 | ||
| 473 | tristate "ARM AMBA PL030 RTC" | ||
| 474 | depends on ARM_AMBA | ||
| 475 | help | ||
| 476 | If you say Y here you will get access to ARM AMBA | ||
| 477 | PrimeCell PL030 RTC found on certain ARM SOCs. | ||
| 478 | |||
| 479 | To compile this driver as a module, choose M here: the | ||
| 480 | module will be called rtc-pl030. | ||
| 481 | |||
| 472 | config RTC_DRV_PL031 | 482 | config RTC_DRV_PL031 |
| 473 | tristate "ARM AMBA PL031 RTC" | 483 | tristate "ARM AMBA PL031 RTC" |
| 474 | depends on ARM_AMBA | 484 | depends on ARM_AMBA |
| @@ -495,12 +505,13 @@ config RTC_DRV_AT91RM9200 | |||
| 495 | this is powered by the backup power supply. | 505 | this is powered by the backup power supply. |
| 496 | 506 | ||
| 497 | config RTC_DRV_AT91SAM9 | 507 | config RTC_DRV_AT91SAM9 |
| 498 | tristate "AT91SAM9x" | 508 | tristate "AT91SAM9x/AT91CAP9" |
| 499 | depends on ARCH_AT91 && !(ARCH_AT91RM9200 || ARCH_AT91X40) | 509 | depends on ARCH_AT91 && !(ARCH_AT91RM9200 || ARCH_AT91X40) |
| 500 | help | 510 | help |
| 501 | RTC driver for the Atmel AT91SAM9x internal RTT (Real Time Timer). | 511 | RTC driver for the Atmel AT91SAM9x and AT91CAP9 internal RTT |
| 502 | These timers are powered by the backup power supply (such as a | 512 | (Real Time Timer). These timers are powered by the backup power |
| 503 | small coin cell battery), but do not need to be used as RTCs. | 513 | supply (such as a small coin cell battery), but do not need to |
| 514 | be used as RTCs. | ||
| 504 | 515 | ||
| 505 | (On AT91SAM9rl chips you probably want to use the dedicated RTC | 516 | (On AT91SAM9rl chips you probably want to use the dedicated RTC |
| 506 | module and leave the RTT available for other uses.) | 517 | module and leave the RTT available for other uses.) |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index b6e14d51670b..b5d9d67df887 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
| @@ -41,6 +41,7 @@ obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o | |||
| 41 | obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o | 41 | obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o |
| 42 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o | 42 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o |
| 43 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o | 43 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o |
| 44 | obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o | ||
| 44 | obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o | 45 | obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o |
| 45 | obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o | 46 | obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o |
| 46 | obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o | 47 | obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 58b7336640ff..d397fa5f3a91 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
| @@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name) | |||
| 345 | struct device *dev; | 345 | struct device *dev; |
| 346 | struct rtc_device *rtc = NULL; | 346 | struct rtc_device *rtc = NULL; |
| 347 | 347 | ||
| 348 | dev = class_find_device(rtc_class, name, __rtc_match); | 348 | dev = class_find_device(rtc_class, NULL, name, __rtc_match); |
| 349 | if (dev) | 349 | if (dev) |
| 350 | rtc = to_rtc_device(dev); | 350 | rtc = to_rtc_device(dev); |
| 351 | 351 | ||
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 2ef8cdfda4a7..90b9a6503e15 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c | |||
| @@ -265,6 +265,7 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | platform_set_drvdata(pdev, rtc); | 267 | platform_set_drvdata(pdev, rtc); |
| 268 | device_init_wakeup(&pdev->dev, 1); | ||
| 268 | 269 | ||
| 269 | dev_info(&pdev->dev, "Atmel RTC for AT32AP700x at %08lx irq %ld\n", | 270 | dev_info(&pdev->dev, "Atmel RTC for AT32AP700x at %08lx irq %ld\n", |
| 270 | (unsigned long)rtc->regs, rtc->irq); | 271 | (unsigned long)rtc->regs, rtc->irq); |
| @@ -284,6 +285,8 @@ static int __exit at32_rtc_remove(struct platform_device *pdev) | |||
| 284 | { | 285 | { |
| 285 | struct rtc_at32ap700x *rtc = platform_get_drvdata(pdev); | 286 | struct rtc_at32ap700x *rtc = platform_get_drvdata(pdev); |
| 286 | 287 | ||
| 288 | device_init_wakeup(&pdev->dev, 0); | ||
| 289 | |||
| 287 | free_irq(rtc->irq, rtc); | 290 | free_irq(rtc->irq, rtc); |
| 288 | iounmap(rtc->regs); | 291 | iounmap(rtc->regs); |
| 289 | rtc_device_unregister(rtc->rtc); | 292 | rtc_device_unregister(rtc->rtc); |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 39e64ab1ecb7..9c3db934cc24 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
| @@ -29,10 +29,6 @@ | |||
| 29 | #include <linux/completion.h> | 29 | #include <linux/completion.h> |
| 30 | 30 | ||
| 31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
| 32 | #include <asm/rtc.h> | ||
| 33 | |||
| 34 | #include <asm/mach/time.h> | ||
| 35 | |||
| 36 | #include <asm/arch/at91_rtc.h> | 32 | #include <asm/arch/at91_rtc.h> |
| 37 | 33 | ||
| 38 | 34 | ||
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 38d8742a4bdf..f0246ef413a4 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/ioctl.h> | 20 | #include <linux/ioctl.h> |
| 21 | 21 | ||
| 22 | #include <asm/mach/time.h> | ||
| 23 | #include <asm/arch/board.h> | 22 | #include <asm/arch/board.h> |
| 24 | #include <asm/arch/at91_rtt.h> | 23 | #include <asm/arch/at91_rtt.h> |
| 25 | 24 | ||
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 90dfa0df747a..0114a78b7cbb 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
| 16 | #include <linux/smp_lock.h> | ||
| 16 | #include "rtc-core.h" | 17 | #include "rtc-core.h" |
| 17 | 18 | ||
| 18 | static dev_t rtc_devt; | 19 | static dev_t rtc_devt; |
| @@ -26,8 +27,11 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
| 26 | struct rtc_device, char_dev); | 27 | struct rtc_device, char_dev); |
| 27 | const struct rtc_class_ops *ops = rtc->ops; | 28 | const struct rtc_class_ops *ops = rtc->ops; |
| 28 | 29 | ||
| 29 | if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) | 30 | lock_kernel(); |
| 30 | return -EBUSY; | 31 | if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) { |
| 32 | err = -EBUSY; | ||
| 33 | goto out; | ||
| 34 | } | ||
| 31 | 35 | ||
| 32 | file->private_data = rtc; | 36 | file->private_data = rtc; |
| 33 | 37 | ||
| @@ -37,11 +41,13 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
| 37 | rtc->irq_data = 0; | 41 | rtc->irq_data = 0; |
| 38 | spin_unlock_irq(&rtc->irq_lock); | 42 | spin_unlock_irq(&rtc->irq_lock); |
| 39 | 43 | ||
| 40 | return 0; | 44 | goto out; |
| 41 | } | 45 | } |
| 42 | 46 | ||
| 43 | /* something has gone wrong */ | 47 | /* something has gone wrong */ |
| 44 | clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); | 48 | clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); |
| 49 | out: | ||
| 50 | unlock_kernel(); | ||
| 45 | return err; | 51 | return err; |
| 46 | } | 52 | } |
| 47 | 53 | ||
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index 11644c8fca82..abfdfcbaa059 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
| @@ -55,7 +55,7 @@ struct fm3130 { | |||
| 55 | int alarm; | 55 | int alarm; |
| 56 | }; | 56 | }; |
| 57 | static const struct i2c_device_id fm3130_id[] = { | 57 | static const struct i2c_device_id fm3130_id[] = { |
| 58 | { "fm3130-rtc", 0 }, | 58 | { "fm3130", 0 }, |
| 59 | { } | 59 | { } |
| 60 | }; | 60 | }; |
| 61 | MODULE_DEVICE_TABLE(i2c, fm3130_id); | 61 | MODULE_DEVICE_TABLE(i2c, fm3130_id); |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index a3e0880b38fb..0a19c06019be 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
| 20 | #include <linux/smp_lock.h> | ||
| 20 | #include <linux/string.h> | 21 | #include <linux/string.h> |
| 21 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
| 22 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
| @@ -655,12 +656,16 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
| 655 | static int wdt_open(struct inode *inode, struct file *file) | 656 | static int wdt_open(struct inode *inode, struct file *file) |
| 656 | { | 657 | { |
| 657 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { | 658 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { |
| 658 | if (test_and_set_bit(0, &wdt_is_open)) | 659 | lock_kernel(); |
| 660 | if (test_and_set_bit(0, &wdt_is_open)) { | ||
| 661 | unlock_kernel(); | ||
| 659 | return -EBUSY; | 662 | return -EBUSY; |
| 663 | } | ||
| 660 | /* | 664 | /* |
| 661 | * Activate | 665 | * Activate |
| 662 | */ | 666 | */ |
| 663 | wdt_is_open = 1; | 667 | wdt_is_open = 1; |
| 668 | unlock_kernel(); | ||
| 664 | return 0; | 669 | return 0; |
| 665 | } | 670 | } |
| 666 | return -ENODEV; | 671 | return -ENODEV; |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 58f81c774943..eb23d8423f42 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
| 23 | 23 | ||
| 24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
| 25 | #include <asm/mach/time.h> | ||
| 26 | 25 | ||
| 27 | 26 | ||
| 28 | /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock | 27 | /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 0fc4c3630780..748a502a6355 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
| @@ -302,6 +302,7 @@ static int pcf8563_remove(struct i2c_client *client) | |||
| 302 | 302 | ||
| 303 | static const struct i2c_device_id pcf8563_id[] = { | 303 | static const struct i2c_device_id pcf8563_id[] = { |
| 304 | { "pcf8563", 0 }, | 304 | { "pcf8563", 0 }, |
| 305 | { "rtc8564", 0 }, | ||
| 305 | { } | 306 | { } |
| 306 | }; | 307 | }; |
| 307 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); | 308 | MODULE_DEVICE_TABLE(i2c, pcf8563_id); |
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c new file mode 100644 index 000000000000..8448eeb9d675 --- /dev/null +++ b/drivers/rtc/rtc-pl030.c | |||
| @@ -0,0 +1,217 @@ | |||
| 1 | /* | ||
| 2 | * linux/drivers/rtc/rtc-pl030.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/rtc.h> | ||
| 12 | #include <linux/init.h> | ||
| 13 | #include <linux/interrupt.h> | ||
| 14 | #include <linux/amba/bus.h> | ||
| 15 | #include <linux/io.h> | ||
| 16 | |||
| 17 | #define RTC_DR (0) | ||
| 18 | #define RTC_MR (4) | ||
| 19 | #define RTC_STAT (8) | ||
| 20 | #define RTC_EOI (8) | ||
| 21 | #define RTC_LR (12) | ||
| 22 | #define RTC_CR (16) | ||
| 23 | #define RTC_CR_MIE (1 << 0) | ||
| 24 | |||
| 25 | struct pl030_rtc { | ||
| 26 | struct rtc_device *rtc; | ||
| 27 | void __iomem *base; | ||
| 28 | }; | ||
| 29 | |||
| 30 | static irqreturn_t pl030_interrupt(int irq, void *dev_id) | ||
| 31 | { | ||
| 32 | struct pl030_rtc *rtc = dev_id; | ||
| 33 | writel(0, rtc->base + RTC_EOI); | ||
| 34 | return IRQ_HANDLED; | ||
| 35 | } | ||
| 36 | |||
| 37 | static int pl030_open(struct device *dev) | ||
| 38 | { | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | |||
| 42 | static void pl030_release(struct device *dev) | ||
| 43 | { | ||
| 44 | } | ||
| 45 | |||
| 46 | static int pl030_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
| 47 | { | ||
| 48 | return -ENOIOCTLCMD; | ||
| 49 | } | ||
| 50 | |||
| 51 | static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
| 52 | { | ||
| 53 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | ||
| 54 | |||
| 55 | rtc_time_to_tm(readl(rtc->base + RTC_MR), &alrm->time); | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
| 60 | { | ||
| 61 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | ||
| 62 | unsigned long time; | ||
| 63 | int ret; | ||
| 64 | |||
| 65 | /* | ||
| 66 | * At the moment, we can only deal with non-wildcarded alarm times. | ||
| 67 | */ | ||
| 68 | ret = rtc_valid_tm(&alrm->time); | ||
| 69 | if (ret == 0) | ||
| 70 | ret = rtc_tm_to_time(&alrm->time, &time); | ||
| 71 | if (ret == 0) | ||
| 72 | writel(time, rtc->base + RTC_MR); | ||
| 73 | return ret; | ||
| 74 | } | ||
| 75 | |||
| 76 | static int pl030_read_time(struct device *dev, struct rtc_time *tm) | ||
| 77 | { | ||
| 78 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | ||
| 79 | |||
| 80 | rtc_time_to_tm(readl(rtc->base + RTC_DR), tm); | ||
| 81 | |||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Set the RTC time. Unfortunately, we can't accurately set | ||
| 87 | * the point at which the counter updates. | ||
| 88 | * | ||
| 89 | * Also, since RTC_LR is transferred to RTC_CR on next rising | ||
| 90 | * edge of the 1Hz clock, we must write the time one second | ||
| 91 | * in advance. | ||
| 92 | */ | ||
| 93 | static int pl030_set_time(struct device *dev, struct rtc_time *tm) | ||
| 94 | { | ||
| 95 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | ||
| 96 | unsigned long time; | ||
| 97 | int ret; | ||
| 98 | |||
| 99 | ret = rtc_tm_to_time(tm, &time); | ||
| 100 | if (ret == 0) | ||
| 101 | writel(time + 1, rtc->base + RTC_LR); | ||
| 102 | |||
| 103 | return ret; | ||
| 104 | } | ||
| 105 | |||
| 106 | static const struct rtc_class_ops pl030_ops = { | ||
| 107 | .open = pl030_open, | ||
| 108 | .release = pl030_release, | ||
| 109 | .ioctl = pl030_ioctl, | ||
| 110 | .read_time = pl030_read_time, | ||
| 111 | .set_time = pl030_set_time, | ||
| 112 | .read_alarm = pl030_read_alarm, | ||
| 113 | .set_alarm = pl030_set_alarm, | ||
| 114 | }; | ||
| 115 | |||
| 116 | static int pl030_probe(struct amba_device *dev, void *id) | ||
| 117 | { | ||
| 118 | struct pl030_rtc *rtc; | ||
| 119 | int ret; | ||
| 120 | |||
| 121 | ret = amba_request_regions(dev, NULL); | ||
| 122 | if (ret) | ||
| 123 | goto err_req; | ||
| 124 | |||
| 125 | rtc = kmalloc(sizeof(*rtc), GFP_KERNEL); | ||
| 126 | if (!rtc) { | ||
| 127 | ret = -ENOMEM; | ||
| 128 | goto err_rtc; | ||
| 129 | } | ||
| 130 | |||
| 131 | rtc->base = ioremap(dev->res.start, SZ_4K); | ||
| 132 | if (!rtc->base) { | ||
| 133 | ret = -ENOMEM; | ||
| 134 | goto err_map; | ||
| 135 | } | ||
| 136 | |||
| 137 | __raw_writel(0, rtc->base + RTC_CR); | ||
| 138 | __raw_writel(0, rtc->base + RTC_EOI); | ||
| 139 | |||
| 140 | amba_set_drvdata(dev, rtc); | ||
| 141 | |||
| 142 | ret = request_irq(dev->irq[0], pl030_interrupt, IRQF_DISABLED, | ||
| 143 | "rtc-pl030", rtc); | ||
| 144 | if (ret) | ||
| 145 | goto err_irq; | ||
| 146 | |||
| 147 | rtc->rtc = rtc_device_register("pl030", &dev->dev, &pl030_ops, | ||
| 148 | THIS_MODULE); | ||
| 149 | if (IS_ERR(rtc->rtc)) { | ||
| 150 | ret = PTR_ERR(rtc->rtc); | ||
| 151 | goto err_reg; | ||
| 152 | } | ||
| 153 | |||
| 154 | return 0; | ||
| 155 | |||
| 156 | err_reg: | ||
| 157 | free_irq(dev->irq[0], rtc); | ||
| 158 | err_irq: | ||
| 159 | iounmap(rtc->base); | ||
| 160 | err_map: | ||
| 161 | kfree(rtc); | ||
| 162 | err_rtc: | ||
| 163 | amba_release_regions(dev); | ||
| 164 | err_req: | ||
| 165 | return ret; | ||
| 166 | } | ||
| 167 | |||
| 168 | static int pl030_remove(struct amba_device *dev) | ||
| 169 | { | ||
| 170 | struct pl030_rtc *rtc = amba_get_drvdata(dev); | ||
| 171 | |||
| 172 | amba_set_drvdata(dev, NULL); | ||
| 173 | |||
| 174 | writel(0, rtc->base + RTC_CR); | ||
| 175 | |||
| 176 | free_irq(dev->irq[0], rtc); | ||
| 177 | rtc_device_unregister(rtc->rtc); | ||
| 178 | iounmap(rtc->base); | ||
| 179 | kfree(rtc); | ||
| 180 | amba_release_regions(dev); | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static struct amba_id pl030_ids[] = { | ||
| 186 | { | ||
| 187 | .id = 0x00041030, | ||
| 188 | .mask = 0x000fffff, | ||
| 189 | }, | ||
| 190 | { 0, 0 }, | ||
| 191 | }; | ||
| 192 | |||
| 193 | static struct amba_driver pl030_driver = { | ||
| 194 | .drv = { | ||
| 195 | .name = "rtc-pl030", | ||
| 196 | }, | ||
| 197 | .probe = pl030_probe, | ||
| 198 | .remove = pl030_remove, | ||
| 199 | .id_table = pl030_ids, | ||
| 200 | }; | ||
| 201 | |||
| 202 | static int __init pl030_init(void) | ||
| 203 | { | ||
| 204 | return amba_driver_register(&pl030_driver); | ||
| 205 | } | ||
| 206 | |||
| 207 | static void __exit pl030_exit(void) | ||
| 208 | { | ||
| 209 | amba_driver_unregister(&pl030_driver); | ||
| 210 | } | ||
| 211 | |||
| 212 | module_init(pl030_init); | ||
| 213 | module_exit(pl030_exit); | ||
| 214 | |||
| 215 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); | ||
| 216 | MODULE_DESCRIPTION("ARM AMBA PL030 RTC Driver"); | ||
| 217 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 2fd49edcc712..08b4610ec5a6 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
| @@ -12,23 +12,12 @@ | |||
| 12 | * as published by the Free Software Foundation; either version | 12 | * as published by the Free Software Foundation; either version |
| 13 | * 2 of the License, or (at your option) any later version. | 13 | * 2 of the License, or (at your option) any later version. |
| 14 | */ | 14 | */ |
| 15 | |||
| 16 | #include <linux/platform_device.h> | ||
| 17 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 18 | #include <linux/rtc.h> | 16 | #include <linux/rtc.h> |
| 19 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 20 | #include <linux/fs.h> | ||
| 21 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
| 22 | #include <linux/string.h> | ||
| 23 | #include <linux/pm.h> | ||
| 24 | #include <linux/bitops.h> | ||
| 25 | |||
| 26 | #include <linux/amba/bus.h> | 19 | #include <linux/amba/bus.h> |
| 27 | 20 | #include <linux/io.h> | |
| 28 | #include <asm/io.h> | ||
| 29 | #include <asm/hardware.h> | ||
| 30 | #include <asm/irq.h> | ||
| 31 | #include <asm/rtc.h> | ||
| 32 | 21 | ||
| 33 | /* | 22 | /* |
| 34 | * Register definitions | 23 | * Register definitions |
| @@ -142,13 +131,12 @@ static int pl031_remove(struct amba_device *adev) | |||
| 142 | { | 131 | { |
| 143 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); | 132 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); |
| 144 | 133 | ||
| 145 | if (ldata) { | 134 | amba_set_drvdata(adev, NULL); |
| 146 | dev_set_drvdata(&adev->dev, NULL); | 135 | free_irq(adev->irq[0], ldata->rtc); |
| 147 | free_irq(adev->irq[0], ldata->rtc); | 136 | rtc_device_unregister(ldata->rtc); |
| 148 | rtc_device_unregister(ldata->rtc); | 137 | iounmap(ldata->base); |
| 149 | iounmap(ldata->base); | 138 | kfree(ldata); |
| 150 | kfree(ldata); | 139 | amba_release_regions(adev); |
| 151 | } | ||
| 152 | 140 | ||
| 153 | return 0; | 141 | return 0; |
| 154 | } | 142 | } |
| @@ -158,13 +146,15 @@ static int pl031_probe(struct amba_device *adev, void *id) | |||
| 158 | int ret; | 146 | int ret; |
| 159 | struct pl031_local *ldata; | 147 | struct pl031_local *ldata; |
| 160 | 148 | ||
| 149 | ret = amba_request_regions(adev, NULL); | ||
| 150 | if (ret) | ||
| 151 | goto err_req; | ||
| 161 | 152 | ||
| 162 | ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); | 153 | ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); |
| 163 | if (!ldata) { | 154 | if (!ldata) { |
| 164 | ret = -ENOMEM; | 155 | ret = -ENOMEM; |
| 165 | goto out; | 156 | goto out; |
| 166 | } | 157 | } |
| 167 | dev_set_drvdata(&adev->dev, ldata); | ||
| 168 | 158 | ||
| 169 | ldata->base = ioremap(adev->res.start, | 159 | ldata->base = ioremap(adev->res.start, |
| 170 | adev->res.end - adev->res.start + 1); | 160 | adev->res.end - adev->res.start + 1); |
| @@ -173,6 +163,8 @@ static int pl031_probe(struct amba_device *adev, void *id) | |||
| 173 | goto out_no_remap; | 163 | goto out_no_remap; |
| 174 | } | 164 | } |
| 175 | 165 | ||
| 166 | amba_set_drvdata(adev, ldata); | ||
| 167 | |||
| 176 | if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, | 168 | if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, |
| 177 | "rtc-pl031", ldata->rtc)) { | 169 | "rtc-pl031", ldata->rtc)) { |
| 178 | ret = -EIO; | 170 | ret = -EIO; |
| @@ -192,10 +184,12 @@ out_no_rtc: | |||
| 192 | free_irq(adev->irq[0], ldata->rtc); | 184 | free_irq(adev->irq[0], ldata->rtc); |
| 193 | out_no_irq: | 185 | out_no_irq: |
| 194 | iounmap(ldata->base); | 186 | iounmap(ldata->base); |
| 187 | amba_set_drvdata(adev, NULL); | ||
| 195 | out_no_remap: | 188 | out_no_remap: |
| 196 | dev_set_drvdata(&adev->dev, NULL); | ||
| 197 | kfree(ldata); | 189 | kfree(ldata); |
| 198 | out: | 190 | out: |
| 191 | amba_release_regions(adev); | ||
| 192 | err_req: | ||
| 199 | return ret; | 193 | return ret; |
| 200 | } | 194 | } |
| 201 | 195 | ||
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index f26e0cad8f16..fed86e507fdf 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
| @@ -26,10 +26,6 @@ | |||
| 26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
| 27 | #include <asm/io.h> | 27 | #include <asm/io.h> |
| 28 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
| 29 | #include <asm/rtc.h> | ||
| 30 | |||
| 31 | #include <asm/mach/time.h> | ||
| 32 | |||
| 33 | #include <asm/plat-s3c/regs-rtc.h> | 29 | #include <asm/plat-s3c/regs-rtc.h> |
| 34 | 30 | ||
| 35 | /* I have yet to find an S3C implementation with more than one | 31 | /* I have yet to find an S3C implementation with more than one |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 67421b0d3a7b..f47294c60148 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | 33 | ||
| 34 | #include <asm/hardware.h> | 34 | #include <asm/hardware.h> |
| 35 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
| 36 | #include <asm/rtc.h> | ||
| 37 | 36 | ||
| 38 | #ifdef CONFIG_ARCH_PXA | 37 | #ifdef CONFIG_ARCH_PXA |
| 39 | #include <asm/arch/pxa-regs.h> | 38 | #include <asm/arch/pxa-regs.h> |
| @@ -47,6 +46,42 @@ static unsigned long rtc_freq = 1024; | |||
| 47 | static struct rtc_time rtc_alarm; | 46 | static struct rtc_time rtc_alarm; |
| 48 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 47 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
| 49 | 48 | ||
| 49 | static inline int rtc_periodic_alarm(struct rtc_time *tm) | ||
| 50 | { | ||
| 51 | return (tm->tm_year == -1) || | ||
| 52 | ((unsigned)tm->tm_mon >= 12) || | ||
| 53 | ((unsigned)(tm->tm_mday - 1) >= 31) || | ||
| 54 | ((unsigned)tm->tm_hour > 23) || | ||
| 55 | ((unsigned)tm->tm_min > 59) || | ||
| 56 | ((unsigned)tm->tm_sec > 59); | ||
| 57 | } | ||
| 58 | |||
| 59 | /* | ||
| 60 | * Calculate the next alarm time given the requested alarm time mask | ||
| 61 | * and the current time. | ||
| 62 | */ | ||
| 63 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm) | ||
| 64 | { | ||
| 65 | unsigned long next_time; | ||
| 66 | unsigned long now_time; | ||
| 67 | |||
| 68 | next->tm_year = now->tm_year; | ||
| 69 | next->tm_mon = now->tm_mon; | ||
| 70 | next->tm_mday = now->tm_mday; | ||
| 71 | next->tm_hour = alrm->tm_hour; | ||
| 72 | next->tm_min = alrm->tm_min; | ||
| 73 | next->tm_sec = alrm->tm_sec; | ||
| 74 | |||
| 75 | rtc_tm_to_time(now, &now_time); | ||
| 76 | rtc_tm_to_time(next, &next_time); | ||
| 77 | |||
| 78 | if (next_time < now_time) { | ||
| 79 | /* Advance one day */ | ||
| 80 | next_time += 60 * 60 * 24; | ||
| 81 | rtc_time_to_tm(next_time, next); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 50 | static int rtc_update_alarm(struct rtc_time *alrm) | 85 | static int rtc_update_alarm(struct rtc_time *alrm) |
| 51 | { | 86 | { |
| 52 | struct rtc_time alarm_tm, now_tm; | 87 | struct rtc_time alarm_tm, now_tm; |
