2002-03-28 15:09:10 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2002-05-24 15:22:33 +00:00
|
|
|
|
#include <stdio.h>
|
2002-04-16 14:02:26 +00:00
|
|
|
|
#include "config.h"
|
2004-10-15 11:33:58 +00:00
|
|
|
|
#include <stdbool.h>
|
2004-11-02 22:24:30 +00:00
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "font.h"
|
2005-01-24 00:01:37 +00:00
|
|
|
|
#include "system.h"
|
2005-03-01 14:35:10 +00:00
|
|
|
|
#include "kernel.h"
|
2005-10-03 09:24:36 +00:00
|
|
|
|
#include "timer.h"
|
2006-08-05 20:19:10 +00:00
|
|
|
|
#include "inttypes.h"
|
|
|
|
|
#include "string.h"
|
2005-03-01 14:35:10 +00:00
|
|
|
|
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
long cpu_frequency = CPU_FREQ;
|
|
|
|
|
#endif
|
2002-04-16 14:02:26 +00:00
|
|
|
|
|
2005-03-03 16:29:02 +00:00
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-10-05 10:07:03 +00:00
|
|
|
|
static int boost_counter = 0;
|
|
|
|
|
static bool cpu_idle = false;
|
|
|
|
|
#ifdef CPU_BOOST_TRACKING
|
|
|
|
|
#define CPU_BOOST_TRACKER_MAX 15
|
|
|
|
|
static char cpu_boost_tracker[CPU_BOOST_TRACKER_MAX+1] = "";
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int get_cpu_boost_counter(void)
|
|
|
|
|
{
|
|
|
|
|
return boost_counter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CPU_BOOST_TRACKING
|
|
|
|
|
const char *get_cpu_boost_tracker()
|
|
|
|
|
{
|
|
|
|
|
return cpu_boost_tracker;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cpu_boost_id(bool on_off, char id)
|
2005-03-03 16:29:02 +00:00
|
|
|
|
{
|
|
|
|
|
if(on_off)
|
|
|
|
|
{
|
|
|
|
|
/* Boost the frequency if not already boosted */
|
2005-03-07 10:51:43 +00:00
|
|
|
|
if(boost_counter++ == 0)
|
2005-03-03 16:29:02 +00:00
|
|
|
|
set_cpu_frequency(CPUFREQ_MAX);
|
2006-10-05 10:07:03 +00:00
|
|
|
|
|
|
|
|
|
/* Add to the boost tracker for debugging */
|
|
|
|
|
int l = strlen(cpu_boost_tracker);
|
|
|
|
|
if (l < CPU_BOOST_TRACKER_MAX)
|
|
|
|
|
{
|
|
|
|
|
cpu_boost_tracker[l] = id;
|
|
|
|
|
cpu_boost_tracker[l+1] = '\0';
|
2005-03-03 16:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Lower the frequency if the counter reaches 0 */
|
2005-03-07 10:51:43 +00:00
|
|
|
|
if(--boost_counter == 0)
|
2005-03-03 16:29:02 +00:00
|
|
|
|
{
|
2005-07-05 07:58:19 +00:00
|
|
|
|
if(cpu_idle)
|
|
|
|
|
set_cpu_frequency(CPUFREQ_DEFAULT);
|
|
|
|
|
else
|
|
|
|
|
set_cpu_frequency(CPUFREQ_NORMAL);
|
2005-03-03 16:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Safety measure */
|
2005-03-07 10:51:43 +00:00
|
|
|
|
if(boost_counter < 0)
|
|
|
|
|
boost_counter = 0;
|
2006-10-05 10:07:03 +00:00
|
|
|
|
|
|
|
|
|
/* Remove an entry from the boost tracker */
|
|
|
|
|
int l = strlen(cpu_boost_tracker);
|
|
|
|
|
while (l >= 0 && cpu_boost_tracker[l] != id)
|
|
|
|
|
l--;
|
|
|
|
|
if (cpu_boost_tracker[l] != id) /* No match found? */
|
|
|
|
|
l = strlen(cpu_boost_tracker)-1; /* Just remove last one */
|
|
|
|
|
while (l < CPU_BOOST_TRACKER_MAX)
|
|
|
|
|
{
|
|
|
|
|
cpu_boost_tracker[l] = cpu_boost_tracker[l+1];
|
|
|
|
|
l++;
|
|
|
|
|
}
|
2005-03-03 16:29:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-05 10:07:03 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void cpu_boost(bool on_off)
|
|
|
|
|
{
|
|
|
|
|
cpu_boost_id(on_off, '?');
|
|
|
|
|
}
|
2005-07-05 07:58:19 +00:00
|
|
|
|
|
|
|
|
|
void cpu_idle_mode(bool on_off)
|
|
|
|
|
{
|
|
|
|
|
cpu_idle = on_off;
|
|
|
|
|
|
|
|
|
|
/* We need to adjust the frequency immediately if the CPU
|
|
|
|
|
isn't boosted */
|
|
|
|
|
if(boost_counter == 0)
|
|
|
|
|
{
|
|
|
|
|
if(cpu_idle)
|
|
|
|
|
set_cpu_frequency(CPUFREQ_DEFAULT);
|
|
|
|
|
else
|
|
|
|
|
set_cpu_frequency(CPUFREQ_NORMAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-03 16:29:02 +00:00
|
|
|
|
#endif
|
2006-08-12 08:01:54 +00:00
|
|
|
|
#if CONFIG_CPU == S3C2440
|
2005-03-03 16:29:02 +00:00
|
|
|
|
|
2006-08-12 08:01:54 +00:00
|
|
|
|
void system_reboot(void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void system_init(void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
2006-08-05 20:19:10 +00:00
|
|
|
|
#if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
|
|
|
|
|
bool detect_flashed_rockbox(void)
|
|
|
|
|
{
|
|
|
|
|
struct flash_header hdr;
|
|
|
|
|
uint8_t *src = (uint8_t *)FLASH_ENTRYPOINT;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-08-11 10:13:16 +00:00
|
|
|
|
# ifndef BOOTLOADER
|
|
|
|
|
int oldmode;
|
|
|
|
|
oldmode = system_memory_guard(MEMGUARD_NONE);
|
|
|
|
|
# endif
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-08-05 20:19:10 +00:00
|
|
|
|
memcpy(&hdr, src, sizeof(struct flash_header));
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-08-11 10:13:16 +00:00
|
|
|
|
# ifndef BOOTLOADER
|
|
|
|
|
system_memory_guard(oldmode);
|
|
|
|
|
# endif
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-08-05 20:19:10 +00:00
|
|
|
|
if (hdr.magic != FLASH_MAGIC)
|
|
|
|
|
return false;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-08-05 20:19:10 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
bool detect_flashed_rockbox(void)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
#if CONFIG_CPU == TCC730
|
|
|
|
|
|
|
|
|
|
void* volatile interrupt_vector[16] __attribute__ ((section(".idata")));
|
|
|
|
|
|
2005-03-03 16:29:02 +00:00
|
|
|
|
static void ddma_wait_idle(void) __attribute__ ((section (".icode")));
|
|
|
|
|
static void ddma_wait_idle(void)
|
2005-01-24 00:01:37 +00:00
|
|
|
|
{
|
2005-03-03 16:29:02 +00:00
|
|
|
|
/* TODO: power saving trick: set the CPU freq to 22MHz
|
|
|
|
|
while doing the busy wait after a disk dma access.
|
|
|
|
|
(Used by Archos) */
|
2005-01-24 00:01:37 +00:00
|
|
|
|
do {
|
|
|
|
|
} while ((DDMACOM & 3) != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-22 09:55:40 +00:00
|
|
|
|
void ddma_transfer(int dir, int mem, void* intAddr, long extAddr, int num)
|
2005-02-08 15:11:58 +00:00
|
|
|
|
__attribute__ ((section (".icode")));
|
2005-02-22 09:55:40 +00:00
|
|
|
|
void ddma_transfer(int dir, int mem, void* intAddr, long extAddr, int num) {
|
2005-01-24 00:01:37 +00:00
|
|
|
|
int irq = set_irq_level(1);
|
|
|
|
|
ddma_wait_idle();
|
|
|
|
|
long externalAddress = (long) extAddr;
|
2005-02-22 09:55:40 +00:00
|
|
|
|
long internalAddress = ((long) intAddr) & 0xFFFF;
|
2005-01-24 00:01:37 +00:00
|
|
|
|
/* HW wants those two in word units. */
|
|
|
|
|
num /= 2;
|
|
|
|
|
externalAddress /= 2;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
DDMACFG = (dir << 1) | (mem << 2);
|
|
|
|
|
DDMAIADR = internalAddress;
|
|
|
|
|
DDMAEADR = externalAddress;
|
|
|
|
|
DDMANUM = num;
|
|
|
|
|
DDMACOM |= 0x4; /* start */
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
ddma_wait_idle(); /* wait for completion */
|
|
|
|
|
set_irq_level(irq);
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-08 15:11:58 +00:00
|
|
|
|
static void ddma_wait_idle_noicode(void)
|
|
|
|
|
{
|
|
|
|
|
do {
|
|
|
|
|
} while ((DDMACOM & 3) != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ddma_transfer_noicode(int dir, int mem, long intAddr, long extAddr, int num) {
|
|
|
|
|
int irq = set_irq_level(1);
|
|
|
|
|
ddma_wait_idle_noicode();
|
|
|
|
|
long externalAddress = (long) extAddr;
|
|
|
|
|
long internalAddress = (long) intAddr;
|
|
|
|
|
/* HW wants those two in word units. */
|
|
|
|
|
num /= 2;
|
|
|
|
|
externalAddress /= 2;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-02-08 15:11:58 +00:00
|
|
|
|
DDMACFG = (dir << 1) | (mem << 2);
|
|
|
|
|
DDMAIADR = internalAddress;
|
|
|
|
|
DDMAEADR = externalAddress;
|
|
|
|
|
DDMANUM = num;
|
|
|
|
|
DDMACOM |= 0x4; /* start */
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-02-08 15:11:58 +00:00
|
|
|
|
ddma_wait_idle_noicode(); /* wait for completion */
|
|
|
|
|
set_irq_level(irq);
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
/* Some linker-defined symbols */
|
|
|
|
|
extern int icodecopy;
|
|
|
|
|
extern int icodesize;
|
|
|
|
|
extern int icodestart;
|
|
|
|
|
|
2005-03-03 16:29:02 +00:00
|
|
|
|
/* change the a PLL frequency */
|
2005-02-15 14:00:21 +00:00
|
|
|
|
void set_pll_freq(int pll_index, long freq_out) {
|
|
|
|
|
volatile unsigned int* plldata;
|
|
|
|
|
volatile unsigned char* pllcon;
|
|
|
|
|
if (pll_index == 0) {
|
|
|
|
|
plldata = &PLL0DATA;
|
|
|
|
|
pllcon = &PLL0CON;
|
|
|
|
|
} else {
|
|
|
|
|
plldata = &PLL1DATA;
|
|
|
|
|
pllcon = &PLL1CON;
|
|
|
|
|
}
|
|
|
|
|
/* VC0 is 32768 Hz */
|
|
|
|
|
#define VC0FREQ (32768L)
|
|
|
|
|
unsigned m = (freq_out / VC0FREQ) - 2;
|
|
|
|
|
/* TODO: if m is too small here, use the divider bits [0,1] */
|
|
|
|
|
*plldata = m << 2;
|
|
|
|
|
*pllcon |= 0x1; /* activate */
|
|
|
|
|
do {
|
|
|
|
|
} while ((*pllcon & 0x2) == 0); /* wait for stabilization */
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-19 17:49:58 +00:00
|
|
|
|
int smsc_version(void) {
|
|
|
|
|
int v;
|
|
|
|
|
int* smsc_ver_addr = (int*)0x4C20;
|
|
|
|
|
__asm__ ("ldc %0, @%1" : "=r"(v) : "a"(smsc_ver_addr));
|
|
|
|
|
v &= 0xFF;
|
|
|
|
|
if (v < 4 || v == 0xFF) {
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void smsc_delay() {
|
|
|
|
|
int i;
|
|
|
|
|
/* FIXME: tune the delay.
|
2005-03-03 16:29:02 +00:00
|
|
|
|
Delay doesn't depend on CPU speed in Archos' firmware.
|
2005-02-19 17:49:58 +00:00
|
|
|
|
*/
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-02-19 17:49:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void extra_init(void) {
|
2005-02-22 09:55:40 +00:00
|
|
|
|
/* Power on stuff */
|
|
|
|
|
P1 |= 0x07;
|
|
|
|
|
P1CON |= 0x1f;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-02-23 15:03:46 +00:00
|
|
|
|
/* P5 conf
|
2006-08-21 17:35:35 +00:00
|
|
|
|
* lines 0, 1 & 4 are digital, other analog. :
|
2005-02-23 15:03:46 +00:00
|
|
|
|
*/
|
|
|
|
|
P5CON = 0xec;
|
|
|
|
|
|
|
|
|
|
P6CON = 0x19;
|
|
|
|
|
|
|
|
|
|
/* P7 conf
|
|
|
|
|
nothing to do: all are inputs
|
|
|
|
|
(reset value of the register is good)
|
|
|
|
|
*/
|
|
|
|
|
|
2005-02-19 17:49:58 +00:00
|
|
|
|
/* SMSC chip config (?) */
|
|
|
|
|
P10CON |= 0x20;
|
|
|
|
|
P6 &= 0xF7;
|
|
|
|
|
P10 &= 0x20;
|
|
|
|
|
smsc_delay();
|
|
|
|
|
if (smsc_version() < 4) {
|
2005-02-19 21:34:03 +00:00
|
|
|
|
P6 |= 0x08;
|
2005-02-19 17:49:58 +00:00
|
|
|
|
P10 |= 0x20;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-03 16:29:02 +00:00
|
|
|
|
void set_cpu_frequency(long frequency) {
|
|
|
|
|
/* Enable SDRAM refresh, at least 15MHz */
|
|
|
|
|
if (frequency < cpu_frequency)
|
|
|
|
|
MIUDCNT = 0x800 | (frequency * 15/1000000L - 1);
|
|
|
|
|
|
|
|
|
|
set_pll_freq(0, frequency);
|
|
|
|
|
PLL0CON |= 0x4; /* use as CPU clock */
|
|
|
|
|
|
|
|
|
|
cpu_frequency = frequency;
|
|
|
|
|
/* wait states and such not changed by Archos. (!?) */
|
|
|
|
|
|
|
|
|
|
/* Enable SDRAM refresh, 15MHz. */
|
|
|
|
|
MIUDCNT = 0x800 | (frequency * 15/1000000L - 1);
|
|
|
|
|
|
|
|
|
|
tick_start(1000/HZ);
|
|
|
|
|
/* TODO: when uart is done; sync uart freq */
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
/* called by crt0 */
|
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* Disable watchdog */
|
|
|
|
|
WDTEN = 0xA5;
|
2005-02-15 14:00:21 +00:00
|
|
|
|
|
|
|
|
|
/****************
|
|
|
|
|
* GPIO ports
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* keep alive (?) -- clear the bit to prevent crash at start (??) */
|
|
|
|
|
P8 = 0x00;
|
|
|
|
|
P8CON = 0x01;
|
2005-02-19 17:49:58 +00:00
|
|
|
|
|
|
|
|
|
/* smsc chip init (?) */
|
|
|
|
|
P10 = 0x20;
|
|
|
|
|
P6 = 0x08;
|
|
|
|
|
|
|
|
|
|
P10CON = 0x20;
|
|
|
|
|
P6CON = 0x08;
|
|
|
|
|
|
2005-02-15 14:00:21 +00:00
|
|
|
|
/********
|
|
|
|
|
* CPU
|
|
|
|
|
*/
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
/* PLL0 (cpu osc. frequency) */
|
2005-03-03 16:29:02 +00:00
|
|
|
|
/* set_cpu_frequency(CPU_FREQ); */
|
2005-01-24 00:01:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************
|
2006-08-21 17:35:35 +00:00
|
|
|
|
* configure S(D)RAM
|
2005-01-24 00:01:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
|
* Copy .icode section to icram
|
|
|
|
|
*/
|
2005-02-08 15:11:58 +00:00
|
|
|
|
ddma_transfer_noicode(0, 0, 0x40, (long)&icodecopy, (int)&icodesize);
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-01-24 00:01:37 +00:00
|
|
|
|
|
|
|
|
|
/***************************
|
2005-02-15 14:00:21 +00:00
|
|
|
|
* Interrupts
|
2005-01-24 00:01:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2005-02-15 14:00:21 +00:00
|
|
|
|
/* priorities ? */
|
2005-01-24 00:01:37 +00:00
|
|
|
|
|
2005-02-15 14:00:21 +00:00
|
|
|
|
/* mask */
|
2005-01-24 00:01:37 +00:00
|
|
|
|
IMR0 = 0;
|
|
|
|
|
IMR1 = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IRQ0 BT INT */
|
|
|
|
|
/* IRQ1 RTC INT */
|
|
|
|
|
/* IRQ2 TA INT */
|
|
|
|
|
/* IRQ3 TAOV INT */
|
|
|
|
|
/* IRQ4 TB INT */
|
|
|
|
|
/* IRQ5 TBOV INT */
|
|
|
|
|
/* IRQ6 TC INT */
|
|
|
|
|
/* IRQ7 TCOV INT */
|
|
|
|
|
/* IRQ8 USB INT */
|
|
|
|
|
/* IRQ9 PPIC INT */
|
|
|
|
|
/* IRQ10 UART_Rx/UART_Err/ UART_tx INT */
|
|
|
|
|
/* IRQ11 IIC INT */
|
|
|
|
|
/* IRQ12 SIO INT */
|
|
|
|
|
/* IRQ13 IIS0 INT */
|
|
|
|
|
/* IRQ14 IIS1 INT */
|
|
|
|
|
/* IRQ15 <20> */
|
2005-02-19 17:49:58 +00:00
|
|
|
|
|
|
|
|
|
extra_init();
|
2005-01-24 00:01:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-08 20:09:07 +00:00
|
|
|
|
void system_reboot (void)
|
|
|
|
|
{
|
|
|
|
|
}
|
2005-03-03 16:29:02 +00:00
|
|
|
|
|
2005-10-08 20:09:07 +00:00
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
(void)newmode;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-07-18 12:40:29 +00:00
|
|
|
|
#elif defined(CPU_COLDFIRE)
|
2006-04-16 23:37:48 +00:00
|
|
|
|
#include "pcf50606.h"
|
2004-10-15 11:33:58 +00:00
|
|
|
|
|
|
|
|
|
#define default_interrupt(name) \
|
2005-07-12 10:30:30 +00:00
|
|
|
|
extern __attribute__((weak,alias("UIE"))) void name (void)
|
2004-10-15 11:33:58 +00:00
|
|
|
|
|
|
|
|
|
static const char* const irqname[] = {
|
|
|
|
|
"", "", "AccessErr","AddrErr","IllInstr", "", "","",
|
|
|
|
|
"PrivVio","Trace","Line-A", "Line-F","Debug","","FormErr","Uninit",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"Spurious","Level1","Level2","Level3","Level4","Level5","Level6","Level7",
|
|
|
|
|
"Trap0","Trap1","Trap2","Trap3","Trap4","Trap5","Trap6","Trap7",
|
|
|
|
|
"Trap8","Trap9","Trap10","Trap11","Trap12","Trap13","Trap14","Trap15",
|
|
|
|
|
"SWT","Timer0","Timer1","I2C","UART1","UART2","DMA0","DMA1",
|
|
|
|
|
"DMA2","DMA3","QSPI","","","","","",
|
|
|
|
|
"PDIR1FULL","PDIR2FULL","EBUTXEMPTY","IIS2TXEMPTY",
|
|
|
|
|
"IIS1TXEMPTY","PDIR3FULL","PDIR3RESYN","UQ2CHANERR",
|
|
|
|
|
"AUDIOTICK","PDIR2RESYN","PDIR2UNOV","PDIR1RESYN",
|
|
|
|
|
"PDIR1UNOV","UQ1CHANERR","IEC2BUFATTEN","IEC2PARERR",
|
|
|
|
|
"IEC2VALNOGOOD","IEC2CNEW","IEC1BUFATTEN","UCHANTXNF",
|
|
|
|
|
"UCHANTXUNDER","UCHANTXEMPTY","PDIR3UNOV","IEC1PARERR",
|
|
|
|
|
"IEC1VALNOGOOD","IEC1CNEW","EBUTXRESYN","EBUTXUNOV",
|
|
|
|
|
"IIS2TXRESYN","IIS2TXUNOV","IIS1TXRESYN","IIS1TXUNOV",
|
2006-10-08 20:21:16 +00:00
|
|
|
|
"GPI0","GPI1","GPI2","GPI3","GPI4","GPI5","GPI6","GPI7",
|
2004-10-15 11:33:58 +00:00
|
|
|
|
"","","","","","","","SOFTINT0",
|
|
|
|
|
"SOFTINT1","SOFTINT2","SOFTINT3","",
|
|
|
|
|
"","CDROMCRCERR","CDROMNOSYNC","CDROMILSYNC",
|
|
|
|
|
"CDROMNEWBLK","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","","",
|
|
|
|
|
"","","","","","","",""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
default_interrupt (TRAP0); /* Trap #0 */
|
|
|
|
|
default_interrupt (TRAP1); /* Trap #1 */
|
|
|
|
|
default_interrupt (TRAP2); /* Trap #2 */
|
|
|
|
|
default_interrupt (TRAP3); /* Trap #3 */
|
|
|
|
|
default_interrupt (TRAP4); /* Trap #4 */
|
|
|
|
|
default_interrupt (TRAP5); /* Trap #5 */
|
|
|
|
|
default_interrupt (TRAP6); /* Trap #6 */
|
|
|
|
|
default_interrupt (TRAP7); /* Trap #7 */
|
|
|
|
|
default_interrupt (TRAP8); /* Trap #8 */
|
|
|
|
|
default_interrupt (TRAP9); /* Trap #9 */
|
|
|
|
|
default_interrupt (TRAP10); /* Trap #10 */
|
|
|
|
|
default_interrupt (TRAP11); /* Trap #11 */
|
|
|
|
|
default_interrupt (TRAP12); /* Trap #12 */
|
|
|
|
|
default_interrupt (TRAP13); /* Trap #13 */
|
|
|
|
|
default_interrupt (TRAP14); /* Trap #14 */
|
|
|
|
|
default_interrupt (TRAP15); /* Trap #15 */
|
|
|
|
|
default_interrupt (SWT); /* Software Watchdog Timer */
|
|
|
|
|
default_interrupt (TIMER0); /* Timer 0 */
|
|
|
|
|
default_interrupt (TIMER1); /* Timer 1 */
|
|
|
|
|
default_interrupt (I2C); /* I2C */
|
|
|
|
|
default_interrupt (UART1); /* UART 1 */
|
|
|
|
|
default_interrupt (UART2); /* UART 2 */
|
|
|
|
|
default_interrupt (DMA0); /* DMA 0 */
|
|
|
|
|
default_interrupt (DMA1); /* DMA 1 */
|
|
|
|
|
default_interrupt (DMA2); /* DMA 2 */
|
|
|
|
|
default_interrupt (DMA3); /* DMA 3 */
|
|
|
|
|
default_interrupt (QSPI); /* QSPI */
|
|
|
|
|
|
|
|
|
|
default_interrupt (PDIR1FULL); /* Processor data in 1 full */
|
|
|
|
|
default_interrupt (PDIR2FULL); /* Processor data in 2 full */
|
|
|
|
|
default_interrupt (EBUTXEMPTY); /* EBU transmit FIFO empty */
|
|
|
|
|
default_interrupt (IIS2TXEMPTY); /* IIS2 transmit FIFO empty */
|
|
|
|
|
default_interrupt (IIS1TXEMPTY); /* IIS1 transmit FIFO empty */
|
|
|
|
|
default_interrupt (PDIR3FULL); /* Processor data in 3 full */
|
|
|
|
|
default_interrupt (PDIR3RESYN); /* Processor data in 3 resync */
|
|
|
|
|
default_interrupt (UQ2CHANERR); /* IEC958-2 Rx U/Q channel error */
|
|
|
|
|
default_interrupt (AUDIOTICK); /* "tick" interrupt */
|
|
|
|
|
default_interrupt (PDIR2RESYN); /* Processor data in 2 resync */
|
|
|
|
|
default_interrupt (PDIR2UNOV); /* Processor data in 2 under/overrun */
|
|
|
|
|
default_interrupt (PDIR1RESYN); /* Processor data in 1 resync */
|
|
|
|
|
default_interrupt (PDIR1UNOV); /* Processor data in 1 under/overrun */
|
|
|
|
|
default_interrupt (UQ1CHANERR); /* IEC958-1 Rx U/Q channel error */
|
|
|
|
|
default_interrupt (IEC2BUFATTEN);/* IEC958-2 channel buffer full */
|
|
|
|
|
default_interrupt (IEC2PARERR); /* IEC958-2 Rx parity or symbol error */
|
|
|
|
|
default_interrupt (IEC2VALNOGOOD);/* IEC958-2 flag not good */
|
|
|
|
|
default_interrupt (IEC2CNEW); /* IEC958-2 New C-channel received */
|
|
|
|
|
default_interrupt (IEC1BUFATTEN);/* IEC958-1 channel buffer full */
|
|
|
|
|
default_interrupt (UCHANTXNF); /* U channel Tx reg next byte is first */
|
|
|
|
|
default_interrupt (UCHANTXUNDER);/* U channel Tx reg underrun */
|
|
|
|
|
default_interrupt (UCHANTXEMPTY);/* U channel Tx reg is empty */
|
|
|
|
|
default_interrupt (PDIR3UNOV); /* Processor data in 3 under/overrun */
|
|
|
|
|
default_interrupt (IEC1PARERR); /* IEC958-1 Rx parity or symbol error */
|
|
|
|
|
default_interrupt (IEC1VALNOGOOD);/* IEC958-1 flag not good */
|
|
|
|
|
default_interrupt (IEC1CNEW); /* IEC958-1 New C-channel received */
|
|
|
|
|
default_interrupt (EBUTXRESYN); /* EBU Tx FIFO resync */
|
|
|
|
|
default_interrupt (EBUTXUNOV); /* EBU Tx FIFO under/overrun */
|
|
|
|
|
default_interrupt (IIS2TXRESYN); /* IIS2 Tx FIFO resync */
|
|
|
|
|
default_interrupt (IIS2TXUNOV); /* IIS2 Tx FIFO under/overrun */
|
|
|
|
|
default_interrupt (IIS1TXRESYN); /* IIS1 Tx FIFO resync */
|
|
|
|
|
default_interrupt (IIS1TXUNOV); /* IIS1 Tx FIFO under/overrun */
|
|
|
|
|
default_interrupt (GPI0); /* GPIO interrupt 0 */
|
|
|
|
|
default_interrupt (GPI1); /* GPIO interrupt 1 */
|
|
|
|
|
default_interrupt (GPI2); /* GPIO interrupt 2 */
|
|
|
|
|
default_interrupt (GPI3); /* GPIO interrupt 3 */
|
|
|
|
|
default_interrupt (GPI4); /* GPIO interrupt 4 */
|
|
|
|
|
default_interrupt (GPI5); /* GPIO interrupt 5 */
|
|
|
|
|
default_interrupt (GPI6); /* GPIO interrupt 6 */
|
|
|
|
|
default_interrupt (GPI7); /* GPIO interrupt 7 */
|
|
|
|
|
|
|
|
|
|
default_interrupt (SOFTINT0); /* Software interrupt 0 */
|
|
|
|
|
default_interrupt (SOFTINT1); /* Software interrupt 1 */
|
|
|
|
|
default_interrupt (SOFTINT2); /* Software interrupt 2 */
|
|
|
|
|
default_interrupt (SOFTINT3); /* Software interrupt 3 */
|
|
|
|
|
|
|
|
|
|
default_interrupt (CDROMCRCERR); /* CD-ROM CRC error */
|
|
|
|
|
default_interrupt (CDROMNOSYNC); /* CD-ROM No sync */
|
|
|
|
|
default_interrupt (CDROMILSYNC); /* CD-ROM Illegal sync */
|
|
|
|
|
default_interrupt (CDROMNEWBLK); /* CD-ROM New block */
|
|
|
|
|
|
|
|
|
|
void UIE (void) /* Unexpected Interrupt or Exception */
|
|
|
|
|
{
|
|
|
|
|
unsigned int format_vector, pc;
|
|
|
|
|
int vector;
|
2004-11-02 22:24:30 +00:00
|
|
|
|
char str[32];
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2004-11-02 22:24:30 +00:00
|
|
|
|
asm volatile ("move.l (52,%%sp),%0": "=r"(format_vector));
|
|
|
|
|
asm volatile ("move.l (56,%%sp),%0": "=r"(pc));
|
2004-10-15 11:33:58 +00:00
|
|
|
|
|
2004-11-02 22:24:30 +00:00
|
|
|
|
vector = (format_vector >> 18) & 0xff;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2004-11-02 22:24:30 +00:00
|
|
|
|
/* clear screen */
|
|
|
|
|
lcd_clear_display ();
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
#endif
|
|
|
|
|
snprintf(str,sizeof(str),"I%02x:%s",vector,irqname[vector]);
|
|
|
|
|
lcd_puts(0,0,str);
|
|
|
|
|
snprintf(str,sizeof(str),"at %08x",pc);
|
|
|
|
|
lcd_puts(0,1,str);
|
|
|
|
|
lcd_update();
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-07-06 20:42:00 +00:00
|
|
|
|
/* set cpu frequency to 11mhz (to prevent overheating) */
|
|
|
|
|
DCR = (DCR & ~0x01ff) | 1;
|
2005-11-05 11:34:57 +00:00
|
|
|
|
PLLCR = 0x10800000;
|
2004-11-02 22:24:30 +00:00
|
|
|
|
|
2004-10-15 11:33:58 +00:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
2005-07-06 20:42:00 +00:00
|
|
|
|
/* check for the ON button (and !hold) */
|
|
|
|
|
if ((GPIO1_READ & 0x22) == 0)
|
2005-11-05 11:34:57 +00:00
|
|
|
|
SYPCR = 0xc0;
|
|
|
|
|
/* Start watchdog timer with 512 cycles timeout. Don't service it. */
|
|
|
|
|
|
|
|
|
|
/* We need a reset method that works in all cases. Calling system_reboot()
|
|
|
|
|
doesn't work when we're called from the debug interrupt, because then
|
|
|
|
|
the CPU is in emulator mode and the only ways leaving it are exexcuting
|
|
|
|
|
an rte instruction or performing a reset. Even disabling the breakpoint
|
|
|
|
|
logic and performing special rte magic doesn't make system_reboot()
|
|
|
|
|
reliable. The system restarts, but boot often fails with ata error -42. */
|
2004-10-15 11:33:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reset vectors are handled in crt0.S */
|
2006-08-21 17:35:35 +00:00
|
|
|
|
void (* const vbr[]) (void) __attribute__ ((section (".vectors"))) =
|
2004-10-15 11:33:58 +00:00
|
|
|
|
{
|
|
|
|
|
UIE,UIE,UIE,UIE,UIE,UIE,
|
|
|
|
|
UIE,UIE,UIE,UIE,UIE,UIE,UIE,UIE,
|
|
|
|
|
UIE,UIE,UIE,UIE,UIE,UIE,UIE,UIE,
|
2005-06-18 12:53:57 +00:00
|
|
|
|
UIE,UIE,UIE,TIMER0,TIMER1,UIE,UIE,UIE,
|
|
|
|
|
/* lvl 3 lvl 4 */
|
2006-02-05 17:34:49 +00:00
|
|
|
|
|
2004-10-15 11:33:58 +00:00
|
|
|
|
TRAP0,TRAP1,TRAP2,TRAP3,TRAP4,TRAP5,TRAP6,TRAP7,
|
|
|
|
|
TRAP8,TRAP9,TRAP10,TRAP11,TRAP12,TRAP13,TRAP14,TRAP15,
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2005-06-18 12:53:57 +00:00
|
|
|
|
SWT,UIE,UIE,I2C,UART1,UART2,DMA0,DMA1,
|
2004-10-15 11:33:58 +00:00
|
|
|
|
DMA2,DMA3,QSPI,UIE,UIE,UIE,UIE,UIE,
|
|
|
|
|
PDIR1FULL,PDIR2FULL,EBUTXEMPTY,IIS2TXEMPTY,
|
|
|
|
|
IIS1TXEMPTY,PDIR3FULL,PDIR3RESYN,UQ2CHANERR,
|
|
|
|
|
AUDIOTICK,PDIR2RESYN,PDIR2UNOV,PDIR1RESYN,
|
|
|
|
|
PDIR1UNOV,UQ1CHANERR,IEC2BUFATTEN,IEC2PARERR,
|
|
|
|
|
IEC2VALNOGOOD,IE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UIE,UIE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
2005-03-03 12:17:45 +00:00
|
|
|
|
/* Clear the accumulators. From here on it's the responsibility of
|
|
|
|
|
whoever uses them to clear them after use (use movclr instruction). */
|
|
|
|
|
asm volatile ("movclr.l %%acc0, %%d0\n\t"
|
|
|
|
|
"movclr.l %%acc1, %%d0\n\t"
|
|
|
|
|
"movclr.l %%acc2, %%d0\n\t"
|
|
|
|
|
"movclr.l %%acc3, %%d0\n\t"
|
|
|
|
|
: : : "d0");
|
2006-04-11 13:49:05 +00:00
|
|
|
|
/* Set EMAC unit to saturating and rounding fractional mode, since that's
|
|
|
|
|
what'll be the most useful for most things which the main thread
|
|
|
|
|
will do. */
|
|
|
|
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
|
2006-10-08 20:21:16 +00:00
|
|
|
|
|
|
|
|
|
/* Set INTBASE and SPURVEC */
|
|
|
|
|
INTBASE = 64;
|
|
|
|
|
SPURVEC = 24;
|
2004-10-15 11:33:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-08 20:09:07 +00:00
|
|
|
|
void system_reboot (void)
|
|
|
|
|
{
|
|
|
|
|
set_cpu_frequency(0);
|
|
|
|
|
|
|
|
|
|
asm(" move.w #0x2700,%sr");
|
|
|
|
|
/* Reset the cookie for the crt0 crash check */
|
|
|
|
|
asm(" move.l #0,%d0");
|
|
|
|
|
asm(" move.l %d0,0x10017ffc");
|
|
|
|
|
asm(" movec.l %d0,%vbr");
|
|
|
|
|
asm(" move.l 0,%sp");
|
|
|
|
|
asm(" move.l 4,%a0");
|
|
|
|
|
asm(" jmp (%a0)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Utilise the breakpoint hardware to catch invalid memory accesses. */
|
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
static const unsigned long modes[MAXMEMGUARD][8] = {
|
|
|
|
|
{ /* catch nothing */
|
|
|
|
|
0x2C870000, 0x00000000, /* TDR = 0x00000000 */
|
|
|
|
|
0x2C8D0000, 0x00000000, /* ABLR = 0x00000000 */
|
|
|
|
|
0x2C8C0000, 0x00000000, /* ABHR = 0x00000000 */
|
|
|
|
|
0x2C860000, 0x00050000, /* AATR = 0x0005 */
|
|
|
|
|
},
|
|
|
|
|
{ /* catch flash ROM writes */
|
|
|
|
|
0x2C8D0000, 0x00000000, /* ABLR = 0x00000000 */
|
|
|
|
|
0x2C8C0FFF, 0xFFFF0000, /* ABHR = 0x0FFFFFFF */
|
|
|
|
|
0x2C860000, 0x6F050000, /* AATR = 0x6F05 */
|
|
|
|
|
0x2C878000, 0x20080000, /* TDR = 0x80002008 */
|
|
|
|
|
},
|
|
|
|
|
{ /* catch all accesses to zero area */
|
|
|
|
|
0x2C8D0000, 0x00000000, /* ABLR = 0x00000000 */
|
|
|
|
|
0x2C8C0FFF, 0xFFFF0000, /* ABHR = 0x0FFFFFFF */
|
|
|
|
|
0x2C860000, 0xEF050000, /* AATR = 0xEF05 */
|
|
|
|
|
0x2C878000, 0x20080000, /* TDR = 0x80002008 */
|
|
|
|
|
}
|
|
|
|
|
/* Note: CPU space accesses (movec instruction), interrupt acknowledges
|
|
|
|
|
and emulator mode accesses are never caught. */
|
|
|
|
|
};
|
2005-11-03 20:34:34 +00:00
|
|
|
|
static int cur_mode = MEMGUARD_NONE;
|
2005-10-08 20:09:07 +00:00
|
|
|
|
|
2005-11-03 20:34:34 +00:00
|
|
|
|
int oldmode = cur_mode;
|
2005-10-08 20:09:07 +00:00
|
|
|
|
const unsigned long *ptr;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (newmode == MEMGUARD_KEEP)
|
|
|
|
|
newmode = oldmode;
|
|
|
|
|
|
|
|
|
|
/* Always set the new mode, we don't know the old settings
|
|
|
|
|
as we cannot read back */
|
|
|
|
|
ptr = modes[newmode];
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
asm ( "wdebug (%0) \n" : : "a"(ptr));
|
|
|
|
|
ptr += 2;
|
|
|
|
|
}
|
2005-11-03 20:34:34 +00:00
|
|
|
|
cur_mode = newmode;
|
2005-10-08 20:09:07 +00:00
|
|
|
|
|
|
|
|
|
return oldmode;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-18 21:29:17 +00:00
|
|
|
|
#ifndef TARGET_TREE
|
2006-04-10 20:33:35 +00:00
|
|
|
|
#if MEM < 32
|
2005-10-03 09:24:36 +00:00
|
|
|
|
#define MAX_REFRESH_TIMER 59
|
|
|
|
|
#define NORMAL_REFRESH_TIMER 21
|
|
|
|
|
#define DEFAULT_REFRESH_TIMER 4
|
2005-07-08 15:03:05 +00:00
|
|
|
|
#else
|
2005-10-03 09:24:36 +00:00
|
|
|
|
#define MAX_REFRESH_TIMER 29
|
|
|
|
|
#define NORMAL_REFRESH_TIMER 10
|
|
|
|
|
#define DEFAULT_REFRESH_TIMER 1
|
2005-07-08 15:03:05 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-16 23:16:32 +00:00
|
|
|
|
#ifdef IRIVER_H300_SERIES
|
|
|
|
|
#define RECALC_DELAYS(f) \
|
|
|
|
|
pcf50606_i2c_recalc_delay(f)
|
|
|
|
|
#else
|
|
|
|
|
#define RECALC_DELAYS(f)
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-10-12 20:22:16 +00:00
|
|
|
|
#ifdef HAVE_SERIAL
|
|
|
|
|
#define BAUD_RATE 57600
|
|
|
|
|
#define BAUDRATE_DIV_DEFAULT (CPUFREQ_DEFAULT/(BAUD_RATE*32*2))
|
|
|
|
|
#define BAUDRATE_DIV_NORMAL (CPUFREQ_NORMAL/(BAUD_RATE*32*2))
|
|
|
|
|
#define BAUDRATE_DIV_MAX (CPUFREQ_MAX/(BAUD_RATE*32*2))
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-03-01 14:35:10 +00:00
|
|
|
|
void set_cpu_frequency (long) __attribute__ ((section (".icode")));
|
|
|
|
|
void set_cpu_frequency(long frequency)
|
|
|
|
|
{
|
|
|
|
|
switch(frequency)
|
|
|
|
|
{
|
|
|
|
|
case CPUFREQ_MAX:
|
2005-11-03 20:01:58 +00:00
|
|
|
|
DCR = (0x8200 | DEFAULT_REFRESH_TIMER);
|
2005-10-03 09:24:36 +00:00
|
|
|
|
/* Refresh timer for bypass frequency */
|
2005-03-01 14:35:10 +00:00
|
|
|
|
PLLCR &= ~1; /* Bypass mode */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
|
2006-04-16 23:16:32 +00:00
|
|
|
|
RECALC_DELAYS(CPUFREQ_MAX);
|
2006-03-30 10:01:04 +00:00
|
|
|
|
PLLCR = 0x11c56005;
|
2005-10-10 19:24:39 +00:00
|
|
|
|
CSCR0 = 0x00001180; /* Flash: 4 wait states */
|
2005-07-17 15:59:32 +00:00
|
|
|
|
CSCR1 = 0x00000980; /* LCD: 2 wait states */
|
2006-06-16 17:34:18 +00:00
|
|
|
|
#if CONFIG_USBOTG == USBOTG_ISP1362
|
|
|
|
|
CSCR3 = 0x00002180; /* USBOTG: 8 wait states */
|
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
|
|
|
|
|
This may take up to 10ms! */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
timers_adjust_prescale(CPUFREQ_MAX_MULT, true);
|
2005-11-03 20:01:58 +00:00
|
|
|
|
DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */
|
2005-03-01 14:35:10 +00:00
|
|
|
|
cpu_frequency = CPUFREQ_MAX;
|
2006-06-16 18:13:35 +00:00
|
|
|
|
IDECONFIG1 = 0x10100000 | (1 << 13) | (2 << 10);
|
2006-06-16 17:34:18 +00:00
|
|
|
|
/* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */
|
|
|
|
|
IDECONFIG2 = 0x40000 | (2 << 8); /* TA enable + CS2wait */
|
2006-10-12 20:22:16 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SERIAL
|
|
|
|
|
UBG10 = BAUDRATE_DIV_MAX >> 8;
|
|
|
|
|
UBG20 = BAUDRATE_DIV_MAX & 0xff;
|
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
break;
|
2006-04-16 23:16:32 +00:00
|
|
|
|
|
2005-03-01 14:35:10 +00:00
|
|
|
|
case CPUFREQ_NORMAL:
|
2005-10-03 09:24:36 +00:00
|
|
|
|
DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
|
|
|
|
|
/* Refresh timer for bypass frequency */
|
2005-03-01 14:35:10 +00:00
|
|
|
|
PLLCR &= ~1; /* Bypass mode */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
|
2006-04-16 23:16:32 +00:00
|
|
|
|
RECALC_DELAYS(CPUFREQ_NORMAL);
|
2006-03-30 10:01:04 +00:00
|
|
|
|
PLLCR = 0x13c5e005;
|
2005-10-10 19:24:39 +00:00
|
|
|
|
CSCR0 = 0x00000580; /* Flash: 1 wait state */
|
2005-07-17 15:59:32 +00:00
|
|
|
|
CSCR1 = 0x00000180; /* LCD: 0 wait states */
|
2006-06-16 17:34:18 +00:00
|
|
|
|
#if CONFIG_USBOTG == USBOTG_ISP1362
|
|
|
|
|
CSCR3 = 0x00000580; /* USBOTG: 1 wait state */
|
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
|
|
|
|
|
This may take up to 10ms! */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true);
|
2005-11-03 20:01:58 +00:00
|
|
|
|
DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */
|
2005-03-01 14:35:10 +00:00
|
|
|
|
cpu_frequency = CPUFREQ_NORMAL;
|
2006-06-16 18:13:35 +00:00
|
|
|
|
IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10);
|
2006-06-16 17:34:18 +00:00
|
|
|
|
/* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */
|
2005-03-18 11:36:48 +00:00
|
|
|
|
IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */
|
2006-10-12 20:22:16 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SERIAL
|
|
|
|
|
UBG10 = BAUDRATE_DIV_NORMAL >> 8;
|
|
|
|
|
UBG20 = BAUDRATE_DIV_NORMAL & 0xff;
|
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2005-11-03 20:01:58 +00:00
|
|
|
|
DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
|
2005-10-03 09:24:36 +00:00
|
|
|
|
/* Refresh timer for bypass frequency */
|
2005-10-14 05:52:24 +00:00
|
|
|
|
PLLCR &= ~1; /* Bypass mode */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true);
|
2006-04-16 23:16:32 +00:00
|
|
|
|
RECALC_DELAYS(CPUFREQ_DEFAULT);
|
2006-03-30 10:01:04 +00:00
|
|
|
|
PLLCR = 0x10c00200; /* Power down PLL, but keep CLSEL and CRSEL */
|
2005-03-01 14:35:10 +00:00
|
|
|
|
CSCR0 = 0x00000180; /* Flash: 0 wait states */
|
|
|
|
|
CSCR1 = 0x00000180; /* LCD: 0 wait states */
|
2006-06-16 17:34:18 +00:00
|
|
|
|
#if CONFIG_USBOTG == USBOTG_ISP1362
|
|
|
|
|
CSCR3 = 0x00000180; /* USBOTG: 0 wait states */
|
|
|
|
|
#endif
|
2005-11-03 20:01:58 +00:00
|
|
|
|
DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */
|
2005-10-03 09:24:36 +00:00
|
|
|
|
cpu_frequency = CPUFREQ_DEFAULT;
|
2006-06-16 18:13:35 +00:00
|
|
|
|
IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10);
|
2006-06-16 17:34:18 +00:00
|
|
|
|
/* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */
|
2005-03-18 11:36:48 +00:00
|
|
|
|
IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */
|
2006-10-12 20:22:16 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SERIAL
|
|
|
|
|
UBG10 = BAUDRATE_DIV_DEFAULT >> 8;
|
|
|
|
|
UBG20 = BAUDRATE_DIV_DEFAULT & 0xff;
|
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-03-18 21:29:17 +00:00
|
|
|
|
#endif
|
2005-03-01 14:35:10 +00:00
|
|
|
|
|
2004-10-15 11:33:58 +00:00
|
|
|
|
#elif CONFIG_CPU == SH7034
|
2002-04-28 21:40:24 +00:00
|
|
|
|
#include "led.h"
|
2002-04-29 14:23:21 +00:00
|
|
|
|
#include "system.h"
|
2003-06-29 15:09:01 +00:00
|
|
|
|
#include "rolo.h"
|
2002-03-28 15:09:10 +00:00
|
|
|
|
|
2004-07-20 21:37:36 +00:00
|
|
|
|
static const char* const irqname[] = {
|
2002-05-28 13:38:42 +00:00
|
|
|
|
"", "", "", "", "IllInstr", "", "IllSltIn","","",
|
|
|
|
|
"CPUAdrEr", "DMAAdrEr", "NMI", "UserBrk",
|
|
|
|
|
"","","","","","","","","","","","","","","","","","","",
|
|
|
|
|
"Trap32","Trap33","Trap34","Trap35","Trap36","Trap37","Trap38","Trap39",
|
|
|
|
|
"Trap40","Trap41","Trap42","Trap43","Trap44","Trap45","Trap46","Trap47",
|
|
|
|
|
"Trap48","Trap49","Trap50","Trap51","Trap52","Trap53","Trap54","Trap55",
|
|
|
|
|
"Trap56","Trap57","Trap58","Trap59","Trap60","Trap61","Trap62","Trap63",
|
|
|
|
|
"Irq0","Irq1","Irq2","Irq3","Irq4","Irq5","Irq6","Irq7",
|
|
|
|
|
"Dma0","","Dma1","","Dma2","","Dma3","",
|
|
|
|
|
"IMIA0","IMIB0","OVI0","", "IMIA1","IMIB1","OVI1","",
|
|
|
|
|
"IMIA2","IMIB2","OVI2","", "IMIA3","IMIB3","OVI3","",
|
|
|
|
|
"IMIA4","IMIB4","OVI4","",
|
|
|
|
|
"Ser0Err","Ser0Rx","Ser0Tx","Ser0TE",
|
|
|
|
|
"Ser1Err","Ser1Rx","Ser1Tx","Ser1TE",
|
|
|
|
|
"ParityEr","A/D conv","","","Watchdog","DRAMRefr"
|
|
|
|
|
};
|
|
|
|
|
|
2006-04-29 12:42:55 +00:00
|
|
|
|
#define RESERVE_INTERRUPT(number) "\t.long\t_UIE" #number "\n"
|
|
|
|
|
#define DEFAULT_INTERRUPT(name, number) "\t.weak\t_" #name \
|
|
|
|
|
"\n\t.set\t_" #name ",_UIE" #number \
|
|
|
|
|
"\n\t.long\t_" #name "\n"
|
|
|
|
|
|
2006-05-01 22:15:36 +00:00
|
|
|
|
asm (
|
|
|
|
|
|
2006-08-21 17:35:35 +00:00
|
|
|
|
/* Vector table.
|
2006-04-29 13:18:40 +00:00
|
|
|
|
* Handled in asm because gcc 4.x doesn't allow weak aliases to symbols
|
|
|
|
|
* defined in an asm block -- silly.
|
|
|
|
|
* Reset vectors (0..3) are handled in crt0.S */
|
2006-05-01 22:15:36 +00:00
|
|
|
|
|
2006-04-29 12:42:55 +00:00
|
|
|
|
".section\t.vectors,\"aw\",@progbits\n"
|
|
|
|
|
DEFAULT_INTERRUPT (GII, 4)
|
|
|
|
|
RESERVE_INTERRUPT ( 5)
|
|
|
|
|
DEFAULT_INTERRUPT (ISI, 6)
|
|
|
|
|
RESERVE_INTERRUPT ( 7)
|
|
|
|
|
RESERVE_INTERRUPT ( 8)
|
|
|
|
|
DEFAULT_INTERRUPT (CPUAE, 9)
|
|
|
|
|
DEFAULT_INTERRUPT (DMAAE, 10)
|
|
|
|
|
DEFAULT_INTERRUPT (NMI, 11)
|
|
|
|
|
DEFAULT_INTERRUPT (UB, 12)
|
|
|
|
|
RESERVE_INTERRUPT ( 13)
|
|
|
|
|
RESERVE_INTERRUPT ( 14)
|
|
|
|
|
RESERVE_INTERRUPT ( 15)
|
|
|
|
|
RESERVE_INTERRUPT ( 16) /* TCB #0 */
|
|
|
|
|
RESERVE_INTERRUPT ( 17) /* TCB #1 */
|
|
|
|
|
RESERVE_INTERRUPT ( 18) /* TCB #2 */
|
|
|
|
|
RESERVE_INTERRUPT ( 19) /* TCB #3 */
|
|
|
|
|
RESERVE_INTERRUPT ( 20) /* TCB #4 */
|
|
|
|
|
RESERVE_INTERRUPT ( 21) /* TCB #5 */
|
|
|
|
|
RESERVE_INTERRUPT ( 22) /* TCB #6 */
|
|
|
|
|
RESERVE_INTERRUPT ( 23) /* TCB #7 */
|
|
|
|
|
RESERVE_INTERRUPT ( 24) /* TCB #8 */
|
|
|
|
|
RESERVE_INTERRUPT ( 25) /* TCB #9 */
|
|
|
|
|
RESERVE_INTERRUPT ( 26) /* TCB #10 */
|
|
|
|
|
RESERVE_INTERRUPT ( 27) /* TCB #11 */
|
|
|
|
|
RESERVE_INTERRUPT ( 28) /* TCB #12 */
|
|
|
|
|
RESERVE_INTERRUPT ( 29) /* TCB #13 */
|
|
|
|
|
RESERVE_INTERRUPT ( 30) /* TCB #14 */
|
|
|
|
|
RESERVE_INTERRUPT ( 31) /* TCB #15 */
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA32, 32)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA33, 33)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA34, 34)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA35, 35)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA36, 36)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA37, 37)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA38, 38)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA39, 39)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA40, 40)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA41, 41)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA42, 42)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA43, 43)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA44, 44)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA45, 45)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA46, 46)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA47, 47)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA48, 48)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA49, 49)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA50, 50)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA51, 51)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA52, 52)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA53, 53)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA54, 54)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA55, 55)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA56, 56)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA57, 57)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA58, 58)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA59, 59)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA60, 60)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA61, 61)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA62, 62)
|
|
|
|
|
DEFAULT_INTERRUPT (TRAPA63, 63)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ0, 64)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ1, 65)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ2, 66)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ3, 67)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ4, 68)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ5, 69)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ6, 70)
|
|
|
|
|
DEFAULT_INTERRUPT (IRQ7, 71)
|
|
|
|
|
DEFAULT_INTERRUPT (DEI0, 72)
|
|
|
|
|
RESERVE_INTERRUPT ( 73)
|
|
|
|
|
DEFAULT_INTERRUPT (DEI1, 74)
|
|
|
|
|
RESERVE_INTERRUPT ( 75)
|
|
|
|
|
DEFAULT_INTERRUPT (DEI2, 76)
|
|
|
|
|
RESERVE_INTERRUPT ( 77)
|
|
|
|
|
DEFAULT_INTERRUPT (DEI3, 78)
|
|
|
|
|
RESERVE_INTERRUPT ( 79)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIA0, 80)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIB0, 81)
|
|
|
|
|
DEFAULT_INTERRUPT (OVI0, 82)
|
|
|
|
|
RESERVE_INTERRUPT ( 83)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIA1, 84)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIB1, 85)
|
|
|
|
|
DEFAULT_INTERRUPT (OVI1, 86)
|
|
|
|
|
RESERVE_INTERRUPT ( 87)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIA2, 88)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIB2, 89)
|
|
|
|
|
DEFAULT_INTERRUPT (OVI2, 90)
|
|
|
|
|
RESERVE_INTERRUPT ( 91)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIA3, 92)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIB3, 93)
|
|
|
|
|
DEFAULT_INTERRUPT (OVI3, 94)
|
|
|
|
|
RESERVE_INTERRUPT ( 95)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIA4, 96)
|
|
|
|
|
DEFAULT_INTERRUPT (IMIB4, 97)
|
|
|
|
|
DEFAULT_INTERRUPT (OVI4, 98)
|
|
|
|
|
RESERVE_INTERRUPT ( 99)
|
|
|
|
|
DEFAULT_INTERRUPT (REI0, 100)
|
|
|
|
|
DEFAULT_INTERRUPT (RXI0, 101)
|
|
|
|
|
DEFAULT_INTERRUPT (TXI0, 102)
|
|
|
|
|
DEFAULT_INTERRUPT (TEI0, 103)
|
|
|
|
|
DEFAULT_INTERRUPT (REI1, 104)
|
|
|
|
|
DEFAULT_INTERRUPT (RXI1, 105)
|
|
|
|
|
DEFAULT_INTERRUPT (TXI1, 106)
|
|
|
|
|
DEFAULT_INTERRUPT (TEI1, 107)
|
|
|
|
|
RESERVE_INTERRUPT ( 108)
|
|
|
|
|
DEFAULT_INTERRUPT (ADITI, 109)
|
2006-04-29 13:18:40 +00:00
|
|
|
|
|
2006-08-21 17:35:35 +00:00
|
|
|
|
/* UIE# block.
|
2006-05-01 22:15:36 +00:00
|
|
|
|
* Must go into the same section as the UIE() handler */
|
|
|
|
|
|
|
|
|
|
"\t.text\n"
|
2006-04-29 12:42:55 +00:00
|
|
|
|
"_UIE4:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE5:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE6:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE7:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE8:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE9:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE10:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE11:\tbsr\t_UIE\n\tmov.l\t@r15+,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t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE96:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE97:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE98:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE99:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE100:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE101:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE102:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE103:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE104:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE105:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE106:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE107:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE108:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
|
|
|
|
"_UIE109:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
|
2006-05-01 22:15:36 +00:00
|
|
|
|
|
2006-04-29 12:42:55 +00:00
|
|
|
|
);
|
|
|
|
|
|
2006-05-01 22:15:36 +00:00
|
|
|
|
extern void UIE4(void); /* needed for calculating the UIE number */
|
|
|
|
|
|
|
|
|
|
void UIE (unsigned int pc) __attribute__((section(".text")));
|
|
|
|
|
void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */
|
|
|
|
|
{
|
|
|
|
|
#if CONFIG_LED == LED_REAL
|
2006-10-08 21:34:26 +00:00
|
|
|
|
bool state = false;
|
|
|
|
|
int i = 0;
|
2006-05-01 22:15:36 +00:00
|
|
|
|
#endif
|
|
|
|
|
unsigned int n;
|
|
|
|
|
char str[32];
|
|
|
|
|
|
|
|
|
|
asm volatile ("sts\tpr,%0" : "=r"(n));
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-05-01 22:15:36 +00:00
|
|
|
|
/* clear screen */
|
|
|
|
|
lcd_clear_display ();
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
#endif
|
|
|
|
|
/* output exception */
|
2006-05-02 07:36:39 +00:00
|
|
|
|
n = (n - (unsigned)UIE4 + 12)>>2; /* get exception or interrupt number */
|
2006-05-01 22:15:36 +00:00
|
|
|
|
snprintf(str,sizeof(str),"I%02x:%s",n,irqname[n]);
|
|
|
|
|
lcd_puts(0,0,str);
|
|
|
|
|
snprintf(str,sizeof(str),"at %08x",pc);
|
|
|
|
|
lcd_puts(0,1,str);
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_update ();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
#if CONFIG_LED == LED_REAL
|
2006-10-08 21:34:26 +00:00
|
|
|
|
if (--i <= 0)
|
|
|
|
|
{
|
|
|
|
|
state = !state;
|
|
|
|
|
led(state);
|
|
|
|
|
i = 240000;
|
|
|
|
|
}
|
2006-05-01 22:15:36 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* try to restart firmware if ON is pressed */
|
|
|
|
|
#if CONFIG_KEYPAD == PLAYER_PAD
|
|
|
|
|
if (!(PADRL & 0x20))
|
|
|
|
|
#elif CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
|
#ifdef HAVE_FMADC
|
|
|
|
|
if (!(PCDR & 0x0008))
|
|
|
|
|
#else
|
|
|
|
|
if (!(PBDRH & 0x01))
|
|
|
|
|
#endif
|
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
|
|
|
if (!(PCDR & 0x0008))
|
|
|
|
|
#endif
|
2006-08-21 17:35:35 +00:00
|
|
|
|
{
|
2006-05-01 22:15:36 +00:00
|
|
|
|
/* enable the watchguard timer, but don't service it */
|
|
|
|
|
RSTCSR_W = 0x5a40; /* Reset enabled, power-on reset */
|
|
|
|
|
TCSR_W = 0xa560; /* Watchdog timer mode, timer enabled, sysclk/2 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-29 09:11:04 +00:00
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* Disable all interrupts */
|
|
|
|
|
IPRA = 0;
|
|
|
|
|
IPRB = 0;
|
|
|
|
|
IPRC = 0;
|
|
|
|
|
IPRD = 0;
|
|
|
|
|
IPRE = 0;
|
|
|
|
|
|
|
|
|
|
/* NMI level low, falling edge on all interrupts */
|
|
|
|
|
ICR = 0;
|
2002-09-05 07:22:37 +00:00
|
|
|
|
|
2004-03-13 11:44:48 +00:00
|
|
|
|
/* Enable burst and RAS down mode on DRAM */
|
|
|
|
|
DCR |= 0x5000;
|
2002-09-05 10:21:48 +00:00
|
|
|
|
|
|
|
|
|
/* Activate Warp mode (simultaneous internal and external mem access) */
|
|
|
|
|
BCR |= 0x2000;
|
2003-10-27 10:30:12 +00:00
|
|
|
|
|
|
|
|
|
/* Bus state controller initializations. These are only necessary when
|
2004-10-12 09:09:16 +00:00
|
|
|
|
running from flash. */
|
|
|
|
|
WCR1 = 0x40FD; /* Long wait states for CS6 (ATA), short for the rest. */
|
2003-10-27 10:30:12 +00:00
|
|
|
|
WCR3 = 0x8000; /* WAIT is pulled up, 1 state inserted for CS6 */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-08 20:09:07 +00:00
|
|
|
|
void system_reboot (void)
|
|
|
|
|
{
|
|
|
|
|
set_irq_level(HIGHEST_IRQ_LEVEL);
|
|
|
|
|
|
|
|
|
|
asm volatile ("ldc\t%0,vbr" : : "r"(0));
|
|
|
|
|
|
|
|
|
|
PACR2 |= 0x4000; /* for coldstart detection */
|
|
|
|
|
IPRA = 0;
|
|
|
|
|
IPRB = 0;
|
|
|
|
|
IPRC = 0;
|
|
|
|
|
IPRD = 0;
|
|
|
|
|
IPRE = 0;
|
|
|
|
|
ICR = 0;
|
|
|
|
|
|
|
|
|
|
asm volatile ("jmp @%0; mov.l @%1,r15" : :
|
|
|
|
|
"r"(*(int*)0),"r"(4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Utilise the user break controller to catch invalid memory accesses. */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
static const struct {
|
|
|
|
|
unsigned long addr;
|
|
|
|
|
unsigned long mask;
|
|
|
|
|
unsigned short bbr;
|
|
|
|
|
} modes[MAXMEMGUARD] = {
|
|
|
|
|
/* catch nothing */
|
|
|
|
|
{ 0x00000000, 0x00000000, 0x0000 },
|
|
|
|
|
/* catch writes to area 02 (flash ROM) */
|
|
|
|
|
{ 0x02000000, 0x00FFFFFF, 0x00F8 },
|
|
|
|
|
/* catch all accesses to areas 00 (internal ROM) and 01 (free) */
|
|
|
|
|
{ 0x00000000, 0x01FFFFFF, 0x00FC }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int oldmode = MEMGUARD_NONE;
|
|
|
|
|
int i;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
/* figure out the old mode from what is in the UBC regs. If the register
|
|
|
|
|
values don't match any mode, assume MEMGUARD_NONE */
|
|
|
|
|
for (i = MEMGUARD_NONE; i < MAXMEMGUARD; i++)
|
|
|
|
|
{
|
|
|
|
|
if (BAR == modes[i].addr && BAMR == modes[i].mask &&
|
|
|
|
|
BBR == modes[i].bbr)
|
|
|
|
|
{
|
|
|
|
|
oldmode = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
if (newmode == MEMGUARD_KEEP)
|
|
|
|
|
newmode = oldmode;
|
|
|
|
|
|
|
|
|
|
BBR = 0; /* switch off everything first */
|
|
|
|
|
|
|
|
|
|
/* always set the UBC according to the mode, in case the old settings
|
|
|
|
|
didn't match any valid mode */
|
|
|
|
|
BAR = modes[newmode].addr;
|
|
|
|
|
BAMR = modes[newmode].mask;
|
|
|
|
|
BBR = modes[newmode].bbr;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
return oldmode;
|
2002-05-29 09:11:04 +00:00
|
|
|
|
}
|
2006-01-24 23:32:16 +00:00
|
|
|
|
#elif defined(CPU_ARM)
|
2005-11-07 23:07:19 +00:00
|
|
|
|
|
2006-01-19 15:03:34 +00:00
|
|
|
|
static const char* const uiename[] = {
|
|
|
|
|
"Undefined instruction", "Prefetch abort", "Data abort"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Unexpected Interrupt or Exception handler. Currently only deals with
|
|
|
|
|
exceptions, but will deal with interrupts later.
|
|
|
|
|
*/
|
|
|
|
|
void UIE(unsigned int pc, unsigned int num)
|
|
|
|
|
{
|
|
|
|
|
char str[32];
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-01-19 15:03:34 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
#endif
|
|
|
|
|
lcd_puts(0, 0, uiename[num]);
|
|
|
|
|
snprintf(str, sizeof(str), "at %08x", pc);
|
|
|
|
|
lcd_puts(0, 1, str);
|
|
|
|
|
lcd_update();
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-01-19 15:03:34 +00:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
/* TODO: perhaps add button handling in here when we get a polling
|
|
|
|
|
driver some day.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-24 23:32:16 +00:00
|
|
|
|
#if CONFIG_CPU==PP5020
|
|
|
|
|
|
2006-01-31 09:40:21 +00:00
|
|
|
|
unsigned int ipod_hw_rev;
|
|
|
|
|
|
2006-01-24 23:32:16 +00:00
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
|
extern void TIMER1(void);
|
2006-03-17 00:08:39 +00:00
|
|
|
|
extern void TIMER2(void);
|
2006-02-27 12:35:05 +00:00
|
|
|
|
|
2006-03-30 18:14:08 +00:00
|
|
|
|
#if defined(IPOD_MINI) /* mini 1 only, mini 2G uses iPod 4G code */
|
2006-02-27 12:35:05 +00:00
|
|
|
|
extern void ipod_mini_button_int(void);
|
|
|
|
|
|
|
|
|
|
void irq(void)
|
|
|
|
|
{
|
|
|
|
|
if (CPU_INT_STAT & TIMER1_MASK)
|
|
|
|
|
TIMER1();
|
2006-03-17 00:18:22 +00:00
|
|
|
|
else if (CPU_INT_STAT & TIMER2_MASK)
|
2006-03-17 00:08:39 +00:00
|
|
|
|
TIMER2();
|
2006-02-27 12:35:05 +00:00
|
|
|
|
else if (CPU_HI_INT_STAT & GPIO_MASK)
|
2006-08-21 17:35:35 +00:00
|
|
|
|
ipod_mini_button_int();
|
2006-02-27 12:35:05 +00:00
|
|
|
|
}
|
2006-08-31 19:19:35 +00:00
|
|
|
|
#elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022)
|
2006-08-20 23:05:47 +00:00
|
|
|
|
/* TODO: this should really be in the target tree, but moving it there caused
|
|
|
|
|
crt0.S not to find it while linking */
|
|
|
|
|
void irq(void)
|
|
|
|
|
{
|
|
|
|
|
if (CPU_INT_STAT & TIMER1_MASK)
|
|
|
|
|
TIMER1();
|
|
|
|
|
else if (CPU_INT_STAT & TIMER2_MASK)
|
2006-08-21 17:35:35 +00:00
|
|
|
|
TIMER2();
|
2006-08-20 23:05:47 +00:00
|
|
|
|
}
|
2006-02-27 12:35:05 +00:00
|
|
|
|
#else
|
2006-01-24 23:32:16 +00:00
|
|
|
|
extern void ipod_4g_button_int(void);
|
|
|
|
|
|
|
|
|
|
void irq(void)
|
|
|
|
|
{
|
2006-08-21 17:35:35 +00:00
|
|
|
|
if (CPU_INT_STAT & TIMER1_MASK)
|
2006-01-24 23:32:16 +00:00
|
|
|
|
TIMER1();
|
2006-03-17 00:18:22 +00:00
|
|
|
|
else if (CPU_INT_STAT & TIMER2_MASK)
|
2006-03-17 00:08:39 +00:00
|
|
|
|
TIMER2();
|
2006-01-24 23:32:16 +00:00
|
|
|
|
else if (CPU_HI_INT_STAT & I2C_MASK)
|
|
|
|
|
ipod_4g_button_int();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-02-27 12:35:05 +00:00
|
|
|
|
#endif /* BOOTLOADER */
|
2006-01-24 23:32:16 +00:00
|
|
|
|
|
2006-08-21 17:35:35 +00:00
|
|
|
|
unsigned int current_core(void)
|
|
|
|
|
{
|
|
|
|
|
if(((*(volatile unsigned long *)(0x60000000)) & 0xff) == 0x55)
|
|
|
|
|
{
|
|
|
|
|
return CPU;
|
|
|
|
|
}
|
|
|
|
|
return COP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 19:11:43 +00:00
|
|
|
|
/* TODO: The following two function have been lifted straight from IPL, and
|
|
|
|
|
hence have a lot of numeric addresses used straight. I'd like to use
|
|
|
|
|
#defines for these, but don't know what most of them are for or even what
|
|
|
|
|
they should be named. Because of this I also have no way of knowing how
|
2006-08-21 17:35:35 +00:00
|
|
|
|
to extend the funtions to do alternate cache configurations and/or
|
2005-12-17 19:11:43 +00:00
|
|
|
|
some other CPU frequency scaling. */
|
|
|
|
|
|
2006-01-05 17:02:48 +00:00
|
|
|
|
#ifndef BOOTLOADER
|
2005-12-17 19:11:43 +00:00
|
|
|
|
static void ipod_init_cache(void)
|
|
|
|
|
{
|
2006-01-05 17:02:48 +00:00
|
|
|
|
/* Initialising the cache in the iPod bootloader prevents Rockbox from starting */
|
2005-12-17 19:11:43 +00:00
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
/* cache init mode? */
|
|
|
|
|
outl(0x4, 0x6000C000);
|
|
|
|
|
|
|
|
|
|
/* PP5002 has 8KB cache */
|
|
|
|
|
for (i = 0xf0004000; i < 0xf0006000; i += 16) {
|
|
|
|
|
outl(0x0, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outl(0x0, 0xf000f040);
|
|
|
|
|
outl(0x3fc0, 0xf000f044);
|
|
|
|
|
|
|
|
|
|
/* enable cache */
|
|
|
|
|
outl(0x1, 0x6000C000);
|
|
|
|
|
|
|
|
|
|
for (i = 0x10000000; i < 0x10002000; i += 16)
|
|
|
|
|
inb(i);
|
|
|
|
|
}
|
2006-03-17 02:44:55 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-03-17 14:27:09 +00:00
|
|
|
|
/* Not all iPod targets support CPU freq. boosting yet */
|
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-03-17 02:02:13 +00:00
|
|
|
|
void set_cpu_frequency(long frequency)
|
2005-12-17 19:11:43 +00:00
|
|
|
|
{
|
2006-03-17 02:02:13 +00:00
|
|
|
|
unsigned long postmult;
|
|
|
|
|
|
|
|
|
|
if (frequency == CPUFREQ_NORMAL)
|
|
|
|
|
postmult = CPUFREQ_NORMAL_MULT;
|
|
|
|
|
else if (frequency == CPUFREQ_MAX)
|
|
|
|
|
postmult = CPUFREQ_MAX_MULT;
|
|
|
|
|
else
|
|
|
|
|
postmult = CPUFREQ_DEFAULT_MULT;
|
|
|
|
|
cpu_frequency = frequency;
|
2005-12-17 19:11:43 +00:00
|
|
|
|
|
2006-03-17 02:02:13 +00:00
|
|
|
|
/* Enable PLL? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
outl(inl(0x70000020) | (1<<30), 0x70000020);
|
2006-03-17 02:02:13 +00:00
|
|
|
|
|
|
|
|
|
/* Select 24MHz crystal as clock source? */
|
2005-12-17 19:11:43 +00:00
|
|
|
|
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020);
|
|
|
|
|
|
2006-03-17 02:02:13 +00:00
|
|
|
|
/* Clock frequency = (24/8)*postmult */
|
|
|
|
|
outl(0xaa020000 | 8 | (postmult << 8), 0x60006034);
|
2006-04-07 12:16:27 +00:00
|
|
|
|
|
2006-03-17 02:02:13 +00:00
|
|
|
|
/* Wait for PLL relock? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
udelay(2000);
|
2005-12-17 19:11:43 +00:00
|
|
|
|
|
2006-03-17 02:02:13 +00:00
|
|
|
|
/* Select PLL as clock source? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020);
|
2006-04-07 12:16:27 +00:00
|
|
|
|
|
2006-08-30 15:36:55 +00:00
|
|
|
|
#if defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
|
2006-04-07 12:16:27 +00:00
|
|
|
|
/* We don't know why the timer interrupt gets disabled on the PP5020
|
|
|
|
|
based ipods, but without the following line, the 4Gs will freeze
|
2006-08-21 17:35:35 +00:00
|
|
|
|
when CPU frequency changing is enabled.
|
2006-04-07 12:16:27 +00:00
|
|
|
|
|
|
|
|
|
Note also that a simple "CPU_INT_EN = TIMER1_MASK;" (as used
|
|
|
|
|
elsewhere to enable interrupts) doesn't work, we need "|=".
|
|
|
|
|
|
|
|
|
|
It's not needed on the PP5021 and PP5022 ipods.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* unmask interrupt source */
|
|
|
|
|
CPU_INT_EN |= TIMER1_MASK;
|
|
|
|
|
#endif
|
2006-03-17 02:02:13 +00:00
|
|
|
|
}
|
2006-03-17 02:44:55 +00:00
|
|
|
|
#elif !defined(BOOTLOADER)
|
2006-03-17 02:02:13 +00:00
|
|
|
|
void ipod_set_cpu_frequency(void)
|
|
|
|
|
{
|
|
|
|
|
/* Enable PLL? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
outl(inl(0x70000020) | (1<<30), 0x70000020);
|
2006-03-17 02:02:13 +00:00
|
|
|
|
|
|
|
|
|
/* Select 24MHz crystal as clock source? */
|
|
|
|
|
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020);
|
|
|
|
|
|
|
|
|
|
/* Clock frequency = (24/8)*25 = 75MHz */
|
|
|
|
|
outl(0xaa020000 | 8 | (25 << 8), 0x60006034);
|
|
|
|
|
/* Wait for PLL relock? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
udelay(2000);
|
2006-03-17 02:02:13 +00:00
|
|
|
|
|
|
|
|
|
/* Select PLL as clock source? */
|
2006-03-17 02:13:49 +00:00
|
|
|
|
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020);
|
2005-12-17 19:11:43 +00:00
|
|
|
|
}
|
2006-01-05 17:02:48 +00:00
|
|
|
|
#endif
|
2005-12-17 19:11:43 +00:00
|
|
|
|
|
2005-12-12 13:53:22 +00:00
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
2006-01-05 17:02:48 +00:00
|
|
|
|
#ifndef BOOTLOADER
|
2006-01-31 01:50:07 +00:00
|
|
|
|
/* The hw revision is written to the last 4 bytes of SDRAM by the
|
|
|
|
|
bootloader - we save it before Rockbox overwrites it. */
|
|
|
|
|
ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc)));
|
|
|
|
|
|
2005-12-12 13:53:22 +00:00
|
|
|
|
/* disable all irqs */
|
|
|
|
|
outl(-1, 0x60001138);
|
|
|
|
|
outl(-1, 0x60001128);
|
|
|
|
|
outl(-1, 0x6000111c);
|
|
|
|
|
|
|
|
|
|
outl(-1, 0x60001038);
|
|
|
|
|
outl(-1, 0x60001028);
|
|
|
|
|
outl(-1, 0x6000101c);
|
2006-03-17 14:27:09 +00:00
|
|
|
|
#ifndef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-03-17 02:02:13 +00:00
|
|
|
|
ipod_set_cpu_frequency();
|
|
|
|
|
#endif
|
2006-03-17 02:13:49 +00:00
|
|
|
|
ipod_init_cache();
|
2006-01-05 17:02:48 +00:00
|
|
|
|
#endif
|
2005-12-12 13:53:22 +00:00
|
|
|
|
}
|
2005-11-07 23:07:19 +00:00
|
|
|
|
|
2005-12-12 13:53:22 +00:00
|
|
|
|
void system_reboot(void)
|
|
|
|
|
{
|
2006-09-20 23:21:59 +00:00
|
|
|
|
/* Reboot */
|
|
|
|
|
DEV_RS |= DEV_SYSTEM;
|
2005-11-07 23:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-02-05 17:34:49 +00:00
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
(void)newmode;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#elif CONFIG_CPU==PP5002
|
|
|
|
|
unsigned int ipod_hw_rev;
|
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
|
extern void TIMER1(void);
|
2006-03-17 00:08:39 +00:00
|
|
|
|
extern void TIMER2(void);
|
2006-02-05 17:34:49 +00:00
|
|
|
|
|
|
|
|
|
void irq(void)
|
|
|
|
|
{
|
2006-08-21 17:35:35 +00:00
|
|
|
|
if (CPU_INT_STAT & TIMER1_MASK)
|
2006-02-05 17:34:49 +00:00
|
|
|
|
TIMER1();
|
2006-08-21 17:35:35 +00:00
|
|
|
|
else if (CPU_INT_STAT & TIMER2_MASK)
|
2006-03-17 00:08:39 +00:00
|
|
|
|
TIMER2();
|
2006-02-24 20:54:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-02-05 17:34:49 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-08-21 17:35:35 +00:00
|
|
|
|
unsigned int current_core(void)
|
|
|
|
|
{
|
|
|
|
|
if(((*(volatile unsigned long *)(0xc4000000)) & 0xff) == 0x55)
|
|
|
|
|
{
|
|
|
|
|
return CPU;
|
|
|
|
|
}
|
|
|
|
|
return COP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-02-05 17:34:49 +00:00
|
|
|
|
/* TODO: The following two function have been lifted straight from IPL, and
|
|
|
|
|
hence have a lot of numeric addresses used straight. I'd like to use
|
|
|
|
|
#defines for these, but don't know what most of them are for or even what
|
|
|
|
|
they should be named. Because of this I also have no way of knowing how
|
2006-08-21 17:35:35 +00:00
|
|
|
|
to extend the funtions to do alternate cache configurations and/or
|
2006-02-05 17:34:49 +00:00
|
|
|
|
some other CPU frequency scaling. */
|
|
|
|
|
|
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
|
static void ipod_init_cache(void)
|
|
|
|
|
{
|
|
|
|
|
int i =0;
|
|
|
|
|
/* Initialising the cache in the iPod bootloader prevents Rockbox from starting */
|
|
|
|
|
outl(inl(0xcf004050) & ~0x700, 0xcf004050);
|
|
|
|
|
outl(0x4000, 0xcf004020);
|
|
|
|
|
|
|
|
|
|
outl(0x2, 0xcf004024);
|
|
|
|
|
|
|
|
|
|
/* PP5002 has 8KB cache */
|
2006-02-24 20:54:09 +00:00
|
|
|
|
for (i = 0xf0004000; i < (int)(0xf0006000); i += 16) {
|
2006-02-05 17:34:49 +00:00
|
|
|
|
outl(0x0, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outl(0x0, 0xf000f020);
|
|
|
|
|
outl(0x3fc0, 0xf000f024);
|
|
|
|
|
|
|
|
|
|
outl(0x3, 0xcf004024);
|
|
|
|
|
}
|
2006-07-24 22:49:06 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
|
void set_cpu_frequency(long frequency)
|
|
|
|
|
{
|
|
|
|
|
unsigned long postmult;
|
|
|
|
|
|
|
|
|
|
if (frequency == CPUFREQ_NORMAL)
|
|
|
|
|
postmult = CPUFREQ_NORMAL_MULT;
|
|
|
|
|
else if (frequency == CPUFREQ_MAX)
|
|
|
|
|
postmult = CPUFREQ_MAX_MULT;
|
|
|
|
|
else
|
|
|
|
|
postmult = CPUFREQ_DEFAULT_MULT;
|
|
|
|
|
cpu_frequency = frequency;
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-07-24 22:49:06 +00:00
|
|
|
|
outl(0x02, 0xcf005008);
|
|
|
|
|
outl(0x55, 0xcf00500c);
|
|
|
|
|
outl(0x6000, 0xcf005010);
|
|
|
|
|
|
|
|
|
|
/* Clock frequency = (24/8)*postmult */
|
|
|
|
|
outl(8, 0xcf005018);
|
|
|
|
|
outl(postmult, 0xcf00501c);
|
|
|
|
|
|
|
|
|
|
outl(0xe000, 0xcf005010);
|
|
|
|
|
|
|
|
|
|
/* Wait for PLL relock? */
|
|
|
|
|
udelay(2000);
|
|
|
|
|
|
|
|
|
|
/* Select PLL as clock source? */
|
|
|
|
|
outl(0xa8, 0xcf00500c);
|
|
|
|
|
}
|
|
|
|
|
#elif !defined(BOOTLOADER)
|
2006-02-05 17:34:49 +00:00
|
|
|
|
static void ipod_set_cpu_speed(void)
|
|
|
|
|
{
|
|
|
|
|
outl(0x02, 0xcf005008);
|
|
|
|
|
outl(0x55, 0xcf00500c);
|
|
|
|
|
outl(0x6000, 0xcf005010);
|
|
|
|
|
#if 1
|
|
|
|
|
// 75 MHz (24/24 * 75) (default)
|
|
|
|
|
outl(24, 0xcf005018);
|
|
|
|
|
outl(75, 0xcf00501c);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// 66 MHz (24/3 * 8)
|
|
|
|
|
outl(3, 0xcf005018);
|
|
|
|
|
outl(8, 0xcf00501c);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
outl(0xe000, 0xcf005010);
|
|
|
|
|
|
|
|
|
|
udelay(2000);
|
|
|
|
|
|
|
|
|
|
outl(0xa8, 0xcf00500c);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
|
ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc)));
|
|
|
|
|
outl(-1, 0xcf00101c);
|
|
|
|
|
outl(-1, 0xcf001028);
|
|
|
|
|
outl(-1, 0xcf001038);
|
2006-07-24 22:49:06 +00:00
|
|
|
|
#ifndef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-02-05 17:34:49 +00:00
|
|
|
|
ipod_set_cpu_speed();
|
2006-07-24 22:49:06 +00:00
|
|
|
|
#endif
|
2006-02-05 17:34:49 +00:00
|
|
|
|
ipod_init_cache();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void system_reboot(void)
|
|
|
|
|
{
|
|
|
|
|
outl(inl(0xcf005030) | 0x4, 0xcf005030);
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-12 15:29:43 +00:00
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
(void)newmode;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-11-07 23:07:19 +00:00
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
|
#elif CONFIG_CPU==PNX0101
|
|
|
|
|
|
|
|
|
|
interrupt_handler_t interrupt_vector[0x1d] __attribute__ ((section(".idata")));
|
|
|
|
|
|
|
|
|
|
#define IRQ_REG(reg) (*(volatile unsigned long *)(0x80300000 + (reg)))
|
|
|
|
|
|
|
|
|
|
static inline unsigned long irq_read(int reg)
|
|
|
|
|
{
|
|
|
|
|
unsigned long v, v2;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
v = IRQ_REG(reg);
|
|
|
|
|
v2 = IRQ_REG(reg);
|
|
|
|
|
} while (v != v2);
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define IRQ_WRITE_WAIT(reg, val, cond) \
|
|
|
|
|
do { unsigned long v, v2; \
|
|
|
|
|
do { \
|
|
|
|
|
IRQ_REG(reg) = (val); \
|
|
|
|
|
v = IRQ_REG(reg); \
|
|
|
|
|
v2 = IRQ_REG(reg); \
|
|
|
|
|
} while ((v != v2) || !(cond)); \
|
|
|
|
|
} while (0);
|
|
|
|
|
|
2006-01-24 23:32:16 +00:00
|
|
|
|
static void undefined_int(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
2006-01-12 00:35:50 +00:00
|
|
|
|
|
|
|
|
|
void irq(void)
|
|
|
|
|
{
|
|
|
|
|
int n = irq_read(0x100) >> 3;
|
|
|
|
|
(*(interrupt_vector[n]))();
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-03 23:26:14 +00:00
|
|
|
|
void fiq(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
|
void irq_enable_int(int n)
|
|
|
|
|
{
|
|
|
|
|
IRQ_WRITE_WAIT(0x404 + n * 4, 0x4010000, v & 0x10000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void irq_set_int_handler(int n, interrupt_handler_t handler)
|
|
|
|
|
{
|
|
|
|
|
interrupt_vector[n + 1] = handler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* turn off watchdog */
|
|
|
|
|
(*(volatile unsigned long *)0x80002804) = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
IRQ_WRITE_WAIT(0x100, 0, v == 0);
|
|
|
|
|
IRQ_WRITE_WAIT(0x104, 0, v == 0);
|
|
|
|
|
IRQ_WRITE_WAIT(0, 0, v == 0);
|
|
|
|
|
IRQ_WRITE_WAIT(4, 0, v == 0);
|
|
|
|
|
*/
|
2006-08-21 17:35:35 +00:00
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
|
for (i = 0; i < 0x1c; i++)
|
|
|
|
|
{
|
|
|
|
|
IRQ_WRITE_WAIT(0x404 + i * 4, 0x1e000001, (v & 0x3010f) == 1);
|
|
|
|
|
IRQ_WRITE_WAIT(0x404 + i * 4, 0x4000000, (v & 0x10000) == 0);
|
|
|
|
|
IRQ_WRITE_WAIT(0x404 + i * 4, 0x10000001, (v & 0xf) == 1);
|
2006-01-24 23:32:16 +00:00
|
|
|
|
interrupt_vector[i + 1] = undefined_int;
|
2006-01-12 00:35:50 +00:00
|
|
|
|
}
|
2006-01-24 23:32:16 +00:00
|
|
|
|
interrupt_vector[0] = undefined_int;
|
2006-01-12 00:35:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void system_reboot(void)
|
|
|
|
|
{
|
|
|
|
|
(*(volatile unsigned long *)0x80002804) = 1;
|
|
|
|
|
while (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int system_memory_guard(int newmode)
|
|
|
|
|
{
|
|
|
|
|
(void)newmode;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-24 23:32:16 +00:00
|
|
|
|
#endif /* CPU_ARM */
|
2005-10-08 20:09:07 +00:00
|
|
|
|
#endif /* CONFIG_CPU */
|
2005-02-02 21:56:03 +00:00
|
|
|
|
|