summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pnx0101
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pnx0101')
-rw-r--r--firmware/target/arm/pnx0101/app.lds144
-rw-r--r--firmware/target/arm/pnx0101/backlight-target.h28
-rw-r--r--firmware/target/arm/pnx0101/crt0-pnx0101.S225
-rw-r--r--firmware/target/arm/pnx0101/debug-pnx0101.c5
-rw-r--r--firmware/target/arm/pnx0101/i2c-pnx0101.c24
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c59
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h31
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c35
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c90
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h49
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c224
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c76
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c55
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h36
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c49
-rw-r--r--firmware/target/arm/pnx0101/kernel-pnx0101.c45
-rw-r--r--firmware/target/arm/pnx0101/pcm-pnx0101.c207
-rw-r--r--firmware/target/arm/pnx0101/system-pnx0101.c317
-rw-r--r--firmware/target/arm/pnx0101/timer-pnx0101.c81
19 files changed, 0 insertions, 1780 deletions
diff --git a/firmware/target/arm/pnx0101/app.lds b/firmware/target/arm/pnx0101/app.lds
deleted file mode 100644
index f14ef90129..0000000000
--- a/firmware/target/arm/pnx0101/app.lds
+++ /dev/null
@@ -1,144 +0,0 @@
1#include "config.h"
2
3ENTRY(start)
4
5OUTPUT_FORMAT(elf32-littlearm)
6OUTPUT_ARCH(arm)
7STARTUP(target/arm/pnx0101/crt0-pnx0101.o)
8
9#define PLUGINSIZE PLUGIN_BUFFER_SIZE
10#define CODECSIZE CODEC_SIZE
11
12#ifdef DEBUG
13#define STUBOFFSET 0x10000
14#else
15#define STUBOFFSET 0
16#endif
17
18#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
19
20#define DRAMORIG 0xc00000 + STUBOFFSET
21#define IRAM0ORIG 0x000000
22#define IRAM0SIZE 0x7000
23#define IRAMORIG 0x400000
24#define IRAMSIZE 0x7000
25
26/* End of the audio buffer, where the codec buffer starts */
27#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
28
29/* Where the codec buffer ends, and the plugin buffer starts */
30#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
31
32MEMORY
33{
34 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
35 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
36 IRAM0 : ORIGIN = IRAM0ORIG, LENGTH = IRAM0SIZE
37}
38
39SECTIONS
40{
41 .text :
42 {
43 loadaddress = .;
44 _loadaddress = .;
45 . = ALIGN(0x200);
46 *(.init.text)
47 *(.text*)
48 *(.glue_7)
49 *(.glue_7t)
50 . = ALIGN(0x4);
51 } > DRAM
52
53 .rodata :
54 {
55 *(.rodata) /* problems without this, dunno why */
56 *(.rodata*)
57 *(.rodata.str1.1)
58 *(.rodata.str1.4)
59 . = ALIGN(0x4);
60 } > DRAM
61
62 .data :
63 {
64 *(.data*)
65 . = ALIGN(0x4);
66 } > DRAM
67
68 /DISCARD/ :
69 {
70 *(.eh_frame)
71 }
72
73 .vectors 0x0 :
74 {
75 _vectorsstart = .;
76 KEEP(*(.vectors));
77 _vectorsend = .;
78 *(.dmabuf)
79 } >IRAM0 AT> DRAM
80
81 _vectorscopy = LOADADDR(.vectors);
82
83 .iram IRAMORIG + SIZEOF(.vectors) :
84 {
85 _iramstart = .;
86 *(.icode)
87 *(.irodata)
88 *(.idata)
89 . = ALIGN(0x4);
90 _iramend = .;
91 } > IRAM AT> DRAM
92
93 _iramcopy = LOADADDR(.iram);
94
95 .ibss (NOLOAD) :
96 {
97 _iedata = .;
98 *(.ibss)
99 . = ALIGN(0x4);
100 _iend = .;
101 } > IRAM
102
103 .stack :
104 {
105 *(.stack)
106 stackbegin = .;
107 . += 0x2000;
108 stackend = .;
109 } > IRAM
110
111 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors):
112 {
113 _edata = .;
114 *(.bss*)
115 *(COMMON)
116 . = ALIGN(0x4);
117 _end = .;
118 } > DRAM
119
120 .audiobuf ALIGN(4) :
121 {
122 _audiobuffer = .;
123 audiobuffer = .;
124 } > DRAM
125
126 .audiobufend ENDAUDIOADDR:
127 {
128 audiobufend = .;
129 _audiobufend = .;
130 } > DRAM
131
132 .codec ENDAUDIOADDR:
133 {
134 codecbuf = .;
135 _codecbuf = .;
136 }
137
138 .plugin ENDADDR:
139 {
140 _pluginbuf = .;
141 pluginbuf = .;
142 }
143}
144
diff --git a/firmware/target/arm/pnx0101/backlight-target.h b/firmware/target/arm/pnx0101/backlight-target.h
deleted file mode 100644
index 7ebe85d66f..0000000000
--- a/firmware/target/arm/pnx0101/backlight-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: backlight-target.h 13136 2007-04-12 22:12:13Z amiconn $
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#ifndef BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24#define backlight_hw_init() true
25void backlight_hw_on(void);
26void backlight_hw_off(void);
27
28#endif
diff --git a/firmware/target/arm/pnx0101/crt0-pnx0101.S b/firmware/target/arm/pnx0101/crt0-pnx0101.S
deleted file mode 100644
index 51be8c72a3..0000000000
--- a/firmware/target/arm/pnx0101/crt0-pnx0101.S
+++ /dev/null
@@ -1,225 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: crt0.S 11850 2006-12-29 02:49:12Z markun $
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#define ASM /* do not include structure definitions from pnx0101.h */
22
23#include "config.h"
24#include "cpu.h"
25
26 .section .init.text,"ax",%progbits
27
28 .global start
29start:
30
31/* Arm bootloader and startup code based on startup.s from the iPodLinux loader
32 *
33 * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
34 * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
35 *
36 */
37
38 msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */
39
40#ifndef BOOTLOADER
41#ifndef DEBUG
42 ldr r0, =0x80105000
43 mov r1, #1
44 str r1, [r0, #4]
45 mov r1, #0
46 str r1, [r0, #4]
471: ldr r1, [r0]
48 cmp r1, #0
49 bne 1b
50 mov r1, #0x74
51 str r1, [r0, #8]
52 mov r1, #2
53 str r1, [r0, #0x18]
54 mov r1, #2
55 str r1, [r0, #0x20]
56 mov r1, #82
57 str r1, [r0, #0x28]
58 mov r1, #100
59 str r1, [r0, #0x2c]
60 mov r1, #0x120
61 str r1, [r0, #0x30]
62 mov r1, #6
63 str r1, [r0, #4]
64 ldr r0, =1f
65 mov r15, r0
661:
67#endif /* !DEBUG */
68
69#ifndef DEBUG
70 /* Copy exception handler code to address 0 */
71 ldr r2, =_vectorsstart
72 ldr r3, =_vectorsend
73 ldr r4, =_vectorscopy
741:
75 cmp r3, r2
76 ldrhi r5, [r4], #4
77 strhi r5, [r2], #4
78 bhi 1b
79#else
80 ldr r1, =vectors
81 ldr r0, =irq_handler
82 str r0, [r1, #24]
83 ldr r0, =fiq_handler
84 str r0, [r1, #28]
85#endif
86
87#ifndef STUB
88 /* Zero out IBSS */
89 ldr r2, =_iedata
90 ldr r3, =_iend
91 mov r4, #0
921:
93 cmp r3, r2
94 strhi r4, [r2], #4
95 bhi 1b
96
97 /* Copy the IRAM */
98 ldr r2, =_iramcopy
99 ldr r3, =_iramstart
100 ldr r4, =_iramend
1011:
102 cmp r4, r3
103 ldrhi r5, [r2], #4
104 strhi r5, [r3], #4
105 bhi 1b
106#endif /* !STUB */
107#endif /* !BOOTLOADER */
108
109 /* Initialise bss section to zero */
110 ldr r2, =_edata
111 ldr r3, =_end
112 mov r4, #0
1131:
114 cmp r3, r2
115 strhi r4, [r2], #4
116 bhi 1b
117
118 /* Set up stack for IRQ mode */
119 msr cpsr_c, #0xd2
120 ldr sp, =irq_stack
121 /* Set up stack for FIQ mode */
122 msr cpsr_c, #0xd1
123 ldr sp, =fiq_stack
124
125 /* Let svc, abort and undefined modes use irq stack */
126 msr cpsr_c, #0xd3
127 ldr sp =irq_stack
128 msr cpsr_c, #0xd7
129 ldr sp, =irq_stack
130 msr cpsr_c, #0xdb
131 ldr sp, =irq_stack
132
133 /* Switch to sys mode */
134 msr cpsr_c, #0xdf
135
136 /* Set up some stack and munge it with 0xdeadbeef */
137 ldr sp, =stackend
138 mov r3, sp
139 ldr r2, =stackbegin
140 ldr r4, =0xdeadbeef
1411:
142 cmp r3, r2
143 strhi r4, [r2], #4
144 bhi 1b
145
146 bl main
147 /* main() should never return */
148
149/* Exception handlers. Will be copied to address 0 after memory remapping */
150 .section .vectors,"aw"
151 ldr pc, [pc, #24]
152 ldr pc, [pc, #24]
153 ldr pc, [pc, #24]
154 ldr pc, [pc, #24]
155 ldr pc, [pc, #24]
156 ldr pc, [pc, #24]
157 ldr pc, [pc, #24]
158 ldr pc, [pc, #24]
159
160 /* Exception vectors */
161 .global vectors
162vectors:
163 .word start
164 .word undef_instr_handler
165 .word software_int_handler
166 .word prefetch_abort_handler
167 .word data_abort_handler
168 .word reserved_handler
169 .word irq_handler
170 .word fiq_handler
171
172 .text
173
174/* All illegal exceptions call into UIE with exception address as first
175 parameter. This is calculated differently depending on which exception
176 we're in. Second parameter is exception number, used for a string lookup
177 in UIE.
178 */
179undef_instr_handler:
180 sub r0, lr, #4
181 mov r1, #0
182 b UIE
183
184/* We run sys mode most of the time, and should never see a software
185 exception being thrown. Make it illegal and call UIE.
186 */
187software_int_handler:
188reserved_handler:
189 sub r0, lr, #4
190 mov r1, #4
191 b UIE
192
193prefetch_abort_handler:
194 sub r0, lr, #4
195 mov r1, #1
196 b UIE
197
198fiq_handler:
199 @ Branch straight to FIQ handler in pcm_playback.c. This also handles the
200 @ the correct return sequence.
201 stmfd sp!, {r0-r7, r12, lr}
202 bl fiq
203 ldmfd sp!, {r0-r7, r12, lr}
204 subs pc, lr, #4
205
206irq_handler:
207#ifndef STUB
208 stmfd sp!, {r0-r11, r12, lr}
209 bl irq
210 ldmfd sp!, {r0-r11, r12, lr}
211#endif
212 subs pc, lr, #4
213
214#ifdef STUB
215UIE:
216 b UIE
217#endif
218
219/* 256 words of IRQ stack */
220 .space 256*4
221irq_stack:
222
223/* 256 words of FIQ stack */
224 .space 256*4
225fiq_stack:
diff --git a/firmware/target/arm/pnx0101/debug-pnx0101.c b/firmware/target/arm/pnx0101/debug-pnx0101.c
deleted file mode 100644
index 8dae2e4925..0000000000
--- a/firmware/target/arm/pnx0101/debug-pnx0101.c
+++ /dev/null
@@ -1,5 +0,0 @@
1#include <stdbool.h>
2bool dbg_ports()
3{
4 return false;
5}
diff --git a/firmware/target/arm/pnx0101/i2c-pnx0101.c b/firmware/target/arm/pnx0101/i2c-pnx0101.c
deleted file mode 100644
index eaf1e79500..0000000000
--- a/firmware/target/arm/pnx0101/i2c-pnx0101.c
+++ /dev/null
@@ -1,24 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Tomasz Malesinski
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
22void i2c_init(void)
23{
24}
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c
deleted file mode 100644
index 0f306f9986..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c
+++ /dev/null
@@ -1,59 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include "system.h"
24#include "kernel.h"
25#include "thread.h"
26#include "adc.h"
27
28static unsigned short adcdata[NUM_ADC_CHANNELS];
29
30unsigned short adc_read(int channel)
31{
32 return adcdata[channel];
33}
34
35static void adc_tick(void)
36{
37 if (ADCST & 0x10) {
38 adcdata[0] = ADCCH0 & 0x3ff;
39 adcdata[1] = ADCCH1 & 0x3ff;
40 adcdata[2] = ADCCH2 & 0x3ff;
41 adcdata[3] = ADCCH3 & 0x3ff;
42 adcdata[4] = ADCCH4 & 0x3ff;
43 ADCST = 0xa;
44 }
45}
46
47void adc_init(void)
48{
49 ADCR24 = 0xaaaaa;
50 ADCR28 = 0;
51 ADCST = 2;
52 ADCST = 0xa;
53
54 while (!(ADCST & 0x10));
55 adc_tick();
56
57 tick_add_task(adc_tick);
58}
59
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h
deleted file mode 100644
index a18aa77c7e..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h
+++ /dev/null
@@ -1,31 +0,0 @@
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#ifndef _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#define NUM_ADC_CHANNELS 5
25
26#define ADC_BUTTONS 0
27#define ADC_BATTERY 1
28#define ADC_BUTTON_PLAY 2
29#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
30
31#endif
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c
deleted file mode 100644
index 8be7a59de2..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c
+++ /dev/null
@@ -1,35 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include "system.h"
24#include "backlight.h"
25#include "lcd.h"
26
27void backlight_hw_on(void)
28{
29 GPIO3_SET = 1;
30}
31
32void backlight_hw_off(void)
33{
34 GPIO3_CLR = 1;
35}
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
deleted file mode 100644
index 45f9fae478..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
+++ /dev/null
@@ -1,90 +0,0 @@
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
23#include <stdlib.h>
24#include "config.h"
25#include "cpu.h"
26#include "system.h"
27#include "button.h"
28#include "kernel.h"
29#include "backlight.h"
30#include "adc.h"
31
32
33void button_init_device(void)
34{
35
36}
37
38bool button_hold(void)
39{
40 return (GPIO5_READ & 4) ? false : true;
41}
42
43/*
44 * Get button pressed from hardware
45 */
46int button_read_device(void)
47{
48 int btn = BUTTON_NONE;
49 int data;
50 static bool hold_button = false;
51 bool hold_button_old;
52
53 /* normal buttons */
54 hold_button_old = hold_button;
55 hold_button = button_hold();
56
57 if (hold_button != hold_button_old)
58 backlight_hold_changed(hold_button);
59
60 if (!button_hold())
61 {
62 data = adc_read(ADC_BUTTONS);
63 if (data < 0x35c)
64 {
65 if (data < 0x151)
66 if (data < 0xc7)
67 if (data < 0x41)
68 btn = BUTTON_LEFT;
69 else
70 btn = BUTTON_RIGHT;
71 else
72 btn = BUTTON_SELECT;
73 else
74 if (data < 0x268)
75 if (data < 0x1d7)
76 btn = BUTTON_UP;
77 else
78 btn = BUTTON_DOWN;
79 else
80 if (data < 0x2f9)
81 btn = BUTTON_EQ;
82 else
83 btn = BUTTON_MODE;
84 }
85
86 if (adc_read(ADC_BUTTON_PLAY) < 0x64)
87 btn |= BUTTON_PLAY;
88 }
89 return btn;
90}
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h
deleted file mode 100644
index 6932b8956f..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h
+++ /dev/null
@@ -1,49 +0,0 @@
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/* Custom written for the ifp7xx */
23
24#ifndef _BUTTON_TARGET_H_
25#define _BUTTON_TARGET_H_
26
27#define HAS_BUTTON_HOLD
28
29/* iriver IFP7XX specific button codes */
30
31#define BUTTON_PLAY 0x00000001
32#define BUTTON_SELECT 0x00000002
33
34#define BUTTON_LEFT 0x00000004
35#define BUTTON_RIGHT 0x00000008
36#define BUTTON_UP 0x00000010
37#define BUTTON_DOWN 0x00000020
38
39#define BUTTON_MODE 0x00000040
40#define BUTTON_EQ 0x00000080
41
42#define BUTTON_MAIN (BUTTON_PLAY|BUTTON_SELECT\
43 |BUTTON_LEFT|BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN\
44 |BUTTON_MODE|BUTTON_EQ)
45
46#define POWEROFF_BUTTON BUTTON_PLAY
47#define POWEROFF_COUNT 40
48
49#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c
deleted file mode 100644
index 1ad604d50c..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c
+++ /dev/null
@@ -1,224 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
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#include "config.h"
22
23#include "kernel.h"
24#include "lcd.h"
25#include "system.h"
26
27/*** definitions ***/
28
29#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
30#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
31#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
32#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
33#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
34#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
35#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
36#define LCD_SET_LCD_BIAS ((char)0xA2)
37#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
38#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
39#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
40#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
41#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
42#define LCD_SET_BIAS_TC_OSC ((char)0xA9)
43#define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA)
44#define LCD_SET_INDICATOR_OFF ((char)0xAC)
45#define LCD_SET_INDICATOR_ON ((char)0xAD)
46#define LCD_SET_DISPLAY_OFF ((char)0xAE)
47#define LCD_SET_DISPLAY_ON ((char)0xAF)
48#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
49#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
50#define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2)
51#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
52#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
53#define LCD_SOFTWARE_RESET ((char)0xE2)
54#define LCD_NOP ((char)0xE3)
55#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
56
57/* LCD command codes */
58#define LCD_CNTL_RESET 0xe2 /* Software reset */
59#define LCD_CNTL_POWER 0x2f /* Power control */
60#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
61#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
62#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
63#define LCD_CNTL_DISPON 0xaf /* Display on */
64
65#define LCD_CNTL_PAGE 0xb0 /* Page address */
66#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
67#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
68
69/*** driver routines ***/
70
71void lcd_write_command(int cmd)
72{
73 while ((LCDSTAT & 3) != 3);
74 LCDCMD = cmd;
75}
76
77void lcd_write_data( const unsigned char* data, int count )
78{
79 int i;
80 for (i=0; i < count; i++) {
81 while ((LCDSTAT & 3) != 3);
82 LCDDATA = data[i];
83 }
84}
85
86/*** hardware configuration ***/
87
88int lcd_default_contrast(void)
89{
90 return 45;
91}
92
93void lcd_set_contrast(int val)
94{
95 lcd_write_command(LCD_CNTL_CONTRAST);
96 lcd_write_command(val);
97}
98
99void lcd_set_invert_display(bool yesno)
100{
101 if (yesno)
102 lcd_write_command(LCD_SET_REVERSE_DISPLAY);
103 else
104 lcd_write_command(LCD_SET_NORMAL_DISPLAY);
105}
106
107/* turn the display upside down (call lcd_update() afterwards) */
108void lcd_set_flip(bool yesno)
109{
110 if (yesno)
111 {
112 lcd_write_command(LCD_SET_SEGMENT_REMAP);
113 lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION);
114 }
115 else
116 {
117 lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01);
118 lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08);
119 }
120}
121
122void lcd_init_device(void)
123{
124 LCDREG10 = 0xf;
125 LCDREG04 = 0x4084;
126
127 /* inits like the original firmware */
128 lcd_write_command(LCD_SOFTWARE_RESET);
129 lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 4);
130 lcd_write_command(LCD_SET_LCD_BIAS);
131 lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7);
132 /* power control register: op-amp=1, regulator=1, booster=1 */
133 lcd_write_command(LCD_SET_DISPLAY_ON);
134 lcd_write_command(LCD_SET_NORMAL_DISPLAY);
135 lcd_set_flip(false);
136 lcd_write_command(LCD_SET_DISPLAY_START_LINE + 0);
137 lcd_set_contrast(lcd_default_contrast());
138 lcd_write_command(LCD_SET_PAGE_ADDRESS);
139 lcd_write_command(LCD_SET_LOWER_COLUMN_ADDRESS + 0);
140 lcd_write_command(LCD_SET_HIGHER_COLUMN_ADDRESS + 0);
141
142 lcd_clear_display();
143 lcd_update();
144}
145
146/*** Update functions ***/
147
148/* Performance function that works with an external buffer
149 note that by and bheight are in 8-pixel units! */
150void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
151 int bheight, int stride)
152{
153 /* Copy display bitmap to hardware */
154 while (bheight--)
155 {
156 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
157 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4)>>4) & 0xf));
158 lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf));
159
160 lcd_write_data(data, width);
161 data += stride;
162 }
163}
164
165
166/* Performance function that works with an external buffer
167 note that by and bheight are in 8-pixel units! */
168void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
169 int x, int by, int width, int bheight, int stride)
170{
171 (void)values;
172 (void)phases;
173 (void)x;
174 (void)by;
175 (void)width;
176 (void)bheight;
177 (void)stride;
178}
179
180/* Update the display.
181 This must be called after all other LCD functions that change the display. */
182void lcd_update(void) ICODE_ATTR;
183void lcd_update(void)
184{
185 int y;
186
187 /* Copy display bitmap to hardware */
188 for (y = 0; y < LCD_FBHEIGHT; y++)
189 {
190 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
191 lcd_write_command (LCD_CNTL_HIGHCOL);
192 lcd_write_command (LCD_CNTL_LOWCOL | 4);
193
194 lcd_write_data (FBADDR(0, y), LCD_WIDTH);
195 }
196}
197
198/* Update a fraction of the display. */
199void lcd_update_rect(int, int, int, int) ICODE_ATTR;
200void lcd_update_rect(int x, int y, int width, int height)
201{
202 int ymax;
203
204 /* The Y coordinates have to work on even 8 pixel rows */
205 ymax = (y + height-1) >> 3;
206 y >>= 3;
207
208 if(x + width > LCD_WIDTH)
209 width = LCD_WIDTH - x;
210 if (width <= 0)
211 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
212 if(ymax >= LCD_FBHEIGHT)
213 ymax = LCD_FBHEIGHT-1;
214
215 /* Copy specified rectange bitmap to hardware */
216 for (; y <= ymax; y++)
217 {
218 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
219 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4) >> 4) & 0xf));
220 lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf));
221
222 lcd_write_data (FBADDR(x,y), width);
223 }
224}
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c
deleted file mode 100644
index 1fd9d68028..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27#include "logf.h"
28#include "usb.h"
29
30#if CONFIG_TUNER
31
32bool tuner_power(bool status)
33{
34 (void)status;
35 return true;
36}
37
38#endif /* #if CONFIG_TUNER */
39
40#ifndef SIMULATOR
41
42void power_init(void)
43{
44}
45
46void ide_power_enable(bool on)
47{
48 (void)on;
49 /* no ide controller */
50}
51
52bool ide_powered(void)
53{
54 return true; /* pretend always powered if not controlable */
55}
56
57void power_off(void)
58{
59 disable_interrupt(IRQ_FIQ_STATUS);
60 GPIO1_CLR = 1 << 16;
61 GPIO2_SET = 1;
62 while(1);
63}
64
65#else
66
67void power_off(void)
68{
69}
70
71void ide_power_enable(bool on)
72{
73 (void)on;
74}
75
76#endif /* SIMULATOR */
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
deleted file mode 100644
index 4ce90a4c4f..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 * Revisions copyright (C) 2005 by Gerald Van Baren
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
23#include "config.h"
24#include "adc.h"
25#include "powermgmt.h"
26
27const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
28{
29 1050, 1150
30};
31
32const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
33{
34 1050, 1150 /* FIXME: just copied from above, was missing in powermgmt.c */
35};
36
37/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
38const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
39{
40 /* These values are the same as for Ondio divided by 3. */
41 /* May need recalibration. */
42 { 930, 1080, 1140, 1180, 1210, 1250, 1280, 1320, 1360, 1420, 1580 }, /* alkaline */
43 { 1030, 1180, 1210, 1230, 1240, 1250, 1260, 1270, 1280, 1290, 1350 } /* NiMH */
44};
45
46/* TODO: only roughly correct */
47#define BATTERY_SCALE_FACTOR 3072
48/* full-scale ADC readout (2^10) in millivolt */
49
50/* Returns battery voltage from ADC [millivolts] */
51int _battery_voltage(void)
52{
53 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
54}
55
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h
deleted file mode 100644
index 9aad4a7b74..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
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 SYSTEM_TARGET_H
22#define SYSTEM_TARGET_H
23
24#include "system-arm.h"
25
26#define CPUFREQ_DEFAULT 12000000
27#define CPUFREQ_NORMAL 48000000
28#define CPUFREQ_MAX 60000000
29
30typedef void (*interrupt_handler_t)(void);
31
32void irq_set_int_handler(int n, interrupt_handler_t handler);
33void irq_enable_int(int n);
34void irq_disable_int(int n);
35
36#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
deleted file mode 100644
index 0bfcdf3b1a..0000000000
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
+++ /dev/null
@@ -1,49 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include "kernel.h"
24#include "thread.h"
25#include "system.h"
26#include "debug.h"
27#include "ata.h"
28#include "disk.h"
29#include "panic.h"
30#include "lcd.h"
31#include "usb.h"
32#include "button.h"
33#include "string.h"
34
35void usb_init_device(void)
36{
37}
38
39int usb_detect(void)
40{
41 /* TODO: Implement USB_ISP1582 */
42 return USB_EXTRACTED;
43}
44
45void usb_enable(bool on)
46{
47 /* TODO: Implement USB_ISP1582 */
48 (void)on;
49}
diff --git a/firmware/target/arm/pnx0101/kernel-pnx0101.c b/firmware/target/arm/pnx0101/kernel-pnx0101.c
deleted file mode 100644
index db0f1b0d7f..0000000000
--- a/firmware/target/arm/pnx0101/kernel-pnx0101.c
+++ /dev/null
@@ -1,45 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Tomasz Malesinski
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#include "config.h"
22#include "system.h"
23#include "kernel.h"
24
25void timer_handler(void)
26{
27 /* Run through the list of tick tasks */
28 call_tick_tasks();
29
30 TIMER0.clr = 0;
31}
32
33void tick_start(unsigned int interval_in_ms)
34{
35 TIMER0.ctrl &= ~0x80; /* Disable the counter */
36 TIMER0.ctrl |= 0x40; /* Reload after counting down to zero */
37 TIMER0.load = 3000000 * interval_in_ms / 1000;
38 TIMER0.ctrl &= ~0xc; /* No prescaler */
39 TIMER0.clr = 1; /* Clear the interrupt request */
40
41 irq_set_int_handler(IRQ_TIMER0, timer_handler);
42 irq_enable_int(IRQ_TIMER0);
43
44 TIMER0.ctrl |= 0x80; /* Enable the counter */
45}
diff --git a/firmware/target/arm/pnx0101/pcm-pnx0101.c b/firmware/target/arm/pnx0101/pcm-pnx0101.c
deleted file mode 100644
index 6099dcb7ef..0000000000
--- a/firmware/target/arm/pnx0101/pcm-pnx0101.c
+++ /dev/null
@@ -1,207 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Tomek Malesinski
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#include "system.h"
22#include "audio.h"
23#include "string.h"
24#include "pcm-internal.h"
25
26#define DMA_BUF_SAMPLES 0x100
27
28short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES];
29short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES];
30
31const int16_t* p IBSS_ATTR;
32size_t p_size IBSS_ATTR;
33
34void pcm_play_lock(void)
35{
36}
37
38void pcm_play_unlock(void)
39{
40}
41
42void pcm_play_dma_start(const void *addr, size_t size)
43{
44 p = addr;
45 p_size = size;
46}
47
48void pcm_play_dma_stop(void)
49{
50}
51
52static inline void fill_dma_buf(int offset)
53{
54 short *l, *r, *lend;
55
56 l = dma_buf_left + offset;
57 lend = l + DMA_BUF_SAMPLES / 2;
58 r = dma_buf_right + offset;
59
60 if (pcm_playing)
61 {
62 bool new_buffer =false;
63
64 do
65 {
66 int count;
67 const int16_t *tmp_p;
68 count = MIN(p_size / 4, (size_t)(lend - l));
69 tmp_p = p;
70 p_size -= count * 4;
71
72 if ((int)l & 3)
73 {
74 *l++ = *tmp_p++;
75 *r++ = *tmp_p++;
76 count--;
77 }
78 while (count >= 4)
79 {
80 asm("ldmia %0!, {r0, r1, r2, r3}\n\t"
81 "and r4, r0, %3\n\t"
82 "orr r4, r4, r1, lsl #16\n\t"
83 "and r5, r2, %3\n\t"
84 "orr r5, r5, r3, lsl #16\n\t"
85 "stmia %1!, {r4, r5}\n\t"
86 "bic r4, r1, %3\n\t"
87 "orr r4, r4, r0, lsr #16\n\t"
88 "bic r5, r3, %3\n\t"
89 "orr r5, r5, r2, lsr #16\n\t"
90 "stmia %2!, {r4, r5}"
91 : "+r" (tmp_p), "+r" (l), "+r" (r)
92 : "r" (0xffff)
93 : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
94 count -= 4;
95 }
96 while (count > 0)
97 {
98 *l++ = *tmp_p++;
99 *r++ = *tmp_p++;
100 count--;
101 }
102 p = tmp_p;
103
104 if (new_buffer)
105 {
106 new_buffer = false;
107 pcm_play_dma_status_callback(PCM_DMAST_STARTED);
108 }
109
110 if (l >= lend)
111 return;
112
113 new_buffer = pcm_play_dma_complete_callback(PCM_DMAST_OK,
114 &p, &p_size);
115 }
116 while (p_size);
117 }
118
119 if (l < lend)
120 {
121 memset(l, 0, sizeof(short) * (lend - l));
122 memset(r, 0, sizeof(short) * (lend - l));
123 }
124}
125
126static void audio_irq(void)
127{
128 unsigned long st = DMAINTSTAT & ~DMAINTEN;
129 int i;
130 for (i = 0; i < 2; i++)
131 if (st & (1 << i))
132 {
133 fill_dma_buf((i == 1) ? 0 : DMA_BUF_SAMPLES / 2);
134 DMAINTSTAT = 1 << i;
135 }
136}
137
138unsigned long physical_address(void *p)
139{
140 unsigned long adr = (unsigned long)p;
141 return (MMUBLOCK((adr >> 21) & 0xf) << 21) | (adr & ((1 << 21) - 1));
142}
143
144void pcm_init(void)
145{
146 int i;
147
148 memset(dma_buf_left, 0, sizeof(dma_buf_left));
149 memset(dma_buf_right, 0, sizeof(dma_buf_right));
150
151 for (i = 0; i < 8; i++)
152 {
153 DMASRC(i) = 0;
154 DMADEST(i) = 0;
155 DMALEN(i) = 0x1ffff;
156 DMAR0C(i) = 0;
157 DMAR10(i) = 0;
158 DMAR1C(i) = 0;
159 }
160
161 DMAINTSTAT = 0xc000ffff;
162 DMAINTEN = 0xc000ffff;
163
164 DMASRC(0) = physical_address(dma_buf_left);
165 DMADEST(0) = 0x80200280;
166 DMALEN(0) = 0xff;
167 DMAR1C(0) = 0;
168 DMAR0C(0) = 0x40408;
169
170 DMASRC(1) = physical_address(dma_buf_right);
171 DMADEST(1) = 0x80200284;
172 DMALEN(1) = 0xff;
173 DMAR1C(1) = 0;
174 DMAR0C(1) = 0x40409;
175
176 irq_set_int_handler(0x1b, audio_irq);
177 irq_enable_int(0x1b);
178
179 DMAINTSTAT = 1;
180 DMAINTSTAT = 2;
181 DMAINTEN &= ~3;
182 DMAR10(0) |= 1;
183 DMAR10(1) |= 1;
184}
185
186void pcm_play_dma_postinit(void)
187{
188 audiohw_postinit();
189}
190
191void pcm_dma_apply_settings(void)
192{
193}
194
195const void * pcm_play_dma_get_peak_buffer(int *count)
196{
197 unsigned long addr = (unsigned long)p;
198 size_t cnt = p_size;
199 *count = cnt >> 2;
200 return (void *)((addr + 2) & ~3);
201}
202
203void audiohw_set_volume(int value)
204{
205 int tmp = (60 - value * 4) & 0xff;
206 CODECVOL = tmp | (tmp << 8);
207}
diff --git a/firmware/target/arm/pnx0101/system-pnx0101.c b/firmware/target/arm/pnx0101/system-pnx0101.c
deleted file mode 100644
index 63720d11be..0000000000
--- a/firmware/target/arm/pnx0101/system-pnx0101.c
+++ /dev/null
@@ -1,317 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Tomasz Malesinski
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#include <stdlib.h>
23#include "pnx0101.h"
24#include "system.h"
25
26static struct
27{
28 unsigned char freq;
29 unsigned char sys_mult;
30 unsigned char sys_div;
31}
32perf_modes[3] ICONST_ATTR =
33{
34 {12, 4, 4},
35 {48, 4, 1},
36 {60, 5, 1}
37};
38
39static int performance_mode, bus_divider;
40
41static void cgu_set_sel_stage_input(int clock, int input)
42{
43 int s = CGU.base_ssr[clock];
44 if (s & 1)
45 CGU.base_fs2[clock] = input;
46 else
47 CGU.base_fs1[clock] = input;
48 CGU.base_scr[clock] = (s & 3) ^ 3;
49}
50
51static void cgu_reset_sel_stage_clocks(int first_esr, int n_esr,
52 int first_div, int n_div)
53{
54 int i;
55 for (i = 0; i < n_esr; i++)
56 CGU.clk_esr[first_esr + i] = 0;
57 for (i = 0; i < n_div; i++)
58 CGU.base_fdc[first_div + i] = 0;
59}
60
61static void cgu_configure_div(int div, int n, int m)
62{
63 int msub, madd, div_size, max_n;
64 unsigned long cfg;
65
66 if (n == m)
67 {
68 CGU.base_fdc[div] = CGU.base_fdc[div] & ~1;
69 return;
70 }
71
72 msub = -n;
73 madd = m - n;
74 div_size = (div == PNX0101_HIPREC_FDC) ? 10 : 8;
75 max_n = 1 << div_size;
76 while ((madd << 1) < max_n && (msub << 1) >= -max_n)
77 {
78 madd <<= 1;
79 msub <<= 1;
80 }
81 cfg = (((msub << div_size) | madd) << 3) | 4;
82 CGU.base_fdc[div] = CGU.base_fdc[div] & ~1;
83 CGU.base_fdc[div] = cfg | 2;
84 CGU.base_fdc[div] = cfg;
85 CGU.base_fdc[div] = cfg | 1;
86}
87
88static void cgu_connect_div_to_clock(int rel_div, int esr)
89{
90 CGU.clk_esr[esr] = (rel_div << 1) | 1;
91}
92
93static void cgu_enable_clock(int clock)
94{
95 CGU.clk_pcr[clock] |= 1;
96}
97
98static void cgu_start_sel_stage_dividers(int bcr)
99{
100 CGU.base_bcr[bcr] = 1;
101}
102
103/* Convert a pointer that points to IRAM (0x4xxxx) to a pointer that
104 points to the uncached page (0x0xxxx) that is also mapped to IRAM. */
105static inline void *noncached(void *p)
106{
107 return (void *)(((unsigned long)p) & 0xffff);
108}
109
110/* To avoid SRAM accesses while changing memory controller settings we
111 run this routine from uncached copy of IRAM. All times are in CPU
112 cycles. At CPU frequencies lower than 60 MHz we could use faster
113 settings, but since DMA may access SRAM at any time, changing
114 memory timings together with CPU frequency would be tricky. */
115static void do_set_mem_timings(void) ICODE_ATTR;
116static void do_set_mem_timings(void)
117{
118 int old_irq = disable_irq_save();
119 while ((EMC.status & 3) != 0);
120 EMC.control = 5;
121 EMCSTATIC0.waitrd = 6;
122 EMCSTATIC0.waitwr = 5;
123 EMCSTATIC1.waitrd = 5;
124 EMCSTATIC1.waitwr = 4; /* OF uses 5 here */
125 EMCSTATIC2.waitrd = 4;
126 EMCSTATIC2.waitwr = 3;
127 EMCSTATIC0.waitoen = 1;
128 EMCSTATIC1.waitoen = 1;
129 EMCSTATIC2.waitoen = 1;
130 /* Enable write buffers for SRAM. */
131#ifndef DEBUG
132 EMCSTATIC1.config = 0x80081;
133#endif
134 EMC.control = 1;
135 restore_irq(old_irq);
136}
137
138static void emc_set_mem_timings(void)
139{
140 void (*f)(void) = noncached(do_set_mem_timings);
141 (*f)();
142}
143
144static void cgu_set_sys_mult(int i)
145{
146 cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS, PNX0101_MAIN_CLOCK_FAST);
147 cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3, PNX0101_MAIN_CLOCK_FAST);
148
149 PLL.lppdn = 1;
150 PLL.lpfin = 1;
151 PLL.lpmbyp = 0;
152 PLL.lpdbyp = 0;
153 PLL.lppsel = 1;
154 PLL.lpmsel = i - 1;
155 PLL.lppdn = 0;
156 while (!PLL.lplock);
157
158 cgu_configure_div(PNX0101_FIRST_DIV_SYS + 1, 1, (i == 5) ? 15 : 12);
159 cgu_connect_div_to_clock(1, 0x11);
160 cgu_enable_clock(0x11);
161 cgu_start_sel_stage_dividers(PNX0101_BCR_SYS);
162
163 cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS,
164 PNX0101_MAIN_CLOCK_MAIN_PLL);
165 cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3,
166 PNX0101_MAIN_CLOCK_MAIN_PLL);
167}
168
169static void pnx0101_set_performance_mode(int mode)
170{
171 int old = performance_mode;
172 if (perf_modes[old].sys_mult != perf_modes[mode].sys_mult)
173 cgu_set_sys_mult(perf_modes[mode].sys_mult);
174 if (perf_modes[old].sys_div != perf_modes[mode].sys_div)
175 cgu_configure_div(bus_divider, 1, perf_modes[mode].sys_div);
176 performance_mode = mode;
177}
178
179static void pnx0101_init_clocks(void)
180{
181 bus_divider = PNX0101_FIRST_DIV_SYS + (CGU.clk_esr[0] >> 1);
182 performance_mode = 0;
183 emc_set_mem_timings();
184 pnx0101_set_performance_mode(2);
185
186 cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB1,
187 PNX0101_MAIN_CLOCK_FAST);
188 cgu_reset_sel_stage_clocks(PNX0101_FIRST_ESR_APB1, PNX0101_N_ESR_APB1,
189 PNX0101_FIRST_DIV_APB1, PNX0101_N_DIV_APB1);
190 cgu_configure_div(PNX0101_FIRST_DIV_APB1, 1, 4);
191 cgu_connect_div_to_clock(0, PNX0101_ESR_APB1);
192 cgu_connect_div_to_clock(0, PNX0101_ESR_T0);
193 cgu_connect_div_to_clock(0, PNX0101_ESR_T1);
194 cgu_connect_div_to_clock(0, PNX0101_ESR_I2C);
195 cgu_enable_clock(PNX0101_CLOCK_APB1);
196 cgu_enable_clock(PNX0101_CLOCK_T0);
197 cgu_enable_clock(PNX0101_CLOCK_T1);
198 cgu_enable_clock(PNX0101_CLOCK_I2C);
199}
200
201#ifdef HAVE_ADJUSTABLE_CPU_FREQ
202void set_cpu_frequency(long frequency)
203{
204 switch (frequency)
205 {
206 case CPUFREQ_MAX:
207 pnx0101_set_performance_mode(2);
208 cpu_frequency = CPUFREQ_MAX;
209 break;
210 case CPUFREQ_NORMAL:
211 pnx0101_set_performance_mode(1);
212 cpu_frequency = CPUFREQ_NORMAL;
213 break;
214 case CPUFREQ_DEFAULT:
215 default:
216 pnx0101_set_performance_mode(0);
217 cpu_frequency = CPUFREQ_DEFAULT;
218 break;
219 }
220
221}
222#endif
223
224interrupt_handler_t interrupt_vector[0x1d] __attribute__ ((section(".idata")));
225
226#define IRQ_READ(reg, dest) \
227 do { unsigned long v2; \
228 do { \
229 dest = (reg); \
230 v2 = (reg); \
231 } while ((dest != v2)); \
232 } while (0);
233
234#define IRQ_WRITE_WAIT(reg, val, cond) \
235 do { unsigned long v, v2; \
236 do { \
237 (reg) = (val); \
238 v = (reg); \
239 v2 = (reg); \
240 } while ((v != v2) || !(cond)); \
241 } while (0);
242
243static void undefined_int(void)
244{
245}
246
247void irq(void)
248{
249 unsigned long n;
250 IRQ_READ(INTVECTOR[0], n)
251 (*(interrupt_vector[n >> 3]))();
252}
253
254void fiq(void)
255{
256}
257
258void irq_enable_int(int n)
259{
260 IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE | INTREQ_ENABLE, v & 0x10000);
261}
262
263void irq_disable_int(int n)
264{
265 IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE, (v & 0x10000) == 0);
266}
267
268void irq_set_int_handler(int n, interrupt_handler_t handler)
269{
270 interrupt_vector[n] = handler;
271}
272
273void system_init(void)
274{
275 int i;
276
277 /* turn off watchdog */
278 (*(volatile unsigned long *)0x80002804) = 0;
279
280 /*
281 IRQ_WRITE_WAIT(INTVECTOR[0], 0, v == 0);
282 IRQ_WRITE_WAIT(INTVECTOR[1], 0, v == 0);
283 IRQ_WRITE_WAIT(INTPRIOMASK[0], 0, v == 0);
284 IRQ_WRITE_WAIT(INTPRIOMASK[1], 0, v == 0);
285 */
286
287 for (i = 1; i <= 0x1c; i++)
288 {
289 IRQ_WRITE_WAIT(INTREQ[i],
290 INTREQ_WEPRIO | INTREQ_WETARGET |
291 INTREQ_WEENABLE | INTREQ_WEACTVLO | 1,
292 (v & 0x3010f) == 1);
293 IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEENABLE, (v & 0x10000) == 0);
294 IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEPRIO | 1, (v & 0xf) == 1);
295 interrupt_vector[i] = undefined_int;
296 }
297 interrupt_vector[0] = undefined_int;
298 pnx0101_init_clocks();
299}
300
301
302void system_reboot(void)
303{
304 (*(volatile unsigned long *)0x80002804) = 1;
305 while (1);
306}
307
308void system_exception_wait(void)
309{
310 while (1);
311}
312
313int system_memory_guard(int newmode)
314{
315 (void)newmode;
316 return 0;
317}
diff --git a/firmware/target/arm/pnx0101/timer-pnx0101.c b/firmware/target/arm/pnx0101/timer-pnx0101.c
deleted file mode 100644
index 1ec1d2871f..0000000000
--- a/firmware/target/arm/pnx0101/timer-pnx0101.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2007 Tomasz Malesinski
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#include "system.h"
23#include "timer.h"
24
25static long cycles_new = 0;
26
27void TIMER1_ISR(void)
28{
29 if (cycles_new > 0)
30 {
31 TIMER1.load = cycles_new - 1;
32 cycles_new = 0;
33 }
34 if (pfn_timer != NULL)
35 {
36 cycles_new = -1;
37 /* "lock" the variable, in case timer_set_period()
38 * is called within pfn_timer() */
39 pfn_timer();
40 cycles_new = 0;
41 }
42 TIMER1.clr = 1; /* clear the interrupt */
43}
44
45bool timer_set(long cycles, bool start)
46{
47 if (start)
48 {
49 if (pfn_unregister != NULL)
50 {
51 pfn_unregister();
52 pfn_unregister = NULL;
53 }
54 TIMER1.ctrl &= ~0x80; /* disable the counter */
55 TIMER1.ctrl |= 0x40; /* reload after counting down to zero */
56 TIMER1.ctrl &= ~0xc; /* no prescaler */
57 TIMER1.clr = 1; /* clear an interrupt event */
58 }
59 if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */
60 { /* enable timer */
61 TIMER1.load = cycles - 1;
62 TIMER1.ctrl |= 0x80; /* enable the counter */
63 }
64 else
65 cycles_new = cycles;
66
67 return true;
68}
69
70bool timer_start(void)
71{
72 irq_set_int_handler(IRQ_TIMER1, TIMER1_ISR);
73 irq_enable_int(IRQ_TIMER1);
74 return true;
75}
76
77void timer_stop(void)
78{
79 TIMER1.ctrl &= ~0x80; /* disable timer 1 */
80 irq_disable_int(IRQ_TIMER1);
81}