summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-05-02 19:12:09 +0000
committerDave Chapman <dave@dchapman.com>2008-05-02 19:12:09 +0000
commitf2042983f08cd49404be0b6916fc73d778fe8dba (patch)
tree33a84414ca4d94770f900e92074c18ecadf23ed7 /firmware/target/arm/tcc77x
parent4cf4b5c2aef075b719e834f30d17c0986fadb658 (diff)
downloadrockbox-f2042983f08cd49404be0b6916fc73d778fe8dba.tar.gz
rockbox-f2042983f08cd49404be0b6916fc73d778fe8dba.zip
Add the Sansa M200 (v1) as a target - it's extremely similar to the Logik DAX (the LCD driver worked unchanged). Plus various tcc77x work, including a working tick interrupt (enabled in the bootloader). Rockbox itself builds for the M200 (there are no keymaps yet for the DAX), but doesn't progress very far due to the lack of an ATA (NAND flash) driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r--firmware/target/arm/tcc77x/app.lds144
-rw-r--r--firmware/target/arm/tcc77x/ata-nand-tcc77x.c10
-rw-r--r--firmware/target/arm/tcc77x/boot.lds8
-rw-r--r--firmware/target/arm/tcc77x/crt0.S124
-rw-r--r--firmware/target/arm/tcc77x/debug-target.h22
-rw-r--r--firmware/target/arm/tcc77x/debug-tcc77x.c81
-rw-r--r--firmware/target/arm/tcc77x/i2c-target.h37
-rw-r--r--firmware/target/arm/tcc77x/kernel-tcc77x.c45
-rw-r--r--firmware/target/arm/tcc77x/lcd-ssd1815.c2
-rw-r--r--firmware/target/arm/tcc77x/m200/adc-target.h26
-rw-r--r--firmware/target/arm/tcc77x/m200/backlight-target.h42
-rw-r--r--firmware/target/arm/tcc77x/m200/button-m200.c97
-rw-r--r--firmware/target/arm/tcc77x/m200/button-target.h52
-rw-r--r--firmware/target/arm/tcc77x/m200/power-m200.c66
-rw-r--r--firmware/target/arm/tcc77x/pcm-tcc77x.c75
-rw-r--r--firmware/target/arm/tcc77x/powermgmt-tcc77x.c64
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c152
-rw-r--r--firmware/target/arm/tcc77x/timer-target.h39
-rw-r--r--firmware/target/arm/tcc77x/timer-tcc77x.c79
-rw-r--r--firmware/target/arm/tcc77x/usb-tcc77x.c36
20 files changed, 1171 insertions, 30 deletions
diff --git a/firmware/target/arm/tcc77x/app.lds b/firmware/target/arm/tcc77x/app.lds
new file mode 100644
index 0000000000..03a427f76b
--- /dev/null
+++ b/firmware/target/arm/tcc77x/app.lds
@@ -0,0 +1,144 @@
1#include "config.h"
2
3ENTRY(start)
4
5OUTPUT_FORMAT(elf32-littlearm)
6OUTPUT_ARCH(arm)
7STARTUP(target/arm/tcc77x/crt0.o)
8
9#define PLUGINSIZE PLUGIN_BUFFER_SIZE
10#define CODECSIZE CODEC_SIZE
11
12#include "imx31l.h"
13
14#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
15
16#define DRAMORIG 0x20000000
17#define IRAMORIG 0x00000000
18#define IRAMSIZE IRAM_SIZE
19
20/* End of the audio buffer, where the codec buffer starts */
21#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
22
23/* Where the codec buffer ends, and the plugin buffer starts */
24#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
25
26MEMORY
27{
28 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
29 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
30}
31
32SECTIONS
33{
34 .text :
35 {
36 loadaddress = .;
37 _loadaddress = .;
38 . = ALIGN(0x200);
39 *(.init.text)
40 *(.text*)
41 *(.glue_7)
42 *(.glue_7t)
43 . = ALIGN(0x4);
44 } > DRAM
45
46 .rodata :
47 {
48 *(.rodata) /* problems without this, dunno why */
49 *(.rodata*)
50 *(.rodata.str1.1)
51 *(.rodata.str1.4)
52 . = ALIGN(0x4);
53
54 /* Pseudo-allocate the copies of the data sections */
55 _datacopy = .;
56 } > DRAM
57
58 /* TRICK ALERT! For RAM execution, we put the .data section at the
59 same load address as the copy. Thus, we don't waste extra RAM
60 when we don't actually need the copy. */
61 .data : AT ( _datacopy )
62 {
63 _datastart = .;
64 *(.data*)
65 . = ALIGN(0x4);
66 _dataend = .;
67 } > DRAM
68
69 /DISCARD/ :
70 {
71 *(.eh_frame)
72 }
73
74 .vectors 0x0 :
75 {
76 _vectorsstart = .;
77 *(.vectors);
78 _vectorsend = .;
79 } AT> DRAM
80
81 _vectorscopy = LOADADDR(.vectors);
82
83 .iram :
84 {
85 _iramstart = .;
86 *(.icode)
87 *(.irodata)
88 *(.idata)
89 . = ALIGN(0x4);
90 _iramend = .;
91 } > DRAM
92
93 _iramcopy = LOADADDR(.iram);
94
95 .ibss (NOLOAD) :
96 {
97 _iedata = .;
98 *(.ibss)
99 . = ALIGN(0x4);
100 _iend = .;
101 } > DRAM
102
103 .stack :
104 {
105 *(.stack)
106 stackbegin = .;
107 . += 0x2000;
108 stackend = .;
109 } > DRAM
110
111 .bss :
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/tcc77x/ata-nand-tcc77x.c b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
index dd0ae7a950..d7ae5d5ed6 100644
--- a/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
+++ b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
@@ -32,6 +32,9 @@ int ata_spinup_time = 0;
32 32
33long last_disk_activity = -1; 33long last_disk_activity = -1;
34 34
35/* Used to store (fake?) identify info */
36static unsigned short identify_info[256];
37
35/** static, private data **/ 38/** static, private data **/
36static bool initialized = false; 39static bool initialized = false;
37 40
@@ -91,4 +94,11 @@ void ata_enable(bool on)
91 94
92int ata_init(void) 95int ata_init(void)
93{ 96{
97 return 0;
98}
99
100/* TEMP: This will return junk, it's here for compilation only */
101unsigned short* ata_get_identify(void)
102{
103 return identify_info;
94} 104}
diff --git a/firmware/target/arm/tcc77x/boot.lds b/firmware/target/arm/tcc77x/boot.lds
index 21fc7db96a..890c4ec785 100644
--- a/firmware/target/arm/tcc77x/boot.lds
+++ b/firmware/target/arm/tcc77x/boot.lds
@@ -10,16 +10,11 @@ STARTUP(target/arm/tcc77x/crt0.o)
10#define DRAMORIG 0x20000000 10#define DRAMORIG 0x20000000
11#define IRAMORIG 0x00000000 11#define IRAMORIG 0x00000000
12#define IRAMSIZE 64K 12#define IRAMSIZE 64K
13#define FLASHORIG 0x0000000 13
14#define FLASHSIZE 1M
15 14
16MEMORY 15MEMORY
17{ 16{
18#ifdef TCCBOOT
19 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 17 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
20#else
21 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
22#endif
23 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE 18 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
24} 19}
25 20
@@ -52,6 +47,7 @@ SECTIONS
52 _stackend = .; 47 _stackend = .;
53 stackend = .; 48 stackend = .;
54 } > DRAM 49 } > DRAM
50
55 .bss : { 51 .bss : {
56 _edata = .; 52 _edata = .;
57 *(.bss*); 53 *(.bss*);
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
index e4ecb05a4e..246d02a1d7 100644
--- a/firmware/target/arm/tcc77x/crt0.S
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -29,6 +29,11 @@
29 29
30 .section .init.text,"ax",%progbits 30 .section .init.text,"ax",%progbits
31 31
32 .extern irq
33 .extern fiq
34 .extern UIE
35 .extern main
36
32 .global start 37 .global start
33 38
34/* Telechips firmware files start with a 32-byte header, as part of the code. */ 39/* Telechips firmware files start with a 32-byte header, as part of the code. */
@@ -44,7 +49,8 @@ start:
44 .word 0 /* Saved entrypoint of original firmware*/ 49 .word 0 /* Saved entrypoint of original firmware*/
45 .word 0 /* Location in RAM of the start of our bootloader */ 50 .word 0 /* Location in RAM of the start of our bootloader */
46#else 51#else
47 ldr pc, =start_loc /* jump to the main entry point */ 52// ldr pc, =start_loc /* jump to the main entry point */
53 b start_loc
48 54
49 .word 0xffff0601 /* Unknown magic */ 55 .word 0xffff0601 /* Unknown magic */
50 .word 0x3a726556 /* "Ver:" */ 56 .word 0x3a726556 /* "Ver:" */
@@ -65,21 +71,40 @@ start:
65start_loc: 71start_loc:
66 72
67#ifdef BOOTLOADER 73#ifdef BOOTLOADER
74
75/*
76 If we are appended to the OF (i.e. dual-booting), do a simple GPIO
77 button check, and branch to the OF's entry point (saved by mktccboot)
78 if not active
79*/
80
68#ifdef TCCBOOT 81#ifdef TCCBOOT
69#ifdef LOGIK_DAX
70 mov r0, #0x80000000 82 mov r0, #0x80000000
71 ldr r0, [r0, #0x300] /* Read GPIO A */ 83#ifdef LOGIK_DAX
84 ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
72 tst r0, #0x2 85 tst r0, #0x2
73 ldrne pc, [pc, #-28] /* Jump to original firmware if HOLD button not pressed */ 86#elif defined(SANSA_M200)
87 ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
88 tst r0, #0x200
74#else 89#else
75 #error No bootup key detection implemented for this target 90 #error No bootup key detection implemented for this target
76#endif 91#endif
77 92
78 /* Copy bootloader to safe area - 0x21000000 (DRAM) */ 93 ldrne pc, [pc, #-28] /* Jump to OF if HOLD button not pressed */
79 /* TODO: Adjust this for other targets - DRAM + DRAMSIZE - 0x100000 */ 94#endif /* TCCBOOT */
80 ldr r0, [pc, #-28] 95
81 mov r1, #0x20000000 96/* We are now definitely executing the bootloader, so we relocate to the
82 add r1, r1, #0x100000 97 linked address (see boot.lds) - 1MB from the end of DRAM.
98*/
99
100#ifdef TCCBOOT
101 ldr r0, [pc, #-28] /* mktccboot fills in the load address */
102#else
103 mov r0, #0x20000000 /* Otherwise, load address is the start of DRAM */
104#endif
105 mov r1, #0x20000000 /* Destination: 1MB from end of DRAM */
106 add r1, r1, #((MEM - 1) * 0x100000)
107
83 ldr r2, =_dataend 108 ldr r2, =_dataend
841: 1091:
85 cmp r2, r1 110 cmp r2, r1
@@ -88,16 +113,14 @@ start_loc:
88 bhi 1b 113 bhi 1b
89 114
90 ldr pc, =copied_start /* jump to the relocated start_loc: */ 115 ldr pc, =copied_start /* jump to the relocated start_loc: */
91
92copied_start: 116copied_start:
93#endif 117#endif /* BOOTLOADER */
94#else
95 /* We don't use interrupts in the bootloader */
96 118
97 /* Set up stack for IRQ mode */ 119 /* Set up stack for IRQ mode */
98 mov r0,#0xd2 120 mov r0,#0xd2
99 msr cpsr, r0 121 msr cpsr, r0
100 ldr sp, =irq_stack 122 ldr sp, =irq_stack
123
101 /* Set up stack for FIQ mode */ 124 /* Set up stack for FIQ mode */
102 mov r0,#0xd1 125 mov r0,#0xd1
103 msr cpsr, r0 126 msr cpsr, r0
@@ -110,13 +133,22 @@ copied_start:
110 mov r0,#0xdb 133 mov r0,#0xdb
111 msr cpsr, r0 134 msr cpsr, r0
112 ldr sp, =irq_stack 135 ldr sp, =irq_stack
113#endif
114 136
115 /* Switch to supervisor mode */ 137 /* Switch to supervisor mode */
116 mov r0,#0xd3 138 mov r0,#0xd3
117 msr cpsr, r0 139 msr cpsr, r0
118 ldr sp, =stackend 140 ldr sp, =stackend
119 141
142 /* Copy exception handler code to address 0 */
143 mov r2, #0x0
144 ldr r3, =vectors_start
145 ldr r4, =vectors_end
1461:
147 cmp r4, r3
148 ldrhi r5, [r3], #4
149 strhi r5, [r2], #4
150 bhi 1b
151
120 /* Initialise bss section to zero */ 152 /* Initialise bss section to zero */
121 ldr r2, =_edata 153 ldr r2, =_edata
122 ldr r3, =_end 154 ldr r3, =_end
@@ -139,9 +171,68 @@ copied_start:
139 bl main 171 bl main
140 /* main() should never return */ 172 /* main() should never return */
141 173
142#ifndef BOOTLOADER 174/* Exception handlers. Will be copied to address 0 after memory remapping */
143 /* We don't use interrupts in the bootloader */ 175vectors_start:
176 ldr pc, [pc, #24]
177 ldr pc, [pc, #24]
178 ldr pc, [pc, #24]
179 ldr pc, [pc, #24]
180 ldr pc, [pc, #24]
181 ldr pc, [pc, #24]
182 ldr pc, [pc, #24]
183 ldr pc, [pc, #24]
184
185 /* Exception vectors */
186 .global vectors
187vectors:
188 .word start
189 .word undef_instr_handler
190 .word software_int_handler
191 .word prefetch_abort_handler
192 .word data_abort_handler
193 .word reserved_handler
194 .word irq_handler
195 .word fiq_handler
196vectors_end:
197
198 .text
199
200/* All illegal exceptions call into UIE with exception address as first
201 parameter. This is calculated differently depending on which exception
202 we're in. Second parameter is exception number, used for a string lookup
203 in UIE.
204 */
205undef_instr_handler:
206 mov r0, lr
207 mov r1, #0
208 b UIE
144 209
210/* We run supervisor mode most of the time, and should never see a software
211 exception being thrown. Perhaps make it illegal and call UIE?
212 */
213software_int_handler:
214reserved_handler:
215 movs pc, lr
216
217prefetch_abort_handler:
218 sub r0, lr, #4
219 mov r1, #1
220 b UIE
221
222data_abort_handler:
223 sub r0, lr, #8
224 mov r1, #2
225 b UIE
226
227irq_handler:
228 stmfd sp!, {r0-r3, r12, lr}
229 bl irq
230 ldmfd sp!, {r0-r3, r12, lr}
231 subs pc, lr, #4
232
233/* Align stacks to cache line boundary */
234 .balign 16
235
145/* 256 words of IRQ stack */ 236/* 256 words of IRQ stack */
146 .space 256*4 237 .space 256*4
147irq_stack: 238irq_stack:
@@ -150,4 +241,3 @@ irq_stack:
150 .space 256*4 241 .space 256*4
151fiq_stack: 242fiq_stack:
152 243
153#endif
diff --git a/firmware/target/arm/tcc77x/debug-target.h b/firmware/target/arm/tcc77x/debug-target.h
new file mode 100644
index 0000000000..07e8fc4322
--- /dev/null
+++ b/firmware/target/arm/tcc77x/debug-target.h
@@ -0,0 +1,22 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20bool __dbg_hw_info(void);
21bool __dbg_ports(void);
22
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c
new file mode 100644
index 0000000000..dc3db3926f
--- /dev/null
+++ b/firmware/target/arm/tcc77x/debug-tcc77x.c
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Rob Purchase
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "string.h"
24#include <stdbool.h>
25#include "button.h"
26#include "lcd.h"
27#include "sprintf.h"
28#include "font.h"
29#include "debug-target.h"
30#include "adc.h"
31
32bool __dbg_ports(void)
33{
34 return false;
35}
36
37bool __dbg_hw_info(void)
38{
39 int line = 0, i, button, oldline;
40 bool done=false;
41 char buf[100];
42
43 lcd_setmargins(0, 0);
44 lcd_setfont(FONT_SYSFIXED);
45 lcd_clear_display();
46
47 /* Put all the static text before the while loop */
48 lcd_puts(0, line++, "[Hardware info]");
49
50 line++;
51 oldline=line;
52 while(!done)
53 {
54 line = oldline;
55 button = button_get(false);
56
57 button &= ~BUTTON_REPEAT;
58
59 if (button == BUTTON_SELECT)
60 done=true;
61
62 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
63 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
64
65 snprintf(buf, sizeof(buf), "GPIOA: 0x%08x GPIOB: 0x%08x",
66 (unsigned int)GPIOA, (unsigned int)GPIOB); lcd_puts(0, line++, buf);
67 snprintf(buf, sizeof(buf), "GPIOC: 0x%08x GPIOD: 0x%08x",
68 (unsigned int)GPIOC, (unsigned int)GPIOD); lcd_puts(0, line++, buf);
69 snprintf(buf, sizeof(buf), "GPIOE: 0x%08x",
70 (unsigned int)GPIOE); lcd_puts(0, line++, buf);
71
72 for (i = 0; i<4; i++)
73 {
74 snprintf(buf, sizeof(buf), "ADC%d: 0x%04x", i, adc_read(i));
75 lcd_puts(0, line++, buf);
76 }
77
78 lcd_update();
79 }
80 return false;
81}
diff --git a/firmware/target/arm/tcc77x/i2c-target.h b/firmware/target/arm/tcc77x/i2c-target.h
new file mode 100644
index 0000000000..4600b8a576
--- /dev/null
+++ b/firmware/target/arm/tcc77x/i2c-target.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Rob Purchase
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef I2C_TARGET_H
20#define I2C_TARGET_H
21
22/* Definitions for the TCC77X I2C bus */
23
24#define SDA_BIT (1<<10)
25#define SCL_BIT (1<<11)
26
27#define SCL (GPIOB & SCL_BIT)
28#define SCL_HI GPIOB |= SCL_BIT
29#define SCL_LO GPIOB &= ~SCL_BIT
30
31#define SDA (GPIOB & SDA_BIT)
32#define SDA_HI GPIOB |= SDA_BIT
33#define SDA_LO GPIOB &= ~SDA_BIT
34#define SDA_INPUT GPIOB_DIR &= ~SDA_BIT
35#define SDA_OUTPUT GPIOB_DIR |= SDA_BIT
36
37#endif /* I2C_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/kernel-tcc77x.c b/firmware/target/arm/tcc77x/kernel-tcc77x.c
new file mode 100644
index 0000000000..17c6ff0734
--- /dev/null
+++ b/firmware/target/arm/tcc77x/kernel-tcc77x.c
@@ -0,0 +1,45 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Rob Purchase
11*
12* All files in this archive are subject to the GNU General Public License.
13* See the file COPYING in the source tree root for full license agreement.
14*
15* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16* KIND, either express or implied.
17*
18****************************************************************************/
19
20#include "config.h"
21#include "system.h"
22#include "kernel.h"
23#include "timer.h"
24#include "thread.h"
25
26void tick_start(unsigned int interval_in_ms)
27{
28 /* configure Timer T-Clock to 2Mhz (clock source 4 (Xin) divided by 6) */
29 PCLKCFG4 = (1 << 31) | (4 << 28) | (5 << 16);
30
31 /* disable Timer0 */
32 TCFG0 &= ~1;
33
34 /* set counter reference value based on 1Mhz tick */
35 TREF0 = interval_in_ms * 1000;
36
37 /* Timer0 = reset to 0, divide=2, IRQ enable, enable (continuous) */
38 TCFG0 = (1<<8) | (0<<4) | (1<<3) | 1;
39
40 /* Unmask timer IRQ */
41 IEN |= TIMER0_IRQ_MASK;
42}
43
44/* NB: Since we are using a single timer IRQ, tick tasks are dispatched as
45 part of the central timer IRQ processing in timer-tcc77x.c */
diff --git a/firmware/target/arm/tcc77x/lcd-ssd1815.c b/firmware/target/arm/tcc77x/lcd-ssd1815.c
index 4101f6ab7d..feb8bf1765 100644
--- a/firmware/target/arm/tcc77x/lcd-ssd1815.c
+++ b/firmware/target/arm/tcc77x/lcd-ssd1815.c
@@ -208,7 +208,7 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
208 208
209/* Performance function that works with an external buffer 209/* Performance function that works with an external buffer
210 note that by and bheight are in 8-pixel units! */ 210 note that by and bheight are in 8-pixel units! */
211void lcd_blit_grey_phase_blit(unsigned char *values, unsigned char *phases, 211void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
212 int x, int by, int width, int bheight, int stride) 212 int x, int by, int width, int bheight, int stride)
213{ 213{
214 (void)values; 214 (void)values;
diff --git a/firmware/target/arm/tcc77x/m200/adc-target.h b/firmware/target/arm/tcc77x/m200/adc-target.h
new file mode 100644
index 0000000000..96fb1e44aa
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/adc-target.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _ADC_TARGET_H_
20#define _ADC_TARGET_H_
21
22#define NUM_ADC_CHANNELS 8
23
24#define ADC_BUTTONS 1
25
26#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/backlight-target.h b/firmware/target/arm/tcc77x/m200/backlight-target.h
new file mode 100644
index 0000000000..a54aa4686d
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/backlight-target.h
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H
21
22#include "tcc77x.h"
23
24static inline bool _backlight_init(void)
25{
26 GPIOA_DIR |= 0x40;
27 return true;
28}
29
30static inline void _backlight_on(void)
31{
32 /* Enable backlight */
33 GPIOA |= 0x40;
34}
35
36static inline void _backlight_off(void)
37{
38 /* Disable backlight */
39 GPIOA &= ~0x40;
40}
41
42#endif
diff --git a/firmware/target/arm/tcc77x/m200/button-m200.c b/firmware/target/arm/tcc77x/m200/button-m200.c
new file mode 100644
index 0000000000..fec745ae99
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/button-m200.c
@@ -0,0 +1,97 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "button.h"
23#include "adc.h"
24
25/*
26
27Results of button testing (viewing ADC values whilst pressing buttons):
28
29HOLD: GPIOB & 0x0200 (0=hold active, 0x0200 = hold inactive)
30
31ADC[1]: (approx values)
32
33Idle - 0x3ff
34MENU - unknown
35
36REPEAT/AB - 0x03?
37LEFT - 0x07?-0x08?
38SELECT - 0x0c?
39RIGHT - 0x11?
40
41PLAY/PAUSE - 0x17?-0x018?
42VOL UP - 0x1e?-0x01f?
43VOL DOWN - 0x26?
44
45*/
46
47void button_init_device(void)
48{
49 /* Nothing to do */
50}
51
52int button_read_device(void)
53{
54 int btn = BUTTON_NONE;
55 int adc;
56
57 /* TODO - determine how to detect BUTTON_MENU - it doesn't appear to
58 be connected to a GPIO or to an ADC
59 */
60
61 adc = adc_read(ADC_BUTTONS);
62
63 if (adc < 0x384) {
64 if (adc < 0x140) {
65 if (adc < 0x96) {
66 if (adc < 0x50) {
67 btn |= BUTTON_REPEATAB; /* 0x00..0x4f */
68 } else {
69 btn |= BUTTON_LEFT; /* 0x50..0x95 */
70 }
71 } else {
72 if (adc < 0xe0) {
73 btn |= BUTTON_SELECT; /* 0x96..0xdf */
74 } else {
75 btn |= BUTTON_RIGHT; /* 0xe0..0x13f */
76 }
77 }
78 } else {
79 if (adc < 0x208) {
80 if (adc < 0x1b0) {
81 btn |= BUTTON_PLAYPAUSE; /* 0x140..0x1af */
82 } else {
83 btn |= BUTTON_VOLUP; /* 0x1b0..0x207 */
84 }
85 } else {
86 btn |= BUTTON_VOLDOWN; /* 0x209..0x383 */
87 }
88 }
89 }
90
91 return btn;
92}
93
94bool button_hold(void)
95{
96 return (GPIOB & 0x200)?false:true;
97}
diff --git a/firmware/target/arm/tcc77x/m200/button-target.h b/firmware/target/arm/tcc77x/m200/button-target.h
new file mode 100644
index 0000000000..da7c82e6b2
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/button-target.h
@@ -0,0 +1,52 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_BUTTON_HOLD
27
28void button_init_device(void);
29int button_read_device(void);
30bool button_hold(void);
31
32/* Main unit's buttons */
33#define BUTTON_MENU 0x00000001
34#define BUTTON_VOLUP 0x00000002
35#define BUTTON_VOLDOWN 0x00000004
36#define BUTTON_PLAYPAUSE 0x00000008
37#define BUTTON_REPEATAB 0x00000010
38#define BUTTON_LEFT 0x00000020
39#define BUTTON_RIGHT 0x00000040
40#define BUTTON_SELECT 0x00000080
41
42#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
43 |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
44 |BUTTON_RIGHT|BUTTON_SELECT)
45
46#define BUTTON_REMOTE 0
47
48/* Software power-off */
49#define POWEROFF_BUTTON BUTTON_MENU
50#define POWEROFF_COUNT 40
51
52#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/power-m200.c b/firmware/target/arm/tcc77x/m200/power-m200.c
new file mode 100644
index 0000000000..df2ee10d6b
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/power-m200.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include <stdbool.h>
22#include "kernel.h"
23#include "system.h"
24#include "power.h"
25
26#ifndef SIMULATOR
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34}
35
36bool ide_powered(void)
37{
38 return true;
39}
40
41void power_off(void)
42{
43}
44
45#else /* SIMULATOR */
46
47bool charger_inserted(void)
48{
49 return false;
50}
51
52void charger_enable(bool on)
53{
54 (void)on;
55}
56
57void power_off(void)
58{
59}
60
61void ide_power_enable(bool on)
62{
63 (void)on;
64}
65
66#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tcc77x/pcm-tcc77x.c b/firmware/target/arm/tcc77x/pcm-tcc77x.c
new file mode 100644
index 0000000000..953f550612
--- /dev/null
+++ b/firmware/target/arm/tcc77x/pcm-tcc77x.c
@@ -0,0 +1,75 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by [whoever fills in these functions]
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "system.h"
20#include "kernel.h"
21#include "logf.h"
22#include "audio.h"
23#include "sound.h"
24#include "file.h"
25
26void pcm_postinit(void)
27{
28}
29
30const void * pcm_play_dma_get_peak_buffer(int *count)
31{
32 (void)count;
33 return 0;
34}
35
36void pcm_play_dma_init(void)
37{
38}
39
40void pcm_apply_settings(void)
41{
42}
43
44void pcm_set_frequency(unsigned int frequency)
45{
46 (void)frequency;
47}
48
49void pcm_play_dma_start(const void *addr, size_t size)
50{
51 (void)addr;
52 (void)size;
53}
54
55void pcm_play_dma_stop(void)
56{
57}
58
59void pcm_play_lock(void)
60{
61}
62
63void pcm_play_unlock(void)
64{
65}
66
67void pcm_play_dma_pause(bool pause)
68{
69 (void)pause;
70}
71
72size_t pcm_get_bytes_waiting(void)
73{
74 return 0;
75}
diff --git a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
new file mode 100644
index 0000000000..20172c00ce
--- /dev/null
+++ b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "adc.h"
22#include "powermgmt.h"
23#include "kernel.h"
24#include "pcf50606.h"
25
26unsigned short current_voltage = 3910;
27
28const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
29{
30 /* FIXME: calibrate value */
31 3380
32};
33
34const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
35{
36 /* FIXME: calibrate value */
37 3300
38};
39
40/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
41const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
42{
43 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
44 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
45};
46
47#if CONFIG_CHARGING
48/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
49const unsigned short percent_to_volt_charge[11] =
50{
51 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
52 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160
53};
54#endif /* CONFIG_CHARGING */
55
56#define BATTERY_SCALE_FACTOR 6000
57/* full-scale ADC readout (2^10) in millivolt */
58
59/* Returns battery voltage from ADC [millivolts] */
60unsigned int battery_adc_voltage(void)
61{
62 return current_voltage;
63}
64
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
index baa1641c78..7323b0ce55 100644
--- a/firmware/target/arm/tcc77x/system-tcc77x.c
+++ b/firmware/target/arm/tcc77x/system-tcc77x.c
@@ -21,6 +21,28 @@
21#include "system.h" 21#include "system.h"
22#include "panic.h" 22#include "panic.h"
23 23
24extern void TIMER(void);
25
26void irq(void)
27{
28 int irq = IREQ & 0x7fffffff;
29 CREQ = irq; /* Clears the corresponding IRQ status */
30
31 if (irq & TIMER0_IRQ_MASK)
32 {
33 TIMER();
34 }
35 else
36 {
37 panicf("Unhandled IRQ 0x%08X", irq);
38 }
39}
40
41void fiq_handler(void)
42{
43 /* TODO */
44}
45
24void system_reboot(void) 46void system_reboot(void)
25{ 47{
26} 48}
@@ -49,7 +71,7 @@ static void gpio_init(void)
49 GPIOB_DIR = 0x6ffff; 71 GPIOB_DIR = 0x6ffff;
50 GPIOB = 0; 72 GPIOB = 0;
51 GPIOC_FUNC = 1; 73 GPIOC_FUNC = 1;
52 GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */ 74 GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
53 GPIOC = 0; 75 GPIOC = 0;
54} 76}
55#elif defined(IAUDIO_7) 77#elif defined(IAUDIO_7)
@@ -72,6 +94,11 @@ static void gpio_init(void)
72 GPIOD_DIR = 0x3e3; 94 GPIOD_DIR = 0x3e3;
73 GPIOE_DIR = 0x88; 95 GPIOE_DIR = 0x88;
74} 96}
97#elif defined(SANSA_M200)
98static void gpio_init(void)
99{
100 /* TODO - Implement for M200 */
101}
75#endif 102#endif
76 103
77/* Second function called in the original firmware's startup code - we just 104/* Second function called in the original firmware's startup code - we just
@@ -80,14 +107,16 @@ static void clock_init(void)
80{ 107{
81 unsigned int i; 108 unsigned int i;
82 109
110 /* STP = 0x1, PW = 0x04 , HLD = 0x0 */
83 CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820; 111 CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
84 112
113 /* XIN=External main, Fcpu=Fsys, BCKDIV=1 (Fbus = Fsys / 2) */
85 CLKCTRL = (CLKCTRL & ~0xff) | 0x14; 114 CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
86 115
87 if (BMI & 0x20) 116 if (BMI & 0x20)
88 PCLKCFG0 = 0xc82d7000; 117 PCLKCFG0 = 0xc82d7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0x2d, P1 = 1 */
89 else 118 else
90 PCLKCFG0 = 0xc8ba7000; 119 PCLKCFG0 = 0xc8ba7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0xba, P1 = 1 */
91 120
92 MCFG |= 0x2000; 121 MCFG |= 0x2000;
93 122
@@ -96,14 +125,20 @@ static void clock_init(void)
96 SDCFG = (SDCFG & ~0x7000) | 0x2000; 125 SDCFG = (SDCFG & ~0x7000) | 0x2000;
97#endif 126#endif
98 127
128 /* Disable PLL */
99 PLL0CFG |= 0x80000000; 129 PLL0CFG |= 0x80000000;
100 130
131 /* Enable PLL, M=0xcf, P=0x13. m=M+8, p=P+2, S = 0
132 Fout = (215/21)*12MHz = 122857142Hz */
101 PLL0CFG = 0x0000cf13; 133 PLL0CFG = 0x0000cf13;
102 134
103 i = 8000; 135 i = 8000;
104 while (--i) {}; 136 while (--i) {};
105 137
106 CLKDIV0 = 0x81000000; 138 /* Enable PLL0 */
139 CLKDIVC = 0x81000000;
140
141 /* Fsys = PLL0, Fcpu = Fsys, Fbus=Fsys / 2 */
107 CLKCTRL = 0x80000010; 142 CLKCTRL = 0x80000010;
108 143
109 asm volatile ( 144 asm volatile (
@@ -112,13 +147,118 @@ static void clock_init(void)
112 ); 147 );
113} 148}
114 149
150static void cpu_init(void)
151{
152 /* Memory protection - see page 48 of ARM946 TRM
153http://infocenter.arm.com/help/topic/com.arm.doc.ddi0201d/DDI0201D_arm946es_r1p1_trm.pdf
154 */
155 asm volatile (
156 /* Region 0 - addr=0, size=4GB, enabled */
157 "mov r0, #0x3f \n\t"
158 "mcr p15, 0, r0, c6, c0, 0 \n\t"
159 "mcr p15, 0, r0, c6, c0, 1 \n\t"
160
161#ifdef LOGIK_DAX
162 /* Address region 1 - addr 0x2fff0000, size=64KB, enabled*/
163 "ldr r0, =0x2fff001f \n\t"
164#elif defined(IAUDIO_7)
165 /* Address region 1 - addr 0x20000000, size=8KB, enabled*/
166 "mov r0, #0x19 \n\t"
167 "add r0, r0, #0x20000000 \n\t"
168#elif defined(SANSA_M200)
169 /* Address region 1 - addr 0x20000000, size=256MB, enabled*/
170 "mov r0, #0x37 \n\t"
171 "add r0, r0, #0x20000000 \n\t"
172#endif
173 "mcr p15, 0, r0, c6, c1, 0 \n\t"
174 "mcr p15, 0, r0, c6, c1, 1 \n\t"
175
176 /* Address region 2 - addr 0x30000000, size=256MB, enabled*/
177 "mov r0, #0x37 \n\t"
178 "add r0, r0, #0x30000000 \n\t"
179 "mcr p15, 0, r0, c6, c2, 0 \n\t"
180 "mcr p15, 0, r0, c6, c2, 1 \n\t"
181
182 /* Address region 2 - addr 0x40000000, size=512MB, enabled*/
183 "mov r0, #0x39 \n\t"
184 "add r0, r0, #0x40000000 \n\t"
185 "mcr p15, 0, r0, c6, c3, 0 \n\t"
186 "mcr p15, 0, r0, c6, c3, 1 \n\t"
187
188 /* Address region 4 - addr 0x60000000, size=256MB, enabled*/
189 "mov r0, #0x37 \n\t"
190 "add r0, r0, #0x60000000 \n\t"
191 "mcr p15, 0, r0, c6, c4, 0 \n\t"
192 "mcr p15, 0, r0, c6, c4, 1 \n\t"
193
194 /* Address region 5 - addr 0x10000000, size=256MB, enabled*/
195 "mov r0, #0x37 \n\t"
196 "add r0, r0, #0x10000000 \n\t"
197 "mcr p15, 0, r0, c6, c5, 0 \n\t"
198 "mcr p15, 0, r0, c6, c5, 1 \n\t"
199
200 /* Address region 6 - addr 0x80000000, size=2GB, enabled*/
201 "mov r0, #0x37 \n\t"
202 "add r0, r0, #0x80000006 \n\t"
203 "mcr p15, 0, r0, c6, c6, 0 \n\t"
204 "mcr p15, 0, r0, c6, c6, 1 \n\t"
205
206 /* Address region 7 - addr 0x3000f000, size=4KB, enabled*/
207 "ldr r0, =0x3000f017 \n\t"
208 "mcr p15, 0, r0, c6, c7, 0 \n\t"
209 "mcr p15, 0, r0, c6, c7, 1 \n\t"
210
211
212 /* Register 5 - Access Permission Registers */
213
214 "ldr r0, =0xffff \n\t"
215 "mcr p15, 0, r0, c5, c0, 0 \n\t" /* write data access permission bits */
216 "mcr p15, 0, r0, c5, c0, 1 \n\t" /* write instruction access permission bits */
217
218 "mov r0, #0xa7 \n\t"
219 "mcr p15, 0, r0, c3, c0, 0 \n\t" /* set write buffer control register */
220
221#ifdef LOGIK_DAX
222 "mov r0, #0xa5 \n\t"
223#elif defined(IAUDIO_7) || defined(SANSA_M200)
224 "mov r0, #0xa7 \n\t"
225#elif
226 #error NOT DEFINED FOR THIS TARGET!
227#endif
228 "mcr p15, 0, r0, c2, c0, 0 \n\t"
229 "mcr p15, 0, r0, c2, c0, 1 \n\t"
230
231 "mov r0, #0xa0000006 \n\t"
232 "mcr p15, 0, r0, c9, c1, 0 \n\t"
233
234 "ldr r1, =0x1107d \n\t"
235 "mov r0, #0x0 \n\t"
236 "mcr p15, 0, r0, c7, c5, 0 \n\t" /* Flush instruction cache */
237 "mcr p15, 0, r0, c7, c6, 0 \n\t" /* Flush data cache */
238
239 "mcr p15, 0, r1, c1, c0, 0 \n\t" /* CPU control bits */
240 : : : "r0", "r1"
241 );
242}
243
244
115 245
116void system_init(void) 246void system_init(void)
117{ 247{
118 /* TODO: cache init - the original firmwares have cache init code which 248 /* mask all interrupts */
119 is called at the very start of the firmware */ 249 IEN = 0;
250
251 /* Set all interrupts as IRQ for now - some may need to be FIQ in future */
252 IRQSEL = 0xffffffff;
253
254 /* Set master enable bit */
255 IEN = 0x80000000;
256
257 cpu_init();
120 clock_init(); 258 clock_init();
121 gpio_init(); 259 gpio_init();
260
261 enable_irq();
122} 262}
123 263
124int system_memory_guard(int newmode) 264int system_memory_guard(int newmode)
diff --git a/firmware/target/arm/tcc77x/timer-target.h b/firmware/target/arm/tcc77x/timer-target.h
new file mode 100644
index 0000000000..db25df7cd4
--- /dev/null
+++ b/firmware/target/arm/tcc77x/timer-target.h
@@ -0,0 +1,39 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2007 by Karl Kurbjun
11*
12* All files in this archive are subject to the GNU General Public License.
13* See the file COPYING in the source tree root for full license agreement.
14*
15* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16* KIND, either express or implied.
17*
18****************************************************************************/
19#ifndef TIMER_TARGET_H
20#define TIMER_TARGET_H
21
22/* timers are based on XIN (12Mhz) */
23#define TIMER_FREQ (12000000)
24
25bool __timer_set(long cycles, bool set);
26bool __timer_register(void);
27void __timer_unregister(void);
28
29#define __TIMER_SET(cycles, set) \
30 __timer_set(cycles, set)
31
32#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
33 int_prio, timer_callback) \
34 __timer_register()
35
36#define __TIMER_UNREGISTER(...) \
37 __timer_unregister()
38
39#endif /* TIMER_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/timer-tcc77x.c b/firmware/target/arm/tcc77x/timer-tcc77x.c
new file mode 100644
index 0000000000..32010b2d25
--- /dev/null
+++ b/firmware/target/arm/tcc77x/timer-tcc77x.c
@@ -0,0 +1,79 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Rob Purchase
11*
12* All files in this archive are subject to the GNU General Public License.
13* See the file COPYING in the source tree root for full license agreement.
14*
15* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16* KIND, either express or implied.
17*
18****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "timer.h"
24#include "logf.h"
25
26/* Use the TC32 counter [sourced by Xin:12Mhz] for this timer, as it's the
27 only one that allows a 32-bit counter (Timer0-5 are 16/20 bit only). */
28
29bool __timer_set(long cycles, bool start)
30{
31 #warning function not implemented
32
33 (void)cycles;
34 (void)start;
35 return false;
36}
37
38bool __timer_register(void)
39{
40 #warning function not implemented
41
42 return false;
43}
44
45void __timer_unregister(void)
46{
47 #warning function not implemented
48}
49
50
51/* Timer interrupt processing - all timers (inc. tick) have a single IRQ */
52
53extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
54
55void TIMER(void)
56{
57 if (TIREQ & TF0) /* Timer0 reached ref value */
58 {
59 int i;
60
61 /* Run through the list of tick tasks */
62 for(i = 0; i < MAX_NUM_TICK_TASKS; i++)
63 {
64 if(tick_funcs[i])
65 {
66 tick_funcs[i]();
67 }
68 }
69 current_tick++;
70
71 /* reset Timer 0 IRQ & ref flags */
72 TIREQ |= TI0 | TF0;
73 }
74
75 if (TC32IRQ & (1<<3)) /* end of TC32 prescale */
76 {
77 /* dispatch timer */
78 }
79}
diff --git a/firmware/target/arm/tcc77x/usb-tcc77x.c b/firmware/target/arm/tcc77x/usb-tcc77x.c
new file mode 100644
index 0000000000..7254b919a7
--- /dev/null
+++ b/firmware/target/arm/tcc77x/usb-tcc77x.c
@@ -0,0 +1,36 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by [whoever fills in these functions]
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "usb.h"
22
23void usb_init_device(void)
24{
25}
26
27void usb_enable(bool on)
28{
29 (void)on;
30}
31
32/* Always return false for now */
33int usb_detect(void)
34{
35 return USB_EXTRACTED;
36}