Index: bootloader/creativezvm.c =================================================================== --- bootloader/creativezvm.c (revision 0) +++ bootloader/creativezvm.c (revision 0) @@ -0,0 +1,527 @@ +/*************************************************************************** +* __________ __ ___. +* 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 "backlight.h" +#include "backlight-target.h" +#include "button.h" +#include "panic.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" + +#define OF_firmware_load(mem_addr, size) asm volatile ( \ + "mov r1, %1\n" \ + "mov r0, %0\n" \ + "ldr pc, =0x1EE0000\n" \ + : \ + : "r"(mem_addr), "r"(size)\ + ); + +void i2c_reading(void){ + + reset_screen(); + printf("Starting I2C reading..."); + + unsigned char test[16]; + 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 dbg_dump_buffer(unsigned char *buf, int len, bool hex_mode) +{ + int i, j; + unsigned char c; + unsigned char ascii[60]; + + if(hex_mode) + { + for(i = 0; i < len/26; i++) + { + for(j = 0; j < 26; j++) + snprintf(&ascii[j*2], 3, "%02x", buf[i*26+j]); + printf("%s", ascii); + } + } + else + { + for(i = 0;i < len/32; i++) + { + for(j = 0;j < 32; j++) + { + c = buf[i*32+j]; + + if(c < 32 || c > 127) + ascii[j] = '.'; + else + ascii[j] = c; + } + ascii[j] = 0; + printf("%s", ascii); + } + } +} + +static struct partition_struct +{ + unsigned int end; + unsigned int start; + char name[8]; +} partition_struct; + +static struct hdd_struct +{ + unsigned char MBLK[4]; + int block_size; + long long total_disk_size; + struct partition_struct minifs; + struct partition_struct cfs; +} hdd_struct; + +static struct __attribute__ ((aligned (32))) minifs_file +{ + char name[16]; + unsigned int unk; + unsigned int size; + unsigned int index; + unsigned int index2; +} minifs_file; + +void do_hdd_browsing(void) +{ + unsigned int i; + unsigned short* identify_info; + identify_info = ata_get_identify(); + reset_screen(); + printf("[ATA_IDENTIFY]"); + for(i=0;i<256;i+=16) + printf("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", + identify_info[i], identify_info[i+1], identify_info[i+2], identify_info[i+3],identify_info[i+4], identify_info[i+5], identify_info[i+6], identify_info[i+7], + identify_info[i+8], identify_info[i+9], identify_info[i+10], identify_info[i+11],identify_info[i+12], identify_info[i+13], identify_info[i+14], identify_info[i+15]); + while(button_read_device() ^ BUTTON_CUSTOM) + yield(); + unsigned char temp[512]; + char temp3[512]; + struct hdd_struct* temp2; + unsigned int j; + reset_screen(); + bool hex_mode = false, mode_changed = false; + ata_read_sectors(0, 1, &temp); + temp2 = (struct hdd_struct*)temp; + i = 0; + j = 1; + while(button_read_device() ^ BUTTON_BACK) + { + if(i!=j || mode_changed) + { + reset_screen(); + printf("---------------------------------------"); + #define _M(x) temp2->MBLK[x] + printf("[%c%c%c%c]", _M(3), _M(2), _M(1), _M(0)); + #undef _M + printf("-> %d * 0x%x -> 0x%x", temp2->block_size, temp2->total_disk_size, temp2->block_size*temp2->total_disk_size); + printf(" * [%s]: 0x%x -> 0x%x", temp2->minifs.name, temp2->minifs.start, temp2->minifs.end); + printf(" * [%s]: 0x%x -> 0x%x", temp2->cfs.name, temp2->cfs.start, temp2->cfs.end); + printf("---------------------------------------"); + printf("[CURRENTLY]: 0x%x * %d = 0x%x", i, temp2->block_size, i*temp2->block_size); + if(!mode_changed) + ata_read_sectors(i*temp2->block_size, 1, &temp3); + dbg_dump_buffer(temp3, 512, hex_mode); + mode_changed = false; + j = i; + } + if((button_read_device() & BUTTON_DOWN) && j==i) + i++; + else if((button_read_device() & BUTTON_UP) && j==i) + i--; + else if((button_read_device() & BUTTON_LEFT) && hex_mode) + { + hex_mode = false; + mode_changed = true; + } + else if(button_read_device() & BUTTON_MENU) + { + char msg[30]; + while(button_read_device() ^ BUTTON_PLAY) + { + if(button_read_device() & BUTTON_DOWN) + i+= 2 * (button_read_device() & BUTTON_HOLD ? 2 : 1); + else if(button_read_device() & BUTTON_UP) + i-= 2 * (button_read_device() & BUTTON_HOLD ? 2 : 1); + snprintf(msg, sizeof(char)*30, "0x%0x", i); + lcd_set_foreground(LCD_RGBPACK(200, 255, 0)); + lcd_putsxy(SYSFONT_WIDTH*12, SYSFONT_HEIGHT*6, msg); + lcd_update(); + } + lcd_set_foreground(LCD_BLACK); + } + else if((button_read_device() & BUTTON_RIGHT) && !hex_mode) + { + hex_mode = true; + mode_changed = true; + } + if(i*temp2->block_size > temp2->total_disk_size) + i = temp2->total_disk_size * temp2->block_size; + yield(); + } +} + +#define ACCESS_DATA(x) (*(volatile unsigned char *)(address + x)) +void do_data_browsing(unsigned int address) +{ + reset_screen(); + char msg[30]; + char put[4]; + unsigned int i=address, lasti=0; + int j,k,l; + while(true) + { + if((button_read_device() & BUTTON_DOWN) && lasti==i) + i+= LCD_WIDTH/(SYSFONT_WIDTH*2); + else if((button_read_device() & BUTTON_UP) && lasti==i) + i-= LCD_WIDTH/(SYSFONT_WIDTH*2); + else if(button_read_device() & BUTTON_MENU) + { + lcd_set_foreground(LCD_RGBPACK(100, 255, 0)); + while(button_read_device() ^ BUTTON_PLAY) + { + if(button_read_device() & BUTTON_DOWN) + i+= LCD_WIDTH/(SYSFONT_WIDTH*2); + else if(button_read_device() & BUTTON_UP) + i-= LCD_WIDTH/(SYSFONT_WIDTH*2); + snprintf(msg, sizeof(char)*30, "%0x", i); + lcd_putsxy(0, 0, msg); + lcd_update(); + } + lcd_set_foreground(LCD_BLACK); + } + else if(button_read_device() & BUTTON_BACK) + return; + if(iAMOUNT_CHOICES-1) + sel_choice = 0; + lastbtn = btn; + } + lcd_update(); + yield(); + } +} + +void read_rtc(void) +{ + unsigned char test[12]; + char temp2[20]; + i2c_read(0x51, test, 12); + snprintf(temp2, sizeof(char)*20, "%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]); + printf("RTC = %s", temp2); + return; +} +void do_pic(void) +{ + unsigned char test[16]; + char msg[20]; + IO_INTC_EINT1 &= ~INTR_EINT1_EXT0; + msg[0] = 1; + i2c_write(0x07, &msg[0], 1); + i2c_read(0x07, test, 16); + snprintf(msg, sizeof(char)*20, "%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("%s", msg); + msg[0] = 2; + i2c_write(0x07, &msg[0], 1); + i2c_read(0x07, test, 16); + snprintf(msg, sizeof(char)*20, "%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("%s", msg); + msg[0] = 9; + i2c_write(0x07, &msg[0], 1); + i2c_read(0x07, test, 16); + snprintf(msg, sizeof(char)*20, "%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("%s", msg); + msg[0] = 10; + i2c_write(0x07, &msg[0], 1); + i2c_read(0x07, test, 16); + snprintf(msg, sizeof(char)*20, "%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("%s", msg); + IO_INTC_IRQ1 = INTR_IRQ1_EXT0; + IO_INTC_EINT1 |= INTR_EINT1_EXT0; + sleep(5); + return; +} + +#include "dsp-target.h" +#include "dsp_image_helloworld.h" +void main(void) +{ +#if 1 + unsigned char* loadbuffer; + int buffer_size; + int rc; + int(*kernel_entry)(void); +#endif + + + /* Make sure interrupts are disabled */ + set_irq_level(IRQ_DISABLED); + set_fiq_status(FIQ_DISABLED); + system_init(); + kernel_init(); + + /* Now enable interrupts */ + set_irq_level(IRQ_ENABLED); + set_fiq_status(FIQ_ENABLED); + backlight_init(); + lcd_init(); + font_init(); + button_init(); + + lcd_enable(true); + lcd_setfont(FONT_SYSFIXED); + reset_screen(); + printf("Rockbox boot loader"); + printf("Version %s", APPSVERSION); + + //asm volatile("msr cpsr_c, #0x13"); // Supervisory mode with interrupts(IRQ/FIQ) enabled +#if 0 + printf("Initing DSP..."); + dsp_init(); +#endif + +#if 1 + int ret= ata_init(); + if(ret) + printf("ATA error: %d", ret); + + if(button_read_device() & BUTTON_HOLD) + do_rescue_menu(); + + unsigned char temp[512]; + struct hdd_struct* temp2; + const unsigned char MBLK[4] = {0x4B, 0x4C, 0x42, 0x4D};/* 0x4B4C424D = KLBM */ + ata_read_sectors(0, 1, &temp); + temp2 = (struct hdd_struct*)temp; + + unsigned int pc; + asm volatile("mov %0, pc\n" : "=r"(pc)); + printf("Current PC: 0x%x", pc); + + if(memcmp(temp2->MBLK, MBLK, 4) != 0) + printf("Unknown partition table!"); + else if(strcmp(temp2->cfs.name, "fat") == 0) + { + ret = fat_mount(IF_MV2(0,) IF_MV2(0,) temp2->cfs.start); + if(ret) + printf("FAT mount error: %d", ret); + + printf("Loading firmware..."); + + loadbuffer = (unsigned char*)0x00900000; + buffer_size = (unsigned char*)0x01900000 - loadbuffer; + + rc = load_firmware(loadbuffer, BOOTFILE, buffer_size); + if(rc < 0) + error(EBOOTFILE, rc); + else if (rc == EOK) + { + printf("Loading Rockbox..."); + kernel_entry = (void*) loadbuffer; + rc = kernel_entry(); + printf("FAILED!"); + } + } + else + printf("No FAT partition found!"); +#endif + + printf("initing USB"); + usb_init(); + + printf("start USB monitoring..."); + usb_start_monitoring(); + + printf("enable USB SERIAL DRIVER..."); + usb_core_enable_driver(USB_DRIVER_SERIAL, true); + + unsigned char test[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + while(1) + { + snprintf(test, sizeof(char)*16, "%x ", button_read_device()); + lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*5, SYSFONT_HEIGHT*2, test); + lcd_update(); + if(button_read_device() & BUTTON_PLAY) + do_hdd_browsing(); + else if(button_read_device() & BUTTON_MENU) + do_rescue_menu(); + else if(button_read_device() & BUTTON_BACK) + do_pic(); + else if(button_read_device() & BUTTON_CUSTOM) + reset_screen(); + yield(); + } + + + /* Show debug messages if button is pressed */ + if(button_read_device()) + verbose = true; +} Index: bootloader/SOURCES =================================================================== --- bootloader/SOURCES (revision 17225) +++ bootloader/SOURCES (working copy) @@ -27,4 +27,8 @@ mrobe500.c #elif defined(CPU_TCC77X) || defined(CPU_TCC780X) telechips.c +#elif defined(CREATIVE_ZVM) +creativezvm.c +#else +main.c #endif Index: tools/creative.c =================================================================== --- tools/creative.c (revision 17225) +++ tools/creative.c (working copy) @@ -41,7 +41,15 @@ {"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0E\0N\0 \0V", 42, null_key_v4} }; +static const unsigned char bootloader_code[] = +{ + 0xD3, 0xF0, 0x29, 0xE3, /* MSR CPSR_cf, #0xD3 */ + 0x09, 0xF6, 0xA0, 0xE3 /* MOV PC, #0x900000 */ +}; +#define SIZEOF_BOOTLOADER_CODE sizeof(bootloader_code)/sizeof(unsigned char) + + /* Create a Zen Vision:M FRESCUE structure file */ @@ -77,11 +85,8 @@ static int make_jrm_file(unsigned char *inbuf, int length, unsigned char *outbuf) { - int i; + unsigned int i; unsigned int sum = 0; - /* Calculate checksum for later use in header */ - for(i=0; i>16); /* Clear the header area to zero */ memset(outbuf, 0, 0x18); @@ -89,34 +94,42 @@ /* Header (EDOC) */ memcpy(outbuf, "EDOC", 4); /* Total Size */ - int2le(length+0x20, &outbuf[0x4]); + int2le(4+0xC+SIZEOF_BOOTLOADER_CODE+0xC+length, &outbuf[0x4]); /* 4 bytes of zero */ - - /* Address = 0x900000 */ - int2le(0x900000, &outbuf[0xC]); + memset(&outbuf[0x8], 0, 0x4); + + /* First block starts here ... */ + /* Address = 0x0 */ + memset(&outbuf[0xC], 0, 0x4); /* Size */ - int2le(length, &outbuf[0x10]); + int2le(SIZEOF_BOOTLOADER_CODE, &outbuf[0x10]); /* Checksum */ + for(i=0; i>16); int2le(sum, &outbuf[0x14]); outbuf[0x16] = 0; outbuf[0x17] = 0; - /* Data starts here... */ - memcpy(&outbuf[0x18], inbuf, length); - + /*Data */ + memcpy(&outbuf[0x18], bootloader_code, SIZEOF_BOOTLOADER_CODE); + + #define SB_START (0x18+SIZEOF_BOOTLOADER_CODE) + /* Second block starts here ... */ - /* Address = 0x0 */ + /* Address = 0x0900000 */ + int2le(0x0900000, &outbuf[SB_START]); /* Size */ - int2le(0x4, &outbuf[0x18+length+0x4]); + int2le(length, &outbuf[SB_START+0x4]); /* Checksum */ - outbuf[0x18+length+0x8] = 0xA9; - outbuf[0x18+length+0x9] = 0xD9; - /* Data: MOV PC, 0x900000 */ - outbuf[0x18+length+0xC] = 0x09; - outbuf[0x18+length+0xD] = 0xF6; - outbuf[0x18+length+0xE] = 0xA0; - outbuf[0x18+length+0xF] = 0xE3; - - return length+0x18+0x10; + sum = 0; + for(i=0; i>16); + int2le(sum, &outbuf[SB_START+0x8]); + outbuf[SB_START+0xA] = 0; + outbuf[SB_START+0xB] = 0; + /* Data */ + memcpy(&outbuf[SB_START+0xC], inbuf, length); + + return 0x18+SIZEOF_BOOTLOADER_CODE+0xC+length; } int zvm_encode(char *iname, char *oname, int device) Index: tools/configure =================================================================== --- tools/configure (revision 17225) +++ tools/configure (working copy) @@ -1461,12 +1461,12 @@ bmp2rb_native="$rootdir/tools/bmp2rb -f 4" bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" - tool="cp" + tool="$rootdir/tools/scramble -creative=zvm" output="rockbox.zvm" appextra="recorder:gui" plugins="" swcodec="yes" - toolset=$gigabeatbitmaptools + toolset=$ipodbitmaptools boottool="$rootdir/tools/scramble -creative=zvm" bootoutput="rockbox.zvmboot" # architecture, manufacturer and model for the target-tree build Index: tools/scramble.c =================================================================== --- tools/scramble.c (revision 17225) +++ tools/scramble.c (working copy) @@ -117,7 +117,7 @@ "\t-add=X Rockbox generic \"add-up\" checksum format\n" "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n" "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n" - "\t tpj2, c200, e200, giga, gigs, m100, m500, d2)\n"); + "\t tpj2, c200, e200, giga, gigs, m100, m500, d2, zvm)\n"); printf("\nNo option results in Archos standard player/recorder format.\n"); exit(1); @@ -269,6 +269,8 @@ modelnum = 24; else if(!strcmp(&argv[1][5], "iam3")) modelnum = 25; + else if(!strcmp(&argv[1][5], "zvm")) + modelnum = 26; else { fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); return 2; Index: utils/MTP/sendfirm.c =================================================================== --- utils/MTP/sendfirm.c (revision 17225) +++ utils/MTP/sendfirm.c (working copy) @@ -54,7 +54,6 @@ int sendfile_function(char *from_path) { printf("Sending %s\n", from_path); - char *filename; uint64_t filesize; #ifdef __USE_LARGEFILE64 struct stat64 sb; @@ -82,7 +81,6 @@ #else filesize = (uint64_t) sb.st_size; #endif - filename = basename(from_path); genfile = LIBMTP_new_file_t(); genfile->filesize = filesize; Index: apps/SOURCES =================================================================== --- apps/SOURCES (revision 17225) +++ apps/SOURCES (working copy) @@ -178,4 +178,6 @@ keymaps/keymap-mr100.c #elif CONFIG_KEYPAD == COWOND2_PAD keymaps/keymap-cowond2.c +#elif CONFIG_KEYPAD == CREATIVEZVM_PAD +keymaps/keymap-creativezvm.c #endif Index: apps/keymaps/keymap-creativezvm.c =================================================================== --- apps/keymaps/keymap-creativezvm.c (revision 0) +++ apps/keymaps/keymap-creativezvm.c (revision 0) @@ -0,0 +1,308 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ + +/* Button Code Definitions for the Creative Zen Vision:M target */ +#include +#include +#include + +#include "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +/* + * The format of the list is as follows + * { Action Code, Button code, Prereq button code } + * if there's no need to check the previous button's value, use BUTTON_NONE + * Insert LAST_ITEM_IN_LIST at the end of each mapping + */ + +/* CONTEXT_CUSTOM's used in this file... + +CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions) +CONTEXT_CUSTOM|CONTEXT_SETTINGS = the direction keys for the eq/col picker screens + i.e where up/down is inc/dec + CONTEXT_SETTINGS = up/down is prev/next, l/r is inc/dec + +*/ + +#define BUTTON_VOL_UP BUTTON_NONE +#define BUTTON_VOL_DOWN BUTTON_NONE + +static const struct button_mapping button_context_standard[] = { + { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + + { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, + + { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT,BUTTON_SELECT }, + + { ACTION_STD_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, + { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, + + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_standard */ + + +static const struct button_mapping button_context_wps[] = { + { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_WPS_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + + { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + + { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, + { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, + + { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_PLAY|BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_WPS_ABSETA_PREVDIR, BUTTON_PLAY|BUTTON_LEFT, BUTTON_NONE }, + { ACTION_WPS_ABRESET, BUTTON_PLAY|BUTTON_SELECT, BUTTON_NONE }, + + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_VOL_DOWN }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_VOL_UP }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + + { ACTION_WPS_PITCHSCREEN, BUTTON_PLAY|BUTTON_UP, BUTTON_PLAY }, + { ACTION_WPS_PITCHSCREEN, BUTTON_PLAY|BUTTON_DOWN, BUTTON_PLAY }, + + { ACTION_WPS_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, + { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, + { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + + { ACTION_WPS_ID3SCREEN, BUTTON_PLAY|BUTTON_MENU, BUTTON_NONE }, + { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST +}; /* button_context_wps */ + +static const struct button_mapping button_context_list[] = { + { ACTION_LISTTREE_PGUP, BUTTON_UP, BUTTON_NONE }, + { ACTION_LISTTREE_PGUP, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + { ACTION_LISTTREE_PGUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, + { ACTION_LISTTREE_PGDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, +#ifdef HAVE_VOLUME_IN_LIST + { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_VOL_UP }, + { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_VOL_DOWN }, +#endif + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_list */ + +static const struct button_mapping button_context_tree[] = { + { ACTION_TREE_WPS, BUTTON_REL, BUTTON_NONE }, + { ACTION_TREE_STOP, BUTTON_POWER, BUTTON_NONE }, + { ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) +}; /* button_context_tree */ + +static const struct button_mapping button_context_listtree_scroll_with_combo[] = { + { ACTION_NONE, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT, BUTTON_LEFT|BUTTON_REL }, + //{ ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT, BUTTON_RIGHT|BUTTON_REL }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), +}; + +static const struct button_mapping button_context_listtree_scroll_without_combo[] = { + { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + //{ ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, + { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), +}; + +static const struct button_mapping button_context_settings[] = { + { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_SETTINGS_RESET, BUTTON_PLAY, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings */ + +static const struct button_mapping button_context_settings_right_is_inc[] = { + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_SETTINGS_RESET, BUTTON_PLAY, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settingsgraphical */ + +static const struct button_mapping button_context_yesno[] = { + { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings_yesno */ + +static const struct button_mapping button_context_colorchooser[] = { + { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), +}; /* button_context_colorchooser */ + +static const struct button_mapping button_context_eq[] = { + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), +}; /* button_context_eq */ + +/** Bookmark Screen **/ +static const struct button_mapping button_context_bmark[] = { + { ACTION_BMS_DELETE, BUTTON_PLAY, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), +}; /* button_context_bmark */ + +static const struct button_mapping button_context_time[] = { + { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_PLAY, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS), +}; /* button_context_time */ + +static const struct button_mapping button_context_quickscreen[] = { + { ACTION_QS_DOWNINV, BUTTON_UP, BUTTON_NONE }, + { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_quickscreen */ + +static const struct button_mapping button_context_pitchscreen[] = { + { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE }, + { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_TOGGLE_MODE, BUTTON_MENU, BUTTON_NONE }, + { ACTION_PS_RESET, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_pitchcreen */ + +static const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_KBD_PAGE_FLIP, BUTTON_MENU, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_REL, BUTTON_PLAY }, + { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_KBD_BACKSPACE, BUTTON_MENU, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU }, + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_KBD_MORSE_INPUT, BUTTON_POWER, BUTTON_NONE }, + { ACTION_KBD_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + +const struct button_mapping* get_context_mapping(int context) +{ + switch (context&~CONTEXT_REMOTE) + { + case CONTEXT_STD: + return button_context_standard; + case CONTEXT_WPS: + return button_context_wps; + case CONTEXT_LIST: + return button_context_list; + case CONTEXT_MAINMENU: + case CONTEXT_TREE: + if (global_settings.hold_lr_for_scroll_in_list) + return button_context_listtree_scroll_without_combo; + else + return button_context_listtree_scroll_with_combo; + case CONTEXT_CUSTOM|CONTEXT_TREE: + return button_context_tree; + case CONTEXT_SETTINGS: + return button_context_settings; + case CONTEXT_CUSTOM|CONTEXT_SETTINGS: + return button_context_settings_right_is_inc; + case CONTEXT_SETTINGS_COLOURCHOOSER: + return button_context_colorchooser; + case CONTEXT_SETTINGS_EQ: + return button_context_eq; + case CONTEXT_SETTINGS_TIME: + return button_context_time; + case CONTEXT_YESNOSCREEN: + return button_context_yesno; + case CONTEXT_BOOKMARKSCREEN: + return button_context_bmark; + case CONTEXT_QUICKSCREEN: + return button_context_quickscreen; + case CONTEXT_PITCHSCREEN: + return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + } + return button_context_standard; +} Index: firmware/export/dm320.h =================================================================== --- firmware/export/dm320.h (revision 17225) +++ firmware/export/dm320.h (working copy) @@ -28,7 +28,12 @@ #define LCD_BUFFER_SIZE (LCD_WIDTH*LCD_HEIGHT*2) #define TTB_SIZE (0x4000) /* must be 16Kb (0x4000) aligned */ +#if 0 +#define MEM_END 0x00900000 + (MEM*0x00100000) +#define TTB_BASE ((unsigned int *)(MEM_END - TTB_SIZE)) /* End of memory */ +#else #define TTB_BASE ((unsigned int *)(0x04900000 - TTB_SIZE)) /* End of memory */ +#endif #define FRAME ((short *) ((char*)TTB_BASE - LCD_BUFFER_SIZE)) /* Right before TTB */ #define PHY_IO_BASE 0x00030000 Index: firmware/export/config-creativezvm.h =================================================================== --- firmware/export/config-creativezvm.h (revision 17225) +++ firmware/export/config-creativezvm.h (working copy) @@ -27,7 +27,7 @@ #define CREATIVE_ZVM 1 /* For Rolo and boot loader */ -#define MODEL_NUMBER 35 +#define MODEL_NUMBER 26 /* define this if you use an ATA controller */ #define HAVE_ATA @@ -65,16 +65,13 @@ /* Define this if your LCD can be enabled/disabled */ #define HAVE_LCD_ENABLE -#define LCD_REMOTE_PIXELFORMAT VERTICAL_PACKING +#define CONFIG_KEYPAD CREATIVEZVM_PAD +#define HAS_BUTTON_HOLD +#define HAVE_HEADPHONE_DETECTION +//#define HAVE_TOUCHPAD -#define MIN_REMOTE_CONTRAST_SETTING 0 -#define MAX_REMOTE_CONTRAST_SETTING 15 -#define DEFAULT_REMOTE_CONTRAST_SETTING 7 +#define CONFIG_I2C I2C_DM320 -#define CONFIG_KEYPAD MROBE500_PAD -//#define HAVE_TOUCHPAD -#define HAVE_BUTTON_DATA - /* Define this if you do software codec */ #define CONFIG_CODEC SWCODEC @@ -84,16 +81,17 @@ /* Define this for LCD backlight available */ //#define HAVE_BACKLIGHT -#define HAVE_BACKLIGHT_BRIGHTNESS +//#define HAVE_BACKLIGHT_BRIGHTNESS /* Main LCD backlight brightness range and defaults */ -#define MIN_BRIGHTNESS_SETTING 0 -#define MAX_BRIGHTNESS_SETTING 127 -#define DEFAULT_BRIGHTNESS_SETTING 85 /* OF "full brightness" */ -#define DEFAULT_DIMNESS_SETTING 22 /* OF "most dim" */ +//#define MIN_BRIGHTNESS_SETTING 0 +//#define MAX_BRIGHTNESS_SETTING 127 +//#define DEFAULT_BRIGHTNESS_SETTING 85 /* OF "full brightness" */ +//#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 @@ -104,11 +102,11 @@ /* Define this if you have the TLV320 audio codec */ //#define HAVE_TLV320 -/* Define this if you want to use the adaptive bass capibility of the 8751 */ -/* #define USE_ADAPTIVE_BASS */ +/* TLV320 has no tone controls, so we use the software ones */ +//#define HAVE_SW_TONE_CONTROLS -#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \ - SAMPR_CAP_11) +/*#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \ + SAMPR_CAP_11)*/ #define BATTERY_CAPACITY_DEFAULT 1100 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */ @@ -117,7 +115,7 @@ #define BATTERY_TYPES_COUNT 1 /* only one type */ /* Hardware controlled charging with monitoring */ -#define CONFIG_CHARGING CHARGING_MONITOR +//#define CONFIG_CHARGING CHARGING_MONITOR #ifndef SIMULATOR @@ -127,8 +125,7 @@ /* Define this if you have a Texas Instruments TSC2100 touch screen */ //#define HAVE_TSC2100 -/* 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 @@ -161,4 +158,23 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTDIR "/.rockbox" +#define HAVE_USBSTACK +#define USB_VENDOR_ID 0x041e +#define USB_PRODUCT_ID 0x4133 + +#define USB_SERIAL + +//DEBUGGING! +#ifdef BOOTLOADER +#define THREAD_EXTRA_CHECKS 1 +#define DEBUG 1 +#define debug(msg) printf(msg) +#define BUTTON_DEBUG + +#define DO_THREAD_TEST #endif + + +//Uncomment next line to make this build Zen Vision compatible +//#define ZEN_VISION +#endif Index: firmware/export/config.h =================================================================== --- firmware/export/config.h (revision 17225) +++ firmware/export/config.h (working copy) @@ -79,6 +79,7 @@ #define IAUDIO67_PAD 21 #define COWOND2_PAD 22 #define IAUDIO_M3_PAD 23 +#define CREATIVEZVM_PAD 24 /* CONFIG_REMOTE_KEYPAD */ #define H100_REMOTE 1 @@ -143,6 +144,7 @@ #define I2C_IMX31L 9 #define I2C_TCC77X 10 #define I2C_TCC780X 11 +#define I2C_DM320 12 /* DM320 style */ /* CONFIG_LED */ #define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */ @@ -168,6 +170,7 @@ /* USB On-the-go */ #define USBOTG_ISP1362 1362 /* iriver H300 */ +#define USBOTG_ISP1583 1583 /* Creative Zen Vision:M */ #define USBOTG_M5636 5636 /* iAudio X5 */ #define USBOTG_ARC 5020 /* PortalPlayer 502x */ @@ -388,13 +391,13 @@ #define ARM_ARCH 6 /* ARMv6 */ #endif -#if defined(CPU_TCC77X) || defined(CPU_TCC780X) +#if defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) #define CPU_ARM #define ARM_ARCH 5 /* ARMv5 */ #endif #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ - || (CONFIG_CPU == DSC25) || (CONFIG_CPU == DM320) + || (CONFIG_CPU == DSC25) #define CPU_ARM #define ARM_ARCH 4 /* ARMv4 */ #endif Index: firmware/export/isp1583.h =================================================================== --- firmware/export/isp1583.h (revision 0) +++ firmware/export/isp1583.h (revision 0) @@ -0,0 +1,185 @@ +/*************************************************************************** + * __________ __ ___. + * 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 + +#ifndef ISP1583_H_OVERRIDE +/* Initialization registers */ +#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) +#define ISP1583_INIT_MODE (*((volatile unsigned short*)(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_A (*((volatile unsigned long*)(ISP1583_IOBASE+0x14))) +#define ISP1583_INIT_INTEN_B +#define ISP1583_INIT_INTEN_READ ISP1583_INIT_INTEN_A +/* 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 */ +#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58))) +/* General registers */ +#define ISP1583_GEN_INT_A (*((volatile unsigned long*)(ISP1583_IOBASE+0x18))) +#define ISP1583_GEN_INT_B +#define ISP1583_GEN_INT_READ ISP1583_GEN_INT_A +#define ISP1583_GEN_CHIPID (*((volatile unsigned long*)(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 set_int_value(a,b,value) a = value; +#endif + +#define ISP1583_UNLOCK_CODE (unsigned short)0xAA37 + +/* Initialization registers' bits */ + +/* Initialization OTG register bits */ +#define INIT_OTG_BSESS_VALID (1 << 4) + +/* Initialization Mode register bits */ +#define INIT_MODE_TEST2 (1 << 15) +#define INIT_MODE_TEST1 (1 << 14) +#define INIT_MODE_TEST0 (1 << 13) +#define INIT_MODE_DMA_CLKON (1 << 9) +#define INIT_MODE_VBUSSTAT (1 << 8) +#define INIT_MODE_CLKAON (1 << 7) +#define INIT_MODE_SNDRSU (1 << 6) +#define INIT_MODE_GOSUSP (1 << 5) +#define INIT_MODE_SFRESET (1 << 4) +#define INIT_MODE_GLINTENA (1 << 3) +#define INIT_MODE_WKUPCS (1 << 2) +#define INIT_MODE_PWRON (1 << 1) +#define INIT_MODE_SOFTCT (1 << 0) + +/* Initialization Interrupt Enable register bits */ +#define INIT_INTEN_IEP7TX (1 << 25) +#define INIT_INTEN_IEP7RX (1 << 24) +#define INIT_INTEN_IEP6TX (1 << 23) +#define INIT_INTEN_IEP6RX (1 << 22) +#define INIT_INTEN_IEP5TX (1 << 21) +#define INIT_INTEN_IEP5RX (1 << 20) +#define INIT_INTEN_IEP4TX (1 << 19) +#define INIT_INTEN_IEP4RX (1 << 18) +#define INIT_INTEN_IEP3TX (1 << 17) +#define INIT_INTEN_IEP3RX (1 << 16) +#define INIT_INTEN_IEP2TX (1 << 15) +#define INIT_INTEN_IEP2RX (1 << 14) +#define INIT_INTEN_IEP1TX (1 << 13) +#define INIT_INTEN_IEP1RX (1 << 12) +#define INIT_INTEN_IEP0TX (1 << 11) +#define INIT_INTEN_IEP0RX (1 << 10) +#define INIT_INTEN_IEP0SETUP (1 << 8) +#define INIT_INTEN_IEVBUS (1 << 7) +#define INIT_INTEN_IEDMA (1 << 6) +#define INIT_INTEN_IEHS_STA (1 << 5) +#define INIT_INTEN_IERESM (1 << 4) +#define INIT_INTEN_IESUSP (1 << 3) +#define INIT_INTEN_IEPSOF (1 << 2) +#define INIT_INTEN_IESOF (1 << 1) +#define INIT_INTEN_IEBRST (1 << 0) + +/* Initialization Interrupt Configuration register bits */ +#define INIT_INTCONF_INTLVL (1 << 1) +#define INIT_INTCONF_INTPOL (1 << 0) + +/* Initialization Address register bits */ +#define INIT_ADDRESS_DEVEN (1 << 7) + +/* Data Flow registers' bits */ + +/* Data Flow Endpoint Index register bits */ +#define DFLOW_EPINDEX_EP0SETUP (1 << 5) + +/* Data Flow Control Function register bits */ +#define DFLOW_CTRLFUN_CLBUF (1 << 4) +#define DFLOW_CTRLFUN_VENDP (1 << 3) +#define DFLOW_CTRLFUN_DSEN (1 << 2) +#define DFLOW_CTRLFUN_STATUS (1 << 1) +#define DFLOW_CTRLFUN_STALL (1 << 0) + +/* Data Flow Endpoint Type register bits */ +#define DFLOW_EPTYPE_NOEMPKT (1 << 4) +#define DFLOW_EPTYPE_ENABLE (1 << 3) +#define DFLOW_EPTYPE_DBLBUF (1 << 2) + +/* General registers' bits */ + +/* General Test Mode register bits */ +#define GEN_TSTMOD_FORCEHS (1 << 7) +#define GEN_TSTMOD_FORCEFS (1 << 4) +#define GEN_TSTMOD_PRBS (1 << 3) +#define GEN_TSTMOD_KSTATE (1 << 2) +#define GEN_TSTMOD_JSTATE (1 << 1) +#define GEN_TSTMOD_SE0_NAK (1 << 0) + +/* Interrupts */ +#define INT_IEP7TX (1 << 25) +#define INT_IEP7RX (1 << 24) +#define INT_IEP6TX (1 << 23) +#define INT_IEP6RX (1 << 22) +#define INT_IEP5TX (1 << 21) +#define INT_IEP5RX (1 << 20) +#define INT_IEP4TX (1 << 19) +#define INT_IEP4RX (1 << 18) +#define INT_IEP3TX (1 << 17) +#define INT_IEP3RX (1 << 16) +#define INT_IEP2TX (1 << 15) +#define INT_IEP2RX (1 << 14) +#define INT_IEP1TX (1 << 13) +#define INT_IEP1RX (1 << 12) +#define INT_IEP0TX (1 << 11) +#define INT_IEP0RX (1 << 10) +#define INT_IEP0SETUP (1 << 8) +#define INT_IEVBUS (1 << 7) +#define INT_IEDMA (1 << 6) +#define INT_IEHS_STA (1 << 5) +#define INT_IERESM (1 << 4) +#define INT_IESUSP (1 << 3) +#define INT_IEPSOF (1 << 2) +#define INT_IESOF (1 << 1) +#define INT_IEBRST (1 << 0) + +#define INT_EP_MASK ( INT_IEP0RX | INT_IEP0TX | INT_IEP1RX | INT_IEP1TX | INT_IEP2RX | INT_IEP2TX | INT_IEP3RX | INT_IEP3TX | INT_IEP4RX | INT_IEP4TX | INT_IEP5RX | INT_IEP5TX | INT_IEP6RX | INT_IEP6TX | INT_IEP7RX | INT_IEP7TX ) + +#define STANDARD_INTEN ( INIT_INTEN_IEBRST | INIT_INTEN_IEHS_STA | INT_IESUSP | INT_IERESM | INIT_INTEN_IEVBUS | INIT_INTEN_IEP0SETUP | INIT_INTEN_IEP0RX | INIT_INTEN_IEP0TX ) +#define STANDARD_INIT_MODE ( INIT_MODE_CLKAON | INIT_MODE_GLINTENA ) + +bool usb_drv_powered(void); +void usb_drv_init(void); +int usb_drv_port_speed(void); +void usb_drv_exit(void); +void usb_drv_stall(int endpoint, bool stall, bool in); +bool usb_drv_stalled(int endpoint, bool in); +int usb_drv_recv(int ep, void* ptr, int length); +int usb_drv_send_nonblocking(int ep, void* ptr, int length); +int usb_drv_send(int endpoint, void* ptr, int length); +void usb_drv_reset_endpoint(int ep, bool send); +void usb_drv_wait(int ep, bool send); +void usb_drv_cancel_all_transfers(void); +void usb_drv_set_address(int address); +void usb_drv_set_test_mode(int mode); +void usb_drv_int(void); /* Method for handling interrupts, must be called from usb-.c */ + +#endif Index: firmware/kernel.c =================================================================== --- firmware/kernel.c (revision 17225) +++ firmware/kernel.c (working copy) @@ -435,6 +435,11 @@ unsigned stop = USEC_TIMER + ticks * (1000000/HZ); while (TIME_BEFORE(USEC_TIMER, stop)) switch_thread(); +#elif defined(CREATIVE_ZVM) && defined(BOOTLOADER) + // hacky.. + long sleep_ticks = current_tick + ticks + 1; + while (sleep_ticks > current_tick) + switch_thread(); #else disable_irq(); sleep_thread(ticks); Index: firmware/panic.c =================================================================== --- firmware/panic.c (revision 17225) +++ firmware/panic.c (working copy) @@ -123,6 +123,8 @@ #elif CONFIG_KEYPAD == ONDIO_PAD if (!(PCDR & 0x0008)) #endif /* CONFIG_KEYPAD */ +#elif defined(CREATIVE_ZVM) + if(false) #endif /* CPU */ system_reboot(); #endif /* !SIMULATOR */ Index: firmware/usbstack/usb_core.c =================================================================== --- firmware/usbstack/usb_core.c (revision 17225) +++ firmware/usbstack/usb_core.c (working copy) @@ -21,8 +21,13 @@ #include "kernel.h" #include "string.h" //#define LOGF_ENABLE -#include "logf.h" +//#include "logf.h" +#define logf + +#define USB_SERIAL +#undef USB_CHARGING_ONLY + #include "usb.h" #include "usb_ch9.h" #include "usb_drv.h" Index: firmware/usbstack/usb_serial.c =================================================================== --- firmware/usbstack/usb_serial.c (revision 17225) +++ firmware/usbstack/usb_serial.c (working copy) @@ -23,8 +23,11 @@ #include "kernel.h" //#define LOGF_ENABLE -#include "logf.h" +//#include "logf.h" +#define logf +#define USB_SERIAL + #ifdef USB_SERIAL /* serial interface */ Index: firmware/usbstack/usb_storage.c =================================================================== --- firmware/usbstack/usb_storage.c (revision 17225) +++ firmware/usbstack/usb_storage.c (working copy) @@ -359,7 +359,7 @@ /* prime rx endpoint. We only need room for commands */ state = WAITING_FOR_COMMAND; -#if CONFIG_CPU == IMX31L +#if CONFIG_CPU == IMX31L || CONFIG_USBOTG == USBOTG_ISP1583 static unsigned char _transfer_buffer[BUFFER_SIZE*2] USBDEVBSS_ATTR __attribute__((aligned(32))); tb.transfer_buffer = (void *)_transfer_buffer; Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (revision 17225) +++ firmware/SOURCES (working copy) @@ -235,10 +235,12 @@ usbstack/usb_serial.c #if CONFIG_USBOTG == USBOTG_ARC target/arm/usb-drv-arc.c +#elif CONFIG_USBOTG == USBOTG_ISP1583 +drivers/isp1583.c #endif #else /* !defined(HAVE_USBSTACK) */ #if CONFIG_USBOTG == USBOTG_ISP1362 -drivers/isp1362.c +drivers/isp1362.c #elif CONFIG_USBOTG == USBOTG_M5636 drivers/m5636.c #endif @@ -670,6 +672,17 @@ #endif /* SIMULATOR */ #endif /* GIGABEAT_S */ +#if CONFIG_CPU == DM320 +target/arm/tms320dm320/debug-dm320.c +target/arm/tms320dm320/dsp-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 +#endif /* CONFIG_CPU == DM320 */ + #ifdef MROBE_500 #ifndef SIMULATOR target/arm/lcd-as-memframe.S @@ -687,17 +700,25 @@ target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c target/arm/tms320dm320/mrobe-500/power-mr500.c target/arm/tms320dm320/mrobe-500/usb-mr500.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 /* MROBE_500 */ +#ifdef CREATIVE_ZVM +#ifndef SIMULATOR +target/arm/lcd-as-memframe.S +target/arm/mmu-arm.c +target/arm/tms320dm320/creative-zvm/adc-creativezvm.c +target/arm/tms320dm320/creative-zvm/audio-creativezvm.c +target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c +target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c +target/arm/tms320dm320/creative-zvm/pic-creativezvm.c +target/arm/tms320dm320/creative-zvm/power-creativezvm.c +target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c +target/arm/tms320dm320/creative-zvm/usb-creativezvm.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 17225) +++ firmware/target/arm/tms320dm320/uart-dm320.c (working copy) @@ -50,7 +50,7 @@ uart1_recieve_write=0; /* Enable the interrupt */ - IO_INTC_EINT0 |= (1<>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 @@ "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 @@ 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 @@ /* 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(); } Index: firmware/target/arm/tms320dm320/dsp-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/dsp-dm320.c (revision 17225) +++ firmware/target/arm/tms320dm320/dsp-dm320.c (working copy) @@ -23,27 +23,22 @@ #include "string.h" #include "dsp-target.h" -/* A "DSP image" is an array of these, terminated by raw_data_size_half = 0. */ -struct dsp_section { - const unsigned short *raw_data; - unsigned short physical_addr; - unsigned short raw_data_size_half; -}; - /* Must define struct dsp_section before including the image. */ #include "dsp_image_helloworld.h" #ifdef DEBUG -static void dsp_status(void) +void dsp_status(void) { unsigned short hpib_ctl = IO_DSPC_HPIB_CONTROL; unsigned short hpib_stat = IO_DSPC_HPIB_STATUS; char buffer1[80], buffer2[80]; - DEBUGF("dsp_status(): clkc_hpib=%u clkc_dsp=%u", - !!(IO_CLK_MOD0 & (1 << 11)), !!(IO_CLK_MOD0 & (1 << 10))); + DEBUGF("[dsp_status()]"); - DEBUGF("dsp_status(): irq_dsphint=%u 7fff=%04x scratch_status=%04x" + DEBUGF("clkc_hpib=%u clkc_dsp=%u", + !!(IO_CLK_MOD0 & CLK_MOD0_HPIB), !!(IO_CLK_MOD0 & CLK_MOD0_DSP)); + + DEBUGF("irq_dsphint=%u 7fff=%04x scratch_status=%04x" " acked=%04x", (IO_INTC_IRQ0 >> IRQ_DSPHINT) & 1, DSP_(0x7fff), DSP_(_status), DSP_(_acked)); @@ -63,8 +58,26 @@ B(buffer2, hpib_stat, 8, HOLDA); B(buffer2, hpib_stat, 12, DXF); - DEBUGF("dsp_status(): hpib: ctl=%s stat=%s", buffer1, buffer2); + DEBUGF("hpib: ctl=%s stat=%s", buffer1, buffer2); #undef B + DEBUGF("scratch_status=%04x" + " acked=%04x", + DSP_(_status), + DSP_(_acked)); + DSP_(_status) = 0x01; + hpib_ctl = DSP_(_acked); + while(DSP_(_acked) == hpib_ctl) + DEBUGF("scratch_status=%04x" + " acked=%04x", + DSP_(_status), + DSP_(_acked)); + DSP_(_status) = 0x02; + hpib_ctl = DSP_(_acked); + while(DSP_(_acked) == hpib_ctl); + DEBUGF("scratch_status=%04x" + " acked=%04x", + DSP_(_status), + DSP_(_acked)); } #endif @@ -72,10 +85,10 @@ { DSP_(0x7fff) = 0xdead; - IO_DSPC_HPIB_CONTROL &= ~(1 << 8); + IO_DSPC_HPIB_CONTROL &= ~HPIB_CTL_DRST; /* HPIB bus cycles will lock up the ARM in here. Don't touch DSP RAM. */ nop; nop; - IO_DSPC_HPIB_CONTROL |= 1 << 8; + IO_DSPC_HPIB_CONTROL |= HPIB_CTL_DRST; /* TODO: Timeout. */ while (DSP_(0x7fff) != 0); @@ -89,9 +102,9 @@ /* The first time you INT0 the DSP, the ROM loader will branch to your RST handler. Subsequent times, your INT0 handler will get executed. */ - IO_DSPC_HPIB_CONTROL &= ~(1 << 7); + IO_DSPC_HPIB_CONTROL &= ~HPIB_CTL_DINT0; nop; nop; - IO_DSPC_HPIB_CONTROL |= 1 << 7; + IO_DSPC_HPIB_CONTROL |= HPIB_CTL_DINT0; restore_irq(old_level); } @@ -127,13 +140,16 @@ void dsp_init(void) { - IO_INTC_IRQ0 = 1 << 11; - IO_INTC_EINT0 |= 1 << 11; + IO_INTC_IRQ0 = INTR_IRQ0_IMGBUF; + IO_INTC_EINT0 |= INTR_EINT0_IMGBUF; - IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0; + IO_CLK_MOD0 |= CLK_MOD0_DSP | CLK_MOD0_HPIB; + + IO_DSPC_HPIB_CONTROL = HPIB_CTL_DBIO | HPIB_CTL_DHOLD | HPIB_CTL_DRST | HPIB_CTL_DINT0 | HPIB_CTL_HPNMI | HPIB_CTL_HPIEN; dsp_reset(); dsp_load(dsp_image_helloworld); + dsp_wake(); } void DSPHINT(void) @@ -141,7 +157,7 @@ unsigned int i; char buffer[80]; - IO_INTC_IRQ0 = 1 << 11; + IO_INTC_IRQ0 = INTR_IRQ0_IMGBUF; /* DSP stores one character per word. */ for (i = 0; i < sizeof(buffer); i++) { Index: firmware/target/arm/tms320dm320/debug-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/debug-dm320.c (revision 17225) +++ firmware/target/arm/tms320dm320/debug-dm320.c (working copy) @@ -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 @@ 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 @@ 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 @@ 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(); } Index: firmware/target/arm/tms320dm320/spi-dm320.c =================================================================== --- firmware/target/arm/tms320dm320/spi-dm320.c (revision 17225) +++ 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; @@ -39,14 +40,21 @@ volatile unsigned short *clrreg; int bit; }; -#define reg(a) ((volatile unsigned short *)(PHY_IO_BASE+a)) + struct SPI_info spi_targets[] = { +#ifndef CREATIVE_ZVM [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 }, +#else + [SPI_target_LTV250QV] = { &IO_GIO_BITCLR2, &IO_GIO_BITSET2, GIO_LCD_ENABLE}, +#endif }; +#define IO_SERIAL0_XMIT (0x100) +#define IO_SERIAL0_MODE_SCLK (1 << 10) + static void spi_disable_all_targets(void) { int i; @@ -70,7 +78,7 @@ IO_SERIAL0_TX_DATA = *tx_bytes++; /* Wait until transfer finished */ - while (IO_SERIAL0_RX_DATA & 0x100); + while (IO_SERIAL0_RX_DATA & IO_SERIAL0_XMIT); } while (rx_size--) @@ -80,7 +88,7 @@ /* Wait until transfer finished */ unsigned short data; - while ((data = IO_SERIAL0_RX_DATA) & 0x100); + while ((data = IO_SERIAL0_RX_DATA) & IO_SERIAL0_XMIT); *rx_bytes++ = data & 0xff; } @@ -95,14 +103,15 @@ { mutex_init(&spi_mtx); /* Set SCLK idle level = 0 */ - IO_SERIAL0_MODE |= 1<<10; + IO_SERIAL0_MODE |= IO_SERIAL0_MODE_SCLK; /* 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; - +#endif spi_disable_all_targets(); /* make sure only one is ever enabled at a time */ + } Index: firmware/target/arm/tms320dm320/dsp-target.h =================================================================== --- firmware/target/arm/tms320dm320/dsp-target.h (revision 17225) +++ firmware/target/arm/tms320dm320/dsp-target.h (working copy) @@ -23,6 +23,21 @@ /* DSP memory is mapped into ARM space via HPIB. */ #define DSP_(addr) (*(volatile unsigned short *)(0x40000 + ((addr) << 1))) +/* A "DSP image" is an array of these, terminated by raw_data_size_half = 0. */ +struct dsp_section { + const unsigned short *raw_data; + unsigned short physical_addr; + unsigned short raw_data_size_half; +}; + +#define HPIB_CTL_DBIO (1 << 10) +#define HPIB_CTL_DHOLD (1 << 9) +#define HPIB_CTL_DRST (1 << 8) +#define HPIB_CTL_DINT0 (1 << 7) +#define HPIB_CTL_EXCHG (1 << 5) +#define HPIB_CTL_HPNMI (1 << 3) +#define HPIB_CTL_HPIEN (1 << 0) + void dsp_init(void); void dsp_wake(void); Index: firmware/target/arm/tms320dm320/spi-target.h =================================================================== --- firmware/target/arm/tms320dm320/spi-target.h (revision 17225) +++ firmware/target/arm/tms320dm320/spi-target.h (working copy) @@ -24,9 +24,13 @@ #include 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, }; Index: firmware/target/arm/tms320dm320/dsp_image_helloworld.h =================================================================== --- firmware/target/arm/tms320dm320/dsp_image_helloworld.h (revision 17225) +++ firmware/target/arm/tms320dm320/dsp_image_helloworld.h (working copy) @@ -19,13 +19,20 @@ * MA 02111-1307 USA * */ +static const unsigned short helloworld_data[] = { +0x4A11, 0x7711, 0x0200, 0x7681, 0xDEAD, 0x6081, 0xDEAD, 0xF820, 0x0021, 0x6081, 0xDEAD, 0xF830, 0x0009, 0xF073, 0x0021, 0x7711, +0x0300, 0xF273, 0x0001, 0x7681, 0x0001, 0x7711, 0x0300, 0xF273, 0x0001, 0x7681, 0x0002, 0x7711, 0x0300, 0xF273, 0x0001, 0x7681, +0x00FF, 0x1181, 0x7711, 0x0001, 0x10F8, 0x000B, 0x08F8, 0x0011, 0xF845, 0x000F, 0x7711, 0x0002, 0x10F8, 0x000B, 0x08F8, 0x0011, +0xF845, 0x0015, 0xF073, 0x001B +}; static const struct dsp_section dsp_image_helloworld[] = { - {NULL, 0, 0} + {helloworld_data, 0x07F80, sizeof(helloworld_data)/sizeof(unsigned short)}, + {NULL, 0, 0} }; /* Symbol table, usable with the DSP_() macro (see dsp-target.h). */ -#define _status 0x0000 -#define _acked 0x0000 +#define _status 0x0200 +#define _acked 0x0300 #endif Index: firmware/target/arm/tms320dm320/crt0.S =================================================================== --- firmware/target/arm/tms320dm320/crt0.S (revision 17225) +++ firmware/target/arm/tms320dm320/crt0.S (working copy) @@ -153,7 +153,7 @@ 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 Index: firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c (revision 0) @@ -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; +} 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,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 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,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); +} + Index: firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c (revision 0) @@ -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; +} 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,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_ */ Index: firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c (revision 0) @@ -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); +} Index: firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c (revision 0) @@ -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; +} Index: firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c (revision 0) @@ -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; +} 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/usb-target.h =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/usb-target.h (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/usb-target.h (revision 0) @@ -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 Index: firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c (revision 0) @@ -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; +} Index: firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c (revision 0) @@ -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; +} Index: firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c (revision 0) +++ firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c (revision 0) @@ -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 */ 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,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 Index: firmware/common/disk.c =================================================================== --- firmware/common/disk.c (revision 17225) +++ firmware/common/disk.c (working copy) @@ -26,6 +26,7 @@ #include "file.h" /* for release_files() */ #endif #include "disk.h" +#include /* Partition table entry layout: ----------------------- @@ -66,8 +67,8 @@ struct partinfo* pinfo = part; #endif - ata_read_sectors(IF_MV2(drive,) 0,1,§or); - + ata_read_sectors(IF_MV2(drive,) 0,1, §or); +#ifndef CREATIVE_ZVM /* check that the boot sector is initialized */ if ( (sector[510] != 0x55) || (sector[511] != 0xaa)) { @@ -90,7 +91,46 @@ /* not handled yet */ } } - +#else + struct partition_struct + { + unsigned int end; + unsigned int start; + char name[8]; + }; + struct hdd_struct + { + unsigned char MBLK[4]; + int sector_size; + long long total_disk_size; + struct partition_struct partitions[4]; + }; + struct hdd_struct* hdd_struct = (struct hdd_struct*)sector; + + if(hdd_struct->MBLK[0] != 0x4B || + hdd_struct->MBLK[1] != 0x4C || + hdd_struct->MBLK[2] != 0x42 || + hdd_struct->MBLK[3] != 0x4D) /* 0x4B4C424D = KLBM */ + { + DEBUGF("Bad boot sector signature\n"); + return NULL; + } + else + { + /* parse partitions */ + for ( i=0; i<4; i++ ) { + if(hdd_struct->partitions[i].name[0] != 0) + { + pinfo[i].type = ( strcmp(hdd_struct->partitions[i].name, "cfs") == 0 ? PARTITION_TYPE_FAT32_LBA : 0); + pinfo[i].start = hdd_struct->partitions[i].start; + pinfo[i].size = (hdd_struct->partitions[i].end - hdd_struct->partitions[i].start); + + DEBUGF("Part%d: Type %02x, start: %08lx size: %08lx\n", + i,pinfo[i].type,pinfo[i].start,pinfo[i].size); + } + } + } +#endif return pinfo; } @@ -147,6 +187,13 @@ { return 0; } +#ifdef CREATIVE_ZVM + /* Speed up loading as there is only one partition on the ZVM */ + if(!fat_mount(IF_MV2(volume,) IF_MV2(drive,) pinfo[1].start)) + return 1; + else + return 0; +#endif #ifdef TOSHIBA_GIGABEAT_S int i = 1; /* For the Gigabeat S, we mount the second partition */ #else Index: firmware/thread.c =================================================================== --- firmware/thread.c (revision 17225) +++ firmware/thread.c (working copy) @@ -802,6 +802,16 @@ ); enable_irq(); } +#elif CONFIG_CPU == DM320 +static inline void core_sleep(void) +{ + asm volatile ( + "mov r0, #0 \n" + "mcr p15, 0, r0, c7, c0, 4 \n" /* Wait for interrupt */ + : : : "r0" + ); + enable_irq(); +} #else static inline void core_sleep(void) { Index: firmware/timer.c =================================================================== --- firmware/timer.c (revision 17225) +++ firmware/timer.c (working copy) @@ -316,7 +316,7 @@ #elif CONFIG_CPU == PNX0101 TIMER1.ctrl &= ~0x80; /* disable timer 1 */ irq_disable_int(IRQ_TIMER1); -#elif CONFIG_CPU == S3C2440 +#elif CONFIG_CPU == S3C2440 || CONFIG_CPU == DM320 __TIMER_UNREGISTER(); #endif pfn_timer = NULL; Index: firmware/usb.c =================================================================== --- firmware/usb.c (revision 17225) +++ firmware/usb.c (working copy) @@ -47,7 +47,8 @@ /* Conditions under which we want the entire driver */ #if !defined(BOOTLOADER) || \ - (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) + (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ + (defined(CREATIVE_ZVM) && defined(HAVE_USBSTACK)) #define USB_FULL_INIT #endif Index: firmware/drivers/rtc/rtc_zenvisionm.c =================================================================== --- firmware/drivers/rtc/rtc_zenvisionm.c (revision 0) +++ firmware/drivers/rtc/rtc_zenvisionm.c (revision 0) @@ -0,0 +1,37 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "i2c-dm320.h" + + #define I2C_ADDRESS 0x51 + + unsigned char* rtc_send_command(short unk1, short unk2) + { + unsigned char ret[12]; + i2c_write(I2C_ADDRESS, (unk2 & 0xFF) | (unk << 8), 1); + i2c_read(I2C_ADDRESS, ret, 12); + return ret; + } + + unsigned char* rtc_read(void) + { + unsigned char ret[12]; + i2c_read(I2C_ADDRESS, ret, 12); + return ret; + } \ No newline at end of file Index: firmware/drivers/fat.c =================================================================== --- firmware/drivers/fat.c (revision 17225) +++ firmware/drivers/fat.c (working copy) @@ -32,6 +32,9 @@ #include "logf.h" #include "atoi.h" +#define logf +#define LDEBUGF + #define BYTES2INT16(array,pos) \ (array[pos] | (array[pos+1] << 8 )) #define BYTES2INT32(array,pos) \ Index: firmware/drivers/isp1583.c =================================================================== --- firmware/drivers/isp1583.c (revision 0) +++ firmware/drivers/isp1583.c (revision 0) @@ -0,0 +1,741 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Tomasz Malesinski + * 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_ch9.h" +#include "usb_drv.h" +#include "usb_core.h" +#include "isp1583.h" +#include "thread.h" + +#define printf +#define logf printf + +#define DIR_RX 0 +#define DIR_TX 1 + +#define DIR_OUT 0 +#define DIR_IN 1 + +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]; + short type; +}; + +static unsigned char setup_pkt_buf[8]; +static struct usb_endpoint endpoints[NUM_ENDPOINTS]; + +static bool high_speed_mode = false; + +static inline void or_int_value(volatile unsigned short *a, volatile unsigned short *b, unsigned long r, unsigned long value) +{ + set_int_value(*a, *b, (r | value)); +} +static inline void bc_int_value(volatile unsigned short *a, volatile unsigned short *b, unsigned long r, unsigned long value) +{ + set_int_value(*a, *b, (r & ~value)); +} + +static inline void nop_f(void) +{ + yield(); +} + +#define NOP asm volatile("nop\n"); + +static inline int ep_index(int n, bool dir) +{ + return (n << 1) | dir; +} + +static inline bool epidx_dir(int idx) +{ + return idx & 1; +} + +static inline int epidx_n(int idx) +{ + return idx >> 1; +} + +static inline void usb_select_endpoint(int idx) +{ + /* Select the endpoint */ + ISP1583_DFLOW_EPINDEX = idx; + /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns. + * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns. + */ + NOP; +} + +static inline void usb_select_setup_endpoint(void) +{ + /* Select the endpoint */ + ISP1583_DFLOW_EPINDEX = DFLOW_EPINDEX_EP0SETUP; + /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns. + * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns. + */ + NOP; +} + +static void usb_setup_endpoint(int idx, int max_pkt_size, int type) +{ + if(epidx_n(idx)!=0) + { + usb_select_endpoint(idx); + ISP1583_DFLOW_MAXPKSZ = max_pkt_size & 0x7FF; + ISP1583_DFLOW_EPTYPE = (DFLOW_EPTYPE_NOEMPKT | DFLOW_EPTYPE_DBLBUF | (type & 0x3)); + + /* clear buffer ... */ + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF; + /* ... twice because of double buffering */ + usb_select_endpoint(idx); + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF; + } + + struct usb_endpoint *ep; + ep = &(endpoints[epidx_n(idx)]); + ep->halt[epidx_dir(idx)] = 0; + ep->enabled[epidx_dir(idx)] = 0; + ep->out_in_progress = 0; + ep->in_min_len = -1; + ep->in_ack = 0; + ep->type = type; + ep->max_pkt_size[epidx_dir(idx)] = max_pkt_size; +} + +static void usb_enable_endpoint(int idx) +{ + if(epidx_n(idx)!=0) + { + usb_select_endpoint(idx); + /* Enable interrupt */ + or_int_value(&ISP1583_INIT_INTEN_A, &ISP1583_INIT_INTEN_B, ISP1583_INIT_INTEN_READ, 1 << (10 + idx)); + /* Enable endpoint */ + ISP1583_DFLOW_EPTYPE |= DFLOW_EPTYPE_ENABLE; + } + + endpoints[epidx_n(idx)].enabled[epidx_dir(idx)] = 1; +} + +static void usb_disable_endpoint(int idx, bool set_struct) +{ + usb_select_endpoint(idx); + ISP1583_DFLOW_EPTYPE &= ~DFLOW_EPTYPE_ENABLE; + bc_int_value(&ISP1583_INIT_INTEN_A, &ISP1583_INIT_INTEN_B, ISP1583_INIT_INTEN_READ, 1 << (10 + idx)); + + if(set_struct) + endpoints[epidx_n(idx)].enabled[epidx_dir(idx)] = 0; +} + +static int usb_get_packet(unsigned char *buf, int max_len) +{ + int len, i; + len = ISP1583_DFLOW_BUFLEN; + + if (max_len < 0 || max_len > len) + max_len = len; + + i = 0; + while (i < len) + { + unsigned short d = ISP1583_DFLOW_DATA; + if (i < max_len) + buf[i] = d & 0xff; + i++; + if (i < max_len) + buf[i] = (d >> 8) & 0xff; + i++; + } + return max_len; +} + +static int usb_receive(int n) +{ + logf("usb_receive(%d)", n); + int len; + + if (endpoints[n].halt[DIR_RX] + || !endpoints[n].enabled[DIR_RX] + || endpoints[n].in_min_len < 0 + || !endpoints[n].in_ack) + return -1; + + endpoints[n].in_ack = 0; + + usb_select_endpoint(ep_index(n, DIR_RX)); + + len = usb_get_packet(endpoints[n].in_buf + endpoints[n].in_ptr, + endpoints[n].in_max_len - endpoints[n].in_ptr); + endpoints[n].in_ptr += len; + if (endpoints[n].in_ptr >= endpoints[n].in_min_len) { + endpoints[n].in_min_len = -1; + if (endpoints[n].in_done) + (*(endpoints[n].in_done))(n, endpoints[n].in_buf, + endpoints[n].in_ptr); + } + logf("receive_end"); + return 0; +} + +static bool usb_out_buffer_full(int ep) +{ + usb_select_endpoint(ep_index(ep, DIR_TX)); + if (ISP1583_DFLOW_EPTYPE & 4) /* Check if type=bulk and double buffering is set */ + return (ISP1583_DFLOW_BUFSTAT & 3) == 3; /* Return true if both buffers are filled */ + else + return (ISP1583_DFLOW_BUFSTAT & 3) != 0; /* Return true if one of the buffers are filled */ +} + +static int usb_send(int n) +{ + logf("usb_send(%d)", n); + int max_pkt_size, len; + int i; + unsigned char *p; + + if (endpoints[n].halt[DIR_TX] + || !endpoints[n].enabled[DIR_TX] + || !endpoints[n].out_in_progress) + { + logf("NOT SEND TO EP!"); + return -1; + } + + if (endpoints[n].out_ptr < 0) + { + endpoints[n].out_in_progress = 0; + if (endpoints[n].out_done) + (*(endpoints[n].out_done))(n, endpoints[n].out_buf, + endpoints[n].out_len); + logf("ALREADY SENT TO EP!"); + return -1; + } + + if (usb_out_buffer_full(n)) + { + logf("BUFFER FULL!"); + return -1; + } + + usb_select_endpoint(ep_index(n, DIR_TX)); + max_pkt_size = endpoints[n].max_pkt_size[DIR_TX]; + len = endpoints[n].out_len - endpoints[n].out_ptr; + if (len > max_pkt_size) + len = max_pkt_size; + + if(len < max_pkt_size) + ISP1583_DFLOW_BUFLEN = len; + + p = endpoints[n].out_buf + endpoints[n].out_ptr; + i = 0; + while (len - i >= 2) { + ISP1583_DFLOW_DATA = p[i] | (p[i + 1] << 8); + i += 2; + } + if (i < len) + ISP1583_DFLOW_DATA = p[i]; + + endpoints[n].out_ptr += len; + +/* + if (endpoints[n].out_ptr == endpoints[n].out_len + && len < max_pkt_size) +*/ + if (endpoints[n].out_ptr == endpoints[n].out_len) + endpoints[n].out_ptr = -1; + + logf("send_end"); + return 0; +} + +static void usb_stall_endpoint(int idx) +{ + usb_select_endpoint(idx); + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STALL; + endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 1; +} + +static void usb_unstall_endpoint(int idx) +{ + usb_select_endpoint(idx); + ISP1583_DFLOW_CTRLFUN &= ~DFLOW_CTRLFUN_STALL; + ISP1583_DFLOW_EPTYPE &= ~DFLOW_EPTYPE_ENABLE; + ISP1583_DFLOW_EPTYPE |= DFLOW_EPTYPE_ENABLE; + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF; + if (epidx_dir(idx) == DIR_TX) + endpoints[epidx_n(idx)].out_in_progress = 0; + else + { + endpoints[epidx_n(idx)].in_min_len = -1; + endpoints[epidx_n(idx)].in_ack = 0; + } + endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 0; +} + +static void usb_status_ack(int ep, int dir) +{ + logf("usb_status_ack(%d)", dir); + usb_select_endpoint(ep_index(ep, dir)); + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STATUS; +} + +static void usb_data_stage_enable(int ep, int dir) +{ + logf("usb_data_stage_enable(%d)", dir); + usb_select_endpoint(ep_index(ep, dir)); + ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_DSEN; +} + +static void usb_handle_setup_rx(void) +{ + int len; + usb_select_setup_endpoint(); + len = usb_get_packet(setup_pkt_buf, 8); + + if (len == 8) + usb_core_control_request((struct usb_ctrlrequest*)setup_pkt_buf); + else + { + usb_drv_stall(0, true, false); + usb_drv_stall(0, true, true); + logf("usb_handle_setup_rx() failed"); + return; + } + + logf("usb_handle_setup_rx(): %02x %02x %02x %02x %02x %02x %02x %02x", setup_pkt_buf[0], setup_pkt_buf[1], setup_pkt_buf[2], setup_pkt_buf[3], setup_pkt_buf[4], setup_pkt_buf[5], setup_pkt_buf[6], setup_pkt_buf[7]); +} + +static void usb_handle_data_int(int ep, int dir) +{ + int len; + if (dir == DIR_TX) + len = usb_send(ep); + else + { + len = usb_receive(ep); + endpoints[ep].in_ack = 1; + } + logf("usb_handle_data_int(%d, %d) finished", ep, dir); +} + +bool usb_drv_powered(void) +{ +#if 0 + return (ISP1583_INIT_OTG & INIT_OTG_BSESS_VALID) ? true : false; +#else + return (ISP1583_INIT_MODE & INIT_MODE_VBUSSTAT) ? true : false; +#endif +} + +static void setup_endpoints(void) +{ + usb_setup_endpoint(ep_index(0, DIR_RX), 64, 0); + usb_setup_endpoint(ep_index(0, DIR_TX), 64, 0); + + int i; + for(i = 1; i < NUM_ENDPOINTS-1; i++) + { + usb_setup_endpoint(ep_index(i, DIR_RX), (high_speed_mode ? 512 : 64), 2); /* 2 = TYPE_BULK */ + usb_setup_endpoint(ep_index(i, DIR_TX), (high_speed_mode ? 512 : 64), 2); + } + + usb_enable_endpoint(ep_index(0, DIR_RX)); + usb_enable_endpoint(ep_index(0, DIR_TX)); + + for (i = 1; i < NUM_ENDPOINTS-1; i++) + { + usb_enable_endpoint(ep_index(i, DIR_RX)); + usb_enable_endpoint(ep_index(i, DIR_TX)); + } + + ZVM_SPECIFIC; +} + +void usb_helper(void) +{ + if(ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ) + { + #ifdef DEBUG + //logf("Helper detected interrupt... [%d]", current_tick); + #endif + usb_drv_int(); + } + return; +} + +void usb_drv_init(void) +{ + /* Disable interrupt at CPU level */ + DIS_INT_CPU_TARGET; + + /* Unlock the device's registers */ + ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE; + + /* Soft reset the device */ + ISP1583_INIT_MODE = INIT_MODE_SFRESET; + sleep(10); + /* Enable CLKAON & GLINTENA */ + ISP1583_INIT_MODE = STANDARD_INIT_MODE; + + /* Disable all OTG functions */ + ISP1583_INIT_OTG = 0; + +#if 0 + #ifdef USE_HIGH_SPEED + /* Force device to high speed */ + ISP1583_GEN_TSTMOD = GEN_TSTMOD_FORCEHS; + high_speed_mode = true; + #endif +#endif + + #ifdef DEBUG + logf("BUS_CONF/DA0:%d MODE0/DA1: %d MODE1: %d", (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST0), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST1), (bool)(ISP1583_INIT_MODE & INIT_MODE_TEST2)); + logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID); + //logf("INV0: 0x% IRQEDGE: 0x%x IRQPORT: 0x%x", IO_GIO_INV0, IO_GIO_IRQEDGE, IO_GIO_IRQPORT); + #endif + + /*Set interrupt generation to target-specific mode + + * Set the control pipe to ACK only interrupt + + * Set the IN pipe to ACK only interrupt + + * Set OUT pipe to ACK and NYET interrupt + */ + + ISP1583_INIT_INTCONF = 0x54 | INT_CONF_TARGET; + /* Clear all interrupts */ + set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, 0xFFFFFFFF); + /* Enable USB interrupts */ + set_int_value(ISP1583_INIT_INTEN_A, ISP1583_INIT_INTEN_B, STANDARD_INTEN); + + ZVM_SPECIFIC; + + /* Enable interrupt at CPU level */ + EN_INT_CPU_TARGET; + + setup_endpoints(); + + /* Clear device address and disable it */ + ISP1583_INIT_ADDRESS = 0; + + /* Turn SoftConnect on */ + ISP1583_INIT_MODE |= INIT_MODE_SOFTCT; + + ZVM_SPECIFIC; + + tick_add_task(usb_helper); + + logf("usb_init_device() finished"); +} + +int usb_drv_port_speed(void) +{ + return (int)high_speed_mode; +} + +void usb_drv_exit(void) +{ + logf("usb_drv_exit()"); + + /* Disable device */ + ISP1583_INIT_MODE &= ~INIT_MODE_SOFTCT; + ISP1583_INIT_ADDRESS = 0; + + /* Disable interrupts */ + set_int_value(ISP1583_INIT_INTEN_A, ISP1583_INIT_INTEN_B, 0); + /* and the CPU's one... */ + DIS_INT_CPU_TARGET; + + + /* Send usb controller to suspend mode */ + ISP1583_INIT_MODE = INIT_MODE_GOSUSP; + ISP1583_INIT_MODE = 0; + + tick_remove_task(usb_helper); + + ZVM_SPECIFIC; +} + +void usb_drv_stall(int endpoint, bool stall, bool in) +{ + logf("%sstall EP%d %s", (stall ? "" : "un"), endpoint, (in ? "RX" : "TX" )); + if (stall) + usb_stall_endpoint(ep_index(endpoint, (int)in)); + else + usb_unstall_endpoint(ep_index(endpoint, (int)in)); +} + +bool usb_drv_stalled(int endpoint, bool in) +{ + return (endpoints[endpoint].halt[(int)in] == 1); +} + +static void out_callback(int ep, unsigned char *buf, int len) +{ + (void)buf; + logf("out_callback(%d, 0x%x, %d)", ep, &buf, len); + usb_status_ack(ep, DIR_RX); + usb_core_transfer_complete(ep, true, 0, len); /* 0=>status succeeded, haven't worked out status failed yet... */ +} + +static void in_callback(int ep, unsigned char *buf, int len) +{ + (void)buf; + logf("in_callback(%d, 0x%x, %d)", ep, &buf, len); + usb_status_ack(ep, DIR_TX); + usb_core_transfer_complete(ep, false, 0, len); +} + +int usb_drv_recv(int ep, void* ptr, int length) +{ + logf("usb_drv_recv(%d, 0x%x, %d)", ep, &ptr, length); + if(ep == 0 && length == 0 && ptr == NULL) + { + usb_status_ack(ep, DIR_TX); + return 0; + } + endpoints[ep].in_done = in_callback; + endpoints[ep].in_buf = ptr; + endpoints[ep].in_max_len = length; + endpoints[ep].in_min_len = length; + endpoints[ep].in_ptr = 0; + if(ep == 0) + { + usb_data_stage_enable(ep, DIR_RX); + return usb_receive(ep); + } + else + return usb_receive(ep); +} + +int usb_drv_send_nonblocking(int ep, void* ptr, int length) +{ + /* First implement DMA... */ + return usb_drv_send(ep, ptr, length); +} + +int usb_drv_send(int ep, void* ptr, int length) +{ + logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, &ptr, length); + if(ep == 0 && length == 0 && ptr == NULL) + { + usb_status_ack(ep, DIR_RX); + return 0; + } + if(endpoints[ep].out_in_progress == 1) + return -1; + endpoints[ep].out_done = out_callback; + endpoints[ep].out_buf = ptr; + endpoints[ep].out_len = length; + endpoints[ep].out_ptr = 0; + endpoints[ep].out_in_progress = 1; + if(ep == 0) + { + int rc = usb_send(ep); + usb_data_stage_enable(ep, DIR_TX); + usb_drv_wait(ep, DIR_TX); + return rc; + } + else + return usb_send(ep); +} + +void usb_drv_reset_endpoint(int ep, bool send) +{ + logf("reset endpoint(%d, %d)", ep, send); + usb_setup_endpoint(ep_index(ep, (int)send), endpoints[ep].max_pkt_size[(int)send], endpoints[ep].type); + usb_enable_endpoint(ep_index(ep, (int)send)); +} + +void usb_drv_wait(int ep, bool send) +{ + logf("usb_drv_wait(%d, %d)", ep, send); + if(send) + { + while (endpoints[ep].out_in_progress) + nop_f(); + } + else + { + while (endpoints[ep].in_ack) + nop_f(); + } +} + +void usb_drv_cancel_all_transfers(void) +{ + logf("usb_drv_cancel_all_tranfers()"); + int i; + + for(i=0;idone"); +} + +/* Method for handling interrupts, must be called from usb-.c */ +void usb_drv_int(void) +{ + unsigned long ints; + ints = ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ; + + if(!ints) + return; + + /* Unlock the device's registers */ + ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE; + + #if 0 + logf(" handling int [0x%x & 0x%x = 0x%x]", ISP1583_GEN_INT_READ, ISP1583_INIT_INTEN_READ, ints); + #endif + + if(ints & INT_IEBRST) /* Bus reset */ + { + logf("BRESET"); + high_speed_mode = false; + bus_reset(); + usb_core_bus_reset(); + /* Mask bus reset interrupt */ + set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, INT_IEBRST); + return; + } + if(ints & INT_IEP0SETUP) /* EP0SETUP interrupt */ + { + logf("EP0SETUP"); + usb_handle_setup_rx(); + } + if(ints & INT_IEHS_STA) /* change from full-speed to high-speed mode -> endpoints need to get reconfigured!! */ + { + logf("HS_STA"); + high_speed_mode = true; + setup_endpoints(); + } + if(ints & INT_EP_MASK) /* Endpoints interrupt */ + { + unsigned long ep_event; + unsigned short i = 10; + ep_event = ints & INT_EP_MASK; + while(ep_event) + { + if(i>25) + break; + + if(ep_event & (1 << i)) + { + logf("EP%d %s interrupt", (i - 10) / 2, i % 2 ? "RX" : "TX"); + usb_handle_data_int((i - 10) / 2, i % 2); + ep_event &= ~(1 << i); + } + i++; + } + } + if(ints & INT_IERESM && !(ints & INT_IESUSP)) /* Resume status: status change from suspend to resume (active) */ + { + logf("RESM"); + } + if(ints & INT_IESUSP && !(ints & INT_IERESM)) /* Suspend status: status change from active to suspend */ + { + logf("SUSP"); + } + if(ints & INT_IEDMA) /* change in the DMA Interrupt Reason register */ + { + logf("DMA"); + } + if(ints & INT_IEVBUS) /* transition from LOW to HIGH on VBUS */ + { + logf("VBUS"); + } + /* Mask all (enabled) interrupts */ + set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, ints); + + ZVM_SPECIFIC; +} + +void usb_drv_set_address(int address) +{ + logf("usb_drv_set_address(0x%x)", address); + ISP1583_INIT_ADDRESS = (address & 0x7F) | INIT_ADDRESS_DEVEN; + + ZVM_SPECIFIC; + + usb_status_ack(0, DIR_TX); +} + +void usb_drv_set_test_mode(int mode) +{ + logf("usb_drv_set_test_mode(%d)", mode); + switch(mode){ + case 0: + ISP1583_GEN_TSTMOD = 0; + /* Power cycle... */ + break; + case 1: + ISP1583_GEN_TSTMOD = GEN_TSTMOD_JSTATE; + break; + case 2: + ISP1583_GEN_TSTMOD = GEN_TSTMOD_KSTATE; + break; + case 3: + ISP1583_GEN_TSTMOD = GEN_TSTMOD_SE0_NAK; + break; + case 4: + //REG_PORTSC1 |= PORTSCX_PTC_PACKET; + break; + case 5: + //REG_PORTSC1 |= PORTSCX_PTC_FORCE_EN; + break; + } +}