Skip to contentSkip to conversation

drivers/rtc/davinci.c: Reference DAVINCI_RTC_BASE more directly

PATCH New Tom Rini 1 participant 8 messages Aug 28, 2013 – Nov 4, 2013

Subsystems (2)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

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.

---
 drivers/rtc/davinci.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/davinci.c +3 -3
index e60c0da..018779e 100644
@@ -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);
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/4 drivers/rtc/davinci.c: Reference DAVINCI_RTC_BASE more directly

Quoted 3 lines · Tom Rini

We shouldn't rely on a define to hide this cast for us.

Applied to u-boot-ti/master.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131104/89604b3e/attachment.pgp>
author
#2 lore raw

PATCH 2/4 am33xx, davinci: Create and use <asm/davinci_rtc.h>

In reply to Tom Rini

Create a common header file for the RTC IP block that is shared between davinci and am33xx.

---
 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
arch/arm/cpu/armv7/am33xx/board.c +4 -3
index 2ea3d69..8141fce 100644
@@ -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);
arch/arm/include/asm/arch-am33xx/cpu.h +0 -9
index 10b56e0..8626821 100644
@@ -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];
arch/arm/include/asm/arch-davinci/hardware.h +0 -38
index 05ecc78..7aaf4bf 100644
@@ -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 */
arch/arm/include/asm/davinci_rtc.h new file +52 -0

52 lines not on this page · raw message

board/enbw/enbw_cmc/enbw_cmc.c +1 -0
index c477962..39efe20 100644
@@ -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;
 
drivers/bootcount/bootcount_davinci.c +1 -2
index efa4d42..eddd940 100644
@@ -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)
 {
drivers/rtc/davinci.c +1 -1
index 018779e..f862e2f 100644
@@ -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)
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 2/4 am33xx, davinci: Create and use <asm/davinci_rtc.h>

Quoted 4 lines · Tom Rini

Create a common header file for the RTC IP block that is shared between davinci and am33xx.

Applied to u-boot-ti/master.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131104/d6c81680/attachment.pgp>
author
#4 lore raw

PATCH 3/4 bootcount_davinci: Switch to scratch register #2

In reply to Tom Rini

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.

---
 drivers/bootcount/bootcount_davinci.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/bootcount/bootcount_davinci.c +6 -4
index eddd940..f0acfad 100644
@@ -20,17 +20,19 @@ void bootcount_store(ulong a)
 	 */
 	writel(RTC_KICK0R_WE, &reg->kick0r);
 	writel(RTC_KICK1R_WE, &reg->kick1r);
-	raw_bootcount_store(&reg->scratch0, a);
-	raw_bootcount_store(&reg->scratch1, BOOTCOUNT_MAGIC);
+	raw_bootcount_store(&reg->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(&reg->scratch1) != BOOTCOUNT_MAGIC)
+	val = raw_bootcount_load(&reg->scratch2);
+	if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
 		return 0;
 	else
-		return raw_bootcount_load(&reg->scratch0);
+		return val & 0x0000ffff;
 }
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 3/4 bootcount_davinci: Switch to scratch register #2

Quoted 5 lines · Tom Rini

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.

Applied to u-boot-ti/master.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131104/1984b234/attachment.pgp>
author
#6 lore raw

PATCH 4/4 TI:am33xx: Add bootcount support to ti_am335x_common.h

In reply to Tom Rini

Enable the bootcount driver for am335x in general. We leave adding a bootlimit and altbootcmd to the environment to the board ports.

---
 drivers/bootcount/Makefile         |    1 +
 include/configs/ti_am335x_common.h |    7 +++++++
 2 files changed, 8 insertions(+)
drivers/bootcount/Makefile +1 -0
index 2b517b6..352a0a1 100644
@@ -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)
include/configs/ti_am335x_common.h +7 -0
index fd3ffab..066618e 100644
@@ -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)
Signature · 1 line
1.7.9.5
author
#7 lore raw

PATCH 4/4 TI:am33xx: Add bootcount support to ti_am335x_common.h

Quoted 4 lines · Tom Rini

Enable the bootcount driver for am335x in general. We leave adding a bootlimit and altbootcmd to the environment to the board ports.

Applied to u-boot-ti/master.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131104/2a7414a7/attachment.pgp>