2007-04-13 20:55:48 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
2007-04-14 01:18:06 +00:00
|
|
|
* Copyright (C) 2007 by Michael Sevakis
|
2007-04-13 20:55:48 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-04-13 20:55:48 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef SYSTEM_TARGET_H
|
|
|
|
#define SYSTEM_TARGET_H
|
|
|
|
|
2010-03-25 23:01:56 +00:00
|
|
|
#include "config.h"
|
2007-04-14 01:18:06 +00:00
|
|
|
#include "system-arm.h"
|
2007-04-13 20:55:48 +00:00
|
|
|
|
2007-09-20 08:01:56 +00:00
|
|
|
#ifdef CPU_PP
|
2007-07-26 15:07:16 +00:00
|
|
|
/* TODO: This header is actually portalplayer specific, and should be
|
|
|
|
* moved into an appropriate subdir (or even split in 2). */
|
|
|
|
|
|
|
|
#if CONFIG_CPU == PP5002
|
2007-07-31 10:56:50 +00:00
|
|
|
#define CPUFREQ_SLEEP 32768
|
2007-07-26 15:07:16 +00:00
|
|
|
#define CPUFREQ_DEFAULT 24000000
|
2007-07-31 10:56:50 +00:00
|
|
|
#define CPUFREQ_NORMAL 30000000
|
|
|
|
#define CPUFREQ_MAX 80000000
|
2007-07-26 15:07:16 +00:00
|
|
|
|
|
|
|
#else /* PP5022, PP5024 */
|
2007-07-31 20:48:49 +00:00
|
|
|
#define CPUFREQ_SLEEP 32768
|
2007-07-26 15:07:16 +00:00
|
|
|
#define CPUFREQ_DEFAULT 24000000
|
2007-07-31 10:56:50 +00:00
|
|
|
#define CPUFREQ_NORMAL 30000000
|
|
|
|
#define CPUFREQ_MAX 80000000
|
2007-07-26 15:07:16 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-14 01:18:06 +00:00
|
|
|
#define inl(a) (*(volatile unsigned long *) (a))
|
|
|
|
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
|
|
|
#define inb(a) (*(volatile unsigned char *) (a))
|
|
|
|
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
|
|
|
#define inw(a) (*(volatile unsigned short *) (a))
|
|
|
|
#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
|
2007-04-13 20:55:48 +00:00
|
|
|
|
2007-04-14 01:18:06 +00:00
|
|
|
static inline void udelay(unsigned usecs)
|
2007-04-13 20:55:48 +00:00
|
|
|
{
|
2007-04-14 01:18:06 +00:00
|
|
|
unsigned stop = USEC_TIMER + usecs;
|
|
|
|
while (TIME_BEFORE(USEC_TIMER, stop));
|
2007-04-13 20:55:48 +00:00
|
|
|
}
|
|
|
|
|
2007-04-14 11:15:43 +00:00
|
|
|
static inline unsigned int current_core(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* PROCESSOR_ID seems to be 32-bits:
|
|
|
|
* CPU = 0x55555555 = |01010101|01010101|01010101|01010101|
|
|
|
|
* COP = 0xaaaaaaaa = |10101010|10101010|10101010|10101010|
|
|
|
|
* ^
|
|
|
|
*/
|
|
|
|
unsigned int core;
|
|
|
|
asm volatile (
|
2007-09-29 06:17:33 +00:00
|
|
|
"ldrb %0, [%1] \n" /* Just load the LSB */
|
|
|
|
"mov %0, %0, lsr #7 \n" /* Bit 7 => index */
|
|
|
|
: "=r"(core) /* CPU=0, COP=1 */
|
|
|
|
: "r"(&PROCESSOR_ID)
|
2007-04-14 11:15:43 +00:00
|
|
|
);
|
|
|
|
return core;
|
|
|
|
}
|
2007-04-13 20:55:48 +00:00
|
|
|
|
2007-10-06 22:27:27 +00:00
|
|
|
/* Return the actual ID instead of core index */
|
|
|
|
static inline unsigned int processor_id(void)
|
|
|
|
{
|
2007-11-27 01:20:26 +00:00
|
|
|
unsigned int id;
|
2007-10-06 22:27:27 +00:00
|
|
|
|
|
|
|
asm volatile (
|
|
|
|
"ldrb %0, [%1] \n"
|
|
|
|
: "=r"(id)
|
|
|
|
: "r"(&PROCESSOR_ID)
|
|
|
|
);
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2008-04-20 17:53:05 +00:00
|
|
|
#if CONFIG_CPU == PP5002
|
|
|
|
static inline void sleep_core(int core)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
/* Sleep: PP5002 crashes if the instruction that puts it to sleep is
|
|
|
|
* located at 0xNNNNNNN0. 4/8/C works. This sequence makes sure
|
|
|
|
* that the correct alternative is executed. Don't change the order
|
|
|
|
* of the next 4 instructions! */
|
|
|
|
"tst pc, #0x0c \n"
|
|
|
|
"mov r0, #0xca \n"
|
|
|
|
"strne r0, [%[ctl]] \n"
|
|
|
|
"streq r0, [%[ctl]] \n"
|
|
|
|
"nop \n" /* nop's needed because of pipeline */
|
|
|
|
"nop \n"
|
|
|
|
"nop \n"
|
|
|
|
:
|
|
|
|
: [ctl]"r"(&PROC_CTL(core))
|
|
|
|
: "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
static inline void wake_core(int core)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
"mov r0, #0xce \n"
|
|
|
|
"str r0, [%[ctl]] \n"
|
|
|
|
:
|
|
|
|
: [ctl]"r"(&PROC_CTL(core))
|
|
|
|
: "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#else /* PP502x */
|
|
|
|
static inline void sleep_core(int core)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
"mov r0, #0x80000000 \n"
|
|
|
|
"str r0, [%[ctl]] \n"
|
|
|
|
"nop \n"
|
|
|
|
:
|
|
|
|
: [ctl]"r"(&PROC_CTL(core))
|
|
|
|
: "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
static inline void wake_core(int core)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
"mov r0, #0 \n"
|
|
|
|
"str r0, [%[ctl]] \n"
|
|
|
|
:
|
|
|
|
: [ctl]"r"(&PROC_CTL(core))
|
|
|
|
: "r0"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-15 08:19:30 +00:00
|
|
|
#if defined(BOOTLOADER) && !defined(HAVE_BOOTLOADER_USB_MODE)
|
2007-10-04 16:10:20 +00:00
|
|
|
/* All addresses within rockbox are in IRAM in the bootloader so
|
|
|
|
are therefore uncached */
|
|
|
|
#define UNCACHED_ADDR(a) (a)
|
2007-11-27 01:20:26 +00:00
|
|
|
|
|
|
|
#else /* !BOOTLOADER */
|
|
|
|
|
|
|
|
#if CONFIG_CPU == PP5002
|
|
|
|
#define UNCACHED_BASE_ADDR 0x28000000
|
|
|
|
#else /* PP502x */
|
|
|
|
#define UNCACHED_BASE_ADDR 0x10000000
|
2007-10-04 16:10:20 +00:00
|
|
|
#endif
|
2007-10-04 04:53:01 +00:00
|
|
|
|
2007-11-27 01:20:26 +00:00
|
|
|
#define UNCACHED_ADDR(a) \
|
|
|
|
((typeof (a))((uintptr_t)(a) | UNCACHED_BASE_ADDR))
|
|
|
|
#endif /* BOOTLOADER */
|
2007-09-29 06:17:33 +00:00
|
|
|
|
2010-03-25 23:01:56 +00:00
|
|
|
#if defined(CPU_PP502x) && defined(HAVE_ATA_DMA)
|
2010-03-26 00:11:50 +00:00
|
|
|
#define STORAGE_WANTS_ALIGN
|
2010-03-25 23:01:56 +00:00
|
|
|
#endif
|
|
|
|
|
2007-11-08 05:17:20 +00:00
|
|
|
/** cache functions **/
|
2011-01-15 08:19:30 +00:00
|
|
|
#if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_USB_MODE)
|
2010-09-08 17:05:49 +00:00
|
|
|
#define HAVE_CPUCACHE_COMMIT_DISCARD
|
|
|
|
#define HAVE_CPUCACHE_COMMIT
|
|
|
|
/* deprecated alias */
|
2009-02-11 12:55:51 +00:00
|
|
|
#define HAVE_CPUCACHE_INVALIDATE
|
|
|
|
#define HAVE_CPUCACHE_FLUSH
|
2007-09-28 10:54:27 +00:00
|
|
|
#endif
|
2007-04-13 20:55:48 +00:00
|
|
|
|
2010-08-29 13:20:16 +00:00
|
|
|
#if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
|
|
|
|
extern unsigned char probed_ramsize;
|
|
|
|
#endif
|
|
|
|
|
2011-01-15 08:19:30 +00:00
|
|
|
|
|
|
|
#ifdef BOOTLOADER
|
|
|
|
#if defined(TATUNG_TPJ1022)
|
|
|
|
/* Some targets don't like yielding in the bootloader - force
|
|
|
|
* yield() to return without a context switch. */
|
|
|
|
#define YIELD_KERNEL_HOOK() true
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
void tick_stop(void);
|
|
|
|
void system_prepare_fw_start(void);
|
|
|
|
|
|
|
|
#else /* !HAVE_BOOTLOADER_USB_MODE */
|
|
|
|
|
|
|
|
/* Busy "sleep" without a tick */
|
|
|
|
#define SLEEP_KERNEL_HOOK(ticks) \
|
|
|
|
({ unsigned _stop = USEC_TIMER + ((ticks) + 1) * (1000000/HZ); \
|
|
|
|
while (TIME_BEFORE(USEC_TIMER, _stop)) \
|
|
|
|
switch_thread(); \
|
|
|
|
true; })
|
|
|
|
#endif /* HAVE_BOOTLOADER_USB_MODE */
|
|
|
|
|
|
|
|
#endif /* BOOTLOADER */
|
|
|
|
|
2007-09-28 10:20:02 +00:00
|
|
|
#endif /* CPU_PP */
|
2007-04-13 20:55:48 +00:00
|
|
|
|
|
|
|
#endif /* SYSTEM_TARGET_H */
|