* [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC
@ 2011-05-13 1:29 Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
2011-05-13 1:32 ` [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
0 siblings, 2 replies; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:29 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
---
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
diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
index 0104418..15922eb 100644
--- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
+++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
@@ -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))
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index e4be4a4..ec064d9 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -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
diff --git a/drivers/rtc/kirkwood.c b/drivers/rtc/kirkwood.c
new file mode 100644
index 0000000..5c9bc81
--- /dev/null
+++ b/drivers/rtc/kirkwood.c
@@ -0,0 +1,76 @@
+/*
+ * Driver for the RTC in Marvell SoCs.
+ *
+ * Based on Linux Kernel driver.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <rtc.h>
+#include <bcd.h>
+#include <asm/arch/kirkwood.h>
+
+#if defined(CONFIG_CMD_DATE)
+
+#define RTC_TIME_REG_OFFS 0
+#define RTC_SECONDS_OFFS 0
+#define RTC_MINUTES_OFFS 8
+#define RTC_HOURS_OFFS 16
+#define RTC_WDAY_OFFS 24
+#define RTC_HOURS_12H_MODE (1 << 22) /* 12 hours mode */
+
+#define RTC_DATE_REG_OFFS 4
+#define RTC_MDAY_OFFS 0
+#define RTC_MONTH_OFFS 8
+#define RTC_YEAR_OFFS 16
+#define KIRKWOOD_YEAR_BASE 2000
+
+int rtc_set(struct rtc_time *tmp)
+{
+ ulong rtc_reg;
+
+ GregorianDay (tmp);
+
+ rtc_reg = (bin2bcd(tmp->tm_sec) << RTC_SECONDS_OFFS) |
+ (bin2bcd(tmp->tm_min) << RTC_MINUTES_OFFS) |
+ (bin2bcd(tmp->tm_hour) << RTC_HOURS_OFFS) |
+ (bin2bcd(tmp->tm_wday) << RTC_WDAY_OFFS);
+ writel(rtc_reg, KW_RTC_TIME);
+
+ rtc_reg = (bin2bcd(tmp->tm_mday) << RTC_MDAY_OFFS) |
+ (bin2bcd(tmp->tm_mon + 1) << RTC_MONTH_OFFS) |
+ (bin2bcd(tmp->tm_year - KIRKWOOD_YEAR_BASE) << RTC_YEAR_OFFS);
+ writel(rtc_reg, KW_RTC_DATE);
+
+ return 0;
+}
+
+int rtc_get(struct rtc_time *tmp)
+{
+ ulong rtc_time, rtc_date;
+
+ rtc_time = readl(KW_RTC_TIME);
+ rtc_date = readl(KW_RTC_DATE);
+
+ tmp->tm_sec = bcd2bin(rtc_time & 0x7f);
+ tmp->tm_min = bcd2bin((rtc_time >> RTC_MINUTES_OFFS) & 0x7f);
+ tmp->tm_hour = bcd2bin((rtc_time >> RTC_HOURS_OFFS) & 0x3f); /* assume 24 hours mode */
+ tmp->tm_mday = bcd2bin(rtc_date & 0x3f);
+ tmp->tm_wday = bcd2bin((rtc_time >> RTC_WDAY_OFFS) & 0x7);
+ tmp->tm_mon = bcd2bin((rtc_date >> RTC_MONTH_OFFS) & 0x3f) - 1;
+ /* hw counts from year 2000, but tm_year is relative to 0 */
+ tmp->tm_year = bcd2bin((rtc_date >> RTC_YEAR_OFFS) & 0xff) + KIRKWOOD_YEAR_BASE;
+
+ return 0;
+}
+
+void rtc_reset(void)
+{
+ return;
+}
+
+#endif /* CONFIG_CMD_DATE */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable
2011-05-13 1:29 [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
@ 2011-05-13 1:29 ` Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request Chris Packham
2011-05-13 1:34 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
2011-05-13 1:32 ` [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
1 sibling, 2 replies; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:29 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
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.
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
common/cmd_net.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..e0d7d23 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -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;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request
2011-05-13 1:29 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
@ 2011-05-13 1:29 ` Chris Packham
2011-05-13 1:33 ` Chris Packham
2011-05-16 2:24 ` [U-Boot] [PATCHv2] " Chris Packham
2011-05-13 1:34 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
1 sibling, 2 replies; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:29 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
net/bootp.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/net/bootp.c b/net/bootp.c
index 4db63cb..53f37d0 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -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 */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC
2011-05-13 1:29 [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
@ 2011-05-13 1:32 ` Chris Packham
2011-05-17 4:25 ` [U-Boot] [PATCHv2] " Chris Packham
1 sibling, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:32 UTC (permalink / raw)
To: u-boot
On Fri, May 13, 2011 at 1:29 PM, Chris Packham <judge.packham@gmail.com> wrote:
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Cc: Prafulla Wadaskar <prafulla@marvell.com>
Sorry for the spam. I was just trying (and failing) to get git to add the Cc.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request
2011-05-13 1:29 ` [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request Chris Packham
@ 2011-05-13 1:33 ` Chris Packham
2011-05-16 2:24 ` [U-Boot] [PATCHv2] " Chris Packham
1 sibling, 0 replies; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:33 UTC (permalink / raw)
To: u-boot
On Fri, May 13, 2011 at 1:29 PM, Chris Packham <judge.packham@gmail.com> wrote:
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Cc: Ben Warren <biggerbadderben@gmail.com>
Sorry for the spam. I was just trying (and failing) to get git to add the Cc.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable
2011-05-13 1:29 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request Chris Packham
@ 2011-05-13 1:34 ` Chris Packham
2011-05-17 4:27 ` [U-Boot] [PATCHv2] " Chris Packham
1 sibling, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-13 1:34 UTC (permalink / raw)
To: u-boot
On Fri, May 13, 2011 at 1:29 PM, Chris Packham <judge.packham@gmail.com> wrote:
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> 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.
>
> Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> ---
Sorry for the spam. I was just trying (and failing) to get git to add the Cc.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] bootp: add ntpserver option to bootp request
2011-05-13 1:29 ` [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request Chris Packham
2011-05-13 1:33 ` Chris Packham
@ 2011-05-16 2:24 ` Chris Packham
2011-05-16 11:57 ` Sergei Shtylyov
1 sibling, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-16 2:24 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
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(-)
diff --git a/net/bootp.c b/net/bootp.c
index 4db63cb..18c743e 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -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 */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] bootp: add ntpserver option to bootp request
2011-05-16 2:24 ` [U-Boot] [PATCHv2] " Chris Packham
@ 2011-05-16 11:57 ` Sergei Shtylyov
2011-05-17 4:09 ` Chris Packham
0 siblings, 1 reply; 14+ messages in thread
From: Sergei Shtylyov @ 2011-05-16 11:57 UTC (permalink / raw)
To: u-boot
Hello.
On 16-05-2011 6:24, Chris Packham wrote:
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Signed-off-by: Luuk Paulussen<luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham<chris.packham@alliedtelesis.co.nz>
> Cc: Ben Warren<biggerbadderben@gmail.com>
[...]
> diff --git a/net/bootp.c b/net/bootp.c
> index 4db63cb..18c743e 100644
> --- a/net/bootp.c
> +++ b/net/bootp.c
> @@ -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).
> + 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...
> + *e++ = 4;
> + e += 4;
> +#endif
WBR, Sergei
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] bootp: add ntpserver option to bootp request
2011-05-16 11:57 ` Sergei Shtylyov
@ 2011-05-17 4:09 ` Chris Packham
2011-05-17 4:29 ` [U-Boot] [PATCHv3] " Chris Packham
0 siblings, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-17 4:09 UTC (permalink / raw)
To: u-boot
Hi Sergei,
On Mon, May 16, 2011 at 11:57 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> Hello.
>
> On 16-05-2011 6:24, Chris Packham wrote:
>
>> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
>> Signed-off-by: Luuk Paulussen<luuk.paulussen@alliedtelesis.co.nz>
>> Acked-by: Chris Packham<chris.packham@alliedtelesis.co.nz>
>> Cc: Ben Warren<biggerbadderben@gmail.com>
>
> [...]
>
>> diff --git a/net/bootp.c b/net/bootp.c
>> index 4db63cb..18c743e 100644
>> --- a/net/bootp.c
>> +++ b/net/bootp.c
>> @@ -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.
>> + ? ? ? ? ? ? ? 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...
Ditto.
>> + ? ? ? *e++ = 4;
>> + ? ? ? e ? += 4;
>> +#endif
>
> WBR, Sergei
>
v3 coming shortly
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] rtc: add driver for internal RTC on kirkwood SoC
2011-05-13 1:32 ` [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
@ 2011-05-17 4:25 ` Chris Packham
0 siblings, 0 replies; 14+ messages in thread
From: Chris Packham @ 2011-05-17 4:25 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
---
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
diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
index 0104418..15922eb 100644
--- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
+++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
@@ -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))
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index e4be4a4..ec064d9 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -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
diff --git a/drivers/rtc/kirkwood.c b/drivers/rtc/kirkwood.c
new file mode 100644
index 0000000..b08fd91
--- /dev/null
+++ b/drivers/rtc/kirkwood.c
@@ -0,0 +1,79 @@
+/*
+ * Driver for the RTC in Marvell SoCs.
+ *
+ * Based on Linux Kernel driver.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <rtc.h>
+#include <bcd.h>
+#include <asm/arch/kirkwood.h>
+
+#if defined(CONFIG_CMD_DATE)
+
+#define RTC_TIME_REG_OFFS 0
+#define RTC_SECONDS_OFFS 0
+#define RTC_MINUTES_OFFS 8
+#define RTC_HOURS_OFFS 16
+#define RTC_WDAY_OFFS 24
+#define RTC_HOURS_12H_MODE (1 << 22) /* 12 hours mode */
+
+#define RTC_DATE_REG_OFFS 4
+#define RTC_MDAY_OFFS 0
+#define RTC_MONTH_OFFS 8
+#define RTC_YEAR_OFFS 16
+#define KIRKWOOD_YEAR_BASE 2000
+
+int rtc_set(struct rtc_time *tmp)
+{
+ ulong rtc_reg;
+
+ GregorianDay(tmp);
+
+ rtc_reg = (bin2bcd(tmp->tm_sec) << RTC_SECONDS_OFFS) |
+ (bin2bcd(tmp->tm_min) << RTC_MINUTES_OFFS) |
+ (bin2bcd(tmp->tm_hour) << RTC_HOURS_OFFS) |
+ (bin2bcd(tmp->tm_wday) << RTC_WDAY_OFFS);
+ writel(rtc_reg, KW_RTC_TIME);
+
+ rtc_reg = (bin2bcd(tmp->tm_mday) << RTC_MDAY_OFFS) |
+ (bin2bcd(tmp->tm_mon + 1) << RTC_MONTH_OFFS) |
+ (bin2bcd(tmp->tm_year - KIRKWOOD_YEAR_BASE)
+ << RTC_YEAR_OFFS);
+ writel(rtc_reg, KW_RTC_DATE);
+
+ return 0;
+}
+
+int rtc_get(struct rtc_time *tmp)
+{
+ ulong rtc_time, rtc_date;
+
+ rtc_time = readl(KW_RTC_TIME);
+ rtc_date = readl(KW_RTC_DATE);
+
+ tmp->tm_sec = bcd2bin(rtc_time & 0x7f);
+ tmp->tm_min = bcd2bin((rtc_time >> RTC_MINUTES_OFFS) & 0x7f);
+ /* assume 24 hour mode */
+ tmp->tm_hour = bcd2bin((rtc_time >> RTC_HOURS_OFFS) & 0x3f);
+ tmp->tm_mday = bcd2bin(rtc_date & 0x3f);
+ tmp->tm_wday = bcd2bin((rtc_time >> RTC_WDAY_OFFS) & 0x7);
+ tmp->tm_mon = bcd2bin((rtc_date >> RTC_MONTH_OFFS) & 0x3f) - 1;
+ /* hw counts from year 2000, but tm_year is relative to 0 */
+ tmp->tm_year = bcd2bin((rtc_date >> RTC_YEAR_OFFS) & 0xff)
+ + KIRKWOOD_YEAR_BASE;
+
+ return 0;
+}
+
+void rtc_reset(void)
+{
+ return;
+}
+
+#endif /* CONFIG_CMD_DATE */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] sntp: avoid use of uninitialized variable
2011-05-13 1:34 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
@ 2011-05-17 4:27 ` Chris Packham
2011-05-17 8:32 ` Detlev Zundel
0 siblings, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-17 4:27 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
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.
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
Changes since v1:
- run through checkpatch.pl, fix line > 80 chars
common/cmd_net.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..fae3c7f 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -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;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv3] bootp: add ntpserver option to bootp request
2011-05-17 4:09 ` Chris Packham
@ 2011-05-17 4:29 ` Chris Packham
2011-07-27 21:20 ` Wolfgang Denk
0 siblings, 1 reply; 14+ messages in thread
From: Chris Packham @ 2011-05-17 4:29 UTC (permalink / raw)
To: u-boot
From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: Ben Warren <biggerbadderben@gmail.com>
---
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(-)
diff --git a/net/bootp.c b/net/bootp.c
index 4db63cb..45eaab1 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -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 */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv2] sntp: avoid use of uninitialized variable
2011-05-17 4:27 ` [U-Boot] [PATCHv2] " Chris Packham
@ 2011-05-17 8:32 ` Detlev Zundel
0 siblings, 0 replies; 14+ messages in thread
From: Detlev Zundel @ 2011-05-17 8:32 UTC (permalink / raw)
To: u-boot
Hi Chris,
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> 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.
>
> Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> ---
> Changes since v1:
> - run through checkpatch.pl, fix line > 80 chars
>
> common/cmd_net.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index 8c6f5c8..fae3c7f 100644
> --- a/common/cmd_net.c
> +++ b/common/cmd_net.c
> @@ -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;
> }
Acked-by: Detlev Zundel <dzu@denx.de>
Cheers
Detlev
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCHv3] bootp: add ntpserver option to bootp request
2011-05-17 4:29 ` [U-Boot] [PATCHv3] " Chris Packham
@ 2011-07-27 21:20 ` Wolfgang Denk
0 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Denk @ 2011-07-27 21:20 UTC (permalink / raw)
To: u-boot
Dear Chris Packham,
In message <1305606559-29993-1-git-send-email-judge.packham@gmail.com> you wrote:
> From: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
>
> Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> ---
> 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(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-07-27 21:20 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-13 1:29 [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
2011-05-13 1:29 ` [U-Boot] [PATCH 3/3] bootp: add ntpserver option to bootp request Chris Packham
2011-05-13 1:33 ` Chris Packham
2011-05-16 2:24 ` [U-Boot] [PATCHv2] " Chris Packham
2011-05-16 11:57 ` Sergei Shtylyov
2011-05-17 4:09 ` Chris Packham
2011-05-17 4:29 ` [U-Boot] [PATCHv3] " Chris Packham
2011-07-27 21:20 ` Wolfgang Denk
2011-05-13 1:34 ` [U-Boot] [PATCH 2/3] sntp: avoid use of uninitialized variable Chris Packham
2011-05-17 4:27 ` [U-Boot] [PATCHv2] " Chris Packham
2011-05-17 8:32 ` Detlev Zundel
2011-05-13 1:32 ` [U-Boot] [PATCH 1/3] rtc: add driver for internal RTC on kirkwood SoC Chris Packham
2011-05-17 4:25 ` [U-Boot] [PATCHv2] " Chris Packham
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.