From 8876018d25c6a56cce118482c1372bbff344cb23 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 5 Mar 2007 00:04:00 +0000 Subject: Bring up the M5 port to a working stage: Extended numerous explicit checks for IAUDIO_X5 to also check for IAUDIO_M5, moved code around the target tree, added preliminary background for the sim. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12610 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 4 +- apps/playback.c | 2 +- apps/plugins/plugin.lds | 2 +- firmware/SOURCES | 37 +- firmware/export/config-iaudiom5.h | 12 +- firmware/target/coldfire/i2c-coldfire.c | 2 +- firmware/target/coldfire/iaudio/adc-iaudio.c | 58 +++ firmware/target/coldfire/iaudio/adc-target.h | 35 ++ firmware/target/coldfire/iaudio/ata-iaudio.c | 64 +++ firmware/target/coldfire/iaudio/button-target.h | 73 +++ .../target/coldfire/iaudio/lcd-remote-iaudio.c | 517 +++++++++++++++++++++ .../target/coldfire/iaudio/lcd-remote-target.h | 38 ++ firmware/target/coldfire/iaudio/m5/audio-m5.c | 82 ++++ firmware/target/coldfire/iaudio/m5/backlight-m5.c | 58 +++ .../target/coldfire/iaudio/m5/backlight-target.h | 29 ++ firmware/target/coldfire/iaudio/m5/button-m5.c | 151 ++++++ firmware/target/coldfire/iaudio/m5/lcd-as-m5.S | 83 ++++ firmware/target/coldfire/iaudio/m5/lcd-m5.c | 219 +++++++++ firmware/target/coldfire/iaudio/m5/power-m5.c | 89 ++++ firmware/target/coldfire/iaudio/pcf50606-iaudio.c | 127 +++++ firmware/target/coldfire/iaudio/system-iaudio.c | 90 ++++ firmware/target/coldfire/iaudio/usb-iaudio.c | 45 ++ firmware/target/coldfire/iaudio/usb-target.h | 24 + firmware/target/coldfire/iaudio/x5/adc-target.h | 35 -- firmware/target/coldfire/iaudio/x5/adc-x5.c | 58 --- firmware/target/coldfire/iaudio/x5/ata-x5.c | 64 --- firmware/target/coldfire/iaudio/x5/button-target.h | 73 --- .../target/coldfire/iaudio/x5/lcd-remote-target.h | 38 -- firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | 517 --------------------- firmware/target/coldfire/iaudio/x5/pcf50606-x5.c | 127 ----- firmware/target/coldfire/iaudio/x5/system-x5.c | 90 ---- firmware/target/coldfire/iaudio/x5/usb-x5.c | 45 -- firmware/target/coldfire/pcm-coldfire.c | 2 +- firmware/target/coldfire/system-coldfire.c | 2 +- uisimulator/sdl/UI-m5.bmp | Bin 0 -> 415856 bytes uisimulator/sdl/uisdl.h | 18 + 36 files changed, 1828 insertions(+), 1082 deletions(-) create mode 100644 firmware/target/coldfire/iaudio/adc-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/adc-target.h create mode 100644 firmware/target/coldfire/iaudio/ata-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/button-target.h create mode 100644 firmware/target/coldfire/iaudio/lcd-remote-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/lcd-remote-target.h create mode 100644 firmware/target/coldfire/iaudio/m5/audio-m5.c create mode 100644 firmware/target/coldfire/iaudio/m5/backlight-m5.c create mode 100644 firmware/target/coldfire/iaudio/m5/backlight-target.h create mode 100644 firmware/target/coldfire/iaudio/m5/button-m5.c create mode 100644 firmware/target/coldfire/iaudio/m5/lcd-as-m5.S create mode 100644 firmware/target/coldfire/iaudio/m5/lcd-m5.c create mode 100644 firmware/target/coldfire/iaudio/m5/power-m5.c create mode 100644 firmware/target/coldfire/iaudio/pcf50606-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/system-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/usb-iaudio.c create mode 100644 firmware/target/coldfire/iaudio/usb-target.h delete mode 100644 firmware/target/coldfire/iaudio/x5/adc-target.h delete mode 100644 firmware/target/coldfire/iaudio/x5/adc-x5.c delete mode 100644 firmware/target/coldfire/iaudio/x5/ata-x5.c delete mode 100644 firmware/target/coldfire/iaudio/x5/button-target.h delete mode 100644 firmware/target/coldfire/iaudio/x5/lcd-remote-target.h delete mode 100644 firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c delete mode 100644 firmware/target/coldfire/iaudio/x5/pcf50606-x5.c delete mode 100644 firmware/target/coldfire/iaudio/x5/system-x5.c delete mode 100644 firmware/target/coldfire/iaudio/x5/usb-x5.c create mode 100644 uisimulator/sdl/UI-m5.bmp diff --git a/apps/debug_menu.c b/apps/debug_menu.c index d6c5ef4d1c..531ac106f4 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1077,7 +1077,7 @@ bool dbg_ports(void) snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons); #endif lcd_puts(0, line++, buf); -#ifdef IAUDIO_X5 +#if defined(IAUDIO_X5) || defined(IAUDIO_M5) snprintf(buf, sizeof(buf), "ADC_REMOTE (%c): %02x", remote_detect() ? '+' : '-', adc_remote); #else @@ -1953,7 +1953,7 @@ static bool dbg_save_roms(void) fd = creat("/internal_rom_000000-1FFFFF.bin"); #elif defined(IRIVER_H300_SERIES) fd = creat("/internal_rom_000000-3FFFFF.bin"); -#elif defined(IAUDIO_X5) +#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) fd = creat("/internal_rom_000000-3FFFFF.bin"); #endif if(fd >= 0) diff --git a/apps/playback.c b/apps/playback.c index 89caec92aa..2873c90772 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -169,7 +169,7 @@ enum { #if defined(CPU_PP) #define CODEC_IRAM_ORIGIN 0x4000c000 #define CODEC_IRAM_SIZE 0xc000 -#elif defined(IAUDIO_X5) +#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) #define CODEC_IRAM_ORIGIN 0x10010000 #define CODEC_IRAM_SIZE 0x10000 #else diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds index 5181e5604d..f38f60656a 100644 --- a/apps/plugins/plugin.lds +++ b/apps/plugins/plugin.lds @@ -24,7 +24,7 @@ OUTPUT_FORMAT(elf32-sh) #define DRAMORIG 0x31000000 #define IRAMORIG 0x1000c000 #define IRAMSIZE 0xc000 -#elif defined(IAUDIO_X5) +#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) #define DRAMORIG 0x31000000 #define IRAMORIG 0x10010000 #define IRAMSIZE 0x10000 diff --git a/firmware/SOURCES b/firmware/SOURCES index ec47fff3d1..ad7d372acc 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -354,17 +354,17 @@ target/coldfire/iaudio/x5/power-x5.c #ifndef SIMULATOR target/coldfire/ata-as-coldfire.S target/coldfire/pcf50606-coldfire.c -target/coldfire/iaudio/x5/adc-x5.c -target/coldfire/iaudio/x5/ata-x5.c +target/coldfire/iaudio/adc-iaudio.c +target/coldfire/iaudio/ata-iaudio.c +target/coldfire/iaudio/lcd-remote-iaudio.c +target/coldfire/iaudio/pcf50606-iaudio.c +target/coldfire/iaudio/system-iaudio.c +target/coldfire/iaudio/usb-iaudio.c target/coldfire/iaudio/x5/backlight-x5.c target/coldfire/iaudio/x5/button-x5.c target/coldfire/iaudio/x5/lcd-as-x5.S -target/coldfire/iaudio/x5/lcd-remote-x5.c target/coldfire/iaudio/x5/lcd-x5.c target/coldfire/iaudio/x5/m5636-x5.c -target/coldfire/iaudio/x5/pcf50606-x5.c -target/coldfire/iaudio/x5/system-x5.c -target/coldfire/iaudio/x5/usb-x5.c #ifndef BOOTLOADER target/coldfire/iaudio/x5/audio-x5.c #endif @@ -372,23 +372,22 @@ target/coldfire/iaudio/x5/audio-x5.c #endif /* IAUDIO_X5 */ #ifdef IAUDIO_M5 -target/coldfire/iaudio/x5/power-x5.c +target/coldfire/iaudio/m5/power-m5.c #ifndef SIMULATOR target/coldfire/ata-as-coldfire.S target/coldfire/pcf50606-coldfire.c -target/coldfire/iaudio/x5/adc-x5.c -target/coldfire/iaudio/x5/ata-x5.c -target/coldfire/iaudio/x5/backlight-x5.c -target/coldfire/iaudio/x5/button-x5.c -target/coldfire/iaudio/x5/lcd-as-x5.S -target/coldfire/iaudio/x5/lcd-remote-x5.c -target/coldfire/iaudio/x5/lcd-x5.c -target/coldfire/iaudio/x5/m5636-x5.c -target/coldfire/iaudio/x5/pcf50606-x5.c -target/coldfire/iaudio/x5/system-x5.c -target/coldfire/iaudio/x5/usb-x5.c +target/coldfire/iaudio/adc-iaudio.c +target/coldfire/iaudio/ata-iaudio.c +target/coldfire/iaudio/lcd-remote-iaudio.c +target/coldfire/iaudio/m5/backlight-m5.c +target/coldfire/iaudio/m5/button-m5.c +target/coldfire/iaudio/m5/lcd-as-m5.S +target/coldfire/iaudio/m5/lcd-m5.c +target/coldfire/iaudio/pcf50606-iaudio.c +target/coldfire/iaudio/system-iaudio.c +target/coldfire/iaudio/usb-iaudio.c #ifndef BOOTLOADER -target/coldfire/iaudio/x5/audio-x5.c +target/coldfire/iaudio/m5/audio-m5.c #endif #endif /* SIMULATOR */ #endif /* IAUDIO_M5 */ diff --git a/firmware/export/config-iaudiom5.h b/firmware/export/config-iaudiom5.h index 2c52bc0730..66c54bfdd9 100644 --- a/firmware/export/config-iaudiom5.h +++ b/firmware/export/config-iaudiom5.h @@ -144,15 +144,9 @@ /** Port-specific settings **/ /* Main LCD contrast range and defaults */ -#define MIN_CONTRAST_SETTING 1 -#define MAX_CONTRAST_SETTING 30 -#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */ - -/* Main LCD backlight brightness range and defaults */ -/* PCF50506 can output 0%-100% duty cycle but D305A expects %15-100%. */ -#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */ -#define MAX_BRIGHTNESS_SETTING 13 /* 3/16 (18.75%) */ -#define DEFAULT_BRIGHTNESS_SETTING 8 /* 8/16 (50.00%) = x5 boot default */ +#define MIN_CONTRAST_SETTING 24 +#define MAX_CONTRAST_SETTING 63 +#define DEFAULT_CONTRAST_SETTING 40 /* Remote LCD contrast range and defaults */ #define MIN_REMOTE_CONTRAST_SETTING 10 diff --git a/firmware/target/coldfire/i2c-coldfire.c b/firmware/target/coldfire/i2c-coldfire.c index a628ce5f0e..b4e7968d1a 100644 --- a/firmware/target/coldfire/i2c-coldfire.c +++ b/firmware/target/coldfire/i2c-coldfire.c @@ -58,7 +58,7 @@ void i2c_init(void) MFDR = 0x0d; MFDR2 = 0x0d; -#ifdef IAUDIO_X5 +#if defined(IAUDIO_X5) || defined(IAUDIO_M5) MBCR = IEN; /* Enable interface */ MBCR2 = IEN; #endif diff --git a/firmware/target/coldfire/iaudio/adc-iaudio.c b/firmware/target/coldfire/iaudio/adc-iaudio.c new file mode 100644 index 0000000000..1895cacfe9 --- /dev/null +++ b/firmware/target/coldfire/iaudio/adc-iaudio.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "kernel.h" +#include "thread.h" +#include "adc.h" +#include "pcf50606.h" + +/* get remaining 2 bits and return 10 bit value */ +static int get_10bit_voltage(int msbdata) +{ + int data = msbdata << 2; + data |= pcf50606_read(0x31) & 0x3; + return data; +} + +unsigned short adc_scan(int channel) +{ + static const int adcc2_parms[] = + { + [ADC_BUTTONS] = 0x81 | (5 << 1), /* 8b - ADCIN2 */ + [ADC_REMOTE] = 0x81 | (6 << 1), /* 8b - ADCIN3 */ + [ADC_BATTERY] = 0x01 | (0 << 1), /* 10b - BATVOLT, resistive divider */ + }; + + int level; + int data; + + level = set_irq_level(HIGHEST_IRQ_LEVEL); + + pcf50606_write(0x2f, adcc2_parms[channel]); + data = pcf50606_read(0x30); + + if (channel == ADC_BATTERY) + data = get_10bit_voltage(data); + + set_irq_level(level); + + return (unsigned short)data; +} diff --git a/firmware/target/coldfire/iaudio/adc-target.h b/firmware/target/coldfire/iaudio/adc-target.h new file mode 100644 index 0000000000..28ba6225d1 --- /dev/null +++ b/firmware/target/coldfire/iaudio/adc-target.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 3 + +#define ADC_BUTTONS 0 +#define ADC_REMOTE 1 +#define ADC_BATTERY 2 +#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ + +/* Force a scan now */ +unsigned short adc_scan(int channel); +static inline unsigned short adc_read(int channel) + { return adc_scan(channel); } +static inline void adc_init(void) + {} +#endif /* _ADC_TARGET_H_ */ diff --git a/firmware/target/coldfire/iaudio/ata-iaudio.c b/firmware/target/coldfire/iaudio/ata-iaudio.c new file mode 100644 index 0000000000..21c088288a --- /dev/null +++ b/firmware/target/coldfire/iaudio/ata-iaudio.c @@ -0,0 +1,64 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "pcf50606.h" + +void ata_reset(void) +{ + and_l(~0x40000000, &GPIO_OUT); + sleep(1); /* > 25us */ + or_l(0x40000000, &GPIO_OUT); + sleep(1); /* > 2ms */ +} + +void ata_enable(bool on) +{ + if(on) + and_l(~0x00000800, &GPIO1_OUT); + else + or_l(0x00000800, &GPIO1_OUT); +} + +bool ata_is_coldstart(void) +{ + return true; /* TODO */ +} + +void ata_device_init(void) +{ + /* ATA reset */ + or_l(0x40000000, &GPIO_OUT); + or_l(0x40000000, &GPIO_ENABLE); + or_l(0x40000000, &GPIO_FUNCTION); + + /* ATA enable */ + or_l(0x00000800, &GPIO1_OUT); + or_l(0x00000800, &GPIO1_ENABLE); + or_l(0x00000800, &GPIO1_FUNCTION); + + /* USB enable */ + and_l(~0x00000008, &GPIO1_OUT); + or_l(0x00000008, &GPIO1_ENABLE); + or_l(0x00000008, &GPIO1_FUNCTION); +} diff --git a/firmware/target/coldfire/iaudio/button-target.h b/firmware/target/coldfire/iaudio/button-target.h new file mode 100644 index 0000000000..af1088dfed --- /dev/null +++ b/firmware/target/coldfire/iaudio/button-target.h @@ -0,0 +1,73 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD +#define HAS_REMOTE_BUTTON_HOLD + +bool button_hold(void); +bool remote_button_hold(void); +void button_init_device(void); +int button_read_device(void); +void button_enable_scan(bool enable); +bool button_scan_enabled(void); + +/* iaudio X5 specific button codes */ + + /* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_REC 0x00000002 + +#define BUTTON_LEFT 0x00000004 +#define BUTTON_RIGHT 0x00000008 +#define BUTTON_UP 0x00000010 +#define BUTTON_DOWN 0x00000020 + +#define BUTTON_PLAY 0x00000040 +#define BUTTON_SELECT 0x00000080 + +#define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\ + |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT) + + /* Remote control's buttons */ +#define BUTTON_RC_PLAY 0x00100000 + +#define BUTTON_RC_REW 0x00080000 +#define BUTTON_RC_FF 0x00040000 +#define BUTTON_RC_VOL_UP 0x00020000 +#define BUTTON_RC_VOL_DOWN 0x00010000 + +#define BUTTON_RC_REC 0x00008000 +#define BUTTON_RC_MENU 0x00004000 + +#define BUTTON_RC_MODE 0x00002000 + +#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\ + |BUTTON_RC_REW|BUTTON_RC_FF\ + |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE) + +#define POWEROFF_BUTTON BUTTON_POWER +#define RC_POWEROFF_BUTTON BUTTON_RC_PLAY +#define POWEROFF_COUNT 30 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c new file mode 100644 index 0000000000..139ebbc2a3 --- /dev/null +++ b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c @@ -0,0 +1,517 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "system.h" +#include "kernel.h" +#include "lcd-remote.h" + +/* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ + +#define LCD_SET_DUTY_RATIO 0x48 +#define LCD_SELECT_ADC 0xa0 +#define LCD_SELECT_SHL 0xc0 +#define LCD_SET_COM0 0x44 +#define LCD_OSC_ON 0xab +#define LCD_SELECT_DCDC 0x64 +#define LCD_SELECT_RES 0x20 +#define LCD_SET_VOLUME 0x81 +#define LCD_SET_BIAS 0x50 +#define LCD_CONTROL_POWER 0x28 +#define LCD_DISPLAY_ON 0xae +#define LCD_SET_INITLINE 0x40 +#define LCD_SET_COLUMN 0x10 +#define LCD_SET_PAGE 0xb0 +#define LCD_SET_GRAY 0x88 +#define LCD_SET_PWM_FRC 0x90 +#define LCD_SET_POWER_SAVE 0xa8 +#define LCD_REVERSE 0xa6 + +#define CS_LO and_l(~0x00000020, &GPIO1_OUT) +#define CS_HI or_l(0x00000020, &GPIO1_OUT) +#define CLK_LO and_l(~0x00004000, &GPIO_OUT) +#define CLK_HI or_l(0x00004000, &GPIO_OUT) +#define DATA_LO and_l(~0x00002000, &GPIO_OUT) +#define DATA_HI or_l(0x00002000, &GPIO_OUT) +#define RS_LO and_l(~0x00008000, &GPIO_OUT) +#define RS_HI or_l(0x00008000, &GPIO_OUT) + +/* cached settings values */ +static bool cached_invert = false; +static bool cached_flip = false; +static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING; + +bool remote_initialized = false; + +static void remote_tick(void); + +/* Standard low-level byte writer. Requires CLK high on entry */ +static inline void _write_byte(unsigned data) +{ + asm volatile ( + "move.l (%[gpo0]), %%d0 \n" /* Get current state of data line */ + "and.l %[dbit], %%d0 \n" + "beq.s 1f \n" /* and set it as previous-state bit */ + "bset #8, %[data] \n" + "1: \n" + "move.l %[data], %%d0 \n" /* Compute the 'bit derivative', i.e. a value */ + "lsr.l #1, %%d0 \n" /* with 1's where the data changes from the */ + "eor.l %%d0, %[data] \n" /* previous state, and 0's where it doesn't */ + "swap %[data] \n" /* Shift data to upper byte */ + "lsl.l #8, %[data] \n" + + "move.l %[cbit], %%d1 \n" /* Prepare mask for flipping CLK */ + "or.l %[dbit], %%d1 \n" /* and DATA at once */ + + "lsl.l #1,%[data] \n" /* Shift out MSB */ + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" /* 1: Flip both CLK and DATA */ + ".word 0x51fa \n" /* (trapf.w - shadow next insn) */ + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" /* else flip CLK only */ + "eor.l %[cbit], (%[gpo0]) \n" /* Flip CLK again */ + + "lsl.l #1,%[data] \n" /* ..unrolled.. */ + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %%d1, (%[gpo0]) \n" + ".word 0x51fa \n" + "1: \n" + "eor.l %[cbit], (%[gpo0]) \n" + "eor.l %[cbit], (%[gpo0]) \n" + : /* outputs */ + [data]"+d"(data) + : /* inputs */ + [gpo0]"a"(&GPIO_OUT), + [cbit]"d"(0x00004000), + [dbit]"d"(0x00002000) + : /* clobbers */ + "d0", "d1" + ); +} + +/* Fast low-level byte writer. Don't use with high CPU clock. + * Requires CLK high on entry */ +static inline void _write_fast(unsigned data) +{ + asm volatile ( + "move.w %%sr,%%d3 \n" /* Get current interrupt level */ + "move.w #0x2700,%%sr \n" /* Disable interrupts */ + + "move.l (%[gpo0]), %%d0 \n" /* Get current state of data port */ + "move.l %%d0, %%d1 \n" + "and.l %[dbit], %%d1 \n" /* Check current state of data line */ + "beq.s 1f \n" /* and set it as previous-state bit */ + "bset #8, %[data] \n" + "1: \n" + "move.l %[data], %%d1 \n" /* Compute the 'bit derivative', i.e. a value */ + "lsr.l #1, %%d1 \n" /* with 1's where the data changes from the */ + "eor.l %%d1, %[data] \n" /* previous state, and 0's where it doesn't */ + "swap %[data] \n" /* Shift data to upper byte */ + "lsl.l #8, %[data] \n" + + "lsl.l #1,%[data] \n" /* Shift out MSB */ + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" /* 1: Flip data bit */ + "1: \n" + "eor.l %[cbit], %%d0 \n" /* Flip clock bit */ + "move.l %%d0, (%[gpo0]) \n" /* Output new state */ + "eor.l %[cbit], %%d0 \n" /* Flip clock bit */ + "move.l %%d0, (%[gpo0]) \n" /* Output new state */ + + "lsl.l #1,%[data] \n" /* ..unrolled.. */ + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "lsl.l #1,%[data] \n" + "bcc.s 1f \n" + "eor.l %[dbit], %%d0 \n" + "1: \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + "eor.l %[cbit], %%d0 \n" + "move.l %%d0, (%[gpo0]) \n" + + "move.w %%d3, %%sr \n" /* Restore interrupt level */ + : /* outputs */ + [data]"+d"(data) + : /* inputs */ + [gpo0]"a"(&GPIO_OUT), + [cbit]"d"(0x00004000), + [dbit]"d"(0x00002000) + : /* clobbers */ + "d0", "d1", "d2", "d3" + ); +} + +void lcd_remote_write_command(int cmd) +{ + RS_LO; + CS_LO; + _write_byte(cmd); + CS_HI; +} + +void lcd_remote_write_command_ex(int cmd, int data) +{ + RS_LO; + CS_LO; + _write_byte(cmd); + _write_byte(data); + CS_HI; +} + +void lcd_remote_write_data(const unsigned char* p_bytes, int count) +{ + const unsigned char *p_end = p_bytes + count; + + RS_HI; + CS_LO; + if (cpu_frequency < 50000000) + { + while (p_bytes < p_end) + _write_fast(*p_bytes++); + } + else + { + while (p_bytes < p_end) + _write_byte(*p_bytes++); + } + CS_HI; +} + +int lcd_remote_default_contrast(void) +{ + return DEFAULT_REMOTE_CONTRAST_SETTING; +} + +void lcd_remote_powersave(bool on) +{ + if(remote_initialized) { + if (on) + lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); + else + lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); + } +} + +void lcd_remote_set_contrast(int val) +{ + if (val < 0) + val = 0; + else if (val > 63) + val = 63; + + cached_contrast = val; + if(remote_initialized) + lcd_remote_write_command_ex(LCD_SET_VOLUME, val); +} + +bool remote_detect(void) +{ + return (GPIO_READ & 0x01000000)?false:true; +} + +void lcd_remote_init_device(void) +{ + or_l(0x0000e000, &GPIO_OUT); + or_l(0x0000e000, &GPIO_ENABLE); + or_l(0x0000e000, &GPIO_FUNCTION); + + or_l(0x00000020, &GPIO1_OUT); + or_l(0x00000020, &GPIO1_ENABLE); + or_l(0x00000020, &GPIO1_FUNCTION); + + and_l(~0x01000000, &GPIO_OUT); + and_l(~0x01000000, &GPIO_ENABLE); + or_l(0x01000000, &GPIO_FUNCTION); + + lcd_remote_clear_display(); + tick_add_task(remote_tick); +} + +void lcd_remote_on(void) +{ + CS_HI; + CLK_HI; + sleep(10); + + lcd_remote_write_command(LCD_SET_DUTY_RATIO); + lcd_remote_write_command(0x70); /* 1/128 */ + + lcd_remote_write_command(LCD_OSC_ON); + + lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ + + lcd_remote_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */ + + lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ + + lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ + + sleep(30); + + lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 1, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 2, 0x0c); + lcd_remote_write_command_ex(LCD_SET_GRAY | 3, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 4, 0xcc); + lcd_remote_write_command_ex(LCD_SET_GRAY | 5, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); + lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); + + lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */ + + lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ + + remote_initialized = true; + + lcd_remote_set_flip(cached_flip); + lcd_remote_set_contrast(cached_contrast); + lcd_remote_set_invert_display(cached_invert); +} + +void lcd_remote_off(void) +{ + remote_initialized = false; + CS_HI; + RS_HI; +} + +void lcd_remote_poweroff(void) +{ + /* Set power save -> Power OFF (VDD - VSS) .. that's it */ + if (remote_initialized && remote_detect()) + lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); +} + +/* Monitor remote hotswap */ +static void remote_tick(void) +{ + static bool last_status = false; + static int countdown = 0; + static int init_delay = 0; + bool current_status; + + current_status = remote_detect(); + + /* Only report when the status has changed */ + if (current_status != last_status) + { + last_status = current_status; + countdown = current_status ? 20*HZ : 1; + } + else + { + /* Count down until it gets negative */ + if (countdown >= 0) + countdown--; + + if (current_status) + { + if (!(countdown % 8)) + { + if (--init_delay <= 0) + { + queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); + init_delay = 6; + } + } + } + else + { + if (countdown == 0) + { + queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); + } + } + } +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_remote_update(void) ICODE_ATTR; +void lcd_remote_update(void) +{ + int y; + if(remote_initialized) { + for(y = 0;y < LCD_REMOTE_FBHEIGHT;y++) { + /* Copy display bitmap to hardware. + The COM48-COM63 lines are not connected so we have to skip + them. Further, the column address doesn't wrap, so we + have to update one page at a time. */ + lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); + lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); + lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], + LCD_REMOTE_WIDTH*2); + } + } +} + +/* Update a fraction of the display. */ +void lcd_remote_update_rect(int, int, int, int) ICODE_ATTR; +void lcd_remote_update_rect(int x, int y, int width, int height) +{ + if(remote_initialized) { + int ymax; + + /* The Y coordinates have to work on even 8 pixel rows */ + ymax = (y + height-1) >> 3; + y >>= 3; + + if(x + width > LCD_REMOTE_WIDTH) + width = LCD_REMOTE_WIDTH - x; + if (width <= 0) + return; /* nothing left to do, 0 is harmful to lcd_write_data() */ + if(ymax >= LCD_REMOTE_FBHEIGHT) + ymax = LCD_REMOTE_FBHEIGHT-1; + + /* Copy specified rectangle bitmap to hardware + COM48-COM63 are not connected, so we need to skip those */ + for (; y <= ymax; y++) + { + lcd_remote_write_command(LCD_SET_PAGE | + ((y > 5?y + 2:y) & 0xf)); + lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), + x & 0xf); + + lcd_remote_write_data ( + (unsigned char *)&lcd_remote_framebuffer[y][x], width*2); + } + } +} + +void lcd_remote_set_invert_display(bool yesno) +{ + cached_invert = yesno; + if(remote_initialized) + lcd_remote_write_command(LCD_REVERSE | yesno); +} + +void lcd_remote_set_flip(bool yesno) +{ + cached_flip = yesno; + if(remote_initialized) { + if(yesno) { + lcd_remote_write_command(LCD_SELECT_ADC | 0); + lcd_remote_write_command(LCD_SELECT_SHL | 0); + lcd_remote_write_command_ex(LCD_SET_COM0, 16); + } else { + lcd_remote_write_command(LCD_SELECT_ADC | 1); + lcd_remote_write_command(LCD_SELECT_SHL | 8); + lcd_remote_write_command_ex(LCD_SET_COM0, 0); + } + } +} diff --git a/firmware/target/coldfire/iaudio/lcd-remote-target.h b/firmware/target/coldfire/iaudio/lcd-remote-target.h new file mode 100644 index 0000000000..86c361097b --- /dev/null +++ b/firmware/target/coldfire/iaudio/lcd-remote-target.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#ifndef LCD_REMOTE_TARGET_H +#define LCD_REMOTE_TARGET_H + +#define REMOTE_INIT_LCD 1 +#define REMOTE_DEINIT_LCD 2 + +void lcd_remote_init_device(void); +void lcd_remote_write_command(int cmd); +void lcd_remote_write_command_ex(int cmd, int data); +void lcd_remote_write_data(const unsigned char* p_bytes, int count); +bool remote_detect(void); +void lcd_remote_powersave(bool on); +void lcd_remote_set_contrast(int val); +void lcd_remote_on(void); +void lcd_remote_off(void); +void lcd_remote_poweroff(void); /* for when remote is plugged during shutdown*/ + +extern bool remote_initialized; + +#endif diff --git a/firmware/target/coldfire/iaudio/m5/audio-m5.c b/firmware/target/coldfire/iaudio/m5/audio-m5.c new file mode 100644 index 0000000000..fcedbcad78 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/audio-m5.c @@ -0,0 +1,82 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Michael Sevakis + * + * 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 "cpu.h" +#include "audio.h" +#include "sound.h" + +void audio_set_output_source(int source) +{ + unsigned long txsrc; + + if ((unsigned)source >= AUDIO_NUM_SOURCES) + txsrc = (3 << 8); /* playback, PDOR3 */ + else + txsrc = (4 << 8); /* recording, iis1RcvData */ + + IIS1CONFIG = (IIS1CONFIG & ~(7 << 8)) | txsrc; +} /* audio_set_output_source */ + +void audio_set_source(int source, unsigned flags) +{ + /* Prevent pops from unneeded switching */ + static int last_source = AUDIO_SRC_PLAYBACK; + + (void)flags; + + switch (source) + { + default: /* playback - no recording */ + source = AUDIO_SRC_PLAYBACK; + case AUDIO_SRC_PLAYBACK: + if (source != last_source) + { + audiohw_disable_recording(); + audiohw_set_monitor(false); + /* Reset PDIR2 data flow */ + DATAINCONTROL = (1 << 9); + } + break; + + case AUDIO_SRC_MIC: /* recording only */ + if (source != last_source) + { + audiohw_enable_recording(true); /* source mic */ + /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ + DATAINCONTROL = (3 << 14) | (4 << 3); + } + break; + + case AUDIO_SRC_LINEIN: /* recording only */ + if (source != last_source) + { + audiohw_enable_recording(false); /* source line */ + /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ + DATAINCONTROL = (3 << 14) | (4 << 3); + } + break; + } /* end switch */ + + or_l((1 << 29), &GPIO_OUT); /* Line In */ + or_l((1 << 29), &GPIO_ENABLE); + or_l((1 << 29), &GPIO_FUNCTION); + + last_source = source; +} /* audio_set_source */ + diff --git a/firmware/target/coldfire/iaudio/m5/backlight-m5.c b/firmware/target/coldfire/iaudio/m5/backlight-m5.c new file mode 100644 index 0000000000..63bc5bc30e --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/backlight-m5.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "backlight.h" +#include "backlight-target.h" +#include "pcf50606.h" +#include "lcd.h" + +bool __backlight_init(void) +{ + __backlight_on(); + + return true; /* Backlight always ON after boot. */ +} + +void __backlight_on(void) +{ + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + + pcf50606_write(0x39, 0x07); + set_irq_level(level); +} + +void __backlight_off(void) +{ + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + + pcf50606_write(0x39, 0x00); + set_irq_level(level); +} + +void __remote_backlight_on(void) +{ + and_l(~0x00200000, &GPIO_OUT); +} + +void __remote_backlight_off(void) +{ + or_l(0x00200000, &GPIO_OUT); +} diff --git a/firmware/target/coldfire/iaudio/m5/backlight-target.h b/firmware/target/coldfire/iaudio/m5/backlight-target.h new file mode 100644 index 0000000000..d9c116803e --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/backlight-target.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +#define __BACKLIGHT_INIT +bool __backlight_init(void); +void __backlight_on(void); +void __backlight_off(void); +void __remote_backlight_on(void); +void __remote_backlight_off(void); + +#endif diff --git a/firmware/target/coldfire/iaudio/m5/button-m5.c b/firmware/target/coldfire/iaudio/m5/button-m5.c new file mode 100644 index 0000000000..a5fdd79fde --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/button-m5.c @@ -0,0 +1,151 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "system.h" +#include "button.h" +#include "backlight.h" +#include "adc.h" +#include "lcd-remote-target.h" + +/* have buttons scan by default */ +static bool button_scan_on = true; +static bool hold_button = false; +static bool remote_hold_button = false; + +void button_init_device(void) +{ + /* Power, Remote Play & Hold switch */ + GPIO_FUNCTION |= 0x0e000000; + GPIO_ENABLE &= ~0x0e000000; +} + +void button_enable_scan(bool enable) +{ + button_scan_on = enable; +} + +bool button_scan_enabled(void) +{ + return button_scan_on; +} + +bool button_hold(void) +{ + return (GPIO_READ & 0x08000000) == 0; +} + +bool remote_button_hold(void) +{ + return remote_hold_button; +} + +int button_read_device(void) +{ + int btn = BUTTON_NONE; + bool hold_button_old; + bool remote_hold_button_old; + int data; + + /* normal buttons */ + hold_button_old = hold_button; + hold_button = button_hold(); + +#ifndef BOOTLOADER + /* give BL notice if HB state chaged */ + if (hold_button != hold_button_old) + backlight_hold_changed(hold_button); +#endif + + if (button_scan_on && !hold_button) + { + data = adc_scan(ADC_BUTTONS); + + if (data < 0xf0) + { + if(data < 0x7c) + if(data < 0x42) + btn = BUTTON_LEFT; + else + if(data < 0x62) + btn = BUTTON_RIGHT; + else + btn = BUTTON_SELECT; + else + if(data < 0xb6) + if(data < 0x98) + btn = BUTTON_PLAY; + else + btn = BUTTON_REC; + else + if(data < 0xd3) + btn = BUTTON_DOWN; + else + btn = BUTTON_UP; + } + } + + /* remote buttons */ + data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff; + + remote_hold_button_old = remote_hold_button; + remote_hold_button = data < 0x17; + +#ifndef BOOTLOADER + if (remote_hold_button != remote_hold_button_old) + remote_backlight_hold_changed(remote_hold_button); +#endif + + if (!remote_hold_button) + { + if (data < 0xee) + { + if(data < 0x7a) + if(data < 0x41) + btn |= BUTTON_RC_FF; + else + if(data < 0x61) + btn |= BUTTON_RC_REW; + else + btn |= BUTTON_RC_MODE; + else + if(data < 0xb4) + if(data < 0x96) + btn |= BUTTON_RC_REC; + else + btn |= BUTTON_RC_MENU; + else + if(data < 0xd1) + btn |= BUTTON_RC_VOL_UP; + else + btn |= BUTTON_RC_VOL_DOWN; + } + } + + data = GPIO_READ; + + /* hold and power are mutually exclusive */ + if (!(data & 0x04000000)) + btn |= BUTTON_POWER; + + /* remote play button should be dead if hold */ + if (!remote_hold_button && !(data & 0x02000000)) + btn |= BUTTON_RC_PLAY; + + return btn; +} diff --git a/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S b/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S new file mode 100644 index 0000000000..c973dc2c40 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S @@ -0,0 +1,83 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Jens Arnold + * + * 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" + + .section .icode,"ax",@progbits + + .align 2 + .global lcd_write_command + .type lcd_write_command,@function + +lcd_write_command: + move.l (4, %sp), %d0 + move.w %d0, 0xf0008000 + rts +.wc_end: + .size lcd_write_command,.wc_end-lcd_write_command + + + .align 2 + .global lcd_write_command_ex + .type lcd_write_command_ex,@function + +lcd_write_command_ex: + lea.l 0xf0008000, %a0 + + move.l (4, %sp), %d0 /* Command */ + move.w %d0, (%a0)+ /* Write to LCD, set A0 = 1 */ + + move.l (8, %sp), %d0 /* Data */ + cmp.l #-1, %d0 /* -1? */ + beq.b .last + move.w %d0, (%a0) /* Write to LCD */ + + move.l (12, %sp), %d0 /* Data */ + cmp.l #-1, %d0 /* -1? */ + beq.b .last + move.w %d0, (%a0) /* Write to LCD */ + +.last: + rts +.wcex_end: + .size lcd_write_command_ex,.wcex_end-lcd_write_command_ex + + + .align 2 + .global lcd_write_data + .type lcd_write_data,@function + +lcd_write_data: + move.l (4,%sp), %a0 /* Data pointer */ + move.l (8,%sp), %d0 /* Length */ + + lea 0xf0008002, %a1 +.loop: + /* When running in IRAM, this loop takes 7 cycles plus the LCD write. + The 7 cycles are necessary to follow the LCD timing specs + at 140MHz */ + move.b (%a0)+, %d1 /* 3(1/0) */ + move.w %d1, (%a1) /* 1(0/1) */ + subq.l #1, %d0 /* 1(0/0) */ + nop /* 1(0/0) */ + bne .loop /* 2(0/0) */ + rts +.wd_end: + .size lcd_write_data,.wd_end-lcd_write_data diff --git a/firmware/target/coldfire/iaudio/m5/lcd-m5.c b/firmware/target/coldfire/iaudio/m5/lcd-m5.c new file mode 100644 index 0000000000..2af46b3145 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/lcd-m5.c @@ -0,0 +1,219 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Jens Arnold + * + * 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 "lcd.h" + +/*** definitions ***/ + +/* LCD command codes */ +#define LCD_CNTL_POWER_CONTROL 0x25 +#define LCD_CNTL_VOLTAGE_SELECT 0x2b +#define LCD_CNTL_LINE_INVERT_DRIVE 0x36 +#define LCD_CNTL_GRAY_SCALE_PATTERN 0x39 +#define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e +#define LCD_CNTL_OSC_FREQUENCY 0x5f +#define LCD_CNTL_ON_OFF 0xae +#define LCD_CNTL_OSC_ON_OFF 0xaa +#define LCD_CNTL_OFF_MODE 0xbe +#define LCD_CNTL_POWER_SAVE 0xa8 +#define LCD_CNTL_REVERSE 0xa6 +#define LCD_CNTL_ALL_LIGHTING 0xa4 +#define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4 +#define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0 +#define LCD_CNTL_NLINE_ON_OFF 0xe4 +#define LCD_CNTL_DISPLAY_MODE 0x66 +#define LCD_CNTL_DUTY_SET 0x6d +#define LCD_CNTL_ELECTRONIC_VOLUME 0x81 +#define LCD_CNTL_DATA_INPUT_DIR 0x84 +#define LCD_CNTL_DISPLAY_START_LINE 0x8a +#define LCD_CNTL_AREA_SCROLL 0x10 + +#define LCD_CNTL_PAGE 0xb1 +#define LCD_CNTL_COLUMN 0x13 +#define LCD_CNTL_DATA_WRITE 0x1d + +/*** shared semi-private declarations ***/ +extern const unsigned char lcd_dibits[16] ICONST_ATTR; + +/*** hardware configuration ***/ +int lcd_default_contrast(void) +{ + return DEFAULT_CONTRAST_SETTING; +} + +void lcd_set_contrast(int val) +{ + /* Keep val in acceptable hw range */ + if (val < 0) + val = 0; + else if (val > 127) + val = 127; + + lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, val, -1); +} + +void lcd_set_invert_display(bool yesno) +{ + lcd_write_command(LCD_CNTL_REVERSE | (yesno?1:0)); +} + +/* turn the display upside down (call lcd_update() afterwards) */ +void lcd_set_flip(bool yesno) +{ + if (yesno) + { + lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); + lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 1); + lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 2); + } + else + { + lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 1); + lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); + lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1); + } +} + +void lcd_init_device(void) +{ + /* LCD Reset */ + and_l(~0x00000010, &GPIO1_OUT); + or_l(0x00000010, &GPIO1_ENABLE); + or_l(0x00000010, &GPIO1_FUNCTION); + sleep(1); + or_l(0x00000010, &GPIO1_OUT); + sleep(1); + + lcd_write_command(LCD_CNTL_ON_OFF | 1); /* LCD ON */ + lcd_write_command(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */ + lcd_write_command(LCD_CNTL_REVERSE | 0); /* Reverse OFF */ + lcd_write_command(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */ + lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal dir */ + lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, 4, -1); + lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 1); /* Reverse */ + lcd_write_command_ex(LCD_CNTL_DISPLAY_MODE, 0, -1); /* Greyscale mode */ + lcd_write_command_ex(LCD_CNTL_GRAY_SCALE_PATTERN, 0x53, -1); + lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1); + lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, 40, -1); + + lcd_write_command(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */ + lcd_write_command(LCD_CNTL_POWER_SAVE | 0); + lcd_write_command_ex(LCD_CNTL_VOLTAGE_SELECT, 3, -1); + lcd_write_command_ex(LCD_CNTL_POWER_CONTROL, 0x17, -1); + lcd_write_command_ex(LCD_CNTL_OSC_FREQUENCY, 3, -1); + lcd_write_command(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */ + lcd_write_command_ex(LCD_CNTL_LINE_INVERT_DRIVE, 0x10, -1); + lcd_write_command_ex(LCD_CNTL_TEMP_GRADIENT_SELECT, 0, -1); + + 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) +{ + const unsigned char *src, *src_end; + unsigned char *dst_u, *dst_l; + static unsigned char upper[LCD_WIDTH] IBSS_ATTR; + static unsigned char lower[LCD_WIDTH] IBSS_ATTR; + unsigned int byte; + + by *= 2; + + while (bheight--) + { + src = data; + src_end = data + width; + dst_u = upper; + dst_l = lower; + do + { + byte = *src++; + *dst_u++ = lcd_dibits[byte & 0x0F]; + byte >>= 4; + *dst_l++ = lcd_dibits[byte & 0x0F]; + } + while (src < src_end); + + lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1); + lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); + lcd_write_command(LCD_CNTL_DATA_WRITE); + lcd_write_data(upper, width); + + lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1); + lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); + lcd_write_command(LCD_CNTL_DATA_WRITE); + lcd_write_data(lower, 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_ex(LCD_CNTL_PAGE, y, -1); + lcd_write_command_ex(LCD_CNTL_COLUMN, 0, -1); + + lcd_write_command(LCD_CNTL_DATA_WRITE); + 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) >> 2; + y >>= 2; + + 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_ex(LCD_CNTL_PAGE, y, -1); + lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); + + lcd_write_command(LCD_CNTL_DATA_WRITE); + lcd_write_data (&lcd_framebuffer[y][x], width); + } +} diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c new file mode 100644 index 0000000000..c689488bfe --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/power-m5.c @@ -0,0 +1,89 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "pcf50606.h" +#include "lcd-remote-target.h" + +#ifndef SIMULATOR + +void power_init(void) +{ + /* Charger detect */ + and_l(~0x01000000, &GPIO1_ENABLE); + or_l(0x01000000, &GPIO1_FUNCTION); + + pcf50606_init(); +} + +bool charger_inserted(void) +{ + return (GPIO1_READ & 0x01000000)?true:false; +} + +void ide_power_enable(bool on) +{ + /* GPOOD3 */ + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + if(on) + pcf50606_write(0x3c, 0x07); + else + pcf50606_write(0x3c, 0x00); + set_irq_level(level); +} + +bool ide_powered(void) +{ + return false; +} + +void power_off(void) +{ + lcd_remote_poweroff(); + set_irq_level(HIGHEST_IRQ_LEVEL); + and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */ + asm("halt"); +} + +#else + +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/coldfire/iaudio/pcf50606-iaudio.c b/firmware/target/coldfire/iaudio/pcf50606-iaudio.c new file mode 100644 index 0000000000..f8f6c1d675 --- /dev/null +++ b/firmware/target/coldfire/iaudio/pcf50606-iaudio.c @@ -0,0 +1,127 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "system.h" +#include "kernel.h" +#include "pcf50606.h" +#include "button-target.h" +#include "powermgmt.h" + +/* These voltages were determined by measuring the output of the PCF50606 + on a running X5, and verified by disassembling the original firmware */ +static void set_voltages(void) +{ + static const unsigned char buf[4] = + { + 0xf4, /* IOREGC = 2.9V, ON in all states */ + 0xf0, /* D1REGC = 2.5V, ON in all states */ + 0xf6, /* D2REGC = 3.1V, ON in all states */ + 0xf4, /* D3REGC = 2.9V, ON in all states */ + }; + + pcf50606_write_multiple(0x23, buf, 4); +} + +static void init_pmu_interrupts(void) +{ + /* inital data is interrupt masks */ + unsigned char data[3] = + { + ~0x04, /* unmask ONKEY1S */ + ~0x00, + ~0x06, /* unmask ACDREM, ACDINS */ + }; + + /* make sure GPI0 interrupt is off before unmasking anything */ + and_l(~0xf, &INTPRI5); /* INT32 - Priority 0 (Off) */ + + /* unmask the PMU interrupts we want to service */ + pcf50606_write_multiple(0x05, data, 3); + /* clear INT1-3 as these are left set after standby */ + pcf50606_read_multiple(0x02, data, 3); + + /* Set to read pcf50606 INT but keep GPI0 off until init completes */ + and_l(~0x00000001, &GPIO_ENABLE); + or_l(0x00000001, &GPIO_FUNCTION); + or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ +} + +static inline void enable_pmu_interrupts(void) +{ + /* clear pending GPI0 interrupts first or it may miss the first + H-L transition */ + or_l(0x00000100, &GPIO_INT_CLEAR); + or_l(0x3, &INTPRI5); /* INT32 - Priority 3 */ +} + +void pcf50606_init(void) +{ + pcf50606_i2c_init(); + + /* initialize pmu interrupts but don't service them yet */ + init_pmu_interrupts(); + set_voltages(); + + pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ + pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ + + /* Accessory detect */ + pcf50606_write(0x33, 0x8c); /* ACDAPE=1, THRSHLD=2.20V */ + + /* allow GPI0 interrupts from PMU now */ + enable_pmu_interrupts(); +} + +void pcf50606_reset_timeout(void) +{ + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */ + set_irq_level(level); +} + +/* Handles interrupts generated by the pcf50606 */ +void GPI0(void) __attribute__ ((interrupt_handler, section(".text"))); +void GPI0(void) +{ + unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ + + /* Clear pending GPI0 interrupts */ + or_l(0x00000100, &GPIO_INT_CLEAR); + + /* clear pending interrupts from pcf50606 */ + pcf50606_read_multiple(0x02, data, 3); + + if (data[0] & 0x04) + { + /* ONKEY1S */ + if (GPIO_READ & 0x02000000) + sys_poweroff(); /* main ONKEY */ + else + pcf50606_reset_timeout(); /* remote ONKEY */ + } + + if (data[2] & 0x06) + { + /* ACDINS/ACDREM */ + /* Check if main buttons should be actually be scanned or not + - bias towards "yes" out of paranoia. */ + button_enable_scan((data[2] & 0x02) != 0 || + (pcf50606_read(0x33) & 0x01) != 0); + } +} diff --git a/firmware/target/coldfire/iaudio/system-iaudio.c b/firmware/target/coldfire/iaudio/system-iaudio.c new file mode 100644 index 0000000000..30a4f6e71b --- /dev/null +++ b/firmware/target/coldfire/iaudio/system-iaudio.c @@ -0,0 +1,90 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "timer.h" +#include "pcf50606.h" + +#define MAX_REFRESH_TIMER 59 +#define NORMAL_REFRESH_TIMER 21 +#define DEFAULT_REFRESH_TIMER 4 + +#define RECALC_DELAYS(f) \ + pcf50606_i2c_recalc_delay(f) + +void set_cpu_frequency (long) __attribute__ ((section (".icode"))); +void set_cpu_frequency(long frequency) +{ + switch(frequency) + { + case CPUFREQ_MAX: + DCR = (0x8200 | DEFAULT_REFRESH_TIMER); + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); + RECALC_DELAYS(CPUFREQ_MAX); + PLLCR = 0x03042045 | (PLLCR & 0x70C00000); + CSCR0 = 0x00001180; /* Flash: 4 wait states */ + CSCR1 = 0x00000980; /* LCD: 2 wait states */ + while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. + This may take up to 10ms! */ + timers_adjust_prescale(CPUFREQ_MAX_MULT, true); + DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_MAX; + IDECONFIG1 = 0x106000 | (5 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ + IDECONFIG2 = 0x40000 | (1 << 8); /* TA enable + CS2wait */ + break; + + case CPUFREQ_NORMAL: + DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); + RECALC_DELAYS(CPUFREQ_NORMAL); + PLLCR = 0x06030045 | (PLLCR & 0x70C00000); + CSCR0 = 0x00000580; /* Flash: 1 wait state */ + CSCR1 = 0x00000180; /* LCD: 0 wait states */ + while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. + This may take up to 10ms! */ + timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true); + DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_NORMAL; + IDECONFIG1 = 0x106000 | (5 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ + IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ + break; + default: + DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true); + RECALC_DELAYS(CPUFREQ_DEFAULT); + /* Power down PLL, but keep CLSEL and CRSEL */ + PLLCR = 0x00000200 | (PLLCR & 0x70C00000); + CSCR0 = 0x00000180; /* Flash: 0 wait states */ + CSCR1 = 0x00000180; /* LCD: 0 wait states */ + DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_DEFAULT; + IDECONFIG1 = 0x106000 | (1 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ + IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ + break; + } +} diff --git a/firmware/target/coldfire/iaudio/usb-iaudio.c b/firmware/target/coldfire/iaudio/usb-iaudio.c new file mode 100644 index 0000000000..3bd1a7a458 --- /dev/null +++ b/firmware/target/coldfire/iaudio/usb-iaudio.c @@ -0,0 +1,45 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#include "config.h" +#include +#include "cpu.h" +#include "system.h" + +void usb_init_device(void) +{ + or_l(0x00800010, &GPIO_OUT); /* RESET deasserted, VBUS powered */ + or_l(0x00800010, &GPIO_ENABLE); + or_l(0x00800010, &GPIO_FUNCTION); + + or_l(0x00800000, &GPIO1_FUNCTION); /* USB detect */ +} + +bool usb_detect(void) +{ + return (GPIO1_READ & 0x00800000)?true:false; +} + +void usb_enable(bool on) +{ + if(on) { + or_l(0x00000008, &GPIO1_OUT); + } else { + and_l(~0x00000008, &GPIO1_OUT); + } +} diff --git a/firmware/target/coldfire/iaudio/usb-target.h b/firmware/target/coldfire/iaudio/usb-target.h new file mode 100644 index 0000000000..ab8cac6f99 --- /dev/null +++ b/firmware/target/coldfire/iaudio/usb-target.h @@ -0,0 +1,24 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 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. + * + ****************************************************************************/ +#ifndef USB_TARGET_H +#define USB_TARGET_H + +bool usb_init_device(void); + +#endif diff --git a/firmware/target/coldfire/iaudio/x5/adc-target.h b/firmware/target/coldfire/iaudio/x5/adc-target.h deleted file mode 100644 index 28ba6225d1..0000000000 --- a/firmware/target/coldfire/iaudio/x5/adc-target.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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. - * - ****************************************************************************/ -#ifndef _ADC_TARGET_H_ -#define _ADC_TARGET_H_ - -#define NUM_ADC_CHANNELS 3 - -#define ADC_BUTTONS 0 -#define ADC_REMOTE 1 -#define ADC_BATTERY 2 -#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ - -/* Force a scan now */ -unsigned short adc_scan(int channel); -static inline unsigned short adc_read(int channel) - { return adc_scan(channel); } -static inline void adc_init(void) - {} -#endif /* _ADC_TARGET_H_ */ diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c deleted file mode 100644 index 1895cacfe9..0000000000 --- a/firmware/target/coldfire/iaudio/x5/adc-x5.c +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include "cpu.h" -#include "system.h" -#include "kernel.h" -#include "thread.h" -#include "adc.h" -#include "pcf50606.h" - -/* get remaining 2 bits and return 10 bit value */ -static int get_10bit_voltage(int msbdata) -{ - int data = msbdata << 2; - data |= pcf50606_read(0x31) & 0x3; - return data; -} - -unsigned short adc_scan(int channel) -{ - static const int adcc2_parms[] = - { - [ADC_BUTTONS] = 0x81 | (5 << 1), /* 8b - ADCIN2 */ - [ADC_REMOTE] = 0x81 | (6 << 1), /* 8b - ADCIN3 */ - [ADC_BATTERY] = 0x01 | (0 << 1), /* 10b - BATVOLT, resistive divider */ - }; - - int level; - int data; - - level = set_irq_level(HIGHEST_IRQ_LEVEL); - - pcf50606_write(0x2f, adcc2_parms[channel]); - data = pcf50606_read(0x30); - - if (channel == ADC_BATTERY) - data = get_10bit_voltage(data); - - set_irq_level(level); - - return (unsigned short)data; -} diff --git a/firmware/target/coldfire/iaudio/x5/ata-x5.c b/firmware/target/coldfire/iaudio/x5/ata-x5.c deleted file mode 100644 index 21c088288a..0000000000 --- a/firmware/target/coldfire/iaudio/x5/ata-x5.c +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include "cpu.h" -#include -#include "kernel.h" -#include "system.h" -#include "power.h" -#include "pcf50606.h" - -void ata_reset(void) -{ - and_l(~0x40000000, &GPIO_OUT); - sleep(1); /* > 25us */ - or_l(0x40000000, &GPIO_OUT); - sleep(1); /* > 2ms */ -} - -void ata_enable(bool on) -{ - if(on) - and_l(~0x00000800, &GPIO1_OUT); - else - or_l(0x00000800, &GPIO1_OUT); -} - -bool ata_is_coldstart(void) -{ - return true; /* TODO */ -} - -void ata_device_init(void) -{ - /* ATA reset */ - or_l(0x40000000, &GPIO_OUT); - or_l(0x40000000, &GPIO_ENABLE); - or_l(0x40000000, &GPIO_FUNCTION); - - /* ATA enable */ - or_l(0x00000800, &GPIO1_OUT); - or_l(0x00000800, &GPIO1_ENABLE); - or_l(0x00000800, &GPIO1_FUNCTION); - - /* USB enable */ - and_l(~0x00000008, &GPIO1_OUT); - or_l(0x00000008, &GPIO1_ENABLE); - or_l(0x00000008, &GPIO1_FUNCTION); -} diff --git a/firmware/target/coldfire/iaudio/x5/button-target.h b/firmware/target/coldfire/iaudio/x5/button-target.h deleted file mode 100644 index af1088dfed..0000000000 --- a/firmware/target/coldfire/iaudio/x5/button-target.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#ifndef _BUTTON_TARGET_H_ -#define _BUTTON_TARGET_H_ - -#include -#include "config.h" - -#define HAS_BUTTON_HOLD -#define HAS_REMOTE_BUTTON_HOLD - -bool button_hold(void); -bool remote_button_hold(void); -void button_init_device(void); -int button_read_device(void); -void button_enable_scan(bool enable); -bool button_scan_enabled(void); - -/* iaudio X5 specific button codes */ - - /* Main unit's buttons */ -#define BUTTON_POWER 0x00000001 -#define BUTTON_REC 0x00000002 - -#define BUTTON_LEFT 0x00000004 -#define BUTTON_RIGHT 0x00000008 -#define BUTTON_UP 0x00000010 -#define BUTTON_DOWN 0x00000020 - -#define BUTTON_PLAY 0x00000040 -#define BUTTON_SELECT 0x00000080 - -#define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\ - |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT) - - /* Remote control's buttons */ -#define BUTTON_RC_PLAY 0x00100000 - -#define BUTTON_RC_REW 0x00080000 -#define BUTTON_RC_FF 0x00040000 -#define BUTTON_RC_VOL_UP 0x00020000 -#define BUTTON_RC_VOL_DOWN 0x00010000 - -#define BUTTON_RC_REC 0x00008000 -#define BUTTON_RC_MENU 0x00004000 - -#define BUTTON_RC_MODE 0x00002000 - -#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\ - |BUTTON_RC_REW|BUTTON_RC_FF\ - |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE) - -#define POWEROFF_BUTTON BUTTON_POWER -#define RC_POWEROFF_BUTTON BUTTON_RC_PLAY -#define POWEROFF_COUNT 30 - -#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h deleted file mode 100644 index 86c361097b..0000000000 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#ifndef LCD_REMOTE_TARGET_H -#define LCD_REMOTE_TARGET_H - -#define REMOTE_INIT_LCD 1 -#define REMOTE_DEINIT_LCD 2 - -void lcd_remote_init_device(void); -void lcd_remote_write_command(int cmd); -void lcd_remote_write_command_ex(int cmd, int data); -void lcd_remote_write_data(const unsigned char* p_bytes, int count); -bool remote_detect(void); -void lcd_remote_powersave(bool on); -void lcd_remote_set_contrast(int val); -void lcd_remote_on(void); -void lcd_remote_off(void); -void lcd_remote_poweroff(void); /* for when remote is plugged during shutdown*/ - -extern bool remote_initialized; - -#endif diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c deleted file mode 100644 index 139ebbc2a3..0000000000 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c +++ /dev/null @@ -1,517 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include "system.h" -#include "kernel.h" -#include "lcd-remote.h" - -/* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ - -#define LCD_SET_DUTY_RATIO 0x48 -#define LCD_SELECT_ADC 0xa0 -#define LCD_SELECT_SHL 0xc0 -#define LCD_SET_COM0 0x44 -#define LCD_OSC_ON 0xab -#define LCD_SELECT_DCDC 0x64 -#define LCD_SELECT_RES 0x20 -#define LCD_SET_VOLUME 0x81 -#define LCD_SET_BIAS 0x50 -#define LCD_CONTROL_POWER 0x28 -#define LCD_DISPLAY_ON 0xae -#define LCD_SET_INITLINE 0x40 -#define LCD_SET_COLUMN 0x10 -#define LCD_SET_PAGE 0xb0 -#define LCD_SET_GRAY 0x88 -#define LCD_SET_PWM_FRC 0x90 -#define LCD_SET_POWER_SAVE 0xa8 -#define LCD_REVERSE 0xa6 - -#define CS_LO and_l(~0x00000020, &GPIO1_OUT) -#define CS_HI or_l(0x00000020, &GPIO1_OUT) -#define CLK_LO and_l(~0x00004000, &GPIO_OUT) -#define CLK_HI or_l(0x00004000, &GPIO_OUT) -#define DATA_LO and_l(~0x00002000, &GPIO_OUT) -#define DATA_HI or_l(0x00002000, &GPIO_OUT) -#define RS_LO and_l(~0x00008000, &GPIO_OUT) -#define RS_HI or_l(0x00008000, &GPIO_OUT) - -/* cached settings values */ -static bool cached_invert = false; -static bool cached_flip = false; -static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING; - -bool remote_initialized = false; - -static void remote_tick(void); - -/* Standard low-level byte writer. Requires CLK high on entry */ -static inline void _write_byte(unsigned data) -{ - asm volatile ( - "move.l (%[gpo0]), %%d0 \n" /* Get current state of data line */ - "and.l %[dbit], %%d0 \n" - "beq.s 1f \n" /* and set it as previous-state bit */ - "bset #8, %[data] \n" - "1: \n" - "move.l %[data], %%d0 \n" /* Compute the 'bit derivative', i.e. a value */ - "lsr.l #1, %%d0 \n" /* with 1's where the data changes from the */ - "eor.l %%d0, %[data] \n" /* previous state, and 0's where it doesn't */ - "swap %[data] \n" /* Shift data to upper byte */ - "lsl.l #8, %[data] \n" - - "move.l %[cbit], %%d1 \n" /* Prepare mask for flipping CLK */ - "or.l %[dbit], %%d1 \n" /* and DATA at once */ - - "lsl.l #1,%[data] \n" /* Shift out MSB */ - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" /* 1: Flip both CLK and DATA */ - ".word 0x51fa \n" /* (trapf.w - shadow next insn) */ - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" /* else flip CLK only */ - "eor.l %[cbit], (%[gpo0]) \n" /* Flip CLK again */ - - "lsl.l #1,%[data] \n" /* ..unrolled.. */ - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %%d1, (%[gpo0]) \n" - ".word 0x51fa \n" - "1: \n" - "eor.l %[cbit], (%[gpo0]) \n" - "eor.l %[cbit], (%[gpo0]) \n" - : /* outputs */ - [data]"+d"(data) - : /* inputs */ - [gpo0]"a"(&GPIO_OUT), - [cbit]"d"(0x00004000), - [dbit]"d"(0x00002000) - : /* clobbers */ - "d0", "d1" - ); -} - -/* Fast low-level byte writer. Don't use with high CPU clock. - * Requires CLK high on entry */ -static inline void _write_fast(unsigned data) -{ - asm volatile ( - "move.w %%sr,%%d3 \n" /* Get current interrupt level */ - "move.w #0x2700,%%sr \n" /* Disable interrupts */ - - "move.l (%[gpo0]), %%d0 \n" /* Get current state of data port */ - "move.l %%d0, %%d1 \n" - "and.l %[dbit], %%d1 \n" /* Check current state of data line */ - "beq.s 1f \n" /* and set it as previous-state bit */ - "bset #8, %[data] \n" - "1: \n" - "move.l %[data], %%d1 \n" /* Compute the 'bit derivative', i.e. a value */ - "lsr.l #1, %%d1 \n" /* with 1's where the data changes from the */ - "eor.l %%d1, %[data] \n" /* previous state, and 0's where it doesn't */ - "swap %[data] \n" /* Shift data to upper byte */ - "lsl.l #8, %[data] \n" - - "lsl.l #1,%[data] \n" /* Shift out MSB */ - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" /* 1: Flip data bit */ - "1: \n" - "eor.l %[cbit], %%d0 \n" /* Flip clock bit */ - "move.l %%d0, (%[gpo0]) \n" /* Output new state */ - "eor.l %[cbit], %%d0 \n" /* Flip clock bit */ - "move.l %%d0, (%[gpo0]) \n" /* Output new state */ - - "lsl.l #1,%[data] \n" /* ..unrolled.. */ - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "lsl.l #1,%[data] \n" - "bcc.s 1f \n" - "eor.l %[dbit], %%d0 \n" - "1: \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - "eor.l %[cbit], %%d0 \n" - "move.l %%d0, (%[gpo0]) \n" - - "move.w %%d3, %%sr \n" /* Restore interrupt level */ - : /* outputs */ - [data]"+d"(data) - : /* inputs */ - [gpo0]"a"(&GPIO_OUT), - [cbit]"d"(0x00004000), - [dbit]"d"(0x00002000) - : /* clobbers */ - "d0", "d1", "d2", "d3" - ); -} - -void lcd_remote_write_command(int cmd) -{ - RS_LO; - CS_LO; - _write_byte(cmd); - CS_HI; -} - -void lcd_remote_write_command_ex(int cmd, int data) -{ - RS_LO; - CS_LO; - _write_byte(cmd); - _write_byte(data); - CS_HI; -} - -void lcd_remote_write_data(const unsigned char* p_bytes, int count) -{ - const unsigned char *p_end = p_bytes + count; - - RS_HI; - CS_LO; - if (cpu_frequency < 50000000) - { - while (p_bytes < p_end) - _write_fast(*p_bytes++); - } - else - { - while (p_bytes < p_end) - _write_byte(*p_bytes++); - } - CS_HI; -} - -int lcd_remote_default_contrast(void) -{ - return DEFAULT_REMOTE_CONTRAST_SETTING; -} - -void lcd_remote_powersave(bool on) -{ - if(remote_initialized) { - if (on) - lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); - else - lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); - } -} - -void lcd_remote_set_contrast(int val) -{ - if (val < 0) - val = 0; - else if (val > 63) - val = 63; - - cached_contrast = val; - if(remote_initialized) - lcd_remote_write_command_ex(LCD_SET_VOLUME, val); -} - -bool remote_detect(void) -{ - return (GPIO_READ & 0x01000000)?false:true; -} - -void lcd_remote_init_device(void) -{ - or_l(0x0000e000, &GPIO_OUT); - or_l(0x0000e000, &GPIO_ENABLE); - or_l(0x0000e000, &GPIO_FUNCTION); - - or_l(0x00000020, &GPIO1_OUT); - or_l(0x00000020, &GPIO1_ENABLE); - or_l(0x00000020, &GPIO1_FUNCTION); - - and_l(~0x01000000, &GPIO_OUT); - and_l(~0x01000000, &GPIO_ENABLE); - or_l(0x01000000, &GPIO_FUNCTION); - - lcd_remote_clear_display(); - tick_add_task(remote_tick); -} - -void lcd_remote_on(void) -{ - CS_HI; - CLK_HI; - sleep(10); - - lcd_remote_write_command(LCD_SET_DUTY_RATIO); - lcd_remote_write_command(0x70); /* 1/128 */ - - lcd_remote_write_command(LCD_OSC_ON); - - lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ - - lcd_remote_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */ - - lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ - - lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ - - sleep(30); - - lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); - lcd_remote_write_command_ex(LCD_SET_GRAY | 1, 0x00); - lcd_remote_write_command_ex(LCD_SET_GRAY | 2, 0x0c); - lcd_remote_write_command_ex(LCD_SET_GRAY | 3, 0x00); - lcd_remote_write_command_ex(LCD_SET_GRAY | 4, 0xcc); - lcd_remote_write_command_ex(LCD_SET_GRAY | 5, 0x00); - lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); - lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); - - lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */ - - lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ - - remote_initialized = true; - - lcd_remote_set_flip(cached_flip); - lcd_remote_set_contrast(cached_contrast); - lcd_remote_set_invert_display(cached_invert); -} - -void lcd_remote_off(void) -{ - remote_initialized = false; - CS_HI; - RS_HI; -} - -void lcd_remote_poweroff(void) -{ - /* Set power save -> Power OFF (VDD - VSS) .. that's it */ - if (remote_initialized && remote_detect()) - lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); -} - -/* Monitor remote hotswap */ -static void remote_tick(void) -{ - static bool last_status = false; - static int countdown = 0; - static int init_delay = 0; - bool current_status; - - current_status = remote_detect(); - - /* Only report when the status has changed */ - if (current_status != last_status) - { - last_status = current_status; - countdown = current_status ? 20*HZ : 1; - } - else - { - /* Count down until it gets negative */ - if (countdown >= 0) - countdown--; - - if (current_status) - { - if (!(countdown % 8)) - { - if (--init_delay <= 0) - { - queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); - init_delay = 6; - } - } - } - else - { - if (countdown == 0) - { - queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); - } - } - } -} - -/* Update the display. - This must be called after all other LCD functions that change the display. */ -void lcd_remote_update(void) ICODE_ATTR; -void lcd_remote_update(void) -{ - int y; - if(remote_initialized) { - for(y = 0;y < LCD_REMOTE_FBHEIGHT;y++) { - /* Copy display bitmap to hardware. - The COM48-COM63 lines are not connected so we have to skip - them. Further, the column address doesn't wrap, so we - have to update one page at a time. */ - lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); - lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); - lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], - LCD_REMOTE_WIDTH*2); - } - } -} - -/* Update a fraction of the display. */ -void lcd_remote_update_rect(int, int, int, int) ICODE_ATTR; -void lcd_remote_update_rect(int x, int y, int width, int height) -{ - if(remote_initialized) { - int ymax; - - /* The Y coordinates have to work on even 8 pixel rows */ - ymax = (y + height-1) >> 3; - y >>= 3; - - if(x + width > LCD_REMOTE_WIDTH) - width = LCD_REMOTE_WIDTH - x; - if (width <= 0) - return; /* nothing left to do, 0 is harmful to lcd_write_data() */ - if(ymax >= LCD_REMOTE_FBHEIGHT) - ymax = LCD_REMOTE_FBHEIGHT-1; - - /* Copy specified rectangle bitmap to hardware - COM48-COM63 are not connected, so we need to skip those */ - for (; y <= ymax; y++) - { - lcd_remote_write_command(LCD_SET_PAGE | - ((y > 5?y + 2:y) & 0xf)); - lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), - x & 0xf); - - lcd_remote_write_data ( - (unsigned char *)&lcd_remote_framebuffer[y][x], width*2); - } - } -} - -void lcd_remote_set_invert_display(bool yesno) -{ - cached_invert = yesno; - if(remote_initialized) - lcd_remote_write_command(LCD_REVERSE | yesno); -} - -void lcd_remote_set_flip(bool yesno) -{ - cached_flip = yesno; - if(remote_initialized) { - if(yesno) { - lcd_remote_write_command(LCD_SELECT_ADC | 0); - lcd_remote_write_command(LCD_SELECT_SHL | 0); - lcd_remote_write_command_ex(LCD_SET_COM0, 16); - } else { - lcd_remote_write_command(LCD_SELECT_ADC | 1); - lcd_remote_write_command(LCD_SELECT_SHL | 8); - lcd_remote_write_command_ex(LCD_SET_COM0, 0); - } - } -} diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c deleted file mode 100644 index f8f6c1d675..0000000000 --- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include "system.h" -#include "kernel.h" -#include "pcf50606.h" -#include "button-target.h" -#include "powermgmt.h" - -/* These voltages were determined by measuring the output of the PCF50606 - on a running X5, and verified by disassembling the original firmware */ -static void set_voltages(void) -{ - static const unsigned char buf[4] = - { - 0xf4, /* IOREGC = 2.9V, ON in all states */ - 0xf0, /* D1REGC = 2.5V, ON in all states */ - 0xf6, /* D2REGC = 3.1V, ON in all states */ - 0xf4, /* D3REGC = 2.9V, ON in all states */ - }; - - pcf50606_write_multiple(0x23, buf, 4); -} - -static void init_pmu_interrupts(void) -{ - /* inital data is interrupt masks */ - unsigned char data[3] = - { - ~0x04, /* unmask ONKEY1S */ - ~0x00, - ~0x06, /* unmask ACDREM, ACDINS */ - }; - - /* make sure GPI0 interrupt is off before unmasking anything */ - and_l(~0xf, &INTPRI5); /* INT32 - Priority 0 (Off) */ - - /* unmask the PMU interrupts we want to service */ - pcf50606_write_multiple(0x05, data, 3); - /* clear INT1-3 as these are left set after standby */ - pcf50606_read_multiple(0x02, data, 3); - - /* Set to read pcf50606 INT but keep GPI0 off until init completes */ - and_l(~0x00000001, &GPIO_ENABLE); - or_l(0x00000001, &GPIO_FUNCTION); - or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ -} - -static inline void enable_pmu_interrupts(void) -{ - /* clear pending GPI0 interrupts first or it may miss the first - H-L transition */ - or_l(0x00000100, &GPIO_INT_CLEAR); - or_l(0x3, &INTPRI5); /* INT32 - Priority 3 */ -} - -void pcf50606_init(void) -{ - pcf50606_i2c_init(); - - /* initialize pmu interrupts but don't service them yet */ - init_pmu_interrupts(); - set_voltages(); - - pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ - pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ - - /* Accessory detect */ - pcf50606_write(0x33, 0x8c); /* ACDAPE=1, THRSHLD=2.20V */ - - /* allow GPI0 interrupts from PMU now */ - enable_pmu_interrupts(); -} - -void pcf50606_reset_timeout(void) -{ - int level = set_irq_level(HIGHEST_IRQ_LEVEL); - pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */ - set_irq_level(level); -} - -/* Handles interrupts generated by the pcf50606 */ -void GPI0(void) __attribute__ ((interrupt_handler, section(".text"))); -void GPI0(void) -{ - unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ - - /* Clear pending GPI0 interrupts */ - or_l(0x00000100, &GPIO_INT_CLEAR); - - /* clear pending interrupts from pcf50606 */ - pcf50606_read_multiple(0x02, data, 3); - - if (data[0] & 0x04) - { - /* ONKEY1S */ - if (GPIO_READ & 0x02000000) - sys_poweroff(); /* main ONKEY */ - else - pcf50606_reset_timeout(); /* remote ONKEY */ - } - - if (data[2] & 0x06) - { - /* ACDINS/ACDREM */ - /* Check if main buttons should be actually be scanned or not - - bias towards "yes" out of paranoia. */ - button_enable_scan((data[2] & 0x02) != 0 || - (pcf50606_read(0x33) & 0x01) != 0); - } -} diff --git a/firmware/target/coldfire/iaudio/x5/system-x5.c b/firmware/target/coldfire/iaudio/x5/system-x5.c deleted file mode 100644 index 30a4f6e71b..0000000000 --- a/firmware/target/coldfire/iaudio/x5/system-x5.c +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include "cpu.h" -#include "kernel.h" -#include "system.h" -#include "power.h" -#include "timer.h" -#include "pcf50606.h" - -#define MAX_REFRESH_TIMER 59 -#define NORMAL_REFRESH_TIMER 21 -#define DEFAULT_REFRESH_TIMER 4 - -#define RECALC_DELAYS(f) \ - pcf50606_i2c_recalc_delay(f) - -void set_cpu_frequency (long) __attribute__ ((section (".icode"))); -void set_cpu_frequency(long frequency) -{ - switch(frequency) - { - case CPUFREQ_MAX: - DCR = (0x8200 | DEFAULT_REFRESH_TIMER); - /* Refresh timer for bypass frequency */ - PLLCR &= ~1; /* Bypass mode */ - timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); - RECALC_DELAYS(CPUFREQ_MAX); - PLLCR = 0x03042045 | (PLLCR & 0x70C00000); - CSCR0 = 0x00001180; /* Flash: 4 wait states */ - CSCR1 = 0x00000980; /* LCD: 2 wait states */ - while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. - This may take up to 10ms! */ - timers_adjust_prescale(CPUFREQ_MAX_MULT, true); - DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */ - cpu_frequency = CPUFREQ_MAX; - IDECONFIG1 = 0x106000 | (5 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ - IDECONFIG2 = 0x40000 | (1 << 8); /* TA enable + CS2wait */ - break; - - case CPUFREQ_NORMAL: - DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; - /* Refresh timer for bypass frequency */ - PLLCR &= ~1; /* Bypass mode */ - timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); - RECALC_DELAYS(CPUFREQ_NORMAL); - PLLCR = 0x06030045 | (PLLCR & 0x70C00000); - CSCR0 = 0x00000580; /* Flash: 1 wait state */ - CSCR1 = 0x00000180; /* LCD: 0 wait states */ - while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. - This may take up to 10ms! */ - timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true); - DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */ - cpu_frequency = CPUFREQ_NORMAL; - IDECONFIG1 = 0x106000 | (5 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ - IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ - break; - default: - DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; - /* Refresh timer for bypass frequency */ - PLLCR &= ~1; /* Bypass mode */ - timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true); - RECALC_DELAYS(CPUFREQ_DEFAULT); - /* Power down PLL, but keep CLSEL and CRSEL */ - PLLCR = 0x00000200 | (PLLCR & 0x70C00000); - CSCR0 = 0x00000180; /* Flash: 0 wait states */ - CSCR1 = 0x00000180; /* LCD: 0 wait states */ - DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */ - cpu_frequency = CPUFREQ_DEFAULT; - IDECONFIG1 = 0x106000 | (1 << 10); /* BUFEN2 enable + CS2Pre/CS2Post */ - IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ - break; - } -} diff --git a/firmware/target/coldfire/iaudio/x5/usb-x5.c b/firmware/target/coldfire/iaudio/x5/usb-x5.c deleted file mode 100644 index 3bd1a7a458..0000000000 --- a/firmware/target/coldfire/iaudio/x5/usb-x5.c +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 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. - * - ****************************************************************************/ -#include "config.h" -#include -#include "cpu.h" -#include "system.h" - -void usb_init_device(void) -{ - or_l(0x00800010, &GPIO_OUT); /* RESET deasserted, VBUS powered */ - or_l(0x00800010, &GPIO_ENABLE); - or_l(0x00800010, &GPIO_FUNCTION); - - or_l(0x00800000, &GPIO1_FUNCTION); /* USB detect */ -} - -bool usb_detect(void) -{ - return (GPIO1_READ & 0x00800000)?true:false; -} - -void usb_enable(bool on) -{ - if(on) { - or_l(0x00000008, &GPIO1_OUT); - } else { - and_l(~0x00000008, &GPIO1_OUT); - } -} diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c index 5c7186e567..8738316aa9 100644 --- a/firmware/target/coldfire/pcm-coldfire.c +++ b/firmware/target/coldfire/pcm-coldfire.c @@ -46,7 +46,7 @@ static int peaks[4]; /* p-l, p-r, r-l, r-r */ (4 << 2) ) /* 64 bit clocks / word clock */ #define IIS_RESET 0x800 -#ifdef IAUDIO_X5 +#if defined(IAUDIO_X5) || defined(IAUDIO_M5) #define SET_IIS_CONFIG(x) IIS1CONFIG = (x); #define IIS_CONFIG IIS1CONFIG #define PLLCR_SET_AUDIO_BITS_DEFPARM \ diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c index c3b2631cb0..bc769877ba 100644 --- a/firmware/target/coldfire/system-coldfire.c +++ b/firmware/target/coldfire/system-coldfire.c @@ -136,7 +136,7 @@ default_interrupt (CDROMNOSYNC); /* CD-ROM No sync */ default_interrupt (CDROMILSYNC); /* CD-ROM Illegal sync */ default_interrupt (CDROMNEWBLK); /* CD-ROM New block */ -#ifdef IAUDIO_X5 +#if defined(IAUDIO_X5) || defined(IAUDIO_M5) #define EXCP_BUTTON_GPIO_READ GPIO_READ #define EXCP_BUTTON_MASK 0x0c000000 #define EXCP_BUTTON_VALUE 0x08000000 /* On button and !hold */ diff --git a/uisimulator/sdl/UI-m5.bmp b/uisimulator/sdl/UI-m5.bmp new file mode 100644 index 0000000000..18bdf9a512 Binary files /dev/null and b/uisimulator/sdl/UI-m5.bmp differ diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h index 7f0a567e79..a0551f1201 100644 --- a/uisimulator/sdl/uisdl.h +++ b/uisimulator/sdl/uisdl.h @@ -189,6 +189,24 @@ #define UI_REMOTE_WIDTH 128 #define UI_REMOTE_HEIGHT 96 +#elif defined(IAUDIO_M5) +#define UI_TITLE "iAudio M5" +#define UI_WIDTH 300 /* width of GUI window */ +#define UI_HEIGHT 558 /* height of GUI window */ +/* high-colour */ +#define UI_LCD_POSX 55 /* x position of lcd */ +#define UI_LCD_POSY 61 /* y position of lcd (74 for real aspect) */ +#define UI_LCD_BGCOLOR 100, 135, 100 /* bkgnd color of LCD (no backlight) */ +#define UI_LCD_BGCOLORLIGHT 223, 216, 255 /* bkgnd color of LCD (backlight) */ +#define UI_LCD_WIDTH LCD_WIDTH /* * 1.5 */ +#define UI_LCD_HEIGHT LCD_HEIGHT /* * 1.5 */ +#define UI_REMOTE_BGCOLOR 90, 145, 90 /* bkgnd of remote lcd (no bklight) */ +#define UI_REMOTE_BGCOLORLIGHT 130, 180, 250 /* bkgnd of remote lcd (bklight) */ +#define UI_REMOTE_POSX 12 /* x position of remote lcd */ +#define UI_REMOTE_POSY 462 /* y position of remote lcd */ +#define UI_REMOTE_WIDTH 128 +#define UI_REMOTE_HEIGHT 96 + #elif defined(GIGABEAT_F) #define UI_TITLE "Toshiba Gigabeat" #define UI_WIDTH 401 /* width of GUI window */ -- cgit v1.2.3