summaryrefslogtreecommitdiff
path: root/packages/uboot/u-boot-mkimage-gta01-native/unbusy-i2c.patch
blob: 680b301620ac76f3e95b54a628595f422f9bd4fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
board/neo1973/gta01/gta01.c: added logic to detect pending PMU interrupts
board/neo1973/gta01/gta01.c (neo1973_new_second, neo1973_on_key_pressed): only
  poll PMU if there is a pending interrupt
board/neo1973/gta01/pcf50606.c (pcf50606_initial_regs): cleared (unmasked)
  SECONDM in INT1M

- Werner Almesberger <werner@openmoko.org>

Index: u-boot/board/neo1973/gta01/gta01.c
===================================================================
--- u-boot.orig/board/neo1973/gta01/gta01.c
+++ u-boot/board/neo1973/gta01/gta01.c
@@ -375,19 +375,60 @@
 #endif
 }
 
+static int pwr_int_pending(void)
+{
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+#if defined(CONFIG_ARCH_GTA01B_v4)
+	return !(gpio->GPGDAT & (1 << 1));	/* EINT9/GPG1 */
+#else
+	return !(gpio->GPGDAT & (1 << 8));	/* EINT16/GPG8 */
+#endif /* !CONFIG_ARCH_GTA01B_v4 */
+}
+
+static int have_int1(uint8_t mask)
+{
+	static uint8_t pending = 0;
+
+	if (pwr_int_pending()) {
+		/*
+		 * We retrieve all interupts, so that we clear any stray ones
+		 * in INT2 and INT3.
+		 */
+		uint8_t int1,int2,int3;
+
+		int1 = pcf50606_reg_read(PCF50606_REG_INT1);
+		int2 = pcf50606_reg_read(PCF50606_REG_INT2);
+		int3 = pcf50606_reg_read(PCF50606_REG_INT3);
+		pending |= int1;
+	}
+	if (!(pending & mask))
+		return 0;
+	pending &= ~mask;
+	return 1;
+}
+
 int neo1973_new_second(void)
 {
-	return pcf50606_reg_read(PCF50606_REG_INT1) & PCF50606_INT1_SECOND;
+	return have_int1(PCF50606_INT1_SECOND);
 }
 
 int neo1973_on_key_pressed(void)
 {
-	return !(pcf50606_reg_read(PCF50606_REG_OOCS) & PFC50606_OOCS_ONKEY);
+	static int pressed = -1;
+
+	if (pressed == -1 ||
+	    have_int1(PCF50606_INT1_ONKEYF | PCF50606_INT1_ONKEYR)) {
+		pressed = !(pcf50606_reg_read(PCF50606_REG_OOCS) &
+		     PFC50606_OOCS_ONKEY);
+}
+	return pressed;
 }
 
 int neo1973_aux_key_pressed(void)
 {
 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
 	if (gpio->GPFDAT & (1 << 6))
 		return 0;
 	return 1;
Index: u-boot/board/neo1973/gta01/pcf50606.c
===================================================================
--- u-boot.orig/board/neo1973/gta01/pcf50606.c
+++ u-boot/board/neo1973/gta01/pcf50606.c
@@ -6,7 +6,7 @@
 const u_int8_t pcf50606_initial_regs[__NUM_PCF50606_REGS] = {
 	[PCF50606_REG_OOCS] 	= 0x00,
 	/* gap */
-	[PCF50606_REG_INT1M]	= PCF50606_INT1_SECOND,
+	[PCF50606_REG_INT1M]	= 0x00,
 	[PCF50606_REG_INT2M]	= 0x00,
 	[PCF50606_REG_INT3M]	= PCF50606_INT3_TSCPRES,
 	[PCF50606_REG_OOCC1] 	= PCF50606_OOCC1_RTCWAK |