summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-11-04 13:22:17 +0000
committerJens Arnold <amiconn@rockbox.org>2007-11-04 13:22:17 +0000
commit6fb4c53fb9acdd4c854662736bc03db3995774be (patch)
treed97acc5bca7e46f67885a0f6ea3c5c18ecb9d1be
parent04d0e3bc41e7b46230e32b1f1fa0e6aaca64464e (diff)
downloadrockbox-6fb4c53fb9acdd4c854662736bc03db3995774be.tar.gz
rockbox-6fb4c53fb9acdd4c854662736bc03db3995774be.zip
The GPIO interrupts are split into several port groups on all PP502x versions, so move those definitions into pp5020.h, and add the missing group. Make microSD hotswap detection work on Sansa c200. Note that microSD access itself does not work yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15460 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/pp5020.h8
-rw-r--r--firmware/export/pp5024.h10
-rw-r--r--firmware/target/arm/ipod/button-mini1g.c6
-rw-r--r--firmware/target/arm/sandisk/ata-c200_e200.c35
-rw-r--r--firmware/target/arm/system-pp502x.c9
5 files changed, 49 insertions, 19 deletions
diff --git a/firmware/export/pp5020.h b/firmware/export/pp5020.h
index 89acb2e8d2..22a53e7ad7 100644
--- a/firmware/export/pp5020.h
+++ b/firmware/export/pp5020.h
@@ -96,7 +96,9 @@
96#define USB_IRQ 24 96#define USB_IRQ 24
97#define FIREWIRE_IRQ 25 97#define FIREWIRE_IRQ 25
98#define HI_IRQ 30 98#define HI_IRQ 30
99#define GPIO_IRQ (32+0) 99#define GPIO0_IRQ (32+0) /* Ports A..D */
100#define GPIO1_IRQ (32+1) /* Ports E..H */
101#define GPIO2_IRQ (32+2) /* Ports I..L */
100#define SER0_IRQ (32+4) 102#define SER0_IRQ (32+4)
101#define SER1_IRQ (32+5) 103#define SER1_IRQ (32+5)
102#define I2C_IRQ (32+8) 104#define I2C_IRQ (32+8)
@@ -109,7 +111,9 @@
109#define USB_MASK (1 << USB_IRQ) 111#define USB_MASK (1 << USB_IRQ)
110#define FIREWIRE_MASK (1 << FIREWIRE_IRQ) 112#define FIREWIRE_MASK (1 << FIREWIRE_IRQ)
111#define HI_MASK (1 << HI_IRQ) 113#define HI_MASK (1 << HI_IRQ)
112#define GPIO_MASK (1 << (GPIO_IRQ-32)) 114#define GPIO0_MASK (1 << (GPIO0_IRQ-32))
115#define GPIO1_MASK (1 << (GPIO1_IRQ-32))
116#define GPIO2_MASK (1 << (GPIO2_IRQ-32))
113#define SER0_MASK (1 << (SER0_IRQ-32)) 117#define SER0_MASK (1 << (SER0_IRQ-32))
114#define SER1_MASK (1 << (SER1_IRQ-32)) 118#define SER1_MASK (1 << (SER1_IRQ-32))
115#define I2C_MASK (1 << (I2C_IRQ-32)) 119#define I2C_MASK (1 << (I2C_IRQ-32))
diff --git a/firmware/export/pp5024.h b/firmware/export/pp5024.h
index 5e2de17741..900032132e 100644
--- a/firmware/export/pp5024.h
+++ b/firmware/export/pp5024.h
@@ -23,14 +23,4 @@
23 completely and redifine any minor differences */ 23 completely and redifine any minor differences */
24#include "pp5020.h" 24#include "pp5020.h"
25 25
26#undef GPIO_IRQ
27/* Ports A, B, ?? */
28#define GPIO0_IRQ (32+0)
29/* Ports F, H, ?? */
30#define GPIO1_IRQ (32+1)
31
32#undef GPIO_MASK
33#define GPIO0_MASK (1 << (GPIO0_IRQ-32))
34#define GPIO1_MASK (1 << (GPIO1_IRQ-32))
35
36#endif 26#endif
diff --git a/firmware/target/arm/ipod/button-mini1g.c b/firmware/target/arm/ipod/button-mini1g.c
index 242f06c071..f02e6acaac 100644
--- a/firmware/target/arm/ipod/button-mini1g.c
+++ b/firmware/target/arm/ipod/button-mini1g.c
@@ -164,10 +164,10 @@ static int ipod_mini_button_read(void)
164 164
165void ipod_mini_button_int(void) 165void ipod_mini_button_int(void)
166{ 166{
167 CPU_HI_INT_CLR = GPIO_MASK; 167 CPU_HI_INT_CLR = GPIO0_MASK;
168 int_btn = ipod_mini_button_read(); 168 int_btn = ipod_mini_button_read();
169 //CPU_INT_EN = 0x40000000; 169 //CPU_INT_EN = 0x40000000;
170 CPU_HI_INT_EN = GPIO_MASK; 170 CPU_HI_INT_EN = GPIO0_MASK;
171} 171}
172 172
173void button_init_device(void) 173void button_init_device(void)
@@ -190,7 +190,7 @@ void button_init_device(void)
190 GPIOB_INT_EN = 0x30; 190 GPIOB_INT_EN = 0x30;
191 /* unmask interrupt */ 191 /* unmask interrupt */
192 CPU_INT_EN = 0x40000000; 192 CPU_INT_EN = 0x40000000;
193 CPU_HI_INT_EN = GPIO_MASK; 193 CPU_HI_INT_EN = GPIO0_MASK;
194} 194}
195 195
196/* 196/*
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c
index 8e17152e6f..a8e1651280 100644
--- a/firmware/target/arm/sandisk/ata-c200_e200.c
+++ b/firmware/target/arm/sandisk/ata-c200_e200.c
@@ -1171,10 +1171,17 @@ int ata_init(void)
1171 1171
1172#ifdef HAVE_HOTSWAP 1172#ifdef HAVE_HOTSWAP
1173 /* enable card detection port - mask interrupt first */ 1173 /* enable card detection port - mask interrupt first */
1174#ifdef SANSA_E200
1174 GPIOA_INT_EN &= ~0x80; 1175 GPIOA_INT_EN &= ~0x80;
1175 1176
1176 GPIOA_OUTPUT_EN &= ~0x80; 1177 GPIOA_OUTPUT_EN &= ~0x80;
1177 GPIOA_ENABLE |= 0x80; 1178 GPIOA_ENABLE |= 0x80;
1179#elif defined SANSA_C200
1180 GPIOL_INT_EN &= ~0x08;
1181
1182 GPIOL_OUTPUT_EN &= ~0x08;
1183 GPIOL_ENABLE |= 0x08;
1184#endif
1178#endif 1185#endif
1179 sd_select_device(0); 1186 sd_select_device(0);
1180 1187
@@ -1188,6 +1195,7 @@ int ata_init(void)
1188 /* enable interupt for the mSD card */ 1195 /* enable interupt for the mSD card */
1189 sleep(HZ/10); 1196 sleep(HZ/10);
1190#ifdef HAVE_HOTSWAP 1197#ifdef HAVE_HOTSWAP
1198#ifdef SANSA_E200
1191 CPU_INT_EN = HI_MASK; 1199 CPU_INT_EN = HI_MASK;
1192 CPU_HI_INT_EN = GPIO0_MASK; 1200 CPU_HI_INT_EN = GPIO0_MASK;
1193 1201
@@ -1195,6 +1203,15 @@ int ata_init(void)
1195 1203
1196 GPIOA_INT_CLR = 0x80; 1204 GPIOA_INT_CLR = 0x80;
1197 GPIOA_INT_EN |= 0x80; 1205 GPIOA_INT_EN |= 0x80;
1206#elif defined SANSA_C200
1207 CPU_INT_EN = HI_MASK;
1208 CPU_HI_INT_EN = GPIO2_MASK;
1209
1210 GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (~GPIOL_INPUT_VAL & 0x08);
1211
1212 GPIOL_INT_CLR = 0x08;
1213 GPIOL_INT_EN |= 0x08;
1214#endif
1198#endif 1215#endif
1199 spinlock_unlock(&sd_spin); 1216 spinlock_unlock(&sd_spin);
1200 } 1217 }
@@ -1239,8 +1256,11 @@ tCardInfo *card_get_info_target(int card_no)
1239#ifdef HAVE_HOTSWAP 1256#ifdef HAVE_HOTSWAP
1240bool card_detect_target(void) 1257bool card_detect_target(void)
1241{ 1258{
1242 /* 0x00:inserted, 0x80:not inserted */ 1259#ifdef SANSA_E200
1243 return (GPIOA_INPUT_VAL & 0x80) == 0; 1260 return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */
1261#elif defined SANSA_C200
1262 return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */
1263#endif
1244} 1264}
1245 1265
1246static bool sd1_oneshot_callback(struct timeout *tmo) 1266static bool sd1_oneshot_callback(struct timeout *tmo)
@@ -1256,6 +1276,7 @@ void microsd_int(void)
1256{ 1276{
1257 static struct timeout sd1_oneshot; 1277 static struct timeout sd1_oneshot;
1258 1278
1279#ifdef SANSA_E200
1259 int detect = GPIOA_INPUT_VAL & 0x80; 1280 int detect = GPIOA_INPUT_VAL & 0x80;
1260 1281
1261 GPIOA_INT_LEV = (GPIOA_INT_LEV & ~0x80) | (detect ^ 0x80); 1282 GPIOA_INT_LEV = (GPIOA_INT_LEV & ~0x80) | (detect ^ 0x80);
@@ -1263,5 +1284,15 @@ void microsd_int(void)
1263 1284
1264 timeout_register(&sd1_oneshot, sd1_oneshot_callback, 1285 timeout_register(&sd1_oneshot, sd1_oneshot_callback,
1265 detect ? 1 : HZ/2, detect == 0); 1286 detect ? 1 : HZ/2, detect == 0);
1287#elif defined SANSA_C200
1288 int detect = GPIOL_INPUT_VAL & 0x08;
1289
1290 GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (detect ^ 0x08);
1291 GPIOL_INT_CLR = 0x08;
1292
1293 timeout_register(&sd1_oneshot, sd1_oneshot_callback,
1294 detect ? HZ/2 : 1, detect != 0);
1295#endif
1296
1266} 1297}
1267#endif /* HAVE_HOTSWAP */ 1298#endif /* HAVE_HOTSWAP */
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c
index 8d253a70db..0f24997451 100644
--- a/firmware/target/arm/system-pp502x.c
+++ b/firmware/target/arm/system-pp502x.c
@@ -27,10 +27,10 @@ extern void TIMER1(void);
27extern void TIMER2(void); 27extern void TIMER2(void);
28extern void ipod_mini_button_int(void); /* iPod Mini 1st gen only */ 28extern void ipod_mini_button_int(void); /* iPod Mini 1st gen only */
29extern void ipod_4g_button_int(void); /* iPod 4th gen and higher only */ 29extern void ipod_4g_button_int(void); /* iPod 4th gen and higher only */
30extern void microsd_int(void); /* Sansa E200 and C200 */
30#ifdef SANSA_E200 31#ifdef SANSA_E200
31extern void button_int(void); 32extern void button_int(void);
32extern void clickwheel_int(void); 33extern void clickwheel_int(void);
33extern void microsd_int(void);
34#endif 34#endif
35 35
36#ifdef HAVE_USBSTACK 36#ifdef HAVE_USBSTACK
@@ -49,7 +49,7 @@ void irq(void)
49 } else if (CPU_INT_STAT & TIMER2_MASK) 49 } else if (CPU_INT_STAT & TIMER2_MASK)
50 TIMER2(); 50 TIMER2();
51#if defined(IPOD_MINI) /* Mini 1st gen only, mini 2nd gen uses iPod 4G code */ 51#if defined(IPOD_MINI) /* Mini 1st gen only, mini 2nd gen uses iPod 4G code */
52 else if (CPU_HI_INT_STAT & GPIO_MASK) 52 else if (CPU_HI_INT_STAT & GPIO0_MASK)
53 ipod_mini_button_int(); 53 ipod_mini_button_int();
54#elif CONFIG_KEYPAD == IPOD_4G_PAD /* except Mini 1st gen, handled above */ 54#elif CONFIG_KEYPAD == IPOD_4G_PAD /* except Mini 1st gen, handled above */
55 else if (CPU_HI_INT_STAT & I2C_MASK) 55 else if (CPU_HI_INT_STAT & I2C_MASK)
@@ -65,6 +65,11 @@ void irq(void)
65 if (GPIOH_INT_STAT & 0xc0) 65 if (GPIOH_INT_STAT & 0xc0)
66 clickwheel_int(); 66 clickwheel_int();
67 } 67 }
68#elif defined(SANSA_C200)
69 else if (CPU_HI_INT_STAT & GPIO2_MASK) {
70 if (GPIOL_INT_STAT & 0x08)
71 microsd_int();
72 }
68#endif 73#endif
69 } else { 74 } else {
70 if (COP_INT_STAT & TIMER2_MASK) 75 if (COP_INT_STAT & TIMER2_MASK)