Skip to contentSkip to conversation

RTC: DaVinci RTC driver

PATCH In review Kevin Hilman 3 participants 7 messages Mar 12, 2010 – Mar 15, 2010 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RTC: DaVinci RTC driver

From: Miguel Aguilar <[email protected]>

This driver features:

* Alarm support.
* Periodic interrupt by using a timer include into the RTC module.
* The update interrupt is not supported by this RTC module.

This driver was tested on a DM365 EVM by using the rtc-test application from the Documentation/rtc.txt.

---
This was reviewed and discussed a while back[1] and I dropped the ball on submitting the final version. Here's the updated version rebased against v2.6.34-rc1.

[1] http://groups.google.com/group/rtc-linux/browse_thread/thread/d88a6c8a31fc2eb6/a858a2a8b8db57fe?lnk=gst&q=davinci#a858a2a8b8db57fe

 drivers/rtc/Kconfig       |   10 +
 drivers/rtc/Makefile      |    1 +
 drivers/rtc/rtc-davinci.c |  673 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 684 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-davinci.c
drivers/rtc/Kconfig +10 -0
index 6a13037..50ac047 100644
@@ -620,6 +620,16 @@ config RTC_DRV_NUC900
 
 comment "on-CPU RTC drivers"
 
+config RTC_DRV_DAVINCI
+	tristate "TI DaVinci RTC"
+	depends on ARCH_DAVINCI_DM365
+	help
+	  If you say yes here you get support for the RTC on the
+	  DaVinci platforms (DM365).
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-davinci.
+
 config RTC_DRV_OMAP
 	tristate "TI OMAP1"
 	depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX
drivers/rtc/Makefile +1 -0
index 44ef194..245311a 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K)	+= rtc-bq32k.o
 obj-$(CONFIG_RTC_DRV_BQ4802)	+= rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)	+= rtc-coh901331.o
+obj-$(CONFIG_RTC_DRV_DAVINCI)	+= rtc-davinci.o
 obj-$(CONFIG_RTC_DRV_DM355EVM)	+= rtc-dm355evm.o
 obj-$(CONFIG_RTC_DRV_DS1216)	+= rtc-ds1216.o
 obj-$(CONFIG_RTC_DRV_DS1286)	+= rtc-ds1286.o
drivers/rtc/rtc-davinci.c new file +673 -0

673 lines not on this page · raw message

Signature · 1 line
1.7.0.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Fri, 12 Mar 2010 11:08:33 -0800 Kevin Hilman <[email protected]>…

This driver was tested on a DM365 EVM by using the rtc-test application from the Documentation/rtc.txt.

Please add an email in MODULE_AUTHOR

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
author Acked-by Alessandro Zummo
#2 lore raw
Quoted 6 lines · Alessandro Zummo
Quoted 3 lines · On Fri, 12 Mar 2010 11:08:33 -0800 Kevin Hilman <[email protected]>…

This driver was tested on a DM365 EVM by using the rtc-test application from the Documentation/rtc.txt.

Quoted 6 lines
Quoted 2 lines

Please add an email in MODULE_AUTHOR

Done. updated version below with your ack added.

Will you merge this via RTC subsystem, or should I merge it via the davinci platform tree?

Kevin

Quoted 1 line

From 9a058a643fd2df4b391871cf1932eef76a5cf2fd Mon Sep 17 00:00:00 2001

From: Miguel Aguilar <[email protected]>
Date: Thu, 5 Nov 2009 08:51:34 -0600
Subject: [PATCH] RTC: DaVinci RTC driver

This driver features:

* Alarm support.
* Periodic interrupt by using a timer include into the RTC module.
* The update interrupt is not supported by this RTC module.

This driver was tested on a DM365 EVM by using the rtc-test application from the Documentation/rtc.txt.

---
 drivers/rtc/Kconfig       |   10 +
 drivers/rtc/Makefile      |    1 +
 drivers/rtc/rtc-davinci.c |  673 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 684 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-davinci.c
drivers/rtc/Kconfig +10 -0
index 6a13037..50ac047 100644
@@ -620,6 +620,16 @@ config RTC_DRV_NUC900
 
 comment "on-CPU RTC drivers"
 
+config RTC_DRV_DAVINCI
+	tristate "TI DaVinci RTC"
+	depends on ARCH_DAVINCI_DM365
+	help
+	  If you say yes here you get support for the RTC on the
+	  DaVinci platforms (DM365).
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-davinci.
+
 config RTC_DRV_OMAP
 	tristate "TI OMAP1"
 	depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX
drivers/rtc/Makefile +1 -0
index 44ef194..245311a 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K)	+= rtc-bq32k.o
 obj-$(CONFIG_RTC_DRV_BQ4802)	+= rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)	+= rtc-coh901331.o
+obj-$(CONFIG_RTC_DRV_DAVINCI)	+= rtc-davinci.o
 obj-$(CONFIG_RTC_DRV_DM355EVM)	+= rtc-dm355evm.o
 obj-$(CONFIG_RTC_DRV_DS1216)	+= rtc-ds1216.o
 obj-$(CONFIG_RTC_DRV_DS1286)	+= rtc-ds1286.o
drivers/rtc/rtc-davinci.c new file +673 -0

673 lines not on this page · raw message

Signature · 1 line
1.7.0.2
#3 lore raw
Quoted 2 lines · On Fri, 12 Mar 2010 14:09:29 -0800 Kevin Hilman <[email protected]>…

Will you merge this via RTC subsystem, or should I merge it via the davinci platform tree?

Use the davinci tree and I'll be grateful ;)

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#4 lore raw
In reply to Kevin Hilman
Quoted 32 lines · On Fri, 12 Mar 2010 11:08:33 -0800 Kevin Hilman <[email protected]>…
drivers/rtc/rtc-davinci.c new file +32 -0
+static int convertfromdays(u16 days, struct rtc_time *tm)
+{
+	int tmp_days, year, mon;
+
+	for (year = 2000;; year++) {
+		tmp_days = rtc_year_days(1, 12, year);
+		if (days >= tmp_days)
+			days -= tmp_days;
+		else {
+			for (mon = 0;; mon++) {
+				tmp_days = rtc_month_days(mon, year);
+				if (days >= tmp_days) {
+					days -= tmp_days;
+				} else {
+					tm->tm_year = year - 1900;
+					tm->tm_mon = mon;
+					tm->tm_mday = days + 1;
+					break;
+				}
+			}
+			break;
+		}
+	}
+	return 0;
+}
+
+static int convert2days(u16 *days, struct rtc_time *tm)
+{
+	int i;
+	*days = 0;
+
+	/* epoch == 1900 */

drivers/rtc/rtc-davinci.c line 289

Quoted 10 lines
drivers/rtc/rtc-davinci.c new file +10 -0
+	if (tm->tm_year < 100 || tm->tm_year > 199)
+		return -EINVAL;
+
+	for (i = 2000; i < 1900 + tm->tm_year; i++)
+		*days += rtc_year_days(1, 12, i);
+
+	*days += rtc_year_days(tm->tm_mday, tm->tm_mon, 1900 + tm->tm_year);
+
+	return 0;
+}

I'm looking suspiciously at these (slow-looking) functions. Are they really specific to this device, or could we be making better use of library code, or adding functionality to library code?

#5 lore raw
Quoted 3 lines · On Mon, 15 Mar 2010 14:20:24 -0700 Andrew Morton <[email protected]>…

I'm looking suspiciously at these (slow-looking) functions. Are they really specific to this device, or could we be making better use of library code, or adding functionality to library code?

I truly hope no other driver with similar needs ;)

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#6 lore raw
Quoted 1 line · On Mon, 15 Mar 2010 23:32:03 +0100 Alessandro Zummo <[email protected]>…

I truly hope no other driver with similar needs ;)

insert "there is" where appropriate..

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it