Root/target/linux/xburst/patches-3.2/0014-MIPS-JZ4740-reset-Initialize-hibernate-wakeup-counte.patch

1From 2dcb0ca66d0bffc23d5f001fad81fb1a7a2c371b Mon Sep 17 00:00:00 2001
2From: Maarten ter Huurne <maarten@treewalker.org>
3Date: Tue, 28 Jun 2011 22:28:59 +0200
4Subject: [PATCH 14/28] MIPS: JZ4740: reset: Initialize hibernate wakeup
5 counters.
6
7In hibernation mode only the wakeup logic and the RTC are left running,
8so this is what users perceive as power down.
9
10If the counters are not initialized, the corresponding pin (typically
11connected to the power button) has to be asserted for two seconds
12before the device wakes up. Most users expect a shorter wakeup time.
13
14I took the timing values of 100 ms and 60 ms from BouKiCHi's patch for
15the Dingoo A320 kernel.
16---
17 arch/mips/jz4740/reset.c | 46 ++++++++++++++++++++++++++++++++++++++++------
18 1 files changed, 40 insertions(+), 6 deletions(-)
19
20diff --git a/arch/mips/jz4740/reset.c b/arch/mips/jz4740/reset.c
21index 5f1fb95..e6d1d7b 100644
22--- a/arch/mips/jz4740/reset.c
23+++ b/arch/mips/jz4740/reset.c
24@@ -21,6 +21,9 @@
25 #include <asm/mach-jz4740/base.h>
26 #include <asm/mach-jz4740/timer.h>
27 
28+#include "reset.h"
29+#include "clock.h"
30+
31 static void jz4740_halt(void)
32 {
33     while (1) {
34@@ -53,21 +56,52 @@ static void jz4740_restart(char *command)
35     jz4740_halt();
36 }
37 
38-#define JZ_REG_RTC_CTRL 0x00
39-#define JZ_REG_RTC_HIBERNATE 0x20
40+#define JZ_REG_RTC_CTRL 0x00
41+#define JZ_REG_RTC_HIBERNATE 0x20
42+#define JZ_REG_RTC_WAKEUP_FILTER 0x24
43+#define JZ_REG_RTC_RESET_COUNTER 0x28
44 
45-#define JZ_RTC_CTRL_WRDY BIT(7)
46+#define JZ_RTC_CTRL_WRDY BIT(7)
47+#define JZ_RTC_WAKEUP_FILTER_MASK 0x0000FFE0
48+#define JZ_RTC_RESET_COUNTER_MASK 0x00000FE0
49 
50-static void jz4740_power_off(void)
51+static inline void jz4740_rtc_wait_ready(void __iomem *rtc_base)
52 {
53- void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x24);
54     uint32_t ctrl;
55-
56     do {
57         ctrl = readl(rtc_base + JZ_REG_RTC_CTRL);
58     } while (!(ctrl & JZ_RTC_CTRL_WRDY));
59+}
60 
61+static void jz4740_power_off(void)
62+{
63+ void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x38);
64+ unsigned long long wakeup_filter_ticks;
65+ unsigned long long reset_counter_ticks;
66+
67+ /* Set minimum wakeup pin assertion time: 100 ms.
68+ Range is 0 to 2 sec if RTC is clocked at 32 kHz. */
69+ wakeup_filter_ticks = (100 * jz4740_clock_bdata.rtc_rate) / 1000;
70+ if (wakeup_filter_ticks < JZ_RTC_WAKEUP_FILTER_MASK)
71+ wakeup_filter_ticks &= JZ_RTC_WAKEUP_FILTER_MASK;
72+ else
73+ wakeup_filter_ticks = JZ_RTC_WAKEUP_FILTER_MASK;
74+ jz4740_rtc_wait_ready(rtc_base);
75+ writel(wakeup_filter_ticks, rtc_base + JZ_REG_RTC_WAKEUP_FILTER);
76+
77+ /* Set reset pin low-level assertion time after wakeup: 60 ms.
78+ Range is 0 to 125 ms if RTC is clocked at 32 kHz. */
79+ reset_counter_ticks = (60 * jz4740_clock_bdata.rtc_rate) / 1000;
80+ if (reset_counter_ticks < JZ_RTC_RESET_COUNTER_MASK)
81+ reset_counter_ticks &= JZ_RTC_RESET_COUNTER_MASK;
82+ else
83+ reset_counter_ticks = JZ_RTC_RESET_COUNTER_MASK;
84+ jz4740_rtc_wait_ready(rtc_base);
85+ writel(reset_counter_ticks, rtc_base + JZ_REG_RTC_RESET_COUNTER);
86+
87+ jz4740_rtc_wait_ready(rtc_base);
88     writel(1, rtc_base + JZ_REG_RTC_HIBERNATE);
89+
90     jz4740_halt();
91 }
92 
93--
941.7.5.4
95
96

Archive Download this file



interactive