summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-04-24 20:08:28 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-04-24 20:08:28 +0000
commit95167e01773dcfe8e5c1b356cfa1ea4b3a55441b (patch)
tree8b5312c5f1d1ecc8231bf8e14a1eb1678474bf8a
parent46b492861152af9b91d3ab65ef0e5e14c876c3fc (diff)
downloadrockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.tar.gz
rockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.zip
Commit whole Creative Zen Vision:M target tree + all related firmware/
changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17241 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES2
-rw-r--r--apps/keymaps/keymap-creativezvm.c185
-rw-r--r--firmware/SOURCES39
-rw-r--r--firmware/common/disk.c48
-rw-r--r--firmware/drivers/isp1583.c741
-rw-r--r--firmware/drivers/rtc/rtc_zenvisionm.c37
-rw-r--r--firmware/export/config-creativezvm.h60
-rw-r--r--firmware/export/config.h7
-rw-r--r--firmware/export/dm320.h5
-rw-r--r--firmware/export/isp1583.h185
-rw-r--r--firmware/kernel.c5
-rw-r--r--firmware/panic.c2
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c32
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/adc-target.h38
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c101
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-target.h68
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c44
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h31
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/button-target.h57
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c405
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h28
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c81
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c323
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c68
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c57
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c65
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/usb-target.h76
-rwxr-xr-xfirmware/target/arm/tms320dm320/crt0.S2
-rwxr-xr-xfirmware/target/arm/tms320dm320/debug-dm320.c70
-rw-r--r--firmware/target/arm/tms320dm320/kernel-dm320.c15
-rw-r--r--firmware/target/arm/tms320dm320/spi-dm320.c23
-rw-r--r--firmware/target/arm/tms320dm320/spi-target.h4
-rw-r--r--firmware/target/arm/tms320dm320/system-dm320.c56
-rw-r--r--firmware/target/arm/tms320dm320/timer-dm320.c20
-rw-r--r--firmware/target/arm/tms320dm320/uart-dm320.c8
-rw-r--r--firmware/thread.c10
-rw-r--r--firmware/timer.c2
-rw-r--r--firmware/usb.c3
-rw-r--r--firmware/usbstack/usb_storage.c2
-rwxr-xr-xtools/configure4
-rw-r--r--tools/scramble.c6
41 files changed, 2940 insertions, 75 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 40aa022842..4d47328108 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -178,4 +178,6 @@ keymaps/keymap-mr500.c
178keymaps/keymap-mr100.c 178keymaps/keymap-mr100.c
179#elif CONFIG_KEYPAD == COWOND2_PAD 179#elif CONFIG_KEYPAD == COWOND2_PAD
180keymaps/keymap-cowond2.c 180keymaps/keymap-cowond2.c
181#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
182keymaps/keymap-creativezvm.c
181#endif 183#endif
diff --git a/apps/keymaps/keymap-creativezvm.c b/apps/keymaps/keymap-creativezvm.c
new file mode 100644
index 0000000000..221830e15e
--- /dev/null
+++ b/apps/keymaps/keymap-creativezvm.c
@@ -0,0 +1,185 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/* Button Code Definitions for the Creative Zen Vision:M target */
21#include <stdio.h>
22#include <string.h>
23#include <stdlib.h>
24
25#include "config.h"
26#include "action.h"
27#include "button.h"
28#include "settings.h"
29
30/*
31 * The format of the list is as follows
32 * { Action Code, Button code, Prereq button code }
33 * if there's no need to check the previous button's value, use BUTTON_NONE
34 * Insert LAST_ITEM_IN_LIST at the end of each mapping
35 */
36
37/* CONTEXT_CUSTOM's used in this file...
38
39CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions)
40CONTEXT_CUSTOM|CONTEXT_SETTINGS = the direction keys for the eq/col picker screens
41 i.e where up/down is inc/dec
42 CONTEXT_SETTINGS = up/down is prev/next, l/r is inc/dec
43
44*/
45
46#define BUTTON_VOL_UP BUTTON_NONE
47#define BUTTON_VOL_DOWN BUTTON_NONE
48
49static const struct button_mapping button_context_standard[] = {
50 { ACTION_STD_PREV, BUTTON_UP|BUTTON_REL, BUTTON_NONE },
51 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
52 { ACTION_STD_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE },
53 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
54
55 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
56 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
57
58 { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT,BUTTON_SELECT },
59
60 { ACTION_STD_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
61 { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
62
63 { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
64 { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
65
66 LAST_ITEM_IN_LIST
67}; /* button_context_standard */
68
69
70static const struct button_mapping button_context_wps[] = {
71 LAST_ITEM_IN_LIST
72}; /* button_context_wps */
73
74static const struct button_mapping button_context_list[] = {
75 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
76}; /* button_context_list */
77
78static const struct button_mapping button_context_tree[] = {
79 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
80}; /* button_context_tree */
81
82static const struct button_mapping button_context_listtree_scroll_with_combo[] = {
83 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
84};
85
86static const struct button_mapping button_context_listtree_scroll_without_combo[] = {
87 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
88};
89
90static const struct button_mapping button_context_settings[] = {
91 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
92 { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP },
93 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
94 { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
95 { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE },
96 { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
97 { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
98 { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT },
99 { ACTION_SETTINGS_RESET, BUTTON_PLAY, BUTTON_NONE },
100
101 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
102}; /* button_context_settings */
103
104static const struct button_mapping button_context_settings_right_is_inc[] = {
105
106 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
107}; /* button_context_settingsgraphical */
108
109static const struct button_mapping button_context_yesno[] = {
110 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
111}; /* button_context_settings_yesno */
112
113static const struct button_mapping button_context_colorchooser[] = {
114 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
115}; /* button_context_colorchooser */
116
117static const struct button_mapping button_context_eq[] = {
118 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
119}; /* button_context_eq */
120
121/** Bookmark Screen **/
122static const struct button_mapping button_context_bmark[] = {
123 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
124}; /* button_context_bmark */
125
126static const struct button_mapping button_context_time[] = {
127 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
128}; /* button_context_time */
129
130static const struct button_mapping button_context_quickscreen[] = {
131
132 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
133}; /* button_context_quickscreen */
134
135static const struct button_mapping button_context_pitchscreen[] = {
136
137 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
138}; /* button_context_pitchcreen */
139
140static const struct button_mapping button_context_keyboard[] = {
141
142 LAST_ITEM_IN_LIST
143}; /* button_context_keyboard */
144
145const struct button_mapping* get_context_mapping(int context)
146{
147 switch (context&~CONTEXT_REMOTE)
148 {
149 case CONTEXT_STD:
150 return button_context_standard;
151 case CONTEXT_WPS:
152 return button_context_wps;
153 case CONTEXT_LIST:
154 return button_context_list;
155 case CONTEXT_MAINMENU:
156 case CONTEXT_TREE:
157 if (global_settings.hold_lr_for_scroll_in_list)
158 return button_context_listtree_scroll_without_combo;
159 else
160 return button_context_listtree_scroll_with_combo;
161 case CONTEXT_CUSTOM|CONTEXT_TREE:
162 return button_context_tree;
163 case CONTEXT_SETTINGS:
164 return button_context_settings;
165 case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
166 return button_context_settings_right_is_inc;
167 case CONTEXT_SETTINGS_COLOURCHOOSER:
168 return button_context_colorchooser;
169 case CONTEXT_SETTINGS_EQ:
170 return button_context_eq;
171 case CONTEXT_SETTINGS_TIME:
172 return button_context_time;
173 case CONTEXT_YESNOSCREEN:
174 return button_context_yesno;
175 case CONTEXT_BOOKMARKSCREEN:
176 return button_context_bmark;
177 case CONTEXT_QUICKSCREEN:
178 return button_context_quickscreen;
179 case CONTEXT_PITCHSCREEN:
180 return button_context_pitchscreen;
181 case CONTEXT_KEYBOARD:
182 return button_context_keyboard;
183 }
184 return button_context_standard;
185}
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 0acfdd5bf9..ac9ac46212 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -237,10 +237,12 @@ usbstack/usb_storage.c
237usbstack/usb_serial.c 237usbstack/usb_serial.c
238#if CONFIG_USBOTG == USBOTG_ARC 238#if CONFIG_USBOTG == USBOTG_ARC
239target/arm/usb-drv-arc.c 239target/arm/usb-drv-arc.c
240#elif CONFIG_USBOTG == USBOTG_ISP1583
241drivers/isp1583.c
240#endif 242#endif
241#else /* !defined(HAVE_USBSTACK) */ 243#else /* !defined(HAVE_USBSTACK) */
242#if CONFIG_USBOTG == USBOTG_ISP1362 244#if CONFIG_USBOTG == USBOTG_ISP1362
243drivers/isp1362.c 245drivers/isp1362.c
244#elif CONFIG_USBOTG == USBOTG_M5636 246#elif CONFIG_USBOTG == USBOTG_M5636
245drivers/m5636.c 247drivers/m5636.c
246#endif 248#endif
@@ -672,6 +674,17 @@ target/arm/imx31/gigabeat-s/pcm-imx31.c
672#endif /* SIMULATOR */ 674#endif /* SIMULATOR */
673#endif /* GIGABEAT_S */ 675#endif /* GIGABEAT_S */
674 676
677#if CONFIG_CPU == DM320
678target/arm/tms320dm320/debug-dm320.c
679target/arm/tms320dm320/dsp-dm320.c
680target/arm/tms320dm320/i2c-dm320.c
681target/arm/tms320dm320/kernel-dm320.c
682target/arm/tms320dm320/spi-dm320.c
683target/arm/tms320dm320/system-dm320.c
684target/arm/tms320dm320/timer-dm320.c
685target/arm/tms320dm320/uart-dm320.c
686#endif /* CONFIG_CPU == DM320 */
687
675#ifdef MROBE_500 688#ifdef MROBE_500
676#ifndef SIMULATOR 689#ifndef SIMULATOR
677target/arm/lcd-as-memframe.S 690target/arm/lcd-as-memframe.S
@@ -689,17 +702,25 @@ target/arm/tms320dm320/mrobe-500/pcm-mr500.c
689target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c 702target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
690target/arm/tms320dm320/mrobe-500/power-mr500.c 703target/arm/tms320dm320/mrobe-500/power-mr500.c
691target/arm/tms320dm320/mrobe-500/usb-mr500.c 704target/arm/tms320dm320/mrobe-500/usb-mr500.c
692target/arm/tms320dm320/debug-dm320.c
693target/arm/tms320dm320/i2c-dm320.c
694target/arm/tms320dm320/kernel-dm320.c
695target/arm/tms320dm320/spi-dm320.c
696target/arm/tms320dm320/system-dm320.c
697target/arm/tms320dm320/timer-dm320.c
698target/arm/tms320dm320/uart-dm320.c
699target/arm/tms320dm320/dsp-dm320.c
700#endif /* SIMULATOR */ 705#endif /* SIMULATOR */
701#endif /* MROBE_500 */ 706#endif /* MROBE_500 */
702 707
708#ifdef CREATIVE_ZVM
709#ifndef SIMULATOR
710target/arm/lcd-as-memframe.S
711target/arm/mmu-arm.c
712target/arm/tms320dm320/creative-zvm/adc-creativezvm.c
713target/arm/tms320dm320/creative-zvm/audio-creativezvm.c
714target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
715target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
716target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c
717target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
718target/arm/tms320dm320/creative-zvm/power-creativezvm.c
719target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
720target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
721#endif /* SIMULATOR */
722#endif /* CREATIVE_ZVM */
723
703#ifdef MROBE_100 724#ifdef MROBE_100
704#ifndef SIMULATOR 725#ifndef SIMULATOR
705drivers/sw_i2c.c 726drivers/sw_i2c.c
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index d4cfbc1a05..a81d57dd01 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -26,6 +26,7 @@
26#include "file.h" /* for release_files() */ 26#include "file.h" /* for release_files() */
27#endif 27#endif
28#include "disk.h" 28#include "disk.h"
29#include <string.h>
29 30
30/* Partition table entry layout: 31/* Partition table entry layout:
31 ----------------------- 32 -----------------------
@@ -66,8 +67,8 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
66 struct partinfo* pinfo = part; 67 struct partinfo* pinfo = part;
67#endif 68#endif
68 69
69 ata_read_sectors(IF_MV2(drive,) 0,1,&sector); 70 ata_read_sectors(IF_MV2(drive,) 0,1, &sector);
70 71#ifndef CREATIVE_ZVM
71 /* check that the boot sector is initialized */ 72 /* check that the boot sector is initialized */
72 if ( (sector[510] != 0x55) || 73 if ( (sector[510] != 0x55) ||
73 (sector[511] != 0xaa)) { 74 (sector[511] != 0xaa)) {
@@ -90,7 +91,46 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
90 /* not handled yet */ 91 /* not handled yet */
91 } 92 }
92 } 93 }
93 94#else
95 struct partition_struct
96 {
97 unsigned int end;
98 unsigned int start;
99 char name[8];
100 };
101 struct hdd_struct
102 {
103 unsigned char MBLK[4];
104 int sector_size;
105 long long total_disk_size;
106 struct partition_struct partitions[4];
107 };
108 struct hdd_struct* hdd_struct = (struct hdd_struct*)sector;
109
110 if(hdd_struct->MBLK[0] != 0x4B ||
111 hdd_struct->MBLK[1] != 0x4C ||
112 hdd_struct->MBLK[2] != 0x42 ||
113 hdd_struct->MBLK[3] != 0x4D) /* 0x4B4C424D = KLBM */
114 {
115 DEBUGF("Bad boot sector signature\n");
116 return NULL;
117 }
118 else
119 {
120 /* parse partitions */
121 for ( i=0; i<4; i++ ) {
122 if(hdd_struct->partitions[i].name[0] != 0)
123 {
124 pinfo[i].type = ( strcmp(hdd_struct->partitions[i].name, "cfs") == 0 ? PARTITION_TYPE_FAT32_LBA : 0);
125 pinfo[i].start = hdd_struct->partitions[i].start;
126 pinfo[i].size = (hdd_struct->partitions[i].end - hdd_struct->partitions[i].start);
127
128 DEBUGF("Part%d: Type %02x, start: %08lx size: %08lx\n",
129 i,pinfo[i].type,pinfo[i].start,pinfo[i].size);
130 }
131 }
132 }
133#endif
94 return pinfo; 134 return pinfo;
95} 135}
96 136
@@ -147,7 +187,7 @@ int disk_mount(int drive)
147 { 187 {
148 return 0; 188 return 0;
149 } 189 }
150#ifdef TOSHIBA_GIGABEAT_S 190#if defined(TOSHIBA_GIGABEAT_S) ||defined(CREATIVE_ZVM)
151 int i = 1; /* For the Gigabeat S, we mount the second partition */ 191 int i = 1; /* For the Gigabeat S, we mount the second partition */
152#else 192#else
153 int i = 0; 193 int i = 0;
diff --git a/firmware/drivers/isp1583.c b/firmware/drivers/isp1583.c
new file mode 100644
index 0000000000..8cc440dc4c
--- /dev/null
+++ b/firmware/drivers/isp1583.c
@@ -0,0 +1,741 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Tomasz Malesinski
11 * Copyright (C) 2008 by Maurus Cuelenaere
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "usb-target.h"
23#include "usb_ch9.h"
24#include "usb_drv.h"
25#include "usb_core.h"
26#include "isp1583.h"
27#include "thread.h"
28
29#define printf
30#define logf printf
31
32#define DIR_RX 0
33#define DIR_TX 1
34
35#define DIR_OUT 0
36#define DIR_IN 1
37
38struct usb_endpoint
39{
40 unsigned char *out_buf;
41 short out_len;
42 short out_ptr;
43 void (*out_done)(int, unsigned char *, int);
44 unsigned char out_in_progress;
45
46 unsigned char *in_buf;
47 short in_min_len;
48 short in_max_len;
49 short in_ptr;
50 void (*in_done)(int, unsigned char *, int);
51 unsigned char in_ack;
52
53 unsigned char halt[2];
54 unsigned char enabled[2];
55 short max_pkt_size[2];
56 short type;
57};
58
59static unsigned char setup_pkt_buf[8];
60static struct usb_endpoint endpoints[NUM_ENDPOINTS];
61
62static bool high_speed_mode = false;
63
64static inline void or_int_value(volatile unsigned short *a, volatile unsigned short *b, unsigned long r, unsigned long value)
65{
66 set_int_value(*a, *b, (r | value));
67}
68static inline void bc_int_value(volatile unsigned short *a, volatile unsigned short *b, unsigned long r, unsigned long value)
69{
70 set_int_value(*a, *b, (r & ~value));
71}
72
73static inline void nop_f(void)
74{
75 yield();
76}
77
78#define NOP asm volatile("nop\n");
79
80static inline int ep_index(int n, bool dir)
81{
82 return (n << 1) | dir;
83}
84
85static inline bool epidx_dir(int idx)
86{
87 return idx & 1;
88}
89
90static inline int epidx_n(int idx)
91{
92 return idx >> 1;
93}
94
95static inline void usb_select_endpoint(int idx)
96{
97 /* Select the endpoint */
98 ISP1583_DFLOW_EPINDEX = idx;
99 /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns.
100 * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns.
101 */
102 NOP;
103}
104
105static inline void usb_select_setup_endpoint(void)
106{
107 /* Select the endpoint */
108 ISP1583_DFLOW_EPINDEX = DFLOW_EPINDEX_EP0SETUP;
109 /* The delay time from the Write Endpoint Index register to the Read Data Port register must be at least 190 ns.
110 * The delay time from the Write Endpoint Index register to the Write Data Port register must be at least 100 ns.
111 */
112 NOP;
113}
114
115static void usb_setup_endpoint(int idx, int max_pkt_size, int type)
116{
117 if(epidx_n(idx)!=0)
118 {
119 usb_select_endpoint(idx);
120 ISP1583_DFLOW_MAXPKSZ = max_pkt_size & 0x7FF;
121 ISP1583_DFLOW_EPTYPE = (DFLOW_EPTYPE_NOEMPKT | DFLOW_EPTYPE_DBLBUF | (type & 0x3));
122
123 /* clear buffer ... */
124 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF;
125 /* ... twice because of double buffering */
126 usb_select_endpoint(idx);
127 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF;
128 }
129
130 struct usb_endpoint *ep;
131 ep = &(endpoints[epidx_n(idx)]);
132 ep->halt[epidx_dir(idx)] = 0;
133 ep->enabled[epidx_dir(idx)] = 0;
134 ep->out_in_progress = 0;
135 ep->in_min_len = -1;
136 ep->in_ack = 0;
137 ep->type = type;
138 ep->max_pkt_size[epidx_dir(idx)] = max_pkt_size;
139}
140
141static void usb_enable_endpoint(int idx)
142{
143 if(epidx_n(idx)!=0)
144 {
145 usb_select_endpoint(idx);
146 /* Enable interrupt */
147 or_int_value(&ISP1583_INIT_INTEN_A, &ISP1583_INIT_INTEN_B, ISP1583_INIT_INTEN_READ, 1 << (10 + idx));
148 /* Enable endpoint */
149 ISP1583_DFLOW_EPTYPE |= DFLOW_EPTYPE_ENABLE;
150 }
151
152 endpoints[epidx_n(idx)].enabled[epidx_dir(idx)] = 1;
153}
154
155static void usb_disable_endpoint(int idx, bool set_struct)
156{
157 usb_select_endpoint(idx);
158 ISP1583_DFLOW_EPTYPE &= ~DFLOW_EPTYPE_ENABLE;
159 bc_int_value(&ISP1583_INIT_INTEN_A, &ISP1583_INIT_INTEN_B, ISP1583_INIT_INTEN_READ, 1 << (10 + idx));
160
161 if(set_struct)
162 endpoints[epidx_n(idx)].enabled[epidx_dir(idx)] = 0;
163}
164
165static int usb_get_packet(unsigned char *buf, int max_len)
166{
167 int len, i;
168 len = ISP1583_DFLOW_BUFLEN;
169
170 if (max_len < 0 || max_len > len)
171 max_len = len;
172
173 i = 0;
174 while (i < len)
175 {
176 unsigned short d = ISP1583_DFLOW_DATA;
177 if (i < max_len)
178 buf[i] = d & 0xff;
179 i++;
180 if (i < max_len)
181 buf[i] = (d >> 8) & 0xff;
182 i++;
183 }
184 return max_len;
185}
186
187static int usb_receive(int n)
188{
189 logf("usb_receive(%d)", n);
190 int len;
191
192 if (endpoints[n].halt[DIR_RX]
193 || !endpoints[n].enabled[DIR_RX]
194 || endpoints[n].in_min_len < 0
195 || !endpoints[n].in_ack)
196 return -1;
197
198 endpoints[n].in_ack = 0;
199
200 usb_select_endpoint(ep_index(n, DIR_RX));
201
202 len = usb_get_packet(endpoints[n].in_buf + endpoints[n].in_ptr,
203 endpoints[n].in_max_len - endpoints[n].in_ptr);
204 endpoints[n].in_ptr += len;
205 if (endpoints[n].in_ptr >= endpoints[n].in_min_len) {
206 endpoints[n].in_min_len = -1;
207 if (endpoints[n].in_done)
208 (*(endpoints[n].in_done))(n, endpoints[n].in_buf,
209 endpoints[n].in_ptr);
210 }
211 logf("receive_end");
212 return 0;
213}
214
215static bool usb_out_buffer_full(int ep)
216{
217 usb_select_endpoint(ep_index(ep, DIR_TX));
218 if (ISP1583_DFLOW_EPTYPE & 4) /* Check if type=bulk and double buffering is set */
219 return (ISP1583_DFLOW_BUFSTAT & 3) == 3; /* Return true if both buffers are filled */
220 else
221 return (ISP1583_DFLOW_BUFSTAT & 3) != 0; /* Return true if one of the buffers are filled */
222}
223
224static int usb_send(int n)
225{
226 logf("usb_send(%d)", n);
227 int max_pkt_size, len;
228 int i;
229 unsigned char *p;
230
231 if (endpoints[n].halt[DIR_TX]
232 || !endpoints[n].enabled[DIR_TX]
233 || !endpoints[n].out_in_progress)
234 {
235 logf("NOT SEND TO EP!");
236 return -1;
237 }
238
239 if (endpoints[n].out_ptr < 0)
240 {
241 endpoints[n].out_in_progress = 0;
242 if (endpoints[n].out_done)
243 (*(endpoints[n].out_done))(n, endpoints[n].out_buf,
244 endpoints[n].out_len);
245 logf("ALREADY SENT TO EP!");
246 return -1;
247 }
248
249 if (usb_out_buffer_full(n))
250 {
251 logf("BUFFER FULL!");
252 return -1;
253 }
254
255 usb_select_endpoint(ep_index(n, DIR_TX));
256 max_pkt_size = endpoints[n].max_pkt_size[DIR_TX];
257 len = endpoints[n].out_len - endpoints[n].out_ptr;
258 if (len > max_pkt_size)
259 len = max_pkt_size;
260
261 if(len < max_pkt_size)
262 ISP1583_DFLOW_BUFLEN = len;
263
264 p = endpoints[n].out_buf + endpoints[n].out_ptr;
265 i = 0;
266 while (len - i >= 2) {
267 ISP1583_DFLOW_DATA = p[i] | (p[i + 1] << 8);
268 i += 2;
269 }
270 if (i < len)
271 ISP1583_DFLOW_DATA = p[i];
272
273 endpoints[n].out_ptr += len;
274
275/*
276 if (endpoints[n].out_ptr == endpoints[n].out_len
277 && len < max_pkt_size)
278*/
279 if (endpoints[n].out_ptr == endpoints[n].out_len)
280 endpoints[n].out_ptr = -1;
281
282 logf("send_end");
283 return 0;
284}
285
286static void usb_stall_endpoint(int idx)
287{
288 usb_select_endpoint(idx);
289 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STALL;
290 endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 1;
291}
292
293static void usb_unstall_endpoint(int idx)
294{
295 usb_select_endpoint(idx);
296 ISP1583_DFLOW_CTRLFUN &= ~DFLOW_CTRLFUN_STALL;
297 ISP1583_DFLOW_EPTYPE &= ~DFLOW_EPTYPE_ENABLE;
298 ISP1583_DFLOW_EPTYPE |= DFLOW_EPTYPE_ENABLE;
299 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_CLBUF;
300 if (epidx_dir(idx) == DIR_TX)
301 endpoints[epidx_n(idx)].out_in_progress = 0;
302 else
303 {
304 endpoints[epidx_n(idx)].in_min_len = -1;
305 endpoints[epidx_n(idx)].in_ack = 0;
306 }
307 endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 0;
308}
309
310static void usb_status_ack(int ep, int dir)
311{
312 logf("usb_status_ack(%d)", dir);
313 usb_select_endpoint(ep_index(ep, dir));
314 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_STATUS;
315}
316
317static void usb_data_stage_enable(int ep, int dir)
318{
319 logf("usb_data_stage_enable(%d)", dir);
320 usb_select_endpoint(ep_index(ep, dir));
321 ISP1583_DFLOW_CTRLFUN |= DFLOW_CTRLFUN_DSEN;
322}
323
324static void usb_handle_setup_rx(void)
325{
326 int len;
327 usb_select_setup_endpoint();
328 len = usb_get_packet(setup_pkt_buf, 8);
329
330 if (len == 8)
331 usb_core_control_request((struct usb_ctrlrequest*)setup_pkt_buf);
332 else
333 {
334 usb_drv_stall(0, true, false);
335 usb_drv_stall(0, true, true);
336 logf("usb_handle_setup_rx() failed");
337 return;
338 }
339
340 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]);
341}
342
343static void usb_handle_data_int(int ep, int dir)
344{
345 int len;
346 if (dir == DIR_TX)
347 len = usb_send(ep);
348 else
349 {
350 len = usb_receive(ep);
351 endpoints[ep].in_ack = 1;
352 }
353 logf("usb_handle_data_int(%d, %d) finished", ep, dir);
354}
355
356bool usb_drv_powered(void)
357{
358#if 0
359 return (ISP1583_INIT_OTG & INIT_OTG_BSESS_VALID) ? true : false;
360#else
361 return (ISP1583_INIT_MODE & INIT_MODE_VBUSSTAT) ? true : false;
362#endif
363}
364
365static void setup_endpoints(void)
366{
367 usb_setup_endpoint(ep_index(0, DIR_RX), 64, 0);
368 usb_setup_endpoint(ep_index(0, DIR_TX), 64, 0);
369
370 int i;
371 for(i = 1; i < NUM_ENDPOINTS-1; i++)
372 {
373 usb_setup_endpoint(ep_index(i, DIR_RX), (high_speed_mode ? 512 : 64), 2); /* 2 = TYPE_BULK */
374 usb_setup_endpoint(ep_index(i, DIR_TX), (high_speed_mode ? 512 : 64), 2);
375 }
376
377 usb_enable_endpoint(ep_index(0, DIR_RX));
378 usb_enable_endpoint(ep_index(0, DIR_TX));
379
380 for (i = 1; i < NUM_ENDPOINTS-1; i++)
381 {
382 usb_enable_endpoint(ep_index(i, DIR_RX));
383 usb_enable_endpoint(ep_index(i, DIR_TX));
384 }
385
386 ZVM_SPECIFIC;
387}
388
389void usb_helper(void)
390{
391 if(ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ)
392 {
393 #ifdef DEBUG
394 //logf("Helper detected interrupt... [%d]", current_tick);
395 #endif
396 usb_drv_int();
397 }
398 return;
399}
400
401void usb_drv_init(void)
402{
403 /* Disable interrupt at CPU level */
404 DIS_INT_CPU_TARGET;
405
406 /* Unlock the device's registers */
407 ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE;
408
409 /* Soft reset the device */
410 ISP1583_INIT_MODE = INIT_MODE_SFRESET;
411 sleep(10);
412 /* Enable CLKAON & GLINTENA */
413 ISP1583_INIT_MODE = STANDARD_INIT_MODE;
414
415 /* Disable all OTG functions */
416 ISP1583_INIT_OTG = 0;
417
418#if 0
419 #ifdef USE_HIGH_SPEED
420 /* Force device to high speed */
421 ISP1583_GEN_TSTMOD = GEN_TSTMOD_FORCEHS;
422 high_speed_mode = true;
423 #endif
424#endif
425
426 #ifdef DEBUG
427 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));
428 logf("Chip ID: 0x%x", ISP1583_GEN_CHIPID);
429 //logf("INV0: 0x% IRQEDGE: 0x%x IRQPORT: 0x%x", IO_GIO_INV0, IO_GIO_IRQEDGE, IO_GIO_IRQPORT);
430 #endif
431
432 /*Set interrupt generation to target-specific mode +
433 * Set the control pipe to ACK only interrupt +
434 * Set the IN pipe to ACK only interrupt +
435 * Set OUT pipe to ACK and NYET interrupt
436 */
437
438 ISP1583_INIT_INTCONF = 0x54 | INT_CONF_TARGET;
439 /* Clear all interrupts */
440 set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, 0xFFFFFFFF);
441 /* Enable USB interrupts */
442 set_int_value(ISP1583_INIT_INTEN_A, ISP1583_INIT_INTEN_B, STANDARD_INTEN);
443
444 ZVM_SPECIFIC;
445
446 /* Enable interrupt at CPU level */
447 EN_INT_CPU_TARGET;
448
449 setup_endpoints();
450
451 /* Clear device address and disable it */
452 ISP1583_INIT_ADDRESS = 0;
453
454 /* Turn SoftConnect on */
455 ISP1583_INIT_MODE |= INIT_MODE_SOFTCT;
456
457 ZVM_SPECIFIC;
458
459 tick_add_task(usb_helper);
460
461 logf("usb_init_device() finished");
462}
463
464int usb_drv_port_speed(void)
465{
466 return (int)high_speed_mode;
467}
468
469void usb_drv_exit(void)
470{
471 logf("usb_drv_exit()");
472
473 /* Disable device */
474 ISP1583_INIT_MODE &= ~INIT_MODE_SOFTCT;
475 ISP1583_INIT_ADDRESS = 0;
476
477 /* Disable interrupts */
478 set_int_value(ISP1583_INIT_INTEN_A, ISP1583_INIT_INTEN_B, 0);
479 /* and the CPU's one... */
480 DIS_INT_CPU_TARGET;
481
482
483 /* Send usb controller to suspend mode */
484 ISP1583_INIT_MODE = INIT_MODE_GOSUSP;
485 ISP1583_INIT_MODE = 0;
486
487 tick_remove_task(usb_helper);
488
489 ZVM_SPECIFIC;
490}
491
492void usb_drv_stall(int endpoint, bool stall, bool in)
493{
494 logf("%sstall EP%d %s", (stall ? "" : "un"), endpoint, (in ? "RX" : "TX" ));
495 if (stall)
496 usb_stall_endpoint(ep_index(endpoint, (int)in));
497 else
498 usb_unstall_endpoint(ep_index(endpoint, (int)in));
499}
500
501bool usb_drv_stalled(int endpoint, bool in)
502{
503 return (endpoints[endpoint].halt[(int)in] == 1);
504}
505
506static void out_callback(int ep, unsigned char *buf, int len)
507{
508 (void)buf;
509 logf("out_callback(%d, 0x%x, %d)", ep, &buf, len);
510 usb_status_ack(ep, DIR_RX);
511 usb_core_transfer_complete(ep, true, 0, len); /* 0=>status succeeded, haven't worked out status failed yet... */
512}
513
514static void in_callback(int ep, unsigned char *buf, int len)
515{
516 (void)buf;
517 logf("in_callback(%d, 0x%x, %d)", ep, &buf, len);
518 usb_status_ack(ep, DIR_TX);
519 usb_core_transfer_complete(ep, false, 0, len);
520}
521
522int usb_drv_recv(int ep, void* ptr, int length)
523{
524 logf("usb_drv_recv(%d, 0x%x, %d)", ep, &ptr, length);
525 if(ep == 0 && length == 0 && ptr == NULL)
526 {
527 usb_status_ack(ep, DIR_TX);
528 return 0;
529 }
530 endpoints[ep].in_done = in_callback;
531 endpoints[ep].in_buf = ptr;
532 endpoints[ep].in_max_len = length;
533 endpoints[ep].in_min_len = length;
534 endpoints[ep].in_ptr = 0;
535 if(ep == 0)
536 {
537 usb_data_stage_enable(ep, DIR_RX);
538 return usb_receive(ep);
539 }
540 else
541 return usb_receive(ep);
542}
543
544int usb_drv_send_nonblocking(int ep, void* ptr, int length)
545{
546 /* First implement DMA... */
547 return usb_drv_send(ep, ptr, length);
548}
549
550int usb_drv_send(int ep, void* ptr, int length)
551{
552 logf("usb_drv_send_nb(%d, 0x%x, %d)", ep, &ptr, length);
553 if(ep == 0 && length == 0 && ptr == NULL)
554 {
555 usb_status_ack(ep, DIR_RX);
556 return 0;
557 }
558 if(endpoints[ep].out_in_progress == 1)
559 return -1;
560 endpoints[ep].out_done = out_callback;
561 endpoints[ep].out_buf = ptr;
562 endpoints[ep].out_len = length;
563 endpoints[ep].out_ptr = 0;
564 endpoints[ep].out_in_progress = 1;
565 if(ep == 0)
566 {
567 int rc = usb_send(ep);
568 usb_data_stage_enable(ep, DIR_TX);
569 usb_drv_wait(ep, DIR_TX);
570 return rc;
571 }
572 else
573 return usb_send(ep);
574}
575
576void usb_drv_reset_endpoint(int ep, bool send)
577{
578 logf("reset endpoint(%d, %d)", ep, send);
579 usb_setup_endpoint(ep_index(ep, (int)send), endpoints[ep].max_pkt_size[(int)send], endpoints[ep].type);
580 usb_enable_endpoint(ep_index(ep, (int)send));
581}
582
583void usb_drv_wait(int ep, bool send)
584{
585 logf("usb_drv_wait(%d, %d)", ep, send);
586 if(send)
587 {
588 while (endpoints[ep].out_in_progress)
589 nop_f();
590 }
591 else
592 {
593 while (endpoints[ep].in_ack)
594 nop_f();
595 }
596}
597
598void usb_drv_cancel_all_transfers(void)
599{
600 logf("usb_drv_cancel_all_tranfers()");
601 int i;
602
603 for(i=0;i<NUM_ENDPOINTS-1;i++)
604 endpoints[i].halt[0] = endpoints[i].halt[1] = 1;
605}
606
607static void bus_reset(void)
608{
609 /* Enable CLKAON & GLINTENA */
610 ISP1583_INIT_MODE = STANDARD_INIT_MODE;
611 /* Enable USB interrupts */
612 ISP1583_INIT_INTCONF = 0x54 | INT_CONF_TARGET;
613 set_int_value(ISP1583_INIT_INTEN_A, ISP1583_INIT_INTEN_B, STANDARD_INTEN);
614
615 /* Disable all OTG functions */
616 ISP1583_INIT_OTG = 0;
617
618 /* Clear device address and enable it */
619 ISP1583_INIT_ADDRESS = INIT_ADDRESS_DEVEN;
620
621 ZVM_SPECIFIC;
622
623 /* Reset endpoints to default */
624 setup_endpoints();
625
626 logf("bus reset->done");
627}
628
629/* Method for handling interrupts, must be called from usb-<target>.c */
630void usb_drv_int(void)
631{
632 unsigned long ints;
633 ints = ISP1583_GEN_INT_READ & ISP1583_INIT_INTEN_READ;
634
635 if(!ints)
636 return;
637
638 /* Unlock the device's registers */
639 ISP1583_GEN_UNLCKDEV = ISP1583_UNLOCK_CODE;
640
641 #if 0
642 logf(" handling int [0x%x & 0x%x = 0x%x]", ISP1583_GEN_INT_READ, ISP1583_INIT_INTEN_READ, ints);
643 #endif
644
645 if(ints & INT_IEBRST) /* Bus reset */
646 {
647 logf("BRESET");
648 high_speed_mode = false;
649 bus_reset();
650 usb_core_bus_reset();
651 /* Mask bus reset interrupt */
652 set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, INT_IEBRST);
653 return;
654 }
655 if(ints & INT_IEP0SETUP) /* EP0SETUP interrupt */
656 {
657 logf("EP0SETUP");
658 usb_handle_setup_rx();
659 }
660 if(ints & INT_IEHS_STA) /* change from full-speed to high-speed mode -> endpoints need to get reconfigured!! */
661 {
662 logf("HS_STA");
663 high_speed_mode = true;
664 setup_endpoints();
665 }
666 if(ints & INT_EP_MASK) /* Endpoints interrupt */
667 {
668 unsigned long ep_event;
669 unsigned short i = 10;
670 ep_event = ints & INT_EP_MASK;
671 while(ep_event)
672 {
673 if(i>25)
674 break;
675
676 if(ep_event & (1 << i))
677 {
678 logf("EP%d %s interrupt", (i - 10) / 2, i % 2 ? "RX" : "TX");
679 usb_handle_data_int((i - 10) / 2, i % 2);
680 ep_event &= ~(1 << i);
681 }
682 i++;
683 }
684 }
685 if(ints & INT_IERESM && !(ints & INT_IESUSP)) /* Resume status: status change from suspend to resume (active) */
686 {
687 logf("RESM");
688 }
689 if(ints & INT_IESUSP && !(ints & INT_IERESM)) /* Suspend status: status change from active to suspend */
690 {
691 logf("SUSP");
692 }
693 if(ints & INT_IEDMA) /* change in the DMA Interrupt Reason register */
694 {
695 logf("DMA");
696 }
697 if(ints & INT_IEVBUS) /* transition from LOW to HIGH on VBUS */
698 {
699 logf("VBUS");
700 }
701 /* Mask all (enabled) interrupts */
702 set_int_value(ISP1583_GEN_INT_A, ISP1583_GEN_INT_B, ints);
703
704 ZVM_SPECIFIC;
705}
706
707void usb_drv_set_address(int address)
708{
709 logf("usb_drv_set_address(0x%x)", address);
710 ISP1583_INIT_ADDRESS = (address & 0x7F) | INIT_ADDRESS_DEVEN;
711
712 ZVM_SPECIFIC;
713
714 usb_status_ack(0, DIR_TX);
715}
716
717void usb_drv_set_test_mode(int mode)
718{
719 logf("usb_drv_set_test_mode(%d)", mode);
720 switch(mode){
721 case 0:
722 ISP1583_GEN_TSTMOD = 0;
723 /* Power cycle... */
724 break;
725 case 1:
726 ISP1583_GEN_TSTMOD = GEN_TSTMOD_JSTATE;
727 break;
728 case 2:
729 ISP1583_GEN_TSTMOD = GEN_TSTMOD_KSTATE;
730 break;
731 case 3:
732 ISP1583_GEN_TSTMOD = GEN_TSTMOD_SE0_NAK;
733 break;
734 case 4:
735 //REG_PORTSC1 |= PORTSCX_PTC_PACKET;
736 break;
737 case 5:
738 //REG_PORTSC1 |= PORTSCX_PTC_FORCE_EN;
739 break;
740 }
741}
diff --git a/firmware/drivers/rtc/rtc_zenvisionm.c b/firmware/drivers/rtc/rtc_zenvisionm.c
new file mode 100644
index 0000000000..b44af65c42
--- /dev/null
+++ b/firmware/drivers/rtc/rtc_zenvisionm.c
@@ -0,0 +1,37 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20 #include "i2c-dm320.h"
21
22 #define I2C_ADDRESS 0x51
23
24 unsigned char* rtc_send_command(short unk1, short unk2)
25 {
26 unsigned char ret[12];
27 i2c_write(I2C_ADDRESS, (unk2 & 0xFF) | (unk << 8), 1);
28 i2c_read(I2C_ADDRESS, ret, 12);
29 return ret;
30 }
31
32 unsigned char* rtc_read(void)
33 {
34 unsigned char ret[12];
35 i2c_read(I2C_ADDRESS, ret, 12);
36 return ret;
37 } \ No newline at end of file
diff --git a/firmware/export/config-creativezvm.h b/firmware/export/config-creativezvm.h
index 0b91510146..f5ec33317e 100644
--- a/firmware/export/config-creativezvm.h
+++ b/firmware/export/config-creativezvm.h
@@ -27,7 +27,7 @@
27#define CREATIVE_ZVM 1 27#define CREATIVE_ZVM 1
28 28
29/* For Rolo and boot loader */ 29/* For Rolo and boot loader */
30#define MODEL_NUMBER 35 30#define MODEL_NUMBER 26
31 31
32/* define this if you use an ATA controller */ 32/* define this if you use an ATA controller */
33#define HAVE_ATA 33#define HAVE_ATA
@@ -65,15 +65,12 @@
65/* Define this if your LCD can be enabled/disabled */ 65/* Define this if your LCD can be enabled/disabled */
66#define HAVE_LCD_ENABLE 66#define HAVE_LCD_ENABLE
67 67
68#define LCD_REMOTE_PIXELFORMAT VERTICAL_PACKING 68#define CONFIG_KEYPAD CREATIVEZVM_PAD
69 69#define HAS_BUTTON_HOLD
70#define MIN_REMOTE_CONTRAST_SETTING 0 70#define HAVE_HEADPHONE_DETECTION
71#define MAX_REMOTE_CONTRAST_SETTING 15
72#define DEFAULT_REMOTE_CONTRAST_SETTING 7
73
74#define CONFIG_KEYPAD MROBE500_PAD
75//#define HAVE_TOUCHPAD 71//#define HAVE_TOUCHPAD
76#define HAVE_BUTTON_DATA 72
73#define CONFIG_I2C I2C_DM320
77 74
78/* Define this if you do software codec */ 75/* Define this if you do software codec */
79#define CONFIG_CODEC SWCODEC 76#define CONFIG_CODEC SWCODEC
@@ -84,16 +81,17 @@
84/* Define this for LCD backlight available */ 81/* Define this for LCD backlight available */
85//#define HAVE_BACKLIGHT 82//#define HAVE_BACKLIGHT
86 83
87#define HAVE_BACKLIGHT_BRIGHTNESS 84//#define HAVE_BACKLIGHT_BRIGHTNESS
88 85
89/* Main LCD backlight brightness range and defaults */ 86/* Main LCD backlight brightness range and defaults */
90#define MIN_BRIGHTNESS_SETTING 0 87//#define MIN_BRIGHTNESS_SETTING 0
91#define MAX_BRIGHTNESS_SETTING 127 88//#define MAX_BRIGHTNESS_SETTING 127
92#define DEFAULT_BRIGHTNESS_SETTING 85 /* OF "full brightness" */ 89//#define DEFAULT_BRIGHTNESS_SETTING 85 /* OF "full brightness" */
93#define DEFAULT_DIMNESS_SETTING 22 /* OF "most dim" */ 90//#define DEFAULT_DIMNESS_SETTING 22 /* OF "most dim" */
94 91
95/* Define this if you have a software controlled poweroff */ 92/* Define this if you have a software controlled poweroff */
96#define HAVE_SW_POWEROFF 93//#define HAVE_SW_POWEROFF
94//TODO: enable this back
97 95
98/* The number of bytes reserved for loadable codecs */ 96/* The number of bytes reserved for loadable codecs */
99#define CODEC_SIZE 0x80000 97#define CODEC_SIZE 0x80000
@@ -104,11 +102,11 @@
104/* Define this if you have the TLV320 audio codec */ 102/* Define this if you have the TLV320 audio codec */
105//#define HAVE_TLV320 103//#define HAVE_TLV320
106 104
107/* Define this if you want to use the adaptive bass capibility of the 8751 */ 105/* TLV320 has no tone controls, so we use the software ones */
108/* #define USE_ADAPTIVE_BASS */ 106//#define HAVE_SW_TONE_CONTROLS
109 107
110#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \ 108/*#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \
111 SAMPR_CAP_11) 109 SAMPR_CAP_11)*/
112 110
113#define BATTERY_CAPACITY_DEFAULT 1100 /* default battery capacity */ 111#define BATTERY_CAPACITY_DEFAULT 1100 /* default battery capacity */
114#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */ 112#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */
@@ -117,7 +115,7 @@
117#define BATTERY_TYPES_COUNT 1 /* only one type */ 115#define BATTERY_TYPES_COUNT 1 /* only one type */
118 116
119/* Hardware controlled charging with monitoring */ 117/* Hardware controlled charging with monitoring */
120#define CONFIG_CHARGING CHARGING_MONITOR 118//#define CONFIG_CHARGING CHARGING_MONITOR
121 119
122#ifndef SIMULATOR 120#ifndef SIMULATOR
123 121
@@ -127,8 +125,7 @@
127/* Define this if you have a Texas Instruments TSC2100 touch screen */ 125/* Define this if you have a Texas Instruments TSC2100 touch screen */
128//#define HAVE_TSC2100 126//#define HAVE_TSC2100
129 127
130/* Define this if you want to use coldfire's i2c interface */ 128#define CONFIG_USBOTG USBOTG_ISP1583
131//#define CONFIG_I2C I2C_S3C2440
132 129
133/* define this if the hardware can be powered off while charging */ 130/* define this if the hardware can be powered off while charging */
134#define HAVE_POWEROFF_WHILE_CHARGING 131#define HAVE_POWEROFF_WHILE_CHARGING
@@ -161,4 +158,23 @@
161#define BOOTFILE "rockbox." BOOTFILE_EXT 158#define BOOTFILE "rockbox." BOOTFILE_EXT
162#define BOOTDIR "/.rockbox" 159#define BOOTDIR "/.rockbox"
163 160
161#define HAVE_USBSTACK
162#define USB_VENDOR_ID 0x041e
163#define USB_PRODUCT_ID 0x4133
164
165#define USB_SERIAL
166
167//DEBUGGING!
168#ifdef BOOTLOADER
169#define THREAD_EXTRA_CHECKS 1
170#define DEBUG 1
171#define debug(msg) printf(msg)
172#define BUTTON_DEBUG
173
174#define DO_THREAD_TEST
175#endif
176
177
178//Uncomment next line to make this build Zen Vision compatible
179//#define ZEN_VISION
164#endif 180#endif
diff --git a/firmware/export/config.h b/firmware/export/config.h
index e502043844..f4e38ce73c 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -79,6 +79,7 @@
79#define IAUDIO67_PAD 21 79#define IAUDIO67_PAD 21
80#define COWOND2_PAD 22 80#define COWOND2_PAD 22
81#define IAUDIO_M3_PAD 23 81#define IAUDIO_M3_PAD 23
82#define CREATIVEZVM_PAD 24
82 83
83/* CONFIG_REMOTE_KEYPAD */ 84/* CONFIG_REMOTE_KEYPAD */
84#define H100_REMOTE 1 85#define H100_REMOTE 1
@@ -143,6 +144,7 @@
143#define I2C_IMX31L 9 144#define I2C_IMX31L 9
144#define I2C_TCC77X 10 145#define I2C_TCC77X 10
145#define I2C_TCC780X 11 146#define I2C_TCC780X 11
147#define I2C_DM320 12 /* DM320 style */
146 148
147/* CONFIG_LED */ 149/* CONFIG_LED */
148#define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */ 150#define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */
@@ -169,6 +171,7 @@
169 171
170/* USB On-the-go */ 172/* USB On-the-go */
171#define USBOTG_ISP1362 1362 /* iriver H300 */ 173#define USBOTG_ISP1362 1362 /* iriver H300 */
174#define USBOTG_ISP1583 1583 /* Creative Zen Vision:M */
172#define USBOTG_M5636 5636 /* iAudio X5 */ 175#define USBOTG_M5636 5636 /* iAudio X5 */
173#define USBOTG_ARC 5020 /* PortalPlayer 502x */ 176#define USBOTG_ARC 5020 /* PortalPlayer 502x */
174 177
@@ -389,13 +392,13 @@
389#define ARM_ARCH 6 /* ARMv6 */ 392#define ARM_ARCH 6 /* ARMv6 */
390#endif 393#endif
391 394
392#if defined(CPU_TCC77X) || defined(CPU_TCC780X) 395#if defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320)
393#define CPU_ARM 396#define CPU_ARM
394#define ARM_ARCH 5 /* ARMv5 */ 397#define ARM_ARCH 5 /* ARMv5 */
395#endif 398#endif
396 399
397#if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ 400#if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \
398 || (CONFIG_CPU == DSC25) || (CONFIG_CPU == DM320) 401 || (CONFIG_CPU == DSC25)
399#define CPU_ARM 402#define CPU_ARM
400#define ARM_ARCH 4 /* ARMv4 */ 403#define ARM_ARCH 4 /* ARMv4 */
401#endif 404#endif
diff --git a/firmware/export/dm320.h b/firmware/export/dm320.h
index 4a26f6e3d5..a70083331e 100644
--- a/firmware/export/dm320.h
+++ b/firmware/export/dm320.h
@@ -28,7 +28,12 @@
28#define LCD_BUFFER_SIZE (LCD_WIDTH*LCD_HEIGHT*2) 28#define LCD_BUFFER_SIZE (LCD_WIDTH*LCD_HEIGHT*2)
29#define TTB_SIZE (0x4000) 29#define TTB_SIZE (0x4000)
30/* must be 16Kb (0x4000) aligned */ 30/* must be 16Kb (0x4000) aligned */
31#if 0
32#define MEM_END 0x00900000 + (MEM*0x00100000)
33#define TTB_BASE ((unsigned int *)(MEM_END - TTB_SIZE)) /* End of memory */
34#else
31#define TTB_BASE ((unsigned int *)(0x04900000 - TTB_SIZE)) /* End of memory */ 35#define TTB_BASE ((unsigned int *)(0x04900000 - TTB_SIZE)) /* End of memory */
36#endif
32#define FRAME ((short *) ((char*)TTB_BASE - LCD_BUFFER_SIZE)) /* Right before TTB */ 37#define FRAME ((short *) ((char*)TTB_BASE - LCD_BUFFER_SIZE)) /* Right before TTB */
33 38
34#define PHY_IO_BASE 0x00030000 39#define PHY_IO_BASE 0x00030000
diff --git a/firmware/export/isp1583.h b/firmware/export/isp1583.h
new file mode 100644
index 0000000000..3ffbbed60e
--- /dev/null
+++ b/firmware/export/isp1583.h
@@ -0,0 +1,185 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef ISP1583_H
20#define ISP1583_H
21
22#ifndef ISP1583_H_OVERRIDE
23/* Initialization registers */
24#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0)))
25#define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC)))
26#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10)))
27#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12)))
28#define ISP1583_INIT_INTEN_A (*((volatile unsigned long*)(ISP1583_IOBASE+0x14)))
29#define ISP1583_INIT_INTEN_B
30#define ISP1583_INIT_INTEN_READ ISP1583_INIT_INTEN_A
31/* Data Flow registers */
32#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2)))
33#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28)))
34#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20)))
35#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C)))
36#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E)))
37#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04)))
38#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08)))
39/* DMA registers */
40#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58)))
41/* General registers */
42#define ISP1583_GEN_INT_A (*((volatile unsigned long*)(ISP1583_IOBASE+0x18)))
43#define ISP1583_GEN_INT_B
44#define ISP1583_GEN_INT_READ ISP1583_GEN_INT_A
45#define ISP1583_GEN_CHIPID (*((volatile unsigned long*)(ISP1583_IOBASE+0x70))) /* Size=3 bytes */
46#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74)))
47#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78)))
48#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C)))
49#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84)))
50
51#define set_int_value(a,b,value) a = value;
52#endif
53
54#define ISP1583_UNLOCK_CODE (unsigned short)0xAA37
55
56/* Initialization registers' bits */
57
58/* Initialization OTG register bits */
59#define INIT_OTG_BSESS_VALID (1 << 4)
60
61/* Initialization Mode register bits */
62#define INIT_MODE_TEST2 (1 << 15)
63#define INIT_MODE_TEST1 (1 << 14)
64#define INIT_MODE_TEST0 (1 << 13)
65#define INIT_MODE_DMA_CLKON (1 << 9)
66#define INIT_MODE_VBUSSTAT (1 << 8)
67#define INIT_MODE_CLKAON (1 << 7)
68#define INIT_MODE_SNDRSU (1 << 6)
69#define INIT_MODE_GOSUSP (1 << 5)
70#define INIT_MODE_SFRESET (1 << 4)
71#define INIT_MODE_GLINTENA (1 << 3)
72#define INIT_MODE_WKUPCS (1 << 2)
73#define INIT_MODE_PWRON (1 << 1)
74#define INIT_MODE_SOFTCT (1 << 0)
75
76/* Initialization Interrupt Enable register bits */
77#define INIT_INTEN_IEP7TX (1 << 25)
78#define INIT_INTEN_IEP7RX (1 << 24)
79#define INIT_INTEN_IEP6TX (1 << 23)
80#define INIT_INTEN_IEP6RX (1 << 22)
81#define INIT_INTEN_IEP5TX (1 << 21)
82#define INIT_INTEN_IEP5RX (1 << 20)
83#define INIT_INTEN_IEP4TX (1 << 19)
84#define INIT_INTEN_IEP4RX (1 << 18)
85#define INIT_INTEN_IEP3TX (1 << 17)
86#define INIT_INTEN_IEP3RX (1 << 16)
87#define INIT_INTEN_IEP2TX (1 << 15)
88#define INIT_INTEN_IEP2RX (1 << 14)
89#define INIT_INTEN_IEP1TX (1 << 13)
90#define INIT_INTEN_IEP1RX (1 << 12)
91#define INIT_INTEN_IEP0TX (1 << 11)
92#define INIT_INTEN_IEP0RX (1 << 10)
93#define INIT_INTEN_IEP0SETUP (1 << 8)
94#define INIT_INTEN_IEVBUS (1 << 7)
95#define INIT_INTEN_IEDMA (1 << 6)
96#define INIT_INTEN_IEHS_STA (1 << 5)
97#define INIT_INTEN_IERESM (1 << 4)
98#define INIT_INTEN_IESUSP (1 << 3)
99#define INIT_INTEN_IEPSOF (1 << 2)
100#define INIT_INTEN_IESOF (1 << 1)
101#define INIT_INTEN_IEBRST (1 << 0)
102
103/* Initialization Interrupt Configuration register bits */
104#define INIT_INTCONF_INTLVL (1 << 1)
105#define INIT_INTCONF_INTPOL (1 << 0)
106
107/* Initialization Address register bits */
108#define INIT_ADDRESS_DEVEN (1 << 7)
109
110/* Data Flow registers' bits */
111
112/* Data Flow Endpoint Index register bits */
113#define DFLOW_EPINDEX_EP0SETUP (1 << 5)
114
115/* Data Flow Control Function register bits */
116#define DFLOW_CTRLFUN_CLBUF (1 << 4)
117#define DFLOW_CTRLFUN_VENDP (1 << 3)
118#define DFLOW_CTRLFUN_DSEN (1 << 2)
119#define DFLOW_CTRLFUN_STATUS (1 << 1)
120#define DFLOW_CTRLFUN_STALL (1 << 0)
121
122/* Data Flow Endpoint Type register bits */
123#define DFLOW_EPTYPE_NOEMPKT (1 << 4)
124#define DFLOW_EPTYPE_ENABLE (1 << 3)
125#define DFLOW_EPTYPE_DBLBUF (1 << 2)
126
127/* General registers' bits */
128
129/* General Test Mode register bits */
130#define GEN_TSTMOD_FORCEHS (1 << 7)
131#define GEN_TSTMOD_FORCEFS (1 << 4)
132#define GEN_TSTMOD_PRBS (1 << 3)
133#define GEN_TSTMOD_KSTATE (1 << 2)
134#define GEN_TSTMOD_JSTATE (1 << 1)
135#define GEN_TSTMOD_SE0_NAK (1 << 0)
136
137/* Interrupts */
138#define INT_IEP7TX (1 << 25)
139#define INT_IEP7RX (1 << 24)
140#define INT_IEP6TX (1 << 23)
141#define INT_IEP6RX (1 << 22)
142#define INT_IEP5TX (1 << 21)
143#define INT_IEP5RX (1 << 20)
144#define INT_IEP4TX (1 << 19)
145#define INT_IEP4RX (1 << 18)
146#define INT_IEP3TX (1 << 17)
147#define INT_IEP3RX (1 << 16)
148#define INT_IEP2TX (1 << 15)
149#define INT_IEP2RX (1 << 14)
150#define INT_IEP1TX (1 << 13)
151#define INT_IEP1RX (1 << 12)
152#define INT_IEP0TX (1 << 11)
153#define INT_IEP0RX (1 << 10)
154#define INT_IEP0SETUP (1 << 8)
155#define INT_IEVBUS (1 << 7)
156#define INT_IEDMA (1 << 6)
157#define INT_IEHS_STA (1 << 5)
158#define INT_IERESM (1 << 4)
159#define INT_IESUSP (1 << 3)
160#define INT_IEPSOF (1 << 2)
161#define INT_IESOF (1 << 1)
162#define INT_IEBRST (1 << 0)
163
164#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 )
165
166#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 )
167#define STANDARD_INIT_MODE ( INIT_MODE_CLKAON | INIT_MODE_GLINTENA )
168
169bool usb_drv_powered(void);
170void usb_drv_init(void);
171int usb_drv_port_speed(void);
172void usb_drv_exit(void);
173void usb_drv_stall(int endpoint, bool stall, bool in);
174bool usb_drv_stalled(int endpoint, bool in);
175int usb_drv_recv(int ep, void* ptr, int length);
176int usb_drv_send_nonblocking(int ep, void* ptr, int length);
177int usb_drv_send(int endpoint, void* ptr, int length);
178void usb_drv_reset_endpoint(int ep, bool send);
179void usb_drv_wait(int ep, bool send);
180void usb_drv_cancel_all_transfers(void);
181void usb_drv_set_address(int address);
182void usb_drv_set_test_mode(int mode);
183void usb_drv_int(void); /* Method for handling interrupts, must be called from usb-<target>.c */
184
185#endif
diff --git a/firmware/kernel.c b/firmware/kernel.c
index f86a188d05..4ccf2bbe17 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -435,6 +435,11 @@ void sleep(int ticks)
435 unsigned stop = USEC_TIMER + ticks * (1000000/HZ); 435 unsigned stop = USEC_TIMER + ticks * (1000000/HZ);
436 while (TIME_BEFORE(USEC_TIMER, stop)) 436 while (TIME_BEFORE(USEC_TIMER, stop))
437 switch_thread(); 437 switch_thread();
438#elif defined(CREATIVE_ZVM) && defined(BOOTLOADER)
439 // hacky..
440 long sleep_ticks = current_tick + ticks + 1;
441 while (sleep_ticks > current_tick)
442 switch_thread();
438#else 443#else
439 disable_irq(); 444 disable_irq();
440 sleep_thread(ticks); 445 sleep_thread(ticks);
diff --git a/firmware/panic.c b/firmware/panic.c
index c61476c423..781345e714 100644
--- a/firmware/panic.c
+++ b/firmware/panic.c
@@ -123,6 +123,8 @@ void panicf( const char *fmt, ...)
123#elif CONFIG_KEYPAD == ONDIO_PAD 123#elif CONFIG_KEYPAD == ONDIO_PAD
124 if (!(PCDR & 0x0008)) 124 if (!(PCDR & 0x0008))
125#endif /* CONFIG_KEYPAD */ 125#endif /* CONFIG_KEYPAD */
126#elif defined(CREATIVE_ZVM)
127 if(false)
126#endif /* CPU */ 128#endif /* CPU */
127 system_reboot(); 129 system_reboot();
128#endif /* !SIMULATOR */ 130#endif /* !SIMULATOR */
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c
new file mode 100644
index 0000000000..d634a71f70
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c
@@ -0,0 +1,32 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "cpu.h"
21#include "adc-target.h"
22#include "kernel.h"
23
24void adc_init(void)
25{
26}
27
28/* Called to get the recent ADC reading */
29inline unsigned short adc_read(int channel)
30{
31 return (short)channel;
32}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h b/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h
new file mode 100644
index 0000000000..aa0f7eb364
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/adc-target.h
@@ -0,0 +1,38 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: adc-target.h 14817 2007-09-22 15:43:38Z kkurbjun $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _ADC_TARGET_H_
21#define _ADC_TARGET_H_
22
23/* only two channels used by the Gigabeat */
24#define NUM_ADC_CHANNELS 2
25
26#define ADC_BATTERY 0
27#define ADC_HPREMOTE 1
28#define ADC_UNKNOWN_3 2
29#define ADC_UNKNOWN_4 3
30#define ADC_UNKNOWN_5 4
31#define ADC_UNKNOWN_6 5
32#define ADC_UNKNOWN_7 6
33#define ADC_UNKNOWN_8 7
34
35#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
36#define ADC_READ_ERROR 0xFFFF
37
38#endif
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
new file mode 100644
index 0000000000..5cbcd72415
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "kernel.h"
23#include "thread.h"
24#include "system.h"
25#include "power.h"
26#include "panic.h"
27#include "ata-target.h"
28
29void ide_power_enable(bool on){
30#if 0
31 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2;
32 if(on)
33 {
34 IO_GIO_BITSET0 = (1 << 14);
35 ata_reset();
36 }
37 else
38 IO_GIO_BITCLR0 = (1 << 14);
39 IO_INTC_EINT1 |= INTR_EINT1_EXT2;
40 return;
41#endif
42}
43
44inline bool ide_powered(){
45#if 0
46 return (IO_GIO_BITSET0 & (1 << 14));
47#else
48 return true;
49#endif
50}
51
52void ata_reset(void)
53{
54/* Disabled until figured out what's wrong */
55 IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; //disable GIO2 interrupt
56 if(!ide_powered())
57 {
58 ide_power_enable(true);
59 sleep(150);
60 }
61 else
62 {
63 IO_GIO_BITSET0 = (1 << 5);
64 IO_GIO_BITCLR0 = (1 << 3);
65 sleep(1);
66 }
67 IO_GIO_BITCLR0 = (1 << 5);
68 sleep(10);
69 IO_GIO_BITSET0 = (1 << 3);
70 while(!(ATA_COMMAND & STATUS_RDY))
71 sleep(10);
72 IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt
73 return;
74}
75
76void ata_enable(bool on)
77{
78 (void)on;
79 return;
80}
81
82bool ata_is_coldstart(void)
83{
84 return true;
85}
86
87void ata_device_init(void)
88{
89 IO_INTC_EINT1 |= INTR_EINT1_EXT2; //enable GIO2 interrupt
90 //TODO: mimic OF inits...
91 return;
92}
93
94void GIO2(void)
95{
96#ifdef DEBUG
97 //printf("GIO2 interrupt...");
98#endif
99 IO_INTC_IRQ1 = INTR_IRQ1_EXT2; //Mask GIO2 interrupt
100 return;
101}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
new file mode 100644
index 0000000000..b098396d5e
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-target.h
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef ATA_TARGET_H
21#define ATA_TARGET_H
22
23/* Plain C read & write loops */
24#define PREFER_C_READING
25#define PREFER_C_WRITING
26
27#define ATA_IOBASE 0x50FEE000
28#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE)))
29#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE+0x2)))
30#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE+0x4)))
31#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE+0x6)))
32#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE+0x8)))
33#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE+0xA)))
34#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE+0xC)))
35#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE+0xE)))
36#define ATA_CONTROL (*((volatile unsigned char*)(ATA_IOBASE+0x800C)))
37
38#define STATUS_BSY 0x80
39#define STATUS_RDY 0x40
40#define STATUS_DF 0x20
41#define STATUS_DRQ 0x08
42#define STATUS_ERR 0x01
43#define ERROR_ABRT 0x04
44
45#define WRITE_PATTERN1 0xa5
46#define WRITE_PATTERN2 0x5a
47#define WRITE_PATTERN3 0xaa
48#define WRITE_PATTERN4 0x55
49
50#define READ_PATTERN1 0xa5
51#define READ_PATTERN2 0x5a
52#define READ_PATTERN3 0xaa
53#define READ_PATTERN4 0x55
54
55#define READ_PATTERN1_MASK 0xff
56#define READ_PATTERN2_MASK 0xff
57#define READ_PATTERN3_MASK 0xff
58#define READ_PATTERN4_MASK 0xff
59
60#define SET_REG(reg,val) reg = (val)
61#define SET_16BITREG(reg,val) reg = (val)
62
63void ata_reset(void);
64void ata_device_init(void);
65bool ata_is_coldstart(void);
66void ide_power_enable(bool on);
67
68#endif
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c
new file mode 100644
index 0000000000..1e5676b19e
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/audio-creativezvm.c
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: audio-c200_e200.c 14624 2007-09-06 03:01:41Z lowlight $
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "cpu.h"
20#include "kernel.h"
21#include "sound.h"
22
23const struct sound_settings_info audiohw_settings[] = {
24 [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
25 [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0},
26 [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0},
27 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
28 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
29 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
30};
31
32
33void audiohw_init(void)
34{
35}
36
37void audiohw_close(void)
38{
39}
40
41void audiohw_mute(bool mute)
42{
43 (void) mute;
44}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h b/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h
new file mode 100644
index 0000000000..446c5640aa
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/backlight-target.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: backlight-target.h 15599 2007-11-12 18:49:53Z amiconn $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef BACKLIGHT_TARGET_H
21#define BACKLIGHT_TARGET_H
22
23bool _backlight_init(void);
24void _backlight_on(void);
25void _backlight_off(void);
26void _backlight_set_brightness(int brightness);
27
28/* true: backlight fades off - false: backlight fades on */
29void __backlight_dim(bool dim);
30
31#endif
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/button-target.h b/firmware/target/arm/tms320dm320/creative-zvm/button-target.h
new file mode 100644
index 0000000000..1b63895374
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/button-target.h
@@ -0,0 +1,57 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Maurus Cuelenaere
11*
12* All files in this archive are subject to the GNU General Public License.
13* See the file COPYING in the source tree root for full license agreement.
14*
15* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16* KIND, either express or implied.
17*
18****************************************************************************/
19
20#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include "config.h"
24
25#define BUTTON_BACK (1 << 0)
26#define BUTTON_CUSTOM (1 << 1)
27#define BUTTON_MENU (1 << 2)
28
29#define BUTTON_LEFT (1 << 3)
30#define BUTTON_RIGHT (1 << 4)
31#define BUTTON_UP (1 << 5)
32#define BUTTON_DOWN (1 << 6)
33#define BUTTON_SELECT (1 << 7)
34
35#define BUTTON_POWER (1 << 8)
36#define BUTTON_PLAY (1 << 9)
37
38#define BUTTON_HOLD (1 << 10)
39
40#define BUTTON_REMOTE 0
41
42#define BUTTON_MAIN ( BUTTON_BACK | BUTTON_MENU | BUTTON_LEFT | BUTTON_RIGHT \
43 | BUTTON_UP | BUTTON_DOWN | BUTTON_SELECT | BUTTON_POWER \
44 | BUTTON_PLAY | BUTTON_HOLD | BUTTON_CUSTOM )
45
46#define POWEROFF_BUTTON BUTTON_POWER
47#define POWEROFF_COUNT 10
48
49void button_init_device(void);
50int button_read_device(void);
51bool headphones_inserted(void);
52bool button_hold(void);
53bool button_usb_connected(void);
54
55int get_debug_info(int choice);
56
57#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
new file mode 100644
index 0000000000..dec20ad72f
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c
@@ -0,0 +1,405 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Maurus Cuelenaere
11*
12* All files in this archive are subject to the GNU General Public License.
13* See the file COPYING in the source tree root for full license agreement.
14*
15* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16* KIND, either express or implied.
17*
18****************************************************************************/
19#include "config.h"
20
21#include "hwcompat.h"
22#include "kernel.h"
23#include "lcd.h"
24#include "system.h"
25#include "memory.h"
26#include "cpu.h"
27#include "spi.h"
28#include "spi-target.h"
29#include "lcd-target.h"
30
31/* Power and display status */
32static bool display_on = true; /* Is the display turned on? */
33static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */
34
35int lcd_default_contrast(void)
36{
37 return 0x1f;
38}
39
40void lcd_set_contrast(int val)
41{
42 /* iirc there is an ltv250qv command to do this */
43 #warning function not implemented
44 (void)val;
45}
46
47void lcd_set_invert_display(bool yesno) {
48 (void) yesno;
49 // TODO:
50}
51
52void lcd_set_flip(bool yesno) {
53 (void) yesno;
54 // TODO:
55}
56
57
58/* LTV250QV panel functions */
59
60static void lcd_write_reg(unsigned char reg, unsigned short val)
61{
62 unsigned char block[3];
63 block[0] = 0x74;
64 block[1] = 0;
65 block[2] = reg | 0xFF;
66 spi_block_transfer(SPI_target_LTV250QV, block, sizeof(block), NULL, 0);
67 block[0] = 0x76;
68 block[1] = (val >> 8) & 0xFF;
69 block[2] = val & 0xFF;
70 spi_block_transfer(SPI_target_LTV250QV, block, sizeof(block), NULL, 0);
71}
72
73static void sleep_ms(unsigned int ms)
74{
75 sleep(ms*HZ/1000);
76}
77
78static void lcd_display_on(void)
79{
80 /* Enable main power */
81 IO_GIO_BITSET2 |= (1 << 3);
82
83 /* power on sequence as per the ZVM firmware */
84 sleep_ms(250);
85 IO_GIO_BITSET1 = (1 << 13);
86 sleep_ms(5);
87 IO_GIO_BITSET2 = (1 << 5);
88 IO_GIO_BITSET2 = (1 << 8);
89 sleep_ms(1);
90
91 //Init SPI here...
92 sleep_ms(32);
93
94 IO_GIO_BITSET2 = (1 << 0);
95 sleep_ms(5);
96 IO_GIO_BITSET2 = (1 << 7);
97 sleep_ms(5);
98 IO_GIO_BITSET2 = (1 << 4);
99 sleep_ms(5);
100 IO_GIO_BITCLR2 = (1 << 8);
101 //TODO: figure out what OF does after this...
102 IO_GIO_BITSET2 = (1 << 8);
103 sleep_ms(1);
104
105 lcd_write_reg(1, 0x1D);
106 lcd_write_reg(2, 0x0);
107 lcd_write_reg(3, 0x0);
108 lcd_write_reg(4, 0x0);
109 lcd_write_reg(5, 0x40A3);
110 lcd_write_reg(6, 0x0);
111 lcd_write_reg(7, 0x0);
112 lcd_write_reg(8, 0x0);
113 lcd_write_reg(9, 0x0);
114 lcd_write_reg(10, 0x0);
115 lcd_write_reg(16, 0x0);
116 lcd_write_reg(17, 0x0);
117 lcd_write_reg(18, 0x0);
118 lcd_write_reg(19, 0x0);
119 lcd_write_reg(20, 0x0);
120 lcd_write_reg(21, 0x0);
121 lcd_write_reg(22, 0x0);
122 lcd_write_reg(23, 0x0);
123 lcd_write_reg(24, 0x0);
124 lcd_write_reg(25, 0x0);
125 sleep_ms(10);
126
127 lcd_write_reg(9, 0x4055);
128 lcd_write_reg(10, 0x0);
129 sleep_ms(40);
130
131 lcd_write_reg(10, 0x2000);
132 sleep_ms(40);
133
134 lcd_write_reg(1, 0x401D);
135 lcd_write_reg(2, 0x204);
136 lcd_write_reg(3, 0x100);
137 lcd_write_reg(4, 0x1000);
138 lcd_write_reg(5, 0x5033);
139 lcd_write_reg(6, 0x5);
140 lcd_write_reg(7, 0x1B);
141 lcd_write_reg(8, 0x800);
142 lcd_write_reg(16, 0x203);
143 lcd_write_reg(17, 0x302);
144 lcd_write_reg(18, 0xC08);
145 lcd_write_reg(19, 0xC08);
146 lcd_write_reg(20, 0x707);
147 lcd_write_reg(21, 0x707);
148 lcd_write_reg(22, 0x104);
149 lcd_write_reg(23, 0x306);
150 lcd_write_reg(24, 0x0);
151 lcd_write_reg(25, 0x0);
152 sleep_ms(60);
153
154 lcd_write_reg(9, 0xA55);
155 lcd_write_reg(10, 0x111A);
156 sleep_ms(10);
157
158 //TODO: other stuff!
159
160 /* tell that we're on now */
161 display_on = true;
162}
163
164static void lcd_display_off(void)
165{
166 display_on = false;
167
168 /* LQV shutdown sequence */
169 lcd_write_reg(9, 0x855);
170 sleep_ms(20);
171
172 lcd_write_reg(9, 0x55);
173 lcd_write_reg(5, 0x4033);
174 lcd_write_reg(10, 0x0);
175 sleep_ms(20);
176
177 lcd_write_reg(9, 0x0);
178 sleep_ms(10);
179 unsigned char temp[1];
180 temp[0] = 0;
181 spi_block_transfer(SPI_target_LTV250QV, temp, sizeof(temp), NULL, 0);
182
183 IO_GIO_BITCLR2 = (1 << 4);
184 sleep_ms(5);
185 IO_GIO_BITCLR2 = (1 << 7);
186 sleep_ms(5);
187 IO_GIO_BITCLR2 = (1 << 0);
188 sleep_ms(2);
189 IO_GIO_BITCLR2 = (1 << 8);
190 IO_GIO_BITCLR2 = (1 << 5);
191
192 /* Disable main power */
193 IO_GIO_BITCLR2 |= (1 << 3);
194}
195
196
197
198void lcd_enable(bool on)
199{
200 if (on == display_on)
201 return;
202
203 if (on)
204 {
205 display_on = true; //TODO: remove me!
206 //lcd_display_on(); /* Turn on display */
207 lcd_update(); /* Resync display */
208 }
209 else
210 {
211 display_on = false; //TODO: remove me!
212 //lcd_display_off(); /* Turn off display */
213 }
214}
215
216bool lcd_enabled(void)
217{
218 return display_on;
219}
220
221void lcd_set_direct_fb(bool yes)
222{
223 unsigned int addr;
224 direct_fb_access = yes;
225 if(yes)
226 addr = ((unsigned int)&lcd_framebuffer-CONFIG_SDRAM_START) / 32;
227 else
228 addr = ((unsigned int)FRAME-CONFIG_SDRAM_START) / 32;
229 IO_OSD_OSDWINADH = addr >> 16;
230 IO_OSD_OSDWIN0ADL = addr & 0xFFFF;
231}
232
233bool lcd_get_direct_fb(void)
234{
235 return direct_fb_access;
236}
237
238void lcd_init_device(void)
239{
240 /* Based on lcd-mr500.c from Catalin Patulea */
241 unsigned int addr;
242
243 /* Clear the Frame */
244 memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT);
245
246 IO_OSD_MODE = 0x00ff;
247 IO_OSD_VIDWINMD = 0x0002;
248 IO_OSD_OSDWINMD0 = 0x2001;
249 IO_OSD_OSDWINMD1 = 0x0002;
250 IO_OSD_ATRMD = 0x0000;
251 IO_OSD_RECTCUR = 0x0000;
252
253 IO_OSD_OSDWIN0OFST = (LCD_WIDTH*16) / 256;
254 addr = ((unsigned int)FRAME-CONFIG_SDRAM_START) / 32;
255 IO_OSD_OSDWINADH = addr >> 16;
256 IO_OSD_OSDWIN0ADL = addr & 0xFFFF;
257
258#ifndef ZEN_VISION
259 IO_OSD_BASEPX=26;
260 IO_OSD_BASEPY=5;
261#else
262 IO_OSD_BASEPX=80;
263 IO_OSD_BASEPY=0;
264#endif
265
266 IO_OSD_OSDWIN0XP = 0;
267 IO_OSD_OSDWIN0YP = 0;
268 IO_OSD_OSDWIN0XL = LCD_WIDTH;
269 IO_OSD_OSDWIN0YL = LCD_HEIGHT;
270#if 0
271 //TODO: set LCD clock!
272 IO_CLK_MOD1 &= ~0x18; // disable OSD clock and VENC clock
273 IO_CLK_02DIV = 3;
274 IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400; // reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN clock'
275 IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000; // set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock'
276 IO_CLK_MOD1 |= 0x18; // enable OSD clock and VENC clock
277
278 /* Set LCD values in OSD */
279 IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 ); // disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit
280 IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 );
281 //TODO: finish this...
282#endif
283}
284
285
286/*** Update functions ***/
287
288
289
290/* Update a fraction of the display. */
291void lcd_update_rect(int x, int y, int width, int height)
292{
293 register fb_data *dst, *src;
294
295 if (!display_on || direct_fb_access)
296 return;
297
298 if (x + width > LCD_WIDTH)
299 width = LCD_WIDTH - x; /* Clip right */
300 if (x < 0)
301 width += x, x = 0; /* Clip left */
302 if (width <= 0)
303 return; /* nothing left to do */
304
305 if (y + height > LCD_HEIGHT)
306 height = LCD_HEIGHT - y; /* Clip bottom */
307 if (y < 0)
308 height += y, y = 0; /* Clip top */
309 if (height <= 0)
310 return; /* nothing left to do */
311
312#if CONFIG_ORIENTATION == SCREEN_PORTAIT
313 dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
314 src = &lcd_framebuffer[y][x];
315
316 /* Copy part of the Rockbox framebuffer to the second framebuffer */
317 if (width < LCD_WIDTH)
318 {
319 /* Not full width - do line-by-line */
320 lcd_copy_buffer_rect(dst, src, width, height);
321 }
322 else
323 {
324 /* Full width - copy as one line */
325 lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
326 }
327#else
328 src = &lcd_framebuffer[y][x];
329
330 register int xc, yc;
331 register fb_data *start=FRAME + LCD_HEIGHT*(LCD_WIDTH-x-1) + y + 1;
332
333 for(yc=0;yc<height;yc++)
334 {
335 dst=start+yc;
336 for(xc=0; xc<width; xc++)
337 {
338 *dst=*src++;
339 dst-=LCD_HEIGHT;
340 }
341 src+=x;
342 }
343#endif
344}
345
346/* Update the display.
347This must be called after all other LCD functions that change the display. */
348void lcd_update(void)
349{
350 if (!display_on || direct_fb_access)
351 return;
352#if CONFIG_ORIENTATION == SCREEN_PORTAIT
353 lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0],
354 LCD_WIDTH*LCD_HEIGHT, 1);
355#else
356 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
357#endif
358}
359
360/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
361extern void lcd_write_yuv420_lines(fb_data *dst,
362unsigned char chroma_buf[LCD_HEIGHT/2*3],
363unsigned char const * const src[3],
364int width,
365int stride);
366/* Performance function to blit a YUV bitmap directly to the LCD */
367/* For the Gigabeat - show it rotated */
368/* So the LCD_WIDTH is now the height */
369void lcd_blit_yuv(unsigned char * const src[3],
370int src_x, int src_y, int stride,
371int x, int y, int width, int height)
372{
373 /* Caches for chroma data so it only need be recalculated every other
374 line */
375 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
376 unsigned char const * yuv_src[3];
377 off_t z;
378
379 if (!display_on || direct_fb_access)
380 return;
381
382 /* Sorry, but width and height must be >= 2 or else */
383 width &= ~1;
384 height >>= 1;
385
386 fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
387
388 z = stride*src_y;
389 yuv_src[0] = src[0] + z + src_x;
390 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
391 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
392
393 do
394 {
395 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
396 stride);
397
398 yuv_src[0] += stride << 1; /* Skip down two luma lines */
399 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
400 yuv_src[2] += stride >> 1;
401 dst -= 2;
402 }
403 while (--height > 0);
404}
405
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h
new file mode 100644
index 0000000000..da63187637
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _LCD_TARGET_H_
21#define _LCD_TARGET_H_
22
23extern void lcd_enable(bool state);
24
25void lcd_set_direct_fb(bool yes);
26bool lcd_get_direct_fb(void);
27
28#endif
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c
new file mode 100644
index 0000000000..6501125f9e
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "system.h"
20#include "kernel.h"
21#include "logf.h"
22#include "audio.h"
23#include "sound.h"
24#include "file.h"
25
26void pcm_postinit(void)
27{
28
29}
30
31const void * pcm_play_dma_get_peak_buffer(int *count)
32{
33 (void) count;
34 return 0;
35}
36
37void pcm_play_dma_init(void)
38{
39
40}
41
42void pcm_apply_settings(void)
43{
44
45}
46
47void pcm_set_frequency(unsigned int frequency)
48{
49 (void) frequency;
50}
51
52void pcm_play_dma_start(const void *addr, size_t size)
53{
54 (void) addr;
55 (void) size;
56}
57
58void pcm_play_dma_stop(void)
59{
60
61}
62
63void pcm_play_lock(void)
64{
65
66}
67
68void pcm_play_unlock(void)
69{
70
71}
72
73void pcm_play_dma_pause(bool pause)
74{
75 (void) pause;
76}
77
78size_t pcm_get_bytes_waiting(void)
79{
80 return 0;
81}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
new file mode 100644
index 0000000000..35e6bd31fb
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
@@ -0,0 +1,323 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Maurus Cuelenaere
11*
12* Creative Zen Vision:M interrupt based PIC driver
13*
14* All files in this archive are subject to the GNU General Public License.
15* See the file COPYING in the source tree root for full license agreement.
16*
17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18* KIND, either express or implied.
19*
20****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "kernel.h"
25#include "button-target.h"
26#include "i2c-dm320.h"
27
28
29#include "lcd-target.h"
30#include "lcd.h"
31#include "sprintf.h"
32#include "font.h"
33
34#ifndef ZEN_VISION
35/* Creative Zen Vision:M */
36#define BTN_LEFT 0x5F00
37#define BTN_RIGHT 0x4F00
38#define BTN_BACK 0xBF00
39#define BTN_CUSTOM 0x8F00
40#define BTN_PLAY 0x2F00
41#define BTN_POWER 0x0F00
42#define BTN_MENU 0x9F00
43#define BTN_HOLD 0x9F06
44#define BTN_UNHOLD 0xAF06
45
46#define BTN_REL 1
47
48#define BTN_TOUCHPAD_PRESS 0x1F00
49#define BTN_TOUCHPAD_CORNER_DOWN 0xAF00
50#define BTN_TOUCHPAD_CORNER_UP 0x3F00
51
52#define HEADPHONE_PLUGIN_A 0x5707
53#define HEADPHONE_PLUGIN_B 0x5F07
54#define HEADPHONE_UNPLUG_A 0x3707
55#define HEADPHONE_UNPLUG_B 0x3F07
56
57#define DOCK_INSERT 0x6707
58#define DOCK_UNPLUG 0xDF06
59#define DOCK_USB_INSERT 0x2F06
60#define DOCK_USB_UNPLUG 0x3F06
61#define DOCK_POWER_INSERT 0x2707
62#define DOCK_POWER_UNPLUG 0x2F07
63
64#else
65/* Creative Zen Vision */
66#define BTN_LEFT 0xCF00
67#define BTN_RIGHT 0xEF00
68#define BTN_BACK 0xBF00
69#define BTN_CUSTOM 0x0
70#define BTN_PLAY 0x2F00
71#define BTN_POWER 0x0F00
72#define BTN_MENU 0x9F00
73#define BTN_HOLD 0x9F06
74#define BTN_UNHOLD 0xAF06
75/* TODO: other values
76First number is just pressing it, second is when you release it or keep it pressed a bit longer
77On/Off = 0F00 && 0F01
78Hold = 9F06 && AF06
79Volume Up = 6F00 && 6F01
80Vol Down = 7F00 && 7F01
81Up = DF00 && DF01
82Right = EF00 && EF01
83Down = FF00 && FF01
84Left = CF00 && CF01
85Back = BF00 && BF01
86Menu = 9F00 && Etcetera
87Ok = 1F00
88Play = 2F00
89Next = 4F00
90Prev = 5F00
91
92USB = 2F06
93USB ouot = 3F06
94Headphones= AF06
95Hdphns out= BF06
96Charger = 4F06 -> 9F05
97Chgrout = 5F06 -> 8F05
98AV in = 8F06
99AV out = 9F06 */
100
101#define BTN_REL 1
102
103#define BTN_TOUCHPAD_PRESS 0x8F00
104#define BTN_TOUCHPAD_LONG_PRESS 0x0F00
105#define BTN_TOUCHPAD_CORNER_DOWN 0xD700
106#define BTN_TOUCHPAD_CORNER_LONG_DOWN 0x5700
107#define BTN_TOUCHPAD_CORNER_UP 0x9F00
108#define BTN_TOUCHPAD_CORNER_LONG_UP 0x1F00
109
110#define HEADPHONE_PLUGIN_A 0xAF06
111#define HEADPHONE_PLUGIN_B 0xAF06
112#define HEADPHONE_UNPLUG_A 0xBF06
113#define HEADPHONE_UNPLUG_B 0xBF06
114
115#define DOCK_INSERT 0x0
116#define DOCK_UNPLUG 0x0
117#define DOCK_USB_INSERT 0x2F06
118#define DOCK_USB_UNPLUG_A 0x3F06
119#define DOCK_USB_UNPLUG_B 0x3F06
120#define DOCK_POWER_INSERT 0x4F06
121#define DOCK_POWER_UNPLUG 0x5F06
122#define DOCK_AV_INSERT 0x8F06
123#define DOCK_AV_UNPLUG 0x9F06
124#endif
125
126#define PIC_ADR 0x07
127
128#define MASK_TV_OUT(x) ((x >> 14) & 1)
129#define MASK_xx1(x) ((x >> 9) & 3)
130#define MASK_xx2(x) ((x >> 4) & 1)
131#define MASK_xx3(x) ((x >> 5) & 1)
132#define MASK_xx4(x) ((x >> 6) & 1)
133#define MASK_xx5(x) ((x >> 13) & 1)
134#define MASK_xx6(x) ((x >> 12) & 1)
135#define MASK_xx7(x) ((x >> 11) & 1)
136
137#define NONBUTTON_HEADPHONE (1 << 0)
138#define NONBUTTON_DOCK (1 << 1)
139#define NONBUTTON_USB (1 << 2)
140#define NONBUTTON_POWER (1 << 3)
141#define NONBUTTON_VIDEOUT (1 << 4)
142
143static unsigned int btn;
144static bool hold_switch;
145static unsigned char nonbtn;
146static unsigned int pic_init_value;
147static unsigned int pic_init2_value;
148static unsigned int last_btn;
149static long last_tick;
150static int tick_diff;
151
152#define TICK_MIN 0x33
153#define TICK_MAX 0x34
154
155/* Taken from scramble.c and modified */
156static inline unsigned short le2short(unsigned char* buf)
157{
158 return (unsigned short)((buf[1] << 8) | buf[0]);
159}
160
161#define map_button(BtN,BtN2) case BtN: \
162 btn ^= BtN2; \
163 btn &= BtN2; \
164 break; \
165 case BtN ^ BTN_REL: \
166 btn ^= BtN2; \
167 btn &= BtN2; \
168 break;
169
170#ifdef BUTTON_DEBUG
171static bool sw = false;
172#endif
173
174void GIO0(void)
175{
176 unsigned char msg[4];
177 i2c_read(PIC_ADR, msg, sizeof(msg));
178 tick_diff = current_tick - last_tick;
179 last_tick = current_tick;
180 unsigned short btn_press = le2short(msg);
181 if(tick_diff >= TICK_MIN && tick_diff <= TICK_MAX)
182 {
183 /* Ignore this, as it is a hold event */
184 IO_INTC_IRQ1 = INTR_IRQ1_EXT0;
185 return;
186 }
187 last_btn = btn_press;
188 switch(btn_press)
189 {
190 map_button(BTN_LEFT, BUTTON_LEFT);
191 map_button(BTN_RIGHT, BUTTON_RIGHT);
192 map_button(BTN_BACK, BUTTON_BACK);
193 map_button(BTN_CUSTOM, BUTTON_CUSTOM);
194 map_button(BTN_MENU, BUTTON_MENU);
195 map_button(BTN_PLAY, BUTTON_PLAY);
196 map_button(BTN_POWER, BUTTON_POWER);
197 map_button(BTN_TOUCHPAD_PRESS, BUTTON_SELECT);
198 map_button(BTN_TOUCHPAD_CORNER_DOWN, BUTTON_DOWN);
199 map_button(BTN_TOUCHPAD_CORNER_UP, BUTTON_UP);
200 case BTN_HOLD:
201 hold_switch = true;
202 break;
203 case BTN_UNHOLD:
204 hold_switch = false;
205 break;
206 case HEADPHONE_PLUGIN_A:
207 case HEADPHONE_PLUGIN_B:
208 nonbtn |= NONBUTTON_HEADPHONE;
209 break;
210 case HEADPHONE_UNPLUG_A:
211 case HEADPHONE_UNPLUG_B:
212 nonbtn &= ~NONBUTTON_HEADPHONE;
213 break;
214 case DOCK_INSERT:
215 nonbtn |= NONBUTTON_DOCK;
216 break;
217 case DOCK_UNPLUG:
218 nonbtn &= ~(NONBUTTON_DOCK | NONBUTTON_USB | NONBUTTON_POWER);
219 break;
220 case DOCK_USB_INSERT:
221 nonbtn |= NONBUTTON_USB;
222 break;
223 case DOCK_USB_UNPLUG:
224 nonbtn &= ~NONBUTTON_USB;
225 break;
226 case DOCK_POWER_INSERT:
227 nonbtn |= NONBUTTON_POWER;
228 break;
229 case DOCK_POWER_UNPLUG:
230 nonbtn &= ~NONBUTTON_POWER;
231 break;
232 }
233#ifdef BUTTON_DEBUG
234 unsigned char weergvn[10];
235#ifdef BOOTLOADER
236 lcd_set_foreground((sw ? LCD_RGBPACK(255,0,0) : LCD_RGBPACK(0,255,0) ));
237#endif
238 snprintf(weergvn, sizeof(char)*10, "%x", (unsigned int)((msg[3] << 24) | (msg[2] << 16) | (msg[1] << 8) | msg[0]));
239 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*10, weergvn);
240 snprintf(weergvn, sizeof(char)*10, "%x", btn);
241 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*7, weergvn);
242#ifdef BOOTLOADER
243 lcd_set_foreground(LCD_BLACK);
244#endif
245 lcd_update();
246 sw = !sw;
247#endif
248 /* Mask GIO0 interrupt */
249 IO_INTC_IRQ1 = INTR_IRQ1_EXT0;
250}
251
252void send_command_to_pic(unsigned char in, unsigned char* out, unsigned int length)
253{
254 /* Disable GIO0 interrupt */
255 IO_INTC_EINT1 &= ~INTR_EINT1_EXT0;
256 /* Clear EXT0 interrupt */
257 IO_INTC_IRQ1 = INTR_IRQ1_EXT0;
258 /* Write command to I²C */
259 restart:
260 i2c_write(PIC_ADR, &in, 1);
261 /* Wait for PIC */
262 int i = 0;
263 while(!(IO_INTC_IRQ1 & INTR_IRQ1_EXT0))
264 {
265 sleep(0);
266 i++;
267 if(i > 50)
268 goto restart;
269 }
270 /* Read return from I²C */
271 i2c_read(PIC_ADR, out, length);
272 /* Re-enable GIO0 interrupt */
273 IO_INTC_EINT1 |= INTR_EINT1_EXT0;
274}
275
276bool headphones_inserted(void)
277{
278 return (bool)(nonbtn & NONBUTTON_HEADPHONE);
279}
280
281void button_init_device(void)
282{
283 /* TODO: I suppose GIO0 has to be set to input and enable interrupts on it? */
284 /* Enable GIO0 interrupt */
285 IO_INTC_EINT1 |= INTR_EINT1_EXT0;
286 btn = nonbtn = pic_init_value = pic_init2_value = last_btn = hold_switch = 0;
287 /* Initialize PIC */
288 send_command_to_pic(1, &pic_init_value, sizeof(pic_init_value));
289 send_command_to_pic(2, &pic_init2_value, sizeof(pic_init2_value));
290}
291
292int get_debug_info(int choice)
293{
294 switch(choice)
295 {
296 case 1:
297 return pic_init_value;
298 case 2:
299 return pic_init2_value;
300 case 3:
301 return last_btn;
302 case 4:
303 return nonbtn;
304 case 5:
305 return tick_diff;
306 }
307 return -1;
308}
309
310int button_read_device(void)
311{
312 return btn;
313}
314
315bool button_hold(void)
316{
317 return hold_switch;
318}
319
320bool button_usb_connected(void)
321{
322 return (bool)(nonbtn & NONBUTTON_USB);
323}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c
new file mode 100644
index 0000000000..5a72deced9
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include <stdbool.h>
23#include "kernel.h"
24#include "system.h"
25#include "power.h"
26#include "backlight.h"
27#include "backlight-target.h"
28
29#ifndef SIMULATOR
30
31void power_init(void)
32{
33 /* Initialize IDE power pin */
34 /* set ATA power on and output */
35 /* Charger detect */
36}
37
38bool charger_inserted(void)
39{
40 return false;
41}
42
43/* Returns true if the unit is charging the batteries. */
44bool charging_state(void) {
45 return false;
46}
47
48void power_off(void)
49{
50}
51
52#else /* SIMULATOR */
53
54bool charger_inserted(void)
55{
56 return false;
57}
58
59void charger_enable(bool on)
60{
61 (void)on;
62}
63
64void power_off(void)
65{
66}
67
68#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
new file mode 100644
index 0000000000..6e8ea7cae5
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
@@ -0,0 +1,57 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "adc.h"
22#include "powermgmt.h"
23#include "kernel.h"
24
25/* THIS CONTAINS CURRENTLY DUMMY CODE! */
26
27unsigned short current_voltage = 3910;
28const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
29{
30 0
31};
32
33const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
34{
35 0
36};
37
38/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
39const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
40{
41 { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 },
42};
43
44/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
45const unsigned short percent_to_volt_charge[11] =
46{
47 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
48};
49void read_battery_inputs(void)
50{
51}
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return current_voltage;
57}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
new file mode 100644
index 0000000000..6bbd08c135
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "system.h"
22#include "kernel.h"
23#include "usb.h"
24#include "usb-target.h"
25#include "usb_drv.h"
26#include "usb_core.h"
27#include "isp1583.h"
28
29#define printf
30
31bool usb_drv_connected(void)
32{
33 return button_usb_connected();
34}
35
36int usb_detect(void)
37{
38 if(button_usb_connected())
39 return USB_INSERTED;
40 else
41 return USB_EXTRACTED;
42}
43
44void usb_init_device(void)
45{
46 return;
47}
48
49void usb_enable(bool on)
50{
51 if(on)
52 usb_core_init();
53 else
54 usb_core_exit();
55}
56
57void GIO7(void)
58{
59#ifdef DEBUG
60 //printf("GIO7 interrupt... [%d]", current_tick);
61#endif
62 usb_drv_int();
63
64 IO_INTC_IRQ1 = INTR_IRQ1_EXT7;
65}
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h
new file mode 100644
index 0000000000..4e3303911c
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h
@@ -0,0 +1,76 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef USB_TARGET_H
21#define USB_TARGET_H
22
23#include "dm320.h"
24
25#define ISP1583_IOBASE 0x60FFC000
26#define ISP1583_H_OVERRIDE
27
28#define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char
29#define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2)))
30#define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char
31#define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char
32#define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2)))
33#define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4)))
34#define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) )
35/* Data flow registers */
36#define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char
37#define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char
38#define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2)))
39#define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2)))
40#define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char
41#define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2)))
42#define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2)))
43/* DMA registers */
44#define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2)))
45/* General registers */
46#define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2)))
47#define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4)))
48#define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16))
49#define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2)))
50#define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char
51#define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) )
52#define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2)))
53#define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2)))
54#define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2)))
55#define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char
56
57#define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7
58#define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7
59#define INT_CONF_TARGET 0
60//#define INT_CONF_TARGET 2
61#define set_int_value(a,b,value) a = value & 0xFFFF; \
62 b = value >> 16;
63
64
65#define ZVM_SPECIFIC asm volatile( \
66 "LDR R12, =0x50FFC000\n" \
67 "LDRH R12, [R12]\n" \
68 : : : "r12")
69//#define ZVM_SPECIFIC
70
71#include "kernel.h"
72int usb_detect(void);
73void usb_init_device(void);
74bool usb_drv_connected(void);
75
76#endif
diff --git a/firmware/target/arm/tms320dm320/crt0.S b/firmware/target/arm/tms320dm320/crt0.S
index 461afdd91a..8c3d36e086 100755
--- a/firmware/target/arm/tms320dm320/crt0.S
+++ b/firmware/target/arm/tms320dm320/crt0.S
@@ -153,7 +153,7 @@ start:
153 msr cpsr_c, #0xd3 153 msr cpsr_c, #0xd3
154 ldr sp, =stackend 154 ldr sp, =stackend
155 155
156#ifdef BOOTLOADER 156#if defined(BOOTLOADER) && !defined(CREATIVE_ZVM)
157 /* get the high part of our execute address */ 157 /* get the high part of our execute address */
158 ldr r2, =0xffffff00 158 ldr r2, =0xffffff00
159 and r4, pc, r2 159 and r4, pc, r2
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c
index 1a987b4dda..abfb5b09bc 100755
--- a/firmware/target/arm/tms320dm320/debug-dm320.c
+++ b/firmware/target/arm/tms320dm320/debug-dm320.c
@@ -27,18 +27,24 @@
27#include "sprintf.h" 27#include "sprintf.h"
28#include "font.h" 28#include "font.h"
29#include "debug-target.h" 29#include "debug-target.h"
30#include "lcd-target.h"
30 31
31bool __dbg_ports(void) 32bool __dbg_ports(void)
32{ 33{
33 return false; 34 return false;
34} 35}
35 36
37#ifndef CREATIVE_ZVM
36extern char r_buffer[5]; 38extern char r_buffer[5];
37extern int r_button; 39extern int r_button;
40#endif
38bool __dbg_hw_info(void) 41bool __dbg_hw_info(void)
39{ 42{
40 int line = 0, button, oldline; 43 int line = 0, oldline;
44 int button;
45#ifndef CREATIVE_ZVM
41 int *address=0x0; 46 int *address=0x0;
47#endif
42 bool done=false; 48 bool done=false;
43 char buf[100]; 49 char buf[100];
44 50
@@ -50,6 +56,7 @@ bool __dbg_hw_info(void)
50 lcd_puts(0, line++, "[Hardware info]"); 56 lcd_puts(0, line++, "[Hardware info]");
51 57
52 lcd_puts(0, line++, "Clock info:"); 58 lcd_puts(0, line++, "Clock info:");
59#if LCD_WIDTH > 320
53 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", 60 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
54 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf); 61 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf);
55 snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", 62 snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x",
@@ -58,12 +65,45 @@ bool __dbg_hw_info(void)
58 IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf); 65 IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf);
59 snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x", 66 snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x",
60 IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf); 67 IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf);
68#else
69 snprintf(buf, sizeof(buf), " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB);
70 lcd_puts(0, line++, buf);
71 snprintf(buf, sizeof(buf), " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_SEL0, IO_CLK_SEL1);
72 lcd_puts(0, line++, buf);
73 snprintf(buf, sizeof(buf), " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x", IO_CLK_SEL2, IO_CLK_DIV0);
74 lcd_puts(0, line++, buf);
75 snprintf(buf, sizeof(buf), " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", IO_CLK_DIV1, IO_CLK_DIV2);
76 lcd_puts(0, line++, buf);
77 snprintf(buf, sizeof(buf), " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x", IO_CLK_DIV3, IO_CLK_DIV4);
78 lcd_puts(0, line++, buf);
79 snprintf(buf, sizeof(buf), " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", IO_CLK_BYP, IO_CLK_INV);
80 lcd_puts(0, line++, buf);
81 snprintf(buf, sizeof(buf), " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ", IO_CLK_MOD0, IO_CLK_MOD1);
82 lcd_puts(0, line++, buf);
83 snprintf(buf, sizeof(buf), " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ", IO_CLK_MOD2, IO_CLK_LPCTL0);
84 lcd_puts(0, line++, buf);
85#endif
86
87 lcd_puts(0, line++, "Board revision:");
88 switch (IO_BUSC_REVR) {
89 case 0x0010:
90 lcd_puts(0, line++, " DM320 Rev. A");
91 break;
92 case 0x0011:
93 lcd_puts(0, line++, " DM320 Rev. B/C");
94 break;
95 default:
96 lcd_puts(0, line++, " Unknown DM320 Chip ID");
97 }
61 98
99#ifndef CREATIVE_ZVM
62 line++; 100 line++;
101#endif
63 oldline=line; 102 oldline=line;
64 while(!done) 103 while(!done)
65 { 104 {
66 line = oldline; 105 line = oldline;
106#ifndef CREATIVE_ZVM
67 button = button_get(false); 107 button = button_get(false);
68 button&=~BUTTON_REPEAT; 108 button&=~BUTTON_REPEAT;
69 if (button == BUTTON_POWER) 109 if (button == BUTTON_POWER)
@@ -81,14 +121,42 @@ bool __dbg_hw_info(void)
81 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf); 121 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
82 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x", 122 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
83 (unsigned int)button, r_button); lcd_puts(0, line++, buf); 123 (unsigned int)button, r_button); lcd_puts(0, line++, buf);
124#else
125 button = button_get(false);
126 if(button & BUTTON_POWER)
127 done = true;
128 else if(button & BUTTON_LEFT)
129 lcd_set_direct_fb(false);
130 else if(button & BUTTON_RIGHT)
131 lcd_set_direct_fb(true);
132
133 lcd_puts(0, line++, "PIC info:");
134 snprintf(buf, sizeof(buf), " Init value 1: 0x%04x", get_debug_info(1));
135 lcd_puts(0, line++, buf);
136 snprintf(buf, sizeof(buf), " Init value 2: 0x%04x", get_debug_info(2));
137 lcd_puts(0, line++, buf);
138 snprintf(buf, sizeof(buf), " Last button value: 0x%04x Raw value: 0x%04x", get_debug_info(3), button_read_device());
139 lcd_puts(0, line++, buf);
140 snprintf(buf, sizeof(buf), " Last button at: 0x%04x", get_debug_info(5));
141 lcd_puts(0, line++, buf);
142 snprintf(buf, sizeof(buf), " Dock values: 0x%04x", get_debug_info(4));
143 lcd_puts(0, line++, buf);
144 lcd_puts(0, line++, "LCD info:");
145 snprintf(buf, sizeof(buf), " LCD direct FB access? %s", (lcd_get_direct_fb() ? "yes" : "no"));
146 lcd_puts(0, line++, buf);
147 line++;
148#endif
149 lcd_puts(0, line++, "[Rockbox info]");
84 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", 150 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
85 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf); 151 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
152#ifndef CREATIVE_ZVM
86 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", 153 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
87 (unsigned int)address, *address); lcd_puts(0, line++, buf); 154 (unsigned int)address, *address); lcd_puts(0, line++, buf);
88 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", 155 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
89 (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf); 156 (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf);
90 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", 157 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
91 (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf); 158 (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf);
159#endif
92 160
93 lcd_update(); 161 lcd_update();
94 } 162 }
diff --git a/firmware/target/arm/tms320dm320/kernel-dm320.c b/firmware/target/arm/tms320dm320/kernel-dm320.c
index 6608aea096..2b2e783c3f 100644
--- a/firmware/target/arm/tms320dm320/kernel-dm320.c
+++ b/firmware/target/arm/tms320dm320/kernel-dm320.c
@@ -27,6 +27,10 @@ extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
27 27
28void tick_start(unsigned int interval_in_ms) 28void tick_start(unsigned int interval_in_ms)
29{ 29{
30/* TODO: set up TIMER1 clock settings
31 IO_CLK_MOD2 &= ~CLK_MOD2_TMR1; //disable TIMER1 clock
32 IO_CLK_SEL0 |= (1 << 2); //set TIMER1 clock to PLLIN*/
33 IO_CLK_MOD2 |= CLK_MOD2_TMR1; //enable TIMER1 clock!!!!!!!!!
30 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; 34 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
31 35
32 /* Setup the Prescalar (Divide by 10) 36 /* Setup the Prescalar (Divide by 10)
@@ -35,13 +39,13 @@ void tick_start(unsigned int interval_in_ms)
35 IO_TIMER1_TMPRSCL = 0x0009; 39 IO_TIMER1_TMPRSCL = 0x0009;
36 40
37 /* Setup the Divisor */ 41 /* Setup the Divisor */
38 IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; 42 IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms - 1;
39 43
40 /* Turn Timer1 to Free Run mode */ 44 /* Turn Timer1 to Free Run mode */
41 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN; 45 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN;
42 46
43 /* Enable the interrupt */ 47 /* Enable the interrupt */
44 IO_INTC_EINT0 |= 1<<IRQ_TIMER1; 48 IO_INTC_EINT0 |= INTR_EINT0_TMR1;
45} 49}
46 50
47void TIMER1(void) 51void TIMER1(void)
@@ -56,8 +60,7 @@ void TIMER1(void)
56 tick_funcs[i](); 60 tick_funcs[i]();
57 } 61 }
58 } 62 }
59
60 current_tick++; 63 current_tick++;
61 64
62 IO_INTC_IRQ0 = 1<<IRQ_TIMER1; 65 IO_INTC_IRQ0 = INTR_IRQ0_TMR1;
63} 66}
diff --git a/firmware/target/arm/tms320dm320/spi-dm320.c b/firmware/target/arm/tms320dm320/spi-dm320.c
index d8f338f592..a7b4fc678e 100644
--- a/firmware/target/arm/tms320dm320/spi-dm320.c
+++ b/firmware/target/arm/tms320dm320/spi-dm320.c
@@ -31,6 +31,7 @@
31#define GIO_TS_ENABLE (1<<2) 31#define GIO_TS_ENABLE (1<<2)
32#define GIO_RTC_ENABLE (1<<12) 32#define GIO_RTC_ENABLE (1<<12)
33#define GIO_BL_ENABLE (1<<13) 33#define GIO_BL_ENABLE (1<<13)
34#define GIO_LCD_ENABLE (1<<5)
34 35
35struct mutex spi_mtx; 36struct mutex spi_mtx;
36 37
@@ -39,14 +40,21 @@ struct SPI_info {
39 volatile unsigned short *clrreg; 40 volatile unsigned short *clrreg;
40 int bit; 41 int bit;
41}; 42};
42#define reg(a) ((volatile unsigned short *)(PHY_IO_BASE+a)) 43
43struct SPI_info spi_targets[] = 44struct SPI_info spi_targets[] =
44{ 45{
46#ifndef CREATIVE_ZVM
45 [SPI_target_TSC2100] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_TS_ENABLE }, 47 [SPI_target_TSC2100] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_TS_ENABLE },
46 [SPI_target_RX5X348AB] = { &IO_GIO_BITSET0, &IO_GIO_BITCLR0, GIO_RTC_ENABLE }, 48 [SPI_target_RX5X348AB] = { &IO_GIO_BITSET0, &IO_GIO_BITCLR0, GIO_RTC_ENABLE},
47 [SPI_target_BACKLIGHT] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_BL_ENABLE }, 49 [SPI_target_BACKLIGHT] = { &IO_GIO_BITCLR1, &IO_GIO_BITSET1, GIO_BL_ENABLE },
50#else
51 [SPI_target_LTV250QV] = { &IO_GIO_BITCLR2, &IO_GIO_BITSET2, GIO_LCD_ENABLE},
52#endif
48}; 53};
49 54
55#define IO_SERIAL0_XMIT (0x100)
56#define IO_SERIAL0_MODE_SCLK (1 << 10)
57
50static void spi_disable_all_targets(void) 58static void spi_disable_all_targets(void)
51{ 59{
52 int i; 60 int i;
@@ -70,7 +78,7 @@ int spi_block_transfer(enum SPI_target target,
70 IO_SERIAL0_TX_DATA = *tx_bytes++; 78 IO_SERIAL0_TX_DATA = *tx_bytes++;
71 79
72 /* Wait until transfer finished */ 80 /* Wait until transfer finished */
73 while (IO_SERIAL0_RX_DATA & 0x100); 81 while (IO_SERIAL0_RX_DATA & IO_SERIAL0_XMIT);
74 } 82 }
75 83
76 while (rx_size--) 84 while (rx_size--)
@@ -80,7 +88,7 @@ int spi_block_transfer(enum SPI_target target,
80 88
81 /* Wait until transfer finished */ 89 /* Wait until transfer finished */
82 unsigned short data; 90 unsigned short data;
83 while ((data = IO_SERIAL0_RX_DATA) & 0x100); 91 while ((data = IO_SERIAL0_RX_DATA) & IO_SERIAL0_XMIT);
84 92
85 *rx_bytes++ = data & 0xff; 93 *rx_bytes++ = data & 0xff;
86 } 94 }
@@ -95,14 +103,15 @@ void spi_init(void)
95{ 103{
96 mutex_init(&spi_mtx); 104 mutex_init(&spi_mtx);
97 /* Set SCLK idle level = 0 */ 105 /* Set SCLK idle level = 0 */
98 IO_SERIAL0_MODE |= 1<<10; 106 IO_SERIAL0_MODE |= IO_SERIAL0_MODE_SCLK;
99 /* Enable TX */ 107 /* Enable TX */
100 IO_SERIAL0_TX_ENABLE = 0x0001; 108 IO_SERIAL0_TX_ENABLE = 0x0001;
101 109#ifndef CREATIVE_ZVM
102 /* Set GIO 18 to output for touch screen slave enable */ 110 /* Set GIO 18 to output for touch screen slave enable */
103 IO_GIO_DIR1 &= ~GIO_TS_ENABLE; 111 IO_GIO_DIR1 &= ~GIO_TS_ENABLE;
104 /* Set GIO 12 to output for rtc slave enable */ 112 /* Set GIO 12 to output for rtc slave enable */
105 IO_GIO_DIR0 &= ~GIO_RTC_ENABLE; 113 IO_GIO_DIR0 &= ~GIO_RTC_ENABLE;
106 114#endif
107 spi_disable_all_targets(); /* make sure only one is ever enabled at a time */ 115 spi_disable_all_targets(); /* make sure only one is ever enabled at a time */
116
108} 117}
diff --git a/firmware/target/arm/tms320dm320/spi-target.h b/firmware/target/arm/tms320dm320/spi-target.h
index fe229d8bda..704867d92b 100644
--- a/firmware/target/arm/tms320dm320/spi-target.h
+++ b/firmware/target/arm/tms320dm320/spi-target.h
@@ -24,9 +24,13 @@
24#include <stdbool.h> 24#include <stdbool.h>
25 25
26enum SPI_target { 26enum SPI_target {
27#ifndef CREATIVE_ZVM
27 SPI_target_TSC2100 = 0, 28 SPI_target_TSC2100 = 0,
28 SPI_target_RX5X348AB, 29 SPI_target_RX5X348AB,
29 SPI_target_BACKLIGHT, 30 SPI_target_BACKLIGHT,
31#else
32 SPI_target_LTV250QV = 0,
33#endif
30 SPI_MAX_TARGETS, 34 SPI_MAX_TARGETS,
31}; 35};
32 36
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c
index da3b9913a2..c03e05522c 100644
--- a/firmware/target/arm/tms320dm320/system-dm320.c
+++ b/firmware/target/arm/tms320dm320/system-dm320.c
@@ -114,7 +114,12 @@ void irq_handler(void)
114 114
115 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ 115 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */
116 "sub sp, sp, #8 \n"); /* Reserve stack */ 116 "sub sp, sp, #8 \n"); /* Reserve stack */
117 irqvector[(IO_INTC_IRQENTRY0>>2)-1](); 117 unsigned short addr = IO_INTC_IRQENTRY0>>2;
118 if(addr != 0)
119 {
120 addr--;
121 irqvector[addr]();
122 }
118 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ 123 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */
119 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ 124 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */
120 "subs pc, lr, #4 \n"); /* Return from FIQ */ 125 "subs pc, lr, #4 \n"); /* Return from FIQ */
@@ -130,18 +135,34 @@ void fiq_handler(void)
130 "sub lr, lr, #4 \r\n" 135 "sub lr, lr, #4 \r\n"
131 "stmfd sp!, {r0-r3, ip, lr} \r\n" 136 "stmfd sp!, {r0-r3, ip, lr} \r\n"
132 "mov r0, #0x00030000 \r\n" 137 "mov r0, #0x00030000 \r\n"
133 "ldr r0, [r0, #0x518] \r\n" 138 "ldr r0, [r0, #0x518] \r\n"
139 "sub r0, r0, #1 \r\n"
134 "ldr r1, =irqvector \r\n" 140 "ldr r1, =irqvector \r\n"
135 "ldr r1, [r1, r0, lsl #2] \r\n" 141 "ldr r1, [r1, r0, lsl #2] \r\n"
136 "mov lr, pc \r\n" 142 "blx r1 \r\n"
137 "bx r1 \r\n"
138 "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" 143 "ldmfd sp!, {r0-r3, ip, pc}^ \r\n"
139 ); 144 );
140} 145}
141 146
142void system_reboot(void) 147void system_reboot(void)
143{ 148{
144 149 /* Code taken from linux/include/asm-arm/arch-itdm320-20/system.h at NeuroSVN */
150 __asm__ __volatile__(
151 "mov ip, #0 \n"
152 "mcr p15, 0, ip, c7, c7, 0 @ invalidate cache \n"
153 "mcr p15, 0, ip, c7, c10,4 @ drain WB \n"
154 "mcr p15, 0, ip, c8, c7, 0 @ flush TLB (v4) \n"
155 "mrc p15, 0, ip, c1, c0, 0 @ get ctrl register\n"
156 "bic ip, ip, #0x000f @ ............wcam \n"
157 "bic ip, ip, #0x2100 @ ..v....s........ \n"
158 "mcr p15, 0, ip, c1, c0, 0 @ ctrl register \n"
159 "mov ip, #0xFF000000 \n"
160 "orr ip, ip, #0xFF0000 @ ip = 0xFFFF0000 \n"
161 "mov pc, ip \n"
162 :
163 :
164 : "cc"
165 );
145} 166}
146 167
147void system_init(void) 168void system_init(void)
@@ -167,16 +188,28 @@ void system_init(void)
167 IO_INTC_FISEL1 = 0; 188 IO_INTC_FISEL1 = 0;
168 IO_INTC_FISEL2 = 0; 189 IO_INTC_FISEL2 = 0;
169 190
191 /* IRQENTRY only reflects enabled interrupts */
192 IO_INTC_RAW = 0;
193
170 IO_INTC_ENTRY_TBA0 = 0; 194 IO_INTC_ENTRY_TBA0 = 0;
171 IO_INTC_ENTRY_TBA1 = 0; 195 IO_INTC_ENTRY_TBA1 = 0;
172 196
173 /* Turn off other timers */ 197 unsigned short i;
198 /* Reset interrupt priorities to default values */
199 for(i = 0; i < 23; i++)
200 DM320_REG(0x0540+i*2) = ( (i*2+1) << 8 ) | i*2 ;//IO_INTC_PRIORITYx
201
202 /* Turn off all timers */
203 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
204 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
174 IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP; 205 IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP;
175 IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP; 206 IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP;
176 207
208#ifndef CREATIVE_ZVM
177 /* set GIO26 (reset pin) to output and low */ 209 /* set GIO26 (reset pin) to output and low */
178 IO_GIO_BITCLR1=(1<<10); 210 IO_GIO_BITCLR1=(1<<10);
179 IO_GIO_DIR1&=~(1<<10); 211 IO_GIO_DIR1&=~(1<<10);
212#endif
180 213
181 uart_init(); 214 uart_init();
182 spi_init(); 215 spi_init();
@@ -186,9 +219,18 @@ void system_init(void)
186 /* Make sure everything is mapped on itself */ 219 /* Make sure everything is mapped on itself */
187 map_section(0, 0, 0x1000, CACHE_NONE); 220 map_section(0, 0, 0x1000, CACHE_NONE);
188 /* Enable caching for RAM */ 221 /* Enable caching for RAM */
189 map_section(0x00900000, 0x00900000, 64, CACHE_ALL); 222 map_section(CONFIG_SDRAM_START, CONFIG_SDRAM_START, MEM, CACHE_ALL);
190 /* enable buffered writing for the framebuffer */ 223 /* enable buffered writing for the framebuffer */
191 map_section((int)FRAME, (int)FRAME, 1, BUFFERED); 224 map_section((int)FRAME, (int)FRAME, 1, BUFFERED);
225#ifdef CREATIVE_ZVM
226 //mimic OF
227 map_section(0x00100000, 0x00100000, 4, CACHE_NONE);
228 map_section(0x04700000, 0x04700000, 2, BUFFERED);
229 map_section(0x40000000, 0x40000000, 16, CACHE_NONE);
230 map_section(0x50000000, 0x50000000, 16, CACHE_NONE);
231 map_section(0x60000000, 0x60000000, 16, CACHE_NONE);
232 map_section(0x80000000, 0x80000000, 1, CACHE_NONE);
233#endif
192 enable_mmu(); 234 enable_mmu();
193} 235}
194 236
diff --git a/firmware/target/arm/tms320dm320/timer-dm320.c b/firmware/target/arm/tms320dm320/timer-dm320.c
index 7895005d46..52b433fac5 100644
--- a/firmware/target/arm/tms320dm320/timer-dm320.c
+++ b/firmware/target/arm/tms320dm320/timer-dm320.c
@@ -24,12 +24,12 @@
24#include "logf.h" 24#include "logf.h"
25 25
26/* GPB0/TOUT0 should already have been configured as output so that pin 26/* GPB0/TOUT0 should already have been configured as output so that pin
27 should not be a functional pin and TIMER0 output unseen there */ 27 should not be a functional pin and TIMER0 output unseen there */
28void TIMER0(void) 28void TIMER0(void)
29{ 29{
30 if (pfn_timer != NULL) 30 if (pfn_timer != NULL)
31 pfn_timer(); 31 pfn_timer();
32 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0; 32 IO_INTC_IRQ0 = INTR_IRQ0_TMR0; //clear TIMER0 interrupt
33} 33}
34 34
35bool __timer_set(long cycles, bool start) 35bool __timer_set(long cycles, bool start)
@@ -40,6 +40,10 @@ bool __timer_set(long cycles, bool start)
40 if(cycles<1) 40 if(cycles<1)
41 return false; 41 return false;
42 42
43 oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
44
45 IO_CLK_MOD2 |= CLK_MOD2_TMR0; //enable TIMER0 clock!!!!!!!!!
46
43 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP; 47 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
44 48
45 if (start && pfn_unregister != NULL) 49 if (start && pfn_unregister != NULL)
@@ -67,23 +71,27 @@ bool __timer_set(long cycles, bool start)
67 71
68static void stop_timer(void) 72static void stop_timer(void)
69{ 73{
70 IO_INTC_EINT0 &= ~(1<<IRQ_TIMER0); 74 IO_INTC_EINT0 &= ~INTR_EINT0_TMR0; //disable TIMER0 interrupt
71 75
72 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0; 76 IO_INTC_IRQ0 = INTR_IRQ0_TMR0; //clear TIMER0 interrupt
73 77
74 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP; 78 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
79
80 IO_CLK_MOD2 &= ~CLK_MOD2_TMR0; //disable TIMER0 clock
75} 81}
76 82
77bool __timer_register(void) 83bool __timer_register(void)
78{ 84{
79 int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS); 85 int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS);
80 86
81 stop_timer(); 87 stop_timer();
88
89 IO_CLK_MOD2 |= CLK_MOD2_TMR0; //enable TIMER0 clock!!!!!!!!!
82 90
83 /* Turn Timer0 to Free Run mode */ 91 /* Turn Timer0 to Free Run mode */
84 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN; 92 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN;
85 93
86 IO_INTC_EINT0 |= 1<<IRQ_TIMER0; 94 IO_INTC_EINT0 |= INTR_EINT0_TMR0; //enable TIMER0 interrupt
87 95
88 restore_interrupt(oldstatus); 96 restore_interrupt(oldstatus);
89 97
diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c
index 151ad2921c..c3dd5459eb 100644
--- a/firmware/target/arm/tms320dm320/uart-dm320.c
+++ b/firmware/target/arm/tms320dm320/uart-dm320.c
@@ -50,7 +50,7 @@ void uart_init(void)
50 uart1_recieve_write=0; 50 uart1_recieve_write=0;
51 51
52 /* Enable the interrupt */ 52 /* Enable the interrupt */
53 IO_INTC_EINT0 |= (1<<IRQ_UART1); 53 IO_INTC_EINT0 |= INTR_EINT0_UART1;
54} 54}
55 55
56void uart1_putc(char ch) 56void uart1_putc(char ch)
@@ -75,7 +75,7 @@ void uart1_puts(const char *str, int size)
75/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/ 75/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/
76int uart1_gets_queue(char *str, unsigned int size) 76int uart1_gets_queue(char *str, unsigned int size)
77{ 77{
78 IO_INTC_EINT0 &= ~(1<<IRQ_UART1); 78 IO_INTC_EINT0 &= ~INTR_EINT0_UART1;
79 int retval; 79 int retval;
80 80
81 if(uart1_recieve_count<size) 81 if(uart1_recieve_count<size)
@@ -106,7 +106,7 @@ int uart1_gets_queue(char *str, unsigned int size)
106 } 106 }
107 107
108 /* Enable the interrupt */ 108 /* Enable the interrupt */
109 IO_INTC_EINT0 |= (1<<IRQ_UART1); 109 IO_INTC_EINT0 |= INTR_EINT0_UART1;
110 110
111 return retval; 111 return retval;
112} 112}
@@ -129,5 +129,5 @@ void UART1(void)
129 } 129 }
130 } 130 }
131 131
132 IO_INTC_IRQ0 = (1<<IRQ_UART1); 132 IO_INTC_IRQ0 = INTR_IRQ0_UART1;
133} 133}
diff --git a/firmware/thread.c b/firmware/thread.c
index 7ece27f4a6..9705293e9e 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -802,6 +802,16 @@ static inline void core_sleep(void)
802 ); 802 );
803 enable_irq(); 803 enable_irq();
804} 804}
805#elif CONFIG_CPU == DM320
806static inline void core_sleep(void)
807{
808 asm volatile (
809 "mov r0, #0 \n"
810 "mcr p15, 0, r0, c7, c0, 4 \n" /* Wait for interrupt */
811 : : : "r0"
812 );
813 enable_irq();
814}
805#else 815#else
806static inline void core_sleep(void) 816static inline void core_sleep(void)
807{ 817{
diff --git a/firmware/timer.c b/firmware/timer.c
index 3d522efd41..bd9050f872 100644
--- a/firmware/timer.c
+++ b/firmware/timer.c
@@ -316,7 +316,7 @@ void timer_unregister(void)
316#elif CONFIG_CPU == PNX0101 316#elif CONFIG_CPU == PNX0101
317 TIMER1.ctrl &= ~0x80; /* disable timer 1 */ 317 TIMER1.ctrl &= ~0x80; /* disable timer 1 */
318 irq_disable_int(IRQ_TIMER1); 318 irq_disable_int(IRQ_TIMER1);
319#elif CONFIG_CPU == S3C2440 319#elif CONFIG_CPU == S3C2440 || CONFIG_CPU == DM320
320 __TIMER_UNREGISTER(); 320 __TIMER_UNREGISTER();
321#endif 321#endif
322 pfn_timer = NULL; 322 pfn_timer = NULL;
diff --git a/firmware/usb.c b/firmware/usb.c
index 6cc3337d82..3867bfb496 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -47,7 +47,8 @@
47 47
48/* Conditions under which we want the entire driver */ 48/* Conditions under which we want the entire driver */
49#if !defined(BOOTLOADER) || \ 49#if !defined(BOOTLOADER) || \
50 (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) 50 (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \
51 (defined(CREATIVE_ZVM) && defined(HAVE_USBSTACK))
51#define USB_FULL_INIT 52#define USB_FULL_INIT
52#endif 53#endif
53 54
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 9e9e356c36..693d50c009 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -359,7 +359,7 @@ void usb_storage_init_connection(int interface,int endpoint)
359 /* prime rx endpoint. We only need room for commands */ 359 /* prime rx endpoint. We only need room for commands */
360 state = WAITING_FOR_COMMAND; 360 state = WAITING_FOR_COMMAND;
361 361
362#if CONFIG_CPU == IMX31L 362#if CONFIG_CPU == IMX31L || CONFIG_USBOTG == USBOTG_ISP1583
363 static unsigned char _transfer_buffer[BUFFER_SIZE*2] 363 static unsigned char _transfer_buffer[BUFFER_SIZE*2]
364 USBDEVBSS_ATTR __attribute__((aligned(32))); 364 USBDEVBSS_ATTR __attribute__((aligned(32)));
365 tb.transfer_buffer = (void *)_transfer_buffer; 365 tb.transfer_buffer = (void *)_transfer_buffer;
diff --git a/tools/configure b/tools/configure
index 151a4b70ff..93a0484b6a 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1461,12 +1461,12 @@ fi
1461 bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 1461 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
1462 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" 1462 bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0"
1463 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" 1463 bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0"
1464 tool="cp" 1464 tool="$rootdir/tools/scramble -creative=zvm"
1465 output="rockbox.zvm" 1465 output="rockbox.zvm"
1466 appextra="recorder:gui" 1466 appextra="recorder:gui"
1467 plugins="" 1467 plugins=""
1468 swcodec="yes" 1468 swcodec="yes"
1469 toolset=$gigabeatbitmaptools 1469 toolset=$ipodbitmaptools
1470 boottool="$rootdir/tools/scramble -creative=zvm" 1470 boottool="$rootdir/tools/scramble -creative=zvm"
1471 bootoutput="rockbox.zvmboot" 1471 bootoutput="rockbox.zvmboot"
1472 # architecture, manufacturer and model for the target-tree build 1472 # architecture, manufacturer and model for the target-tree build
diff --git a/tools/scramble.c b/tools/scramble.c
index 7aad4bfa92..a17b16efaa 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -117,7 +117,7 @@ void usage(void)
117 "\t-add=X Rockbox generic \"add-up\" checksum format\n" 117 "\t-add=X Rockbox generic \"add-up\" checksum format\n"
118 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n" 118 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n"
119 "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n" 119 "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n"
120 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2)\n"); 120 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2, zvm)\n");
121 printf("\nNo option results in Archos standard player/recorder format.\n"); 121 printf("\nNo option results in Archos standard player/recorder format.\n");
122 122
123 exit(1); 123 exit(1);
@@ -269,6 +269,8 @@ int main (int argc, char** argv)
269 modelnum = 24; 269 modelnum = 24;
270 else if(!strcmp(&argv[1][5], "iam3")) 270 else if(!strcmp(&argv[1][5], "iam3"))
271 modelnum = 25; 271 modelnum = 25;
272 else if(!strcmp(&argv[1][5], "zvm"))
273 modelnum = 26;
272 else { 274 else {
273 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 275 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
274 return 2; 276 return 2;
@@ -344,6 +346,8 @@ int main (int argc, char** argv)
344 return zvm_encode(iname, oname, ZENVISION); 346 return zvm_encode(iname, oname, ZENVISION);
345 else if(!strcmp(&argv[1][10], "zenv")) 347 else if(!strcmp(&argv[1][10], "zenv"))
346 return zvm_encode(iname, oname, ZENV); 348 return zvm_encode(iname, oname, ZENV);
349 else if(!strcmp(&argv[1][10], "zen"))
350 return zvm_encode(iname, oname, ZEN);
347 else { 351 else {
348 fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]); 352 fprintf(stderr, "unsupported Creative device: %s\n", &argv[1][10]);
349 return 2; 353 return 2;