From 95167e01773dcfe8e5c1b356cfa1ea4b3a55441b Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Thu, 24 Apr 2008 20:08:28 +0000 Subject: Commit whole Creative Zen Vision:M target tree + all related firmware/ changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17241 a1c6a512-1295-4272-9138-f99709370657 --- .../arm/tms320dm320/creative-zvm/adc-creativezvm.c | 32 ++ .../arm/tms320dm320/creative-zvm/adc-target.h | 38 ++ .../arm/tms320dm320/creative-zvm/ata-creativezvm.c | 101 +++++ .../arm/tms320dm320/creative-zvm/ata-target.h | 68 ++++ .../tms320dm320/creative-zvm/audio-creativezvm.c | 44 +++ .../tms320dm320/creative-zvm/backlight-target.h | 31 ++ .../arm/tms320dm320/creative-zvm/button-target.h | 57 +++ .../arm/tms320dm320/creative-zvm/lcd-creativezvm.c | 405 +++++++++++++++++++++ .../arm/tms320dm320/creative-zvm/lcd-target.h | 28 ++ .../arm/tms320dm320/creative-zvm/pcm-creativezvm.c | 81 +++++ .../arm/tms320dm320/creative-zvm/pic-creativezvm.c | 323 ++++++++++++++++ .../tms320dm320/creative-zvm/power-creativezvm.c | 68 ++++ .../creative-zvm/powermgmt-creativezvm.c | 57 +++ .../arm/tms320dm320/creative-zvm/usb-creativezvm.c | 65 ++++ .../arm/tms320dm320/creative-zvm/usb-target.h | 76 ++++ firmware/target/arm/tms320dm320/crt0.S | 2 +- firmware/target/arm/tms320dm320/debug-dm320.c | 70 +++- firmware/target/arm/tms320dm320/kernel-dm320.c | 15 +- firmware/target/arm/tms320dm320/spi-dm320.c | 23 +- firmware/target/arm/tms320dm320/spi-target.h | 4 + firmware/target/arm/tms320dm320/system-dm320.c | 56 ++- firmware/target/arm/tms320dm320/timer-dm320.c | 20 +- firmware/target/arm/tms320dm320/uart-dm320.c | 8 +- 23 files changed, 1640 insertions(+), 32 deletions(-) create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/adc-target.h create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/ata-target.h create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/button-target.h create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c create mode 100644 firmware/target/arm/tms320dm320/creative-zvm/usb-target.h (limited to 'firmware/target/arm/tms320dm320') diff --git a/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c new file mode 100644 index 0000000000..d634a71f70 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c @@ -0,0 +1,32 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $ + * + * 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" + +void adc_init(void) +{ +} + +/* Called to get the recent ADC reading */ +inline unsigned short adc_read(int channel) +{ + return (short)channel; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h b/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h new file mode 100644 index 0000000000..aa0f7eb364 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: adc-target.h 14817 2007-09-22 15:43:38Z kkurbjun $ + * + * 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/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c new file mode 100644 index 0000000000..5cbcd72415 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c @@ -0,0 +1,101 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * + * 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 "ata-target.h" + +void ide_power_enable(bool on){ +#if 0 + IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; + if(on) + { + IO_GIO_BITSET0 = (1 << 14); + ata_reset(); + } + else + IO_GIO_BITCLR0 = (1 << 14); + IO_INTC_EINT1 |= INTR_EINT1_EXT2; + return; +#endif +} + +inline bool ide_powered(){ +#if 0 + return (IO_GIO_BITSET0 & (1 << 14)); +#else + return true; +#endif +} + +void ata_reset(void) +{ +/* Disabled until figured out what's wrong */ + IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; //disable GIO2 interrupt + if(!ide_powered()) + { + ide_power_enable(true); + sleep(150); + } + else + { + IO_GIO_BITSET0 = (1 << 5); + IO_GIO_BITCLR0 = (1 << 3); + sleep(1); + } + IO_GIO_BITCLR0 = (1 << 5); + sleep(10); + IO_GIO_BITSET0 = (1 << 3); + while(!(ATA_COMMAND & STATUS_RDY)) + sleep(10); + IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt + return; +} + +void ata_enable(bool on) +{ + (void)on; + return; +} + +bool ata_is_coldstart(void) +{ + return true; +} + +void ata_device_init(void) +{ + IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt + //TODO: mimic OF inits... + return; +} + +void GIO2(void) +{ +#ifdef DEBUG + //printf("GIO2 interrupt..."); +#endif + IO_INTC_IRQ1 = INTR_IRQ1_EXT2; //Mask GIO2 interrupt + return; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h new file mode 100644 index 0000000000..b098396d5e --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h @@ -0,0 +1,68 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Maurus Cuelenaere + * + * 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 0x50FEE000 +#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE))) +#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE+0x2))) +#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE+0x4))) +#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE+0x6))) +#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE+0x8))) +#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE+0xA))) +#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE+0xC))) +#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE+0xE))) +#define ATA_CONTROL (*((volatile unsigned char*)(ATA_IOBASE+0x800C))) + +#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); +void ide_power_enable(bool on); + +#endif diff --git a/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c new file mode 100644 index 0000000000..1e5676b19e --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c @@ -0,0 +1,44 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: audio-c200_e200.c 14624 2007-09-06 03:01:41Z lowlight $ + * + * Copyright (C) 2007 by Michael Sevakis + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "cpu.h" +#include "kernel.h" +#include "sound.h" + +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, + [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0}, + [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, +}; + + +void audiohw_init(void) +{ +} + +void audiohw_close(void) +{ +} + +void audiohw_mute(bool mute) +{ + (void) mute; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h b/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h new file mode 100644 index 0000000000..446c5640aa --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: backlight-target.h 15599 2007-11-12 18:49:53Z amiconn $ + * + * 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/creative-zvm/button-target.h b/firmware/target/arm/tms320dm320/creative-zvm/button-target.h new file mode 100644 index 0000000000..1b63895374 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/button-target.h @@ -0,0 +1,57 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2008 by Maurus Cuelenaere +* +* 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 "config.h" + +#define BUTTON_BACK (1 << 0) +#define BUTTON_CUSTOM (1 << 1) +#define BUTTON_MENU (1 << 2) + +#define BUTTON_LEFT (1 << 3) +#define BUTTON_RIGHT (1 << 4) +#define BUTTON_UP (1 << 5) +#define BUTTON_DOWN (1 << 6) +#define BUTTON_SELECT (1 << 7) + +#define BUTTON_POWER (1 << 8) +#define BUTTON_PLAY (1 << 9) + +#define BUTTON_HOLD (1 << 10) + +#define BUTTON_REMOTE 0 + +#define BUTTON_MAIN ( BUTTON_BACK | BUTTON_MENU | BUTTON_LEFT | BUTTON_RIGHT \ + | BUTTON_UP | BUTTON_DOWN | BUTTON_SELECT | BUTTON_POWER \ + | BUTTON_PLAY | BUTTON_HOLD | BUTTON_CUSTOM ) + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +void button_init_device(void); +int button_read_device(void); +bool headphones_inserted(void); +bool button_hold(void); +bool button_usb_connected(void); + +int get_debug_info(int choice); + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c new file mode 100644 index 0000000000..dec20ad72f --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c @@ -0,0 +1,405 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2008 by Maurus Cuelenaere +* +* 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 "hwcompat.h" +#include "kernel.h" +#include "lcd.h" +#include "system.h" +#include "memory.h" +#include "cpu.h" +#include "spi.h" +#include "spi-target.h" +#include "lcd-target.h" + +/* Power and display status */ +static bool display_on = true; /* Is the display turned on? */ +static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */ + +int lcd_default_contrast(void) +{ + return 0x1f; +} + +void lcd_set_contrast(int val) +{ + /* iirc there is an ltv250qv command to do this */ + #warning function not implemented + (void)val; +} + +void lcd_set_invert_display(bool yesno) { + (void) yesno; + // TODO: +} + +void lcd_set_flip(bool yesno) { + (void) yesno; + // TODO: +} + + +/* LTV250QV panel functions */ + +static void lcd_write_reg(unsigned char reg, unsigned short val) +{ + unsigned char block[3]; + block[0] = 0x74; + block[1] = 0; + block[2] = reg | 0xFF; + spi_block_transfer(SPI_target_LTV250QV, block, sizeof(block), NULL, 0); + block[0] = 0x76; + block[1] = (val >> 8) & 0xFF; + block[2] = val & 0xFF; + spi_block_transfer(SPI_target_LTV250QV, block, sizeof(block), NULL, 0); +} + +static void sleep_ms(unsigned int ms) +{ + sleep(ms*HZ/1000); +} + +static void lcd_display_on(void) +{ + /* Enable main power */ + IO_GIO_BITSET2 |= (1 << 3); + + /* power on sequence as per the ZVM firmware */ + sleep_ms(250); + IO_GIO_BITSET1 = (1 << 13); + sleep_ms(5); + IO_GIO_BITSET2 = (1 << 5); + IO_GIO_BITSET2 = (1 << 8); + sleep_ms(1); + + //Init SPI here... + sleep_ms(32); + + IO_GIO_BITSET2 = (1 << 0); + sleep_ms(5); + IO_GIO_BITSET2 = (1 << 7); + sleep_ms(5); + IO_GIO_BITSET2 = (1 << 4); + sleep_ms(5); + IO_GIO_BITCLR2 = (1 << 8); + //TODO: figure out what OF does after this... + IO_GIO_BITSET2 = (1 << 8); + sleep_ms(1); + + lcd_write_reg(1, 0x1D); + lcd_write_reg(2, 0x0); + lcd_write_reg(3, 0x0); + lcd_write_reg(4, 0x0); + lcd_write_reg(5, 0x40A3); + lcd_write_reg(6, 0x0); + lcd_write_reg(7, 0x0); + lcd_write_reg(8, 0x0); + lcd_write_reg(9, 0x0); + lcd_write_reg(10, 0x0); + lcd_write_reg(16, 0x0); + lcd_write_reg(17, 0x0); + lcd_write_reg(18, 0x0); + lcd_write_reg(19, 0x0); + lcd_write_reg(20, 0x0); + lcd_write_reg(21, 0x0); + lcd_write_reg(22, 0x0); + lcd_write_reg(23, 0x0); + lcd_write_reg(24, 0x0); + lcd_write_reg(25, 0x0); + sleep_ms(10); + + lcd_write_reg(9, 0x4055); + lcd_write_reg(10, 0x0); + sleep_ms(40); + + lcd_write_reg(10, 0x2000); + sleep_ms(40); + + lcd_write_reg(1, 0x401D); + lcd_write_reg(2, 0x204); + lcd_write_reg(3, 0x100); + lcd_write_reg(4, 0x1000); + lcd_write_reg(5, 0x5033); + lcd_write_reg(6, 0x5); + lcd_write_reg(7, 0x1B); + lcd_write_reg(8, 0x800); + lcd_write_reg(16, 0x203); + lcd_write_reg(17, 0x302); + lcd_write_reg(18, 0xC08); + lcd_write_reg(19, 0xC08); + lcd_write_reg(20, 0x707); + lcd_write_reg(21, 0x707); + lcd_write_reg(22, 0x104); + lcd_write_reg(23, 0x306); + lcd_write_reg(24, 0x0); + lcd_write_reg(25, 0x0); + sleep_ms(60); + + lcd_write_reg(9, 0xA55); + lcd_write_reg(10, 0x111A); + sleep_ms(10); + + //TODO: other stuff! + + /* tell that we're on now */ + display_on = true; +} + +static void lcd_display_off(void) +{ + display_on = false; + + /* LQV shutdown sequence */ + lcd_write_reg(9, 0x855); + sleep_ms(20); + + lcd_write_reg(9, 0x55); + lcd_write_reg(5, 0x4033); + lcd_write_reg(10, 0x0); + sleep_ms(20); + + lcd_write_reg(9, 0x0); + sleep_ms(10); + unsigned char temp[1]; + temp[0] = 0; + spi_block_transfer(SPI_target_LTV250QV, temp, sizeof(temp), NULL, 0); + + IO_GIO_BITCLR2 = (1 << 4); + sleep_ms(5); + IO_GIO_BITCLR2 = (1 << 7); + sleep_ms(5); + IO_GIO_BITCLR2 = (1 << 0); + sleep_ms(2); + IO_GIO_BITCLR2 = (1 << 8); + IO_GIO_BITCLR2 = (1 << 5); + + /* Disable main power */ + IO_GIO_BITCLR2 |= (1 << 3); +} + + + +void lcd_enable(bool on) +{ + if (on == display_on) + return; + + if (on) + { + display_on = true; //TODO: remove me! + //lcd_display_on(); /* Turn on display */ + lcd_update(); /* Resync display */ + } + else + { + display_on = false; //TODO: remove me! + //lcd_display_off(); /* Turn off display */ + } +} + +bool lcd_enabled(void) +{ + return display_on; +} + +void lcd_set_direct_fb(bool yes) +{ + unsigned int addr; + direct_fb_access = yes; + if(yes) + addr = ((unsigned int)&lcd_framebuffer-CONFIG_SDRAM_START) / 32; + else + addr = ((unsigned int)FRAME-CONFIG_SDRAM_START) / 32; + IO_OSD_OSDWINADH = addr >> 16; + IO_OSD_OSDWIN0ADL = addr & 0xFFFF; +} + +bool lcd_get_direct_fb(void) +{ + return direct_fb_access; +} + +void lcd_init_device(void) +{ + /* Based on lcd-mr500.c from Catalin Patulea */ + unsigned int addr; + + /* Clear the Frame */ + memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT); + + IO_OSD_MODE = 0x00ff; + IO_OSD_VIDWINMD = 0x0002; + IO_OSD_OSDWINMD0 = 0x2001; + IO_OSD_OSDWINMD1 = 0x0002; + IO_OSD_ATRMD = 0x0000; + IO_OSD_RECTCUR = 0x0000; + + IO_OSD_OSDWIN0OFST = (LCD_WIDTH*16) / 256; + addr = ((unsigned int)FRAME-CONFIG_SDRAM_START) / 32; + IO_OSD_OSDWINADH = addr >> 16; + IO_OSD_OSDWIN0ADL = addr & 0xFFFF; + +#ifndef ZEN_VISION + IO_OSD_BASEPX=26; + IO_OSD_BASEPY=5; +#else + IO_OSD_BASEPX=80; + IO_OSD_BASEPY=0; +#endif + + IO_OSD_OSDWIN0XP = 0; + IO_OSD_OSDWIN0YP = 0; + IO_OSD_OSDWIN0XL = LCD_WIDTH; + IO_OSD_OSDWIN0YL = LCD_HEIGHT; +#if 0 + //TODO: set LCD clock! + IO_CLK_MOD1 &= ~0x18; // disable OSD clock and VENC clock + IO_CLK_02DIV = 3; + IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400; // reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN clock' + IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000; // set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock' + IO_CLK_MOD1 |= 0x18; // enable OSD clock and VENC clock + + /* Set LCD values in OSD */ + IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 ); // disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit + IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 ); + //TODO: finish this... +#endif +} + + +/*** Update functions ***/ + + + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + register fb_data *dst, *src; + + if (!display_on || direct_fb_access) + 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 */ + +#if CONFIG_ORIENTATION == SCREEN_PORTAIT + 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) + { + /* Not full width - do line-by-line */ + lcd_copy_buffer_rect(dst, src, width, height); + } + else + { + /* Full width - copy as one line */ + lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1); + } +#else + src = &lcd_framebuffer[y][x]; + + register int xc, yc; + register fb_data *start=FRAME + LCD_HEIGHT*(LCD_WIDTH-x-1) + y + 1; + + for(yc=0;yc= 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); +} + diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h new file mode 100644 index 0000000000..da63187637 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * 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 _LCD_TARGET_H_ +#define _LCD_TARGET_H_ + +extern void lcd_enable(bool state); + +void lcd_set_direct_fb(bool yes); +bool lcd_get_direct_fb(void); + +#endif diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c new file mode 100644 index 0000000000..6501125f9e --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c @@ -0,0 +1,81 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "system.h" +#include "kernel.h" +#include "logf.h" +#include "audio.h" +#include "sound.h" +#include "file.h" + +void pcm_postinit(void) +{ + +} + +const void * pcm_play_dma_get_peak_buffer(int *count) +{ + (void) count; + return 0; +} + +void pcm_play_dma_init(void) +{ + +} + +void pcm_apply_settings(void) +{ + +} + +void pcm_set_frequency(unsigned int frequency) +{ + (void) frequency; +} + +void pcm_play_dma_start(const void *addr, size_t size) +{ + (void) addr; + (void) size; +} + +void pcm_play_dma_stop(void) +{ + +} + +void pcm_play_lock(void) +{ + +} + +void pcm_play_unlock(void) +{ + +} + +void pcm_play_dma_pause(bool pause) +{ + (void) pause; +} + +size_t pcm_get_bytes_waiting(void) +{ + return 0; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c new file mode 100644 index 0000000000..35e6bd31fb --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c @@ -0,0 +1,323 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2008 by Maurus Cuelenaere +* +* Creative Zen Vision:M interrupt based PIC driver +* +* 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 "button-target.h" +#include "i2c-dm320.h" + + +#include "lcd-target.h" +#include "lcd.h" +#include "sprintf.h" +#include "font.h" + +#ifndef ZEN_VISION +/* Creative Zen Vision:M */ +#define BTN_LEFT 0x5F00 +#define BTN_RIGHT 0x4F00 +#define BTN_BACK 0xBF00 +#define BTN_CUSTOM 0x8F00 +#define BTN_PLAY 0x2F00 +#define BTN_POWER 0x0F00 +#define BTN_MENU 0x9F00 +#define BTN_HOLD 0x9F06 +#define BTN_UNHOLD 0xAF06 + +#define BTN_REL 1 + +#define BTN_TOUCHPAD_PRESS 0x1F00 +#define BTN_TOUCHPAD_CORNER_DOWN 0xAF00 +#define BTN_TOUCHPAD_CORNER_UP 0x3F00 + +#define HEADPHONE_PLUGIN_A 0x5707 +#define HEADPHONE_PLUGIN_B 0x5F07 +#define HEADPHONE_UNPLUG_A 0x3707 +#define HEADPHONE_UNPLUG_B 0x3F07 + +#define DOCK_INSERT 0x6707 +#define DOCK_UNPLUG 0xDF06 +#define DOCK_USB_INSERT 0x2F06 +#define DOCK_USB_UNPLUG 0x3F06 +#define DOCK_POWER_INSERT 0x2707 +#define DOCK_POWER_UNPLUG 0x2F07 + +#else +/* Creative Zen Vision */ +#define BTN_LEFT 0xCF00 +#define BTN_RIGHT 0xEF00 +#define BTN_BACK 0xBF00 +#define BTN_CUSTOM 0x0 +#define BTN_PLAY 0x2F00 +#define BTN_POWER 0x0F00 +#define BTN_MENU 0x9F00 +#define BTN_HOLD 0x9F06 +#define BTN_UNHOLD 0xAF06 +/* TODO: other values +First number is just pressing it, second is when you release it or keep it pressed a bit longer +On/Off = 0F00 && 0F01 +Hold = 9F06 && AF06 +Volume Up = 6F00 && 6F01 +Vol Down = 7F00 && 7F01 +Up = DF00 && DF01 +Right = EF00 && EF01 +Down = FF00 && FF01 +Left = CF00 && CF01 +Back = BF00 && BF01 +Menu = 9F00 && Etcetera +Ok = 1F00 +Play = 2F00 +Next = 4F00 +Prev = 5F00 + +USB = 2F06 +USB ouot = 3F06 +Headphones= AF06 +Hdphns out= BF06 +Charger = 4F06 -> 9F05 +Chgrout = 5F06 -> 8F05 +AV in = 8F06 +AV out = 9F06 */ + +#define BTN_REL 1 + +#define BTN_TOUCHPAD_PRESS 0x8F00 +#define BTN_TOUCHPAD_LONG_PRESS 0x0F00 +#define BTN_TOUCHPAD_CORNER_DOWN 0xD700 +#define BTN_TOUCHPAD_CORNER_LONG_DOWN 0x5700 +#define BTN_TOUCHPAD_CORNER_UP 0x9F00 +#define BTN_TOUCHPAD_CORNER_LONG_UP 0x1F00 + +#define HEADPHONE_PLUGIN_A 0xAF06 +#define HEADPHONE_PLUGIN_B 0xAF06 +#define HEADPHONE_UNPLUG_A 0xBF06 +#define HEADPHONE_UNPLUG_B 0xBF06 + +#define DOCK_INSERT 0x0 +#define DOCK_UNPLUG 0x0 +#define DOCK_USB_INSERT 0x2F06 +#define DOCK_USB_UNPLUG_A 0x3F06 +#define DOCK_USB_UNPLUG_B 0x3F06 +#define DOCK_POWER_INSERT 0x4F06 +#define DOCK_POWER_UNPLUG 0x5F06 +#define DOCK_AV_INSERT 0x8F06 +#define DOCK_AV_UNPLUG 0x9F06 +#endif + +#define PIC_ADR 0x07 + +#define MASK_TV_OUT(x) ((x >> 14) & 1) +#define MASK_xx1(x) ((x >> 9) & 3) +#define MASK_xx2(x) ((x >> 4) & 1) +#define MASK_xx3(x) ((x >> 5) & 1) +#define MASK_xx4(x) ((x >> 6) & 1) +#define MASK_xx5(x) ((x >> 13) & 1) +#define MASK_xx6(x) ((x >> 12) & 1) +#define MASK_xx7(x) ((x >> 11) & 1) + +#define NONBUTTON_HEADPHONE (1 << 0) +#define NONBUTTON_DOCK (1 << 1) +#define NONBUTTON_USB (1 << 2) +#define NONBUTTON_POWER (1 << 3) +#define NONBUTTON_VIDEOUT (1 << 4) + +static unsigned int btn; +static bool hold_switch; +static unsigned char nonbtn; +static unsigned int pic_init_value; +static unsigned int pic_init2_value; +static unsigned int last_btn; +static long last_tick; +static int tick_diff; + +#define TICK_MIN 0x33 +#define TICK_MAX 0x34 + +/* Taken from scramble.c and modified */ +static inline unsigned short le2short(unsigned char* buf) +{ + return (unsigned short)((buf[1] << 8) | buf[0]); +} + +#define map_button(BtN,BtN2) case BtN: \ + btn ^= BtN2; \ + btn &= BtN2; \ + break; \ + case BtN ^ BTN_REL: \ + btn ^= BtN2; \ + btn &= BtN2; \ + break; + +#ifdef BUTTON_DEBUG +static bool sw = false; +#endif + +void GIO0(void) +{ + unsigned char msg[4]; + i2c_read(PIC_ADR, msg, sizeof(msg)); + tick_diff = current_tick - last_tick; + last_tick = current_tick; + unsigned short btn_press = le2short(msg); + if(tick_diff >= TICK_MIN && tick_diff <= TICK_MAX) + { + /* Ignore this, as it is a hold event */ + IO_INTC_IRQ1 = INTR_IRQ1_EXT0; + return; + } + last_btn = btn_press; + switch(btn_press) + { + map_button(BTN_LEFT, BUTTON_LEFT); + map_button(BTN_RIGHT, BUTTON_RIGHT); + map_button(BTN_BACK, BUTTON_BACK); + map_button(BTN_CUSTOM, BUTTON_CUSTOM); + map_button(BTN_MENU, BUTTON_MENU); + map_button(BTN_PLAY, BUTTON_PLAY); + map_button(BTN_POWER, BUTTON_POWER); + map_button(BTN_TOUCHPAD_PRESS, BUTTON_SELECT); + map_button(BTN_TOUCHPAD_CORNER_DOWN, BUTTON_DOWN); + map_button(BTN_TOUCHPAD_CORNER_UP, BUTTON_UP); + case BTN_HOLD: + hold_switch = true; + break; + case BTN_UNHOLD: + hold_switch = false; + break; + case HEADPHONE_PLUGIN_A: + case HEADPHONE_PLUGIN_B: + nonbtn |= NONBUTTON_HEADPHONE; + break; + case HEADPHONE_UNPLUG_A: + case HEADPHONE_UNPLUG_B: + nonbtn &= ~NONBUTTON_HEADPHONE; + break; + case DOCK_INSERT: + nonbtn |= NONBUTTON_DOCK; + break; + case DOCK_UNPLUG: + nonbtn &= ~(NONBUTTON_DOCK | NONBUTTON_USB | NONBUTTON_POWER); + break; + case DOCK_USB_INSERT: + nonbtn |= NONBUTTON_USB; + break; + case DOCK_USB_UNPLUG: + nonbtn &= ~NONBUTTON_USB; + break; + case DOCK_POWER_INSERT: + nonbtn |= NONBUTTON_POWER; + break; + case DOCK_POWER_UNPLUG: + nonbtn &= ~NONBUTTON_POWER; + break; + } +#ifdef BUTTON_DEBUG + unsigned char weergvn[10]; +#ifdef BOOTLOADER + lcd_set_foreground((sw ? LCD_RGBPACK(255,0,0) : LCD_RGBPACK(0,255,0) )); +#endif + snprintf(weergvn, sizeof(char)*10, "%x", (unsigned int)((msg[3] << 24) | (msg[2] << 16) | (msg[1] << 8) | msg[0])); + lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*10, weergvn); + snprintf(weergvn, sizeof(char)*10, "%x", btn); + lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*7, weergvn); +#ifdef BOOTLOADER + lcd_set_foreground(LCD_BLACK); +#endif + lcd_update(); + sw = !sw; +#endif + /* Mask GIO0 interrupt */ + IO_INTC_IRQ1 = INTR_IRQ1_EXT0; +} + +void send_command_to_pic(unsigned char in, unsigned char* out, unsigned int length) +{ + /* Disable GIO0 interrupt */ + IO_INTC_EINT1 &= ~INTR_EINT1_EXT0; + /* Clear EXT0 interrupt */ + IO_INTC_IRQ1 = INTR_IRQ1_EXT0; + /* Write command to I²C */ + restart: + i2c_write(PIC_ADR, &in, 1); + /* Wait for PIC */ + int i = 0; + while(!(IO_INTC_IRQ1 & INTR_IRQ1_EXT0)) + { + sleep(0); + i++; + if(i > 50) + goto restart; + } + /* Read return from I²C */ + i2c_read(PIC_ADR, out, length); + /* Re-enable GIO0 interrupt */ + IO_INTC_EINT1 |= INTR_EINT1_EXT0; +} + +bool headphones_inserted(void) +{ + return (bool)(nonbtn & NONBUTTON_HEADPHONE); +} + +void button_init_device(void) +{ + /* TODO: I suppose GIO0 has to be set to input and enable interrupts on it? */ + /* Enable GIO0 interrupt */ + IO_INTC_EINT1 |= INTR_EINT1_EXT0; + btn = nonbtn = pic_init_value = pic_init2_value = last_btn = hold_switch = 0; + /* Initialize PIC */ + send_command_to_pic(1, &pic_init_value, sizeof(pic_init_value)); + send_command_to_pic(2, &pic_init2_value, sizeof(pic_init2_value)); +} + +int get_debug_info(int choice) +{ + switch(choice) + { + case 1: + return pic_init_value; + case 2: + return pic_init2_value; + case 3: + return last_btn; + case 4: + return nonbtn; + case 5: + return tick_diff; + } + return -1; +} + +int button_read_device(void) +{ + return btn; +} + +bool button_hold(void) +{ + return hold_switch; +} + +bool button_usb_connected(void) +{ + return (bool)(nonbtn & NONBUTTON_USB); +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c new file mode 100644 index 0000000000..5a72deced9 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c @@ -0,0 +1,68 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $ + * + * 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 "backlight.h" +#include "backlight-target.h" + +#ifndef SIMULATOR + +void power_init(void) +{ + /* Initialize IDE power pin */ + /* set ATA power on and output */ + /* Charger detect */ +} + +bool charger_inserted(void) +{ + return false; +} + +/* Returns true if the unit is charging the batteries. */ +bool charging_state(void) { + return false; +} + +void power_off(void) +{ +} + +#else /* SIMULATOR */ + +bool charger_inserted(void) +{ + return false; +} + +void charger_enable(bool on) +{ + (void)on; +} + +void power_off(void) +{ +} + +#endif /* SIMULATOR */ diff --git a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c new file mode 100644 index 0000000000..6e8ea7cae5 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c @@ -0,0 +1,57 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "adc.h" +#include "powermgmt.h" +#include "kernel.h" + +/* THIS CONTAINS CURRENTLY DUMMY CODE! */ + +unsigned short current_voltage = 3910; +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 0 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 0 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 }, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = +{ + 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, +}; +void read_battery_inputs(void) +{ +} + +/* Returns battery voltage from ADC [millivolts] */ +unsigned int battery_adc_voltage(void) +{ + return current_voltage; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c new file mode 100644 index 0000000000..6bbd08c135 --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c @@ -0,0 +1,65 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * + * 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 "usb.h" +#include "usb-target.h" +#include "usb_drv.h" +#include "usb_core.h" +#include "isp1583.h" + +#define printf + +bool usb_drv_connected(void) +{ + return button_usb_connected(); +} + +int usb_detect(void) +{ + if(button_usb_connected()) + return USB_INSERTED; + else + return USB_EXTRACTED; +} + +void usb_init_device(void) +{ + return; +} + +void usb_enable(bool on) +{ + if(on) + usb_core_init(); + else + usb_core_exit(); +} + +void GIO7(void) +{ +#ifdef DEBUG + //printf("GIO7 interrupt... [%d]", current_tick); +#endif + usb_drv_int(); + + IO_INTC_IRQ1 = INTR_IRQ1_EXT7; +} diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h new file mode 100644 index 0000000000..4e3303911c --- /dev/null +++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h @@ -0,0 +1,76 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Maurus Cuelenaere + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef USB_TARGET_H +#define USB_TARGET_H + +#include "dm320.h" + +#define ISP1583_IOBASE 0x60FFC000 +#define ISP1583_H_OVERRIDE + +#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char +#define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2))) +#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char +#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char +#define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2))) +#define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4))) +#define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) ) +/* Data flow registers */ +#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char +#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char +#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2))) +#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2))) +#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char +#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2))) +#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2))) +/* DMA registers */ +#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2))) +/* General registers */ +#define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2))) +#define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4))) +#define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16)) +#define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2))) +#define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char +#define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) ) +#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2))) +#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2))) +#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2))) +#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char + +#define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7 +#define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7 +#define INT_CONF_TARGET 0 +//#define INT_CONF_TARGET 2 +#define set_int_value(a,b,value) a = value & 0xFFFF; \ + b = value >> 16; + + +#define ZVM_SPECIFIC asm volatile( \ + "LDR R12, =0x50FFC000\n" \ + "LDRH R12, [R12]\n" \ + : : : "r12") +//#define ZVM_SPECIFIC + +#include "kernel.h" +int usb_detect(void); +void usb_init_device(void); +bool usb_drv_connected(void); + +#endif diff --git a/firmware/target/arm/tms320dm320/crt0.S b/firmware/target/arm/tms320dm320/crt0.S index 461afdd91a..8c3d36e086 100755 --- a/firmware/target/arm/tms320dm320/crt0.S +++ b/firmware/target/arm/tms320dm320/crt0.S @@ -153,7 +153,7 @@ start: msr cpsr_c, #0xd3 ldr sp, =stackend -#ifdef BOOTLOADER +#if defined(BOOTLOADER) && !defined(CREATIVE_ZVM) /* get the high part of our execute address */ ldr r2, =0xffffff00 and r4, pc, r2 diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c index 1a987b4dda..abfb5b09bc 100755 --- a/firmware/target/arm/tms320dm320/debug-dm320.c +++ b/firmware/target/arm/tms320dm320/debug-dm320.c @@ -27,18 +27,24 @@ #include "sprintf.h" #include "font.h" #include "debug-target.h" +#include "lcd-target.h" bool __dbg_ports(void) { return false; } +#ifndef CREATIVE_ZVM extern char r_buffer[5]; extern int r_button; +#endif bool __dbg_hw_info(void) { - int line = 0, button, oldline; + int line = 0, oldline; + int button; +#ifndef CREATIVE_ZVM int *address=0x0; +#endif bool done=false; char buf[100]; @@ -50,6 +56,7 @@ bool __dbg_hw_info(void) lcd_puts(0, line++, "[Hardware info]"); lcd_puts(0, line++, "Clock info:"); +#if LCD_WIDTH > 320 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", @@ -58,12 +65,45 @@ bool __dbg_hw_info(void) IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x", IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf); +#else + snprintf(buf, sizeof(buf), " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_SEL0, IO_CLK_SEL1); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x", IO_CLK_SEL2, IO_CLK_DIV0); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", IO_CLK_DIV1, IO_CLK_DIV2); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x", IO_CLK_DIV3, IO_CLK_DIV4); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", IO_CLK_BYP, IO_CLK_INV); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ", IO_CLK_MOD0, IO_CLK_MOD1); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ", IO_CLK_MOD2, IO_CLK_LPCTL0); + lcd_puts(0, line++, buf); +#endif + + lcd_puts(0, line++, "Board revision:"); + switch (IO_BUSC_REVR) { + case 0x0010: + lcd_puts(0, line++, " DM320 Rev. A"); + break; + case 0x0011: + lcd_puts(0, line++, " DM320 Rev. B/C"); + break; + default: + lcd_puts(0, line++, " Unknown DM320 Chip ID"); + } +#ifndef CREATIVE_ZVM line++; +#endif oldline=line; while(!done) { line = oldline; +#ifndef CREATIVE_ZVM button = button_get(false); button&=~BUTTON_REPEAT; if (button == BUTTON_POWER) @@ -81,14 +121,42 @@ bool __dbg_hw_info(void) r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x", (unsigned int)button, r_button); lcd_puts(0, line++, buf); +#else + button = button_get(false); + if(button & BUTTON_POWER) + done = true; + else if(button & BUTTON_LEFT) + lcd_set_direct_fb(false); + else if(button & BUTTON_RIGHT) + lcd_set_direct_fb(true); + + lcd_puts(0, line++, "PIC info:"); + snprintf(buf, sizeof(buf), " Init value 1: 0x%04x", get_debug_info(1)); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " Init value 2: 0x%04x", get_debug_info(2)); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " Last button value: 0x%04x Raw value: 0x%04x", get_debug_info(3), button_read_device()); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " Last button at: 0x%04x", get_debug_info(5)); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), " Dock values: 0x%04x", get_debug_info(4)); + lcd_puts(0, line++, buf); + lcd_puts(0, line++, "LCD info:"); + snprintf(buf, sizeof(buf), " LCD direct FB access? %s", (lcd_get_direct_fb() ? "yes" : "no")); + lcd_puts(0, line++, buf); + line++; +#endif + lcd_puts(0, line++, "[Rockbox info]"); snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf); +#ifndef CREATIVE_ZVM snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)address, *address); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf); +#endif lcd_update(); } diff --git a/firmware/target/arm/tms320dm320/kernel-dm320.c b/firmware/target/arm/tms320dm320/kernel-dm320.c index 6608aea096..2b2e783c3f 100644 --- a/firmware/target/arm/tms320dm320/kernel-dm320.c +++ b/firmware/target/arm/tms320dm320/kernel-dm320.c @@ -27,6 +27,10 @@ extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); void tick_start(unsigned int interval_in_ms) { +/* TODO: set up TIMER1 clock settings + IO_CLK_MOD2 &= ~CLK_MOD2_TMR1; //disable TIMER1 clock + IO_CLK_SEL0 |= (1 << 2); //set TIMER1 clock to PLLIN*/ + IO_CLK_MOD2 |= CLK_MOD2_TMR1; //enable TIMER1 clock!!!!!!!!! IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; /* Setup the Prescalar (Divide by 10) @@ -35,13 +39,13 @@ void tick_start(unsigned int interval_in_ms) IO_TIMER1_TMPRSCL = 0x0009; /* Setup the Divisor */ - IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; - + IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms - 1; + /* Turn Timer1 to Free Run mode */ IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN; - + /* Enable the interrupt */ - IO_INTC_EINT0 |= 1< enum SPI_target { +#ifndef CREATIVE_ZVM SPI_target_TSC2100 = 0, SPI_target_RX5X348AB, SPI_target_BACKLIGHT, +#else + SPI_target_LTV250QV = 0, +#endif SPI_MAX_TARGETS, }; diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c index da3b9913a2..c03e05522c 100644 --- a/firmware/target/arm/tms320dm320/system-dm320.c +++ b/firmware/target/arm/tms320dm320/system-dm320.c @@ -114,7 +114,12 @@ void irq_handler(void) asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ "sub sp, sp, #8 \n"); /* Reserve stack */ - irqvector[(IO_INTC_IRQENTRY0>>2)-1](); + unsigned short addr = IO_INTC_IRQENTRY0>>2; + if(addr != 0) + { + addr--; + irqvector[addr](); + } 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 */ @@ -130,18 +135,34 @@ void fiq_handler(void) "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 r0, [r0, #0x518] \r\n" + "sub r0, r0, #1 \r\n" "ldr r1, =irqvector \r\n" "ldr r1, [r1, r0, lsl #2] \r\n" - "mov lr, pc \r\n" - "bx r1 \r\n" + "blx r1 \r\n" "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" ); } void system_reboot(void) { - + /* Code taken from linux/include/asm-arm/arch-itdm320-20/system.h at NeuroSVN */ + __asm__ __volatile__( + "mov ip, #0 \n" + "mcr p15, 0, ip, c7, c7, 0 @ invalidate cache \n" + "mcr p15, 0, ip, c7, c10,4 @ drain WB \n" + "mcr p15, 0, ip, c8, c7, 0 @ flush TLB (v4) \n" + "mrc p15, 0, ip, c1, c0, 0 @ get ctrl register\n" + "bic ip, ip, #0x000f @ ............wcam \n" + "bic ip, ip, #0x2100 @ ..v....s........ \n" + "mcr p15, 0, ip, c1, c0, 0 @ ctrl register \n" + "mov ip, #0xFF000000 \n" + "orr ip, ip, #0xFF0000 @ ip = 0xFFFF0000 \n" + "mov pc, ip \n" + : + : + : "cc" + ); } void system_init(void) @@ -167,16 +188,28 @@ void system_init(void) IO_INTC_FISEL1 = 0; IO_INTC_FISEL2 = 0; + /* IRQENTRY only reflects enabled interrupts */ + IO_INTC_RAW = 0; + IO_INTC_ENTRY_TBA0 = 0; IO_INTC_ENTRY_TBA1 = 0; - /* Turn off other timers */ + unsigned short i; + /* Reset interrupt priorities to default values */ + for(i = 0; i < 23; i++) + DM320_REG(0x0540+i*2) = ( (i*2+1) << 8 ) | i*2 ;//IO_INTC_PRIORITYx + + /* Turn off all timers */ + IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP; + IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP; IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP; +#ifndef CREATIVE_ZVM /* set GIO26 (reset pin) to output and low */ IO_GIO_BITCLR1=(1<<10); IO_GIO_DIR1&=~(1<<10); +#endif uart_init(); spi_init(); @@ -186,9 +219,18 @@ void system_init(void) /* Make sure everything is mapped on itself */ map_section(0, 0, 0x1000, CACHE_NONE); /* Enable caching for RAM */ - map_section(0x00900000, 0x00900000, 64, CACHE_ALL); + map_section(CONFIG_SDRAM_START, CONFIG_SDRAM_START, MEM, CACHE_ALL); /* enable buffered writing for the framebuffer */ map_section((int)FRAME, (int)FRAME, 1, BUFFERED); +#ifdef CREATIVE_ZVM + //mimic OF + map_section(0x00100000, 0x00100000, 4, CACHE_NONE); + map_section(0x04700000, 0x04700000, 2, BUFFERED); + map_section(0x40000000, 0x40000000, 16, CACHE_NONE); + map_section(0x50000000, 0x50000000, 16, CACHE_NONE); + map_section(0x60000000, 0x60000000, 16, CACHE_NONE); + map_section(0x80000000, 0x80000000, 1, CACHE_NONE); +#endif enable_mmu(); } diff --git a/firmware/target/arm/tms320dm320/timer-dm320.c b/firmware/target/arm/tms320dm320/timer-dm320.c index 7895005d46..52b433fac5 100644 --- a/firmware/target/arm/tms320dm320/timer-dm320.c +++ b/firmware/target/arm/tms320dm320/timer-dm320.c @@ -24,12 +24,12 @@ #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 */ + should not be a functional pin and TIMER0 output unseen there */ void TIMER0(void) { if (pfn_timer != NULL) pfn_timer(); - IO_INTC_IRQ0 |= 1<