* Patch by Masami Komiya, 30 Mar 2005:
  add SNTP support and expand time server and time offset fields of
  DHCP support. See doc/README.SNTP

* Patch by Steven Scholz, 13 Dec 2004:
  Fix bug in at91rm920 ethernet driver
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 47f9622..b6d436e 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -136,6 +136,19 @@
 #endif
 	if (NetOurNISDomain[0])
 		setenv ("domain", NetOurNISDomain);
+
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_TIMEOFFSET)
+	if (NetTimeOffset) {
+		sprintf (tmp, "%d", NetTimeOffset);
+		setenv ("timeoffset", tmp);
+	}
+#endif
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NTPSERVER)
+	if (NetNtpServerIP) {
+		ip_to_string (NetNtpServerIP, tmp);
+		setenv ("ntpserverip", tmp);
+	}
+#endif
 }
 
 static int
@@ -279,4 +292,42 @@
 );
 #endif	/* CFG_CMD_CDP */
 
+#if (CONFIG_COMMANDS & CFG_CMD_SNTP)
+int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	char *toff;
+
+	if (argc < 2) {
+		NetNtpServerIP = getenv_IPaddr ("ntpserverip");
+		if (NetNtpServerIP == 0) {
+			printf ("ntpserverip not set\n");
+			return (1);
+		}
+	} else {
+		NetNtpServerIP = string_to_ip(argv[1]);
+		if (NetNtpServerIP == 0) {
+			printf ("Bad NTP server IP address\n");
+			return (1);
+		}
+	}
+
+	toff = getenv ("timeoffset");
+	if (toff == NULL) NetTimeOffset = 0;
+	else NetTimeOffset = simple_strtol (toff, NULL, 10);
+
+	if (NetLoop(SNTP) < 0) {
+		printf("SNTP failed: host %s not responding\n", argv[1]);
+		return 1;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	sntp,	2,	1,	do_sntp,
+	"sntp\t- synchronize RTC via network\n",
+	"[NTP server IP]\n"
+);
+#endif	/* CFG_CMD_SNTP */
+
 #endif	/* CFG_CMD_NET */