Index: bootloader/creativezvm.c =================================================================== --- bootloader/creativezvm.c (revision 0) +++ bootloader/creativezvm.c (revision 0) @@ -0,0 +1,370 @@ +/*************************************************************************** +* __________ __ ___. +* 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 "inttypes.h" +#include "string.h" +#include "cpu.h" +#include "system.h" +#include "lcd.h" +#include "kernel.h" +#include "thread.h" +#include "ata.h" +#include "fat.h" +#include "disk.h" +#include "font.h" +#include "adc.h" +#include "backlight.h" +#include "backlight-target.h" +#include "button.h" +#include "panic.h" +#include "power.h" +#include "file.h" +#include "common.h" +#include "rbunicode.h" +#include "usb.h" +#include "spi.h" +#include "uart-target.h" +#include "time.h" +#include "system-arm.h" +#include +#include "sprintf.h" +#include "memory.h" +#include "i2c-dm320.h" +#include "ata-target.h" +#include "timer.h" +#include "usb-target.h" +#include "isp1583.h" + +void i2c_reading(void){ + printf("Starting I2C reading..."); + + unsigned char test[20]; + unsigned char msg[40]; + int i, j, ret; + bool flag; + while(true){ + for(i=0;i<0x7F;i++){ //max=7-bit + snprintf(msg, sizeof(char)*20, "0x%x ", i); + lcd_putsxy(260, 0, msg); + lcd_update(); + ret = i2c_read(i, test, 16); + flag = false; + for(j=0;j<16;j++){ + if((test[j]!=0xFF) & (test[j]!=0)) + flag = true; + } + if(flag){ + snprintf(msg, sizeof(char)*40, "%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x", + test[0], test[1], test[2], test[3], test[4], + test[5], test[6], test[7], test[8], test[9], + test[10], test[11], test[12], test[13], test[14], + test[15]); + printf("0x%x: %s [%d]", i, msg, ret); + } + asm volatile("nop\nnop\nnop\nnop\nnop\nnop\nnop\n"); + } + } +} + +void GIO7(void) +{ + printf("GIO7 interrupt..."); + IO_INTC_IRQ1 = INTR_IRQ1_EXT7; + return; +} + +/*void do_hdd_browsing(void) +{ + reset_screen(); + printf("Initing HDD..."); + int ret = ata_init(); + if(ret) + printf("ATA error: %d", ret); + disk_init(); + printf("HDD inited..."); + printf("Press any key to continue..."); + while(button_read_device() == 0); + reset_screen(); + char msg[30]; + char put[2]; + unsigned char buf[512]; + unsigned int i=0x100000, lasti=0; + int j,k,l; + while(true) + { + if((button_read_device() & BUTTON_RIGHT) && lasti==i) + i++; + else if((button_read_device() & BUTTON_LEFT) && lasti==i) + i--; + if(i<0x100000) + i = 0x100000; + if(i != lasti) + { + lasti = i; + ata_read_sectors(i, 0, buf); + printf(" "); + printf("%x%x%x%x%x", buf[0], buf[1], buf[2], buf[3], buf[4]); + l = 0; + k = SYSFONT_HEIGHT; + for(j=0;j<(int)LCD_WIDTH/(SYSFONT_WIDTH*2);j+= SYSFONT_WIDTH*2) + { + snprintf(put, sizeof(char)*2, "%x", buf[l]); + lcd_putsxy(j, k, put); + l++; + } + snprintf(msg, 30, "%x", i); + lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*4, 0, msg); + lcd_update(); + } + ata_spin(); + sleep(1); + } +}*/ + +void do_rescue_menu(void) +{ + short sel_choice = 0; + const char* const choices[] = {"Boot Rockbox", "Boot Creative OS", "USB Mode", "Reboot", "Power Off"}; + #define AMOUNT_CHOICES 5 + short i = 0; + lcd_set_foreground(LCD_WHITE); + lcd_set_background(LCD_BLACK); + lcd_clear_display(); + while(true) + { + for(i=0; iAMOUNT_CHOICES) + sel_choice = AMOUNT_CHOICES - 1; + lcd_update(); + sleep(1); + } +} + +int do_write(void) +{ + unsigned char temp[4]; + int i; + for(i=0; i<0x20; i++) + { + temp[0] = 0x8; + i2c_write(0xE, temp, 1); + i2c_read(0xF, temp, 4); + printf("%x", le2int(temp)); + } + return le2int(temp); +} + +void main(void) +{ + unsigned char* loadbuffer; + int buffer_size; + int rc; + int(*kernel_entry)(void); + + //power_init(); + lcd_init(); + font_init(); + + lcd_enable(true); + lcd_setfont(FONT_SYSFIXED); + reset_screen(); + printf("Rockbox boot loader"); + printf("Version %s", APPSVERSION); + switch (IO_BUSC_REVR) + { + case 0x0010: + printf("DM320 Rev. A"); + break; + case 0x0011: + printf("DM320 Rev. B/C"); + break; + default: + printf("Unknown DM320 Chip ID"); + } + + system_init(); + kernel_init(); + + int level = set_irq_level(0); + set_fiq_status(FIQ_ENABLED); + printf("Previous IRQ level was 0x%x", level); + + button_init(); + + printf("Enabling GIOx interrupts..."); + IO_INTC_EINT1 |= INTR_EINT1_EXT7; + printf("Done"); + + if(button_read_device() & BUTTON_HOLD) + do_rescue_menu(); + unsigned char test[16]; + while(1) + { + snprintf(test, sizeof(char)*16, "%x ", button_read_device()); + lcd_putsxy(0, SYSFONT_HEIGHT*7, test); + snprintf(test, sizeof(char)*16, "%x ", current_tick); + lcd_putsxy(0, SYSFONT_HEIGHT*8, test); + lcd_update(); + if(button_read_device() & BUTTON_PLAY) + printf("%x", do_write()); + else if(button_read_device() & BUTTON_MENU) + do_rescue_menu(); + /*else if(button_read_device() & BUTTON_BACK) + do_hdd_browsing();*/ + else if(button_read_device() & BUTTON_CUSTOM) + { + set_irq_level(IRQ_DISABLED); + set_fiq_status(FIQ_DISABLED); + } + nop;nop;nop;nop; + } + + //adc_init(); + //button_init(); + //backlight_init(); + + + /* Show debug messages if button is pressed */ + // if(button_read_device()) + verbose = true; + + printf("Initing USB..."); + usb_init(); + + char msg[400]; + unsigned int i; + #define TEST_REG(addr) (*(volatile unsigned short *)(addr)) + #define UNK2 TEST_REG(0x4F0000) + #define UNK3 TEST_REG(0x50FFC000) + #define UNK7 TEST_REG(0x50FF600C) + #define MAYBEUSB TEST_REG(0x60FFC0F8) + + const char* const names[] = + { + "IO_GIO_BITSET0","IO_GIO_BITSET1","IO_GIO_BITSET2","IO_GIO_BITCLR0","IO_GIO_BITCLR1","IO_GIO_BITCLR2"//,"IO_GIO_DIR0","IO_GIO_DIR1","IO_GIO_DIR2","IO_GIO_INV0","IO_GIO_INV1","IO_GIO_INV2" + ,"IO_GIO_FSEL0","IO_GIO_FSEL1","IO_GIO_FSEL2","IO_GIO_FSEL3","IO_GIO_FSEL4"//,"IO_GIO_IRQPORT","IO_GIO_IRQEDGE","IO_GIO_CHAT0","IO_GIO_CHAT1","IO_GIO_CHAT2","IO_GIO_NCHAT" + ,"0x4F0000","0x50FFC000","IO_I2C_TXDATA","IO_TIMER1_TMCNT" + //,"IO_CLK_PLLA","IO_CLK_PLLB","IO_CLK_SEL0","IO_CLK_SEL1","IO_CLK_SEL2","IO_CLK_DIV0","IO_CLK_DIV1","IO_CLK_DIV2","IO_CLK_DIV3","IO_CLK_DIV4" + //,"IO_DSPC_HPIB_CONTROL","IO_DSPC_HPIB_STATUS" + ,"IO_CLK_MOD0","IO_CLK_MOD1","IO_CLK_MOD2","current_tick" + ,"IO_INTC_IRQ0","IO_INTC_IRQ1","IO_INTC_IRQ2" + ,"ISP1583_GEN_INT","ISP1583_INIT_MODE","ISP1583_INIT_INTCONF","ISP1583_INIT_OTG","ISP1583_INIT_INTEN" + ,"ISP1583_GEN_UNLCKDEV","MAYBEUSB" + }; + volatile unsigned short * vars[] = + { + &IO_GIO_BITSET0,&IO_GIO_BITSET1,&IO_GIO_BITSET2,&IO_GIO_BITCLR0,&IO_GIO_BITCLR1,&IO_GIO_BITCLR2//,&IO_GIO_DIR0,&IO_GIO_DIR1,&IO_GIO_DIR2,&IO_GIO_INV0,&IO_GIO_INV1,&IO_GIO_INV2 + ,&IO_GIO_FSEL0,&IO_GIO_FSEL1,&IO_GIO_FSEL2,&IO_GIO_FSEL3,&IO_GIO_FSEL4//,&IO_GIO_IRQPORT,&IO_GIO_IRQEDGE,&IO_GIO_CHAT0,&IO_GIO_CHAT1,&IO_GIO_CHAT2,&IO_GIO_NCHAT + ,&UNK2,&UNK3,&IO_I2C_TXDATA,&IO_TIMER1_TMCNT + //,&IO_CLK_PLLA,&IO_CLK_PLLB,&IO_CLK_SEL0,&IO_CLK_SEL1,&IO_CLK_SEL2,&IO_CLK_DIV0,&IO_CLK_DIV1,&IO_CLK_DIV2,&IO_CLK_DIV3,&IO_CLK_DIV4 + //,&IO_DSPC_HPIB_CONTROL,&IO_DSPC_HPIB_STATUS + ,&IO_CLK_MOD0,&IO_CLK_MOD1,&IO_CLK_MOD2,¤t_tick + ,&IO_INTC_IRQ0,&IO_INTC_IRQ1,&IO_INTC_IRQ2 + ,&ISP1583_GEN_INT,&ISP1583_INIT_MODE,&ISP1583_INIT_INTCONF,&ISP1583_INIT_OTG,&ISP1583_INIT_INTEN + ,&ISP1583_GEN_UNLCKDEV,&MAYBEUSB + }; + unsigned int tempval[sizeof(vars)/sizeof(volatile unsigned short*)]; + unsigned int temp; + int flag=0; + reset_screen(); + lcd_set_foreground(LCD_RGBPACK(255,0,0)); + lcd_putsxy(0, LCD_HEIGHT-SYSFONT_HEIGHT, "RED means higher"); + lcd_set_foreground(LCD_RGBPACK(0,255,0)); + lcd_putsxy(100, LCD_HEIGHT-SYSFONT_HEIGHT, "GREEN means lower"); + lcd_set_foreground(LCD_BLACK); + lcd_putsxy(210, LCD_HEIGHT-SYSFONT_HEIGHT, "BLACK means equal"); + while(true) { + for(i=0;itempval[i]) + lcd_set_foreground(LCD_RGBPACK(255,0,0)); + else if(temptempval[i+1]) + lcd_set_foreground(LCD_RGBPACK(255,0,0)); + else if(temp ) \___| < | \_\ ( <_> > < < - * 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. - * - ****************************************************************************/ +* __________ __ ___. +* 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. +* +****************************************************************************/ /* - * This config file is for the Creative Zen Vision:M - */ +* This config file is for the Creative Zen Vision:M +*/ #define TARGET_TREE /* this target is using the target tree system */ #define CONFIG_SDRAM_START 0x00900000 @@ -62,15 +62,10 @@ /* Define this if your LCD can be enabled/disabled */ #define HAVE_LCD_ENABLE -#define LCD_REMOTE_PIXELFORMAT VERTICAL_PACKING - -#define MIN_REMOTE_CONTRAST_SETTING 0 -#define MAX_REMOTE_CONTRAST_SETTING 15 -#define DEFAULT_REMOTE_CONTRAST_SETTING 7 - #define CONFIG_KEYPAD MROBE500_PAD +#define HAS_BUTTON_HOLD +#define HAVE_HEADPHONE_DETECTION //#define HAVE_TOUCHPAD -#define HAVE_BUTTON_DATA /* Define this if you do software codec */ #define CONFIG_CODEC SWCODEC @@ -90,8 +85,10 @@ #define DEFAULT_DIMNESS_SETTING 22 /* OF "most dim" */ /* Define this if you have a software controlled poweroff */ -#define HAVE_SW_POWEROFF +//#define HAVE_SW_POWEROFF +//TODO: enable this back + /* The number of bytes reserved for loadable codecs */ #define CODEC_SIZE 0x80000 @@ -105,7 +102,7 @@ /* #define USE_ADAPTIVE_BASS */ #define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \ - SAMPR_CAP_11) + SAMPR_CAP_11) #define BATTERY_CAPACITY_DEFAULT 1100 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */ @@ -127,6 +124,8 @@ /* Define this if you want to use coldfire's i2c interface */ //#define CONFIG_I2C I2C_S3C2440 +#define CONFIG_USBOTG USBOTG_ISP1583 + /* define this if the hardware can be powered off while charging */ #define HAVE_POWEROFF_WHILE_CHARGING @@ -158,4 +157,10 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTDIR "/.rockbox" +//DEBUGGING! +#define THREAD_EXTRA_CHECKS 1 +#define DEBUG 1 +#define debug(msg) printf(msg) + + #endif Index: firmware/export/config.h =================================================================== --- firmware/export/config.h (revision 16542) +++ firmware/export/config.h (working copy) @@ -166,6 +166,7 @@ /* USB On-the-go */ #define USBOTG_ISP1362 1362 /* iriver H300 */ +#define USBOTG_ISP1538 1538 /* Creative Zen Vision:M */ #define USBOTG_M5636 5636 /* iAudio X5 */ #define USBOTG_ARC 5020 /* PortalPlayer 502x */ Index: firmware/export/isp1583.h =================================================================== --- firmware/export/isp1583.h (revision 0) +++ firmware/export/isp1583.h (revision 0) @@ -0,0 +1,47 @@ +/*************************************************************************** + * __________ __ ___. + * 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 ISP1583_H +#define ISP1583_H + +/* Initialization registers */ +#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) +#define ISP1583_INIT_MODE (*((volatile unsigned char*)(ISP1583_IOBASE+0xC))) +#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10))) +#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12))) +#define ISP1583_INIT_INTEN (*((volatile unsigned int*)(ISP1583_IOBASE+0x14))) +/* Data flow registers */ +#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2))) +#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28))) +#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20))) +#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C))) +#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E))) +#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04))) +#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08))) +/* DMA registers */ +/* General registers */ +#define ISP1583_GEN_INT (*((volatile unsigned int*)(ISP1583_IOBASE+0x18))) +#define ISP1583_GEN_CHIPID (*((volatile unsigned int*)(ISP1583_IOBASE+0x70))) //Size=3 bytes +#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74))) +#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78))) +#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C))) +#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84))) + +#define ISP1583_UNLOCK_CODE 0xaa37 + +#endif Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (revision 16542) +++ firmware/SOURCES (working copy) @@ -239,7 +239,9 @@ #endif #else /* !defined(HAVE_USBSTACK) */ #if CONFIG_USBOTG == USBOTG_ISP1362 -drivers/isp1362.c +drivers/isp1362.c +#elif CONFIG_USBOTG == USBOTG_ISP1583 +drivers/isp1583.c #elif CONFIG_USBOTG == USBOTG_M5636 drivers/m5636.c #endif @@ -661,6 +663,25 @@ #endif /* SIMULATOR */ #endif /* MROBE_500 */ +#ifdef CREATIVE_ZVM +#ifndef SIMULATOR +target/arm/lcd-as-memframe.S +target/arm/mmu-arm.c +target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c +target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +target/arm/tms320dm320/creative-zvm/button-creativezvm.c +target/arm/tms320dm320/creative-zvm/usb-creativezvm.c +target/arm/tms320dm320/debug-dm320.c +target/arm/tms320dm320/i2c-dm320.c +target/arm/tms320dm320/kernel-dm320.c +target/arm/tms320dm320/spi-dm320.c +target/arm/tms320dm320/system-dm320.c +target/arm/tms320dm320/timer-dm320.c +target/arm/tms320dm320/uart-dm320.c +target/arm/tms320dm320/dsp-dm320.c +#endif /* SIMULATOR */ +#endif /* CREATIVE_ZVM */ + #ifdef MROBE_100 #ifndef SIMULATOR drivers/sw_i2c.c Index: firmware/target/arm/tms320dm320/uart-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/uart-dm320.c (revision 16542) +++ firmware/target/arm/tms320dm320/uart-dm320.c (working copy) @@ -1,21 +1,21 @@ /*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 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. - * - ****************************************************************************/ +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2007 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. +* +****************************************************************************/ #include "config.h" #include "cpu.h" #include "system.h" @@ -28,7 +28,7 @@ char // uart1_send_buffer_ring[SEND_RING_SIZE], - uart1_recieve_buffer_ring[RECIEVE_RING_SIZE]; +uart1_recieve_buffer_ring[RECIEVE_RING_SIZE]; //static unsigned int uart1_send_count, uart1_send_read, uart1_send_write; static unsigned int uart1_recieve_count, uart1_recieve_read, uart1_recieve_write; @@ -36,11 +36,11 @@ void uart_init(void) { // 8-N-1 - IO_UART1_MSR=0x8000; - IO_UART1_BRSR=0x0057; + IO_UART1_MSR = 0x8000; + IO_UART1_BRSR = 0x0057; IO_UART1_RFCR = 0x8010; /* Trigger later */ /* gio 27 is input, uart1 rx - gio 28 is output, uart1 tx */ + gio 28 is output, uart1 tx */ IO_GIO_DIR1 |= (1<<11); /* gio 27 */ IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */ @@ -50,7 +50,7 @@ uart1_recieve_write=0; /* Enable the interrupt */ - IO_INTC_EINT0 |= (1< RECIEVE_RING_SIZE) - panicf("UART1 buffer overflow"); + panicf("UART1 buffer overflow"); else { if(uart1_recieve_write==RECIEVE_RING_SIZE) - uart1_recieve_write=0; + uart1_recieve_write=0; uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff; uart1_recieve_write++; @@ -129,5 +129,5 @@ } } - IO_INTC_IRQ0 = (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. - * - ****************************************************************************/ +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2008 by Maurus Cuelenaere +* +* DM320 I²C 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 "system.h" +#include "thread.h" #include "i2c-dm320.h" -#if 0 -static int i2c_getack(void) +#define I2C_SCS_COND_START 0x0001 +#define I2C_SCS_COND_STOP 0x0002 +#define I2C_SCS_XMIT 0x0004 + +#define I2C_TX_ACK (1 << 20) + +static struct mutex i2c_mtx; + +void i2c_begin(void) { - return 0; + mutex_lock(&i2c_mtx); } -static int i2c_start(void) +void i2c_end(void) { - return 0; + mutex_unlock(&i2c_mtx); } -static void i2c_stop(void) +static bool i2c_getack(void) { + return (IO_I2C_RXDATA & 0x100)>>8; +} +static void i2c_ack(bool bit) +{ + if(bit) + IO_I2C_TXDATA |= I2C_TX_ACK; + else + IO_I2C_TXDATA &= ~I2C_TX_ACK; + return; } -static int i2c_outb(unsigned char byte) +#define WAIT_FOR_I2C if(IO_I2C_SCS & 0x4){ \ + while(IO_I2C_SCS & 0x4) { \ + asm volatile("nop"); \ + } \ + } \ + +static void i2c_start(void) { - (void) byte; - return 0; + IO_I2C_SCS |= I2C_SCS_XMIT; + return; } + +int i2c_write(unsigned short address, const unsigned char *buf, int count) +{ + int i; + int ret=0; + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + i2c_begin(); + IO_I2C_TXDATA = address & 0xFF; + i2c_ack(true); + IO_I2C_SCS &= ~0x3; //clear conditions + IO_I2C_SCS |= I2C_SCS_COND_START; // write 'start condition' + i2c_start(); + WAIT_FOR_I2C; +#if 0 /* experimental */ + if(address>0x7F){ // check if it is 10-bit instead of 7-bit + IO_I2C_TXDATA = address>>7; + i2c_ack(true); + IO_I2C_SCS &= ~0x3; //normal transfer + i2c_start(); + WAIT_FOR_I2C; + IO_I2C_TXDATA = (address & 0xFF) | 1; + i2c_ack(true); + IO_I2C_SCS &= ~0x3; //clear conditions + IO_I2C_SCS |= I2C_SCS_COND_START; //write 'start condition' + i2c_start(); + WAIT_FOR_I2C; + } #endif + for(i=0; i0x7F){ // check if it is 10-bit instead of 7-bit + IO_I2C_TXDATA = address>>7; + i2c_ack(true); + IO_I2C_SCS &= ~0x3; //normal transfer + i2c_start(); + WAIT_FOR_I2C; + IO_I2C_TXDATA = (address & 0xFF) | 1; + i2c_ack(true); + IO_I2C_SCS &= ~0x3; //clear conditions + IO_I2C_SCS |= I2C_SCS_COND_START; //write 'start condition' + i2c_start(); + WAIT_FOR_I2C; + } +#endif + for(i=0; i> 8; + } + IO_I2C_SCS &= ~0x3; //clear conditions + IO_I2C_SCS |= I2C_SCS_COND_STOP; //write 'stop condition' + i2c_start(); + WAIT_FOR_I2C; + i2c_end(); + set_irq_level(level); + return ack; } void i2c_init(void) { - +#if 0 //TODO: mimic OF I2C clock settings; currently this is done by the bootloader + IO_CLK_MOD2 &= ~CLK_MOD2_I2C; // turn I²C clock off (just to be sure) + IO_CLK_LPCTL1 &= ~1; // set Powerdown mode to off + IO_CLK_SEL0 &= ~0x800; // set I²C clock to PLLA + IO_CLK_DIV4 &= ~0x1F; // I²C clock division = 1 + IO_CLK_MOD2 |= CLK_MOD2_I2C; // enable I²C clock +#endif + IO_I2C_SCS &= ~0x8; //set clock to 100 kHz + IO_INTC_EINT2 &= ~INTR_EINT2_I2C; // disable I²C interrupt } Index: firmware/target/arm/tms320dm320/timer-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/timer-dm320.c (revision 16542) +++ firmware/target/arm/tms320dm320/timer-dm320.c (working copy) @@ -8,6 +8,7 @@ * $Id$ * * Copyright (C) 2007 by Karl Kurbjun +* 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. @@ -24,12 +25,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<65535 && prescaler<1024) { @@ -67,23 +70,27 @@ static void stop_timer(void) { - 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. - * - ****************************************************************************/ +* __________ __ ___. +* 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" @@ -27,21 +27,27 @@ void tick_start(unsigned int interval_in_ms) { + int level = set_irq_level(HIGHEST_IRQ_LEVEL); + //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) - * Based on linux/include/asm-arm/arch-integrator/timex.h - */ + * Based on linux/include/asm-arm/arch-integrator/timex.h + */ 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< ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: i2c-meg-fx.h 13720 2007-06-26 02:11:30Z jethead71 $ + * $Id$ * - * Copyright (C) 2007 by Michael Sevakis + * 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. @@ -17,28 +17,9 @@ * ****************************************************************************/ -/* chip-specific i2c functions */ - -/* IICCON */ -#define I2C_ACKGEN (1 << 7) -#define I2C_TXCLK_512 (1 << 6) -#define I2C_TXRX_INTENB (1 << 5) -#define I2C_TXRX_INTPND (1 << 4) - -/* IICSTAT */ -#define I2C_MODE_MASTER (2 << 6) -#define I2C_MODE_TX (1 << 6) -#define I2C_BUSY (1 << 5) -#define I2C_START (1 << 5) -#define I2C_RXTX_ENB (1 << 4) -#define I2C_BUS_ARB_FAILED (1 << 3) -#define I2C_S_ADDR_STAT (1 << 2) -#define I2C_S_ADDR_MATCH (1 << 1) -#define I2C_ACK_L (1 << 0) - -/* IICLC */ -#define I2C_FLT_ENB (1 << 2) - void i2c_init(void); -void i2c_write(int addr, const unsigned char *data, int count); +void i2c_begin(void); +void i2c_end(void); +int i2c_write(unsigned short address, const unsigned char *data, int count); +int i2c_read(unsigned short address, unsigned char* buf, int count ); Index: firmware/target/arm/tms320dm320/system-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/system-dm320.c (revision 16542) +++ firmware/target/arm/tms320dm320/system-dm320.c (working copy) @@ -8,6 +8,7 @@ * $Id$ * * Copyright (C) 2007 by Karl Kurbjun + * 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. @@ -78,7 +79,7 @@ default_interrupt(ARMCOM_TX); default_interrupt(RESERVED); -static void (* const irqvector[])(void) = +static void (* const irqvector[])(void) __attribute__((aligned(4))) = { TIMER0,TIMER1,TIMER2,TIMER3,CCD_VD0,CCD_VD1, CCD_WEN,VENC,SERIAL0,SERIAL1,EXT_HOST,DSPHINT, @@ -102,50 +103,62 @@ static void UIRQ(void) { - unsigned int offset = (IO_INTC_IRQENTRY0>>2)-1; - panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]); + unsigned int IRQoffset = (IO_INTC_IRQENTRY0 + (IO_INTC_IRQENTRY1 << 16)) - (int)irqvector; + //unsigned int FIQoffset = (IO_INTC_FIQENTRY0 + (IO_INTC_FIQENTRY1 << 16)) - (int)irqvector; + panicf("Unhandled IRQ %02X: %s (0x%x and 0x%x)", IRQoffset/4, irqname[(IRQoffset/4)], IO_INTC_IRQENTRY0 + (IO_INTC_IRQENTRY1 << 16), IO_INTC_FIQENTRY0 + (IO_INTC_FIQENTRY1 << 16)); } 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 */ + asm volatile("stmfd sp!, {r0-r7, ip, lr}\n" /* Store context */ + "sub sp, sp, #8 \n" /* Reserve stack */ + "LDR R3, =0x30518 \n" + "LDRH R2, [R3] \n" + "MOV R2, R2,LSL#16 \n" + "MOV R2, R2,LSR#16 \n" + "ADD R3, R3, #2 \n" + "LDRH R3, [R3] \n" + "MOV R3, R3,LSL#16 \n" + "LDR R3, [R2,R3] \n" + "BLX R3 \n" + "add sp, sp, #8 \n" /* Cleanup stack */ + "ldmfd sp!, {r0-r7, ip, lr}\n" /* Restore context */ + "subs pc, lr, #4 \n"); /* Return from IRQ */ } 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" + "LDR R3, =0x30510 \n" + "LDRH R2, [R3] \n" + "MOV R2, R2,LSL#16 \n" + "MOV R2, R2,LSR#16 \n" + "ADD R3, R3, #2 \n" + "LDRH R3, [R3] \n" + "MOV R3, R3,LSL#16 \n" + "LDR R3, [R2,R3] \n" + "BLX R3 \n" "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" ); } void system_reboot(void) { - } void system_init(void) { + int level = set_irq_level(HIGHEST_IRQ_LEVEL); /* taken from linux/arch/arm/mach-itdm320-20/irq.c */ /* Clearing all FIQs and IRQs. */ @@ -162,21 +175,28 @@ IO_INTC_EINT1 = 0; IO_INTC_EINT2 = 0; - /* Setting INTC to all IRQs. */ + /* Setting all INTC to IRQs. */ IO_INTC_FISEL0 = 0; IO_INTC_FISEL1 = 0; IO_INTC_FISEL2 = 0; - IO_INTC_ENTRY_TBA0 = 0; - IO_INTC_ENTRY_TBA1 = 0; + /* Setting IRQ base address to 0 and size to 4 bytes */ + IO_INTC_ENTRY_TBA0 = ((int)irqvector & 0xFFFF) & ~1; + IO_INTC_ENTRY_TBA1 = (int)irqvector >> 16; + + /* IRQENTRY only reflects enabled interrupts */ + IO_INTC_RAW = 0; - /* Turn off other timers */ + /* 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,10 +206,21 @@ /* 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, 64, CACHE_ALL); /*64 must be equal to MEMORY_SIZE, but this doesn't seem to be available in C code (only in .lds) */ /* 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(); + set_irq_level(level); } int system_memory_guard(int newmode) Index: firmware/target/arm/tms320dm320/debug-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/debug-dm320.c (revision 16542) +++ firmware/target/arm/tms320dm320/debug-dm320.c (working copy) @@ -8,6 +8,7 @@ * $Id$ * * Copyright (C) 2007 by Karl Kurbjun + * 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. @@ -37,8 +38,11 @@ extern int r_button; bool __dbg_hw_info(void) { - int line = 0, button, oldline; + int line = 0, oldline; +#ifndef CREATIVE_ZVM + int button; int *address=0x0; +#endif bool done=false; char buf[100]; @@ -58,12 +62,25 @@ 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); + + 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"); + } line++; oldline=line; while(!done) { line = oldline; +#ifndef CREATIVE_ZVM button = button_get(false); button&=~BUTTON_REPEAT; if (button == BUTTON_POWER) @@ -76,19 +93,24 @@ address+=0x800; else if (button==BUTTON_RC_REW) address-=0x800; +#endif snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x", r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf); +#ifndef CREATIVE_ZVM snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x", (unsigned int)button, r_button); lcd_puts(0, line++, buf); +#endif 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(); } Index: firmware/target/arm/tms320dm320/spi-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/spi-dm320.c (revision 16542) +++ firmware/target/arm/tms320dm320/spi-dm320.c (working copy) @@ -31,6 +31,7 @@ #define GIO_TS_ENABLE (1<<2) #define GIO_RTC_ENABLE (1<<12) #define GIO_BL_ENABLE (1<<13) +#define GIO_LCD_ENABLE (1<<5) struct mutex spi_mtx; @@ -43,8 +44,9 @@ struct SPI_info spi_targets[] = { [SPI_target_TSC2100] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_TS_ENABLE }, - [SPI_target_RX5X348AB] = { &IO_GIO_BITSET0, &IO_GIO_BITCLR0, GIO_RTC_ENABLE }, + [SPI_target_RX5X348AB] = { &IO_GIO_BITSET0, &IO_GIO_BITCLR0, GIO_RTC_ENABLE}, [SPI_target_BACKLIGHT] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_BL_ENABLE }, + [SPI_target_LTV250QV] = { &IO_GIO_BITCLR2, &IO_GIO_BITSET2, GIO_LCD_ENABLE}, }; static void spi_disable_all_targets(void) @@ -98,11 +100,12 @@ IO_SERIAL0_MODE |= 1<<10; /* Enable TX */ IO_SERIAL0_TX_ENABLE = 0x0001; - +#ifndef CREATIVE_ZVM /* Set GIO 18 to output for touch screen slave enable */ IO_GIO_DIR1 &= ~GIO_TS_ENABLE; /* Set GIO 12 to output for rtc slave enable */ IO_GIO_DIR0 &= ~GIO_RTC_ENABLE; spi_disable_all_targets(); /* make sure only one is ever enabled at a time */ +#endif } Index: firmware/target/arm/tms320dm320/spi-target.h =================================================================== --- firmware/target/arm/tms320dm320/spi-target.h (revision 16542) +++ firmware/target/arm/tms320dm320/spi-target.h (working copy) @@ -27,6 +27,7 @@ SPI_target_TSC2100 = 0, SPI_target_RX5X348AB, SPI_target_BACKLIGHT, + SPI_target_LTV250QV, SPI_MAX_TARGETS, }; Index: firmware/target/arm/tms320dm320/creative-zvm/ata-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/ata-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/ata-target.h (revision 0) @@ -0,0 +1,71 @@ +/*************************************************************************** + * __________ __ ___. + * 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*)(0x50FF600C))) //just to set ATA_CONTROL to *some* value +//0x50FFC000 +//0x50FF6000 +//0x50FF600C + +#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 Index: firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c (revision 0) @@ -0,0 +1,365 @@ +/*************************************************************************** +* __________ __ ___. +* 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 = false; /* Is the display turned on? */ + +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; +} + + +/* LTV250QV panel functions */ + +static void lcd_write_reg(unsigned char reg, unsigned short val) +{ + unsigned char block[] = {0x74, 0, reg | 0xFF}; + spi_block_transfer(SPI_target_LTV250QV, block, sizeof(block), NULL, 0); + unsigned char block2[] = {0x76, (val >> 8) & 0xFF, val & 0xFF}; + spi_block_transfer(SPI_target_LTV250QV, block2, sizeof(block2), NULL, 0); +} + +#if 0 +static void sleep_ms(unsigned int ms) +{ + unsigned int temp = current_tick; + while(current_tick> 16; + IO_OSD_OSDWIN0ADL=addr & 0xFFFF; + + IO_OSD_BASEPX=26; //Zen Vision=80 + IO_OSD_BASEPY=5; //Zen Vision=0 + + 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 + set_irq_level(oldlevel); +} + + +/*** 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) + 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); +} + Index: firmware/target/arm/tms320dm320/creative-zvm/adc-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/adc-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/adc-target.h (revision 0) @@ -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 Index: firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h (revision 0) @@ -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 Index: firmware/target/arm/tms320dm320/creative-zvm/button-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/button-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/button-target.h (revision 0) @@ -0,0 +1,59 @@ +/*************************************************************************** +* __________ __ ___. +* 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_MAIN (BUTTON_BACK|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT \ + |BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT|BUTTON_POWER \ + |BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_NEXT|BUTTON_PREV \ + |BUTTON_PLAY|BUTTON_HOLD) + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#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) + +void button_init_device(void); +int button_read_device(void); +bool headphones_inserted(void); +bool button_hold(void); + +#endif /* _BUTTON_TARGET_H_ */ Index: firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h (revision 0) @@ -0,0 +1,25 @@ +/*************************************************************************** + * __________ __ ___. + * 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); + +#endif Index: firmware/thread.c =================================================================== --- firmware/thread.c (revision 16542) +++ firmware/thread.c (working copy) @@ -1588,13 +1588,15 @@ */ void switch_thread(struct thread_entry *old) { +#if defined(CREATIVE_ZVM) && defined(BOOTLOADER) + return; /* quick and dirty hack */ +#endif const unsigned int core = CURRENT_CORE; struct thread_entry *thread = cores[core].running; struct thread_entry *block = old; if (block == NULL) old = thread; - #ifdef RB_PROFILE profile_thread_stopped(old - threads); #endif @@ -1617,7 +1619,6 @@ * any of them due to timeout. Also puts core into sleep state until * there is at least one running process again. */ thread = sleep_core(IF_COP(core)); - #ifdef HAVE_PRIORITY_SCHEDULING /* Select the new task based on priorities and the last time a process * got CPU time. */ @@ -1687,6 +1688,9 @@ */ void sleep_thread(int ticks) { +#if defined(CREATIVE_ZVM) && defined(BOOTLOADER) + return; /* quick and dirty hack */ +#endif /* Get the entry for the current running thread. */ struct thread_entry *current = cores[CURRENT_CORE].running; @@ -1694,7 +1698,6 @@ /* Lock thread slot */ GET_THREAD_STATE(current); #endif - /* Set our timeout, change lists, and finally switch threads. * Unlock during switch on mulicore. */ current->tmo_tick = current_tick + ticks + 1; Index: firmware/timer.c =================================================================== --- firmware/timer.c (revision 16542) +++ firmware/timer.c (working copy) @@ -304,7 +304,7 @@ #elif CONFIG_CPU == PNX0101 TIMER1.ctrl &= ~0x80; /* disable timer 1 */ irq_disable_int(IRQ_TIMER1); -#elif CONFIG_CPU == S3C2440 +#else __TIMER_UNREGISTER(); #endif pfn_timer = NULL; Index: firmware/FILES =================================================================== --- firmware/FILES (revision 16542) +++ firmware/FILES (working copy) @@ -42,6 +42,7 @@ target/arm/tcc780x/*.[chS] target/arm/tcc780x/cowond2/*.[chS] target/arm/tms320dm320/*.[chS] +target/arm/tms320dm320/creative-zvm/*.[chS] target/arm/tms320dm320/mrobe-500/*.[chS] target/coldfire/*.[chS] target/coldfire/iaudio/*.[chS] Index: firmware/drivers/ata.c =================================================================== --- firmware/drivers/ata.c (revision 16542) +++ firmware/drivers/ata.c (working copy) @@ -1052,7 +1052,7 @@ for (i=0; i ) \___| < | \_\ ( <_> > < < + * 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 "usb-target.h" +#include "usb_drv.h" +#include "isp1583.h" + +struct usb_endpoint +{ + unsigned char *out_buf; + short out_len; + short out_ptr; + void (*out_done)(int, unsigned char *, int); + unsigned char out_in_progress; + + unsigned char *in_buf; + short in_min_len; + short in_max_len; + short in_ptr; + void (*in_done)(int, unsigned char *, int); + unsigned char in_ack; + + unsigned char halt[2]; + unsigned char enabled[2]; + short max_pkt_size[2]; +}; + +void usb_drv_init(void) +{ + +} + +void usb_drv_exit(void) +{ + +} + +void usb_drv_int(void) +{ + +}