From 80f1688423eaad7a2ad9e4809331e192bcd0047d Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 30 Sep 2007 08:57:49 +0000 Subject: I got bullied in IRC by linuxstb and markun... git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14909 a1c6a512-1295-4272-9138-f99709370657 --- firmware/SOURCES | 26 +-- firmware/boot.lds | 2 +- 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 | 131 ------------- firmware/target/arm/olympus/mrobe-500/ata-target.h | 70 ------- .../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 | 96 ---------- .../target/arm/olympus/mrobe-500/button-target.h | 63 ------- firmware/target/arm/olympus/mrobe-500/crt0.S | 206 -------------------- .../target/arm/olympus/mrobe-500/kernel-mr500.c | 63 ------- 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 | 95 ---------- firmware/target/arm/olympus/mrobe-500/spi-mr500.c | 77 -------- firmware/target/arm/olympus/mrobe-500/spi-target.h | 29 --- .../target/arm/olympus/mrobe-500/system-mr500.c | 210 --------------------- .../target/arm/olympus/mrobe-500/system-target.h | 32 ---- .../target/arm/olympus/mrobe-500/timer-mr500.c | 106 ----------- .../target/arm/olympus/mrobe-500/timer-target.h | 39 ---- firmware/target/arm/olympus/mrobe-500/uart-mr500.c | 172 ----------------- .../target/arm/olympus/mrobe-500/uart-target.h | 33 ---- firmware/target/arm/olympus/mrobe-500/usb-mr500.c | 55 ------ .../target/arm/tms320dm320/mrobe-500/adc-mr500.c | 46 +++++ .../target/arm/tms320dm320/mrobe-500/adc-target.h | 38 ++++ .../target/arm/tms320dm320/mrobe-500/ata-mr500.c | 131 +++++++++++++ .../target/arm/tms320dm320/mrobe-500/ata-target.h | 70 +++++++ .../arm/tms320dm320/mrobe-500/backlight-mr500.c | 50 +++++ .../arm/tms320dm320/mrobe-500/backlight-target.h | 31 +++ .../arm/tms320dm320/mrobe-500/button-mr500.c | 96 ++++++++++ .../arm/tms320dm320/mrobe-500/button-target.h | 63 +++++++ firmware/target/arm/tms320dm320/mrobe-500/crt0.S | 206 ++++++++++++++++++++ .../arm/tms320dm320/mrobe-500/kernel-mr500.c | 63 +++++++ .../target/arm/tms320dm320/mrobe-500/lcd-mr500.c | 206 ++++++++++++++++++++ .../target/arm/tms320dm320/mrobe-500/lcd-target.h | 21 +++ .../target/arm/tms320dm320/mrobe-500/power-mr500.c | 95 ++++++++++ .../target/arm/tms320dm320/mrobe-500/spi-mr500.c | 77 ++++++++ .../target/arm/tms320dm320/mrobe-500/spi-target.h | 29 +++ .../arm/tms320dm320/mrobe-500/system-mr500.c | 210 +++++++++++++++++++++ .../arm/tms320dm320/mrobe-500/system-target.h | 32 ++++ .../target/arm/tms320dm320/mrobe-500/timer-mr500.c | 106 +++++++++++ .../arm/tms320dm320/mrobe-500/timer-target.h | 39 ++++ .../target/arm/tms320dm320/mrobe-500/uart-mr500.c | 172 +++++++++++++++++ .../target/arm/tms320dm320/mrobe-500/uart-target.h | 33 ++++ .../target/arm/tms320dm320/mrobe-500/usb-mr500.c | 55 ++++++ tools/configure | 2 +- 47 files changed, 1884 insertions(+), 1884 deletions(-) delete mode 100644 firmware/target/arm/olympus/mrobe-500/adc-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/adc-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/ata-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/ata-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/backlight-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/backlight-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/button-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/button-target.h delete mode 100755 firmware/target/arm/olympus/mrobe-500/crt0.S delete mode 100644 firmware/target/arm/olympus/mrobe-500/kernel-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/lcd-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/lcd-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/power-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/spi-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/spi-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/system-mr500.c delete mode 100755 firmware/target/arm/olympus/mrobe-500/system-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/timer-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/timer-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/uart-mr500.c delete mode 100644 firmware/target/arm/olympus/mrobe-500/uart-target.h delete mode 100644 firmware/target/arm/olympus/mrobe-500/usb-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/adc-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/ata-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/button-target.h create mode 100755 firmware/target/arm/tms320dm320/mrobe-500/crt0.S create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/spi-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c create mode 100755 firmware/target/arm/tms320dm320/mrobe-500/system-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/timer-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/uart-target.h create mode 100644 firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c diff --git a/firmware/SOURCES b/firmware/SOURCES index 45bedd9dbe..7e2d328c72 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -333,7 +333,7 @@ target/arm/crt0-pp.S #elif CONFIG_CPU == PNX0101 target/arm/pnx0101/crt0-pnx0101.S #elif defined(OLYMPUS_MROBE_500) -target/arm/olympus/mrobe-500/crt0.S +target/arm/tms320dm320/mrobe-500/crt0.S #elif defined(CPU_ARM) target/arm/crt0.S #endif /* defined(CPU_*) */ @@ -622,18 +622,18 @@ target/arm/imx31/gigabeat-s/pcm-imx31.c #ifdef MROBE_500 #ifndef SIMULATOR -target/arm/olympus/mrobe-500/adc-mr500.c -target/arm/olympus/mrobe-500/ata-mr500.c -target/arm/olympus/mrobe-500/backlight-mr500.c -target/arm/olympus/mrobe-500/button-mr500.c -target/arm/olympus/mrobe-500/kernel-mr500.c -target/arm/olympus/mrobe-500/lcd-mr500.c -target/arm/olympus/mrobe-500/power-mr500.c -target/arm/olympus/mrobe-500/system-mr500.c -target/arm/olympus/mrobe-500/timer-mr500.c -target/arm/olympus/mrobe-500/usb-mr500.c -target/arm/olympus/mrobe-500/uart-mr500.c -target/arm/olympus/mrobe-500/spi-mr500.c +target/arm/tms320dm320/mrobe-500/adc-mr500.c +target/arm/tms320dm320/mrobe-500/ata-mr500.c +target/arm/tms320dm320/mrobe-500/backlight-mr500.c +target/arm/tms320dm320/mrobe-500/button-mr500.c +target/arm/tms320dm320/mrobe-500/kernel-mr500.c +target/arm/tms320dm320/mrobe-500/lcd-mr500.c +target/arm/tms320dm320/mrobe-500/power-mr500.c +target/arm/tms320dm320/mrobe-500/system-mr500.c +target/arm/tms320dm320/mrobe-500/timer-mr500.c +target/arm/tms320dm320/mrobe-500/usb-mr500.c +target/arm/tms320dm320/mrobe-500/uart-mr500.c +target/arm/tms320dm320/mrobe-500/spi-mr500.c #ifndef BOOTLOADER #endif diff --git a/firmware/boot.lds b/firmware/boot.lds index e3dbb49a8c..062370bf20 100644 --- a/firmware/boot.lds +++ b/firmware/boot.lds @@ -10,7 +10,7 @@ OUTPUT_ARCH(arm) #ifdef CPU_PP INPUT(target/arm/crt0-pp-bl.o) #elif defined(OLYMPUS_MROBE_500) -INPUT(target/arm/olympus/mrobe-500/crt0.o) +INPUT(target/arm/tms320dm320/mrobe-500/crt0.o) #else INPUT(target/arm/crt0.o) #endif diff --git a/firmware/target/arm/olympus/mrobe-500/adc-mr500.c b/firmware/target/arm/olympus/mrobe-500/adc-mr500.c deleted file mode 100644 index 39d92d67b0..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/adc-mr500.c +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 deleted file mode 100644 index 7d4713a186..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/adc-target.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 deleted file mode 100644 index 47a8c61a45..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/ata-mr500.c +++ /dev/null @@ -1,131 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 (IO_GIO_BITCLR0 = 1 << 10) -#define ATA_RESET_DISABLE (IO_GIO_BITSET0 = 1 << 10) - -/* ATA_EN on C7C68300 */ -#define USB_ATA_ENABLE (IO_GIO_BITSET0 = 1 << 2) -#define USB_ATA_DISABLE (IO_GIO_BITCLR0 = 1 << 2) - -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 true; -} - -void ata_device_init(void) -{ - /* ATA reset */ - ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ - IO_GIO_DIR0&=~(1<<10); -} - -#if 0 -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 deleted file mode 100644 index 97b6f62c86..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/ata-target.h +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 - -#define ATA_IOBASE 0x50000000 -#define REGISTER_OFFSET (ATA_IOBASE+0x00400000) /* A21 = High */ -#define CONTROL_OFFSET (ATA_IOBASE+0x00800000) /* A22 = High */ -#define IDE_SHIFT 17 -#define ATA_DATA (*((volatile unsigned short*)(REGISTER_OFFSET + (0x00 << IDE_SHIFT)))) -#define ATA_ERROR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x01 << IDE_SHIFT)))) -#define ATA_NSECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x02 << IDE_SHIFT)))) -#define ATA_SECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x03 << IDE_SHIFT)))) -#define ATA_LCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x04 << IDE_SHIFT)))) -#define ATA_HCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x05 << IDE_SHIFT)))) -#define ATA_SELECT (*((volatile unsigned char*)(REGISTER_OFFSET + (0x06 << IDE_SHIFT)))) -#define ATA_COMMAND (*((volatile unsigned char*)(REGISTER_OFFSET + (0x07 << IDE_SHIFT)))) -#define ATA_CONTROL (*((volatile unsigned char*)(CONTROL_OFFSET + (0x06 << IDE_SHIFT)))) - -#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 deleted file mode 100644 index 3c80ede00d..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 deleted file mode 100644 index 783b9e1320..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/backlight-target.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 deleted file mode 100644 index 1d0d2714a8..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/button-mr500.c +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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" -#include "uart-target.h" - -#define BUTTON_TIMEOUT 50 - -#define BUTTON_START_BYTE 0xF0 -#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ - /* but always the same one for the session? */ - -void button_init_device(void) -{ - /* GIO is the power button, set as input */ - IO_GIO_DIR0 |= 0x01; -} - -inline bool button_hold(void) -{ - return false; -} - -int button_read_device(void) -{ - char data[5], c; - int i = 0; - int btn = BUTTON_NONE; - - if ((IO_GIO_BITSET0&0x01) == 0) - btn |= BUTTON_POWER; - - uart1_heartbeat(); - while (uartAvailable()) - { - if (uart1_getch(&c)) - { - if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2)) - { - data[i++] = c; - } - else if (c == BUTTON_START_BYTE || - c == BUTTON_START_BYTE2) - { - data[0] = c; - i = 1; - } - - if (i == 5) - { - if (data[1]& (1<<7)) - btn |= BUTTON_RC_HEART; - if (data[1]& (1<<6)) - btn |= BUTTON_RC_MODE; - if (data[1]& (1<<5)) - btn |= BUTTON_RC_VOL_DOWN; - if (data[1]& (1<<4)) - btn |= BUTTON_RC_VOL_UP; - if (data[1]& (1<<3)) - btn |= BUTTON_RC_REW; - if (data[1]& (1<<2)) - btn |= BUTTON_RC_FF; - if (data[1]& (1<<1)) - btn |= BUTTON_RC_DOWN; - if (data[1]& (1<<0)) - btn |= BUTTON_RC_PLAY; - break; - } - } - } - return btn; -} diff --git a/firmware/target/arm/olympus/mrobe-500/button-target.h b/firmware/target/arm/olympus/mrobe-500/button-target.h deleted file mode 100644 index f574321717..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/button-target.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 by Jonathan Gordon - * - * 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); - -/* m:robe 500 specific button codes */ - -#define BUTTON_POWER 0x00000001 - -/* Remote control buttons */ - -#define BUTTON_RC_HEART 0x00000002 -#define BUTTON_RC_MODE 0x00000004 -#define BUTTON_RC_VOL_DOWN 0x00000008 -#define BUTTON_RC_VOL_UP 0x00000010 - - -#define BUTTON_RC_PLAY 0x00000020 -#define BUTTON_RC_REW 0x00000040 -#define BUTTON_RC_FF 0x00000080 -#define BUTTON_RC_DOWN 0x00000100 -#define BUTTON_TOUCH 0x00000200 - -/* compatibility hacks */ -#define BUTTON_LEFT BUTTON_RC_REW -#define BUTTON_RIGHT BUTTON_RC_FF -#define POWEROFF_BUTTON BUTTON_POWER -#define POWEROFF_COUNT 40 - -#define BUTTON_MAIN BUTTON_POWER - -#define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \ - BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \ - BUTTON_RC_PLAY|BUTTON_RC_DOWN| \ - BUTTON_RC_REW|BUTTON_RC_FF) - -#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/olympus/mrobe-500/crt0.S b/firmware/target/arm/olympus/mrobe-500/crt0.S deleted file mode 100755 index 193470fd4a..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/crt0.S +++ /dev/null @@ -1,206 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Linus Nielsen Feltzing - * - * Arm bootloader and startup code based on startup.s from the iPodLinux loader - * - * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org) - * Copyright (c) 2005, Bernard Leach - * - * 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 .init.text,"ax",%progbits - - .global start -start: - msr cpsr, #0xd3 /* enter supervisor mode, disable IRQ */ - -#if !defined(DEBUG) - /* Copy exception handler code to address 0 */ - ldr r2, =_vectorsstart - ldr r3, =_vectorsend - ldr r4, =_vectorscopy -1: - cmp r3, r2 - ldrhi r5, [r4], #4 - strhi r5, [r2], #4 - bhi 1b -#else - ldr r1, =vectors - ldr r0, =irq_handler - str r0, [r1, #24] - ldr r0, =fiq_handler - str r0, [r1, #28] -#endif - - /* Disable high vectors (at 0xffff0000 instead of 0x00000000) */ - mrc p15, 0, r0, c1, c0 - and r0, r0, #~(1<<13) - mcr p15, 0, r0, c1, c0 - -#if !defined(BOOTLOADER) - -#if !defined(STUB) - /* Zero out IBSS */ - ldr r2, =_iedata - ldr r3, =_iend - mov r4, #0 -1: - cmp r3, r2 - strhi r4, [r2], #4 - bhi 1b - - /* Copy the IRAM */ - ldr r2, =_iramcopy - ldr r3, =_iramstart - ldr r4, =_iramend -1: - cmp r4, r3 - ldrhi r5, [r2], #4 - strhi r5, [r3], #4 - bhi 1b -#endif /* !STUB */ -#endif /* !BOOTLOADER */ - - /* Initialise bss section to zero */ - ldr r2, =_edata - ldr r3, =_end - mov r4, #0 -1: - cmp r3, r2 - strhi r4, [r2], #4 - bhi 1b - - /* Set up some stack and munge it with 0xdeadbeef */ - ldr r3, =stackend - ldr r2, =stackbegin - ldr r4, =0xdeadbeef -1: - cmp r3, r2 - strhi r4, [r2], #4 - bhi 1b - - /* Set up stack for IRQ mode */ - msr cpsr_c, #0xd2 - ldr sp, =irq_stack - /* Set up stack for FIQ mode */ - msr cpsr_c, #0xd1 - ldr sp, =fiq_stack - - /* Let abort and undefined modes use IRQ stack */ - msr cpsr_c, #0xd7 - ldr sp, =irq_stack - msr cpsr_c, #0xdb - ldr sp, =irq_stack - /* Switch to supervisor mode (no IRQ) */ - msr cpsr_c, #0xd3 - ldr sp, =stackend - -#ifdef BOOTLOADER - /* get the high part of our execute address */ - ldr r2, =0xffffff00 - and r4, pc, r2 - - /* Copy bootloader to safe area - 0x01900000 */ - mov r5, #0x00900000 - add r5, r5, #0x01000000 - ldr r6, = _dataend - sub r0, r6, r5 /* length of loader */ - add r0, r4, r0 /* r0 points to start of loader */ -1: - cmp r5, r6 - ldrcc r2, [r4], #4 - strcc r2, [r5], #4 - bcc 1b - - ldr pc, =start_loc /* jump to the relocated start_loc: */ - -#endif - -start_loc: - bl main - /* main() should never return */ - -/* Exception handlers. Will be copied to address 0 after memory remapping */ - .section .vectors,"aw" - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - ldr pc, [pc, #24] - - /* Exception vectors */ - .global vectors -vectors: - .word start - .word undef_instr_handler - .word software_int_handler - .word prefetch_abort_handler - .word data_abort_handler - .word reserved_handler - .word irq_handler - .word fiq_handler - - .text - -#if !defined(STUB) - .global irq - .global fiq - .global UIE -#endif - -/* All illegal exceptions call into UIE with exception address as first - parameter. This is calculated differently depending on which exception - we're in. Second parameter is exception number, used for a string lookup - in UIE. - */ -undef_instr_handler: - mov r0, lr - mov r1, #0 - b UIE - -/* We run supervisor mode most of the time, and should never see a software - exception being thrown. Perhaps make it illegal and call UIE? - */ -software_int_handler: -reserved_handler: - movs pc, lr - -prefetch_abort_handler: - sub r0, lr, #4 - mov r1, #1 - b UIE - -data_abort_handler: - sub r0, lr, #8 - mov r1, #2 - b UIE - -UIE: - b UIE - -/* 256 words of IRQ stack */ - .space 256*4 -irq_stack: - -/* 256 words of FIQ stack */ - .space 256*4 -fiq_stack: diff --git a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c deleted file mode 100644 index be2b14b3cb..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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) -{ - IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; - - /* Setup the Prescalar (Divide by 10) - * Based on linux/include/asm-arm/arch-integrator/timex.h - */ - IO_TIMER1_TMPRSCL = 0x000A; - - /* Setup the Divisor */ - IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; - - /* Turn Timer1 to Free Run mode */ - IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN; - - /* Enable the interrupt */ - IO_INTC_EINT0 |= 1< ) \___| < | \_\ ( <_> > < < - * 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 deleted file mode 100644 index c64cc56276..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/lcd-target.h +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 deleted file mode 100644 index 3a6dad77f4..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/power-mr500.c +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 */ - /* set GIO17 (ATA power) on and output */ - ide_power_enable(true); - IO_GIO_DIR1&=~(1<<1); - /* 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) - IO_GIO_BITCLR1=(1<<1); - else - IO_GIO_BITSET1=(1<<1); -} - -bool ide_powered(void) -{ - return !(IO_GIO_BITSET1&(1<<1)); -} - -void power_off(void) -{ - /* turn off backlight and wait for 1 second */ - __backlight_off(); - sleep(HZ); - /* Hard shutdown */ - IO_GIO_BITSET1|=1<<10; -} - -#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/spi-mr500.c b/firmware/target/arm/olympus/mrobe-500/spi-mr500.c deleted file mode 100644 index c47ab8f6ed..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/spi-mr500.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPI interface driver for the DM320 SoC - * - * Copyright (C) 2007 shirour - * Copyright (C) 2007 Catalin Patulea - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "system.h" - -#define GIO_TS_ENABLE (1<<2) -#define clr_gio_enable() IO_GIO_BITSET1=GIO_TS_ENABLE -#define set_gio_enable() IO_GIO_BITCLR1=GIO_TS_ENABLE - -int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, - uint8_t *rx_bytes, unsigned int rx_size) -{ - /* Activate the slave select pin */ - set_gio_enable(); - - while (tx_size--) - { - /* Send one byte */ - IO_SERIAL0_TX_DATA = *tx_bytes++; - - /* Wait until transfer finished */ - while (IO_SERIAL0_RX_DATA & 0x100); - } - - while (rx_size--) - { - /* Make the clock tick */ - IO_SERIAL0_TX_DATA = 0; - - /* Wait until transfer finished */ - unsigned short data; - while ((data = IO_SERIAL0_RX_DATA) & 0x100); - - *rx_bytes++ = data & 0xff; - } - - clr_gio_enable(); - - return 0; -} - -void spi_init(void) -{ - /* Set SCLK idle level = 0 */ - IO_SERIAL0_MODE |= (1<<10); - - /* Enable TX */ - IO_SERIAL0_TX_ENABLE = 0x0001; - - /* Set GIO 18 to output for touch screen slave enable */ - IO_GIO_DIR1&=~GIO_TS_ENABLE; - clr_gio_enable(); -} diff --git a/firmware/target/arm/olympus/mrobe-500/spi-target.h b/firmware/target/arm/olympus/mrobe-500/spi-target.h deleted file mode 100644 index 866919dc27..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/spi-target.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 by Catalin Patulea - * - * 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 SPI_TARGET_H -#define SPI_TARGET_H - -#include - -void spi_init(void); -int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, - uint8_t *rx_bytes, unsigned int rx_size); - -#endif diff --git a/firmware/target/arm/olympus/mrobe-500/system-mr500.c b/firmware/target/arm/olympus/mrobe-500/system-mr500.c deleted file mode 100644 index fad2d4331e..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/system-mr500.c +++ /dev/null @@ -1,210 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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 = (IO_INTC_IRQENTRY0>>2)-1; - 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( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ - "sub sp, sp, #8 \n"); /* Reserve stack */ - irqvector[(IO_INTC_IRQENTRY0>>2)-1](); - asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ - "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ - "subs pc, lr, #4 \n"); /* Return from FIQ */ -} - -void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked)); -void fiq_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 enable_interrupts (void) -{ - asm volatile ("msr cpsr_c, #0x13" ); -} - -void system_init(void) -{ - /* taken from linux/arch/arm/mach-itdm320-20/irq.c */ - - /* Clearing all FIQs and IRQs. */ - IO_INTC_IRQ0 = 0xFFFF; - IO_INTC_IRQ1 = 0xFFFF; - IO_INTC_IRQ2 = 0xFFFF; - - IO_INTC_FIQ0 = 0xFFFF; - IO_INTC_FIQ1 = 0xFFFF; - IO_INTC_FIQ2 = 0xFFFF; - - /* Masking all Interrupts. */ - IO_INTC_EINT0 = 0; - IO_INTC_EINT1 = 0; - IO_INTC_EINT2 = 0; - - /* Setting INTC to all IRQs. */ - IO_INTC_FISEL0 = 0; - IO_INTC_FISEL1 = 0; - IO_INTC_FISEL2 = 0; - - IO_INTC_ENTRY_TBA0 = - IO_INTC_ENTRY_TBA1 = 0; - - /* set GIO26 (reset pin) to output and low */ - IO_GIO_BITCLR1=(1<<10); - IO_GIO_DIR1&=~(1<<10); - - enable_interrupts(); -} - -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/system-target.h b/firmware/target/arm/olympus/mrobe-500/system-target.h deleted file mode 100755 index 7adfda6f7d..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/system-target.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 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 SYSTEM_TARGET_H -#define SYSTEM_TARGET_H - -#include "system-arm.h" - -#define CPUFREQ_SLEEP 32768 -#define CPUFREQ_DEFAULT 24000000 -#define CPUFREQ_NORMAL 30000000 -#define CPUFREQ_MAX 80000000 - -#define inw(p) (*((volatile unsigned short*)((p) + PHY_IO_BASE))) -#define outw(v,p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)) = (v)) - -#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c deleted file mode 100644 index 21449ed19f..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** -* __________ __ ___. -* 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(); - IO_INTC_IRQ0 |= 1< 1024; prescaler >>= 1, divider++); - - /* Setup the Prescalar */ - IO_TIMER0_TMPRSCL = prescaler; - - /* Setup the Divisor */ - IO_TIMER0_TMDIV = divider; - - set_irq_level(oldlevel); - - return true; -} - -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 */ - IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN; - - IO_INTC_EINT0 |= 1< ) \___| < | \_\ ( <_> > < < -* 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 (27000000) - -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/uart-mr500.c b/firmware/target/arm/olympus/mrobe-500/uart-mr500.c deleted file mode 100644 index 66e59eaaac..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/uart-mr500.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * (C) Copyright 2007 Catalin Patulea - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - */ -#include "config.h" -#include "cpu.h" -#include "system.h" - -/* UART 0/1 */ - -#define CONFIG_UART_BRSR 87 -#define MAX_UART_BUFFER 32 -static unsigned char uart1buffer[MAX_UART_BUFFER]; -int uart1read = 0, uart1write = 0, uart1count = 0; - -void do_checksums(char *data, int len, char *xor, char *add) -{ - int i; - *xor = data[0]; - *add = data[0]; - for(i=1;i= 0x20); - - // Write character - IO_UART1_DTRR=ch; -} - -// Unsigned integer to ASCII hexadecimal conversion -void uartPutHex(unsigned int n) { - unsigned int i; - - for (i = 8; i != 0; i--) { - unsigned int digit = n >> 28; - uartPutc(digit >= 10 ? digit - 10 + 'A' : digit + '0'); - n <<= 4; - } -} - -void uartPuts(const char *str) { - char ch; - while ((ch = *str++) != '\0') { - uartPutc(ch); - } -} - -void uartGets(char *str, unsigned int size) { - for (;;) { - char ch; - - // Wait for FIFO to contain something - while ((IO_UART1_RFCR & 0x3f) == 0); - - // Read character - ch = (char)IO_UART1_DTRR; - - // Echo character back - IO_UART1_DTRR=ch; - - // If CR, also echo LF, null-terminate, and return - if (ch == '\r') { - IO_UART1_DTRR='\n'; - if (size) { - *str++ = '\0'; - } - return; - } - - // Append to buffer - if (size) { - *str++ = ch; - --size; - } - } -} - -int uartPollch(unsigned int ticks) { - while (ticks--) { - if (IO_UART1_RFCR & 0x3f) { - return IO_UART1_DTRR & 0xff; - } - } - - return -1; -} - -bool uartAvailable(void) -{ - return uart1count > 0; -} - -void uart1_heartbeat(void) -{ - char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; - uartPuts(data); -} - -void uartSendData(char* data, int len) -{ - int i; - for(i=0;i 0) - { - *c = uart1buffer[uart1read]; - uart1read = (uart1read+1) % MAX_UART_BUFFER; - uart1count--; - return true; - } - return false; -} - -/* UART1 receive intterupt handler */ -void UART1(void) -{ - if (IO_UART1_RFCR & 0x3f) - { - if (uart1count >= MAX_UART_BUFFER) - panicf("UART1 buffer overflow"); - uart1buffer[uart1write] = IO_UART1_DTRR & 0xff; - uart1write = (uart1write+1) % MAX_UART_BUFFER; - uart1count++; - } - - IO_INTC_IRQ0 = (1< - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - * - */ -#ifndef UART_H -#define UART_H - -void uart_init(void); -bool uart1_getch(char *c); -void uart1_heartbeat(void); - -void uartPuts(const char *str); -void uartGets(char *str, unsigned int size); -int uartPollch(unsigned int ticks); -void uartPutc(char ch); -void uartPutHex(unsigned int n); - -#endif diff --git a/firmware/target/arm/olympus/mrobe-500/usb-mr500.c b/firmware/target/arm/olympus/mrobe-500/usb-mr500.c deleted file mode 100644 index 6063ed3727..0000000000 --- a/firmware/target/arm/olympus/mrobe-500/usb-mr500.c +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * 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; - } -} diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c new file mode 100644 index 0000000000..39d92d67b0 --- /dev/null +++ b/firmware/target/arm/tms320dm320/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/tms320dm320/mrobe-500/adc-target.h b/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h new file mode 100644 index 0000000000..7d4713a186 --- /dev/null +++ b/firmware/target/arm/tms320dm320/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/tms320dm320/mrobe-500/ata-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c new file mode 100644 index 0000000000..47a8c61a45 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c @@ -0,0 +1,131 @@ +/*************************************************************************** + * __________ __ ___. + * 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 (IO_GIO_BITCLR0 = 1 << 10) +#define ATA_RESET_DISABLE (IO_GIO_BITSET0 = 1 << 10) + +/* ATA_EN on C7C68300 */ +#define USB_ATA_ENABLE (IO_GIO_BITSET0 = 1 << 2) +#define USB_ATA_DISABLE (IO_GIO_BITCLR0 = 1 << 2) + +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 true; +} + +void ata_device_init(void) +{ + /* ATA reset */ + ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ + IO_GIO_DIR0&=~(1<<10); +} + +#if 0 +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/tms320dm320/mrobe-500/ata-target.h b/firmware/target/arm/tms320dm320/mrobe-500/ata-target.h new file mode 100644 index 0000000000..97b6f62c86 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/ata-target.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * __________ __ ___. + * 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 + +#define ATA_IOBASE 0x50000000 +#define REGISTER_OFFSET (ATA_IOBASE+0x00400000) /* A21 = High */ +#define CONTROL_OFFSET (ATA_IOBASE+0x00800000) /* A22 = High */ +#define IDE_SHIFT 17 +#define ATA_DATA (*((volatile unsigned short*)(REGISTER_OFFSET + (0x00 << IDE_SHIFT)))) +#define ATA_ERROR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x01 << IDE_SHIFT)))) +#define ATA_NSECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x02 << IDE_SHIFT)))) +#define ATA_SECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x03 << IDE_SHIFT)))) +#define ATA_LCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x04 << IDE_SHIFT)))) +#define ATA_HCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x05 << IDE_SHIFT)))) +#define ATA_SELECT (*((volatile unsigned char*)(REGISTER_OFFSET + (0x06 << IDE_SHIFT)))) +#define ATA_COMMAND (*((volatile unsigned char*)(REGISTER_OFFSET + (0x07 << IDE_SHIFT)))) +#define ATA_CONTROL (*((volatile unsigned char*)(CONTROL_OFFSET + (0x06 << IDE_SHIFT)))) + +#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/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c new file mode 100644 index 0000000000..3c80ede00d --- /dev/null +++ b/firmware/target/arm/tms320dm320/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/tms320dm320/mrobe-500/backlight-target.h b/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h new file mode 100644 index 0000000000..783b9e1320 --- /dev/null +++ b/firmware/target/arm/tms320dm320/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/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c new file mode 100644 index 0000000000..1d0d2714a8 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -0,0 +1,96 @@ +/*************************************************************************** + * __________ __ ___. + * 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" +#include "uart-target.h" + +#define BUTTON_TIMEOUT 50 + +#define BUTTON_START_BYTE 0xF0 +#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ + /* but always the same one for the session? */ + +void button_init_device(void) +{ + /* GIO is the power button, set as input */ + IO_GIO_DIR0 |= 0x01; +} + +inline bool button_hold(void) +{ + return false; +} + +int button_read_device(void) +{ + char data[5], c; + int i = 0; + int btn = BUTTON_NONE; + + if ((IO_GIO_BITSET0&0x01) == 0) + btn |= BUTTON_POWER; + + uart1_heartbeat(); + while (uartAvailable()) + { + if (uart1_getch(&c)) + { + if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2)) + { + data[i++] = c; + } + else if (c == BUTTON_START_BYTE || + c == BUTTON_START_BYTE2) + { + data[0] = c; + i = 1; + } + + if (i == 5) + { + if (data[1]& (1<<7)) + btn |= BUTTON_RC_HEART; + if (data[1]& (1<<6)) + btn |= BUTTON_RC_MODE; + if (data[1]& (1<<5)) + btn |= BUTTON_RC_VOL_DOWN; + if (data[1]& (1<<4)) + btn |= BUTTON_RC_VOL_UP; + if (data[1]& (1<<3)) + btn |= BUTTON_RC_REW; + if (data[1]& (1<<2)) + btn |= BUTTON_RC_FF; + if (data[1]& (1<<1)) + btn |= BUTTON_RC_DOWN; + if (data[1]& (1<<0)) + btn |= BUTTON_RC_PLAY; + break; + } + } + } + return btn; +} diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h new file mode 100644 index 0000000000..f574321717 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Jonathan Gordon + * + * 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); + +/* m:robe 500 specific button codes */ + +#define BUTTON_POWER 0x00000001 + +/* Remote control buttons */ + +#define BUTTON_RC_HEART 0x00000002 +#define BUTTON_RC_MODE 0x00000004 +#define BUTTON_RC_VOL_DOWN 0x00000008 +#define BUTTON_RC_VOL_UP 0x00000010 + + +#define BUTTON_RC_PLAY 0x00000020 +#define BUTTON_RC_REW 0x00000040 +#define BUTTON_RC_FF 0x00000080 +#define BUTTON_RC_DOWN 0x00000100 +#define BUTTON_TOUCH 0x00000200 + +/* compatibility hacks */ +#define BUTTON_LEFT BUTTON_RC_REW +#define BUTTON_RIGHT BUTTON_RC_FF +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 40 + +#define BUTTON_MAIN BUTTON_POWER + +#define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \ + BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \ + BUTTON_RC_PLAY|BUTTON_RC_DOWN| \ + BUTTON_RC_REW|BUTTON_RC_FF) + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/tms320dm320/mrobe-500/crt0.S b/firmware/target/arm/tms320dm320/mrobe-500/crt0.S new file mode 100755 index 0000000000..193470fd4a --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/crt0.S @@ -0,0 +1,206 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * Arm bootloader and startup code based on startup.s from the iPodLinux loader + * + * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org) + * Copyright (c) 2005, Bernard Leach + * + * 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 .init.text,"ax",%progbits + + .global start +start: + msr cpsr, #0xd3 /* enter supervisor mode, disable IRQ */ + +#if !defined(DEBUG) + /* Copy exception handler code to address 0 */ + ldr r2, =_vectorsstart + ldr r3, =_vectorsend + ldr r4, =_vectorscopy +1: + cmp r3, r2 + ldrhi r5, [r4], #4 + strhi r5, [r2], #4 + bhi 1b +#else + ldr r1, =vectors + ldr r0, =irq_handler + str r0, [r1, #24] + ldr r0, =fiq_handler + str r0, [r1, #28] +#endif + + /* Disable high vectors (at 0xffff0000 instead of 0x00000000) */ + mrc p15, 0, r0, c1, c0 + and r0, r0, #~(1<<13) + mcr p15, 0, r0, c1, c0 + +#if !defined(BOOTLOADER) + +#if !defined(STUB) + /* Zero out IBSS */ + ldr r2, =_iedata + ldr r3, =_iend + mov r4, #0 +1: + cmp r3, r2 + strhi r4, [r2], #4 + bhi 1b + + /* Copy the IRAM */ + ldr r2, =_iramcopy + ldr r3, =_iramstart + ldr r4, =_iramend +1: + cmp r4, r3 + ldrhi r5, [r2], #4 + strhi r5, [r3], #4 + bhi 1b +#endif /* !STUB */ +#endif /* !BOOTLOADER */ + + /* Initialise bss section to zero */ + ldr r2, =_edata + ldr r3, =_end + mov r4, #0 +1: + cmp r3, r2 + strhi r4, [r2], #4 + bhi 1b + + /* Set up some stack and munge it with 0xdeadbeef */ + ldr r3, =stackend + ldr r2, =stackbegin + ldr r4, =0xdeadbeef +1: + cmp r3, r2 + strhi r4, [r2], #4 + bhi 1b + + /* Set up stack for IRQ mode */ + msr cpsr_c, #0xd2 + ldr sp, =irq_stack + /* Set up stack for FIQ mode */ + msr cpsr_c, #0xd1 + ldr sp, =fiq_stack + + /* Let abort and undefined modes use IRQ stack */ + msr cpsr_c, #0xd7 + ldr sp, =irq_stack + msr cpsr_c, #0xdb + ldr sp, =irq_stack + /* Switch to supervisor mode (no IRQ) */ + msr cpsr_c, #0xd3 + ldr sp, =stackend + +#ifdef BOOTLOADER + /* get the high part of our execute address */ + ldr r2, =0xffffff00 + and r4, pc, r2 + + /* Copy bootloader to safe area - 0x01900000 */ + mov r5, #0x00900000 + add r5, r5, #0x01000000 + ldr r6, = _dataend + sub r0, r6, r5 /* length of loader */ + add r0, r4, r0 /* r0 points to start of loader */ +1: + cmp r5, r6 + ldrcc r2, [r4], #4 + strcc r2, [r5], #4 + bcc 1b + + ldr pc, =start_loc /* jump to the relocated start_loc: */ + +#endif + +start_loc: + bl main + /* main() should never return */ + +/* Exception handlers. Will be copied to address 0 after memory remapping */ + .section .vectors,"aw" + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + ldr pc, [pc, #24] + + /* Exception vectors */ + .global vectors +vectors: + .word start + .word undef_instr_handler + .word software_int_handler + .word prefetch_abort_handler + .word data_abort_handler + .word reserved_handler + .word irq_handler + .word fiq_handler + + .text + +#if !defined(STUB) + .global irq + .global fiq + .global UIE +#endif + +/* All illegal exceptions call into UIE with exception address as first + parameter. This is calculated differently depending on which exception + we're in. Second parameter is exception number, used for a string lookup + in UIE. + */ +undef_instr_handler: + mov r0, lr + mov r1, #0 + b UIE + +/* We run supervisor mode most of the time, and should never see a software + exception being thrown. Perhaps make it illegal and call UIE? + */ +software_int_handler: +reserved_handler: + movs pc, lr + +prefetch_abort_handler: + sub r0, lr, #4 + mov r1, #1 + b UIE + +data_abort_handler: + sub r0, lr, #8 + mov r1, #2 + b UIE + +UIE: + b UIE + +/* 256 words of IRQ stack */ + .space 256*4 +irq_stack: + +/* 256 words of FIQ stack */ + .space 256*4 +fiq_stack: diff --git a/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c new file mode 100644 index 0000000000..be2b14b3cb --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c @@ -0,0 +1,63 @@ +/*************************************************************************** + * __________ __ ___. + * 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) +{ + IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; + + /* Setup the Prescalar (Divide by 10) + * Based on linux/include/asm-arm/arch-integrator/timex.h + */ + IO_TIMER1_TMPRSCL = 0x000A; + + /* Setup the Divisor */ + IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; + + /* Turn Timer1 to Free Run mode */ + IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN; + + /* Enable the interrupt */ + IO_INTC_EINT0 |= 1< ) \___| < | \_\ ( <_> > < < + * 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/tms320dm320/mrobe-500/lcd-target.h b/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h new file mode 100644 index 0000000000..c64cc56276 --- /dev/null +++ b/firmware/target/arm/tms320dm320/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/tms320dm320/mrobe-500/power-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c new file mode 100644 index 0000000000..3a6dad77f4 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c @@ -0,0 +1,95 @@ +/*************************************************************************** + * __________ __ ___. + * 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 */ + /* set GIO17 (ATA power) on and output */ + ide_power_enable(true); + IO_GIO_DIR1&=~(1<<1); + /* 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) + IO_GIO_BITCLR1=(1<<1); + else + IO_GIO_BITSET1=(1<<1); +} + +bool ide_powered(void) +{ + return !(IO_GIO_BITSET1&(1<<1)); +} + +void power_off(void) +{ + /* turn off backlight and wait for 1 second */ + __backlight_off(); + sleep(HZ); + /* Hard shutdown */ + IO_GIO_BITSET1|=1<<10; +} + +#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/tms320dm320/mrobe-500/spi-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c new file mode 100644 index 0000000000..c47ab8f6ed --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c @@ -0,0 +1,77 @@ +/* + * SPI interface driver for the DM320 SoC + * + * Copyright (C) 2007 shirour + * Copyright (C) 2007 Catalin Patulea + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "system.h" + +#define GIO_TS_ENABLE (1<<2) +#define clr_gio_enable() IO_GIO_BITSET1=GIO_TS_ENABLE +#define set_gio_enable() IO_GIO_BITCLR1=GIO_TS_ENABLE + +int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, + uint8_t *rx_bytes, unsigned int rx_size) +{ + /* Activate the slave select pin */ + set_gio_enable(); + + while (tx_size--) + { + /* Send one byte */ + IO_SERIAL0_TX_DATA = *tx_bytes++; + + /* Wait until transfer finished */ + while (IO_SERIAL0_RX_DATA & 0x100); + } + + while (rx_size--) + { + /* Make the clock tick */ + IO_SERIAL0_TX_DATA = 0; + + /* Wait until transfer finished */ + unsigned short data; + while ((data = IO_SERIAL0_RX_DATA) & 0x100); + + *rx_bytes++ = data & 0xff; + } + + clr_gio_enable(); + + return 0; +} + +void spi_init(void) +{ + /* Set SCLK idle level = 0 */ + IO_SERIAL0_MODE |= (1<<10); + + /* Enable TX */ + IO_SERIAL0_TX_ENABLE = 0x0001; + + /* Set GIO 18 to output for touch screen slave enable */ + IO_GIO_DIR1&=~GIO_TS_ENABLE; + clr_gio_enable(); +} diff --git a/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h b/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h new file mode 100644 index 0000000000..866919dc27 --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Catalin Patulea + * + * 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 SPI_TARGET_H +#define SPI_TARGET_H + +#include + +void spi_init(void); +int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, + uint8_t *rx_bytes, unsigned int rx_size); + +#endif diff --git a/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c new file mode 100644 index 0000000000..fad2d4331e --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c @@ -0,0 +1,210 @@ +/*************************************************************************** + * __________ __ ___. + * 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 = (IO_INTC_IRQENTRY0>>2)-1; + 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( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ + "sub sp, sp, #8 \n"); /* Reserve stack */ + irqvector[(IO_INTC_IRQENTRY0>>2)-1](); + asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ + "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ + "subs pc, lr, #4 \n"); /* Return from FIQ */ +} + +void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked)); +void fiq_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 enable_interrupts (void) +{ + asm volatile ("msr cpsr_c, #0x13" ); +} + +void system_init(void) +{ + /* taken from linux/arch/arm/mach-itdm320-20/irq.c */ + + /* Clearing all FIQs and IRQs. */ + IO_INTC_IRQ0 = 0xFFFF; + IO_INTC_IRQ1 = 0xFFFF; + IO_INTC_IRQ2 = 0xFFFF; + + IO_INTC_FIQ0 = 0xFFFF; + IO_INTC_FIQ1 = 0xFFFF; + IO_INTC_FIQ2 = 0xFFFF; + + /* Masking all Interrupts. */ + IO_INTC_EINT0 = 0; + IO_INTC_EINT1 = 0; + IO_INTC_EINT2 = 0; + + /* Setting INTC to all IRQs. */ + IO_INTC_FISEL0 = 0; + IO_INTC_FISEL1 = 0; + IO_INTC_FISEL2 = 0; + + IO_INTC_ENTRY_TBA0 = + IO_INTC_ENTRY_TBA1 = 0; + + /* set GIO26 (reset pin) to output and low */ + IO_GIO_BITCLR1=(1<<10); + IO_GIO_DIR1&=~(1<<10); + + enable_interrupts(); +} + +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/tms320dm320/mrobe-500/system-target.h b/firmware/target/arm/tms320dm320/mrobe-500/system-target.h new file mode 100755 index 0000000000..7adfda6f7d --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/system-target.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 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 SYSTEM_TARGET_H +#define SYSTEM_TARGET_H + +#include "system-arm.h" + +#define CPUFREQ_SLEEP 32768 +#define CPUFREQ_DEFAULT 24000000 +#define CPUFREQ_NORMAL 30000000 +#define CPUFREQ_MAX 80000000 + +#define inw(p) (*((volatile unsigned short*)((p) + PHY_IO_BASE))) +#define outw(v,p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)) = (v)) + +#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c new file mode 100644 index 0000000000..21449ed19f --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c @@ -0,0 +1,106 @@ +/*************************************************************************** +* __________ __ ___. +* 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(); + IO_INTC_IRQ0 |= 1< 1024; prescaler >>= 1, divider++); + + /* Setup the Prescalar */ + IO_TIMER0_TMPRSCL = prescaler; + + /* Setup the Divisor */ + IO_TIMER0_TMDIV = divider; + + set_irq_level(oldlevel); + + return true; +} + +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 */ + IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN; + + IO_INTC_EINT0 |= 1< ) \___| < | \_\ ( <_> > < < +* 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 (27000000) + +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/tms320dm320/mrobe-500/uart-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c new file mode 100644 index 0000000000..66e59eaaac --- /dev/null +++ b/firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c @@ -0,0 +1,172 @@ +/* + * (C) Copyright 2007 Catalin Patulea + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ +#include "config.h" +#include "cpu.h" +#include "system.h" + +/* UART 0/1 */ + +#define CONFIG_UART_BRSR 87 +#define MAX_UART_BUFFER 32 +static unsigned char uart1buffer[MAX_UART_BUFFER]; +int uart1read = 0, uart1write = 0, uart1count = 0; + +void do_checksums(char *data, int len, char *xor, char *add) +{ + int i; + *xor = data[0]; + *add = data[0]; + for(i=1;i= 0x20); + + // Write character + IO_UART1_DTRR=ch; +} + +// Unsigned integer to ASCII hexadecimal conversion +void uartPutHex(unsigned int n) { + unsigned int i; + + for (i = 8; i != 0; i--) { + unsigned int digit = n >> 28; + uartPutc(digit >= 10 ? digit - 10 + 'A' : digit + '0'); + n <<= 4; + } +} + +void uartPuts(const char *str) { + char ch; + while ((ch = *str++) != '\0') { + uartPutc(ch); + } +} + +void uartGets(char *str, unsigned int size) { + for (;;) { + char ch; + + // Wait for FIFO to contain something + while ((IO_UART1_RFCR & 0x3f) == 0); + + // Read character + ch = (char)IO_UART1_DTRR; + + // Echo character back + IO_UART1_DTRR=ch; + + // If CR, also echo LF, null-terminate, and return + if (ch == '\r') { + IO_UART1_DTRR='\n'; + if (size) { + *str++ = '\0'; + } + return; + } + + // Append to buffer + if (size) { + *str++ = ch; + --size; + } + } +} + +int uartPollch(unsigned int ticks) { + while (ticks--) { + if (IO_UART1_RFCR & 0x3f) { + return IO_UART1_DTRR & 0xff; + } + } + + return -1; +} + +bool uartAvailable(void) +{ + return uart1count > 0; +} + +void uart1_heartbeat(void) +{ + char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; + uartPuts(data); +} + +void uartSendData(char* data, int len) +{ + int i; + for(i=0;i 0) + { + *c = uart1buffer[uart1read]; + uart1read = (uart1read+1) % MAX_UART_BUFFER; + uart1count--; + return true; + } + return false; +} + +/* UART1 receive intterupt handler */ +void UART1(void) +{ + if (IO_UART1_RFCR & 0x3f) + { + if (uart1count >= MAX_UART_BUFFER) + panicf("UART1 buffer overflow"); + uart1buffer[uart1write] = IO_UART1_DTRR & 0xff; + uart1write = (uart1write+1) % MAX_UART_BUFFER; + uart1count++; + } + + IO_INTC_IRQ0 = (1< + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ +#ifndef UART_H +#define UART_H + +void uart_init(void); +bool uart1_getch(char *c); +void uart1_heartbeat(void); + +void uartPuts(const char *str); +void uartGets(char *str, unsigned int size); +int uartPollch(unsigned int ticks); +void uartPutc(char ch); +void uartPutHex(unsigned int n); + +#endif diff --git a/firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c new file mode 100644 index 0000000000..6063ed3727 --- /dev/null +++ b/firmware/target/arm/tms320dm320/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; + } +} diff --git a/tools/configure b/tools/configure index f5219f7a44..085c11092b 100755 --- a/tools/configure +++ b/tools/configure @@ -1301,7 +1301,7 @@ EOF bootoutput="rockbox.mrboot" # architecture, manufacturer and model for the target-tree build t_cpu="arm" - t_manufacturer="olympus" + t_manufacturer="tms320dm320" t_model="mrobe-500" ;; -- cgit v1.2.3