diff options
author | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
commit | 28f6ae49ec1b1d3464add2941eb015bab56f8016 (patch) | |
tree | 6d4cddba129663340cf2f30212a516acdd16a4eb | |
parent | d3e101bd1184e5c1f474ff0978f65ac7e8e2dbfb (diff) | |
download | rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.gz rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.zip |
Initial work on a port to the Logik DAX 1GB MP3/DAB player. The bootloader build compiles and runs (but only displays some debugging info), and the LCD and ADC drivers are working. Two different bootloader builds are possible: 1) The default build is just a test application for uploading to the device via tcctool; 2) Adding -DTCCBOOT to EXTRA_DEFINES in the build directory Makefile will compile the bootloader so that it can be appended to the end of the original firmware and installed on the device, dual-booting. This commit also includes some work by Hein-Pieter van Braam on a port to the iAudio 7, but that doesn't build yet. A large part of these ports will be generic to all TCC77x devices - see the TelechipsInfo wiki page for some other devices with this CPU. NOTE: Compiling these builds requires an arm-elf-gcc with armv5 support - the current version of rockboxdev.sh compiles such a gcc.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15339 a1c6a512-1295-4272-9138-f99709370657
24 files changed, 1594 insertions, 7 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 919e002f1b..11dfb667ae 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -22,6 +22,8 @@ iaudio_x5.c | |||
22 | iriver_h300.c | 22 | iriver_h300.c |
23 | #elif defined(MROBE_500) | 23 | #elif defined(MROBE_500) |
24 | mrobe500.c | 24 | mrobe500.c |
25 | #elif defined(CPU_TCC77X) | ||
26 | telechips.c | ||
25 | #else | 27 | #else |
26 | main.c | 28 | main.c |
27 | #endif | 29 | #endif |
diff --git a/bootloader/telechips.c b/bootloader/telechips.c new file mode 100644 index 0000000000..c1dcda0dae --- /dev/null +++ b/bootloader/telechips.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
11 | * | ||
12 | * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing | ||
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 | #include "config.h" | ||
22 | |||
23 | #include <stdlib.h> | ||
24 | #include <stdio.h> | ||
25 | #include <string.h> | ||
26 | #include "cpu.h" | ||
27 | #include "system.h" | ||
28 | #include "lcd.h" | ||
29 | #include "kernel.h" | ||
30 | #include "thread.h" | ||
31 | #include "ata.h" | ||
32 | #include "fat.h" | ||
33 | #include "disk.h" | ||
34 | #include "font.h" | ||
35 | #include "adc.h" | ||
36 | #include "adc-target.h" | ||
37 | #include "backlight-target.h" | ||
38 | #include "panic.h" | ||
39 | #include "power.h" | ||
40 | #include "file.h" | ||
41 | #include "common.h" | ||
42 | |||
43 | char version[] = APPSVERSION; | ||
44 | |||
45 | extern int line; | ||
46 | |||
47 | void* main(void) | ||
48 | { | ||
49 | unsigned short button; | ||
50 | int gpioa; | ||
51 | |||
52 | system_init(); | ||
53 | adc_init(); | ||
54 | lcd_init(); | ||
55 | font_init(); | ||
56 | |||
57 | __backlight_on(); | ||
58 | |||
59 | while(1) { | ||
60 | line = 0; | ||
61 | printf("Hello World!"); | ||
62 | |||
63 | gpioa = GPIOA; | ||
64 | printf("GPIOA: 0x%08x",gpioa); | ||
65 | |||
66 | button = adc_read(ADC_BUTTONS); | ||
67 | printf("ADC[0]: 0x%04x",button); | ||
68 | } | ||
69 | |||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | /* These functions are present in the firmware library, but we reimplement | ||
74 | them here because the originals do a lot more than we want */ | ||
75 | void usb_acknowledge(void) | ||
76 | { | ||
77 | } | ||
78 | |||
79 | void usb_wait_for_disconnect(void) | ||
80 | { | ||
81 | } | ||
diff --git a/firmware/FILES b/firmware/FILES index a3cfc0c8c2..1882f3dd07 100644 --- a/firmware/FILES +++ b/firmware/FILES | |||
@@ -25,6 +25,8 @@ target/arm/archos/av300/*.[chS] | |||
25 | target/arm/s3c2440/gigabeat-fx/*.[chS] | 25 | target/arm/s3c2440/gigabeat-fx/*.[chS] |
26 | target/arm/iriver/*.[chS] | 26 | target/arm/iriver/*.[chS] |
27 | target/arm/iriver/h10/*.[chS] | 27 | target/arm/iriver/h10/*.[chS] |
28 | target/arm/tcc77x/*.[chS] | ||
29 | target/arm/tcc77x/logikdax/*.[chS] | ||
28 | target/arm/tms320dm320/*.[chS] | 30 | target/arm/tms320dm320/*.[chS] |
29 | target/arm/tms320dm320/mrobe-500/*.[chS] | 31 | target/arm/tms320dm320/mrobe-500/*.[chS] |
30 | target/arm/pnx0101/*.[chS] | 32 | target/arm/pnx0101/*.[chS] |
diff --git a/firmware/SOURCES b/firmware/SOURCES index 9e501b661a..5061ac7370 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -111,7 +111,7 @@ drivers/ata_mmc.c | |||
111 | #ifdef HAVE_FLASH_DISK | 111 | #ifdef HAVE_FLASH_DISK |
112 | drivers/ata_flash.c | 112 | drivers/ata_flash.c |
113 | #else /* !HAVE_FLASH_DISK */ | 113 | #else /* !HAVE_FLASH_DISK */ |
114 | #if !defined(SANSA_E200) && !defined(SANSA_C200) | 114 | #if !defined(SANSA_E200) && !defined(SANSA_C200) && !defined(LOGIK_DAX) && !defined(IAUDIO_7) |
115 | drivers/ata.c | 115 | drivers/ata.c |
116 | #endif /* SANSA_E200 */ | 116 | #endif /* SANSA_E200 */ |
117 | #endif /* HAVE_FLASH_DISK */ | 117 | #endif /* HAVE_FLASH_DISK */ |
@@ -336,6 +336,8 @@ target/arm/crt0-pp.S | |||
336 | target/arm/pnx0101/crt0-pnx0101.S | 336 | target/arm/pnx0101/crt0-pnx0101.S |
337 | #elif defined(OLYMPUS_MROBE_500) | 337 | #elif defined(OLYMPUS_MROBE_500) |
338 | target/arm/tms320dm320/crt0.S | 338 | target/arm/tms320dm320/crt0.S |
339 | #elif defined(CPU_TCC77X) | ||
340 | target/arm/tcc77x/crt0.S | ||
339 | #elif defined(CPU_ARM) | 341 | #elif defined(CPU_ARM) |
340 | target/arm/crt0.S | 342 | target/arm/crt0.S |
341 | #endif /* defined(CPU_*) */ | 343 | #endif /* defined(CPU_*) */ |
@@ -814,3 +816,22 @@ target/arm/pnx0101/pcm-pnx0101.c | |||
814 | #endif /* SIMULATOR */ | 816 | #endif /* SIMULATOR */ |
815 | #endif /* IRIVER_IFP7XX */ | 817 | #endif /* IRIVER_IFP7XX */ |
816 | 818 | ||
819 | #ifdef LOGIK_DAX | ||
820 | #ifndef SIMULATOR | ||
821 | target/arm/tcc77x/adc-tcc77x.c | ||
822 | target/arm/tcc77x/ata-nand-tcc77x.c | ||
823 | target/arm/tcc77x/system-tcc77x.c | ||
824 | target/arm/tcc77x/logikdax/lcd-logikdax.c | ||
825 | target/arm/tcc77x/logikdax/power-logikdax.c | ||
826 | #endif /* SIMULATOR */ | ||
827 | #endif /* LOGIK_DAX */ | ||
828 | |||
829 | #ifdef IAUDIO_7 | ||
830 | #ifndef SIMULATOR | ||
831 | target/arm/tcc77x/adc-tcc77x.c | ||
832 | target/arm/tcc77x/ata-nand-tcc77x.c | ||
833 | target/arm/tcc77x/system-tcc77x.c | ||
834 | target/arm/tcc77x/iaudio7/lcd-iaudio7.c | ||
835 | target/arm/tcc77x/iaudio7/power-iaudio7.c | ||
836 | #endif /* SIMULATOR */ | ||
837 | #endif /* IAUDIO_7 */ | ||
diff --git a/firmware/boot.lds b/firmware/boot.lds index a8404134ae..d2ea10a30d 100644 --- a/firmware/boot.lds +++ b/firmware/boot.lds | |||
@@ -11,6 +11,8 @@ OUTPUT_ARCH(arm) | |||
11 | INPUT(target/arm/crt0-pp-bl.o) | 11 | INPUT(target/arm/crt0-pp-bl.o) |
12 | #elif defined(OLYMPUS_MROBE_500) | 12 | #elif defined(OLYMPUS_MROBE_500) |
13 | INPUT(target/arm/tms320dm320/crt0.o) | 13 | INPUT(target/arm/tms320dm320/crt0.o) |
14 | #elif defined(CPU_TCC77X) | ||
15 | INPUT(target/arm/tcc77x/crt0.o) | ||
14 | #else | 16 | #else |
15 | INPUT(target/arm/crt0.o) | 17 | INPUT(target/arm/crt0.o) |
16 | #endif | 18 | #endif |
@@ -77,6 +79,12 @@ INPUT(target/sh/crt0.o) | |||
77 | #define IRAMSIZE 16K | 79 | #define IRAMSIZE 16K |
78 | #define FLASHORIG 0x0000000 | 80 | #define FLASHORIG 0x0000000 |
79 | #define FLASHSIZE 1M | 81 | #define FLASHSIZE 1M |
82 | #elif defined(CPU_TCC77X) | ||
83 | #define DRAMORIG 0x20000000 | ||
84 | #define IRAMORIG 0x00000000 | ||
85 | #define IRAMSIZE 64K | ||
86 | #define FLASHORIG 0x0000000 | ||
87 | #define FLASHSIZE 1M | ||
80 | #else | 88 | #else |
81 | #define DRAMORIG 0x09000000 | 89 | #define DRAMORIG 0x09000000 |
82 | #define IRAMORIG 0x0f000000 | 90 | #define IRAMORIG 0x0f000000 |
@@ -85,7 +93,17 @@ INPUT(target/sh/crt0.o) | |||
85 | #define FLASHSIZE 256K - ROM_START | 93 | #define FLASHSIZE 256K - ROM_START |
86 | #endif | 94 | #endif |
87 | 95 | ||
88 | #if !defined(CPU_PP) && (CONFIG_CPU!=S3C2440) && (CONFIG_CPU!=IMX31L) | 96 | #if defined(CPU_TCC77X) |
97 | MEMORY | ||
98 | { | ||
99 | #ifdef TCCBOOT | ||
100 | DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 | ||
101 | #else | ||
102 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
103 | #endif | ||
104 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | ||
105 | } | ||
106 | #elif !defined(CPU_PP) && (CONFIG_CPU!=S3C2440) && (CONFIG_CPU!=IMX31L) | ||
89 | MEMORY | 107 | MEMORY |
90 | { | 108 | { |
91 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | 109 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE |
@@ -168,6 +186,43 @@ SECTIONS | |||
168 | _end = .; | 186 | _end = .; |
169 | } | 187 | } |
170 | } | 188 | } |
189 | #elif defined(CPU_TCC77X) | ||
190 | { | ||
191 | .text : { | ||
192 | *(.init.text) | ||
193 | *(.text) | ||
194 | *(.text*) | ||
195 | *(.glue_7) | ||
196 | *(.glue_7t) | ||
197 | } > DRAM | ||
198 | |||
199 | .data : { | ||
200 | *(.icode) | ||
201 | *(.irodata) | ||
202 | *(.idata) | ||
203 | *(.data*) | ||
204 | *(.rodata.*) | ||
205 | . = ALIGN(0x4); | ||
206 | _dataend = . ; | ||
207 | } > DRAM | ||
208 | |||
209 | .stack : | ||
210 | { | ||
211 | *(.stack) | ||
212 | _stackbegin = .; | ||
213 | stackbegin = .; | ||
214 | . += 0x2000; | ||
215 | _stackend = .; | ||
216 | stackend = .; | ||
217 | } > DRAM | ||
218 | .bss : { | ||
219 | _edata = .; | ||
220 | *(.bss*); | ||
221 | *(.ibss); | ||
222 | *(COMMON) | ||
223 | _end = .; | ||
224 | } > DRAM | ||
225 | } | ||
171 | #elif (CONFIG_CPU==DM320) | 226 | #elif (CONFIG_CPU==DM320) |
172 | { | 227 | { |
173 | . = DRAMORIG + 0x1000000; | 228 | . = DRAMORIG + 0x1000000; |
diff --git a/firmware/export/config-logikdax.h b/firmware/export/config-logikdax.h new file mode 100644 index 0000000000..384dac4e11 --- /dev/null +++ b/firmware/export/config-logikdax.h | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * This config file is for the Logik DAX MP3/DAB | ||
3 | */ | ||
4 | #define TARGET_TREE /* this target is using the target tree system */ | ||
5 | |||
6 | /* For Rolo and boot loader */ | ||
7 | #define MODEL_NUMBER 23 | ||
8 | |||
9 | /* define this if you have recording possibility */ | ||
10 | //#define HAVE_RECORDING | ||
11 | |||
12 | /* Define bitmask of input sources - recordable bitmask can be defined | ||
13 | explicitly if different */ | ||
14 | //#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_SPDIF) | ||
15 | |||
16 | /* define this if you have a bitmap LCD display */ | ||
17 | #define HAVE_LCD_BITMAP | ||
18 | |||
19 | /* define this if you can flip your LCD */ | ||
20 | #define HAVE_LCD_FLIP | ||
21 | |||
22 | /* define this if you can invert the colours on your LCD */ | ||
23 | #define HAVE_LCD_INVERT | ||
24 | |||
25 | /* define this if you have access to the quickscreen */ | ||
26 | #define HAVE_QUICKSCREEN | ||
27 | /* define this if you have access to the pitchscreen */ | ||
28 | #define HAVE_PITCHSCREEN | ||
29 | |||
30 | /* define this if you would like tagcache to build on this target */ | ||
31 | #define HAVE_TAGCACHE | ||
32 | |||
33 | /* define this if you have a flash memory storage */ | ||
34 | #define HAVE_FLASH_STORAGE | ||
35 | |||
36 | /* LCD dimensions */ | ||
37 | #define LCD_WIDTH 128 | ||
38 | #define LCD_HEIGHT 64 | ||
39 | #define LCD_DEPTH 1 | ||
40 | |||
41 | #define LCD_PIXELFORMAT VERTICAL_PACKING | ||
42 | |||
43 | /* define this to indicate your device's keypad */ | ||
44 | #define CONFIG_KEYPAD LOGIK_DAX_PAD | ||
45 | |||
46 | /* define this if you have a real-time clock */ | ||
47 | #define CONFIG_RTC RTC_TCC77X | ||
48 | |||
49 | /* define this if you have RTC RAM available for settings */ | ||
50 | //#define HAVE_RTC_RAM | ||
51 | |||
52 | /* The number of bytes reserved for loadable plugins */ | ||
53 | #define PLUGIN_BUFFER_SIZE 0x8000 | ||
54 | |||
55 | #define AB_REPEAT_ENABLE 1 | ||
56 | |||
57 | /* Define this if you do software codec */ | ||
58 | #define CONFIG_CODEC SWCODEC | ||
59 | |||
60 | /* Define this for LCD backlight available */ | ||
61 | #define HAVE_BACKLIGHT | ||
62 | |||
63 | #define CONFIG_I2C I2C_TCC77X | ||
64 | |||
65 | #define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */ | ||
66 | #define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ | ||
67 | #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ | ||
68 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | ||
69 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | ||
70 | |||
71 | /* define this if the unit should not shut down on low battery. */ | ||
72 | #define NO_LOW_BATTERY_SHUTDOWN | ||
73 | |||
74 | #ifndef SIMULATOR | ||
75 | |||
76 | /* Define this if you have a TCC773L */ | ||
77 | #define CONFIG_CPU TCC773L | ||
78 | |||
79 | /* Define this if you have ATA power-off control */ | ||
80 | #define HAVE_ATA_POWER_OFF | ||
81 | |||
82 | /* Define this to the CPU frequency */ | ||
83 | #define CPU_FREQ 120000000 | ||
84 | |||
85 | /* Offset ( in the firmware file's header ) to the file length */ | ||
86 | #define FIRMWARE_OFFSET_FILE_LENGTH 0 | ||
87 | |||
88 | /* Offset ( in the firmware file's header ) to the file CRC */ | ||
89 | #define FIRMWARE_OFFSET_FILE_CRC 4 | ||
90 | |||
91 | /* Offset ( in the firmware file's header ) to the real data */ | ||
92 | #define FIRMWARE_OFFSET_FILE_DATA 6 | ||
93 | |||
94 | /* The start address index for ROM builds */ | ||
95 | /* #define ROM_START 0x11010 for behind original Archos */ | ||
96 | #define ROM_START 0x7010 /* for behind BootBox */ | ||
97 | |||
98 | /* Software controlled LED */ | ||
99 | #define CONFIG_LED LED_VIRTUAL | ||
100 | |||
101 | #define CONFIG_LCD LCD_SSD1815 | ||
102 | |||
103 | #define BOOTFILE_EXT "logik" | ||
104 | #define BOOTFILE "rockbox." BOOTFILE_EXT | ||
105 | #define BOOTDIR "/" | ||
106 | |||
107 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/export/config.h b/firmware/export/config.h index 05938d14ec..538c75d08a 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -51,6 +51,8 @@ | |||
51 | #define DSC25 25 | 51 | #define DSC25 25 |
52 | #define DM320 320 | 52 | #define DM320 320 |
53 | #define IMX31L 31 | 53 | #define IMX31L 31 |
54 | #define TCC771L 771 | ||
55 | #define TCC773L 773 | ||
54 | 56 | ||
55 | /* CONFIG_KEYPAD */ | 57 | /* CONFIG_KEYPAD */ |
56 | #define PLAYER_PAD 1 | 58 | #define PLAYER_PAD 1 |
@@ -71,6 +73,8 @@ | |||
71 | #define ARCHOS_AV300_PAD 16 | 73 | #define ARCHOS_AV300_PAD 16 |
72 | #define MROBE500_PAD 17 | 74 | #define MROBE500_PAD 17 |
73 | #define GIGABEAT_S_PAD 18 | 75 | #define GIGABEAT_S_PAD 18 |
76 | #define LOGIK_DAX_PAD 19 | ||
77 | #define IAUDIO67_PAD 20 | ||
74 | 78 | ||
75 | /* CONFIG_REMOTE_KEYPAD */ | 79 | /* CONFIG_REMOTE_KEYPAD */ |
76 | #define H100_REMOTE 1 | 80 | #define H100_REMOTE 1 |
@@ -103,6 +107,8 @@ | |||
103 | #define LCD_DSC25 16 /* as used by Archos AV300 */ | 107 | #define LCD_DSC25 16 /* as used by Archos AV300 */ |
104 | #define LCD_C200 17 /* as used by Sandisk Sansa c200 */ | 108 | #define LCD_C200 17 /* as used by Sandisk Sansa c200 */ |
105 | #define LCD_MROBE500 18 /* as used by Olympus M:Robe 500i */ | 109 | #define LCD_MROBE500 18 /* as used by Olympus M:Robe 500i */ |
110 | #define LCD_LOGIKDAX 19 /* as used by Logik DAX - SSD1815 */ | ||
111 | #define LCD_IAUDIO67 20 /* as used by iAudio 6/7 - unknown */ | ||
106 | 112 | ||
107 | /* LCD_PIXELFORMAT */ | 113 | /* LCD_PIXELFORMAT */ |
108 | #define HORIZONTAL_PACKING 1 | 114 | #define HORIZONTAL_PACKING 1 |
@@ -122,6 +128,7 @@ | |||
122 | #define I2C_S3C2440 7 | 128 | #define I2C_S3C2440 7 |
123 | #define I2C_PP5024 8 /* PP5024 style */ | 129 | #define I2C_PP5024 8 /* PP5024 style */ |
124 | #define I2C_IMX31L 9 | 130 | #define I2C_IMX31L 9 |
131 | #define I2C_TCC77X 10 | ||
125 | 132 | ||
126 | /* CONFIG_LED */ | 133 | /* CONFIG_LED */ |
127 | #define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */ | 134 | #define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */ |
@@ -141,6 +148,7 @@ | |||
141 | #define RTC_DS1339_DS3231 7 /* h1x0 RTC mod */ | 148 | #define RTC_DS1339_DS3231 7 /* h1x0 RTC mod */ |
142 | #define RTC_IMX31L 8 | 149 | #define RTC_IMX31L 8 |
143 | #define RTC_RX5X348AB 9 | 150 | #define RTC_RX5X348AB 9 |
151 | #define RTC_TCC77X 10 | ||
144 | 152 | ||
145 | /* USB On-the-go */ | 153 | /* USB On-the-go */ |
146 | #define USBOTG_ISP1362 1362 /* iriver H300 */ | 154 | #define USBOTG_ISP1362 1362 /* iriver H300 */ |
@@ -210,6 +218,10 @@ | |||
210 | #include "config-tpj1022.h" | 218 | #include "config-tpj1022.h" |
211 | #elif defined(MROBE_500) | 219 | #elif defined(MROBE_500) |
212 | #include "config-mrobe500.h" | 220 | #include "config-mrobe500.h" |
221 | #elif defined(LOGIK_DAX) | ||
222 | #include "config-logikdax.h" | ||
223 | #elif defined(IAUDIO_7) | ||
224 | #include "config-iaudio7.h" | ||
213 | #else | 225 | #else |
214 | /* no known platform */ | 226 | /* no known platform */ |
215 | #endif | 227 | #endif |
@@ -309,6 +321,11 @@ | |||
309 | #define CPU_PP502x | 321 | #define CPU_PP502x |
310 | #endif | 322 | #endif |
311 | 323 | ||
324 | /* define for all cpus from TCC77X family */ | ||
325 | #if (CONFIG_CPU == TCC771L) || (CONFIG_CPU == TCC773L) | ||
326 | #define CPU_TCC77X | ||
327 | #endif | ||
328 | |||
312 | /* define for all cpus from ARM7TDMI family (for specific optimisations) */ | 329 | /* define for all cpus from ARM7TDMI family (for specific optimisations) */ |
313 | #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == DSC25) | 330 | #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == DSC25) |
314 | #define CPU_ARM7TDMI | 331 | #define CPU_ARM7TDMI |
@@ -316,7 +333,8 @@ | |||
316 | 333 | ||
317 | /* define for all cpus from ARM family */ | 334 | /* define for all cpus from ARM family */ |
318 | #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ | 335 | #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ |
319 | || (CONFIG_CPU == DSC25) || (CONFIG_CPU == IMX31L) || (CONFIG_CPU == DM320) | 336 | || (CONFIG_CPU == DSC25) || (CONFIG_CPU == IMX31L) || (CONFIG_CPU == DM320) \ |
337 | || defined(CPU_TCC77X) | ||
320 | #define CPU_ARM | 338 | #define CPU_ARM |
321 | #endif | 339 | #endif |
322 | 340 | ||
@@ -342,6 +360,7 @@ | |||
342 | (((CONFIG_CPU == SH7034) && !defined(PLUGIN)) || /* SH1 archos: core only */ \ | 360 | (((CONFIG_CPU == SH7034) && !defined(PLUGIN)) || /* SH1 archos: core only */ \ |
343 | defined(CPU_COLDFIRE) || /* Coldfire: core, plugins, codecs */ \ | 361 | defined(CPU_COLDFIRE) || /* Coldfire: core, plugins, codecs */ \ |
344 | defined(CPU_PP) || /* PortalPlayer: core, plugins, codecs */ \ | 362 | defined(CPU_PP) || /* PortalPlayer: core, plugins, codecs */ \ |
363 | defined(CPU_TCC77X) || /* Telechips: core, plugins, codecs */ \ | ||
345 | (CONFIG_CPU == PNX0101)) | 364 | (CONFIG_CPU == PNX0101)) |
346 | #define ICODE_ATTR __attribute__ ((section(".icode"))) | 365 | #define ICODE_ATTR __attribute__ ((section(".icode"))) |
347 | #define ICONST_ATTR __attribute__ ((section(".irodata"))) | 366 | #define ICONST_ATTR __attribute__ ((section(".irodata"))) |
diff --git a/firmware/export/cpu.h b/firmware/export/cpu.h index 893e7ffaa8..84229378ec 100644 --- a/firmware/export/cpu.h +++ b/firmware/export/cpu.h | |||
@@ -48,3 +48,6 @@ | |||
48 | #if CONFIG_CPU == IMX31L | 48 | #if CONFIG_CPU == IMX31L |
49 | #include "imx31l.h" | 49 | #include "imx31l.h" |
50 | #endif | 50 | #endif |
51 | #ifdef CPU_TCC77X | ||
52 | #include "tcc77x.h" | ||
53 | #endif | ||
diff --git a/firmware/export/tcc77x.h b/firmware/export/tcc77x.h new file mode 100644 index 0000000000..1ab1888649 --- /dev/null +++ b/firmware/export/tcc77x.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 __TCC77X_H__ | ||
20 | #define __TCC77X_H__ | ||
21 | |||
22 | /* General-purpose IO */ | ||
23 | |||
24 | #define GPIOA (*(volatile unsigned long *)0x80000300) | ||
25 | #define GPIOB (*(volatile unsigned long *)0x80000310) | ||
26 | #define GPIOC (*(volatile unsigned long *)0x80000320) | ||
27 | #define GPIOD (*(volatile unsigned long *)0x80000330) | ||
28 | #define GPIOE (*(volatile unsigned long *)0x80000340) | ||
29 | |||
30 | #define GPIOA_DIR (*(volatile unsigned long *)0x80000304) | ||
31 | #define GPIOB_DIR (*(volatile unsigned long *)0x80000314) | ||
32 | #define GPIOC_DIR (*(volatile unsigned long *)0x80000324) | ||
33 | #define GPIOD_DIR (*(volatile unsigned long *)0x80000334) | ||
34 | #define GPIOE_DIR (*(volatile unsigned long *)0x80000344) | ||
35 | |||
36 | #define GPIOA_FUNC (*(volatile unsigned long *)0x80000308) | ||
37 | #define GPIOB_FUNC (*(volatile unsigned long *)0x80000318) | ||
38 | #define GPIOC_FUNC (*(volatile unsigned long *)0x80000328) | ||
39 | #define GPIOD_FUNC (*(volatile unsigned long *)0x80000338) | ||
40 | #define GPIOE_FUNC (*(volatile unsigned long *)0x80000348) | ||
41 | |||
42 | #define BMI (*(volatile unsigned long *)0x80000364) | ||
43 | |||
44 | /* Clock Generator */ | ||
45 | |||
46 | #define CLKCTRL (*(volatile unsigned long *)0x80000400) | ||
47 | #define PLL0CFG (*(volatile unsigned long *)0x80000404) | ||
48 | #define CLKDIV0 (*(volatile unsigned long *)0x8000040c) | ||
49 | #define MODECTR (*(volatile unsigned long *)0x80000410) | ||
50 | #define BCLKCTR (*(volatile unsigned long *)0x80000414) | ||
51 | #define SWRESET (*(volatile unsigned long *)0x80000418) | ||
52 | #define PCLKCFG0 (*(volatile unsigned long *)0x8000041c) | ||
53 | #define PCLKCFG1 (*(volatile unsigned long *)0x80000420) | ||
54 | #define PCLKCFG2 (*(volatile unsigned long *)0x80000424) | ||
55 | #define PCLKCFG3 (*(volatile unsigned long *)0x80000428) | ||
56 | #define PCLKCFG4 (*(volatile unsigned long *)0x8000042c) | ||
57 | #define PCLKCFG5 (*(volatile unsigned long *)0x80000430) | ||
58 | #define PCLKCFG6 (*(volatile unsigned long *)0x80000434) | ||
59 | |||
60 | /* ADC */ | ||
61 | |||
62 | #define ADCCON (*(volatile unsigned long *)0x80000a00) | ||
63 | #define ADCDATA (*(volatile unsigned long *)0x80000a04) | ||
64 | #define ADCCONA (*(volatile unsigned long *)0x80000a80) | ||
65 | #define ADCSTATUS (*(volatile unsigned long *)0x80000a84) | ||
66 | #define ADCCFG (*(volatile unsigned long *)0x80000a88) | ||
67 | |||
68 | |||
69 | /* Memory Controller */ | ||
70 | #define SDCFG (*(volatile unsigned long *)0xf0000000) | ||
71 | #define SDFSM (*(volatile unsigned long *)0xf0000004) | ||
72 | #define MCFG (*(volatile unsigned long *)0xf0000008) | ||
73 | #define TST (*(volatile unsigned long *)0xf000000c) | ||
74 | #define CSCFG0 (*(volatile unsigned long *)0xf0000010) | ||
75 | #define CSCFG1 (*(volatile unsigned long *)0xf0000014) | ||
76 | #define CSCFG2 (*(volatile unsigned long *)0xf0000018) | ||
77 | #define CSCFG3 (*(volatile unsigned long *)0xf000001c) | ||
78 | #define CLKCFG (*(volatile unsigned long *)0xf0000020) | ||
79 | #define SDCMD (*(volatile unsigned long *)0xf0000024) | ||
80 | |||
81 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c new file mode 100644 index 0000000000..d6d97aaf84 --- /dev/null +++ b/firmware/target/arm/tcc77x/adc-tcc77x.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "string.h" | ||
25 | #include "adc.h" | ||
26 | |||
27 | /* | ||
28 | TODO: We probably want to do this on the timer interrupt once we get | ||
29 | interrupts going - see the sh-adc.c implementation for an example which | ||
30 | looks like it should work well with the TCC77x. | ||
31 | */ | ||
32 | |||
33 | static unsigned short adcdata[8]; | ||
34 | |||
35 | static void adc_do_read(void) | ||
36 | { | ||
37 | int i; | ||
38 | uint32_t adc_status; | ||
39 | |||
40 | PCLKCFG6 |= (1<<15); /* Enable ADC clock */ | ||
41 | |||
42 | /* Start converting the first 4 channels */ | ||
43 | for (i = 0; i < 4; i++) | ||
44 | ADCCON = i; | ||
45 | |||
46 | /* Wait for data to become stable */ | ||
47 | while ((ADCDATA & 0x1) == 0); | ||
48 | |||
49 | /* Now read the values back */ | ||
50 | for (i=0;i < 4; i++) { | ||
51 | adc_status = ADCSTATUS; | ||
52 | adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff; | ||
53 | } | ||
54 | |||
55 | PCLKCFG6 &= ~(1<<15); /* Disable ADC clock */ | ||
56 | } | ||
57 | |||
58 | unsigned short adc_read(int channel) | ||
59 | { | ||
60 | adc_do_read(); | ||
61 | |||
62 | return adcdata[channel]; | ||
63 | } | ||
64 | |||
65 | void adc_init(void) | ||
66 | { | ||
67 | int i; | ||
68 | |||
69 | ADCCON = (1<<4); /* Leave standby mode */ | ||
70 | ADCCFG |= 0x00000003; /* Single-mode, auto power-down */ | ||
71 | } | ||
diff --git a/firmware/target/arm/tcc77x/ata-nand-tcc77x.c b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c new file mode 100644 index 0000000000..dd0ae7a950 --- /dev/null +++ b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 "ata.h" | ||
20 | #include "ata-target.h" | ||
21 | #include "ata_idle_notify.h" | ||
22 | #include "system.h" | ||
23 | #include <string.h> | ||
24 | #include "thread.h" | ||
25 | #include "led.h" | ||
26 | #include "disk.h" | ||
27 | #include "panic.h" | ||
28 | #include "usb.h" | ||
29 | |||
30 | /* for compatibility */ | ||
31 | int ata_spinup_time = 0; | ||
32 | |||
33 | long last_disk_activity = -1; | ||
34 | |||
35 | /** static, private data **/ | ||
36 | static bool initialized = false; | ||
37 | |||
38 | static long next_yield = 0; | ||
39 | #define MIN_YIELD_PERIOD 2000 | ||
40 | |||
41 | /* API Functions */ | ||
42 | |||
43 | void ata_led(bool onoff) | ||
44 | { | ||
45 | led(onoff); | ||
46 | } | ||
47 | |||
48 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | ||
49 | void* inbuf) | ||
50 | { | ||
51 | |||
52 | } | ||
53 | |||
54 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | ||
55 | const void* outbuf) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | void ata_spindown(int seconds) | ||
60 | { | ||
61 | (void)seconds; | ||
62 | } | ||
63 | |||
64 | bool ata_disk_is_active(void) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | void ata_sleep(void) | ||
70 | { | ||
71 | } | ||
72 | |||
73 | void ata_spin(void) | ||
74 | { | ||
75 | } | ||
76 | |||
77 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ | ||
78 | int ata_hard_reset(void) | ||
79 | { | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | int ata_soft_reset(void) | ||
84 | { | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | void ata_enable(bool on) | ||
89 | { | ||
90 | } | ||
91 | |||
92 | int ata_init(void) | ||
93 | { | ||
94 | } | ||
diff --git a/firmware/target/arm/tcc77x/ata-target.h b/firmware/target/arm/tcc77x/ata-target.h new file mode 100644 index 0000000000..79ac638de1 --- /dev/null +++ b/firmware/target/arm/tcc77x/ata-target.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 ATA_TARGET_H | ||
20 | #define ATA_TARGET_H | ||
21 | |||
22 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S new file mode 100644 index 0000000000..e4ecb05a4e --- /dev/null +++ b/firmware/target/arm/tcc77x/crt0.S | |||
@@ -0,0 +1,153 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
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 | /* Arm bootloader and startup code based on startup.s from the iPodLinux loader | ||
21 | * | ||
22 | * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org) | ||
23 | * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include "config.h" | ||
28 | #include "cpu.h" | ||
29 | |||
30 | .section .init.text,"ax",%progbits | ||
31 | |||
32 | .global start | ||
33 | |||
34 | /* Telechips firmware files start with a 32-byte header, as part of the code. */ | ||
35 | |||
36 | start: | ||
37 | #ifdef TCCBOOT | ||
38 | /* Add -DTCCBOOT to EXTRA_DEFINES in the bootloader Makefile to | ||
39 | enable building the bootloader to be appended to the end of the | ||
40 | original firmware, dual-booting based on a key-press. | ||
41 | |||
42 | The following two values are filled in by mktccboot. | ||
43 | */ | ||
44 | .word 0 /* Saved entrypoint of original firmware*/ | ||
45 | .word 0 /* Location in RAM of the start of our bootloader */ | ||
46 | #else | ||
47 | ldr pc, =start_loc /* jump to the main entry point */ | ||
48 | |||
49 | .word 0xffff0601 /* Unknown magic */ | ||
50 | .word 0x3a726556 /* "Ver:" */ | ||
51 | .word 0x31373030 /* "0071" */ | ||
52 | .word 0 /* First CRC32 */ | ||
53 | .word 0 /* Unknown - always 0 */ | ||
54 | .word 0 /* Second CRC32 */ | ||
55 | .word 0 /* length of firmware file */ | ||
56 | |||
57 | #ifdef LOGIK_DAX | ||
58 | /* Some original firmwares have 0x40 bytes of zeroes here - we | ||
59 | don't know why, but err on the side of caution and include it | ||
60 | here. */ | ||
61 | .space 0x40 | ||
62 | #endif | ||
63 | #endif | ||
64 | |||
65 | start_loc: | ||
66 | |||
67 | #ifdef BOOTLOADER | ||
68 | #ifdef TCCBOOT | ||
69 | #ifdef LOGIK_DAX | ||
70 | mov r0, #0x80000000 | ||
71 | ldr r0, [r0, #0x300] /* Read GPIO A */ | ||
72 | tst r0, #0x2 | ||
73 | ldrne pc, [pc, #-28] /* Jump to original firmware if HOLD button not pressed */ | ||
74 | #else | ||
75 | #error No bootup key detection implemented for this target | ||
76 | #endif | ||
77 | |||
78 | /* Copy bootloader to safe area - 0x21000000 (DRAM) */ | ||
79 | /* TODO: Adjust this for other targets - DRAM + DRAMSIZE - 0x100000 */ | ||
80 | ldr r0, [pc, #-28] | ||
81 | mov r1, #0x20000000 | ||
82 | add r1, r1, #0x100000 | ||
83 | ldr r2, =_dataend | ||
84 | 1: | ||
85 | cmp r2, r1 | ||
86 | ldrhi r3, [r0], #4 | ||
87 | strhi r3, [r1], #4 | ||
88 | bhi 1b | ||
89 | |||
90 | ldr pc, =copied_start /* jump to the relocated start_loc: */ | ||
91 | |||
92 | copied_start: | ||
93 | #endif | ||
94 | #else | ||
95 | /* We don't use interrupts in the bootloader */ | ||
96 | |||
97 | /* Set up stack for IRQ mode */ | ||
98 | mov r0,#0xd2 | ||
99 | msr cpsr, r0 | ||
100 | ldr sp, =irq_stack | ||
101 | /* Set up stack for FIQ mode */ | ||
102 | mov r0,#0xd1 | ||
103 | msr cpsr, r0 | ||
104 | ldr sp, =fiq_stack | ||
105 | |||
106 | /* Let abort and undefined modes use IRQ stack */ | ||
107 | mov r0,#0xd7 | ||
108 | msr cpsr, r0 | ||
109 | ldr sp, =irq_stack | ||
110 | mov r0,#0xdb | ||
111 | msr cpsr, r0 | ||
112 | ldr sp, =irq_stack | ||
113 | #endif | ||
114 | |||
115 | /* Switch to supervisor mode */ | ||
116 | mov r0,#0xd3 | ||
117 | msr cpsr, r0 | ||
118 | ldr sp, =stackend | ||
119 | |||
120 | /* Initialise bss section to zero */ | ||
121 | ldr r2, =_edata | ||
122 | ldr r3, =_end | ||
123 | mov r4, #0 | ||
124 | 1: | ||
125 | cmp r3, r2 | ||
126 | strhi r4, [r2], #4 | ||
127 | bhi 1b | ||
128 | |||
129 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
130 | ldr sp, =stackend | ||
131 | mov r3, sp | ||
132 | ldr r2, =stackbegin | ||
133 | ldr r4, =0xdeadbeef | ||
134 | 1: | ||
135 | cmp r3, r2 | ||
136 | strhi r4, [r2], #4 | ||
137 | bhi 1b | ||
138 | |||
139 | bl main | ||
140 | /* main() should never return */ | ||
141 | |||
142 | #ifndef BOOTLOADER | ||
143 | /* We don't use interrupts in the bootloader */ | ||
144 | |||
145 | /* 256 words of IRQ stack */ | ||
146 | .space 256*4 | ||
147 | irq_stack: | ||
148 | |||
149 | /* 256 words of FIQ stack */ | ||
150 | .space 256*4 | ||
151 | fiq_stack: | ||
152 | |||
153 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/adc-target.h b/firmware/target/arm/tcc77x/logikdax/adc-target.h new file mode 100644 index 0000000000..cfc8117a99 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/adc-target.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 _ADC_TARGET_H_ | ||
20 | #define _ADC_TARGET_H_ | ||
21 | |||
22 | #define NUM_ADC_CHANNELS 8 | ||
23 | |||
24 | #define ADC_BUTTONS 0 | ||
25 | |||
26 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h new file mode 100644 index 0000000000..4714f22aa3 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/backlight-target.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 BACKLIGHT_TARGET_H | ||
20 | #define BACKLIGHT_TARGET_H | ||
21 | |||
22 | #include "tcc77x.h" | ||
23 | |||
24 | #define __backlight_init() true | ||
25 | |||
26 | static inline void __backlight_on(void) | ||
27 | { | ||
28 | /* Enable backlight */ | ||
29 | GPIOD |= 0x10; | ||
30 | } | ||
31 | |||
32 | static inline void __backlight_off(void) | ||
33 | { | ||
34 | /* Disable backlight */ | ||
35 | GPIOD &= ~0x10; | ||
36 | } | ||
37 | |||
38 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h new file mode 100644 index 0000000000..2925a423b6 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/button-target.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 <stdbool.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | /* | ||
27 | |||
28 | Results of button testing: | ||
29 | |||
30 | HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released) | ||
31 | POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released) | ||
32 | |||
33 | ADC[0]: (approx values) | ||
34 | |||
35 | RIGHT - 0x37 | ||
36 | LEFT - 0x7f | ||
37 | JOYSTICK PRESS - 0xc7 | ||
38 | UP - 0x11e | ||
39 | DOWN - 0x184 | ||
40 | MODE - 0x1f0/0x1ff | ||
41 | PRESET - 0x268/0x269 | ||
42 | TIMESHIFT - 0x2dd | ||
43 | |||
44 | Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384 | ||
45 | |||
46 | */ | ||
47 | |||
48 | |||
49 | void button_init_device(void); | ||
50 | int button_read_device(void); | ||
51 | |||
52 | /* Main unit's buttons */ | ||
53 | #define BUTTON_POWERPLAY 0x00000001 | ||
54 | #define BUTTON_MODE 0x00000002 | ||
55 | #define BUTTON_HOLD 0x00000004 | ||
56 | #define BUTTON_REC 0x00000008 | ||
57 | #define BUTTON_PRESET 0x00000010 | ||
58 | #define BUTTON_LEFT 0x00000020 | ||
59 | #define BUTTON_RIGHT 0x00000040 | ||
60 | #define BUTTON_UP 0x00000080 | ||
61 | #define BUTTON_DOWN 0x00000100 | ||
62 | #define BUTTON_SELECT 0x00000200 | ||
63 | |||
64 | #define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\ | ||
65 | |BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\ | ||
66 | |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT) | ||
67 | |||
68 | #define BUTTON_REMOTE 0 | ||
69 | |||
70 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c new file mode 100644 index 0000000000..973d4cb333 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c | |||
@@ -0,0 +1,253 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
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 "cpu.h" | ||
26 | |||
27 | /*** definitions ***/ | ||
28 | |||
29 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
30 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
31 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
32 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
33 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
34 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
35 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
36 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
37 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
38 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
39 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
40 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
41 | #define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) | ||
42 | #define LCD_SET_BIAS_TC_OSC ((char)0xA9) | ||
43 | #define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA) | ||
44 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
45 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
46 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
47 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
48 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
49 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
50 | #define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2) | ||
51 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
52 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
53 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
54 | #define LCD_NOP ((char)0xE3) | ||
55 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
56 | |||
57 | /* LCD command codes */ | ||
58 | #define LCD_CNTL_RESET 0xe2 /* Software reset */ | ||
59 | #define LCD_CNTL_POWER 0x2f /* Power control */ | ||
60 | #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ | ||
61 | #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ | ||
62 | #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ | ||
63 | #define LCD_CNTL_DISPON 0xaf /* Display on */ | ||
64 | |||
65 | #define LCD_CNTL_PAGE 0xb0 /* Page address */ | ||
66 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | ||
67 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | ||
68 | |||
69 | /* TCC77x specific defines */ | ||
70 | #define LCD_BASE 0x50000000 | ||
71 | #define LCD_CMD *(volatile unsigned char*)(LCD_BASE) | ||
72 | #define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1) | ||
73 | |||
74 | void lcd_write_command(int byte) | ||
75 | { | ||
76 | LCD_CMD = byte; | ||
77 | |||
78 | asm volatile ( | ||
79 | "nop \n\t" | ||
80 | "nop \n\t" | ||
81 | "nop \n\t" | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
86 | { | ||
87 | while (count--) | ||
88 | { | ||
89 | LCD_DATA = *(p_bytes++); | ||
90 | |||
91 | asm volatile ( | ||
92 | "nop \n\t" | ||
93 | "nop \n\t" | ||
94 | "nop \n\t" | ||
95 | ); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /* End of TCC77x specific defines */ | ||
100 | |||
101 | |||
102 | /** globals **/ | ||
103 | |||
104 | static int xoffset; /* needed for flip */ | ||
105 | |||
106 | /*** hardware configuration ***/ | ||
107 | |||
108 | int lcd_default_contrast(void) | ||
109 | { | ||
110 | return 0x1f; | ||
111 | } | ||
112 | |||
113 | void lcd_set_contrast(int val) | ||
114 | { | ||
115 | lcd_write_command(LCD_CNTL_CONTRAST); | ||
116 | lcd_write_command(val); | ||
117 | } | ||
118 | |||
119 | void lcd_set_invert_display(bool yesno) | ||
120 | { | ||
121 | if (yesno) | ||
122 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | ||
123 | else | ||
124 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
125 | } | ||
126 | |||
127 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
128 | void lcd_set_flip(bool yesno) | ||
129 | { | ||
130 | /* TODO: flip mode isn't working. The commands in the else part of | ||
131 | this function are how the original firmware inits the LCD */ | ||
132 | |||
133 | if (yesno) | ||
134 | { | ||
135 | lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01); | ||
136 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION); | ||
137 | xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 128 we have */ | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | lcd_write_command(LCD_SET_SEGMENT_REMAP); | ||
142 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08); | ||
143 | xoffset = 0; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | |||
148 | /* LCD init */ | ||
149 | void lcd_init_device(void) | ||
150 | { | ||
151 | uint32_t bus_width; | ||
152 | |||
153 | /* Telechips init the same as the original firmware */ | ||
154 | CSCFG1 &= 0xc3ffc000; | ||
155 | CSCFG1 |= 0x3400101a; | ||
156 | CSCFG1 |= (1 << 21); | ||
157 | CSCFG1 &= ~(1 << 21); | ||
158 | |||
159 | bus_width = ((MCFG >> 11) & 0x3) ^ 3; | ||
160 | |||
161 | CSCFG1 = (bus_width << 28) | | ||
162 | (3 << 26) | /* MTYPE = 3 */ | ||
163 | ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */ | ||
164 | (1 << 20) | /* Unknown */ | ||
165 | (3 << 11) | /* Setup time = 3 cycles */ | ||
166 | (3 << 3) | /* Pulse width = 3+1 cycles */ | ||
167 | (1 << 0); /* Hold time = 1 cycle */ | ||
168 | |||
169 | /* SSD1815 inits like the original firmware */ | ||
170 | lcd_write_command(LCD_SET_DISPLAY_OFF); | ||
171 | lcd_set_flip(false); | ||
172 | lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5); | ||
173 | lcd_set_contrast(lcd_default_contrast()); | ||
174 | lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7); | ||
175 | /* power control register: op-amp=1, regulator=1, booster=1 */ | ||
176 | lcd_write_command(LCD_SET_BIAS_TC_OSC); | ||
177 | |||
178 | /* 0xc2 = 110 000 10: Osc. Freq 110 - ??? | ||
179 | TC value 000 - "-0.01%/C (TC0, POR)" | ||
180 | Bias ratio 10 - "1/9, 1/7 (POR)" | ||
181 | */ | ||
182 | lcd_write_command(0xc2); | ||
183 | lcd_write_command(LCD_SET_DISPLAY_ON); | ||
184 | |||
185 | lcd_clear_display(); | ||
186 | lcd_update(); | ||
187 | } | ||
188 | |||
189 | /*** Update functions ***/ | ||
190 | |||
191 | /* Performance function that works with an external buffer | ||
192 | note that by and bheight are in 8-pixel units! */ | ||
193 | void lcd_blit(const unsigned char* data, int x, int by, int width, | ||
194 | int bheight, int stride) | ||
195 | { | ||
196 | /* Copy display bitmap to hardware */ | ||
197 | while (bheight--) | ||
198 | { | ||
199 | lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); | ||
200 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf)); | ||
201 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
202 | |||
203 | lcd_write_data(data, width); | ||
204 | data += stride; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | |||
209 | /* Update the display. | ||
210 | This must be called after all other LCD functions that change the display. */ | ||
211 | void lcd_update(void) ICODE_ATTR; | ||
212 | void lcd_update(void) | ||
213 | { | ||
214 | int y; | ||
215 | |||
216 | /* Copy display bitmap to hardware */ | ||
217 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
218 | { | ||
219 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
220 | lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf)); | ||
221 | lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf)); | ||
222 | |||
223 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /* Update a fraction of the display. */ | ||
228 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
229 | void lcd_update_rect(int x, int y, int width, int height) | ||
230 | { | ||
231 | int ymax; | ||
232 | |||
233 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
234 | ymax = (y + height-1) >> 3; | ||
235 | y >>= 3; | ||
236 | |||
237 | if(x + width > LCD_WIDTH) | ||
238 | width = LCD_WIDTH - x; | ||
239 | if (width <= 0) | ||
240 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
241 | if(ymax >= LCD_FBHEIGHT) | ||
242 | ymax = LCD_FBHEIGHT-1; | ||
243 | |||
244 | /* Copy specified rectange bitmap to hardware */ | ||
245 | for (; y <= ymax; y++) | ||
246 | { | ||
247 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
248 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf)); | ||
249 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
250 | |||
251 | lcd_write_data (&lcd_framebuffer[y][x], width); | ||
252 | } | ||
253 | } | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c new file mode 100644 index 0000000000..df2ee10d6b --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | |||
26 | #ifndef SIMULATOR | ||
27 | |||
28 | void power_init(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | void ide_power_enable(bool on) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | bool ide_powered(void) | ||
37 | { | ||
38 | return true; | ||
39 | } | ||
40 | |||
41 | void power_off(void) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | #else /* SIMULATOR */ | ||
46 | |||
47 | bool charger_inserted(void) | ||
48 | { | ||
49 | return false; | ||
50 | } | ||
51 | |||
52 | void charger_enable(bool on) | ||
53 | { | ||
54 | (void)on; | ||
55 | } | ||
56 | |||
57 | void power_off(void) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | void ide_power_enable(bool on) | ||
62 | { | ||
63 | (void)on; | ||
64 | } | ||
65 | |||
66 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/arm/tcc77x/system-target.h b/firmware/target/arm/tcc77x/system-target.h new file mode 100644 index 0000000000..0df92e3263 --- /dev/null +++ b/firmware/target/arm/tcc77x/system-target.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 SYSTEM_TARGET_H | ||
20 | #define SYSTEM_TARGET_H | ||
21 | |||
22 | #include "system-arm.h" | ||
23 | |||
24 | #define CPUFREQ_DEFAULT 98784000 | ||
25 | #define CPUFREQ_NORMAL 98784000 | ||
26 | #define CPUFREQ_MAX 120000000 | ||
27 | |||
28 | #define inl(a) (*(volatile unsigned long *) (a)) | ||
29 | #define outl(a,b) (*(volatile unsigned long *) (b) = (a)) | ||
30 | #define inb(a) (*(volatile unsigned char *) (a)) | ||
31 | #define outb(a,b) (*(volatile unsigned char *) (b) = (a)) | ||
32 | #define inw(a) (*(volatile unsigned short *) (a)) | ||
33 | #define outw(a,b) (*(volatile unsigned short *) (b) = (a)) | ||
34 | |||
35 | #endif /* SYSTEM_TARGET_H */ | ||
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c new file mode 100644 index 0000000000..baa1641c78 --- /dev/null +++ b/firmware/target/arm/tcc77x/system-tcc77x.c | |||
@@ -0,0 +1,136 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 "kernel.h" | ||
21 | #include "system.h" | ||
22 | #include "panic.h" | ||
23 | |||
24 | void system_reboot(void) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | /* TODO - these should live in the target-specific directories and | ||
29 | once we understand what all the GPIO pins do, move the init to the | ||
30 | specific driver for that hardware. For now, we just perform the | ||
31 | same GPIO init as the original firmware - this makes it easier to | ||
32 | investigate what the GPIO pins do. | ||
33 | */ | ||
34 | |||
35 | #ifdef LOGIK_DAX | ||
36 | static void gpio_init(void) | ||
37 | { | ||
38 | /* Do what the original firmware does */ | ||
39 | GPIOD_FUNC = 0; | ||
40 | GPIOD_DIR = 0x3f0; | ||
41 | GPIOD = 0xe0; | ||
42 | GPIOE_FUNC = 0; | ||
43 | GPIOE_DIR = 0xe0; | ||
44 | GPIOE = 0; | ||
45 | GPIOA_FUNC = 0; | ||
46 | GPIOA_DIR = 0xffff1000; /* 0 - 0xf000 */ | ||
47 | GPIOA = 0x1080; | ||
48 | GPIOB_FUNC = 0x16a3; | ||
49 | GPIOB_DIR = 0x6ffff; | ||
50 | GPIOB = 0; | ||
51 | GPIOC_FUNC = 1; | ||
52 | GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */ | ||
53 | GPIOC = 0; | ||
54 | } | ||
55 | #elif defined(IAUDIO_7) | ||
56 | static void gpio_init(void) | ||
57 | { | ||
58 | /* Do what the original firmware does */ | ||
59 | GPIOA_FUNC = 0; | ||
60 | GPIOB_FUNC = 0x1623; | ||
61 | GPIOC_FUNC = 1; | ||
62 | GPIOD_FUNC = 0; | ||
63 | GPIOE_FUNC = 0; | ||
64 | GPIOA = 0x30; | ||
65 | GPIOB = 0x80000; | ||
66 | GPIOC = 0; | ||
67 | GPIOD = 0x180; | ||
68 | GPIOE = 0; | ||
69 | GPIOA_DIR = 0x84b0 | ||
70 | GPIOB_DIR = 0x80800; | ||
71 | GPIOC_DIR = 0x2000000; | ||
72 | GPIOD_DIR = 0x3e3; | ||
73 | GPIOE_DIR = 0x88; | ||
74 | } | ||
75 | #endif | ||
76 | |||
77 | /* Second function called in the original firmware's startup code - we just | ||
78 | set up the clocks in the same way as the original firmware for now. */ | ||
79 | static void clock_init(void) | ||
80 | { | ||
81 | unsigned int i; | ||
82 | |||
83 | CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820; | ||
84 | |||
85 | CLKCTRL = (CLKCTRL & ~0xff) | 0x14; | ||
86 | |||
87 | if (BMI & 0x20) | ||
88 | PCLKCFG0 = 0xc82d7000; | ||
89 | else | ||
90 | PCLKCFG0 = 0xc8ba7000; | ||
91 | |||
92 | MCFG |= 0x2000; | ||
93 | |||
94 | #ifdef LOGIK_DAX | ||
95 | /* Only seen in the Logik DAX original firmware */ | ||
96 | SDCFG = (SDCFG & ~0x7000) | 0x2000; | ||
97 | #endif | ||
98 | |||
99 | PLL0CFG |= 0x80000000; | ||
100 | |||
101 | PLL0CFG = 0x0000cf13; | ||
102 | |||
103 | i = 8000; | ||
104 | while (--i) {}; | ||
105 | |||
106 | CLKDIV0 = 0x81000000; | ||
107 | CLKCTRL = 0x80000010; | ||
108 | |||
109 | asm volatile ( | ||
110 | "nop \n\t" | ||
111 | "nop \n\t" | ||
112 | ); | ||
113 | } | ||
114 | |||
115 | |||
116 | void system_init(void) | ||
117 | { | ||
118 | /* TODO: cache init - the original firmwares have cache init code which | ||
119 | is called at the very start of the firmware */ | ||
120 | clock_init(); | ||
121 | gpio_init(); | ||
122 | } | ||
123 | |||
124 | int system_memory_guard(int newmode) | ||
125 | { | ||
126 | (void)newmode; | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
131 | |||
132 | void set_cpu_frequency(long frequency) | ||
133 | { | ||
134 | } | ||
135 | |||
136 | #endif | ||
diff --git a/firmware/thread.c b/firmware/thread.c index 896cc0fb3d..4bcea0542d 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -651,6 +651,11 @@ static inline void core_sleep(struct thread_entry **waking) | |||
651 | "msr cpsr_c, r0 \n" | 651 | "msr cpsr_c, r0 \n" |
652 | : : "r"(waking) : "r0", "r1", "r2", "r3"); | 652 | : : "r"(waking) : "r0", "r1", "r2", "r3"); |
653 | } | 653 | } |
654 | #elif defined(CPU_TCC77X) | ||
655 | static inline void core_sleep(struct thread_entry **waking) | ||
656 | { | ||
657 | #warning TODO: Implement core_sleep | ||
658 | } | ||
654 | #else | 659 | #else |
655 | static inline void core_sleep(struct thread_entry **waking) | 660 | static inline void core_sleep(struct thread_entry **waking) |
656 | { | 661 | { |
diff --git a/tools/Makefile b/tools/Makefile index 347b113287..f45c5df036 100644 --- a/tools/Makefile +++ b/tools/Makefile | |||
@@ -11,7 +11,7 @@ LDFLAGS := -g | |||
11 | 11 | ||
12 | CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \ | 12 | CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \ |
13 | generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat database \ | 13 | generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat database \ |
14 | lngdump telechips gigabeats | 14 | lngdump telechips gigabeats mktccboot |
15 | 15 | ||
16 | all: | 16 | all: |
17 | @echo "Run make in your build directory!" | 17 | @echo "Run make in your build directory!" |
@@ -38,6 +38,9 @@ rdf2binary: rdf2binary.c | |||
38 | mkboot: mkboot.c | 38 | mkboot: mkboot.c |
39 | $(SILENT)$(CC) -g $+ -o $@ | 39 | $(SILENT)$(CC) -g $+ -o $@ |
40 | 40 | ||
41 | mktccboot: mktccboot.c telechips.o | ||
42 | $(SILENT)$(CC) -g $+ -o $@ | ||
43 | |||
41 | lngdump: lngdump.c | 44 | lngdump: lngdump.c |
42 | $(SILENT)$(CC) -g $+ -o $@ | 45 | $(SILENT)$(CC) -g $+ -o $@ |
43 | 46 | ||
diff --git a/tools/configure b/tools/configure index 1cc7e6220e..3971bcb2e4 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -212,6 +212,13 @@ arm9tdmicc () { | |||
212 | endian="little" | 212 | endian="little" |
213 | } | 213 | } |
214 | 214 | ||
215 | arm946cc () { | ||
216 | prefixtools arm-elf- | ||
217 | GCCOPTS="$CCOPTS -mcpu=arm9e -mlong-calls" | ||
218 | GCCOPTIMIZE="-fomit-frame-pointer" | ||
219 | endian="little" | ||
220 | } | ||
221 | |||
215 | whichadvanced () { | 222 | whichadvanced () { |
216 | ################################################################## | 223 | ################################################################## |
217 | # Prompt for specific developer options | 224 | # Prompt for specific developer options |
@@ -619,10 +626,10 @@ cat <<EOF | |||
619 | ==iAudio== ==Toshiba== ==SanDisk== | 626 | ==iAudio== ==Toshiba== ==SanDisk== |
620 | 30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200 | 627 | 30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200 |
621 | 31) M5/M5L 41) Gigabeat S 51) Sansa e200R | 628 | 31) M5/M5L 41) Gigabeat S 51) Sansa e200R |
622 | 52) Sansa c200 | 629 | 32) 7 52) Sansa c200 |
623 | 630 | ||
624 | ==Tatung== ==Olympus== | 631 | ==Tatung== ==Olympus== ==Logik== |
625 | 60) Elio TPJ-1022 70) M:Robe 500 | 632 | 60) Elio TPJ-1022 70) M:Robe 500 80) DAX 1GB MP3/DAB |
626 | EOF | 633 | EOF |
627 | 634 | ||
628 | buildfor=`input`; | 635 | buildfor=`input`; |
@@ -636,6 +643,7 @@ EOF | |||
636 | iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb" | 643 | iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb" |
637 | ipodbitmaptools="$toolset scramble ipod_fw bmp2rb" | 644 | ipodbitmaptools="$toolset scramble ipod_fw bmp2rb" |
638 | gigabeatbitmaptools="$toolset scramble descramble bmp2rb" | 645 | gigabeatbitmaptools="$toolset scramble descramble bmp2rb" |
646 | tccbitmaptools="$toolset scramble mktccboot bmp2rb" | ||
639 | # generic is used by IFP, H10, Sansa-e200 | 647 | # generic is used by IFP, H10, Sansa-e200 |
640 | genericbitmaptools="$toolset bmp2rb" | 648 | genericbitmaptools="$toolset bmp2rb" |
641 | 649 | ||
@@ -1310,6 +1318,32 @@ EOF | |||
1310 | t_model="mrobe-500" | 1318 | t_model="mrobe-500" |
1311 | ;; | 1319 | ;; |
1312 | 1320 | ||
1321 | 80|logikdax) | ||
1322 | target_id=31 | ||
1323 | archos="logikdax" | ||
1324 | target="-DLOGIK_DAX" | ||
1325 | memory=2 # always | ||
1326 | arm946cc | ||
1327 | tool="$rootdir/tools/scramble -add=ldax" | ||
1328 | boottool="$rootdir/tools/scramble -tcc=crc" | ||
1329 | bootoutput="player.rom" | ||
1330 | bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" | ||
1331 | bmp2rb_native="$rootdir/tools/bmp2rb -f 0" | ||
1332 | output="rockbox.logik" | ||
1333 | appextra="recorder:gui" | ||
1334 | archosrom="" | ||
1335 | flash="" | ||
1336 | plugins="no" | ||
1337 | swcodec="yes" | ||
1338 | # toolset is the tools within the tools directory that we build for | ||
1339 | # this particular target. | ||
1340 | toolset=$tccbitmaptools | ||
1341 | # architecture, manufacturer and model for the target-tree build | ||
1342 | t_cpu="arm" | ||
1343 | t_manufacturer="tcc77x" | ||
1344 | t_model="logikdax" | ||
1345 | ;; | ||
1346 | |||
1313 | 50|e200) | 1347 | 50|e200) |
1314 | target_id=23 | 1348 | target_id=23 |
1315 | archos="e200" | 1349 | archos="e200" |
@@ -1416,6 +1450,32 @@ EOF | |||
1416 | t_manufacturer="tatung" | 1450 | t_manufacturer="tatung" |
1417 | t_model="tpj1022" | 1451 | t_model="tpj1022" |
1418 | ;; | 1452 | ;; |
1453 | |||
1454 | 32|iaudio7) | ||
1455 | target_id=32 | ||
1456 | archos="iaudio7" | ||
1457 | target="-DIAUDIO_7" | ||
1458 | memory=16 # always | ||
1459 | arm946cc | ||
1460 | tool="$rootdir/tools/scramble -add i7" | ||
1461 | boottool="$rootdir/tools/scramble -tcc=crc" | ||
1462 | bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" | ||
1463 | bmp2rb_native="$rootdir/tools/bmp2rb -f 5" | ||
1464 | output="rockbox.iaudio" | ||
1465 | appextra="recorder:gui" | ||
1466 | archosrom="" | ||
1467 | flash="" | ||
1468 | plugins="yes" | ||
1469 | swcodec="yes" | ||
1470 | bootoutput="I7_FW.BIN" | ||
1471 | # toolset is the tools within the tools directory that we build for | ||
1472 | # this particular target. | ||
1473 | toolset="$tccbitmaptools" | ||
1474 | # architecture, manufacturer and model for the target-tree build | ||
1475 | t_cpu="arm" | ||
1476 | t_manufacturer="tcc77x" | ||
1477 | t_model="iaudio7" | ||
1478 | ;; | ||
1419 | 1479 | ||
1420 | *) | 1480 | *) |
1421 | echo "Please select a supported target platform!" | 1481 | echo "Please select a supported target platform!" |
diff --git a/tools/mktccboot.c b/tools/mktccboot.c new file mode 100644 index 0000000000..90b85e8335 --- /dev/null +++ b/tools/mktccboot.c | |||
@@ -0,0 +1,184 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
11 | * | ||
12 | * Based on mkboot, Copyright (C) 2005 by Linus Nielsen Feltzing | ||
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 | #include <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <string.h> | ||
24 | #include <sys/types.h> | ||
25 | #include <sys/stat.h> | ||
26 | #include <fcntl.h> | ||
27 | #include <inttypes.h> | ||
28 | #include "telechips.h" | ||
29 | |||
30 | /* | ||
31 | |||
32 | Append a Rockbox bootloader to a Telechips original firmware file. | ||
33 | |||
34 | The first instruction in a TCC firmware file is always of the form: | ||
35 | |||
36 | ldr pc, [pc, #xxx] | ||
37 | |||
38 | where [pc, #xxx] is the entry point of the firmware - e.g. 0x20000020 | ||
39 | |||
40 | mktccboot appends the Rockbox bootloader to the end of the original | ||
41 | firmware image and replaces the contents of [pc, #xxx] with the entry | ||
42 | point of our bootloader - i.e. the length of the original firmware plus | ||
43 | 0x20000000. | ||
44 | |||
45 | It then stores the original entry point from [pc, #xxx] in a fixed | ||
46 | offset in the Rockbox boootloader, which is used by the bootloader to | ||
47 | dual-boot. | ||
48 | |||
49 | Finally, mktccboot corrects the length and CRCs in the main firmware | ||
50 | header, creating a new legal firmware file which can be installed on | ||
51 | the device. | ||
52 | |||
53 | */ | ||
54 | |||
55 | /* win32 compatibility */ | ||
56 | |||
57 | #ifndef O_BINARY | ||
58 | #define O_BINARY 0 | ||
59 | #endif | ||
60 | |||
61 | static void put_uint32le(uint32_t x, unsigned char* p) | ||
62 | { | ||
63 | p[0] = x & 0xff; | ||
64 | p[1] = (x >> 8) & 0xff; | ||
65 | p[2] = (x >> 16) & 0xff; | ||
66 | p[3] = (x >> 24) & 0xff; | ||
67 | } | ||
68 | |||
69 | static uint32_t get_uint32le(unsigned char* p) | ||
70 | { | ||
71 | return (p[3] << 24) | (p[2] << 16) | (p[1]<<8) | p[0]; | ||
72 | } | ||
73 | |||
74 | void usage(void) | ||
75 | { | ||
76 | printf("Usage: mktccboot <firmware file> <boot file> <output file>\n"); | ||
77 | |||
78 | exit(1); | ||
79 | } | ||
80 | |||
81 | off_t filesize(int fd) { | ||
82 | struct stat buf; | ||
83 | |||
84 | if (fstat(fd,&buf) < 0) { | ||
85 | perror("[ERR] Checking filesize of input file"); | ||
86 | return -1; | ||
87 | } else { | ||
88 | return(buf.st_size); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | |||
93 | int main(int argc, char *argv[]) | ||
94 | { | ||
95 | char *infile, *bootfile, *outfile; | ||
96 | int fdin, fdboot,fdout; | ||
97 | int i,n; | ||
98 | int inlength,bootlength; | ||
99 | uint32_t ldr; | ||
100 | unsigned char* image; | ||
101 | int origoffset; | ||
102 | |||
103 | if(argc < 3) { | ||
104 | usage(); | ||
105 | } | ||
106 | |||
107 | infile = argv[1]; | ||
108 | bootfile = argv[2]; | ||
109 | outfile = argv[3]; | ||
110 | |||
111 | fdin = open(infile, O_RDONLY|O_BINARY); | ||
112 | if (fdin < 0) | ||
113 | { | ||
114 | perror(infile); | ||
115 | } | ||
116 | |||
117 | fdboot = open(bootfile, O_RDONLY|O_BINARY); | ||
118 | if (fdboot < 0) | ||
119 | { | ||
120 | perror(bootfile); | ||
121 | } | ||
122 | |||
123 | inlength = filesize(fdin); | ||
124 | bootlength = filesize(fdboot); | ||
125 | |||
126 | image = malloc(inlength + bootlength); | ||
127 | |||
128 | if (image==NULL) | ||
129 | { | ||
130 | printf("[ERR] Could not allocate memory, aborting\n"); | ||
131 | return 1; | ||
132 | } | ||
133 | |||
134 | n = read(fdin, image, inlength); | ||
135 | if (n != inlength) | ||
136 | { | ||
137 | printf("[ERR] Could not read from %s\n",infile); | ||
138 | return 2; | ||
139 | } | ||
140 | |||
141 | n = read(fdboot, image + inlength, bootlength); | ||
142 | if (n != bootlength) | ||
143 | { | ||
144 | printf("[ERR] Could not read from %s\n",bootfile); | ||
145 | return 3; | ||
146 | } | ||
147 | |||
148 | ldr = get_uint32le(image); | ||
149 | |||
150 | /* TODO: Verify it's a LDR instruction */ | ||
151 | origoffset = (ldr&0xfff) + 8; | ||
152 | |||
153 | printf("original firmware entry point: 0x%08x\n",get_uint32le(image + origoffset)); | ||
154 | printf("New entry point: 0x%08x\n",0x20000000 + inlength + 8); | ||
155 | |||
156 | /* Save the original firmware entry point at the start of the bootloader image */ | ||
157 | put_uint32le(get_uint32le(image + origoffset),image+inlength); | ||
158 | put_uint32le(0x20000000 + inlength,image + inlength + 4); | ||
159 | |||
160 | /* Change the original firmware entry point to the third word in our bootloader */ | ||
161 | put_uint32le(0x20000000 + inlength + 8,image+origoffset); | ||
162 | |||
163 | |||
164 | telechips_encode_crc(image, inlength + bootlength); | ||
165 | |||
166 | fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); | ||
167 | if (fdout < 0) | ||
168 | { | ||
169 | perror(bootfile); | ||
170 | } | ||
171 | |||
172 | n = write(fdout, image, inlength + bootlength); | ||
173 | if (n != inlength + bootlength) | ||
174 | { | ||
175 | printf("[ERR] Could not write output file %s\n",outfile); | ||
176 | return 3; | ||
177 | } | ||
178 | |||
179 | close(fdin); | ||
180 | close(fdboot); | ||
181 | close(fdout); | ||
182 | |||
183 | return 0; | ||
184 | } | ||