summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-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 @@
+#include "config.h"
+
+ENTRY(start)
+
+OUTPUT_FORMAT(elf32-littlearm)
+OUTPUT_ARCH(arm)
+STARTUP(target/arm/tcc77x/crt0.o)
+
+#define PLUGINSIZE PLUGIN_BUFFER_SIZE
+#define CODECSIZE CODEC_SIZE
+
+#include "imx31l.h"
+
+#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
+
+#define DRAMORIG 0x20000000
+#define IRAMORIG 0x00000000
+#define IRAMSIZE IRAM_SIZE
+
+/* End of the audio buffer, where the codec buffer starts */
+#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
+
+/* Where the codec buffer ends, and the plugin buffer starts */
+#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
+
+MEMORY
+{
+ DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
+ IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
+}
+
+SECTIONS
+{
+ .text :
+ {
+ loadaddress = .;
+ _loadaddress = .;
+ . = ALIGN(0x200);
+ *(.init.text)
+ *(.text*)
+ *(.glue_7)
+ *(.glue_7t)
+ . = ALIGN(0x4);
+ } > DRAM
+
+ .rodata :
+ {
+ *(.rodata) /* problems without this, dunno why */
+ *(.rodata*)
+ *(.rodata.str1.1)
+ *(.rodata.str1.4)
+ . = ALIGN(0x4);
+
+ /* Pseudo-allocate the copies of the data sections */
+ _datacopy = .;
+ } > DRAM
+
+ /* TRICK ALERT! For RAM execution, we put the .data section at the
+ same load address as the copy. Thus, we don't waste extra RAM
+ when we don't actually need the copy. */
+ .data : AT ( _datacopy )
+ {
+ _datastart = .;
+ *(.data*)
+ . = ALIGN(0x4);
+ _dataend = .;
+ } > DRAM
+
+ /DISCARD/ :
+ {
+ *(.eh_frame)
+ }
+
+ .vectors 0x0 :
+ {
+ _vectorsstart = .;
+ *(.vectors);
+ _vectorsend = .;
+ } AT> DRAM
+
+ _vectorscopy = LOADADDR(.vectors);
+
+ .iram :
+ {
+ _iramstart = .;
+ *(.icode)
+ *(.irodata)
+ *(.idata)
+ . = ALIGN(0x4);
+ _iramend = .;
+ } > DRAM
+
+ _iramcopy = LOADADDR(.iram);
+
+ .ibss (NOLOAD) :
+ {
+ _iedata = .;
+ *(.ibss)
+ . = ALIGN(0x4);
+ _iend = .;
+ } > DRAM
+
+ .stack :
+ {
+ *(.stack)
+ stackbegin = .;
+ . += 0x2000;
+ stackend = .;
+ } > DRAM
+
+ .bss :
+ {
+ _edata = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(0x4);
+ _end = .;
+ } > DRAM
+
+ .audiobuf ALIGN(4) :
+ {
+ _audiobuffer = .;
+ audiobuffer = .;
+ } > DRAM
+
+ .audiobufend ENDAUDIOADDR:
+ {
+ audiobufend = .;
+ _audiobufend = .;
+ } > DRAM
+
+ .codec ENDAUDIOADDR:
+ {
+ codecbuf = .;
+ _codecbuf = .;
+ }
+
+ .plugin ENDADDR:
+ {
+ _pluginbuf = .;
+ pluginbuf = .;
+ }
+}
+
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;
long last_disk_activity = -1;
+/* Used to store (fake?) identify info */
+static unsigned short identify_info[256];
+
/** static, private data **/
static bool initialized = false;
@@ -91,4 +94,11 @@ void ata_enable(bool on)
int ata_init(void)
{
+ return 0;
+}
+
+/* TEMP: This will return junk, it's here for compilation only */
+unsigned short* ata_get_identify(void)
+{
+ return identify_info;
}
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)
#define DRAMORIG 0x20000000
#define IRAMORIG 0x00000000
#define IRAMSIZE 64K
-#define FLASHORIG 0x0000000
-#define FLASHSIZE 1M
+
MEMORY
{
-#ifdef TCCBOOT
DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
-#else
- DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
-#endif
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
@@ -52,6 +47,7 @@ SECTIONS
_stackend = .;
stackend = .;
} > DRAM
+
.bss : {
_edata = .;
*(.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 @@
.section .init.text,"ax",%progbits
+ .extern irq
+ .extern fiq
+ .extern UIE
+ .extern main
+
.global start
/* Telechips firmware files start with a 32-byte header, as part of the code. */
@@ -44,7 +49,8 @@ start:
.word 0 /* Saved entrypoint of original firmware*/
.word 0 /* Location in RAM of the start of our bootloader */
#else
- ldr pc, =start_loc /* jump to the main entry point */
+// ldr pc, =start_loc /* jump to the main entry point */
+ b start_loc
.word 0xffff0601 /* Unknown magic */
.word 0x3a726556 /* "Ver:" */
@@ -65,21 +71,40 @@ start:
start_loc:
#ifdef BOOTLOADER
+
+/*
+ If we are appended to the OF (i.e. dual-booting), do a simple GPIO
+ button check, and branch to the OF's entry point (saved by mktccboot)
+ if not active
+*/
+
#ifdef TCCBOOT
-#ifdef LOGIK_DAX
mov r0, #0x80000000
- ldr r0, [r0, #0x300] /* Read GPIO A */
+#ifdef LOGIK_DAX
+ ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
tst r0, #0x2
- ldrne pc, [pc, #-28] /* Jump to original firmware if HOLD button not pressed */
+#elif defined(SANSA_M200)
+ ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
+ tst r0, #0x200
#else
#error No bootup key detection implemented for this target
#endif
- /* Copy bootloader to safe area - 0x21000000 (DRAM) */
- /* TODO: Adjust this for other targets - DRAM + DRAMSIZE - 0x100000 */
- ldr r0, [pc, #-28]
- mov r1, #0x20000000
- add r1, r1, #0x100000
+ ldrne pc, [pc, #-28] /* Jump to OF if HOLD button not pressed */
+#endif /* TCCBOOT */
+
+/* We are now definitely executing the bootloader, so we relocate to the
+ linked address (see boot.lds) - 1MB from the end of DRAM.
+*/
+
+#ifdef TCCBOOT
+ ldr r0, [pc, #-28] /* mktccboot fills in the load address */
+#else
+ mov r0, #0x20000000 /* Otherwise, load address is the start of DRAM */
+#endif
+ mov r1, #0x20000000 /* Destination: 1MB from end of DRAM */
+ add r1, r1, #((MEM - 1) * 0x100000)
+
ldr r2, =_dataend
1:
cmp r2, r1
@@ -88,16 +113,14 @@ start_loc:
bhi 1b
ldr pc, =copied_start /* jump to the relocated start_loc: */
-
copied_start:
-#endif
-#else
- /* We don't use interrupts in the bootloader */
+#endif /* BOOTLOADER */
/* Set up stack for IRQ mode */
mov r0,#0xd2
msr cpsr, r0
ldr sp, =irq_stack
+
/* Set up stack for FIQ mode */
mov r0,#0xd1
msr cpsr, r0
@@ -110,13 +133,22 @@ copied_start:
mov r0,#0xdb
msr cpsr, r0
ldr sp, =irq_stack
-#endif
/* Switch to supervisor mode */
mov r0,#0xd3
msr cpsr, r0
ldr sp, =stackend
+ /* Copy exception handler code to address 0 */
+ mov r2, #0x0
+ ldr r3, =vectors_start
+ ldr r4, =vectors_end
+1:
+ cmp r4, r3
+ ldrhi r5, [r3], #4
+ strhi r5, [r2], #4
+ bhi 1b
+
/* Initialise bss section to zero */
ldr r2, =_edata
ldr r3, =_end
@@ -139,9 +171,68 @@ copied_start:
bl main
/* main() should never return */
-#ifndef BOOTLOADER
- /* We don't use interrupts in the bootloader */
+/* Exception handlers. Will be copied to address 0 after memory remapping */
+vectors_start:
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+ ldr pc, [pc, #24]
+
+ /* Exception vectors */
+ .global vectors
+vectors:
+ .word start
+ .word undef_instr_handler
+ .word software_int_handler
+ .word prefetch_abort_handler
+ .word data_abort_handler
+ .word reserved_handler
+ .word irq_handler
+ .word fiq_handler
+vectors_end:
+
+ .text
+
+/* All illegal exceptions call into UIE with exception address as first
+ parameter. This is calculated differently depending on which exception
+ we're in. Second parameter is exception number, used for a string lookup
+ in UIE.
+ */
+undef_instr_handler:
+ mov r0, lr
+ mov r1, #0
+ b UIE
+/* We run supervisor mode most of the time, and should never see a software
+ exception being thrown. Perhaps make it illegal and call UIE?
+ */
+software_int_handler:
+reserved_handler:
+ movs pc, lr
+
+prefetch_abort_handler:
+ sub r0, lr, #4
+ mov r1, #1
+ b UIE
+
+data_abort_handler:
+ sub r0, lr, #8
+ mov r1, #2
+ b UIE
+
+irq_handler:
+ stmfd sp!, {r0-r3, r12, lr}
+ bl irq
+ ldmfd sp!, {r0-r3, r12, lr}
+ subs pc, lr, #4
+
+/* Align stacks to cache line boundary */
+ .balign 16
+
/* 256 words of IRQ stack */
.space 256*4
irq_stack:
@@ -150,4 +241,3 @@ irq_stack:
.space 256*4
fiq_stack:
-#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Karl Kurbjun
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+bool __dbg_hw_info(void);
+bool __dbg_ports(void);
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Rob Purchase
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "string.h"
+#include <stdbool.h>
+#include "button.h"
+#include "lcd.h"
+#include "sprintf.h"
+#include "font.h"
+#include "debug-target.h"
+#include "adc.h"
+
+bool __dbg_ports(void)
+{
+ return false;
+}
+
+bool __dbg_hw_info(void)
+{
+ int line = 0, i, button, oldline;
+ bool done=false;
+ char buf[100];
+
+ lcd_setmargins(0, 0);
+ lcd_setfont(FONT_SYSFIXED);
+ lcd_clear_display();
+
+ /* Put all the static text before the while loop */
+ lcd_puts(0, line++, "[Hardware info]");
+
+ line++;
+ oldline=line;
+ while(!done)
+ {
+ line = oldline;
+ button = button_get(false);
+
+ button &= ~BUTTON_REPEAT;
+
+ if (button == BUTTON_SELECT)
+ done=true;
+
+ snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
+ (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
+
+ snprintf(buf, sizeof(buf), "GPIOA: 0x%08x GPIOB: 0x%08x",
+ (unsigned int)GPIOA, (unsigned int)GPIOB); lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "GPIOC: 0x%08x GPIOD: 0x%08x",
+ (unsigned int)GPIOC, (unsigned int)GPIOD); lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "GPIOE: 0x%08x",
+ (unsigned int)GPIOE); lcd_puts(0, line++, buf);
+
+ for (i = 0; i<4; i++)
+ {
+ snprintf(buf, sizeof(buf), "ADC%d: 0x%04x", i, adc_read(i));
+ lcd_puts(0, line++, buf);
+ }
+
+ lcd_update();
+ }
+ return false;
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Rob Purchase
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef I2C_TARGET_H
+#define I2C_TARGET_H
+
+/* Definitions for the TCC77X I2C bus */
+
+#define SDA_BIT (1<<10)
+#define SCL_BIT (1<<11)
+
+#define SCL (GPIOB & SCL_BIT)
+#define SCL_HI GPIOB |= SCL_BIT
+#define SCL_LO GPIOB &= ~SCL_BIT
+
+#define SDA (GPIOB & SDA_BIT)
+#define SDA_HI GPIOB |= SDA_BIT
+#define SDA_LO GPIOB &= ~SDA_BIT
+#define SDA_INPUT GPIOB_DIR &= ~SDA_BIT
+#define SDA_OUTPUT GPIOB_DIR |= SDA_BIT
+
+#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 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2008 by Rob Purchase
+*
+* All files in this archive are subject to the GNU General Public License.
+* See the file COPYING in the source tree root for full license agreement.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#include "config.h"
+#include "system.h"
+#include "kernel.h"
+#include "timer.h"
+#include "thread.h"
+
+void tick_start(unsigned int interval_in_ms)
+{
+ /* configure Timer T-Clock to 2Mhz (clock source 4 (Xin) divided by 6) */
+ PCLKCFG4 = (1 << 31) | (4 << 28) | (5 << 16);
+
+ /* disable Timer0 */
+ TCFG0 &= ~1;
+
+ /* set counter reference value based on 1Mhz tick */
+ TREF0 = interval_in_ms * 1000;
+
+ /* Timer0 = reset to 0, divide=2, IRQ enable, enable (continuous) */
+ TCFG0 = (1<<8) | (0<<4) | (1<<3) | 1;
+
+ /* Unmask timer IRQ */
+ IEN |= TIMER0_IRQ_MASK;
+}
+
+/* NB: Since we are using a single timer IRQ, tick tasks are dispatched as
+ 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,
/* Performance function that works with an external buffer
note that by and bheight are in 8-pixel units! */
-void lcd_blit_grey_phase_blit(unsigned char *values, unsigned char *phases,
+void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
int x, int by, int width, int bheight, int stride)
{
(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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _ADC_TARGET_H_
+#define _ADC_TARGET_H_
+
+#define NUM_ADC_CHANNELS 8
+
+#define ADC_BUTTONS 1
+
+#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
+
+#include "tcc77x.h"
+
+static inline bool _backlight_init(void)
+{
+ GPIOA_DIR |= 0x40;
+ return true;
+}
+
+static inline void _backlight_on(void)
+{
+ /* Enable backlight */
+ GPIOA |= 0x40;
+}
+
+static inline void _backlight_off(void)
+{
+ /* Disable backlight */
+ GPIOA &= ~0x40;
+}
+
+#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+#include "button.h"
+#include "adc.h"
+
+/*
+
+Results of button testing (viewing ADC values whilst pressing buttons):
+
+HOLD: GPIOB & 0x0200 (0=hold active, 0x0200 = hold inactive)
+
+ADC[1]: (approx values)
+
+Idle - 0x3ff
+MENU - unknown
+
+REPEAT/AB - 0x03?
+LEFT - 0x07?-0x08?
+SELECT - 0x0c?
+RIGHT - 0x11?
+
+PLAY/PAUSE - 0x17?-0x018?
+VOL UP - 0x1e?-0x01f?
+VOL DOWN - 0x26?
+
+*/
+
+void button_init_device(void)
+{
+ /* Nothing to do */
+}
+
+int button_read_device(void)
+{
+ int btn = BUTTON_NONE;
+ int adc;
+
+ /* TODO - determine how to detect BUTTON_MENU - it doesn't appear to
+ be connected to a GPIO or to an ADC
+ */
+
+ adc = adc_read(ADC_BUTTONS);
+
+ if (adc < 0x384) {
+ if (adc < 0x140) {
+ if (adc < 0x96) {
+ if (adc < 0x50) {
+ btn |= BUTTON_REPEATAB; /* 0x00..0x4f */
+ } else {
+ btn |= BUTTON_LEFT; /* 0x50..0x95 */
+ }
+ } else {
+ if (adc < 0xe0) {
+ btn |= BUTTON_SELECT; /* 0x96..0xdf */
+ } else {
+ btn |= BUTTON_RIGHT; /* 0xe0..0x13f */
+ }
+ }
+ } else {
+ if (adc < 0x208) {
+ if (adc < 0x1b0) {
+ btn |= BUTTON_PLAYPAUSE; /* 0x140..0x1af */
+ } else {
+ btn |= BUTTON_VOLUP; /* 0x1b0..0x207 */
+ }
+ } else {
+ btn |= BUTTON_VOLDOWN; /* 0x209..0x383 */
+ }
+ }
+ }
+
+ return btn;
+}
+
+bool button_hold(void)
+{
+ return (GPIOB & 0x200)?false:true;
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+#define HAS_BUTTON_HOLD
+
+void button_init_device(void);
+int button_read_device(void);
+bool button_hold(void);
+
+/* Main unit's buttons */
+#define BUTTON_MENU 0x00000001
+#define BUTTON_VOLUP 0x00000002
+#define BUTTON_VOLDOWN 0x00000004
+#define BUTTON_PLAYPAUSE 0x00000008
+#define BUTTON_REPEATAB 0x00000010
+#define BUTTON_LEFT 0x00000020
+#define BUTTON_RIGHT 0x00000040
+#define BUTTON_SELECT 0x00000080
+
+#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
+ |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
+ |BUTTON_RIGHT|BUTTON_SELECT)
+
+#define BUTTON_REMOTE 0
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_MENU
+#define POWEROFF_COUNT 40
+
+#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include "cpu.h"
+#include <stdbool.h>
+#include "kernel.h"
+#include "system.h"
+#include "power.h"
+
+#ifndef SIMULATOR
+
+void power_init(void)
+{
+}
+
+void ide_power_enable(bool on)
+{
+}
+
+bool ide_powered(void)
+{
+ return true;
+}
+
+void power_off(void)
+{
+}
+
+#else /* SIMULATOR */
+
+bool charger_inserted(void)
+{
+ return false;
+}
+
+void charger_enable(bool on)
+{
+ (void)on;
+}
+
+void power_off(void)
+{
+}
+
+void ide_power_enable(bool on)
+{
+ (void)on;
+}
+
+#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by [whoever fills in these functions]
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "system.h"
+#include "kernel.h"
+#include "logf.h"
+#include "audio.h"
+#include "sound.h"
+#include "file.h"
+
+void pcm_postinit(void)
+{
+}
+
+const void * pcm_play_dma_get_peak_buffer(int *count)
+{
+ (void)count;
+ return 0;
+}
+
+void pcm_play_dma_init(void)
+{
+}
+
+void pcm_apply_settings(void)
+{
+}
+
+void pcm_set_frequency(unsigned int frequency)
+{
+ (void)frequency;
+}
+
+void pcm_play_dma_start(const void *addr, size_t size)
+{
+ (void)addr;
+ (void)size;
+}
+
+void pcm_play_dma_stop(void)
+{
+}
+
+void pcm_play_lock(void)
+{
+}
+
+void pcm_play_unlock(void)
+{
+}
+
+void pcm_play_dma_pause(bool pause)
+{
+ (void)pause;
+}
+
+size_t pcm_get_bytes_waiting(void)
+{
+ return 0;
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Karl Kurbjun
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "adc.h"
+#include "powermgmt.h"
+#include "kernel.h"
+#include "pcf50606.h"
+
+unsigned short current_voltage = 3910;
+
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
+{
+ /* FIXME: calibrate value */
+ 3380
+};
+
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
+{
+ /* FIXME: calibrate value */
+ 3300
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{
+ /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
+ { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
+};
+
+#if CONFIG_CHARGING
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
+const unsigned short percent_to_volt_charge[11] =
+{
+ /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
+ 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160
+};
+#endif /* CONFIG_CHARGING */
+
+#define BATTERY_SCALE_FACTOR 6000
+/* full-scale ADC readout (2^10) in millivolt */
+
+/* Returns battery voltage from ADC [millivolts] */
+unsigned int battery_adc_voltage(void)
+{
+ return current_voltage;
+}
+
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 @@
#include "system.h"
#include "panic.h"
+extern void TIMER(void);
+
+void irq(void)
+{
+ int irq = IREQ & 0x7fffffff;
+ CREQ = irq; /* Clears the corresponding IRQ status */
+
+ if (irq & TIMER0_IRQ_MASK)
+ {
+ TIMER();
+ }
+ else
+ {
+ panicf("Unhandled IRQ 0x%08X", irq);
+ }
+}
+
+void fiq_handler(void)
+{
+ /* TODO */
+}
+
void system_reboot(void)
{
}
@@ -49,7 +71,7 @@ static void gpio_init(void)
GPIOB_DIR = 0x6ffff;
GPIOB = 0;
GPIOC_FUNC = 1;
- GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
+ GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
GPIOC = 0;
}
#elif defined(IAUDIO_7)
@@ -72,6 +94,11 @@ static void gpio_init(void)
GPIOD_DIR = 0x3e3;
GPIOE_DIR = 0x88;
}
+#elif defined(SANSA_M200)
+static void gpio_init(void)
+{
+ /* TODO - Implement for M200 */
+}
#endif
/* Second function called in the original firmware's startup code - we just
@@ -80,14 +107,16 @@ static void clock_init(void)
{
unsigned int i;
+ /* STP = 0x1, PW = 0x04 , HLD = 0x0 */
CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
+ /* XIN=External main, Fcpu=Fsys, BCKDIV=1 (Fbus = Fsys / 2) */
CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
if (BMI & 0x20)
- PCLKCFG0 = 0xc82d7000;
+ PCLKCFG0 = 0xc82d7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0x2d, P1 = 1 */
else
- PCLKCFG0 = 0xc8ba7000;
+ PCLKCFG0 = 0xc8ba7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0xba, P1 = 1 */
MCFG |= 0x2000;
@@ -96,14 +125,20 @@ static void clock_init(void)
SDCFG = (SDCFG & ~0x7000) | 0x2000;
#endif
+ /* Disable PLL */
PLL0CFG |= 0x80000000;
+ /* Enable PLL, M=0xcf, P=0x13. m=M+8, p=P+2, S = 0
+ Fout = (215/21)*12MHz = 122857142Hz */
PLL0CFG = 0x0000cf13;
i = 8000;
while (--i) {};
- CLKDIV0 = 0x81000000;
+ /* Enable PLL0 */
+ CLKDIVC = 0x81000000;
+
+ /* Fsys = PLL0, Fcpu = Fsys, Fbus=Fsys / 2 */
CLKCTRL = 0x80000010;
asm volatile (
@@ -112,13 +147,118 @@ static void clock_init(void)
);
}
+static void cpu_init(void)
+{
+ /* Memory protection - see page 48 of ARM946 TRM
+http://infocenter.arm.com/help/topic/com.arm.doc.ddi0201d/DDI0201D_arm946es_r1p1_trm.pdf
+ */
+ asm volatile (
+ /* Region 0 - addr=0, size=4GB, enabled */
+ "mov r0, #0x3f \n\t"
+ "mcr p15, 0, r0, c6, c0, 0 \n\t"
+ "mcr p15, 0, r0, c6, c0, 1 \n\t"
+
+#ifdef LOGIK_DAX
+ /* Address region 1 - addr 0x2fff0000, size=64KB, enabled*/
+ "ldr r0, =0x2fff001f \n\t"
+#elif defined(IAUDIO_7)
+ /* Address region 1 - addr 0x20000000, size=8KB, enabled*/
+ "mov r0, #0x19 \n\t"
+ "add r0, r0, #0x20000000 \n\t"
+#elif defined(SANSA_M200)
+ /* Address region 1 - addr 0x20000000, size=256MB, enabled*/
+ "mov r0, #0x37 \n\t"
+ "add r0, r0, #0x20000000 \n\t"
+#endif
+ "mcr p15, 0, r0, c6, c1, 0 \n\t"
+ "mcr p15, 0, r0, c6, c1, 1 \n\t"
+
+ /* Address region 2 - addr 0x30000000, size=256MB, enabled*/
+ "mov r0, #0x37 \n\t"
+ "add r0, r0, #0x30000000 \n\t"
+ "mcr p15, 0, r0, c6, c2, 0 \n\t"
+ "mcr p15, 0, r0, c6, c2, 1 \n\t"
+
+ /* Address region 2 - addr 0x40000000, size=512MB, enabled*/
+ "mov r0, #0x39 \n\t"
+ "add r0, r0, #0x40000000 \n\t"
+ "mcr p15, 0, r0, c6, c3, 0 \n\t"
+ "mcr p15, 0, r0, c6, c3, 1 \n\t"
+
+ /* Address region 4 - addr 0x60000000, size=256MB, enabled*/
+ "mov r0, #0x37 \n\t"
+ "add r0, r0, #0x60000000 \n\t"
+ "mcr p15, 0, r0, c6, c4, 0 \n\t"
+ "mcr p15, 0, r0, c6, c4, 1 \n\t"
+
+ /* Address region 5 - addr 0x10000000, size=256MB, enabled*/
+ "mov r0, #0x37 \n\t"
+ "add r0, r0, #0x10000000 \n\t"
+ "mcr p15, 0, r0, c6, c5, 0 \n\t"
+ "mcr p15, 0, r0, c6, c5, 1 \n\t"
+
+ /* Address region 6 - addr 0x80000000, size=2GB, enabled*/
+ "mov r0, #0x37 \n\t"
+ "add r0, r0, #0x80000006 \n\t"
+ "mcr p15, 0, r0, c6, c6, 0 \n\t"
+ "mcr p15, 0, r0, c6, c6, 1 \n\t"
+
+ /* Address region 7 - addr 0x3000f000, size=4KB, enabled*/
+ "ldr r0, =0x3000f017 \n\t"
+ "mcr p15, 0, r0, c6, c7, 0 \n\t"
+ "mcr p15, 0, r0, c6, c7, 1 \n\t"
+
+
+ /* Register 5 - Access Permission Registers */
+
+ "ldr r0, =0xffff \n\t"
+ "mcr p15, 0, r0, c5, c0, 0 \n\t" /* write data access permission bits */
+ "mcr p15, 0, r0, c5, c0, 1 \n\t" /* write instruction access permission bits */
+
+ "mov r0, #0xa7 \n\t"
+ "mcr p15, 0, r0, c3, c0, 0 \n\t" /* set write buffer control register */
+
+#ifdef LOGIK_DAX
+ "mov r0, #0xa5 \n\t"
+#elif defined(IAUDIO_7) || defined(SANSA_M200)
+ "mov r0, #0xa7 \n\t"
+#elif
+ #error NOT DEFINED FOR THIS TARGET!
+#endif
+ "mcr p15, 0, r0, c2, c0, 0 \n\t"
+ "mcr p15, 0, r0, c2, c0, 1 \n\t"
+
+ "mov r0, #0xa0000006 \n\t"
+ "mcr p15, 0, r0, c9, c1, 0 \n\t"
+
+ "ldr r1, =0x1107d \n\t"
+ "mov r0, #0x0 \n\t"
+ "mcr p15, 0, r0, c7, c5, 0 \n\t" /* Flush instruction cache */
+ "mcr p15, 0, r0, c7, c6, 0 \n\t" /* Flush data cache */
+
+ "mcr p15, 0, r1, c1, c0, 0 \n\t" /* CPU control bits */
+ : : : "r0", "r1"
+ );
+}
+
+
void system_init(void)
{
- /* TODO: cache init - the original firmwares have cache init code which
- is called at the very start of the firmware */
+ /* mask all interrupts */
+ IEN = 0;
+
+ /* Set all interrupts as IRQ for now - some may need to be FIQ in future */
+ IRQSEL = 0xffffffff;
+
+ /* Set master enable bit */
+ IEN = 0x80000000;
+
+ cpu_init();
clock_init();
gpio_init();
+
+ enable_irq();
}
int 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 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2007 by Karl Kurbjun
+*
+* All files in this archive are subject to the GNU General Public License.
+* See the file COPYING in the source tree root for full license agreement.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+#ifndef TIMER_TARGET_H
+#define TIMER_TARGET_H
+
+/* timers are based on XIN (12Mhz) */
+#define TIMER_FREQ (12000000)
+
+bool __timer_set(long cycles, bool set);
+bool __timer_register(void);
+void __timer_unregister(void);
+
+#define __TIMER_SET(cycles, set) \
+ __timer_set(cycles, set)
+
+#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
+ int_prio, timer_callback) \
+ __timer_register()
+
+#define __TIMER_UNREGISTER(...) \
+ __timer_unregister()
+
+#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 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2008 by Rob Purchase
+*
+* All files in this archive are subject to the GNU General Public License.
+* See the file COPYING in the source tree root for full license agreement.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "timer.h"
+#include "logf.h"
+
+/* Use the TC32 counter [sourced by Xin:12Mhz] for this timer, as it's the
+ only one that allows a 32-bit counter (Timer0-5 are 16/20 bit only). */
+
+bool __timer_set(long cycles, bool start)
+{
+ #warning function not implemented
+
+ (void)cycles;
+ (void)start;
+ return false;
+}
+
+bool __timer_register(void)
+{
+ #warning function not implemented
+
+ return false;
+}
+
+void __timer_unregister(void)
+{
+ #warning function not implemented
+}
+
+
+/* Timer interrupt processing - all timers (inc. tick) have a single IRQ */
+
+extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
+
+void TIMER(void)
+{
+ if (TIREQ & TF0) /* Timer0 reached ref value */
+ {
+ int i;
+
+ /* Run through the list of tick tasks */
+ for(i = 0; i < MAX_NUM_TICK_TASKS; i++)
+ {
+ if(tick_funcs[i])
+ {
+ tick_funcs[i]();
+ }
+ }
+ current_tick++;
+
+ /* reset Timer 0 IRQ & ref flags */
+ TIREQ |= TI0 | TF0;
+ }
+
+ if (TC32IRQ & (1<<3)) /* end of TC32 prescale */
+ {
+ /* dispatch timer */
+ }
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by [whoever fills in these functions]
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "usb.h"
+
+void usb_init_device(void)
+{
+}
+
+void usb_enable(bool on)
+{
+ (void)on;
+}
+
+/* Always return false for now */
+int usb_detect(void)
+{
+ return USB_EXTRACTED;
+}