Skip to contentSkip to conversation

A320: driver for FTRTC010 real time clock

PATCH Superseded Po-Yu Chuang 3 participants 4 messages Jun 23, 2009 – Jun 24, 2009

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 A320: driver for FTRTC010 real time clock

This patch adds an FTRTC010 driver for Faraday A320 evaluation board.

---
Index: drivers/rtc/Makefile
===================================================================
RCS file: /usr/local/cvsroot/ctd/u-boot-2009.06/drivers/rtc/Makefile,v retrieving revision 1.1.1.1
retrieving revision 1.2

rtc/Makefile +1 -0
diff -u -r1.1.1.1 -r1.2
@@ -40,6 +40,7 @@
 COBJS-$(CONFIG_RTC_DS164x) += ds164x.o
 COBJS-$(CONFIG_RTC_DS174x) += ds174x.o
 COBJS-$(CONFIG_RTC_DS3231) += ds3231.o
+COBJS-$(CONFIG_RTC_FTRTC) += ftrtc010.o
 COBJS-$(CONFIG_RTC_ISL1208) += isl1208.o
 COBJS-$(CONFIG_RTC_M41T11) += m41t11.o
 COBJS-$(CONFIG_RTC_M41T60) += m41t60.o

Index: drivers/rtc/ftrtc010.c
===================================================================
RCS file: drivers/rtc/ftrtc010.c

rtc/ftrtc010.c new file +125 -0

125 lines not on this page · raw message

#1 lore raw

PATCH 2/3 A320: driver for FTRTC010 real time clock

rtc/ftrtc010.c line 51

Quoted 4 lines
rtc/ftrtc010.c new file +4 -0
+
+static volatile struct ftrtc010 *rtc = (struct ftrtc010 *)CONFIG_SYS_RTC_BASE;
+
+static void ftrtc_enable (void)

you use it at one please only the reset

rtc/ftrtc010.c line 53

Quoted 2 lines
rtc/ftrtc010.c new file +2 -0
+{
+	rtc->cr = cpu_to_le32 (FTRTC010_CR_ENABLE);

so please move this code there

Quoted 5 lines
rtc/ftrtc010.c new file +5 -0
+}
+
+/*
+ * return current time in seconds
+ */

rtc/ftrtc010.c line 68

Quoted 10 lines
rtc/ftrtc010.c new file +10 -0
+static unsigned long ftrtc_time (void)
+{
+	unsigned long day;
+	unsigned long hour;
+	unsigned long minute;
+	unsigned long second;
+	unsigned long second2;
+
+	do {
+		second	= le32_to_cpu (rtc->sec);

please use proper accessor
readl/writel

Best Regards,
J.

#2 lore raw

PATCH 2/3 A320: driver for FTRTC010 real time clock

Dear Jean-Christophe PLAGNIOL-VILLARD,

2009/6/24 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>:

Quoted 5 lines

rtc/ftrtc010.c line 51

Quoted 4 lines
rtc/ftrtc010.c new file +4 -0
+
+static volatile struct ftrtc010 *rtc = (struct ftrtc010 *)CONFIG_SYS_RTC_BASE;
+
+static void ftrtc_enable (void)

you use it at one please only the reset

Sorry, I don't understand what do you mean

Quoted 12 lines
Quoted 2 lines

+{
+ ? ? rtc->cr = cpu_to_le32 (FTRTC010_CR_ENABLE);

so please move this code there

Quoted 9 lines
rtc/ftrtc010.c new file +9 -0
+}
+
+/*
+ * return current time in seconds
+ */
+static unsigned long ftrtc_time (void)
+{
+ ? ? unsigned long day;
+ ? ? unsigned long hour;
Quoted 8 lines
Quoted 6 lines

+ ? ? unsigned long minute;
+ ? ? unsigned long second;
+ ? ? unsigned long second2;
+
+ ? ? do {
+ ? ? ? ? ? ? second ?= le32_to_cpu (rtc->sec);

please use proper accessor
readl/writel

Should I use
second = readl(&rtc->sec);
or just
second = rtc->sec;

Best regards,
Po-Yu Chuang

#3 lore raw

PATCH 2/3 A320: driver for FTRTC010 real time clock

Hi Po-Yu Chuang,

Quoted 9 lines

Dear Jean-Christophe PLAGNIOL-VILLARD,

2009/6/24 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>:

Quoted 5 lines

rtc/ftrtc010.c line 51

Quoted 4 lines
rtc/ftrtc010.c new file +4 -0
+
+static volatile struct ftrtc010 *rtc = (struct ftrtc010 *)CONFIG_SYS_RTC_BASE;
+
+static void ftrtc_enable (void)

you use it at one please only the reset

Sorry, I don't understand what do you mean

I guess he means that he doesn't like functions which are only called from one place - he'd rather like to see the code directly at the callers site.

However I do not agree here - functions have also a documentation effect, so I vote to keep the function. If neccessary, we could declare the function inline, but this is really overkill here.

Quoted 20 lines
Quoted 12 lines
Quoted 2 lines

+{
+ ? ? rtc->cr = cpu_to_le32 (FTRTC010_CR_ENABLE);

so please move this code there

Quoted 9 lines
rtc/ftrtc010.c new file +9 -0
+}
+
+/*
+ * return current time in seconds
+ */
+static unsigned long ftrtc_time (void)
+{
+ ? ? unsigned long day;
+ ? ? unsigned long hour;
Quoted 8 lines
Quoted 6 lines

+ ? ? unsigned long minute;
+ ? ? unsigned long second;
+ ? ? unsigned long second2;
+
+ ? ? do {
+ ? ? ? ? ? ? second ?= le32_to_cpu (rtc->sec);

please use proper accessor
readl/writel

Quoted 2 lines

Should I use
second = readl(&rtc->sec);

Yep.

Cheers
Detlev

Signature · 8 lines
BUGS:
  It is not yet possible to change operating system by writing to
  /proc/sys/kernel/ostype.
                                     -- Linux sysctl(2) man page
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de