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
This commit is contained in:
Jens Arnold 2007-11-04 13:22:17 +00:00
parent 04d0e3bc41
commit 6fb4c53fb9
5 changed files with 49 additions and 19 deletions

View file

@ -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))

View file

@ -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

View file

@ -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;
}
/*

View file

@ -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 */

View file

@ -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)