Updates RTC driver for Samsung S3C64XX and newer SoCs
cover Updates RTC driver for Samsung S3C64XX and newer SoCs
This patch updates RTC driver for Samsung S3C64XX and newer SoCs.
NOTE: depends on previous RTC patch for clock enabling.
[PATCH 1/3] ARM: SAMSUNG: Updates RTC register for support Alarm IRQ and Time Tick. [PATCH 2/3] rtc: rtc-s3c: Updates driver for S3C64XX and newer SoCs [PATCH 3/3] rtc: rtc-s3c: Add BCD register initialization codes
PATCH 1/3 ARM: SAMSUNG: Updates RTC register for support Alarm IRQ and Time Tick.
From: Atul Dahiya <[email protected]>
This patch updates RTC registers for support Alarm IRQ and Time Tick.
--- arch/arm/plat-samsung/include/plat/regs-rtc.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/include/plat/regs-rtc.h +3 -0
@@ -14,6 +14,9 @@#define __ASM_ARCH_REGS_RTC_H __FILE__#define S3C2410_RTCREG (x) (x) +#define S3C2410_INTP S3C2410_RTCREG(0x30) +#define S3C2410_INTP_ALM (1 << 1) +#define S3C2410_INTP_TIC (1 << 0)#define S3C2410_RTCCON S3C2410_RTCREG(0x40)#define S3C2410_RTCCON_RTCEN (1<<0)
Signature · 1 line
1.6.2.5
PATCH 2/3 rtc: rtc-s3c: Updates driver for S3C64XX and newer SoCs
In reply to Kukjin KimFrom: Atul Dahiya <[email protected]>
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.
--- drivers/rtc/rtc-s3c.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
drivers/rtc/rtc-s3c.c +10 -2
@@ -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 ;
Signature · 1 line
1.6.2.5
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
In reply to Kukjin KimFrom: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
--- drivers/rtc/rtc-s3c.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/rtc/rtc-s3c.c +12 -2
@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data; -if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) +if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) { rtc->max_user_freq =32768 ; -else + +/* 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); + } + }else { rtc->max_user_freq =128 ; + }platform_set_drvdata (pdev, rtc);
Signature · 1 line
1.6.2.5
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
Hello.
Quoted 6 lines · Kukjin Kim
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>
[...]
Quoted 9 lines
drivers/rtc/rtc-s3c.c +0
-1@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data; -if (s3c_rtc_cpu_type ==TYPE_S3C64XX )
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev) · line 547
Quoted 10 lines
drivers/rtc/rtc-s3c.c +8
-1+if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) { rtc->max_user_freq =32768 ; - else + +/* 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 ))
There is no need to have parens around > operations.
WBR, Sergei
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
Quoted 3 lines · Sergei Shtylyov
Hello.
Hi :-)
Quoted 18 lines
Quoted 6 lines · Kukjin Kim
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>[...]
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct
Quoted 5 lines
drivers/rtc/rtc-s3c.c +0
-0@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct
platform_device*pdev)Quoted 3 lines
drivers/rtc/rtc-s3c.c +0
-0s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data;
Quoted 11 lines
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev)
Quoted 11 lines
drivers/rtc/rtc-s3c.c +8
-2-if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) +if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) { rtc->max_user_freq =32768 ; -else + +/* 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))
Quoted 3 lines
There is no need to have parens around > operations.
Ok...you're right. will fix it.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
In reply to Kukjin Kim2010/7/21 Kukjin Kim <[email protected]>:
Quoted 3 lines
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Do you mean that the hardware register does not have default value? Any results if no initialized value here?
Quoted 42 lines
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>---
?drivers/rtc/rtc-s3c.c | ? 14 ++++++++++++-- ?1 files changed, 12 insertions(+), 2 deletions(-)drivers/rtc/rtc-s3c.c +12
-3@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) ? ? ? ?s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; - ? ? ? if (s3c_rtc_cpu_type == TYPE_S3C64XX) + ? ? ? if (s3c_rtc_cpu_type == TYPE_S3C64XX) { ? ? ? ? ? ? ? ?rtc->max_user_freq = 32768; - ? ? ? else + + ? ? ? ? ? ? ? /* 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); + ? ? ? ? ? ? ? } + ? ? ? } else { ? ? ? ? ? ? ? ?rtc->max_user_freq = 128; + ? ? ? } ? ? ? ?platform_set_drvdata(pdev, rtc); --1.6.2.5
--
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
Signature · 10 lines
*linux-arm-kernel mailing list mail addr:linux-arm-kernel at lists.infradead.org you can subscribe by: http://lists.infradead.org/mailman/listinfo/linux-arm-kernel * linux-arm-NUC900 mailing list mail addr:NUC900 at googlegroups.com main web: https://groups.google.com/group/NUC900 you can subscribe it by sending me mail: mcuos.com at gmail.com
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
Quoted 9 lines · Wan ZongShun
2010/7/21 Kukjin Kim <[email protected]>:
Quoted 3 lines
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Do you mean that the hardware register does not have default value? Any results if no initialized value here?
Hi,
Yes..I mean that it has no default value.
As you know, it has to be keep the previous time value after reset..and the reset value is not defined.
So added check that functionality, because if it has no valid BCD value, RTC time does not move on. Of course, if we set time at that time, RTC works well...I mean just need initialize that.
Quoted 33 lines
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct
Quoted 12 lines
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>--- drivers/rtc/rtc-s3c.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)drivers/rtc/rtc-s3c.c +0
-0@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct
platform_device*pdev)Quoted 20 lines
drivers/rtc/rtc-s3c.c +12
-2s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data; -if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) +if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) { rtc->max_user_freq =32768 ; -else + +/* 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); + } + }else { rtc->max_user_freq =128 ; + }
Quoted 5 lines
Quoted 5 lines
drivers/rtc/rtc-s3c.c +0
-1platform_set_drvdata (pdev, rtc); --1.6.2.5
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
2010/7/23 Kukjin Kim <[email protected]>:
Quoted 7 lines
Quoted 6 lines · Wan ZongShun
2010/7/21 Kukjin Kim <[email protected]>:
Quoted 3 lines
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Quoted 8 lines
Quoted 3 lines
Do you mean that the hardware register does not have default value? Any results if no initialized value here?
Hi,
Yes..I mean that it has no default value.
As you know, it has to be keep the previous time value after reset..and the reset value is not defined.
So, reset is no use to this RTC BCD registers, it still keep previous time value.
Quoted 3 lines
So added check that functionality, because if it has no valid BCD value, RTC time does not move on. Of course, if we set time at that time, RTC works well...I mean just need initialize that.
Okay,good patch.:)
In addtion,For making sure to get valid value, it is much better to use also 'rtc_valid_tm(tm)' to check returning time value in your s3c_rtc_gettime() and s3c_rtc_getalarm(() functions.
Quoted 53 lines
Quoted 33 lines
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct
Quoted 12 lines
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>---
?drivers/rtc/rtc-s3c.c | ? 14 ++++++++++++-- ?1 files changed, 12 insertions(+), 2 deletions(-)drivers/rtc/rtc-s3c.c +0
-0@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct
platform_device*pdev)Quoted 20 lines
drivers/rtc/rtc-s3c.c +12
-2? ? ? ?s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; - ? ? ? if (s3c_rtc_cpu_type == TYPE_S3C64XX) + ? ? ? if (s3c_rtc_cpu_type == TYPE_S3C64XX) { ? ? ? ? ? ? ? ?rtc->max_user_freq = 32768; - ? ? ? else + + ? ? ? ? ? ? ? /* 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); + ? ? ? ? ? ? ? } + ? ? ? } else { ? ? ? ? ? ? ? ?rtc->max_user_freq = 128; + ? ? ? }Quoted 5 lines
Quoted 5 lines
drivers/rtc/rtc-s3c.c +0
-1? ? ? ?platform_set_drvdata(pdev, rtc); --1.6.2.5
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.--
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
Signature · 10 lines
*linux-arm-kernel mailing list mail addr:linux-arm-kernel at lists.infradead.org you can subscribe by: http://lists.infradead.org/mailman/listinfo/linux-arm-kernel * linux-arm-NUC900 mailing list mail addr:NUC900 at googlegroups.com main web: https://groups.google.com/group/NUC900 you can subscribe it by sending me mail: mcuos.com at gmail.com
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
Quoted 22 lines · Wan ZongShun
2010/7/23 Kukjin Kim <[email protected]>:
Quoted 7 lines
Quoted 6 lines · Wan ZongShun
2010/7/21 Kukjin Kim <[email protected]>:
Quoted 3 lines
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Quoted 7 lines
Quoted 3 lines
Do you mean that the hardware register does not have default value? Any results if no initialized value here?
Hi,
Yes..I mean that it has no default value.
As you know, it has to be keep the previous time value after reset..and the resetvalue is not defined.
Quoted 1 line
So, reset is no use to this RTC BCD registers, it still keep previous time value.
Quoted 8 lines
Quoted 1 line
So added check that functionality, because if it has no valid BCD value, RTC
time does not move on.
Quoted 1 line
Of course, if we set time at that time, RTC works well...I mean just need initialize
that.
Quoted 1 line
Okay,good patch.:)
Thanks ;-)
Quoted 4 lines
In addtion,For making sure to get valid value, it is much better to use also '
rtc_valid_tm(tm)' to check returning time value in yours3c_rtc_gettime()and s3c_rtc_getalarm(() functions.
Ok..will do it later as per your suggestion.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>--- drivers/rtc/rtc-s3c.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
(snip)
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
In reply to Kukjin KimQuoted 20 lines · Kukjin Kim
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>--- drivers/rtc/rtc-s3c.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)drivers/rtc/rtc-s3c.c +1
-1@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data; -if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) +if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) {
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev) · line 548
Quoted 10 lines
drivers/rtc/rtc-s3c.c +8
-1rtc->max_user_freq =32768 ; - else + +/* 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);
This is something we should probably do for all SoCs.
PATCH 3/3 rtc: rtc-s3c: Add BCD register initialization codes
Quoted 21 lines · Ben Dooks
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct
Quoted 15 lines · Kukjin Kim
From: Taekgyun Ko <[email protected]>
RTC needs to be initialized when BCD registers have invalid value.
Signed-off-by Taekgyun Ko <[email protected]>Signed-off-by Kukjin Kim <[email protected]>--- drivers/rtc/rtc-s3c.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)drivers/rtc/rtc-s3c.c +0
-0@@ -536,10 +536,20 @@ static int __devinit s3c_rtc_probe(struct
platform_device*pdev)Quoted 3 lines
drivers/rtc/rtc-s3c.c +0
-0s3c_rtc_cpu_type =platform_get_device_id (pdev)->driver_data;
Quoted 11 lines
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev)
Quoted 11 lines
drivers/rtc/rtc-s3c.c +8
-2-if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) +if (s3c_rtc_cpu_type ==TYPE_S3C64XX ) { rtc->max_user_freq =32768 ; -else + +/* 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))
Quoted 3 lines
drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev) · line 548
Quoted 1 line
drivers/rtc/rtc-s3c.c +1
-0+writeb (0 , s3c_rtc_base + i);This is something we should probably do for all SoCs.
Yeah...ok...will move it.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.