From e48add8c1c462fb10d6297b739a57ef599eb02ae Mon Sep 17 00:00:00 2001 From: Atul Dahiya Date: Tue, 20 Jul 2010 12:19:14 +0530 Subject: rtc: rtc-s3c: Updates RTC driver for clock enabling support This Patch updates existing Samsung RTC driver for clock enabling support. Signed-off-by: Atul Dahiya Signed-off-by: Kukjin Kim Cc: Ben Dooks Acked-by: Wan ZongShun --- drivers/rtc/rtc-s3c.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/rtc') diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 70b68d35f969..c032a15c84ab 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -1,4 +1,7 @@ /* drivers/rtc/rtc-s3c.c + * + * Copyright (c) 2010 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ * * Copyright (c) 2004,2006 Simtec Electronics * Ben Dooks, @@ -39,6 +42,7 @@ enum s3c_cpu_type { static struct resource *s3c_rtc_mem; +static struct clk *rtc_clk; static void __iomem *s3c_rtc_base; static int s3c_rtc_alarmno = NO_IRQ; static int s3c_rtc_tickno = NO_IRQ; @@ -431,6 +435,10 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) s3c_rtc_setpie(&dev->dev, 0); s3c_rtc_setaie(0); + clk_disable(rtc_clk); + clk_put(rtc_clk); + rtc_clk = NULL; + iounmap(s3c_rtc_base); release_resource(s3c_rtc_mem); kfree(s3c_rtc_mem); @@ -488,6 +496,16 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) goto err_nomap; } + rtc_clk = clk_get(&pdev->dev, "rtc"); + if (IS_ERR(rtc_clk)) { + dev_err(&pdev->dev, "failed to find rtc clock source\n"); + ret = PTR_ERR(rtc_clk); + rtc_clk = NULL; + goto err_clk; + } + + clk_enable(rtc_clk); + /* check to see if everything is setup correctly */ s3c_rtc_enable(pdev, 1); @@ -523,6 +541,10 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) err_nortc: s3c_rtc_enable(pdev, 0); + clk_disable(rtc_clk); + clk_put(rtc_clk); + + err_clk: iounmap(s3c_rtc_base); err_nomap: -- cgit v1.2.1 From 2f3478f6579b3f8d4579b6d49d7a8e9376c48fc2 Mon Sep 17 00:00:00 2001 From: Atul Dahiya Date: Tue, 20 Jul 2010 16:02:51 +0530 Subject: rtc: rtc-s3c: Updates driver for S3C64XX and newer SoCs This Patch does followings. 1) Enables support for alarm and time tick pending register for periodic interrupt generation. 2) Changes writeb to writew beacuse the macro S3C64XX_RTCCON_TICEN (Tick Timer Enable) is 9th bit of register. 3) Changes writeb to writel as max_user_freq used in s3c64xx is 32768 and requires 15 bits to update the Tick Count Register. Signed-off-by: Atul Dahiya Signed-off-by: Taekgyun Ko Signed-off-by: Kukjin Kim Cc: Ben Dooks --- drivers/rtc/rtc-s3c.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers/rtc') diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index c032a15c84ab..204001769ebc 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -57,6 +57,10 @@ static irqreturn_t s3c_rtc_alarmirq(int irq, void *id) struct rtc_device *rdev = id; rtc_update_irq(rdev, 1, RTC_AF | RTC_IRQF); + + if (s3c_rtc_cpu_type == TYPE_S3C64XX) + writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP); + return IRQ_HANDLED; } @@ -65,6 +69,10 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id) struct rtc_device *rdev = id; rtc_update_irq(rdev, 1, RTC_PF | RTC_IRQF); + + if (s3c_rtc_cpu_type == TYPE_S3C64XX) + writeb(S3C2410_INTP_TIC, s3c_rtc_base + S3C2410_INTP); + return IRQ_HANDLED; } @@ -98,7 +106,7 @@ static int s3c_rtc_setpie(struct device *dev, int enabled) if (enabled) tmp |= S3C64XX_RTCCON_TICEN; - writeb(tmp, s3c_rtc_base + S3C2410_RTCCON); + writew(tmp, s3c_rtc_base + S3C2410_RTCCON); } else { tmp = readb(s3c_rtc_base + S3C2410_TICNT); tmp &= ~S3C2410_TICNT_ENABLE; @@ -132,7 +140,7 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) tmp |= (rtc_dev->max_user_freq / freq)-1; - writeb(tmp, s3c_rtc_base + S3C2410_TICNT); + writel(tmp, s3c_rtc_base + S3C2410_TICNT); spin_unlock_irq(&s3c_rtc_pie_lock); return 0; -- cgit v1.2.1 From 051fe54e9f8c568dc9cd288b630d436ee93afe35 Mon Sep 17 00:00:00 2001 From: Taekgyun Ko Date: Thu, 29 Jul 2010 13:00:42 +0900 Subject: rtc: rtc-s3c: Add BCD register initialization codes RTC needs to be initialized when BCD registers have invalid value. Signed-off-by: Taekgyun Ko Signed-off-by: Kukjin Kim Cc: Ben Dooks Acked-by: Alessandro Zummo --- drivers/rtc/rtc-s3c.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/rtc') diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 204001769ebc..a0d3ec89d412 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -458,6 +458,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) { struct rtc_device *rtc; struct resource *res; + unsigned int tmp, i; int ret; pr_debug("%s: probe=%p\n", __func__, pdev); @@ -536,6 +537,15 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; + /* Check RTC Time */ + + for (i = S3C2410_RTCSEC; i <= S3C2410_RTCYEAR; i += 0x4) { + tmp = readb(s3c_rtc_base + i); + + if ((tmp & 0xf) > 0x9 || ((tmp >> 4) & 0xf) > 0x9) + writeb(0, s3c_rtc_base + i); + } + if (s3c_rtc_cpu_type == TYPE_S3C64XX) rtc->max_user_freq = 32768; else -- cgit v1.2.1 From 16f4efe7bf6cae180f72618ccc4027afee78123a Mon Sep 17 00:00:00 2001 From: Atul Dahiya Date: Tue, 20 Jul 2010 16:38:49 +0530 Subject: rtc: rtc-s3c: Add extra option to include RTC for Samsung SoCs This patch adds HAVE_S3C_RTC to control inclusion of RTC driver for Samsung SoCs. This option will help to include the driver only for the necessary machines and not for any given arch. Signed-off-by: Atul Dahiya Signed-off-by: Kukjin Kim Cc: Ben Dooks --- drivers/rtc/Kconfig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/rtc') diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 10ba12c8c5e0..c43732ff1800 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -645,9 +645,16 @@ config RTC_DRV_OMAP DA8xx/OMAP-L13x chips. This driver can also be built as a module called rtc-omap. +config HAVE_S3C_RTC + bool + help + This will include RTC support for Samsung SoCs. If + you want to include RTC support for any machine, kindly + select this in the respective mach-XXXX/Kconfig file. + config RTC_DRV_S3C tristate "Samsung S3C series SoC RTC" - depends on ARCH_S3C2410 || ARCH_S3C64XX + depends on ARCH_S3C2410 || ARCH_S3C64XX || HAVE_S3C_RTC help RTC (Realtime Clock) driver for the clock inbuilt into the Samsung S3C24XX series of SoCs. This can provide periodic -- cgit v1.2.1