summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
#define USB_IRQ 24
#define FIREWIRE_IRQ 25
#define HI_IRQ 30
-#define GPIO_IRQ (32+0)
+#define GPIO0_IRQ (32+0) /* Ports A..D */
+#define GPIO1_IRQ (32+1) /* Ports E..H */
+#define GPIO2_IRQ (32+2) /* Ports I..L */
#define SER0_IRQ (32+4)
#define SER1_IRQ (32+5)
#define I2C_IRQ (32+8)
@@ -109,7 +111,9 @@
#define USB_MASK (1 << USB_IRQ)
#define FIREWIRE_MASK (1 << FIREWIRE_IRQ)
#define HI_MASK (1 << HI_IRQ)
-#define GPIO_MASK (1 << (GPIO_IRQ-32))
+#define GPIO0_MASK (1 << (GPIO0_IRQ-32))
+#define GPIO1_MASK (1 << (GPIO1_IRQ-32))
+#define GPIO2_MASK (1 << (GPIO2_IRQ-32))
#define SER0_MASK (1 << (SER0_IRQ-32))
#define SER1_MASK (1 << (SER1_IRQ-32))
#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 @@
completely and redifine any minor differences */
#include "pp5020.h"
-#undef GPIO_IRQ
-/* Ports A, B, ?? */
-#define GPIO0_IRQ (32+0)
-/* Ports F, H, ?? */
-#define GPIO1_IRQ (32+1)
-
-#undef GPIO_MASK
-#define GPIO0_MASK (1 << (GPIO0_IRQ-32))
-#define GPIO1_MASK (1 << (GPIO1_IRQ-32))
-
#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)
void ipod_mini_button_int(void)
{
- CPU_HI_INT_CLR = GPIO_MASK;
+ CPU_HI_INT_CLR = GPIO0_MASK;
int_btn = ipod_mini_button_read();
//CPU_INT_EN = 0x40000000;
- CPU_HI_INT_EN = GPIO_MASK;
+ CPU_HI_INT_EN = GPIO0_MASK;
}
void button_init_device(void)
@@ -190,7 +190,7 @@ void button_init_device(void)
GPIOB_INT_EN = 0x30;
/* unmask interrupt */
CPU_INT_EN = 0x40000000;
- CPU_HI_INT_EN = GPIO_MASK;
+ CPU_HI_INT_EN = GPIO0_MASK;
}
/*
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)
#ifdef HAVE_HOTSWAP
/* enable card detection port - mask interrupt first */
+#ifdef SANSA_E200
GPIOA_INT_EN &= ~0x80;
GPIOA_OUTPUT_EN &= ~0x80;
GPIOA_ENABLE |= 0x80;
+#elif defined SANSA_C200
+ GPIOL_INT_EN &= ~0x08;
+
+ GPIOL_OUTPUT_EN &= ~0x08;
+ GPIOL_ENABLE |= 0x08;
+#endif
#endif
sd_select_device(0);
@@ -1188,6 +1195,7 @@ int ata_init(void)
/* enable interupt for the mSD card */
sleep(HZ/10);
#ifdef HAVE_HOTSWAP
+#ifdef SANSA_E200
CPU_INT_EN = HI_MASK;
CPU_HI_INT_EN = GPIO0_MASK;
@@ -1195,6 +1203,15 @@ int ata_init(void)
GPIOA_INT_CLR = 0x80;
GPIOA_INT_EN |= 0x80;
+#elif defined SANSA_C200
+ CPU_INT_EN = HI_MASK;
+ CPU_HI_INT_EN = GPIO2_MASK;
+
+ GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (~GPIOL_INPUT_VAL & 0x08);
+
+ GPIOL_INT_CLR = 0x08;
+ GPIOL_INT_EN |= 0x08;
+#endif
#endif
spinlock_unlock(&sd_spin);
}
@@ -1239,8 +1256,11 @@ tCardInfo *card_get_info_target(int card_no)
#ifdef HAVE_HOTSWAP
bool card_detect_target(void)
{
- /* 0x00:inserted, 0x80:not inserted */
- return (GPIOA_INPUT_VAL & 0x80) == 0;
+#ifdef SANSA_E200
+ return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */
+#elif defined SANSA_C200
+ return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */
+#endif
}
static bool sd1_oneshot_callback(struct timeout *tmo)
@@ -1256,6 +1276,7 @@ void microsd_int(void)
{
static struct timeout sd1_oneshot;
+#ifdef SANSA_E200
int detect = GPIOA_INPUT_VAL & 0x80;
GPIOA_INT_LEV = (GPIOA_INT_LEV & ~0x80) | (detect ^ 0x80);
@@ -1263,5 +1284,15 @@ void microsd_int(void)
timeout_register(&sd1_oneshot, sd1_oneshot_callback,
detect ? 1 : HZ/2, detect == 0);
+#elif defined SANSA_C200
+ int detect = GPIOL_INPUT_VAL & 0x08;
+
+ GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (detect ^ 0x08);
+ GPIOL_INT_CLR = 0x08;
+
+ timeout_register(&sd1_oneshot, sd1_oneshot_callback,
+ detect ? HZ/2 : 1, detect != 0);
+#endif
+
}
#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);
extern void TIMER2(void);
extern void ipod_mini_button_int(void); /* iPod Mini 1st gen only */
extern void ipod_4g_button_int(void); /* iPod 4th gen and higher only */
+extern void microsd_int(void); /* Sansa E200 and C200 */
#ifdef SANSA_E200
extern void button_int(void);
extern void clickwheel_int(void);
-extern void microsd_int(void);
#endif
#ifdef HAVE_USBSTACK
@@ -49,7 +49,7 @@ void irq(void)
} else if (CPU_INT_STAT & TIMER2_MASK)
TIMER2();
#if defined(IPOD_MINI) /* Mini 1st gen only, mini 2nd gen uses iPod 4G code */
- else if (CPU_HI_INT_STAT & GPIO_MASK)
+ else if (CPU_HI_INT_STAT & GPIO0_MASK)
ipod_mini_button_int();
#elif CONFIG_KEYPAD == IPOD_4G_PAD /* except Mini 1st gen, handled above */
else if (CPU_HI_INT_STAT & I2C_MASK)
@@ -65,6 +65,11 @@ void irq(void)
if (GPIOH_INT_STAT & 0xc0)
clickwheel_int();
}
+#elif defined(SANSA_C200)
+ else if (CPU_HI_INT_STAT & GPIO2_MASK) {
+ if (GPIOL_INT_STAT & 0x08)
+ microsd_int();
+ }
#endif
} else {
if (COP_INT_STAT & TIMER2_MASK)