summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/system-target.h
blob: 0dd02a87041162bb116e1e8b10326913edef754a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2002 by Alan Korr
 * Copyright (C) 2007 by Michael Sevakis
 *
 * 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.
 *
 ****************************************************************************/
#ifndef SYSTEM_TARGET_H
#define SYSTEM_TARGET_H

#include "system-arm.h"

#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))
extern unsigned int ipod_hw_rev;

static inline void udelay(unsigned usecs)
{
    unsigned stop = USEC_TIMER + usecs;
    while (TIME_BEFORE(USEC_TIMER, stop));
}

#if CONFIG_CPU == PP5020 || CONFIG_CPU == PP5024
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 (
        "ldr    %0, =0x60000000 \r\n" /* PROCESSOR_ID      */
        "ldrb   %0, [%0]        \r\n" /* Just load the LSB */
        "mov    %0, %0, lsr #7  \r\n" /* Bit 7 => index    */
        : "=&r"(core)                 /* CPU=0, COP=1      */
    );
    return core;
}
#else
unsigned int current_core(void);
#endif

#if CONFIG_CPU != PP5002

#define HAVE_INVALIDATE_ICACHE
static inline void invalidate_icache(void)
{
    outl(inl(0xf000f044) | 0x6, 0xf000f044);
    while ((CACHE_CTL & 0x8000) != 0);
}

#define HAVE_FLUSH_ICACHE
static inline void flush_icache(void)
{
    outl(inl(0xf000f044) | 0x2, 0xf000f044);
    while ((CACHE_CTL & 0x8000) != 0);
}

#endif /* CONFIG_CPU */

#endif /* SYSTEM_TARGET_H */