2006-12-29 02:49:12 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "panic.h"
|
2007-04-21 04:48:20 +00:00
|
|
|
#include "mmu-meg-fx.h"
|
2006-12-29 02:49:12 +00:00
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
|
2007-04-30 12:54:05 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TIMER4_MASK = (1 << 14),
|
|
|
|
LCD_MASK = (1 << 16),
|
|
|
|
DMA0_MASK = (1 << 17),
|
|
|
|
DMA1_MASK = (1 << 18),
|
|
|
|
DMA2_MASK = (1 << 19),
|
|
|
|
DMA3_MASK = (1 << 20),
|
|
|
|
ALARM_MASK = (1 << 30),
|
|
|
|
};
|
2007-01-04 11:33:13 +00:00
|
|
|
|
|
|
|
int system_memory_guard(int newmode)
|
2006-12-29 02:49:12 +00:00
|
|
|
{
|
|
|
|
(void)newmode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void timer4(void);
|
2007-04-30 12:54:05 +00:00
|
|
|
extern void dma0(void); /* free */
|
2007-01-04 11:33:13 +00:00
|
|
|
extern void dma1(void);
|
|
|
|
extern void dma3(void);
|
2006-12-29 02:49:12 +00:00
|
|
|
|
2007-01-04 11:33:13 +00:00
|
|
|
void irq(void)
|
2006-12-29 02:49:12 +00:00
|
|
|
{
|
|
|
|
int intpending = INTPND;
|
|
|
|
|
|
|
|
SRCPND = intpending; /* Clear this interrupt. */
|
|
|
|
INTPND = intpending; /* Clear this interrupt. */
|
|
|
|
|
|
|
|
/* Timer 4 */
|
|
|
|
if ((intpending & TIMER4_MASK) != 0)
|
|
|
|
timer4();
|
2007-01-04 11:33:13 +00:00
|
|
|
else
|
2006-12-29 02:49:12 +00:00
|
|
|
{
|
|
|
|
/* unexpected interrupt */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-04 11:33:13 +00:00
|
|
|
void system_reboot(void)
|
|
|
|
{
|
2007-01-15 22:49:55 +00:00
|
|
|
WTCON = 0;
|
2007-01-04 11:33:13 +00:00
|
|
|
WTCNT = WTDAT = 1 ;
|
|
|
|
WTCON = 0x21;
|
|
|
|
for(;;)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void system_init(void)
|
|
|
|
{
|
|
|
|
/* Turn off un-needed devices */
|
|
|
|
|
|
|
|
/* Turn off all of the UARTS */
|
|
|
|
CLKCON &= ~( (1<<10) | (1<<11) |(1<<12) );
|
|
|
|
|
|
|
|
/* Turn off AC97 and Camera */
|
|
|
|
CLKCON &= ~( (1<<19) | (1<<20) );
|
2007-01-13 02:24:15 +00:00
|
|
|
|
2007-01-15 22:49:55 +00:00
|
|
|
/* Turn off USB host */
|
|
|
|
CLKCON &= ~(1 << 6);
|
2007-05-07 19:34:34 +00:00
|
|
|
|
|
|
|
/* Turn off USB device */
|
|
|
|
CLKCON &= ~(1 << 7);
|
2007-01-15 22:49:55 +00:00
|
|
|
|
|
|
|
/* Turn off NAND flash controller */
|
|
|
|
CLKCON &= ~(1 << 4);
|
2007-05-07 19:34:34 +00:00
|
|
|
|
|
|
|
/* Turn off the USB PLL */
|
|
|
|
CLKSLOW |= (1 << 7);
|
2007-01-17 01:47:05 +00:00
|
|
|
|
2007-01-04 11:33:13 +00:00
|
|
|
}
|
|
|
|
|
2007-01-17 03:04:31 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
|
2007-01-16 15:49:29 +00:00
|
|
|
void set_cpu_frequency(long frequency)
|
|
|
|
{
|
|
|
|
if (frequency == CPUFREQ_MAX)
|
|
|
|
{
|
2007-01-17 18:15:50 +00:00
|
|
|
asm volatile("mov r0, #0\n"
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0\n"
|
|
|
|
"orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0" : : : "r0");
|
2007-01-16 15:49:29 +00:00
|
|
|
|
|
|
|
FREQ = CPUFREQ_MAX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-01-17 18:15:50 +00:00
|
|
|
asm volatile("mov r0, #0\n"
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0\n"
|
|
|
|
"bic r0, r0, #3<<30\n" /* set to FastBus mode*/
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0" : : : "r0");
|
2007-01-04 11:33:13 +00:00
|
|
|
|
2007-01-16 15:49:29 +00:00
|
|
|
FREQ = CPUFREQ_NORMAL;
|
|
|
|
}
|
|
|
|
}
|
2007-01-17 03:04:31 +00:00
|
|
|
|
|
|
|
#endif
|