From 7b97fe21c0f2c9b6742ad50439020023f385fe6c Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Thu, 20 Sep 2007 04:46:41 +0000 Subject: Beginning of an M:Robe 500i port. Currently only in the bootloader stage. Needs another piece of code to start the boot process - will be in the wiki. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14763 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/olympus/mrobe-500/adc-mr500.c | 46 +++++ firmware/target/arm/olympus/mrobe-500/adc-target.h | 38 ++++ firmware/target/arm/olympus/mrobe-500/ata-mr500.c | 130 +++++++++++++ firmware/target/arm/olympus/mrobe-500/ata-target.h | 71 +++++++ .../target/arm/olympus/mrobe-500/backlight-mr500.c | 50 +++++ .../arm/olympus/mrobe-500/backlight-target.h | 31 ++++ .../target/arm/olympus/mrobe-500/button-mr500.c | 56 ++++++ .../target/arm/olympus/mrobe-500/button-target.h | 99 ++++++++++ .../target/arm/olympus/mrobe-500/kernel-mr500.c | 48 +++++ firmware/target/arm/olympus/mrobe-500/lcd-mr500.c | 206 +++++++++++++++++++++ firmware/target/arm/olympus/mrobe-500/lcd-target.h | 21 +++ .../target/arm/olympus/mrobe-500/power-mr500.c | 93 ++++++++++ .../target/arm/olympus/mrobe-500/system-mr500.c | 181 ++++++++++++++++++ .../target/arm/olympus/mrobe-500/timer-mr500.c | 108 +++++++++++ .../target/arm/olympus/mrobe-500/timer-target.h | 39 ++++ firmware/target/arm/olympus/mrobe-500/usb-mr500.c | 55 ++++++ 16 files changed, 1272 insertions(+) create mode 100644 firmware/target/arm/olympus/mrobe-500/adc-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/adc-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/ata-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/ata-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/backlight-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/backlight-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/button-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/button-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/kernel-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/lcd-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/lcd-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/power-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/system-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/timer-mr500.c create mode 100644 firmware/target/arm/olympus/mrobe-500/timer-target.h create mode 100644 firmware/target/arm/olympus/mrobe-500/usb-mr500.c (limited to 'firmware/target/arm/olympus') diff --git a/firmware/target/arm/olympus/mrobe-500/adc-mr500.c b/firmware/target/arm/olympus/mrobe-500/adc-mr500.c new file mode 100644 index 0000000000..4fb2aa3677 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/adc-mr500.c @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "cpu.h" +#include "adc-target.h" +#include "kernel.h" + +/* prototypes */ +static void adc_tick(void); + +void adc_init(void) +{ + /* attach the adc reading to the tick */ + tick_add_task(adc_tick); +} + +/* Called to get the recent ADC reading */ +inline unsigned short adc_read(int channel) +{ + return (short)channel; +} + +/* add this to the tick so that the ADC converts are done in the background */ +static void adc_tick(void) +{ +} + + + + diff --git a/firmware/target/arm/olympus/mrobe-500/adc-target.h b/firmware/target/arm/olympus/mrobe-500/adc-target.h new file mode 100644 index 0000000000..fbf38ee13d --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/adc-target.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +/* only two channels used by the Gigabeat */ +#define NUM_ADC_CHANNELS 2 + +#define ADC_BATTERY 0 +#define ADC_HPREMOTE 1 +#define ADC_UNKNOWN_3 2 +#define ADC_UNKNOWN_4 3 +#define ADC_UNKNOWN_5 4 +#define ADC_UNKNOWN_6 5 +#define ADC_UNKNOWN_7 6 +#define ADC_UNKNOWN_8 7 + +#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ +#define ADC_READ_ERROR 0xFFFF + +#endif diff --git a/firmware/target/arm/olympus/mrobe-500/ata-mr500.c b/firmware/target/arm/olympus/mrobe-500/ata-mr500.c new file mode 100644 index 0000000000..b4028d5ead --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/ata-mr500.c @@ -0,0 +1,130 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "thread.h" +#include "system.h" +#include "power.h" +#include "panic.h" +#include "pcf50606.h" +#include "ata-target.h" +#include "backlight-target.h" + +/* ARESET on C7C68300 and RESET on ATA interface (Active Low) */ +#define ATA_RESET_ENABLE return +#define ATA_RESET_DISABLE return + +/* ATA_EN on C7C68300 */ +#define USB_ATA_ENABLE return +#define USB_ATA_DISABLE return + +void ata_reset(void) +{ + ATA_RESET_ENABLE; + sleep(1); /* > 25us */ + ATA_RESET_DISABLE; + sleep(1); /* > 2ms */ +} + +/* This function is called before enabling the USB bus */ +void ata_enable(bool on) +{ + if(on) + USB_ATA_DISABLE; + else + USB_ATA_ENABLE; +} + +bool ata_is_coldstart(void) +{ + return false; +} + +void ata_device_init(void) +{ + /* ATA reset */ + ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ +} + +#if !defined(BOOTLOADER) +void copy_read_sectors(unsigned char* buf, int wordcount) +{ + __buttonlight_trigger(); + + /* Unaligned transfer - slow copy */ + if ( (unsigned long)buf & 1) + { /* not 16-bit aligned, copy byte by byte */ + unsigned short tmp = 0; + unsigned char* bufend = buf + wordcount*2; + do + { + tmp = ATA_DATA; + *buf++ = tmp & 0xff; /* I assume big endian */ + *buf++ = tmp >> 8; /* and don't use the SWAB16 macro */ + } while (buf < bufend); /* tail loop is faster */ + return; + } + /* This should never happen, but worth watching for */ + if(wordcount > (1 << 18)) + panicf("atd-meg-fx.c: copy_read_sectors: too many sectors per read!"); + +//#define GIGABEAT_DEBUG_ATA +#ifdef GIGABEAT_DEBUG_ATA + static int line = 0; + static char str[256]; + snprintf(str, sizeof(str), "ODD DMA to %08x, %d", buf, wordcount); + lcd_puts(10, line, str); + line = (line+1) % 32; + lcd_update(); +#endif + /* Reset the channel */ + DMASKTRIG0 |= 4; + /* Wait for DMA controller to be ready */ + while(DMASKTRIG0 & 0x2) + ; + while(DSTAT0 & (1 << 20)) + ; + /* Source is ATA_DATA, on AHB Bus, Fixed */ + DISRC0 = (int) 0x18000000; + DISRCC0 = 0x1; + /* Dest mapped to physical address, on AHB bus, increment */ + DIDST0 = (int) buf; + if(DIDST0 < 0x30000000) + DIDST0 += 0x30000000; + DIDSTC0 = 0; + + /* DACK/DREQ Sync to AHB, Whole service, No reload, 16-bit transfers */ + DCON0 = ((1 << 30) | (1<<27) | (1<<22) | (1<<20)) | wordcount; + + /* Activate the channel */ + DMASKTRIG0 = 0x2; + + invalidate_dcache_range((void *)buf, wordcount*2); + + /* Start DMA */ + DMASKTRIG0 |= 0x1; + + /* Wait for transfer to complete */ + while((DSTAT0 & 0x000fffff)) + priority_yield(); + /* Dump cache for the buffer */ +} +#endif diff --git a/firmware/target/arm/olympus/mrobe-500/ata-target.h b/firmware/target/arm/olympus/mrobe-500/ata-target.h new file mode 100644 index 0000000000..87d8a9b535 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/ata-target.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef ATA_TARGET_H +#define ATA_TARGET_H + +/* Plain C read & write loops */ +#define PREFER_C_READING +#define PREFER_C_WRITING +#if !defined(BOOTLOADER) +//#define ATA_OPTIMIZED_READING +//void copy_read_sectors(unsigned char* buf, int wordcount); +#endif + +#define ATA_IOBASE 0x50000000 +#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE+0xa0))) +#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0xa2))) +#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x24))) +#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x26))) +#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x28))) +#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x2A))) +#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x2C))) +#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x2E))) +#define ATA_CONTROL (*((volatile unsigned char*)(ATA_IOBASE + 0x9C))) + +#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/olympus/mrobe-500/backlight-mr500.c b/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c new file mode 100644 index 0000000000..6a335d357c --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c @@ -0,0 +1,50 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "backlight-target.h" +#include "backlight.h" +#include "lcd.h" +#include "power.h" + +void __backlight_on(void) +{ +} + +void __backlight_off(void) +{ +} + +/* Assumes that the backlight has been initialized */ +void __backlight_set_brightness(int brightness) +{ + (void) brightness; +} + +void __backlight_dim(bool dim_now) +{ + (void) dim_now; +} + +bool __backlight_init(void) +{ + return true; +} diff --git a/firmware/target/arm/olympus/mrobe-500/backlight-target.h b/firmware/target/arm/olympus/mrobe-500/backlight-target.h new file mode 100644 index 0000000000..d28cfbbdf1 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/backlight-target.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +bool __backlight_init(void); +void __backlight_on(void); +void __backlight_off(void); +void __backlight_set_brightness(int brightness); + +/* true: backlight fades off - false: backlight fades on */ +void __backlight_dim(bool dim); + +#endif diff --git a/firmware/target/arm/olympus/mrobe-500/button-mr500.c b/firmware/target/arm/olympus/mrobe-500/button-mr500.c new file mode 100644 index 0000000000..9cafab5c14 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/button-mr500.c @@ -0,0 +1,56 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "button.h" +#include "kernel.h" +#include "backlight.h" +#include "adc.h" +#include "system.h" +#include "backlight-target.h" + +static int const remote_buttons[] = +{ + BUTTON_NONE, /* Headphones connected - remote disconnected */ + BUTTON_RC_PLAY, + BUTTON_RC_DSP, + BUTTON_RC_REW, + BUTTON_RC_FF, + BUTTON_RC_VOL_UP, + BUTTON_RC_VOL_DOWN, + BUTTON_NONE, /* Remote control attached - no buttons pressed */ + BUTTON_NONE, /* Nothing in the headphone socket */ +}; + +void button_init_device(void) +{ + /* Power, Remote Play & Hold switch */ +} + +inline bool button_hold(void) +{ + return false; +} + +int button_read_device(void) +{ + return 0; +} diff --git a/firmware/target/arm/olympus/mrobe-500/button-target.h b/firmware/target/arm/olympus/mrobe-500/button-target.h new file mode 100644 index 0000000000..6637c5bf2b --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/button-target.h @@ -0,0 +1,99 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _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 + +/* Remote control buttons */ + +#define BUTTON_RC_VOL_UP 0x00000400 +#define BUTTON_RC_VOL_DOWN 0x00000800 +#define BUTTON_RC_FF 0x00001000 +#define BUTTON_RC_REW 0x00002000 + +#define BUTTON_RC_PLAY 0x00004000 +#define BUTTON_RC_DSP 0x00008000 + +/* Toshiba Gigabeat specific remote button ADC values */ +/* The remote control uses ADC 1 to emulate button pushes + Reading (approx) Button HP plugged in? Remote plugged in? + 0 N/A Yes No + 125 Play/Pause Cant tell Yes + 241 Speaker+ Cant tell Yes + 369 Rewind Cant tell Yes + 492 Fast Fwd Cant tell Yes + 616 Vol + Cant tell Yes + 742 Vol - Cant tell Yes + 864 None Cant tell Yes + 1023 N/A No No +*/ + +/* + Notes: + + Buttons on the remote are translated into equivalent button presses just + as if you were pressing them on the Gigabeat itself. + + We cannot tell if the hold is asserted on the remote. The Hold function on + the remote is to block the output of the buttons changing. + + Only one button can be sensed at a time. If another is pressed, the button + with the lowest reading is dominant. So, if Rewind and Vol + are pressed + at the same time, Rewind value is the one that is read. +*/ + + + + +#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 (BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_FF\ + |BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_RC_DSP) + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c new file mode 100644 index 0000000000..27bb0475e4 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c @@ -0,0 +1,48 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "system.h" +#include "kernel.h" +#include "timer.h" +#include "thread.h" + +extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); + +void tick_start(unsigned int interval_in_ms) +{ + (void)interval_in_ms; +} + +void TIMER4(void) +{ + int i; + + /* Run through the list of tick tasks */ + for(i = 0; i < MAX_NUM_TICK_TASKS; i++) + { + if(tick_funcs[i]) + { + tick_funcs[i](); + } + } + + current_tick++; + +} diff --git a/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c new file mode 100644 index 0000000000..5e41b829e1 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c @@ -0,0 +1,206 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * Some of this is based on the Cowon A2 Firmware release: + * http://www.cowonglobal.com/download/gnu/cowon_pmp_a2_src_1.59_GPL.tar.gz + * + * 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 "string.h" +#include "lcd.h" +#include "kernel.h" +#include "memory.h" +#include "system-target.h" + +static volatile bool lcd_on = true; +volatile bool lcd_poweroff = false; +/* +** These are imported from lcd-16bit.c +*/ +extern unsigned fg_pattern; +extern unsigned bg_pattern; + +bool lcd_enabled(void) +{ + return lcd_on; +} + +/* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c + * and code by Catalin Patulea from the M:Robe 500i linux port + */ +void lcd_init_device(void) +{ + unsigned int addr; + + /* Clear the Frame */ + memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT); + + outw(0x00ff, IO_OSD_MODE); + outw(0x0002, IO_OSD_VIDWINMD); + outw(0x2001, IO_OSD_OSDWINMD0); + outw(0x0002, IO_OSD_OSDWINMD1); + outw(0x0000, IO_OSD_ATRMD); + outw(0x0000, IO_OSD_RECTCUR); + + outw((480*2) / 32, IO_OSD_OSDWIN0OFST); + addr = ((int)FRAME-CONFIG_SDRAM_START) / 32; + outw(addr >> 16, IO_OSD_OSDWINADH); + outw(addr & 0xFFFF, IO_OSD_OSDWIN0ADL); + + outw(80, IO_OSD_BASEPX); + outw(2, IO_OSD_BASEPY); + + outw(0, IO_OSD_OSDWIN0XP); + outw(0, IO_OSD_OSDWIN0YP); + outw(480, IO_OSD_OSDWIN0XL); + outw(640, IO_OSD_OSDWIN0YL); +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + fb_data *dst, *src; + + if (!lcd_on) + return; + + if (x + width > LCD_WIDTH) + width = LCD_WIDTH - x; /* Clip right */ + if (x < 0) + width += x, x = 0; /* Clip left */ + if (width <= 0) + return; /* nothing left to do */ + + if (y + height > LCD_HEIGHT) + height = LCD_HEIGHT - y; /* Clip bottom */ + if (y < 0) + height += y, y = 0; /* Clip top */ + if (height <= 0) + return; /* nothing left to do */ + + dst = (fb_data *)FRAME + LCD_WIDTH*y + x; + src = &lcd_framebuffer[y][x]; + + /* Copy part of the Rockbox framebuffer to the second framebuffer */ + if (width < LCD_WIDTH) + { + int y; + /* Not full width - do line-by-line */ + for(y=0;y= 2 or else */ + width &= ~1; + height >>= 1; + + fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1; + + z = stride*src_y; + yuv_src[0] = src[0] + z + src_x; + yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); + yuv_src[2] = src[2] + (yuv_src[1] - src[1]); + + do + { + lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width, + stride); + yuv_src[0] += stride << 1; /* Skip down two luma lines */ + yuv_src[1] += stride >> 1; /* Skip down one chroma line */ + yuv_src[2] += stride >> 1; + dst -= 2; + } + while (--height > 0); +} + +void lcd_set_contrast(int val) { + (void) val; + // TODO: +} + +void lcd_set_invert_display(bool yesno) { + (void) yesno; + // TODO: +} + +void lcd_blit(const fb_data* data, int bx, int y, int bwidth, + int height, int stride) +{ + (void) data; + (void) bx; + (void) y; + (void) bwidth; + (void) height; + (void) stride; + //TODO: +} + +void lcd_set_flip(bool yesno) { + (void) yesno; + // TODO: +} + diff --git a/firmware/target/arm/olympus/mrobe-500/lcd-target.h b/firmware/target/arm/olympus/mrobe-500/lcd-target.h new file mode 100644 index 0000000000..bac1bef237 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/lcd-target.h @@ -0,0 +1,21 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +extern void lcd_enable(bool state); + diff --git a/firmware/target/arm/olympus/mrobe-500/power-mr500.c b/firmware/target/arm/olympus/mrobe-500/power-mr500.c new file mode 100644 index 0000000000..28fe6a297a --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/power-mr500.c @@ -0,0 +1,93 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "pcf50606.h" +#include "backlight.h" +#include "backlight-target.h" + +#ifndef SIMULATOR + +void power_init(void) +{ + /* Initialize IDE power pin */ + ide_power_enable(true); + /* Charger detect */ +} + +bool charger_inserted(void) +{ + return false; +} + +/* Returns true if the unit is charging the batteries. */ +bool charging_state(void) { + return false; +} + +void ide_power_enable(bool on) +{ + if (on) + return; + else + return; +} + +bool ide_powered(void) +{ + return true; +} + +void power_off(void) +{ + /* turn off backlight and wait for 1 second */ + __backlight_off(); + sleep(HZ); + /* set SLEEP bit to on in CLKCON to turn off */ +// CLKCON |=(1<<3); +} + +#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/olympus/mrobe-500/system-mr500.c b/firmware/target/arm/olympus/mrobe-500/system-mr500.c new file mode 100644 index 0000000000..c93c9f6260 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/system-mr500.c @@ -0,0 +1,181 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "kernel.h" +#include "system.h" +#include "panic.h" + +#define default_interrupt(name) \ + extern __attribute__((weak,alias("UIRQ"))) void name (void) + +default_interrupt(TIMER0); +default_interrupt(TIMER1); +default_interrupt(TIMER2); +default_interrupt(TIMER3); +default_interrupt(CCD_VD0); +default_interrupt(CCD_VD1); +default_interrupt(CCD_WEN); +default_interrupt(VENC); +default_interrupt(SERIAL0); +default_interrupt(SERIAL1); +default_interrupt(EXT_HOST); +default_interrupt(DSPHINT); +default_interrupt(UART0); +default_interrupt(UART1); +default_interrupt(USB_DMA); +default_interrupt(USB_CORE); +default_interrupt(VLYNQ); +default_interrupt(MTC0); +default_interrupt(MTC1); +default_interrupt(SD_MMC); +default_interrupt(SDIO_MS); +default_interrupt(GIO0); +default_interrupt(GIO1); +default_interrupt(GIO2); +default_interrupt(GIO3); +default_interrupt(GIO4); +default_interrupt(GIO5); +default_interrupt(GIO6); +default_interrupt(GIO7); +default_interrupt(GIO8); +default_interrupt(GIO9); +default_interrupt(GIO10); +default_interrupt(GIO11); +default_interrupt(GIO12); +default_interrupt(GIO13); +default_interrupt(GIO14); +default_interrupt(GIO15); +default_interrupt(PREVIEW0); +default_interrupt(PREVIEW1); +default_interrupt(WATCHDOG); +default_interrupt(I2C); +default_interrupt(CLKC); +default_interrupt(ICE); +default_interrupt(ARMCOM_RX); +default_interrupt(ARMCOM_TX); +default_interrupt(RESERVED); + +static void (* const irqvector[])(void) = +{ + TIMER0,TIMER1,TIMER2,TIMER3,CCD_VD0,CCD_VD1, + CCD_WEN,VENC,SERIAL0,SERIAL1,EXT_HOST,DSPHINT, + UART0,UART1,USB_DMA,USB_CORE,VLYNQ,MTC0,MTC1, + SD_MMC,SDIO_MS,GIO0,GIO1,GIO2,GIO3,GIO4,GIO5, + GIO6,GIO7,GIO8,GIO9,GIO10,GIO11,GIO12,GIO13, + GIO14,GIO15,PREVIEW0,PREVIEW1,WATCHDOG,I2C,CLKC, + ICE,ARMCOM_RX,ARMCOM_TX,RESERVED +}; + +static const char * const irqname[] = +{ + "TIMER0","TIMER1","TIMER2","TIMER3","CCD_VD0","CCD_VD1", + "CCD_WEN","VENC","SERIAL0","SERIAL1","EXT_HOST","DSPHINT", + "UART0","UART1","USB_DMA","USB_CORE","VLYNQ","MTC0","MTC1", + "SD_MMC","SDIO_MS","GIO0","GIO1","GIO2","GIO3","GIO4","GIO5", + "GIO6","GIO7","GIO8","GIO9","GIO10","GIO11","GIO12","GIO13", + "GIO14","GIO15","PREVIEW0","PREVIEW1","WATCHDOG","I2C","CLKC", + "ICE","ARMCOM_RX","ARMCOM_TX","RESERVED" +}; + +static void UIRQ(void) +{ + unsigned int offset = inw(IO_INTC_IRQENTRY0); + panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]); +} + +void irq_handler(void) __attribute__((interrupt ("IRQ"), naked)); +void irq_handler(void) +{ + /* + * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c + */ + + asm volatile ( + "sub lr, lr, #4 \r\n" + "stmfd sp!, {r0-r3, ip, lr} \r\n" + "mov r0, #0x00030000 \r\n" + "ldr r0, [r0, #0x518] \r\n" + "ldr r1, =irqvector \r\n" + "ldr r1, [r1, r0, lsl #2] \r\n" + "mov lr, pc \r\n" + "bx r1 \r\n" + "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" + ); +} + +void system_reboot(void) +{ + +} + +void system_init(void) +{ + /* taken from linux/arch/arm/mach-itdm320-20/irq.c */ + + /* Clearing all FIQs and IRQs. */ + outw(0xFFFF, IO_INTC_IRQ0); + outw(0xFFFF, IO_INTC_IRQ1); + outw(0xFFFF, IO_INTC_IRQ2); + + outw(0xFFFF, IO_INTC_FIQ0); + outw(0xFFFF, IO_INTC_FIQ1); + outw(0xFFFF, IO_INTC_FIQ2); + + /* Masking all Interrupts. */ + outw(0, IO_INTC_EINT0); + outw(0, IO_INTC_EINT1); + outw(0, IO_INTC_EINT2); + + /* Setting INTC to all IRQs. */ + outw(0, IO_INTC_FISEL0); + outw(0, IO_INTC_FISEL1); + outw(0, IO_INTC_FISEL2); +} + +int system_memory_guard(int newmode) +{ + (void)newmode; + return 0; +} + +#ifdef HAVE_ADJUSTABLE_CPU_FREQ + +void set_cpu_frequency(long frequency) +{ + if (frequency == CPUFREQ_MAX) + { + asm volatile("mov r0, #0\n" + "mrc p15, 0, r0, c1, c0, 0\n" + "orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/ + "mcr p15, 0, r0, c1, c0, 0" : : : "r0"); + + FREQ = CPUFREQ_MAX; + } + else + { + asm volatile("mov r0, #0\n" + "mrc p15, 0, r0, c1, c0, 0\n" + "bic r0, r0, #3<<30\n" /* set to FastBus mode*/ + "mcr p15, 0, r0, c1, c0, 0" : : : "r0"); + + FREQ = CPUFREQ_NORMAL; + } +} + +#endif diff --git a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c new file mode 100644 index 0000000000..cd3cec5663 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c @@ -0,0 +1,108 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id: $ +* +* Copyright (C) 2007 by Karl Kurbjun +* +* All files in this archive are subject to the GNU General Public License. +* See the file COPYING in the source tree root for full license agreement. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "timer.h" +#include "logf.h" + +/* GPB0/TOUT0 should already have been configured as output so that pin + should not be a functional pin and TIMER0 output unseen there */ +void TIMER0(void) +{ + if (pfn_timer != NULL) + pfn_timer(); +} + +static void stop_timer(void) +{ +} + +bool __timer_set(long cycles, bool start) +{ + /* taken from linux/arch/arm/mach-itdm320-20/time.c and timer-meg-fx.c */ + + /* Turn off all timers */ +/* outw(CONFIG_TIMER0_TMMD_STOP, IO_TIMER0_TMMD); + outw(CONFIG_TIMER1_TMMD_STOP, IO_TIMER1_TMMD); + outw(CONFIG_TIMER2_TMMD_STOP, IO_TIMER2_TMMD); + outw(CONFIG_TIMER3_TMMD_STOP, IO_TIMER3_TMMD); + */ + /* Turn Timer0 to Free Run mode */ +// outw(CONFIG_TIMER0_TMMD_FREE_RUN, IO_TIMER0_TMMD); + + bool retval = false; + + /* Find the minimum factor that puts the counter in range 1-65535 */ + unsigned int prescaler = (cycles + 65534) / 65535; + + /* Test this by writing 1's to registers to see how many bits we have */ + /* Maximum divider setting is x / 1024 / 65536 = x / 67108864 */ + { + int oldlevel; + unsigned int divider; + + if (start && pfn_unregister != NULL) + { + pfn_unregister(); + pfn_unregister = NULL; + } + + oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); + + /* Max prescale is 1023+1 */ + for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++); + + /* Setup the Prescalar */ + outw(prescaler, IO_TIMER0_TMPRSCL); + + /* Setup the Divisor */ + outw(divider, IO_TIMER0_TMDIV); + + set_irq_level(oldlevel); + + retval = true; + } + + return retval; +} + +bool __timer_register(void) +{ + bool retval = true; + + int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS); + + stop_timer(); + + /* Turn Timer0 to Free Run mode */ + outw(0x0002, IO_TIMER0_TMMD); + + set_interrupt_status(oldstatus, IRQ_FIQ_STATUS); + + return retval; +} + +void __timer_unregister(void) +{ + int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS); + stop_timer(); + set_interrupt_status(oldstatus, IRQ_FIQ_STATUS); +} diff --git a/firmware/target/arm/olympus/mrobe-500/timer-target.h b/firmware/target/arm/olympus/mrobe-500/timer-target.h new file mode 100644 index 0000000000..320b35d5d3 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/timer-target.h @@ -0,0 +1,39 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id: $ +* +* Copyright (C) 2007 by Karl Kurbjun +* +* All files in this archive are subject to the GNU General Public License. +* See the file COPYING in the source tree root for full license agreement. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ +#ifndef TIMER_TARGET_H +#define TIMER_TARGET_H + +/* timer is based on PCLK and minimum division is 2 */ +#define TIMER_FREQ (49156800/2) + +bool __timer_set(long cycles, bool set); +bool __timer_register(void); +void __timer_unregister(void); + +#define __TIMER_SET(cycles, set) \ + __timer_set(cycles, set) + +#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \ + int_prio, timer_callback) \ + __timer_register() + +#define __TIMER_UNREGISTER(...) \ + __timer_unregister() + +#endif /* TIMER_TARGET_H */ diff --git a/firmware/target/arm/olympus/mrobe-500/usb-mr500.c b/firmware/target/arm/olympus/mrobe-500/usb-mr500.c new file mode 100644 index 0000000000..e8d0e39c2e --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/usb-mr500.c @@ -0,0 +1,55 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2007 by Karl Kurbjun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "kernel.h" +#include "ata.h" + +#define USB_RST_ASSERT +#define USB_RST_DEASSERT + +#define USB_VPLUS_PWR_ASSERT +#define USB_VPLUS_PWR_DEASSERT + +#define USB_UNIT_IS_PRESENT false + +/* The usb detect is one pin to the cpu active low */ +inline bool usb_detect(void) +{ + return USB_UNIT_IS_PRESENT; +} + +void usb_init_device(void) +{ +// ata_enable(true); +} + +void usb_enable(bool on) +{ + if (on) + { + USB_VPLUS_PWR_ASSERT; + } + else + { + USB_VPLUS_PWR_DEASSERT; + } +} -- cgit v1.2.3