From aa061bc19285b2311d2fbec0b311c55cd6fb70d3 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Sun, 2 Nov 2008 17:11:33 +0000 Subject: AS3525 : fix interrupts support (but leave them disabled) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18979 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/as3525.h | 43 +++++++++++++++++++++++++++++- firmware/target/arm/as3525/system-as3525.c | 32 ++++++++++++---------- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/firmware/export/as3525.h b/firmware/export/as3525.h index 91d0155234..9bd4b19a20 100644 --- a/firmware/export/as3525.h +++ b/firmware/export/as3525.h @@ -195,7 +195,7 @@ CE lines #define CGU_MEMSTICK (*(volatile unsigned long *)(CGU_BASE + 0x34)) #define CGU_DBOP (*(volatile unsigned long *)(CGU_BASE + 0x38)) - +#define CGU_VIC_CLOCK_ENABLE ( 1 << 23 ) /* vic */ /* --- are disabled after reset --- */ #define CGU_DMA_CLOCK_ENABLE ( 1 << 22 ) /* dma */ #define CGU_USB_CLOCK_ENABLE ( 1 << 21 ) /* usb */ @@ -347,4 +347,45 @@ interface */ #define MPMC_PERIPH_ID2 (*(volatile unsigned long*)(MPMC_BASE+0xFE8)) +/* VIC controller (PL190) registers */ + +#define VIC_IRQ_STATUS (*(volatile unsigned long*)(VIC_BASE+0x00)) +#define VIC_FIQ_STATUS (*(volatile unsigned long*)(VIC_BASE+0x04)) +#define VIC_RAW_INTR (*(volatile unsigned long*)(VIC_BASE+0x08)) +#define VIC_INT_SELECT (*(volatile unsigned long*)(VIC_BASE+0x0C)) +#define VIC_INT_ENABLE (*(volatile unsigned long*)(VIC_BASE+0x10)) +#define VIC_INT_EN_CLEAR (*(volatile unsigned long*)(VIC_BASE+0x14)) +#define VIC_SOFT_INT (*(volatile unsigned long*)(VIC_BASE+0x18)) +#define VIC_SOFT_INT_CLEAR (*(volatile unsigned long*)(VIC_BASE+0x1C)) +#define VIC_PROTECTION (*(volatile unsigned long*)(VIC_BASE+0x20)) +#define VIC_VECT_ADDR (*(volatile unsigned long*)(VIC_BASE+0x30)) +#define VIC_DEF_VECT_ADDR (*(volatile unsigned long*)(VIC_BASE+0x34)) + +/* Interrupts */ +#define INTERRUPT_WATCHDOG (1<<0) +#define INTERRUPT_TIMER1 (1<<1) +#define INTERRUPT_TIMER2 (1<<2) +#define INTERRUPT_USB (1<<3) +#define INTERRUPT_DMAC (1<<4) +#define INTERRUPT_NAND (1<<5) +#define INTERRUPT_IDE (1<<6) +#define INTERRUPT_MCI0 (1<<1<<7) +#define INTERRUPT_MCI1 (1<<8) +#define INTERRUPT_AUDIO (1<<9) +#define INTERRUPT_SSP (1<<10) +#define INTERRUPT_I2C_MS (1<<11) +#define INTERRUPT_I2C_AUDIO (1<<12) +#define INTERRUPT_I2SIN (1<<13) +#define INTERRUPT_I2SOUT (1<<14) +#define INTERRUPT_UART (1<<15) +#define INTERRUPT_GPIOD (1<<16) +/* 17 reserved */ +#define INTERRUPT_CGU (1<<18) +#define INTERRUPT_MEMORY_STICK (1<<19) +#define INTERRUPT_DBOP (1<<20) +/* 21-28 reserved */ +#define INTERRUPT_GPIOA (1<<29) +#define INTERRUPT_GPIOB (1<<30) +#define INTERRUPT_GPIOC (1<<31) + #endif /*__AS3525_H__*/ diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index a28ffc473e..9944e60cc5 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -87,10 +87,12 @@ static const char * const irqname[] = static void UIRQ(void) { -/* TODO - unsigned int offset = INTOFFSET; - panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]); -*/ + unsigned int irq_no = 0; + int status = VIC_IRQ_STATUS; + while((status >>= 1)) + irq_no++; + + panicf("Unhandled IRQ %02X: %s", irq_no, irqname[irq_no]); } void irq_handler(void) @@ -102,16 +104,12 @@ void irq_handler(void) asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ "sub sp, sp, #8 \n"); /* Reserve stack */ - /* TODO */ -#if 0 - int irq_no = INTOFFSET; /* Read clears the corresponding IRQ status */ -#else - int irq_no = 69; -#endif - if ((irq_no & (1<<31)) == 0) /* Ensure invalid flag is not set */ - { - irqvector[irq_no](); - } + unsigned int irq_no = 0; + int status = VIC_IRQ_STATUS; + while((status >>= 1)) + irq_no++; + + irqvector[irq_no](); asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ @@ -228,6 +226,12 @@ void system_init(void) sdram_init(); CGU_PERI |= (5<<2)|0x01; /* pclk = PLLA / 6 = 64 MHz */ + +#if 0 /* we don't use interrupts at the moment */ + /* enable VIC */ + CGU_PERI |= CGU_VIC_CLOCK_ENABLE; + VIC_INT_SELECT = 0; /* only IRQ, no FIQ */ +#endif } void system_reboot(void) -- cgit v1.2.3