summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/common/disk.c5
-rw-r--r--firmware/export/config-tpj1022.h123
-rw-r--r--firmware/export/config.h5
-rw-r--r--firmware/kernel.c3
-rw-r--r--firmware/system.c2
-rw-r--r--firmware/target/arm/tatung/tpj1022/adc-target.h42
-rw-r--r--firmware/target/arm/tatung/tpj1022/adc-tpj1022.c101
-rw-r--r--firmware/target/arm/tatung/tpj1022/backlight-target.h28
-rw-r--r--firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c44
-rw-r--r--firmware/target/arm/tatung/tpj1022/button-target.h58
-rw-r--r--firmware/target/arm/tatung/tpj1022/button-tpj1022.c83
-rw-r--r--firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c97
-rw-r--r--firmware/target/arm/tatung/tpj1022/power-tpj1022.c67
-rw-r--r--firmware/target/arm/tatung/tpj1022/usb-target.h27
-rw-r--r--firmware/target/arm/tatung/tpj1022/usb-tpj1022.c107
16 files changed, 802 insertions, 2 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 29e8ad8271..07b8355662 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -293,3 +293,15 @@ target/arm/gigabeat/meg-fx/lcd-meg-fx.c
target/arm/gigabeat/meg-fx/sc606-meg-fx.c
#endif
#endif
+
+#ifdef ELIO_TPJ1022
+#ifndef SIMULATOR
+target/arm/tatung/tpj1022/backlight-tpj1022.c
+target/arm/tatung/tpj1022/button-tpj1022.c
+target/arm/ata-pp5020.c
+target/arm/tatung/tpj1022/power-tpj1022.c
+target/arm/tatung/tpj1022/usb-tpj1022.c
+target/arm/tatung/tpj1022/lcd-tpj1022.c
+target/arm/tatung/tpj1022/adc-tpj1022.c
+#endif
+#endif
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 2f1d789738..950658286c 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -146,6 +146,10 @@ int disk_mount(int drive)
{
return 0;
}
+#ifndef ELIO_TPJ1022
+ /* The Elio's hard drive has no partition table and probing for partitions causes
+ Rockbox to crash - so we temporarily disable the probing until we fix the
+ real problem. */
for (i=0; volume != -1 && i<4; i++)
{
if (!fat_mount(IF_MV2(volume,) IF_MV2(drive,) pinfo[i].start))
@@ -155,6 +159,7 @@ int disk_mount(int drive)
volume = get_free_volume(); /* prepare next entry */
}
}
+#endif
if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */
{ /* try "superfloppy" mode */
diff --git a/firmware/export/config-tpj1022.h b/firmware/export/config-tpj1022.h
new file mode 100644
index 0000000000..03ab9445fb
--- /dev/null
+++ b/firmware/export/config-tpj1022.h
@@ -0,0 +1,123 @@
+/*
+ * This config file is for the Tatung Elio TPJ-1022
+ */
+
+#define TARGET_TREE /* this target is using the target tree system */
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 15
+
+/* define this if you have recording possibility */
+/*#define HAVE_RECORDING 1*/ /* TODO: add support for this */
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP 1
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR 1
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you have access to the pitchscreen */
+#define HAVE_PITCHSCREEN
+
+/* LCD dimensions */
+#define LCD_WIDTH 220
+#define LCD_HEIGHT 176
+#define LCD_DEPTH 16 /* 65536 colours */
+#define LCD_PIXELFORMAT RGB565
+
+/* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */
+
+#define CONFIG_KEYPAD ELIO_TPJ1022_PAD
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* define this if you have a real-time clock */
+#ifndef BOOTLOADER
+//#define CONFIG_RTC RTC_E8564
+#endif
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x80000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x80000
+
+/* Define this if you have the WM8731 audio codec */
+#define HAVE_WM8731
+
+#define AB_REPEAT_ENABLE 1
+
+/* Define this for LCD backlight available */
+#define CONFIG_BACKLIGHT BL_TPJ1022 /* TODO: figure this out, probably not necessary
+ because of 'target' stuff */
+
+#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity
+ TODO: check this, probably different
+ for different models too */
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LPCS355385
+#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 1600 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 10 /* capacity increment */
+#define BATTERY_TYPES_COUNT 1 /* only one type */
+#define BATTERY_SCALE_FACTOR 5865
+
+/* Hardware controlled charging? FIXME */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
+
+/* define this if the hardware can be powered off while charging */
+/* TODO: should this be set for the H10? */
+//#define HAVE_POWEROFF_WHILE_CHARGING
+
+/* The start address index for ROM builds */
+#define ROM_START 0x00000000
+
+/* Define this to the CPU frequency */
+/* TODO: this is probably wrong */
+#define CPU_FREQ 11289600
+
+/* Type of LCD */
+#define CONFIG_LCD LCD_TPJ1022
+
+#define DEFAULT_CONTRAST_SETTING 19
+
+/* Offset ( in the firmware file's header ) to the file length */
+#define FIRMWARE_OFFSET_FILE_LENGTH 0
+
+/* Offset ( in the firmware file's header ) to the file CRC */
+#define FIRMWARE_OFFSET_FILE_CRC 0
+
+/* Offset ( in the firmware file's header ) to the real data */
+#define FIRMWARE_OFFSET_FILE_DATA 8
+
+/* #define USB_IPODSTYLE */
+
+/* define this if the unit can be powered or charged via USB */
+/*#define HAVE_USB_POWER*/
+
+/* Virtual LED (icon) */
+#define CONFIG_LED LED_VIRTUAL
+
+/* Define this if you have adjustable CPU frequency */
+#define HAVE_ADJUSTABLE_CPU_FREQ
+
+#define BOOTFILE_EXT "elio"
+#define BOOTFILE "rockbox." BOOTFILE_EXT
+
+#endif
diff --git a/firmware/export/config.h b/firmware/export/config.h
index cd674b63f8..18adaeeca2 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -59,6 +59,7 @@
#define GIGABEAT_PAD 10
#define IRIVER_H10_PAD 11
#define SANSA_E200_PAD 12
+#define ELIO_TPJ1022_PAD 13
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@@ -96,6 +97,7 @@
#define LCD_GIGABEAT 12
#define LCD_H10 13 /* as used by iriver H10 20Gb */
#define LCD_H10_5GB 14 /* as used by iriver H10 5Gb */
+#define LCD_TPJ1022 15 /* as used by Tatung Elio TPJ-1022 */
/* LCD_PIXELFORMAT */
#define HORIZONTAL_PACKING 1
@@ -121,6 +123,7 @@
#define BL_H10 12 /* iriver H10 */
#define BL_X5 13 /* iAudio X5 PCF50606 I2C */
#define BL_H10_5GB 14 /* iriver H10 5/6GB */
+#define BL_TPJ1022 15 /* Tatung Elio TPJ-1022 */
/* CONFIG_I2C */
#define I2C_PLAYREC 0 /* Archos Player/Recorder style */
@@ -204,6 +207,8 @@
#include "config-h10_5gb.h"
#elif defined(SANSA_E200)
#include "config-e200.h"
+#elif defined(ELIO_TPJ1022)
+#include "config-tpj1022.h"
#else
/* no known platform */
#endif
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 1c8bf9dd81..b4123fe3ca 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -83,7 +83,8 @@ void sleep(int ticks)
void yield(void)
{
-#if CONFIG_CPU == S3C2440 && defined(BOOTLOADER)
+#if (CONFIG_CPU == S3C2440 || defined(ELIO_TPJ1022) && defined(BOOTLOADER))
+ /* Some targets don't like yielding in the bootloader */
#else
switch_thread();
wake_up_thread();
diff --git a/firmware/system.c b/firmware/system.c
index 44453db816..9b2f1ba5a4 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -1162,7 +1162,7 @@ void irq(void)
else if (CPU_HI_INT_STAT & GPIO_MASK)
ipod_mini_button_int();
}
-#elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB)
+#elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022)
/* TODO: this should really be in the target tree, but moving it there caused
crt0.S not to find it while linking */
void irq(void)
diff --git a/firmware/target/arm/tatung/tpj1022/adc-target.h b/firmware/target/arm/tatung/tpj1022/adc-target.h
new file mode 100644
index 0000000000..3aab373290
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/adc-target.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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 ADC_ENABLE_ADDR (*(volatile unsigned long*)(0x70000010))
+#define ADC_ENABLE 0x1100
+
+#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00))
+#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04))
+#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20))
+#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24))
+#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c))
+
+#define NUM_ADC_CHANNELS 4
+
+#define ADC_BATTERY 0
+#define ADC_UNKNOWN_1 1
+#define ADC_UNKNOWN_2 2
+#define ADC_SCROLLPAD 3
+#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
+
+/* Force a scan now */
+unsigned short adc_scan(int channel);
+
+#endif
diff --git a/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c b/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c
new file mode 100644
index 0000000000..134b90b587
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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 "adc.h"
+
+static unsigned short adcdata[NUM_ADC_CHANNELS];
+
+/* Scan ADC so that adcdata[channel] gets updated */
+unsigned short adc_scan(int channel)
+{
+ unsigned int adc_data_1;
+ unsigned int adc_data_2;
+
+ /* Initialise */
+ ADC_ADDR=0x130;
+ ADC_STATUS=0; /* 4 bytes, 1 per channel. Each byte is 0 if the channel is
+ off, 0x40 if the channel is on */
+
+ /* Enable Channel */
+ ADC_ADDR |= (0x1000000<<channel);
+
+ /* Start? */
+ ADC_ADDR |= 0x20000000;
+ ADC_ADDR |= 0x80000000;
+
+ /* ADC_DATA_1 and ADC_DATA_2 are both four bytes, one byte per channel.
+ For each channel, ADC_DATA_1 stores the 8-bit msb, ADC_DATA_2 stores the
+ 2-bit lsb (in bits 0 and 1). Each channel is 10 bits total. */
+ adc_data_1 = ((ADC_DATA_1 >> (8*channel)) & 0xff);
+ adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3);
+
+ adcdata[channel] = (adc_data_1<<2 | adc_data_2);
+
+ return adcdata[channel];
+}
+
+/* Read 10-bit channel data */
+unsigned short adc_read(int channel)
+{
+ return adcdata[channel];
+}
+
+static int adc_counter;
+
+static void adc_tick(void)
+{
+ if(++adc_counter == HZ)
+ {
+ adc_counter = 0;
+ adc_scan(ADC_BATTERY);
+ adc_scan(ADC_UNKNOWN_1);
+ adc_scan(ADC_UNKNOWN_2);
+ adc_scan(ADC_SCROLLPAD);
+ }
+}
+
+void adc_init(void)
+{
+ /* Enable ADC */
+ ADC_ENABLE_ADDR |= ADC_ENABLE;
+
+ /* Initialise */
+ ADC_INIT=0;
+ ADC_ADDR=0x130;
+ ADC_STATUS=0;
+
+ /* Enable Channels 1-4 */
+ ADC_ADDR |= 0x1000000;
+ ADC_ADDR |= 0x2000000;
+ ADC_ADDR |= 0x4000000;
+ ADC_ADDR |= 0x8000000;
+
+ /* Start? */
+ ADC_ADDR |= 0x20000000;
+ ADC_ADDR |= 0x80000000;
+
+ /* Wait 50ms for things to settle */
+ sleep(HZ/20);
+
+ tick_add_task(adc_tick);
+}
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-target.h b/firmware/target/arm/tatung/tpj1022/backlight-target.h
new file mode 100644
index 0000000000..b5fe2f7c5d
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/backlight-target.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Taken from the x5's implementation */
+
+#ifndef BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
+
+void __backlight_on(void);
+void __backlight_off(void);
+
+#endif
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c
new file mode 100644
index 0000000000..51218e21be
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* The H10 display (and hence backlight) possibly identical to that of the X5,
+ so that code was used here but left #if 0'ed out for the moment */
+
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "backlight.h"
+
+void __backlight_on(void)
+{
+#if 0
+ int level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
+ set_irq_level(level);
+#endif
+}
+
+void __backlight_off(void)
+{
+#if 0
+ int level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */
+ set_irq_level(level);
+#endif
+}
diff --git a/firmware/target/arm/tatung/tpj1022/button-target.h b/firmware/target/arm/tatung/tpj1022/button-target.h
new file mode 100644
index 0000000000..74bd61ed3d
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/button-target.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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
+
+bool button_hold(void);
+void button_init_device(void);
+int button_read_device(void);
+
+/* Tatung Elio TPJ-1022 button codes */
+
+/* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+
+#define BUTTON_LEFT 0x00000002
+#define BUTTON_RIGHT 0x00000004
+#define BUTTON_UP 0x00000008
+#define BUTTON_DOWN 0x00000010
+
+#define BUTTON_MENU 0x00000020
+#define BUTTON_FF 0x00000040
+#define BUTTON_REW 0x00000080
+#define BUTTON_REC 0x00000100
+#define BUTTON_AB 0x00000200
+#define BUTTON_PLUS 0x00000400
+#define BUTTON_MINUS 0x00000800
+
+#define BUTTON_MAIN 0x00000fff
+
+/* No Remote control */
+#define BUTTON_REMOTE 0
+
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tatung/tpj1022/button-tpj1022.c b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c
new file mode 100644
index 0000000000..f0b338c1c1
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Custom written for the TPJ-1022 based on analysis of the GPIO data */
+
+#include <stdlib.h>
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "button.h"
+#include "kernel.h"
+#include "backlight.h"
+#include "adc.h"
+#include "system.h"
+
+void button_init_device(void)
+{
+ /* No hardware initialisation required as it is done by the bootloader */
+}
+
+bool button_hold(void)
+{
+ return false;
+}
+
+/*
+ * Get button pressed from hardware
+ */
+int button_read_device(void)
+{
+ int btn = BUTTON_NONE;
+ unsigned char state;
+ static bool hold_button = false;
+
+#if 0
+ /* light handling */
+ if (hold_button && !button_hold())
+ {
+ backlight_on();
+ }
+#endif
+
+ hold_button = button_hold();
+ if (!hold_button)
+ {
+ /* Read normal buttons */
+ state = GPIOA_INPUT_VAL;
+ if ((state & 0x2) == 0) btn |= BUTTON_REW;
+ if ((state & 0x4) == 0) btn |= BUTTON_FF;
+ if ((state & 0x80) == 0) btn |= BUTTON_RIGHT;
+
+ /* Buttons left to figure out:
+ button_hold()
+ BUTTON_POWER
+ BUTTON_LEFT
+ BUTTON_UP
+ BUTTON_DOWN
+ BUTTON_MENU
+ BUTTON_REC
+ BUTTON_AB
+ BUTTON_PLUS
+ BUTTON_MINUS
+ */
+ }
+
+ return btn;
+}
diff --git a/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c b/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c
new file mode 100644
index 0000000000..53f32792c3
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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 "lcd.h"
+#include "kernel.h"
+#include "system.h"
+
+/*** hardware configuration ***/
+
+void lcd_set_contrast(int val)
+{
+ /* TODO: Implement lcd_set_contrast() */
+ (void)val;
+}
+
+void lcd_set_invert_display(bool yesno)
+{
+ /* TODO: Implement lcd_set_invert_display() */
+ (void)yesno;
+}
+
+/* turn the display upside down (call lcd_update() afterwards) */
+void lcd_set_flip(bool yesno)
+{
+ /* TODO: Implement lcd_set_flip() */
+ (void)yesno;
+}
+
+/* LCD init */
+void lcd_init_device(void)
+{
+
+}
+
+/*** update functions ***/
+
+/* Performance function that works with an external buffer
+ note that by and bheight are in 4-pixel units! */
+void lcd_blit(const fb_data* data, int x, int by, int width,
+ int bheight, int stride)
+{
+ /* TODO: Implement lcd_blit() */
+ (void)data;
+ (void)x;
+ (void)by;
+ (void)width;
+ (void)bheight;
+ (void)stride;
+}
+
+/* Performance function to blit a YUV bitmap directly to the LCD */
+void lcd_yuv_blit(unsigned char * const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height)
+{
+ (void)src;
+ (void)src_x;
+ (void)src_y;
+ (void)stride;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+}
+
+/* Update a fraction of the display. */
+void lcd_update_rect(int x0, int y0, int width, int height)
+{
+ (void)x0;
+ (void)y0;
+ (void)width;
+ (void)height;
+}
+
+/* Update the display.
+ This must be called after all other LCD functions that change the display. */
+void lcd_update(void)
+{
+ lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
+}
diff --git a/firmware/target/arm/tatung/tpj1022/power-tpj1022.c b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c
new file mode 100644
index 0000000000..e8bc4e1fb0
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Created from power.c using some iPod code, and some custom stuff based on
+ GPIO analysis
+*/
+
+#include "config.h"
+#include "cpu.h"
+#include <stdbool.h>
+#include "adc.h"
+#include "kernel.h"
+#include "system.h"
+#include "power.h"
+#include "hwcompat.h"
+#include "logf.h"
+#include "usb.h"
+
+#if CONFIG_CHARGING == CHARGING_CONTROL
+bool charger_enabled;
+#endif
+
+void power_init(void)
+{
+}
+
+bool charger_inserted(void)
+{
+ return false;
+}
+
+void ide_power_enable(bool on)
+{
+ (void)on;
+ /* We do nothing on the iPod */
+}
+
+
+bool ide_powered(void)
+{
+ /* pretend we are always powered - we don't turn it off on the ipod */
+ return true;
+}
+
+void power_off(void)
+{
+ /* Give things a second to settle before cutting power */
+ sleep(HZ);
+
+ //GPIOF_OUTPUT_VAL &=~ 0x20;
+}
diff --git a/firmware/target/arm/tatung/tpj1022/usb-target.h b/firmware/target/arm/tatung/tpj1022/usb-target.h
new file mode 100644
index 0000000000..7a17f7bacf
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/usb-target.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardelll
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Based off x5 version */
+
+#ifndef USB_TARGET_H
+#define USB_TARGET_H
+
+bool usb_init_device(void);
+
+#endif
diff --git a/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c b/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c
new file mode 100644
index 0000000000..b238de4369
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Code from the iPod port but commented out. USB detection custom made based
+ on GPIO analysis */
+
+#include "config.h"
+#include "cpu.h"
+#include "kernel.h"
+#include "thread.h"
+#include "system.h"
+#include "debug.h"
+#include "ata.h"
+#include "fat.h"
+#include "disk.h"
+#include "panic.h"
+#include "lcd.h"
+#include "adc.h"
+#include "usb.h"
+#include "button.h"
+#include "sprintf.h"
+#include "string.h"
+#include "hwcompat.h"
+#ifdef HAVE_MMC
+#include "ata_mmc.h"
+#endif
+
+void usb_init_device(void)
+{
+#if 0
+ int r0;
+ outl(inl(0x70000084) | 0x200, 0x70000084);
+
+ outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
+ outl(inl(0x6000600C) | 0x400000, 0x6000600C);
+
+ outl(inl(0x60006004) | 0x400000, 0x60006004); /* reset usb start */
+ outl(inl(0x60006004) & ~0x400000, 0x60006004); /* reset usb end */
+
+ outl(inl(0x70000020) | 0x80000000, 0x70000020);
+ while ((inl(0x70000028) & 0x80) == 0);
+
+ outl(inl(0xc5000184) | 0x100, 0xc5000184);
+ while ((inl(0xc5000184) & 0x100) != 0);
+
+ outl(inl(0xc50001A4) | 0x5F000000, 0xc50001A4);
+ if ((inl(0xc50001A4) & 0x100) == 0) {
+ outl(inl(0xc50001A8) & ~0x3, 0xc50001A8);
+ outl(inl(0xc50001A8) | 0x2, 0xc50001A8);
+ outl(inl(0x70000028) | 0x4000, 0x70000028);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+ } else {
+ outl(inl(0xc50001A8) | 0x3, 0xc50001A8);
+ outl(inl(0x70000028) &~0x4000, 0x70000028);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+ }
+ outl(inl(0xc5000140) | 0x2, 0xc5000140);
+ while((inl(0xc5000140) & 0x2) != 0);
+ r0 = inl(0xc5000184);
+
+ /* Note from IPL source (referring to next 5 lines of code:
+ THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */
+ outl(inl(0x70000020) | 0x80000000, 0x70000020);
+ outl(inl(0x6000600C) | 0x400000, 0x6000600C);
+ while ((inl(0x70000028) & 0x80) == 0);
+ outl(inl(0x70000028) | 0x2, 0x70000028);
+
+ udelay(0x186A0);
+#endif
+}
+
+bool usb_detect(void)
+{
+ return false;
+}
+
+void usb_enable(bool on)
+{
+ (void)on;
+#if 0
+ /* For the ipod, we can only do one thing with USB mode - reboot
+ into Apple's flash-based disk-mode. This does not return. */
+ if (on)
+ {
+ /* The following code is copied from ipodlinux */
+ unsigned char* storage_ptr = (unsigned char *)0x40017F00;
+ memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21);
+ DEV_RS |= 4; /* Reboot */
+ }
+#endif
+}