summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/tcc77x
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-10-28 11:08:10 +0000
committerDave Chapman <dave@dchapman.com>2007-10-28 11:08:10 +0000
commit28f6ae49ec1b1d3464add2941eb015bab56f8016 (patch)
tree6d4cddba129663340cf2f30212a516acdd16a4eb /firmware/target/arm/tcc77x
parentd3e101bd1184e5c1f474ff0978f65ac7e8e2dbfb (diff)
downloadrockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.gz
rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.zip
Initial work on a port to the Logik DAX 1GB MP3/DAB player. The bootloader build compiles and runs (but only displays some debugging info), and the LCD and ADC drivers are working. Two different bootloader builds are possible: 1) The default build is just a test application for uploading to the device via tcctool; 2) Adding -DTCCBOOT to EXTRA_DEFINES in the build directory Makefile will compile the bootloader so that it can be appended to the end of the original firmware and installed on the device, dual-booting. This commit also includes some work by Hein-Pieter van Braam on a port to the iAudio 7, but that doesn't build yet. A large part of these ports will be generic to all TCC77x devices - see the TelechipsInfo wiki page for some other devices with this CPU. NOTE: Compiling these builds requires an arm-elf-gcc with armv5 support - the current version of rockboxdev.sh compiles such a gcc.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15339 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r--firmware/target/arm/tcc77x/adc-tcc77x.c71
-rw-r--r--firmware/target/arm/tcc77x/ata-nand-tcc77x.c94
-rw-r--r--firmware/target/arm/tcc77x/ata-target.h22
-rw-r--r--firmware/target/arm/tcc77x/crt0.S153
-rw-r--r--firmware/target/arm/tcc77x/logikdax/adc-target.h26
-rw-r--r--firmware/target/arm/tcc77x/logikdax/backlight-target.h38
-rw-r--r--firmware/target/arm/tcc77x/logikdax/button-target.h70
-rw-r--r--firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c253
-rw-r--r--firmware/target/arm/tcc77x/logikdax/power-logikdax.c66
-rw-r--r--firmware/target/arm/tcc77x/system-target.h35
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c136
11 files changed, 964 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c
new file mode 100644
index 0000000000..d6d97aaf84
--- /dev/null
+++ b/firmware/target/arm/tcc77x/adc-tcc77x.c
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 "system.h"
+#include "kernel.h"
+#include "thread.h"
+#include "string.h"
+#include "adc.h"
+
+/*
+ TODO: We probably want to do this on the timer interrupt once we get
+ interrupts going - see the sh-adc.c implementation for an example which
+ looks like it should work well with the TCC77x.
+*/
+
+static unsigned short adcdata[8];
+
+static void adc_do_read(void)
+{
+ int i;
+ uint32_t adc_status;
+
+ PCLKCFG6 |= (1<<15); /* Enable ADC clock */
+
+ /* Start converting the first 4 channels */
+ for (i = 0; i < 4; i++)
+ ADCCON = i;
+
+ /* Wait for data to become stable */
+ while ((ADCDATA & 0x1) == 0);
+
+ /* Now read the values back */
+ for (i=0;i < 4; i++) {
+ adc_status = ADCSTATUS;
+ adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff;
+ }
+
+ PCLKCFG6 &= ~(1<<15); /* Disable ADC clock */
+}
+
+unsigned short adc_read(int channel)
+{
+ adc_do_read();
+
+ return adcdata[channel];
+}
+
+void adc_init(void)
+{
+ int i;
+
+ ADCCON = (1<<4); /* Leave standby mode */
+ ADCCFG |= 0x00000003; /* Single-mode, auto power-down */
+}
diff --git a/firmware/target/arm/tcc77x/ata-nand-tcc77x.c b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
new file mode 100644
index 0000000000..dd0ae7a950
--- /dev/null
+++ b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 "ata.h"
+#include "ata-target.h"
+#include "ata_idle_notify.h"
+#include "system.h"
+#include <string.h>
+#include "thread.h"
+#include "led.h"
+#include "disk.h"
+#include "panic.h"
+#include "usb.h"
+
+/* for compatibility */
+int ata_spinup_time = 0;
+
+long last_disk_activity = -1;
+
+/** static, private data **/
+static bool initialized = false;
+
+static long next_yield = 0;
+#define MIN_YIELD_PERIOD 2000
+
+/* API Functions */
+
+void ata_led(bool onoff)
+{
+ led(onoff);
+}
+
+int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
+ void* inbuf)
+{
+
+}
+
+int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
+ const void* outbuf)
+{
+}
+
+void ata_spindown(int seconds)
+{
+ (void)seconds;
+}
+
+bool ata_disk_is_active(void)
+{
+ return 0;
+}
+
+void ata_sleep(void)
+{
+}
+
+void ata_spin(void)
+{
+}
+
+/* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */
+int ata_hard_reset(void)
+{
+ return 0;
+}
+
+int ata_soft_reset(void)
+{
+ return 0;
+}
+
+void ata_enable(bool on)
+{
+}
+
+int ata_init(void)
+{
+}
diff --git a/firmware/target/arm/tcc77x/ata-target.h b/firmware/target/arm/tcc77x/ata-target.h
new file mode 100644
index 0000000000..79ac638de1
--- /dev/null
+++ b/firmware/target/arm/tcc77x/ata-target.h
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 ATA_TARGET_H
+#define ATA_TARGET_H
+
+#endif
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
new file mode 100644
index 0000000000..e4ecb05a4e
--- /dev/null
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -0,0 +1,153 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Arm bootloader and startup code based on startup.s from the iPodLinux loader
+ *
+ * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
+ * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
+ *
+ */
+
+#include "config.h"
+#include "cpu.h"
+
+ .section .init.text,"ax",%progbits
+
+ .global start
+
+/* Telechips firmware files start with a 32-byte header, as part of the code. */
+
+start:
+#ifdef TCCBOOT
+ /* Add -DTCCBOOT to EXTRA_DEFINES in the bootloader Makefile to
+ enable building the bootloader to be appended to the end of the
+ original firmware, dual-booting based on a key-press.
+
+ The following two values are filled in by mktccboot.
+ */
+ .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 */
+
+ .word 0xffff0601 /* Unknown magic */
+ .word 0x3a726556 /* "Ver:" */
+ .word 0x31373030 /* "0071" */
+ .word 0 /* First CRC32 */
+ .word 0 /* Unknown - always 0 */
+ .word 0 /* Second CRC32 */
+ .word 0 /* length of firmware file */
+
+#ifdef LOGIK_DAX
+ /* Some original firmwares have 0x40 bytes of zeroes here - we
+ don't know why, but err on the side of caution and include it
+ here. */
+ .space 0x40
+#endif
+#endif
+
+start_loc:
+
+#ifdef BOOTLOADER
+#ifdef TCCBOOT
+#ifdef LOGIK_DAX
+ mov r0, #0x80000000
+ ldr r0, [r0, #0x300] /* Read GPIO A */
+ tst r0, #0x2
+ ldrne pc, [pc, #-28] /* Jump to original firmware if HOLD button not pressed */
+#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
+ ldr r2, =_dataend
+1:
+ cmp r2, r1
+ ldrhi r3, [r0], #4
+ strhi r3, [r1], #4
+ bhi 1b
+
+ ldr pc, =copied_start /* jump to the relocated start_loc: */
+
+copied_start:
+#endif
+#else
+ /* We don't use interrupts in the 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
+ ldr sp, =fiq_stack
+
+ /* Let abort and undefined modes use IRQ stack */
+ mov r0,#0xd7
+ msr cpsr, r0
+ ldr sp, =irq_stack
+ mov r0,#0xdb
+ msr cpsr, r0
+ ldr sp, =irq_stack
+#endif
+
+ /* Switch to supervisor mode */
+ mov r0,#0xd3
+ msr cpsr, r0
+ ldr sp, =stackend
+
+ /* Initialise bss section to zero */
+ ldr r2, =_edata
+ ldr r3, =_end
+ mov r4, #0
+1:
+ cmp r3, r2
+ strhi r4, [r2], #4
+ bhi 1b
+
+ /* Set up some stack and munge it with 0xdeadbeef */
+ ldr sp, =stackend
+ mov r3, sp
+ ldr r2, =stackbegin
+ ldr r4, =0xdeadbeef
+1:
+ cmp r3, r2
+ strhi r4, [r2], #4
+ bhi 1b
+
+ bl main
+ /* main() should never return */
+
+#ifndef BOOTLOADER
+ /* We don't use interrupts in the bootloader */
+
+/* 256 words of IRQ stack */
+ .space 256*4
+irq_stack:
+
+/* 256 words of FIQ stack */
+ .space 256*4
+fiq_stack:
+
+#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/adc-target.h b/firmware/target/arm/tcc77x/logikdax/adc-target.h
new file mode 100644
index 0000000000..cfc8117a99
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/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 0
+
+#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
new file mode 100644
index 0000000000..4714f22aa3
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
+
+#include "tcc77x.h"
+
+#define __backlight_init() true
+
+static inline void __backlight_on(void)
+{
+ /* Enable backlight */
+ GPIOD |= 0x10;
+}
+
+static inline void __backlight_off(void)
+{
+ /* Disable backlight */
+ GPIOD &= ~0x10;
+}
+
+#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h
new file mode 100644
index 0000000000..2925a423b6
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/button-target.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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"
+
+/*
+
+Results of button testing:
+
+HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
+POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
+
+ADC[0]: (approx values)
+
+RIGHT - 0x37
+LEFT - 0x7f
+JOYSTICK PRESS - 0xc7
+UP - 0x11e
+DOWN - 0x184
+MODE - 0x1f0/0x1ff
+PRESET - 0x268/0x269
+TIMESHIFT - 0x2dd
+
+Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
+
+*/
+
+
+void button_init_device(void);
+int button_read_device(void);
+
+/* Main unit's buttons */
+#define BUTTON_POWERPLAY 0x00000001
+#define BUTTON_MODE 0x00000002
+#define BUTTON_HOLD 0x00000004
+#define BUTTON_REC 0x00000008
+#define BUTTON_PRESET 0x00000010
+#define BUTTON_LEFT 0x00000020
+#define BUTTON_RIGHT 0x00000040
+#define BUTTON_UP 0x00000080
+#define BUTTON_DOWN 0x00000100
+#define BUTTON_SELECT 0x00000200
+
+#define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\
+ |BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\
+ |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT)
+
+#define BUTTON_REMOTE 0
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c
new file mode 100644
index 0000000000..973d4cb333
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c
@@ -0,0 +1,253 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Alan Korr
+ *
+ * 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 "hwcompat.h"
+#include "kernel.h"
+#include "lcd.h"
+#include "system.h"
+#include "cpu.h"
+
+/*** definitions ***/
+
+#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
+#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
+#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
+#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
+#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
+#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
+#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
+#define LCD_SET_LCD_BIAS ((char)0xA2)
+#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
+#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
+#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
+#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
+#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
+#define LCD_SET_BIAS_TC_OSC ((char)0xA9)
+#define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA)
+#define LCD_SET_INDICATOR_OFF ((char)0xAC)
+#define LCD_SET_INDICATOR_ON ((char)0xAD)
+#define LCD_SET_DISPLAY_OFF ((char)0xAE)
+#define LCD_SET_DISPLAY_ON ((char)0xAF)
+#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
+#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
+#define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2)
+#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
+#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
+#define LCD_SOFTWARE_RESET ((char)0xE2)
+#define LCD_NOP ((char)0xE3)
+#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
+
+/* LCD command codes */
+#define LCD_CNTL_RESET 0xe2 /* Software reset */
+#define LCD_CNTL_POWER 0x2f /* Power control */
+#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
+#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
+#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
+#define LCD_CNTL_DISPON 0xaf /* Display on */
+
+#define LCD_CNTL_PAGE 0xb0 /* Page address */
+#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
+#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
+
+/* TCC77x specific defines */
+#define LCD_BASE 0x50000000
+#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
+#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
+
+void lcd_write_command(int byte)
+{
+ LCD_CMD = byte;
+
+ asm volatile (
+ "nop \n\t"
+ "nop \n\t"
+ "nop \n\t"
+ );
+}
+
+void lcd_write_data(const fb_data* p_bytes, int count)
+{
+ while (count--)
+ {
+ LCD_DATA = *(p_bytes++);
+
+ asm volatile (
+ "nop \n\t"
+ "nop \n\t"
+ "nop \n\t"
+ );
+ }
+}
+
+/* End of TCC77x specific defines */
+
+
+/** globals **/
+
+static int xoffset; /* needed for flip */
+
+/*** hardware configuration ***/
+
+int lcd_default_contrast(void)
+{
+ return 0x1f;
+}
+
+void lcd_set_contrast(int val)
+{
+ lcd_write_command(LCD_CNTL_CONTRAST);
+ lcd_write_command(val);
+}
+
+void lcd_set_invert_display(bool yesno)
+{
+ if (yesno)
+ lcd_write_command(LCD_SET_REVERSE_DISPLAY);
+ else
+ lcd_write_command(LCD_SET_NORMAL_DISPLAY);
+}
+
+/* turn the display upside down (call lcd_update() afterwards) */
+void lcd_set_flip(bool yesno)
+{
+ /* TODO: flip mode isn't working. The commands in the else part of
+ this function are how the original firmware inits the LCD */
+
+ if (yesno)
+ {
+ lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01);
+ lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION);
+ xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 128 we have */
+ }
+ else
+ {
+ lcd_write_command(LCD_SET_SEGMENT_REMAP);
+ lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08);
+ xoffset = 0;
+ }
+}
+
+
+/* LCD init */
+void lcd_init_device(void)
+{
+ uint32_t bus_width;
+
+ /* Telechips init the same as the original firmware */
+ CSCFG1 &= 0xc3ffc000;
+ CSCFG1 |= 0x3400101a;
+ CSCFG1 |= (1 << 21);
+ CSCFG1 &= ~(1 << 21);
+
+ bus_width = ((MCFG >> 11) & 0x3) ^ 3;
+
+ CSCFG1 = (bus_width << 28) |
+ (3 << 26) | /* MTYPE = 3 */
+ ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
+ (1 << 20) | /* Unknown */
+ (3 << 11) | /* Setup time = 3 cycles */
+ (3 << 3) | /* Pulse width = 3+1 cycles */
+ (1 << 0); /* Hold time = 1 cycle */
+
+ /* SSD1815 inits like the original firmware */
+ lcd_write_command(LCD_SET_DISPLAY_OFF);
+ lcd_set_flip(false);
+ lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5);
+ lcd_set_contrast(lcd_default_contrast());
+ lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7);
+ /* power control register: op-amp=1, regulator=1, booster=1 */
+ lcd_write_command(LCD_SET_BIAS_TC_OSC);
+
+ /* 0xc2 = 110 000 10: Osc. Freq 110 - ???
+ TC value 000 - "-0.01%/C (TC0, POR)"
+ Bias ratio 10 - "1/9, 1/7 (POR)"
+ */
+ lcd_write_command(0xc2);
+ lcd_write_command(LCD_SET_DISPLAY_ON);
+
+ lcd_clear_display();
+ lcd_update();
+}
+
+/*** Update functions ***/
+
+/* Performance function that works with an external buffer
+ note that by and bheight are in 8-pixel units! */
+void lcd_blit(const unsigned char* data, int x, int by, int width,
+ int bheight, int stride)
+{
+ /* Copy display bitmap to hardware */
+ while (bheight--)
+ {
+ lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
+ lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf));
+ lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
+
+ lcd_write_data(data, width);
+ data += stride;
+ }
+}
+
+
+/* Update the display.
+ This must be called after all other LCD functions that change the display. */
+void lcd_update(void) ICODE_ATTR;
+void lcd_update(void)
+{
+ int y;
+
+ /* Copy display bitmap to hardware */
+ for (y = 0; y < LCD_FBHEIGHT; y++)
+ {
+ lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
+ lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf));
+ lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf));
+
+ lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
+ }
+}
+
+/* Update a fraction of the display. */
+void lcd_update_rect(int, int, int, int) ICODE_ATTR;
+void lcd_update_rect(int x, int y, int width, int height)
+{
+ int ymax;
+
+ /* The Y coordinates have to work on even 8 pixel rows */
+ ymax = (y + height-1) >> 3;
+ y >>= 3;
+
+ if(x + width > LCD_WIDTH)
+ width = LCD_WIDTH - x;
+ if (width <= 0)
+ return; /* nothing left to do, 0 is harmful to lcd_write_data() */
+ if(ymax >= LCD_FBHEIGHT)
+ ymax = LCD_FBHEIGHT-1;
+
+ /* Copy specified rectange bitmap to hardware */
+ for (; y <= ymax; y++)
+ {
+ lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
+ lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf));
+ lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
+
+ lcd_write_data (&lcd_framebuffer[y][x], width);
+ }
+}
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
new file mode 100644
index 0000000000..df2ee10d6b
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/power-logikdax.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/system-target.h b/firmware/target/arm/tcc77x/system-target.h
new file mode 100644
index 0000000000..0df92e3263
--- /dev/null
+++ b/firmware/target/arm/tcc77x/system-target.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 SYSTEM_TARGET_H
+#define SYSTEM_TARGET_H
+
+#include "system-arm.h"
+
+#define CPUFREQ_DEFAULT 98784000
+#define CPUFREQ_NORMAL 98784000
+#define CPUFREQ_MAX 120000000
+
+#define inl(a) (*(volatile unsigned long *) (a))
+#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
+#define inb(a) (*(volatile unsigned char *) (a))
+#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
+#define inw(a) (*(volatile unsigned short *) (a))
+#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
+
+#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
new file mode 100644
index 0000000000..baa1641c78
--- /dev/null
+++ b/firmware/target/arm/tcc77x/system-tcc77x.c
@@ -0,0 +1,136 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 "kernel.h"
+#include "system.h"
+#include "panic.h"
+
+void system_reboot(void)
+{
+}
+
+/* TODO - these should live in the target-specific directories and
+ once we understand what all the GPIO pins do, move the init to the
+ specific driver for that hardware. For now, we just perform the
+ same GPIO init as the original firmware - this makes it easier to
+ investigate what the GPIO pins do.
+*/
+
+#ifdef LOGIK_DAX
+static void gpio_init(void)
+{
+ /* Do what the original firmware does */
+ GPIOD_FUNC = 0;
+ GPIOD_DIR = 0x3f0;
+ GPIOD = 0xe0;
+ GPIOE_FUNC = 0;
+ GPIOE_DIR = 0xe0;
+ GPIOE = 0;
+ GPIOA_FUNC = 0;
+ GPIOA_DIR = 0xffff1000; /* 0 - 0xf000 */
+ GPIOA = 0x1080;
+ GPIOB_FUNC = 0x16a3;
+ GPIOB_DIR = 0x6ffff;
+ GPIOB = 0;
+ GPIOC_FUNC = 1;
+ GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
+ GPIOC = 0;
+}
+#elif defined(IAUDIO_7)
+static void gpio_init(void)
+{
+ /* Do what the original firmware does */
+ GPIOA_FUNC = 0;
+ GPIOB_FUNC = 0x1623;
+ GPIOC_FUNC = 1;
+ GPIOD_FUNC = 0;
+ GPIOE_FUNC = 0;
+ GPIOA = 0x30;
+ GPIOB = 0x80000;
+ GPIOC = 0;
+ GPIOD = 0x180;
+ GPIOE = 0;
+ GPIOA_DIR = 0x84b0
+ GPIOB_DIR = 0x80800;
+ GPIOC_DIR = 0x2000000;
+ GPIOD_DIR = 0x3e3;
+ GPIOE_DIR = 0x88;
+}
+#endif
+
+/* Second function called in the original firmware's startup code - we just
+ set up the clocks in the same way as the original firmware for now. */
+static void clock_init(void)
+{
+ unsigned int i;
+
+ CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
+
+ CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
+
+ if (BMI & 0x20)
+ PCLKCFG0 = 0xc82d7000;
+ else
+ PCLKCFG0 = 0xc8ba7000;
+
+ MCFG |= 0x2000;
+
+#ifdef LOGIK_DAX
+ /* Only seen in the Logik DAX original firmware */
+ SDCFG = (SDCFG & ~0x7000) | 0x2000;
+#endif
+
+ PLL0CFG |= 0x80000000;
+
+ PLL0CFG = 0x0000cf13;
+
+ i = 8000;
+ while (--i) {};
+
+ CLKDIV0 = 0x81000000;
+ CLKCTRL = 0x80000010;
+
+ asm volatile (
+ "nop \n\t"
+ "nop \n\t"
+ );
+}
+
+
+void system_init(void)
+{
+ /* TODO: cache init - the original firmwares have cache init code which
+ is called at the very start of the firmware */
+ clock_init();
+ gpio_init();
+}
+
+int system_memory_guard(int newmode)
+{
+ (void)newmode;
+ return 0;
+}
+
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+
+void set_cpu_frequency(long frequency)
+{
+}
+
+#endif