From dd754886f5fd4004b521c954e263772d35fb6a46 Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Sat, 12 Aug 2006 08:01:54 +0000 Subject: update the gigabeat code and move to target_tree git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10535 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c | 43 +++++++++++ firmware/target/arm/gigabeat/meg-fx/ata-target.h | 66 +++++++++++++++++ .../target/arm/gigabeat/meg-fx/backlight-meg-fx.c | 38 ++++++++++ .../target/arm/gigabeat/meg-fx/backlight-target.h | 26 +++++++ .../target/arm/gigabeat/meg-fx/button-meg-fx.c | 84 ++++++++++++++++++++++ .../target/arm/gigabeat/meg-fx/button-target.h | 58 +++++++++++++++ firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c | 31 ++++++++ firmware/target/arm/gigabeat/meg-fx/power-meg-fx.c | 75 +++++++++++++++++++ firmware/target/arm/gigabeat/meg-fx/usb-meg-fx.c | 52 ++++++++++++++ firmware/target/arm/gigabeat/meg-fx/usb-target.h | 26 +++++++ 10 files changed, 499 insertions(+) create mode 100644 firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/ata-target.h create mode 100644 firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/backlight-target.h create mode 100644 firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/button-target.h create mode 100644 firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/power-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/usb-meg-fx.c create mode 100644 firmware/target/arm/gigabeat/meg-fx/usb-target.h (limited to 'firmware/target/arm/gigabeat') diff --git a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c new file mode 100644 index 0000000000..58fec1e6a3 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c @@ -0,0 +1,43 @@ +/*************************************************************************** + * __________ __ ___. + * 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) +{ +} + +void ata_enable(bool on) +{ + (void)on; +} + +bool ata_is_coldstart(void) +{ + return true; /* TODO */ +} + +void ata_device_init(void) +{ +} diff --git a/firmware/target/arm/gigabeat/meg-fx/ata-target.h b/firmware/target/arm/gigabeat/meg-fx/ata-target.h new file mode 100644 index 0000000000..95b66ab1bd --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/ata-target.h @@ -0,0 +1,66 @@ +/*************************************************************************** + * __________ __ ___. + * 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 ATA_TARGET_H +#define ATA_TARGET_H + +/* Plain C read & write loops */ +#define PREFER_C_READING +#define PREFER_C_WRITING + +#define ATA_IOBASE 0x18000000 +#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE))) +#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0x02))) +#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x04))) +#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x06))) +#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x08))) +#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x0A))) +#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x0C))) +#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x0E))) +#define ATA_CONTROL (*((volatile unsigned char*)(0x20000000 + 0x1C))) + +#define STATUS_BSY 0x80 +#define STATUS_RDY 0x40 +#define STATUS_DF 0x20 +#define STATUS_DRQ 0x08 +#define STATUS_ERR 0x01 +#define ERROR_ABRT 0x04 + +#define WRITE_PATTERN1 0xa5 +#define WRITE_PATTERN2 0x5a +#define WRITE_PATTERN3 0xaa +#define WRITE_PATTERN4 0x55 + +#define READ_PATTERN1 0xa5 +#define READ_PATTERN2 0x5a +#define READ_PATTERN3 0xaa +#define READ_PATTERN4 0x55 + +#define READ_PATTERN1_MASK 0xff +#define READ_PATTERN2_MASK 0xff +#define READ_PATTERN3_MASK 0xff +#define READ_PATTERN4_MASK 0xff + +#define SET_REG(reg,val) reg = (val) +#define SET_16BITREG(reg,val) reg = (val) + +void ata_reset(void); +void ata_device_init(void); +bool ata_is_coldstart(void); + +#endif diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c new file mode 100644 index 0000000000..8f7c30b5d7 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c @@ -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. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "backlight.h" +#include "lcd.h" + +void __backlight_on(void) +{ +} + +void __backlight_off(void) +{ +} + +void __backlight_set_brightness(int val) +{ + /* The SC606 LED driver of the gigabeat series + * can set the brightness in 64 steps */ + val &= 0x3F; +} diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h new file mode 100644 index 0000000000..3204293131 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * 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 + +void __backlight_on(void); +void __backlight_off(void); +void __backlight_set_brightness(int val); + +#endif diff --git a/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c new file mode 100644 index 0000000000..88a1b4de09 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c @@ -0,0 +1,84 @@ +/*************************************************************************** + * __________ __ ___. + * 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 +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "button.h" +#include "kernel.h" +#include "backlight.h" +#include "adc.h" +#include "system.h" + +void button_init_device(void) +{ + /* Power, Remote Play & Hold switch */ +} + +bool button_hold(void) +{ + return (GPGDAT & (1 << 15)); +} + +int button_read_device(void) +{ + int btn = BUTTON_NONE; + int touchpad = GPJDAT; + int buttons = GPGDAT; + + /* Check for hold first */ + if (buttons & (1 << 15)) + return btn; + + /* the side buttons */ + if (buttons & (1 << 0)) + btn |= BUTTON_POWER; + + if (buttons & (1 << 1)) + btn |= BUTTON_MENU; + + if (buttons & (1 << 2)) + btn |= BUTTON_VOL_UP; + + if (buttons & (1 << 3)) + btn |= BUTTON_VOL_DOWN; + + if (buttons & (1 << 4)) + btn |= BUTTON_A; + + /* the touchpad */ + if (touchpad & (1 << 0)) + btn |= BUTTON_UP; + + if (touchpad & (1 << 12)) + btn |= BUTTON_RIGHT; + + if (touchpad & (1 << 6)) + btn |= BUTTON_DOWN; + + if (touchpad & (1 << 7)) + btn |= BUTTON_LEFT; + + if (touchpad & (1 << 3)) + btn |= BUTTON_SELECT; + + return btn; +} + diff --git a/firmware/target/arm/gigabeat/meg-fx/button-target.h b/firmware/target/arm/gigabeat/meg-fx/button-target.h new file mode 100644 index 0000000000..95fb72e601 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/button-target.h @@ -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. + * + ****************************************************************************/ +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(void); + +/* Toshiba Gigabeat specific button codes */ + +#define BUTTON_POWER 0x00000001 +#define BUTTON_MENU 0x00000002 + +#define BUTTON_LEFT 0x00000004 +#define BUTTON_RIGHT 0x00000008 +#define BUTTON_UP 0x00000010 +#define BUTTON_DOWN 0x00000020 + +#define BUTTON_VOL_UP 0x00000040 +#define BUTTON_VOL_DOWN 0x00000080 + +#define BUTTON_SELECT 0x00000100 +#define BUTTON_A 0x00000200 + + +#define BUTTON_MAIN (BUTTON_POWER|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\ + |BUTTON_UP|BUTTON_DOWN|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ + |BUTTON_SELECT|BUTTON_A) + + +#define BUTTON_REMOTE 0 + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c new file mode 100644 index 0000000000..5ec62271ad --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c @@ -0,0 +1,31 @@ +#include "config.h" +#include "cpu.h" +#include "lcd.h" +#include "kernel.h" +#include "system.h" + +void lcd_init_device(void); +void lcd_update_rec(int, int, int, int); +void lcd_update(void); + +/* LCD init */ +void lcd_init_device(void) +{ +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + (void)x; + (void)y; + (void)width; + (void)height; + memcpy(FRAME, &lcd_framebuffer, sizeof(lcd_framebuffer)); +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} diff --git a/firmware/target/arm/gigabeat/meg-fx/power-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/power-meg-fx.c new file mode 100644 index 0000000000..688b44eaa6 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/power-meg-fx.c @@ -0,0 +1,75 @@ +/*************************************************************************** + * __________ __ ___. + * 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" + +#ifndef SIMULATOR + +void power_init(void) +{ + /* Charger detect */ +} + +bool charger_inserted(void) +{ + return !(GPFDAT & (1 << 4)); +} + +void ide_power_enable(bool on) +{ + (void)on; +} + +bool ide_powered(void) +{ + return true; +} + +void power_off(void) +{ +} + +#else /* SIMULATOR */ + +bool charger_inserted(void) +{ + return false; +} + +void charger_enable(bool on) +{ + (void)on; +} + +void power_off(void) +{ +} + +void ide_power_enable(bool on) +{ + (void)on; +} + +#endif /* SIMULATOR */ + diff --git a/firmware/target/arm/gigabeat/meg-fx/usb-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/usb-meg-fx.c new file mode 100644 index 0000000000..6e0f31e8c7 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/usb-meg-fx.c @@ -0,0 +1,52 @@ +/*************************************************************************** + * __________ __ ___. + * 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) +{ +} + +bool usb_detect(void) +{ + return (GPFDAT & 1) ? false : true; +} + +void usb_enable(bool on) +{ + if(on) { + int i; + + GPBDAT &= 0x7EF; + GPBCON |= 1<<8; + + GPGDAT &= 0xE7FF; + GPGDAT |= 1<<11; + + for (i = 0; i < 10000000; i++) {continue;} + + GPBCON &= 0x2FFCFF; + GPBDAT |= 1<<5; + GPBDAT |= 1<<6; + } else { + /* TODO how turn USB mode back off again? */ + } +} diff --git a/firmware/target/arm/gigabeat/meg-fx/usb-target.h b/firmware/target/arm/gigabeat/meg-fx/usb-target.h new file mode 100644 index 0000000000..baeb539b38 --- /dev/null +++ b/firmware/target/arm/gigabeat/meg-fx/usb-target.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * 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); +bool usb_detect(void); +void usb_enable(bool on); + +#endif -- cgit v1.2.3