summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pp
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pp')
-rw-r--r--firmware/target/arm/pp/ascodec-target.h103
-rw-r--r--firmware/target/arm/pp/ata-target.h92
-rw-r--r--firmware/target/arm/pp/debug-target.h48
-rw-r--r--firmware/target/arm/pp/sd-pp-target.h32
-rw-r--r--firmware/target/arm/pp/system-target.h206
5 files changed, 481 insertions, 0 deletions
diff --git a/firmware/target/arm/pp/ascodec-target.h b/firmware/target/arm/pp/ascodec-target.h
new file mode 100644
index 0000000000..68d9905a6b
--- /dev/null
+++ b/firmware/target/arm/pp/ascodec-target.h
@@ -0,0 +1,103 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Driver for AS3514 audio codec
11 *
12 * Copyright (c) 2007 Daniel Ankers
13 * Copyright (c) 2007 Christian Gmeiner
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24
25#ifndef _ASCODEC_TARGET_H
26#define _ASCODEC_TARGET_H
27
28#include "config.h"
29
30#ifdef CPU_PP
31/* TODO: This header is actually portalplayer specific, and should be
32 * moved into an appropriate subdir */
33
34#include "as3514.h"
35#include "i2c-pp.h"
36
37static inline int ascodec_write(unsigned int reg, unsigned int value)
38{
39 return pp_i2c_send(AS3514_I2C_ADDR, reg, value);
40}
41
42static inline int ascodec_read(unsigned int reg)
43{
44 return i2c_readbyte(AS3514_I2C_ADDR, reg);
45}
46
47static inline int ascodec_readbytes(int addr, int len, unsigned char *data)
48{
49 return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data);
50}
51
52static inline void ascodec_lock(void)
53{
54 i2c_lock();
55}
56
57static inline void ascodec_unlock(void)
58{
59 i2c_unlock();
60}
61
62static inline bool ascodec_chg_status(void)
63{
64 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
65}
66
67static inline bool ascodec_endofch(void)
68{
69 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
70}
71
72static inline void ascodec_monitor_endofch(void)
73{
74 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
75}
76
77static inline void ascodec_wait_adc_finished(void)
78{
79 /*
80 * FIXME: not implemented
81 *
82 * If irqs are not available on the target platform,
83 * this should be most likely implemented by polling
84 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
85 * is polling IRQ_ENDOFCH.
86 */
87}
88
89static inline void ascodec_write_charger(int value)
90{
91 ascodec_write(AS3514_CHARGER, value);
92}
93
94static inline int ascodec_read_charger(void)
95{
96 return ascodec_read(AS3514_CHARGER);
97}
98
99extern void ascodec_suppressor_on(bool on);
100
101#endif /* CPU_PP */
102
103#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/arm/pp/ata-target.h b/firmware/target/arm/pp/ata-target.h
new file mode 100644
index 0000000000..616c451579
--- /dev/null
+++ b/firmware/target/arm/pp/ata-target.h
@@ -0,0 +1,92 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef ATA_TARGET_H
23#define ATA_TARGET_H
24
25#include "config.h"
26
27#ifdef CPU_PP
28
29#ifdef HAVE_BOOTLOADER_USB_MODE
30#define ATA_DRIVER_CLOSE
31#endif
32
33/* primary channel */
34#define ATA_DATA (*((volatile unsigned short*)(IDE_BASE + 0x1e0)))
35#define ATA_ERROR (*((volatile unsigned char*)(IDE_BASE + 0x1e4)))
36#define ATA_NSECTOR (*((volatile unsigned char*)(IDE_BASE + 0x1e8)))
37#define ATA_SECTOR (*((volatile unsigned char*)(IDE_BASE + 0x1ec)))
38#define ATA_LCYL (*((volatile unsigned char*)(IDE_BASE + 0x1f0)))
39#define ATA_HCYL (*((volatile unsigned char*)(IDE_BASE + 0x1f4)))
40#define ATA_SELECT (*((volatile unsigned char*)(IDE_BASE + 0x1f8)))
41#define ATA_COMMAND (*((volatile unsigned char*)(IDE_BASE + 0x1fc)))
42#define ATA_CONTROL (*((volatile unsigned char*)(IDE_BASE + 0x3f8)))
43
44#if (CONFIG_CPU == PP5002)
45
46#define ATA_OUT8(reg,val) do { reg = (val); \
47 while (!(IDE_CFG_STATUS & 0x40)); \
48 } while (0)
49
50/* Plain C reading and writing. See comment in ata-as-arm.S */
51
52#elif defined CPU_PP502x
53
54/* asm optimized reading and writing */
55#define ATA_OPTIMIZED_READING
56#define ATA_OPTIMIZED_WRITING
57
58#endif /* CONFIG_CPU */
59
60#endif
61
62#ifdef HAVE_ATA_DMA
63
64/* IDE DMA controller registers */
65#define IDE_DMA_CONTROL (*(volatile unsigned long *)(0xc3000400))
66#define IDE_DMA_LENGTH (*(volatile unsigned long *)(0xc3000408))
67#define IDE_DMA_ADDR (*(volatile unsigned long *)(0xc300040C))
68
69/* Maximum multi-word DMA mode supported by the controller */
70#define ATA_MAX_MWDMA 2
71
72#ifndef BOOTLOADER
73/* The PP5020 supports UDMA 4, but it needs cpu boosting and only
74 * improves performance by ~10% with a stock disk.
75 * UDMA 2 is stable at 30 Mhz.
76 * UDMA 1 is stable at 24 Mhz.
77 */
78#if CPUFREQ_NORMAL >= 30000000
79#define ATA_MAX_UDMA 2
80#elif CPUFREQ_NORMAL >= 24000000
81#define ATA_MAX_UDMA 1
82#else
83#error "CPU speeds under 24Mhz have not been tested with DMA"
84#endif
85#else
86/* The bootloader runs at 24 Mhz and needs a slower mode */
87#define ATA_MAX_UDMA 1
88#endif
89
90#endif /* HAVE_ATA_DMA */
91
92#endif /* ATA_TARGET_H */
diff --git a/firmware/target/arm/pp/debug-target.h b/firmware/target/arm/pp/debug-target.h
new file mode 100644
index 0000000000..b7a1f7e5cb
--- /dev/null
+++ b/firmware/target/arm/pp/debug-target.h
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Marcin Bukat
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#if (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
22 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
23 (CONFIG_KEYPAD == IPOD_4G_PAD)
24# define DEBUG_CANCEL BUTTON_MENU
25
26#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
27# define DEBUG_CANCEL BUTTON_REW
28
29#elif (CONFIG_KEYPAD == MROBE100_PAD)
30# define DEBUG_CANCEL BUTTON_MENU
31
32#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
33 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
34 (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD)
35# define DEBUG_CANCEL BUTTON_LEFT
36
37#elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
38 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
39# define DEBUG_CANCEL BUTTON_POWER
40
41#elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
42# define DEBUG_CANCEL BUTTON_PLAY
43
44#elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
45# define DEBUG_CANCEL BUTTON_CANCEL
46#endif
47bool dbg_ports(void);
48bool dbg_hw_info(void);
diff --git a/firmware/target/arm/pp/sd-pp-target.h b/firmware/target/arm/pp/sd-pp-target.h
new file mode 100644
index 0000000000..222daa1a52
--- /dev/null
+++ b/firmware/target/arm/pp/sd-pp-target.h
@@ -0,0 +1,32 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Antonius Hellmann
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef ATA_SD_TARGET_H
22#define ATA_SD_TARGET_H
23
24#ifdef CPU_PP /* PortalPlayer specific functions */
25
26#ifdef HAVE_HOTSWAP
27void microsd_int(void);
28#endif
29
30#endif
31
32#endif
diff --git a/firmware/target/arm/pp/system-target.h b/firmware/target/arm/pp/system-target.h
new file mode 100644
index 0000000000..e7f9ce0245
--- /dev/null
+++ b/firmware/target/arm/pp/system-target.h
@@ -0,0 +1,206 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 * Copyright (C) 2007 by Michael Sevakis
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#ifndef SYSTEM_TARGET_H
23#define SYSTEM_TARGET_H
24
25#include "config.h"
26#include "system-arm.h"
27#include <stdbool.h>
28
29#ifdef CPU_PP
30/* TODO: This header is actually portalplayer specific, and should be
31 * moved into an appropriate subdir (or even split in 2). */
32
33#if CONFIG_CPU == PP5002
34#define CPUFREQ_SLEEP 32768
35#define CPUFREQ_DEFAULT 24000000
36#define CPUFREQ_NORMAL 30000000
37#define CPUFREQ_MAX 80000000
38
39#else /* PP5022, PP5024 */
40#define CPUFREQ_SLEEP 32768
41#define CPUFREQ_DEFAULT 24000000
42#define CPUFREQ_NORMAL 30000000
43#define CPUFREQ_MAX 80000000
44#endif
45
46#define inl(a) (*(volatile unsigned long *) (a))
47#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
48#define inb(a) (*(volatile unsigned char *) (a))
49#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
50#define inw(a) (*(volatile unsigned short *) (a))
51#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
52
53void usb_pin_init(void);
54bool usb_plugged(void);
55void firewire_insert_int(void);
56void usb_insert_int(void);
57
58static inline void udelay(unsigned usecs)
59{
60 unsigned stop = USEC_TIMER + usecs;
61 while (TIME_BEFORE(USEC_TIMER, stop));
62}
63
64static inline unsigned int current_core(void)
65{
66 /*
67 * PROCESSOR_ID seems to be 32-bits:
68 * CPU = 0x55555555 = |01010101|01010101|01010101|01010101|
69 * COP = 0xaaaaaaaa = |10101010|10101010|10101010|10101010|
70 * ^
71 */
72 unsigned int core;
73 asm volatile (
74 "ldrb %0, [%1] \n" /* Just load the LSB */
75 "mov %0, %0, lsr #7 \n" /* Bit 7 => index */
76 : "=r"(core) /* CPU=0, COP=1 */
77 : "r"(&PROCESSOR_ID)
78 );
79 return core;
80}
81
82/* Return the actual ID instead of core index */
83static inline unsigned int processor_id(void)
84{
85 unsigned int id;
86
87 asm volatile (
88 "ldrb %0, [%1] \n"
89 : "=r"(id)
90 : "r"(&PROCESSOR_ID)
91 );
92
93 return id;
94}
95
96#if CONFIG_CPU == PP5002
97static inline void sleep_core(int core)
98{
99 asm volatile (
100 /* Sleep: PP5002 crashes if the instruction that puts it to sleep is
101 * located at 0xNNNNNNN0. 4/8/C works. This sequence makes sure
102 * that the correct alternative is executed. Don't change the order
103 * of the next 4 instructions! */
104 "tst pc, #0x0c \n"
105 "mov r0, #0xca \n"
106 "strne r0, [%[ctl]] \n"
107 "streq r0, [%[ctl]] \n"
108 "nop \n" /* nop's needed because of pipeline */
109 "nop \n"
110 "nop \n"
111 :
112 : [ctl]"r"(&PROC_CTL(core))
113 : "r0"
114 );
115}
116static inline void wake_core(int core)
117{
118 asm volatile (
119 "mov r0, #0xce \n"
120 "str r0, [%[ctl]] \n"
121 :
122 : [ctl]"r"(&PROC_CTL(core))
123 : "r0"
124 );
125}
126#else /* PP502x */
127static inline void sleep_core(int core)
128{
129 asm volatile (
130 "mov r0, #0x80000000 \n"
131 "str r0, [%[ctl]] \n"
132 "nop \n"
133 :
134 : [ctl]"r"(&PROC_CTL(core))
135 : "r0"
136 );
137}
138static inline void wake_core(int core)
139{
140 asm volatile (
141 "mov r0, #0 \n"
142 "str r0, [%[ctl]] \n"
143 :
144 : [ctl]"r"(&PROC_CTL(core))
145 : "r0"
146 );
147}
148#endif
149
150void commit_dcache(void);
151void commit_discard_dcache(void);
152void commit_discard_idcache(void);
153
154#if defined(BOOTLOADER) && !defined(HAVE_BOOTLOADER_USB_MODE)
155/* All addresses within rockbox are in IRAM in the bootloader so
156 are therefore uncached */
157#define UNCACHED_ADDR(a) (a)
158
159#else /* !BOOTLOADER */
160
161#if CONFIG_CPU == PP5002
162#define UNCACHED_BASE_ADDR 0x28000000
163#else /* PP502x */
164#define UNCACHED_BASE_ADDR 0x10000000
165#endif
166
167#define UNCACHED_ADDR(a) \
168 ((typeof (a))((uintptr_t)(a) | UNCACHED_BASE_ADDR))
169#endif /* BOOTLOADER */
170
171#if defined(CPU_PP502x) && defined(HAVE_ATA_DMA)
172#define STORAGE_WANTS_ALIGN
173#endif
174
175#if defined(IPOD_VIDEO) && !defined(BOOTLOADER)
176extern unsigned char probed_ramsize;
177int battery_default_capacity(void);
178#endif
179
180
181#ifdef BOOTLOADER
182#if defined(TATUNG_TPJ1022)
183 /* Some targets don't like yielding in the bootloader - force
184 * yield() to return without a context switch. */
185#define YIELD_KERNEL_HOOK() true
186#endif
187
188#ifdef HAVE_BOOTLOADER_USB_MODE
189void tick_stop(void);
190void system_prepare_fw_start(void);
191
192#else /* !HAVE_BOOTLOADER_USB_MODE */
193
194 /* Busy "sleep" without a tick */
195#define SLEEP_KERNEL_HOOK(ticks) \
196 ({ unsigned _stop = USEC_TIMER + ((ticks) + 1) * (1000000/HZ); \
197 while (TIME_BEFORE(USEC_TIMER, _stop)) \
198 switch_thread(); \
199 true; })
200#endif /* HAVE_BOOTLOADER_USB_MODE */
201
202#endif /* BOOTLOADER */
203
204#endif /* CPU_PP */
205
206#endif /* SYSTEM_TARGET_H */