Skip to contentSkip to conversation

rtc: add driver for internal RTC on kirkwood SoC

PATCH Superseded Chris Packham 4 participants 14 messages May 13, 2011 – Jul 27, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 rtc: add driver for internal RTC on kirkwood SoC

From: Luuk Paulussen <[email protected]>

---
 arch/arm/include/asm/arch-kirkwood/kirkwood.h |    2 +
 drivers/rtc/Makefile                          |    1 +
 drivers/rtc/kirkwood.c                        |   76 +++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/kirkwood.c
arch/arm/include/asm/arch-kirkwood/kirkwood.h +2 -0
index 0104418..15922eb 100644
@@ -50,6 +50,8 @@
 #define KW_MPP_BASE			(KW_REGISTER(0x10000))
 #define KW_GPIO0_BASE			(KW_REGISTER(0x10100))
 #define KW_GPIO1_BASE			(KW_REGISTER(0x10140))
+#define KW_RTC_TIME			(KW_REGISTER(0x10300))
+#define KW_RTC_DATE			(KW_REGISTER(0x10304))
 #define KW_NANDF_BASE			(KW_REGISTER(0x10418))
 #define KW_SPI_BASE			(KW_REGISTER(0x10600))
 #define KW_CPU_WIN_BASE			(KW_REGISTER(0x20000))
drivers/rtc/Makefile +1 -0
index e4be4a4..ec064d9 100644
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_RTC_DS174x) += ds174x.o
 COBJS-$(CONFIG_RTC_DS3231) += ds3231.o
 COBJS-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 COBJS-$(CONFIG_RTC_ISL1208) += isl1208.o
+COBJS-$(CONFIG_RTC_KIRKWOOD) += kirkwood.o
 COBJS-$(CONFIG_RTC_M41T11) += m41t11.o
 COBJS-$(CONFIG_RTC_M41T60) += m41t60.o
 COBJS-$(CONFIG_RTC_M41T62) += m41t62.o
drivers/rtc/kirkwood.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 1/1 rtc: add driver for internal RTC on kirkwood SoC

From: Luuk Paulussen <[email protected]>

---
Changes since v1:
- run through checkpatch.pl and fix style issues (spaces before bracket and lines > 80 chars)

 arch/arm/include/asm/arch-kirkwood/kirkwood.h |    2 +
 drivers/rtc/Makefile                          |    1 +
 drivers/rtc/kirkwood.c                        |   79 +++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/kirkwood.c
arch/arm/include/asm/arch-kirkwood/kirkwood.h +2 -0
index 0104418..15922eb 100644
@@ -50,6 +50,8 @@
 #define KW_MPP_BASE			(KW_REGISTER(0x10000))
 #define KW_GPIO0_BASE			(KW_REGISTER(0x10100))
 #define KW_GPIO1_BASE			(KW_REGISTER(0x10140))
+#define KW_RTC_TIME			(KW_REGISTER(0x10300))
+#define KW_RTC_DATE			(KW_REGISTER(0x10304))
 #define KW_NANDF_BASE			(KW_REGISTER(0x10418))
 #define KW_SPI_BASE			(KW_REGISTER(0x10600))
 #define KW_CPU_WIN_BASE			(KW_REGISTER(0x20000))
drivers/rtc/Makefile +1 -0
index e4be4a4..ec064d9 100644
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_RTC_DS174x) += ds174x.o
 COBJS-$(CONFIG_RTC_DS3231) += ds3231.o
 COBJS-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 COBJS-$(CONFIG_RTC_ISL1208) += isl1208.o
+COBJS-$(CONFIG_RTC_KIRKWOOD) += kirkwood.o
 COBJS-$(CONFIG_RTC_M41T11) += m41t11.o
 COBJS-$(CONFIG_RTC_M41T60) += m41t60.o
 COBJS-$(CONFIG_RTC_M41T62) += m41t62.o
drivers/rtc/kirkwood.c new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 2/3 sntp: avoid use of uninitialized variable

In reply to Chris Packham

From: Luuk Paulussen <[email protected]>

When we use the ntpserverip environment variable argv[1] may not be set. Printing the error message using the NetNtpServerIP variable ensures the correct output in both cases.

---
 common/cmd_net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
common/cmd_net.c +1 -1
index 8c6f5c8..e0d7d23 100644
@@ -324,7 +324,7 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 
 	if (NetLoop(SNTP) < 0) {
-		printf("SNTP failed: host %s not responding\n", argv[1]);
+		printf("SNTP failed: host %pI4 not responding\n", &NetNtpServerIP);
 		return 1;
 	}
 
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 2/3 sntp: avoid use of uninitialized variable

Quoted 10 lines · Chris Packham

From: Luuk Paulussen <[email protected]>

When we use the ntpserverip environment variable argv[1] may not be set. Printing the error message using the NetNtpServerIP variable ensures the correct output in both cases.

---

Sorry for the spam. I was just trying (and failing) to get git to add the Cc.

#5 lore raw

PATCH v2 1/1 sntp: avoid use of uninitialized variable

From: Luuk Paulussen <[email protected]>

When we use the ntpserverip environment variable argv[1] may not be set. Printing the error message using the NetNtpServerIP variable ensures the correct output in both cases.

---
Changes since v1:
- run through checkpatch.pl, fix line > 80 chars

 common/cmd_net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
common/cmd_net.c +2 -1
index 8c6f5c8..fae3c7f 100644
@@ -324,7 +324,8 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 
 	if (NetLoop(SNTP) < 0) {
-		printf("SNTP failed: host %s not responding\n", argv[1]);
+		printf("SNTP failed: host %pI4 not responding\n",
+			&NetNtpServerIP);
 		return 1;
 	}
 
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH v2 1/1 sntp: avoid use of uninitialized variable

Hi Chris,

Quoted 21 lines

From: Luuk Paulussen <[email protected]>

When we use the ntpserverip environment variable argv[1] may not be set. Printing the error message using the NetNtpServerIP variable ensures the correct output in both cases.

---
Changes since v1:
- run through checkpatch.pl, fix line > 80 chars

 common/cmd_net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
common/cmd_net.c +0 -0
index 8c6f5c8..fae3c7f 100644

common/cmd_net.c int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 330

Quoted 8 lines
common/cmd_net.c +2 -1
@@ -324,7 +324,8 @@ int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else NetTimeOffset = simple_strtol (toff, NULL, 10);
 
 	if (NetLoop(SNTP) < 0) {
-		printf("SNTP failed: host %s not responding\n", argv[1]);
+		printf("SNTP failed: host %pI4 not responding\n",
+			&NetNtpServerIP);
 		return 1;
 	}

Cheers
Detlev

Signature · 6 lines
Is this a private fight or can anyone join in?
                           -- Old Irish saying
--
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
#7 lore raw

PATCH 3/3 bootp: add ntpserver option to bootp request

In reply to Chris Packham

From: Luuk Paulussen <[email protected]>

---
 net/bootp.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
net/bootp.c +13 -0
index 4db63cb..53f37d0 100644
@@ -228,6 +228,11 @@ static void BootpVendorFieldProcess (u8 * ext)
 			NetOurNISDomain[size] = 0;
 		}
 		break;
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+	case 42:	/* NTP server IP */
+		NetCopyIP (&NetNtpServerIP, (IPaddr_t *) (ext + 2));
+		break;
+#endif
 		/* Application layer fields */
 	case 43:		/* Vendor specific info - Not yet supported	*/
 		/*
@@ -278,6 +283,9 @@ static void BootpVendorProcess (u8 * ext, int size)
 
 	if (NetBootFileSize)
 		debug("NetBootFileSize: %d\n", NetBootFileSize);
+
+	if (NetNtpServerIP)
+		debug("NetNtpServerIP : %pI4\n", &NetNtpServerIP);
 }
 /*
  *	Handle a BOOTP received packet.
@@ -538,6 +546,11 @@ static int BootpExtended (u8 * e)
 	*e++ = 32;
 	e   += 32;
 #endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+	*e++  = 42;
+	*e++ = 4;
+	e   += 4;
+#endif
 
 	*e++ = 255;		/* End of the list */
 
Signature · 1 line
1.7.4.1
#9 lore raw

PATCH v2 1/1 bootp: add ntpserver option to bootp request

In reply to Chris Packham

From: Luuk Paulussen <[email protected]>

---
Changes since v1:
- fixed compile error in BootpVendorProcess when CONFIG_CMD_SNTP is not defined

 net/bootp.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
net/bootp.c +15 -0
index 4db63cb..18c743e 100644
@@ -228,6 +228,11 @@ static void BootpVendorFieldProcess (u8 * ext)
 			NetOurNISDomain[size] = 0;
 		}
 		break;
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+	case 42:	/* NTP server IP */
+		NetCopyIP (&NetNtpServerIP, (IPaddr_t *) (ext + 2));
+		break;
+#endif
 		/* Application layer fields */
 	case 43:		/* Vendor specific info - Not yet supported	*/
 		/*
@@ -278,6 +283,11 @@ static void BootpVendorProcess (u8 * ext, int size)
 
 	if (NetBootFileSize)
 		debug("NetBootFileSize: %d\n", NetBootFileSize);
+
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+	if (NetNtpServerIP)
+		debug("NetNtpServerIP : %pI4\n", &NetNtpServerIP);
+#endif
 }
 /*
  *	Handle a BOOTP received packet.
@@ -538,6 +548,11 @@ static int BootpExtended (u8 * e)
 	*e++ = 32;
 	e   += 32;
 #endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+	*e++  = 42;
+	*e++ = 4;
+	e   += 4;
+#endif
 
 	*e++ = 255;		/* End of the list */
 
Signature · 1 line
1.7.4.1
#10 lore raw

PATCH v2 1/1 bootp: add ntpserver option to bootp request

Hello.

Quoted 5 lines · Chris Packham

From: Luuk Paulussen <[email protected]>

[...]

net/bootp.c static void BootpVendorFieldProcess (u8 * ext) · line 233

Quoted 11 lines
net/bootp.c +3 -0
index 4db63cb..18c743e 100644
@@ -228,6 +228,11 @@ static void BootpVendorFieldProcess (u8 * ext)
  			NetOurNISDomain[size] = 0;
  		}
  		break;
+#if defined(CONFIG_CMD_SNTP)&&  defined(CONFIG_BOOTP_NTPSERVER)
+	case 42:	/* NTP server IP */
+		NetCopyIP (&NetNtpServerIP, (IPaddr_t *) (ext + 2));

There should be no space between function name and (. You're now supposed
to run your patch thru scripts/checkpatch.pl (from Linux source tree).

net/bootp.c static int BootpExtended (u8 * e) · line 552

Quoted 11 lines
net/bootp.c +4 -0
+		break;
+#endif
  		/* Application layer fields */
  	case 43:		/* Vendor specific info - Not yet supported	*/
  		/*
@@ -538,6 +548,11 @@ static int BootpExtended (u8 * e)
  	*e++ = 32;
  	e   += 32;
  #endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+	*e++  = 42;

Too many spaces...

net/bootp.c static int BootpExtended (u8 * e) · line 555

Quoted 3 lines
net/bootp.c +3 -0
+	*e++ = 4;
+	e   += 4;
+#endif

WBR, Sergei

#11 lore raw

PATCH v2 1/1 bootp: add ntpserver option to bootp request

Hi Sergei,

Quoted 12 lines · Sergei Shtylyov

Hello.

Quoted 5 lines · Chris Packham

From: Luuk Paulussen <[email protected]>

[...]

Quoted 14 lines

net/bootp.c static void BootpVendorFieldProcess (u8 * ext) · line 233

Quoted 11 lines
net/bootp.c +3 -0
index 4db63cb..18c743e 100644
@@ -228,6 +228,11 @@ static void BootpVendorFieldProcess (u8 * ext)
 ? ? ? ? ? ? ? ? ? ? ? ?NetOurNISDomain[size] = 0;
 ? ? ? ? ? ? ? ?}
 ? ? ? ? ? ? ? ?break;
+#if defined(CONFIG_CMD_SNTP)&& ?defined(CONFIG_BOOTP_NTPSERVER)
+ ? ? ? case 42: ? ? ? ?/* NTP server IP */
+ ? ? ? ? ? ? ? NetCopyIP (&NetNtpServerIP, (IPaddr_t *) (ext + 2));

? There should be no space between function name and (. You're now supposed to run your patch thru scripts/checkpatch.pl (from Linux source tree).

Will fix (and run through checkpatch.pl) in next version.

Quoted 6 lines
Quoted 6 lines
net/bootp.c +2 -0
+ ? ? ? ? ? ? ? break;
+#endif

? ? ? ? ? ? ? ?/* Application layer fields */
? ? ? ?case 43: ? ? ? ? ? ? ? ?/* Vendor specific info - Not yet supported ? ? */
? ? ? ? ? ? ? ?/*

Quoted 8 lines
Quoted 6 lines
net/bootp.c +0 -0
@@ -538,6 +548,11 @@ static int BootpExtended (u8 * e)
 ? ? ? ?*e++ = 32;
 ? ? ? ?e ? += 32;

?#endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+ ? ? ? *e++ ?= 42;

? Too many spaces...

Ditto.

Quoted 6 lines
Quoted 3 lines

+ ? ? ? *e++ = 4;
+ ? ? ? e ? += 4;
+#endif

WBR, Sergei

v3 coming shortly

#12 lore raw

PATCH v3 1/1 bootp: add ntpserver option to bootp request

From: Luuk Paulussen <[email protected]>

---
Changes since v1:
- fixed compile error in BootpVendorProcess when CONFIG_CMD_SNTP is not defined
Changes since v2:
- run though checkpatch.pl. Address comments from Sergei.

 net/bootp.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
net/bootp.c +15 -0
index 4db63cb..45eaab1 100644
@@ -228,6 +228,11 @@ static void BootpVendorFieldProcess (u8 * ext)
 			NetOurNISDomain[size] = 0;
 		}
 		break;
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+	case 42:	/* NTP server IP */
+		NetCopyIP(&NetNtpServerIP, (IPaddr_t *) (ext + 2));
+		break;
+#endif
 		/* Application layer fields */
 	case 43:		/* Vendor specific info - Not yet supported	*/
 		/*
@@ -278,6 +283,11 @@ static void BootpVendorProcess (u8 * ext, int size)
 
 	if (NetBootFileSize)
 		debug("NetBootFileSize: %d\n", NetBootFileSize);
+
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+	if (NetNtpServerIP)
+		debug("NetNtpServerIP : %pI4\n", &NetNtpServerIP);
+#endif
 }
 /*
  *	Handle a BOOTP received packet.
@@ -538,6 +548,11 @@ static int BootpExtended (u8 * e)
 	*e++ = 32;
 	e   += 32;
 #endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+	*e++ = 42;
+	*e++ = 4;
+	e   += 4;
+#endif
 
 	*e++ = 255;		/* End of the list */
 
Signature · 1 line
1.7.4.1
#13 lore raw

PATCH v3 1/1 bootp: add ntpserver option to bootp request

Dear Chris Packham,

Quoted 12 lines · In message <[email protected]> you…

From: Luuk Paulussen <[email protected]>

---
Changes since v1:
- fixed compile error in BootpVendorProcess when CONFIG_CMD_SNTP is not defined
Changes since v2:
- run though checkpatch.pl. Address comments from Sergei.

Quoted 2 lines
 net/bootp.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If you want strict real-time behavior, run in the real  time  schedu-
ling class.  But there are no seatbelts or airbags;  main(){for(;;);}
can hard hang your system.                          -- Bart Smaalders