[U-Boot] [PATCH 1/4] drivers/rtc/davinci.c: Reference DAVINCI_RTC_BASE more directly

We shouldn't rely on a define to hide this cast for us.
Signed-off-by: Tom Rini trini@ti.com --- drivers/rtc/davinci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/davinci.c b/drivers/rtc/davinci.c index e60c0da..018779e 100644 --- a/drivers/rtc/davinci.c +++ b/drivers/rtc/davinci.c @@ -13,7 +13,7 @@ #if defined(CONFIG_CMD_DATE) int rtc_get(struct rtc_time *tmp) { - struct davinci_rtc *rtc = davinci_rtc_base; + struct davinci_rtc *rtc = (struct davinci_rtc *)DAVINCI_RTC_BASE; unsigned long sec, min, hour, mday, wday, mon_cent, year; unsigned long status;
@@ -57,7 +57,7 @@ int rtc_get(struct rtc_time *tmp)
int rtc_set(struct rtc_time *tmp) { - struct davinci_rtc *rtc = davinci_rtc_base; + struct davinci_rtc *rtc = (struct davinci_rtc *)DAVINCI_RTC_BASE;
debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, @@ -75,7 +75,7 @@ int rtc_set(struct rtc_time *tmp)
void rtc_reset(void) { - struct davinci_rtc *rtc = davinci_rtc_base; + struct davinci_rtc *rtc = (struct davinci_rtc *)DAVINCI_RTC_BASE;
/* run RTC counter */ writel(0x01, &rtc->ctrl);

Create a common header file for the RTC IP block that is shared between davinci and am33xx.
Signed-off-by: Tom Rini trini@ti.com --- arch/arm/cpu/armv7/am33xx/board.c | 7 ++-- arch/arm/include/asm/arch-am33xx/cpu.h | 9 ----- arch/arm/include/asm/arch-davinci/hardware.h | 38 ------------------- arch/arm/include/asm/davinci_rtc.h | 52 ++++++++++++++++++++++++++ board/enbw/enbw_cmc/enbw_cmc.c | 1 + drivers/bootcount/bootcount_davinci.c | 3 +- drivers/rtc/davinci.c | 2 +- 7 files changed, 59 insertions(+), 53 deletions(-) create mode 100644 arch/arm/include/asm/davinci_rtc.h
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 2ea3d69..8141fce 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -31,6 +31,7 @@ #include <linux/usb/gadget.h> #include <linux/usb/musb.h> #include <asm/omap_musb.h> +#include <asm/davinci_rtc.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -139,15 +140,15 @@ int arch_misc_init(void) #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT) static void rtc32k_enable(void) { - struct rtc_regs *rtc = (struct rtc_regs *)RTC_BASE; + struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
/* * Unlock the RTC's registers. For more details please see the * RTC_SS section of the TRM. In order to unlock we need to * write these specific values (keys) in this order. */ - writel(0x83e70b13, &rtc->kick0r); - writel(0x95a4f1e0, &rtc->kick1r); + writel(RTC_KICK0R_WE, &rtc->kick0r); + writel(RTC_KICK1R_WE, &rtc->kick1r);
/* Enable the RTC 32K OSC by setting bits 3 and 6. */ writel((1 << 3) | (1 << 6), &rtc->osc); diff --git a/arch/arm/include/asm/arch-am33xx/cpu.h b/arch/arm/include/asm/arch-am33xx/cpu.h index 10b56e0..8626821 100644 --- a/arch/arm/include/asm/arch-am33xx/cpu.h +++ b/arch/arm/include/asm/arch-am33xx/cpu.h @@ -423,15 +423,6 @@ struct gptimer { unsigned int tcar2; /* offset 0x58 */ };
-/* RTC Registers */ -struct rtc_regs { - unsigned int res[21]; - unsigned int osc; /* offset 0x54 */ - unsigned int res2[5]; - unsigned int kick0r; /* offset 0x6c */ - unsigned int kick1r; /* offset 0x70 */ -}; - /* UART Registers */ struct uart_sys { unsigned int resv1[21]; diff --git a/arch/arm/include/asm/arch-davinci/hardware.h b/arch/arm/include/asm/arch-davinci/hardware.h index 05ecc78..7aaf4bf 100644 --- a/arch/arm/include/asm/arch-davinci/hardware.h +++ b/arch/arm/include/asm/arch-davinci/hardware.h @@ -613,42 +613,4 @@ static inline enum davinci_clk_ids get_async3_src(void)
#endif
-struct davinci_rtc { - dv_reg second; - dv_reg minutes; - dv_reg hours; - dv_reg day; - dv_reg month; /* 0x10 */ - dv_reg year; - dv_reg dotw; - dv_reg resv1; - dv_reg alarmsecond; /* 0x20 */ - dv_reg alarmminute; - dv_reg alarmhour; - dv_reg alarmday; - dv_reg alarmmonth; /* 0x30 */ - dv_reg alarmyear; - dv_reg resv2[2]; - dv_reg ctrl; /* 0x40 */ - dv_reg status; - dv_reg irq; - dv_reg complsb; - dv_reg compmsb; /* 0x50 */ - dv_reg osc; - dv_reg resv3[2]; - dv_reg scratch0; /* 0x60 */ - dv_reg scratch1; - dv_reg scratch2; - dv_reg kick0r; - dv_reg kick1r; /* 0x70 */ -}; - -#define RTC_STATE_BUSY 0x01 -#define RTC_STATE_RUN 0x02 - -#define RTC_KICK0R_WE 0x83e70b13 -#define RTC_KICK1R_WE 0x95a4f1e0 - -#define davinci_rtc_base ((struct davinci_rtc *)DAVINCI_RTC_BASE) - #endif /* __ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/include/asm/davinci_rtc.h b/arch/arm/include/asm/davinci_rtc.h new file mode 100644 index 0000000..575b590 --- /dev/null +++ b/arch/arm/include/asm/davinci_rtc.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007 Sergey Kubushyn ksi@koi8.net + * + * Based on: + * + * ------------------------------------------------------------------------- + * + * linux/include/asm-arm/arch-davinci/hardware.h + * + * Copyright (C) 2006 Texas Instruments. + * + * SPDX-License-Identifier: GPL-2.0 + */ +#ifndef __ASM_DAVINCI_RTC_H +#define __ASM_DAVINCI_RTC_H + +struct davinci_rtc { + unsigned int second; + unsigned int minutes; + unsigned int hours; + unsigned int day; + unsigned int month; /* 0x10 */ + unsigned int year; + unsigned int dotw; + unsigned int resv1; + unsigned int alarmsecond; /* 0x20 */ + unsigned int alarmminute; + unsigned int alarmhour; + unsigned int alarmday; + unsigned int alarmmonth; /* 0x30 */ + unsigned int alarmyear; + unsigned int resv2[2]; + unsigned int ctrl; /* 0x40 */ + unsigned int status; + unsigned int irq; + unsigned int complsb; + unsigned int compmsb; /* 0x50 */ + unsigned int osc; + unsigned int resv3[2]; + unsigned int scratch0; /* 0x60 */ + unsigned int scratch1; + unsigned int scratch2; + unsigned int kick0r; + unsigned int kick1r; /* 0x70 */ +}; + +#define RTC_STATE_BUSY 0x01 +#define RTC_STATE_RUN 0x02 + +#define RTC_KICK0R_WE 0x83e70b13 +#define RTC_KICK1R_WE 0x95a4f1e0 +#endif diff --git a/board/enbw/enbw_cmc/enbw_cmc.c b/board/enbw/enbw_cmc/enbw_cmc.c index c477962..39efe20 100644 --- a/board/enbw/enbw_cmc/enbw_cmc.c +++ b/board/enbw/enbw_cmc/enbw_cmc.c @@ -36,6 +36,7 @@ #include <asm/arch/hardware.h> #include <asm/arch/sdmmc_defs.h> #include <asm/arch/timer_defs.h> +#include <asm/davinci_rtc.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/bootcount/bootcount_davinci.c b/drivers/bootcount/bootcount_davinci.c index efa4d42..eddd940 100644 --- a/drivers/bootcount/bootcount_davinci.c +++ b/drivers/bootcount/bootcount_davinci.c @@ -6,8 +6,7 @@ */
#include <bootcount.h> -#include <asm/arch/da850_lowlevel.h> -#include <asm/arch/davinci_misc.h> +#include <asm/davinci_rtc.h>
void bootcount_store(ulong a) { diff --git a/drivers/rtc/davinci.c b/drivers/rtc/davinci.c index 018779e..f862e2f 100644 --- a/drivers/rtc/davinci.c +++ b/drivers/rtc/davinci.c @@ -8,7 +8,7 @@ #include <command.h> #include <rtc.h> #include <asm/io.h> -#include <asm/arch/hardware.h> +#include <asm/davinci_rtc.h>
#if defined(CONFIG_CMD_DATE) int rtc_get(struct rtc_time *tmp)

On Wed, Aug 28, 2013 at 09:00:28AM -0400, Tom Rini wrote:
Create a common header file for the RTC IP block that is shared between davinci and am33xx.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master.

The RTC IP block here provides 3 scratch registers. Currently when using DeepSleep on am335x the scratch0/1 registers are used so moving ourself to scratch2 makes cooperation easier.
Signed-off-by: Tom Rini trini@ti.com --- drivers/bootcount/bootcount_davinci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/bootcount/bootcount_davinci.c b/drivers/bootcount/bootcount_davinci.c index eddd940..f0acfad 100644 --- a/drivers/bootcount/bootcount_davinci.c +++ b/drivers/bootcount/bootcount_davinci.c @@ -20,17 +20,19 @@ void bootcount_store(ulong a) */ writel(RTC_KICK0R_WE, ®->kick0r); writel(RTC_KICK1R_WE, ®->kick1r); - raw_bootcount_store(®->scratch0, a); - raw_bootcount_store(®->scratch1, BOOTCOUNT_MAGIC); + raw_bootcount_store(®->scratch2, + (BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff)); }
ulong bootcount_load(void) { + unsigned long val; struct davinci_rtc *reg = (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
- if (raw_bootcount_load(®->scratch1) != BOOTCOUNT_MAGIC) + val = raw_bootcount_load(®->scratch2); + if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000)) return 0; else - return raw_bootcount_load(®->scratch0); + return val & 0x0000ffff; }

On Wed, Aug 28, 2013 at 09:00:29AM -0400, Tom Rini wrote:
The RTC IP block here provides 3 scratch registers. Currently when using DeepSleep on am335x the scratch0/1 registers are used so moving ourself to scratch2 makes cooperation easier.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master.

Enable the bootcount driver for am335x in general. We leave adding a bootlimit and altbootcmd to the environment to the board ports.
Signed-off-by: Tom Rini trini@ti.com --- drivers/bootcount/Makefile | 1 + include/configs/ti_am335x_common.h | 7 +++++++ 2 files changed, 8 insertions(+)
diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile index 2b517b6..352a0a1 100644 --- a/drivers/bootcount/Makefile +++ b/drivers/bootcount/Makefile @@ -10,6 +10,7 @@ COBJS-y += bootcount.o COBJS-$(CONFIG_AT91SAM9XE) += bootcount_at91.o COBJS-$(CONFIG_BLACKFIN) += bootcount_blackfin.o COBJS-$(CONFIG_SOC_DA8XX) += bootcount_davinci.o +COBJS-$(CONFIG_AM33XX) += bootcount_davinci.o COBJS-$(CONFIG_BOOTCOUNT_RAM) += bootcount_ram.o
COBJS := $(COBJS-y) diff --git a/include/configs/ti_am335x_common.h b/include/configs/ti_am335x_common.h index fd3ffab..066618e 100644 --- a/include/configs/ti_am335x_common.h +++ b/include/configs/ti_am335x_common.h @@ -41,6 +41,13 @@ #define CONFIG_BOOTP_SUBNETMASK #define CONFIG_NET_RETRY_COUNT 10
+/* + * RTC related defines. To use bootcount you must set bootlimit in the + * environment to a non-zero value. + */ +#define CONFIG_BOOTCOUNT_LIMIT +#define CONFIG_SYS_BOOTCOUNT_ADDR 0x44E3E000 + /* SPL defines. */ #define CONFIG_SPL_TEXT_BASE 0x402F0400 #define CONFIG_SPL_MAX_SIZE (0x4030C000 - CONFIG_SPL_TEXT_BASE)

On Wed, Aug 28, 2013 at 09:00:30AM -0400, Tom Rini wrote:
Enable the bootcount driver for am335x in general. We leave adding a bootlimit and altbootcmd to the environment to the board ports.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master.

On Wed, Aug 28, 2013 at 09:00:27AM -0400, Tom Rini wrote:
We shouldn't rely on a define to hide this cast for us.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master.
participants (1)
-
Tom Rini