diff options
21 files changed, 1408 insertions, 33 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 19bc9591c2..04b48f8471 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -51,7 +51,7 @@ ondavx747.c | |||
51 | show_logo.c | 51 | show_logo.c |
52 | #elif defined(CREATIVE_ZVx) | 52 | #elif defined(CREATIVE_ZVx) |
53 | creativezvm.c | 53 | creativezvm.c |
54 | #elif CONFIG_CPU==AS3525 | 54 | #elif CONFIG_CPU==AS3525 || CONFIG_CPU==AS3525v2 |
55 | sansa_as3525.c | 55 | sansa_as3525.c |
56 | show_logo.c | 56 | show_logo.c |
57 | #elif defined(LYRE_PROTO1) | 57 | #elif defined(LYRE_PROTO1) |
diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c index 7e6ac2dddb..8d6090ed17 100644 --- a/bootloader/sansa_as3525.c +++ b/bootloader/sansa_as3525.c | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | int show_logo(void); | 38 | int show_logo(void); |
39 | 39 | ||
40 | void main(void) __attribute__((naked, noreturn)); | 40 | void main(void) __attribute__((noreturn)); |
41 | void main(void) | 41 | void main(void) |
42 | { | 42 | { |
43 | unsigned char* loadbuffer; | 43 | unsigned char* loadbuffer; |
@@ -58,7 +58,7 @@ void main(void) | |||
58 | button_init_device(); | 58 | button_init_device(); |
59 | int btn = button_read_device(); | 59 | int btn = button_read_device(); |
60 | 60 | ||
61 | #if !defined(SANSA_FUZE) && !defined(SANSA_CLIP) | 61 | #if !defined(SANSA_FUZE) && !defined(SANSA_CLIP) && !defined(SANSA_CLIPV2) |
62 | if (button_hold()) | 62 | if (button_hold()) |
63 | { | 63 | { |
64 | verbose = true; | 64 | verbose = true; |
diff --git a/bootloader/show_logo.c b/bootloader/show_logo.c index c0627aa423..90cf222067 100644 --- a/bootloader/show_logo.c +++ b/bootloader/show_logo.c | |||
@@ -41,7 +41,7 @@ int show_logo( void ) | |||
41 | lcd_clear_display(); | 41 | lcd_clear_display(); |
42 | lcd_setfont(FONT_SYSFIXED); | 42 | lcd_setfont(FONT_SYSFIXED); |
43 | 43 | ||
44 | #ifdef SANSA_CLIP | 44 | #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) |
45 | /* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48 | 45 | /* The top 16 lines of the Sansa Clip screen are yellow, and the bottom 48 |
46 | are blue, so we reverse the usual positioning */ | 46 | are blue, so we reverse the usual positioning */ |
47 | lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION); | 47 | lcd_putsxy(TEXT_XPOS, 0, BOOT_VERSION); |
diff --git a/firmware/SOURCES b/firmware/SOURCES index ee1b5c4dc9..a0c0629868 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -402,11 +402,13 @@ target/arm/pnx0101/system-pnx0101.c | |||
402 | target/arm/pnx0101/timer-pnx0101.c | 402 | target/arm/pnx0101/timer-pnx0101.c |
403 | #endif | 403 | #endif |
404 | 404 | ||
405 | #if CONFIG_CPU == AS3525 | 405 | #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 |
406 | target/arm/as3525/system-as3525.c | 406 | target/arm/as3525/system-as3525.c |
407 | target/arm/as3525/kernel-as3525.c | 407 | target/arm/as3525/kernel-as3525.c |
408 | target/arm/as3525/timer-as3525.c | 408 | target/arm/as3525/timer-as3525.c |
409 | #ifndef SANSA_CLIPV2 | ||
409 | target/arm/as3525/ata_sd_as3525.c | 410 | target/arm/as3525/ata_sd_as3525.c |
411 | #endif | ||
410 | target/arm/as3525/power-as3525.c | 412 | target/arm/as3525/power-as3525.c |
411 | target/arm/as3525/usb-as3525.c | 413 | target/arm/as3525/usb-as3525.c |
412 | target/arm/as3525/dma-pl081.c | 414 | target/arm/as3525/dma-pl081.c |
@@ -1198,6 +1200,21 @@ target/arm/tcc77x/c100/audio-c100.c | |||
1198 | #endif /* SIMULATOR */ | 1200 | #endif /* SIMULATOR */ |
1199 | #endif /* SANSA_C100 */ | 1201 | #endif /* SANSA_C100 */ |
1200 | 1202 | ||
1203 | #ifdef SANSA_CLIPV2 | ||
1204 | #ifndef SIMULATOR | ||
1205 | target/arm/as3525/sansa-clip/lcd-ssd1303.c | ||
1206 | target/arm/as3525/sansa-clip/lcd-as-clip.S | ||
1207 | |||
1208 | target/arm/as3525/sansa-clipv2/sd-clipv2.c | ||
1209 | target/arm/as3525/sansa-clipv2/button-clip.c | ||
1210 | target/arm/as3525/sansa-clipv2/backlight-clip.c | ||
1211 | #ifndef BOOTLOADER | ||
1212 | target/arm/powermgmt-ascodec.c | ||
1213 | target/arm/as3525/sansa-clip/powermgmt-clip.c | ||
1214 | #endif /* !BOOTLOADER */ | ||
1215 | #endif /* !SIMULATOR */ | ||
1216 | #endif /* SANSA_CLIPV2 */ | ||
1217 | |||
1201 | #ifdef SANSA_CLIP | 1218 | #ifdef SANSA_CLIP |
1202 | #ifndef SIMULATOR | 1219 | #ifndef SIMULATOR |
1203 | target/arm/as3525/sansa-clip/lcd-ssd1303.c | 1220 | target/arm/as3525/sansa-clip/lcd-ssd1303.c |
diff --git a/firmware/export/as3525v2.h b/firmware/export/as3525v2.h new file mode 100644 index 0000000000..2a2f67cbc5 --- /dev/null +++ b/firmware/export/as3525v2.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2009 Rafaël Carré | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
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 | #ifndef __AS3525V2_H__ | ||
23 | #define __AS3525V2_H__ | ||
24 | |||
25 | #include "as3525.h" | ||
26 | |||
27 | /* insert differences here */ | ||
28 | |||
29 | #endif /* __AS3525V2_H__ */ | ||
diff --git a/firmware/export/config.h b/firmware/export/config.h index 01933dadf2..2b7c6d8663 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -71,6 +71,7 @@ | |||
71 | #define JZ4732 4732 | 71 | #define JZ4732 4732 |
72 | #define AS3525 3525 | 72 | #define AS3525 3525 |
73 | #define AT91SAM9260 9260 | 73 | #define AT91SAM9260 9260 |
74 | #define AS3525v2 35252 | ||
74 | 75 | ||
75 | /* CONFIG_KEYPAD */ | 76 | /* CONFIG_KEYPAD */ |
76 | #define PLAYER_PAD 1 | 77 | #define PLAYER_PAD 1 |
@@ -377,6 +378,8 @@ Lyre prototype 1 */ | |||
377 | #include "config/ondavx767.h" | 378 | #include "config/ondavx767.h" |
378 | #elif defined(SANSA_CLIP) | 379 | #elif defined(SANSA_CLIP) |
379 | #include "config/sansaclip.h" | 380 | #include "config/sansaclip.h" |
381 | #elif defined(SANSA_CLIPV2) | ||
382 | #include "config/sansaclipv2.h" | ||
380 | #elif defined(SANSA_E200V2) | 383 | #elif defined(SANSA_E200V2) |
381 | #include "config/sansae200v2.h" | 384 | #include "config/sansae200v2.h" |
382 | #elif defined(SANSA_M200V4) | 385 | #elif defined(SANSA_M200V4) |
@@ -456,15 +459,13 @@ Lyre prototype 1 */ | |||
456 | #if (CONFIG_CPU == IMX31L) | 459 | #if (CONFIG_CPU == IMX31L) |
457 | #define CPU_ARM | 460 | #define CPU_ARM |
458 | #define ARM_ARCH 6 /* ARMv6 */ | 461 | #define ARM_ARCH 6 /* ARMv6 */ |
459 | #endif | ||
460 | 462 | ||
461 | #if defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \ | 463 | #elif defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \ |
462 | || (CONFIG_CPU == AT91SAM9260) | 464 | || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) |
463 | #define CPU_ARM | 465 | #define CPU_ARM |
464 | #define ARM_ARCH 5 /* ARMv5 */ | 466 | #define ARM_ARCH 5 /* ARMv5 */ |
465 | #endif | ||
466 | 467 | ||
467 | #if defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ | 468 | #elif defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ |
468 | || (CONFIG_CPU == DSC25) || defined(CPU_S5L870X) || (CONFIG_CPU == AS3525) | 469 | || (CONFIG_CPU == DSC25) || defined(CPU_S5L870X) || (CONFIG_CPU == AS3525) |
469 | #define CPU_ARM | 470 | #define CPU_ARM |
470 | #define ARM_ARCH 4 /* ARMv4 */ | 471 | #define ARM_ARCH 4 /* ARMv4 */ |
@@ -675,8 +676,8 @@ Lyre prototype 1 */ | |||
675 | #endif /* BOOTLOADER */ | 676 | #endif /* BOOTLOADER */ |
676 | 677 | ||
677 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ | 678 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ |
678 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == S3C2440) \ | 679 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \ |
679 | || defined(CPU_S5L870X) | 680 | || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) |
680 | #define HAVE_WAKEUP_OBJECTS | 681 | #define HAVE_WAKEUP_OBJECTS |
681 | #endif | 682 | #endif |
682 | 683 | ||
diff --git a/firmware/export/config/sansaclipv2.h b/firmware/export/config/sansaclipv2.h new file mode 100644 index 0000000000..513b093f2f --- /dev/null +++ b/firmware/export/config/sansaclipv2.h | |||
@@ -0,0 +1,215 @@ | |||
1 | /* | ||
2 | * This config file is for the Sandisk Sansa Clip v2 | ||
3 | */ | ||
4 | #define TARGET_TREE /* this target is using the target tree system */ | ||
5 | |||
6 | /* For Rolo and boot loader */ | ||
7 | #define MODEL_NUMBER 66 | ||
8 | #define MODEL_NAME "Sandisk Sansa Clipv2" | ||
9 | #define FIRMWARE_OFFSET_FILE_DATA 8 | ||
10 | #define FIRMWARE_OFFSET_FILE_CRC 0 | ||
11 | |||
12 | #if 0 /* disabled since there is no driver (yet) */ | ||
13 | |||
14 | #define HW_SAMPR_CAPS (SAMPR_CAP_44) | ||
15 | |||
16 | /* define this if you have recording possibility */ | ||
17 | #define HAVE_RECORDING | ||
18 | |||
19 | #define REC_SAMPR_CAPS (SAMPR_CAP_22) | ||
20 | #define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ | ||
21 | #define REC_SAMPR_DEFAULT SAMPR_22 | ||
22 | |||
23 | #endif | ||
24 | |||
25 | /* Define bitmask of input sources - recordable bitmask can be defined | ||
26 | explicitly if different */ | ||
27 | #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) | ||
28 | |||
29 | /* define this if you have a bitmap LCD display */ | ||
30 | #define HAVE_LCD_BITMAP | ||
31 | |||
32 | /* define this if you have a light associated with the buttons */ | ||
33 | #define HAVE_BUTTON_LIGHT | ||
34 | |||
35 | /* define this if you have access to the quickscreen */ | ||
36 | #define HAVE_QUICKSCREEN | ||
37 | |||
38 | /* define this if you have access to the pitchscreen */ | ||
39 | #define HAVE_PITCHSCREEN | ||
40 | |||
41 | /* define this if you would like tagcache to build on this target */ | ||
42 | #define HAVE_TAGCACHE | ||
43 | |||
44 | /* LCD dimensions */ | ||
45 | #define LCD_WIDTH 128 | ||
46 | #define LCD_HEIGHT 64 | ||
47 | #define LCD_DEPTH 1 | ||
48 | |||
49 | #define LCD_PIXELFORMAT VERTICAL_PACKING | ||
50 | #define HAVE_NEGATIVE_LCD /* bright on dark */ | ||
51 | #define HAVE_LCD_SPLIT /* split display */ | ||
52 | |||
53 | /* Display colours, for screenshots and sim (0xRRGGBB) */ | ||
54 | #define LCD_DARKCOLOR 0x000000 | ||
55 | #define LCD_BRIGHTCOLOR 0x000000 | ||
56 | #define LCD_BL_DARKCOLOR 0x000000 | ||
57 | #define LCD_BL_BRIGHTCOLOR 0x0de2e5 | ||
58 | |||
59 | #define LCD_DARKCOLOR_2 0x000000 | ||
60 | #define LCD_BRIGHTCOLOR_2 0x000000 | ||
61 | #define LCD_BL_DARKCOLOR_2 0x000000 | ||
62 | #define LCD_BL_BRIGHTCOLOR_2 0xffe60f | ||
63 | |||
64 | #define LCD_SPLIT_POS 16 | ||
65 | #define LCD_SPLIT_LINES 2 | ||
66 | |||
67 | /* define this if you have LCD enable function */ | ||
68 | #define HAVE_LCD_ENABLE | ||
69 | |||
70 | #ifndef BOOTLOADER | ||
71 | /* Define this if your LCD can be put to sleep. | ||
72 | * HAVE_LCD_ENABLE should be defined as well. */ | ||
73 | //#define HAVE_LCD_SLEEP | ||
74 | //#define HAVE_LCD_SLEEP_SETTING | ||
75 | #endif | ||
76 | |||
77 | /* define this if you can flip your LCD */ | ||
78 | #define HAVE_LCD_FLIP | ||
79 | |||
80 | /* define this if you can invert the pixels */ | ||
81 | #define HAVE_LCD_INVERT | ||
82 | |||
83 | /* Define this if your LCD can set contrast */ | ||
84 | #define HAVE_LCD_CONTRAST | ||
85 | |||
86 | #define MIN_CONTRAST_SETTING 0 | ||
87 | #define MAX_CONTRAST_SETTING 50 | ||
88 | #define DEFAULT_CONTRAST_SETTING 30 | ||
89 | |||
90 | #define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */ | ||
91 | |||
92 | #define CONFIG_KEYPAD SANSA_CLIP_PAD | ||
93 | |||
94 | /* define this if the target has volume keys which can be used in the lists */ | ||
95 | #define HAVE_VOLUME_IN_LIST | ||
96 | |||
97 | /* Define this if you do software codec */ | ||
98 | #define CONFIG_CODEC SWCODEC | ||
99 | /* There is no hardware tone control */ | ||
100 | #define HAVE_SW_TONE_CONTROLS | ||
101 | |||
102 | /* We're working on the assumption that the AS3525 has something | ||
103 | similar to the AS3514 for audio codec etc */ | ||
104 | #define HAVE_AS3514 | ||
105 | |||
106 | /* define this if you have a real-time clock */ | ||
107 | #ifndef BOOTLOADER | ||
108 | #define CONFIG_RTC RTC_AS3514 | ||
109 | #endif | ||
110 | |||
111 | /* Define this if you have a software controlled poweroff */ | ||
112 | #define HAVE_SW_POWEROFF | ||
113 | |||
114 | #define HAVE_FAT16SUPPORT | ||
115 | |||
116 | /* The number of bytes reserved for loadable codecs */ | ||
117 | #define CODEC_SIZE 0x100000 | ||
118 | |||
119 | /* The number of bytes reserved for loadable plugins */ | ||
120 | #define PLUGIN_BUFFER_SIZE 0x80000 | ||
121 | |||
122 | #define AB_REPEAT_ENABLE 1 | ||
123 | |||
124 | /* FM Tuner */ | ||
125 | #define CONFIG_TUNER SI4700 /* in fact SI4702 */ | ||
126 | //#define HAVE_TUNER_PWR_CTRL | ||
127 | |||
128 | /* Define this for LCD backlight available */ | ||
129 | #define HAVE_BACKLIGHT | ||
130 | |||
131 | /* define this if you have a flash memory storage */ | ||
132 | #define HAVE_FLASH_STORAGE | ||
133 | |||
134 | /* define this if the flash memory uses the SecureDigital Memory Card protocol */ | ||
135 | #define CONFIG_STORAGE STORAGE_SD | ||
136 | |||
137 | #define BATTERY_CAPACITY_DEFAULT 380 /* default battery capacity */ | ||
138 | #define BATTERY_CAPACITY_MIN 380 /* min. capacity selectable */ | ||
139 | #define BATTERY_CAPACITY_MAX 380 /* max. capacity selectable */ | ||
140 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ | ||
141 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | ||
142 | |||
143 | /* Charging implemented in a target-specific algorithm */ | ||
144 | #define CONFIG_CHARGING CHARGING_TARGET | ||
145 | |||
146 | /* define this if the unit can be powered or charged via USB */ | ||
147 | #define HAVE_USB_POWER | ||
148 | |||
149 | /** Non-simulator section **/ | ||
150 | #ifndef SIMULATOR | ||
151 | |||
152 | /* Define this if you have a AMS AS3525v2 SoC */ | ||
153 | #define CONFIG_CPU AS3525v2 | ||
154 | |||
155 | /* Define this if you want to use the AS3525 i2c interface */ | ||
156 | #define CONFIG_I2C I2C_AS3525 /* FIXME : looks similar to AS353x interface */ | ||
157 | |||
158 | /* define this if the hardware can be powered off while charging */ | ||
159 | /* Sansa can't be powered off while charging */ | ||
160 | /* #define HAVE_POWEROFF_WHILE_CHARGING */ | ||
161 | |||
162 | /* The start address index for ROM builds */ | ||
163 | #define ROM_START 0x00000000 | ||
164 | |||
165 | /* Define this to the CPU frequency */ | ||
166 | #define CPU_FREQ 250000000 | ||
167 | |||
168 | /* Type of LCD */ | ||
169 | #define CONFIG_LCD LCD_SSD1303 | ||
170 | |||
171 | #ifndef BOOTLOADER | ||
172 | |||
173 | #define USB_HANDLED_BY_OF | ||
174 | |||
175 | #if 0 /* disabled since there is no USB driver */ | ||
176 | |||
177 | /* USB On-the-go */ | ||
178 | #define CONFIG_USBOTG USBOTG_ARC | ||
179 | |||
180 | /* enable these for the experimental usb stack */ | ||
181 | #define HAVE_USBSTACK | ||
182 | #define USB_VENDOR_ID 0x0781 | ||
183 | #define USB_PRODUCT_ID 0x7433 | ||
184 | #endif /* BOOTLOADER */ | ||
185 | |||
186 | #endif | ||
187 | |||
188 | |||
189 | /* Virtual LED (icon) */ | ||
190 | #define CONFIG_LED LED_VIRTUAL | ||
191 | |||
192 | /* Define this if you have adjustable CPU frequency */ | ||
193 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
194 | |||
195 | #define BOOTFILE_EXT "sansa" | ||
196 | #define BOOTFILE "rockbox." BOOTFILE_EXT | ||
197 | #define BOOTDIR "/.rockbox" | ||
198 | |||
199 | #define ICODE_ATTR_TREMOR_NOT_MDCT | ||
200 | |||
201 | #define INCLUDE_TIMEOUT_API | ||
202 | |||
203 | #endif /* SIMULATOR */ | ||
204 | |||
205 | /** Port-specific settings **/ | ||
206 | |||
207 | /* Main LCD backlight brightness range and defaults */ | ||
208 | #define MIN_BRIGHTNESS_SETTING 1 | ||
209 | #define MAX_BRIGHTNESS_SETTING 12 | ||
210 | #define DEFAULT_BRIGHTNESS_SETTING 6 | ||
211 | |||
212 | /* Default recording levels */ | ||
213 | #define DEFAULT_REC_MIC_GAIN 23 | ||
214 | #define DEFAULT_REC_LEFT_GAIN 23 | ||
215 | #define DEFAULT_REC_RIGHT_GAIN 23 | ||
diff --git a/firmware/export/cpu.h b/firmware/export/cpu.h index 47de38c378..381830ab52 100644 --- a/firmware/export/cpu.h +++ b/firmware/export/cpu.h | |||
@@ -68,4 +68,6 @@ | |||
68 | #if CONFIG_CPU == AS3525 | 68 | #if CONFIG_CPU == AS3525 |
69 | #include "as3525.h" | 69 | #include "as3525.h" |
70 | #endif | 70 | #endif |
71 | 71 | #if CONFIG_CPU == AS3525v2 | |
72 | #include "as3525v2.h" | ||
73 | #endif | ||
diff --git a/firmware/target/arm/as3525/boot.lds b/firmware/target/arm/as3525/boot.lds index 9c6d6faf11..dcc291b54f 100644 --- a/firmware/target/arm/as3525/boot.lds +++ b/firmware/target/arm/as3525/boot.lds | |||
@@ -6,24 +6,29 @@ OUTPUT_FORMAT(elf32-littlearm) | |||
6 | OUTPUT_ARCH(arm) | 6 | OUTPUT_ARCH(arm) |
7 | STARTUP(target/arm/crt0.o) | 7 | STARTUP(target/arm/crt0.o) |
8 | 8 | ||
9 | #define IRAMORIG 0x81000000 | 9 | #ifdef SANSA_CLIPV2 |
10 | #define IRAMSIZE 0x50000 | 10 | #define RAMORIG 0x0 /* DRAM */ |
11 | #define RAMSIZE (MEM*0x100000) | ||
12 | #else | ||
13 | #define RAMORIG 0x81000000 /* IRAM */ | ||
14 | #define RAMSIZE 0x50000 | ||
15 | #endif | ||
11 | 16 | ||
12 | MEMORY | 17 | MEMORY |
13 | { | 18 | { |
14 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | 19 | RAM : ORIGIN = RAMORIG, LENGTH = RAMSIZE |
15 | } | 20 | } |
16 | 21 | ||
17 | SECTIONS | 22 | SECTIONS |
18 | { | 23 | { |
19 | . = IRAMORIG; | 24 | . = RAMORIG; |
20 | 25 | ||
21 | .text : { | 26 | .text : { |
22 | *(.init.text) | 27 | *(.init.text) |
23 | *(.glue_7) | 28 | *(.glue_7) |
24 | *(.glue_7t) | 29 | *(.glue_7t) |
25 | *(.text*) | 30 | *(.text*) |
26 | } > IRAM | 31 | } > RAM |
27 | 32 | ||
28 | .data : { | 33 | .data : { |
29 | *(.icode) | 34 | *(.icode) |
@@ -33,7 +38,7 @@ SECTIONS | |||
33 | *(.ncdata*) | 38 | *(.ncdata*) |
34 | *(.rodata*) | 39 | *(.rodata*) |
35 | _dataend = . ; | 40 | _dataend = . ; |
36 | } > IRAM | 41 | } > RAM |
37 | 42 | ||
38 | .stack : | 43 | .stack : |
39 | { | 44 | { |
@@ -43,7 +48,7 @@ SECTIONS | |||
43 | . += 0x2000; | 48 | . += 0x2000; |
44 | _stackend = .; | 49 | _stackend = .; |
45 | stackend = .; | 50 | stackend = .; |
46 | } > IRAM | 51 | } > RAM |
47 | 52 | ||
48 | .bss : { | 53 | .bss : { |
49 | _edata = .; | 54 | _edata = .; |
@@ -52,5 +57,5 @@ SECTIONS | |||
52 | *(COMMON) | 57 | *(COMMON) |
53 | *(.ncbss*); | 58 | *(.ncbss*); |
54 | _end = .; | 59 | _end = .; |
55 | } > IRAM | 60 | } > RAM |
56 | } | 61 | } |
diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h index bc112fdea8..08c385c7cd 100644 --- a/firmware/target/arm/as3525/clock-target.h +++ b/firmware/target/arm/as3525/clock-target.h | |||
@@ -56,6 +56,13 @@ | |||
56 | #define AS3525_CLK_FCLK 3 /* Available as PCLK input only */ | 56 | #define AS3525_CLK_FCLK 3 /* Available as PCLK input only */ |
57 | 57 | ||
58 | /** ************ Change these to reconfigure clocking scheme *******************/ | 58 | /** ************ Change these to reconfigure clocking scheme *******************/ |
59 | #ifdef SANSA_CLIPV2 | ||
60 | |||
61 | /* PLL* registers differ from AS3525 */ | ||
62 | #define AS3525_PLLA_FREQ 240000000 | ||
63 | |||
64 | #else | ||
65 | |||
59 | /* PLL frequencies and settings*/ | 66 | /* PLL frequencies and settings*/ |
60 | #define AS3525_PLLA_FREQ 248000000 /*124,82.7,62,49.6,41.3,35.4 */ | 67 | #define AS3525_PLLA_FREQ 248000000 /*124,82.7,62,49.6,41.3,35.4 */ |
61 | /* FCLK_PREDIV-> *7/8 = 217MHz 108.5 ,72.3, 54.25, 43.4, 36.17 */ | 68 | /* FCLK_PREDIV-> *7/8 = 217MHz 108.5 ,72.3, 54.25, 43.4, 36.17 */ |
@@ -63,6 +70,8 @@ | |||
63 | /* *5/8 = 155MHz 77.5, 51.67, 38.75 */ | 70 | /* *5/8 = 155MHz 77.5, 51.67, 38.75 */ |
64 | #define AS3525_PLLA_SETTING 0x261F | 71 | #define AS3525_PLLA_SETTING 0x261F |
65 | 72 | ||
73 | #endif /* SANSA_CLIPV2 */ | ||
74 | |||
66 | //#define AS3525_PLLA_FREQ 384000000 /*192,128,96,76.8,64,54.9,48,42.7,38.4*/ | 75 | //#define AS3525_PLLA_FREQ 384000000 /*192,128,96,76.8,64,54.9,48,42.7,38.4*/ |
67 | /* FCLK_PREDIV-> *7/8 = 336MHz 168, 112, 84, 67.2, 56, 48, 42, 37.3*/ | 76 | /* FCLK_PREDIV-> *7/8 = 336MHz 168, 112, 84, 67.2, 56, 48, 42, 37.3*/ |
68 | /* *6/8 = 288MHz 144, 96, 72, 57.6, 48, 41.1, */ | 77 | /* *6/8 = 288MHz 144, 96, 72, 57.6, 48, 41.1, */ |
@@ -118,7 +127,13 @@ | |||
118 | 127 | ||
119 | #define AS3525_IDE_SEL AS3525_CLK_PLLA /* Input Source */ | 128 | #define AS3525_IDE_SEL AS3525_CLK_PLLA /* Input Source */ |
120 | #define AS3525_IDE_DIV (CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1)/*div=1/(n+1)*/ | 129 | #define AS3525_IDE_DIV (CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1)/*div=1/(n+1)*/ |
130 | |||
131 | #ifdef SANSA_CLIPV2 | ||
132 | #define AS3525_MS_FREQ 120000000 | ||
133 | #define AS3525_IDE_FREQ 80000000 | ||
134 | #else | ||
121 | #define AS3525_IDE_FREQ 50000000 /* The OF uses 66MHz maximal freq */ | 135 | #define AS3525_IDE_FREQ 50000000 /* The OF uses 66MHz maximal freq */ |
136 | #endif /* SANSA_CLIPV2 */ | ||
122 | 137 | ||
123 | 138 | ||
124 | //#define AS3525_USB_SEL AS3525_CLK_PLLA /* Input Source */ | 139 | //#define AS3525_USB_SEL AS3525_CLK_PLLA /* Input Source */ |
diff --git a/firmware/target/arm/as3525/fmradio-i2c-as3525.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c index d987938d3a..6cdf0c7c7f 100644 --- a/firmware/target/arm/as3525/fmradio-i2c-as3525.c +++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c | |||
@@ -37,6 +37,12 @@ | |||
37 | #define I2C_SCL_PIN 4 | 37 | #define I2C_SCL_PIN 4 |
38 | #define I2C_SDA_PIN 5 | 38 | #define I2C_SDA_PIN 5 |
39 | 39 | ||
40 | #elif defined(SANSA_CLIPV2) | ||
41 | #define I2C_GPIO(x) GPIOB_PIN(x) | ||
42 | #define I2C_GPIO_DIR GPIOB_DIR | ||
43 | #define I2C_SCL_PIN 6 | ||
44 | #define I2C_SDA_PIN 7 | ||
45 | |||
40 | #elif defined(SANSA_M200V4) | 46 | #elif defined(SANSA_M200V4) |
41 | #define I2C_GPIO(x) GPIOD_PIN(x) | 47 | #define I2C_GPIO(x) GPIOD_PIN(x) |
42 | #define I2C_GPIO_DIR GPIOD_DIR | 48 | #define I2C_GPIO_DIR GPIOD_DIR |
diff --git a/firmware/target/arm/as3525/powermgmt-target.h b/firmware/target/arm/as3525/powermgmt-target.h index d458508275..269a89349e 100644 --- a/firmware/target/arm/as3525/powermgmt-target.h +++ b/firmware/target/arm/as3525/powermgmt-target.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #ifndef POWERMGMT_TARGET_H | 22 | #ifndef POWERMGMT_TARGET_H |
23 | #define POWERMGMT_TARGET_H | 23 | #define POWERMGMT_TARGET_H |
24 | 24 | ||
25 | #if defined(SANSA_CLIP) | 25 | #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) |
26 | 26 | ||
27 | /* Check if topped-off and monitor voltage while plugged. */ | 27 | /* Check if topped-off and monitor voltage while plugged. */ |
28 | #define BATT_FULL_VOLTAGE 4160 | 28 | #define BATT_FULL_VOLTAGE 4160 |
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c index 1ca26dd1a1..45de3e80dc 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c +++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Alan Korr | 10 | * Copyright (C) 2002 by Alan Korr |
11 | * Copyright (C) 2008 François Dinel | 11 | * Copyright (C) 2008 François Dinel |
12 | * Copyright (C) 2008 Rafaël Carré | 12 | * Copyright (C) 2008-2009 Rafaël Carré |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU General Public License | 15 | * modify it under the terms of the GNU General Public License |
@@ -30,7 +30,12 @@ | |||
30 | #include "string.h" | 30 | #include "string.h" |
31 | 31 | ||
32 | /*** AS3525 specifics ***/ | 32 | /*** AS3525 specifics ***/ |
33 | #ifdef SANSA_CLIPV2 | ||
34 | #include "as3525v2.h" | ||
35 | #else | ||
33 | #include "as3525.h" | 36 | #include "as3525.h" |
37 | #endif | ||
38 | |||
34 | #include "ascodec.h" | 39 | #include "ascodec.h" |
35 | 40 | ||
36 | /*** definitions ***/ | 41 | /*** definitions ***/ |
@@ -71,6 +76,7 @@ | |||
71 | /* DBOP initialisation, do what OF does */ | 76 | /* DBOP initialisation, do what OF does */ |
72 | static void ams3525_dbop_init(void) | 77 | static void ams3525_dbop_init(void) |
73 | { | 78 | { |
79 | #ifdef SANSA_CLIP | ||
74 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | 80 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; |
75 | 81 | ||
76 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ | 82 | GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */ |
@@ -79,14 +85,34 @@ static void ams3525_dbop_init(void) | |||
79 | DBOP_CTRL = 0x51008; | 85 | DBOP_CTRL = 0x51008; |
80 | DBOP_TIMPOL_01 = 0x6E167; | 86 | DBOP_TIMPOL_01 = 0x6E167; |
81 | DBOP_TIMPOL_23 = 0xA167E06F; | 87 | DBOP_TIMPOL_23 = 0xA167E06F; |
88 | #else /* SANSA_CLIPV2 */ | ||
89 | CCU_IO |= (1<<12); /* ?? */ | ||
90 | CGU_DBOP |= /*(1<<3)*/ 0x18 | AS3525_DBOP_DIV; | ||
91 | |||
92 | DBOP_CTRL = 0x51004; | ||
93 | DBOP_TIMPOL_01 = 0x36A12F; | ||
94 | DBOP_TIMPOL_23 = 0xE037E037; | ||
95 | #endif | ||
82 | } | 96 | } |
83 | 97 | ||
98 | #ifdef SANSA_CLIP | ||
99 | #define LCD_DELAY 1 | ||
100 | #else /* SANSA_CLIPV2 */ | ||
101 | #define LCD_DELAY 10 | ||
102 | #endif | ||
103 | |||
84 | void lcd_write_command(int byte) | 104 | void lcd_write_command(int byte) |
85 | { | 105 | { |
86 | volatile int i = 0; | 106 | volatile int i = 0; |
87 | while(i<1) i++; | 107 | while(i<LCD_DELAY) i++; |
108 | |||
88 | /* unset D/C# (data or command) */ | 109 | /* unset D/C# (data or command) */ |
110 | #ifdef SANSA_CLIP | ||
89 | GPIOA_PIN(5) = 0; | 111 | GPIOA_PIN(5) = 0; |
112 | #else /* SANSA_CLIPV2 */ | ||
113 | GPIOB_PIN(2) = 0; | ||
114 | DBOP_TIMPOL_23 = 0xE0370036; | ||
115 | #endif | ||
90 | 116 | ||
91 | /* Write command */ | 117 | /* Write command */ |
92 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ | 118 | /* Only bits 15:12 and 3:0 of DBOP_DOUT are meaningful */ |
@@ -95,14 +121,22 @@ void lcd_write_command(int byte) | |||
95 | /* While push fifo is not empty */ | 121 | /* While push fifo is not empty */ |
96 | while ((DBOP_STAT & (1<<10)) == 0) | 122 | while ((DBOP_STAT & (1<<10)) == 0) |
97 | ; | 123 | ; |
124 | |||
125 | #ifdef SANSA_CLIPV2 | ||
126 | DBOP_TIMPOL_23 = 0xE0370036; | ||
127 | #endif | ||
98 | } | 128 | } |
99 | 129 | ||
100 | void lcd_write_data(const fb_data* p_bytes, int count) | 130 | void lcd_write_data(const fb_data* p_bytes, int count) |
101 | { | 131 | { |
102 | volatile int i = 0; | 132 | volatile int i = 0; |
103 | while(i<1) i++; | 133 | while(i<LCD_DELAY) i++; |
104 | /* set D/C# (data or command) */ | 134 | /* set D/C# (data or command) */ |
135 | #ifdef SANSA_CLIP | ||
105 | GPIOA_PIN(5) = (1<<5); | 136 | GPIOA_PIN(5) = (1<<5); |
137 | #else /* SANSA_CLIPV2 */ | ||
138 | GPIOB_PIN(2) = (1<<2); | ||
139 | #endif | ||
106 | 140 | ||
107 | while (count--) | 141 | while (count--) |
108 | { | 142 | { |
@@ -139,9 +173,9 @@ void lcd_set_contrast(int val) | |||
139 | 173 | ||
140 | void lcd_set_invert_display(bool yesno) | 174 | void lcd_set_invert_display(bool yesno) |
141 | { | 175 | { |
142 | if (yesno) | 176 | if (yesno) |
143 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | 177 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); |
144 | else | 178 | else |
145 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | 179 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); |
146 | } | 180 | } |
147 | 181 | ||
@@ -168,8 +202,10 @@ void lcd_enable(bool enable) | |||
168 | 202 | ||
169 | if( (display_on = enable) ) /* simple '=' is not a typo ! */ | 203 | if( (display_on = enable) ) /* simple '=' is not a typo ! */ |
170 | { | 204 | { |
205 | #ifdef SANSA_CLIP | ||
171 | /* Enable DC-DC AS3525 for some Clip v1 that need it */ | 206 | /* Enable DC-DC AS3525 for some Clip v1 that need it */ |
172 | ascodec_write(AS3514_DCDC15, 1); | 207 | ascodec_write(AS3514_DCDC15, 1); |
208 | #endif | ||
173 | 209 | ||
174 | lcd_write_command(LCD_SET_DISPLAY_ON); | 210 | lcd_write_command(LCD_SET_DISPLAY_ON); |
175 | send_event(LCD_EVENT_ACTIVATION, NULL); | 211 | send_event(LCD_EVENT_ACTIVATION, NULL); |
@@ -177,8 +213,10 @@ void lcd_enable(bool enable) | |||
177 | else { | 213 | else { |
178 | lcd_write_command(LCD_SET_DISPLAY_OFF); | 214 | lcd_write_command(LCD_SET_DISPLAY_OFF); |
179 | 215 | ||
216 | #ifdef SANSA_CLIP | ||
180 | /* Disable DC-DC AS3525 */ | 217 | /* Disable DC-DC AS3525 */ |
181 | ascodec_write(AS3514_DCDC15, 0); | 218 | ascodec_write(AS3514_DCDC15, 0); |
219 | #endif | ||
182 | } | 220 | } |
183 | } | 221 | } |
184 | 222 | ||
@@ -198,6 +236,7 @@ void lcd_init_device(void) | |||
198 | 236 | ||
199 | ams3525_dbop_init(); | 237 | ams3525_dbop_init(); |
200 | 238 | ||
239 | #ifdef SANSA_CLIP | ||
201 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ | 240 | GPIOA_DIR |= 0x33; /* pins 5:4 and 1:0 out */ |
202 | GPIOB_DIR |= 0x40; /* pin 6 out */ | 241 | GPIOB_DIR |= 0x40; /* pin 6 out */ |
203 | 242 | ||
@@ -205,6 +244,10 @@ void lcd_init_device(void) | |||
205 | GPIOA_PIN(0) = (1<<0); | 244 | GPIOA_PIN(0) = (1<<0); |
206 | GPIOA_PIN(4) = 0; | 245 | GPIOA_PIN(4) = 0; |
207 | GPIOB_PIN(6) = (1<<6); | 246 | GPIOB_PIN(6) = (1<<6); |
247 | #else /* SANSA_CLIPV2 */ | ||
248 | GPIOB_DIR |= (1<<2)|(1<<5); | ||
249 | GPIOB_PIN(5) = (1<<5); | ||
250 | #endif | ||
208 | 251 | ||
209 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ | 252 | /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ |
210 | lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); | 253 | lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); |
@@ -247,7 +290,7 @@ void lcd_init_device(void) | |||
247 | lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/); | 290 | lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/); |
248 | lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/); | 291 | lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/); |
249 | 292 | ||
250 | memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ | 293 | memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ |
251 | 294 | ||
252 | for(i = 0; i < 8; i++) | 295 | for(i = 0; i < 8; i++) |
253 | { | 296 | { |
diff --git a/firmware/target/arm/as3525/sansa-clipv2/backlight-clip.c b/firmware/target/arm/as3525/sansa-clipv2/backlight-clip.c new file mode 100644 index 0000000000..dc36b5237f --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipv2/backlight-clip.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2009 Rafaël Carré | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
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 "backlight-target.h" | ||
23 | #include "lcd.h" | ||
24 | #include "as3525v2.h" | ||
25 | #include "ascodec-target.h" | ||
26 | |||
27 | void _backlight_on(void) | ||
28 | { | ||
29 | ascodec_write(0x25, ascodec_read(0x25) | 2); /* lcd power */ | ||
30 | ascodec_write(0x1c, 8|1); | ||
31 | ascodec_write(0x1b, 0x90); | ||
32 | lcd_enable(true); | ||
33 | } | ||
34 | |||
35 | void _backlight_off(void) | ||
36 | { | ||
37 | ascodec_write(0x25, ascodec_read(0x25) & ~2); /* lcd power */ | ||
38 | lcd_enable(false); | ||
39 | } | ||
40 | |||
41 | void _buttonlight_on(void) | ||
42 | { | ||
43 | GPIOA_DIR |= (1<<5); | ||
44 | GPIOA_PIN(5) = (1<<5); /* set pin a5 high */ | ||
45 | } | ||
46 | |||
47 | void _buttonlight_off(void) | ||
48 | { | ||
49 | GPIOA_DIR |= (1<<5); | ||
50 | GPIOA_PIN(5) = 0; /* set pin a5 low */ | ||
51 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-clipv2/backlight-target.h b/firmware/target/arm/as3525/sansa-clipv2/backlight-target.h new file mode 100644 index 0000000000..d202408356 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipv2/backlight-target.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2009 Rafaël Carré | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #define _backlight_init() true | ||
25 | |||
26 | void _backlight_on(void); | ||
27 | void _backlight_off(void); | ||
28 | |||
29 | void _buttonlight_on(void); | ||
30 | void _buttonlight_off(void); | ||
31 | |||
32 | #endif | ||
diff --git a/firmware/target/arm/as3525/sansa-clipv2/button-clip.c b/firmware/target/arm/as3525/sansa-clipv2/button-clip.c new file mode 100644 index 0000000000..4291665e3d --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipv2/button-clip.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * Copyright © 2008-2009 Rafaël Carré | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #include "button-target.h" | ||
23 | #include "as3525v2.h" | ||
24 | #include "kernel.h" | ||
25 | |||
26 | /* FIXME : use Clipv1 like driver (FS#10285) */ | ||
27 | |||
28 | void button_init_device(void) | ||
29 | { | ||
30 | GPIOA_DIR &= ~((1<<7) | (1<<3)); | ||
31 | GPIOD_DIR &= ~((1<<2) | (1<<1) | (1<<0)); | ||
32 | GPIOD_PIN(3) = 1<<3; | ||
33 | GPIOD_PIN(4) = 1<<4; | ||
34 | GPIOD_PIN(5) = 1<<5; | ||
35 | GPIOD_DIR |= ((1<<5) | (1<<4) | (1<<3)); | ||
36 | } | ||
37 | |||
38 | int button_read_device(void) | ||
39 | { | ||
40 | int result = 0; | ||
41 | static unsigned power_counter = 0; | ||
42 | |||
43 | if(button_hold()) | ||
44 | { | ||
45 | power_counter = HZ; | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | /* direct GPIO connections */ | ||
50 | /* read power, but not if hold button was just released, since | ||
51 | * you basically always hit power due to the slider mechanism after | ||
52 | * releasing hold (wait 1 sec) */ | ||
53 | if (power_counter) | ||
54 | power_counter--; | ||
55 | |||
56 | if (GPIOA_PIN(7) && !power_counter) | ||
57 | result |= BUTTON_POWER; | ||
58 | |||
59 | /* This is a keypad using D3-D5 as columns and D0-D2 as rows */ | ||
60 | |||
61 | GPIOD_PIN(3) = 0x00; /* activate D3 */ | ||
62 | asm volatile ("nop\nnop\nnop\nnop\nnop\n"); /* wait a bit for reliable results */ | ||
63 | |||
64 | /* D3D0 is unused */ | ||
65 | |||
66 | if (!GPIOD_PIN(1)) | ||
67 | result |= BUTTON_VOL_UP; | ||
68 | |||
69 | if (!GPIOD_PIN(2)) | ||
70 | result |= BUTTON_UP; | ||
71 | |||
72 | GPIOD_PIN(3) = 1<<3; | ||
73 | |||
74 | GPIOD_PIN(4) = 0x00; /* activate D4 */ | ||
75 | asm volatile ("nop\nnop\nnop\nnop\nnop\n"); | ||
76 | |||
77 | if (!GPIOD_PIN(0)) | ||
78 | result |= BUTTON_LEFT; | ||
79 | |||
80 | if (!GPIOD_PIN(1)) | ||
81 | result |= BUTTON_SELECT; | ||
82 | |||
83 | if (!GPIOD_PIN(2)) | ||
84 | result |= BUTTON_RIGHT; | ||
85 | |||
86 | GPIOD_PIN(4) = 1<<4; | ||
87 | |||
88 | GPIOD_PIN(5) = 0x00; /* activate D5 */ | ||
89 | asm volatile ("nop\nnop\nnop\nnop\nnop\n"); | ||
90 | |||
91 | if (!GPIOD_PIN(0)) | ||
92 | result |= BUTTON_DOWN; | ||
93 | |||
94 | if (!GPIOD_PIN(1)) | ||
95 | result |= BUTTON_VOL_DOWN; | ||
96 | |||
97 | if (!GPIOD_PIN(2)) | ||
98 | result |= BUTTON_HOME; | ||
99 | |||
100 | GPIOD_PIN(5) = 1<<5; | ||
101 | |||
102 | return result; | ||
103 | } | ||
104 | |||
105 | bool button_hold(void) | ||
106 | { | ||
107 | return (GPIOA_PIN(3) != 0); | ||
108 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-clipv2/button-target.h b/firmware/target/arm/as3525/sansa-clipv2/button-target.h new file mode 100644 index 0000000000..238fd1dee5 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipv2/button-target.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
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 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | |||
30 | void button_init_device(void); | ||
31 | int button_read_device(void); | ||
32 | bool button_hold(void); | ||
33 | |||
34 | /* Main unit's buttons */ | ||
35 | #define BUTTON_HOME 0x00000001 | ||
36 | |||
37 | #define BUTTON_VOL_UP 0x00000002 | ||
38 | #define BUTTON_VOL_DOWN 0x00000004 | ||
39 | |||
40 | #define BUTTON_UP 0x00000008 | ||
41 | #define BUTTON_DOWN 0x00000010 | ||
42 | #define BUTTON_LEFT 0x00000020 | ||
43 | #define BUTTON_RIGHT 0x00000040 | ||
44 | |||
45 | #define BUTTON_SELECT 0x00000080 | ||
46 | |||
47 | #define BUTTON_POWER 0x00000100 | ||
48 | |||
49 | #define BUTTON_MAIN (BUTTON_HOME|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ | ||
50 | |BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|BUTTON_RIGHT\ | ||
51 | |BUTTON_SELECT|BUTTON_POWER) | ||
52 | |||
53 | #define BUTTON_REMOTE 0 | ||
54 | |||
55 | /* Software power-off */ | ||
56 | #define POWEROFF_BUTTON BUTTON_POWER | ||
57 | #define POWEROFF_COUNT 10 | ||
58 | |||
59 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-clipv2/sd-clipv2.c b/firmware/target/arm/as3525/sansa-clipv2/sd-clipv2.c new file mode 100644 index 0000000000..70c0477431 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipv2/sd-clipv2.c | |||
@@ -0,0 +1,777 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Daniel Ankers | ||
11 | * Copyright © 2008-2009 Rafaël Carré | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" /* for HAVE_MULTIVOLUME */ | ||
24 | #include "fat.h" | ||
25 | #include "thread.h" | ||
26 | #include "hotswap.h" | ||
27 | #include "system.h" | ||
28 | #include "kernel.h" | ||
29 | #include "cpu.h" | ||
30 | #include <stdio.h> | ||
31 | #include <stdlib.h> | ||
32 | #include <string.h> | ||
33 | #include "as3525v2.h" | ||
34 | #include "pl081.h" /* DMA controller */ | ||
35 | #include "dma-target.h" /* DMA request lines */ | ||
36 | #include "clock-target.h" | ||
37 | #include "panic.h" | ||
38 | #include "stdbool.h" | ||
39 | #include "ata_idle_notify.h" | ||
40 | #include "sd.h" | ||
41 | |||
42 | #include "lcd.h" | ||
43 | #include <stdarg.h> | ||
44 | #include "sysfont.h" | ||
45 | |||
46 | static int line = 0; | ||
47 | static void printf(const char *format, ...) | ||
48 | { | ||
49 | char buf[50]; | ||
50 | int len; | ||
51 | va_list ap; | ||
52 | va_start(ap, format); | ||
53 | |||
54 | len = vsnprintf(buf, sizeof(buf), format, ap); | ||
55 | va_end(ap); | ||
56 | |||
57 | lcd_puts(0, line++, buf); | ||
58 | lcd_update(); | ||
59 | if(line >= LCD_HEIGHT/SYSFONT_HEIGHT) | ||
60 | line = 0; | ||
61 | } | ||
62 | |||
63 | /* command flags */ | ||
64 | #define MCI_NO_RESP (0<<0) | ||
65 | #define MCI_RESP (1<<0) | ||
66 | #define MCI_LONG_RESP (1<<1) | ||
67 | |||
68 | /* controller registers */ | ||
69 | #define SD_BASE 0xC6070000 | ||
70 | |||
71 | /* | ||
72 | * REGISTERS | ||
73 | * | ||
74 | * m = modify (orr/bic), r = read, w = write | ||
75 | * | ||
76 | * 00 m/r/w | ||
77 | * 04 m/w | ||
78 | * 08 m | ||
79 | * 0C ? | ||
80 | * 10 r/w | ||
81 | * 14 w | ||
82 | * 18 m | ||
83 | * 1C w ==> set a bit before transfer (sometimes) ! | ||
84 | * 20 w ==> set a bit before transfer ! | ||
85 | * 24 w irq mask ? | ||
86 | * 28 w arg | ||
87 | * 2C r/w cmd | ||
88 | * 30 r resp0 | ||
89 | * 34 r resp1 | ||
90 | * 38 r resp2 | ||
91 | * 3C r resp3 | ||
92 | * 40 r irq status (only read in isr) | ||
93 | * 44 m/w irq clear | ||
94 | * 48 r | ||
95 | * 4C m | ||
96 | * 64 w | ||
97 | * 70 r | ||
98 | * 100 FIFO | ||
99 | */ | ||
100 | |||
101 | /* | ||
102 | * STATUS register | ||
103 | * & 0xBA80 | ||
104 | * & 8 | ||
105 | * & 0x428 | ||
106 | * & 0x418 | ||
107 | */ | ||
108 | |||
109 | /* | ||
110 | * INFO on CMD register | ||
111 | * | ||
112 | * if(cmd >= 200) cmd -= 200; (>= 200 = acmd?) | ||
113 | * | ||
114 | * COMMANDS (| (x<<16) BITS RESPONSE | ||
115 | * | ||
116 | * 1 ? reserved & ~0x80, | 0x40, | 0x8000 ? | ||
117 | * 5 ? reserved for I/O cards & ~0x80, | 0x40 ? | ||
118 | * 11 ? reserved & ~0x80, | 0x40, | 0x2200, | 0x800 ? | ||
119 | * 14 ? reserved & ~0x80, | 0x40, | 0x2200, ~0x1000 ? | ||
120 | * 19 ? reserved & ~0x80, |0x40, | 0x2700, & ~0x1000 ? | ||
121 | * 20 ? reserved & ~0x80, |0x40, | 0x2700, | 0x800 ? | ||
122 | * 23 ? reserved & ~0x80, | 0x40 ? | ||
123 | * 39 ? reserved & ~0x80, | 0x40 ? | ||
124 | * 51 ? reserved & ~0x80, | 0x40, | 0x2000, | 0x200 ? | ||
125 | * 52 ? reserved for I/O & ~0x80, | 0x40 ? | ||
126 | * 53 ? reserved for I/O & ~0x80, | 0x40, | 0x2200, & ~0x1000 ? | ||
127 | * 253 ? & ~0x80, |0x40, | 0x2700, & ~0x1000 ? | ||
128 | * | ||
129 | * 0 GO IDLE STATE & ~0x4000, & ~0xC0, | 0x4000 no | ||
130 | * 2 ALL SEND CID & ~0x4000, |0xC0 r2 | ||
131 | * 3 SEND RCA & ~0x80, | 0x40 r6 | ||
132 | * 6 SWITCH_FUNC & ~0x80, | 0x40 r1 | ||
133 | * 7 SELECT CARD & ~0x80, | 0x40 r1b | ||
134 | * 8 SEND IF COND & ~0x80, | 0x40, | 0x2200, & ~0x1000 r7 | ||
135 | * 9 SEND CSD & ~0x4000, | 0xc0 r2 | ||
136 | * 12 STOP TRANSMISSION & ~0x80, | 0x40, | 0x4000 r1b | ||
137 | * 13 SEND STATUS & ~0x80, | 0x40 r1 | ||
138 | * 15 GO INACTIVE STATE & ~0x4000, & ~0xC0 no | ||
139 | * 16 SET BLOCKLEN & ~0x80, | 0x40 r1 | ||
140 | * 17 READ SINGLE BLOCK & ~0x80, | 0x40, | 0x2200 r1 | ||
141 | * 18 READ MULTIPLE BLOCK & ~0x80, | 0x40, | 0x2200 r1 | ||
142 | * 24 WRITE BLOCK & ~0x80, |0x40, | 0x2700 r1 | ||
143 | * 25 WRITE MULTIPLE BLOCK & ~0x80, |0x40, | 0x2700 r1 | ||
144 | * 41 SEND APP OP COND & ~0x80, | 0x40 r3 | ||
145 | * 42 LOCK UNLOCK & ~0x80, |0x40, | 0x2700 r1 | ||
146 | * 55 APP CMD & ~0x80, | 0x40 r1 | ||
147 | * 206 SET BUS WIDTH & ~0x80, | 0x40, | 0x2000 r1 | ||
148 | * 207 SELECT CARD ? & ~0x4000, & ~0xC0 r1b | ||
149 | * | ||
150 | * | ||
151 | * bits 5:0 = cmd | ||
152 | * bit 6 (0x40) = response | ||
153 | * bit 7 (0x80) = long response | ||
154 | * => like pl180 <= | ||
155 | * BIT SET IN COMANDS: | ||
156 | * | ||
157 | * bit 8 (0x100) ? write block, write multi_block, lock/unlock | ||
158 | * bit 9 (0x200) ? send if cond, read block, read multi_block, write block, write multi_block, lock/unlock | ||
159 | * bit 10 (0x400) ? write block, write multi_block, lock/unlock | ||
160 | * bit 11 (0x800) ? | ||
161 | * bit 12 (0x1000) ? | ||
162 | * bit 13 (0x2000) ? send if cond, read block, read multi_block, write block, write multi_block, lock/unlock, set bus width | ||
163 | * bit 14 (0x4000) ? go idle state, stop transmission | ||
164 | * bit 15 (0x8000) ? | ||
165 | * | ||
166 | */ | ||
167 | |||
168 | /* FIXME */ | ||
169 | #define MCI_POWER | ||
170 | #define MCI_CLOCK | ||
171 | #define MCI_ARGUMENT (*(volatile unsigned long *) (SD_BASE+0x28)) | ||
172 | #define MCI_COMMAND (*(volatile unsigned long *) (SD_BASE+0x2C)) | ||
173 | #define MCI_RESPCMD | ||
174 | #define MCI_RESP0 (*(volatile unsigned long *) (SD_BASE+0x30)) | ||
175 | #define MCI_RESP1 (*(volatile unsigned long *) (SD_BASE+0x34)) | ||
176 | #define MCI_RESP2 (*(volatile unsigned long *) (SD_BASE+0x38)) | ||
177 | #define MCI_RESP3 (*(volatile unsigned long *) (SD_BASE+0x3C)) | ||
178 | #define MCI_DATA_TIMER | ||
179 | #define MCI_DATA_LENGTH | ||
180 | #define MCI_DATA_CTRL | ||
181 | #define MCI_STATUS (*(volatile unsigned long *) (SD_BASE+0x40)) | ||
182 | #define MCI_CLEAR (*(volatile unsigned long *) (SD_BASE+0x44)) | ||
183 | #define MCI_MASK (*(volatile unsigned long *) (SD_BASE+0x24)) | ||
184 | #define MCI_SELECT | ||
185 | |||
186 | #define MCI_ERROR 0 /* FIXME */ | ||
187 | |||
188 | #define MCI_FIFO ((unsigned long *) (SD_BASE+0x100)) | ||
189 | |||
190 | #define MCI_COMMAND_ENABLE (1<<31) | ||
191 | #define MCI_COMMAND_ACTIVE MCI_COMMAND_ENABLE | ||
192 | #define MCI_COMMAND_RESPONSE (1<<6) | ||
193 | #define MCI_COMMAND_LONG_RESPONSE (1<<7) | ||
194 | |||
195 | |||
196 | |||
197 | static int sd_init_card(void); | ||
198 | static void init_controller(void); | ||
199 | |||
200 | static tCardInfo card_info; | ||
201 | |||
202 | /* for compatibility */ | ||
203 | static long last_disk_activity = -1; | ||
204 | |||
205 | #define MIN_YIELD_PERIOD 5 /* ticks */ | ||
206 | static long next_yield = 0; | ||
207 | |||
208 | static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x200)/sizeof(long)]; | ||
209 | static const char sd_thread_name[] = "ata/sd"; | ||
210 | static struct mutex sd_mtx SHAREDBSS_ATTR; | ||
211 | static struct event_queue sd_queue; | ||
212 | #ifndef BOOTLOADER | ||
213 | static bool sd_enabled = false; | ||
214 | #endif | ||
215 | |||
216 | static struct wakeup transfer_completion_signal; | ||
217 | static volatile bool retry; | ||
218 | |||
219 | static inline void mci_delay(void) { int i = 0xffff; while(i--) ; } | ||
220 | |||
221 | void INT_NAND(void) | ||
222 | { | ||
223 | (*(volatile unsigned long *) (SD_BASE+0x0)) &= ~0x10; // ? | ||
224 | const int status = MCI_STATUS; | ||
225 | |||
226 | #if 0 | ||
227 | if(status & MCI_ERROR) | ||
228 | retry = true; | ||
229 | #endif | ||
230 | |||
231 | // wakeup_signal(&transfer_completion_signal); | ||
232 | MCI_CLEAR = status; | ||
233 | |||
234 | static int x = 0; | ||
235 | switch(status) | ||
236 | { | ||
237 | case 0x4: /* cmd received ? */ | ||
238 | case 0x104: /* ? 1 time in init (10th interrupt) */ | ||
239 | case 0x2000: /* ? after cmd read_mul_blocks | 0x2200 */ | ||
240 | |||
241 | case 0x820: /* ? 1 time while copy from FIFO (not DMA) */ | ||
242 | case 0x20: /* ? rx fifo empty */ | ||
243 | break; | ||
244 | default: | ||
245 | printf("%2d NAND 0x%x", ++x, status); | ||
246 | int delay = 0x100000; while(delay--) ; | ||
247 | } | ||
248 | /* | ||
249 | * 0x48 = some kind of status | ||
250 | * 0x106 | ||
251 | * 0x4106 | ||
252 | * 1B906 | ||
253 | * 1F906 | ||
254 | * 1B906 | ||
255 | * 1F906 | ||
256 | * 1F906 | ||
257 | * 1906 | ||
258 | * ... | ||
259 | * 6906 | ||
260 | * 6D06 (dma) | ||
261 | * | ||
262 | * read resp (6, 7, 12, 42) : while bit 9 is unset ; | ||
263 | * | ||
264 | */ | ||
265 | printf("%x %x", status, (*(volatile unsigned long *) (SD_BASE+0x48))); | ||
266 | //while(!button_read_device()); | ||
267 | //while(button_read_device()); | ||
268 | |||
269 | (*(volatile unsigned long *) (SD_BASE+0x0)) |= 0x10; // ? | ||
270 | } | ||
271 | |||
272 | static bool send_cmd(const int cmd, const int arg, const int flags, | ||
273 | unsigned long *response) | ||
274 | { | ||
275 | int val; | ||
276 | val = cmd | MCI_COMMAND_ENABLE; | ||
277 | if(flags & MCI_RESP) | ||
278 | { | ||
279 | val |= MCI_COMMAND_RESPONSE; | ||
280 | if(flags & MCI_LONG_RESP) | ||
281 | val |= MCI_COMMAND_LONG_RESPONSE; | ||
282 | } | ||
283 | |||
284 | if(cmd == 18) /* r */ | ||
285 | val |= 0x2200; | ||
286 | else if(cmd == 25) /* w */ | ||
287 | val |= 0x2700; | ||
288 | |||
289 | int tmp = (*(volatile unsigned long *) (SD_BASE+0x10)); | ||
290 | (*(volatile unsigned long *) (SD_BASE+0x10)) = 0; | ||
291 | |||
292 | MCI_COMMAND = 0x80202000; | ||
293 | MCI_ARGUMENT = 0; | ||
294 | int max = 10; | ||
295 | while(max-- && MCI_COMMAND & MCI_COMMAND_ACTIVE); | ||
296 | |||
297 | (*(volatile unsigned long *) (SD_BASE+0x08)) &= ~0xff; | ||
298 | (*(volatile unsigned long *) (SD_BASE+0x08)) |= 0; | ||
299 | |||
300 | MCI_COMMAND = 0x80202000; | ||
301 | MCI_ARGUMENT = 0; | ||
302 | max = 10; | ||
303 | while(max-- && MCI_COMMAND & MCI_COMMAND_ACTIVE); | ||
304 | |||
305 | (*(volatile unsigned long *) (SD_BASE+0x10)) = tmp; | ||
306 | |||
307 | MCI_COMMAND = 0x80202000; | ||
308 | MCI_ARGUMENT = 0; | ||
309 | max = 10; | ||
310 | while(max-- && MCI_COMMAND & MCI_COMMAND_ACTIVE); | ||
311 | |||
312 | mci_delay(); | ||
313 | |||
314 | MCI_ARGUMENT = arg; | ||
315 | MCI_COMMAND = val; | ||
316 | |||
317 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 0x10; | ||
318 | |||
319 | max = 1000; | ||
320 | while(max-- && MCI_COMMAND & MCI_COMMAND_ACTIVE); /* wait for cmd completion */ | ||
321 | if(!max) | ||
322 | return false; | ||
323 | |||
324 | if(flags & MCI_RESP) | ||
325 | { | ||
326 | if(flags & MCI_LONG_RESP) | ||
327 | { | ||
328 | /* store the response in little endian order for the words */ | ||
329 | response[0] = MCI_RESP3; | ||
330 | response[1] = MCI_RESP2; | ||
331 | response[2] = MCI_RESP1; | ||
332 | response[3] = MCI_RESP0; | ||
333 | } | ||
334 | else | ||
335 | response[0] = MCI_RESP0; | ||
336 | } | ||
337 | return true; | ||
338 | } | ||
339 | |||
340 | static int sd_init_card(void) | ||
341 | { | ||
342 | unsigned long response; | ||
343 | unsigned long temp_reg[4]; | ||
344 | int max_tries = 100; /* max acmd41 attemps */ | ||
345 | bool sdhc; | ||
346 | int i; | ||
347 | |||
348 | if(!send_cmd(SD_GO_IDLE_STATE, 0, MCI_NO_RESP, NULL)) | ||
349 | return -1; | ||
350 | |||
351 | mci_delay(); | ||
352 | |||
353 | sdhc = false; | ||
354 | if(send_cmd(SD_SEND_IF_COND, 0x1AA, MCI_RESP, &response)) | ||
355 | if((response & 0xFFF) == 0x1AA) | ||
356 | sdhc = true; | ||
357 | |||
358 | do { | ||
359 | /* some MicroSD cards seems to need more delays, so play safe */ | ||
360 | mci_delay(); | ||
361 | mci_delay(); | ||
362 | mci_delay(); | ||
363 | |||
364 | /* app_cmd */ | ||
365 | if( !send_cmd(SD_APP_CMD, 0, MCI_RESP, &response) /*|| | ||
366 | !(response & (1<<5))*/ ) | ||
367 | { | ||
368 | return -2; | ||
369 | } | ||
370 | |||
371 | /* acmd41 */ | ||
372 | if(!send_cmd(SD_APP_OP_COND, (sdhc ? 0x40FF8000 : (1<<23)), | ||
373 | MCI_RESP, &card_info.ocr)) | ||
374 | return -3; | ||
375 | } while(!(card_info.ocr & (1<<31)) && max_tries--); | ||
376 | |||
377 | if(max_tries < 0) | ||
378 | return -4; | ||
379 | |||
380 | mci_delay(); | ||
381 | mci_delay(); | ||
382 | mci_delay(); | ||
383 | |||
384 | /* send CID */ | ||
385 | if(!send_cmd(SD_ALL_SEND_CID, 0, MCI_RESP|MCI_LONG_RESP, card_info.cid)) | ||
386 | return -5; | ||
387 | |||
388 | /* send RCA */ | ||
389 | if(!send_cmd(SD_SEND_RELATIVE_ADDR, 0, MCI_RESP, &card_info.rca)) | ||
390 | return -6; | ||
391 | |||
392 | /* send CSD */ | ||
393 | if(!send_cmd(SD_SEND_CSD, card_info.rca, | ||
394 | MCI_RESP|MCI_LONG_RESP, temp_reg)) | ||
395 | return -7; | ||
396 | |||
397 | for(i=0; i<4; i++) | ||
398 | card_info.csd[3-i] = temp_reg[i]; | ||
399 | |||
400 | sd_parse_csd(&card_info); | ||
401 | |||
402 | if(!send_cmd(SD_APP_CMD, 0, MCI_RESP, &response) || | ||
403 | !send_cmd(42, 0, MCI_NO_RESP, NULL)) /* disconnect the 50 KOhm pull-up | ||
404 | resistor on CD/DAT3 */ | ||
405 | return -13; | ||
406 | |||
407 | if(!send_cmd(SD_APP_CMD, card_info.rca, MCI_NO_RESP, NULL)) | ||
408 | return -10; | ||
409 | |||
410 | if(!send_cmd(SD_SET_BUS_WIDTH, card_info.rca | 2, MCI_NO_RESP, NULL)) | ||
411 | return -11; | ||
412 | |||
413 | (*(volatile unsigned long *) (SD_BASE+0x18)) &= ~(0x10001); | ||
414 | (*(volatile unsigned long *) (SD_BASE+0x18)) |= 0x1; | ||
415 | |||
416 | if(!send_cmd(SD_SELECT_CARD, card_info.rca, MCI_NO_RESP, NULL)) | ||
417 | return -9; | ||
418 | |||
419 | /* not sent in init_card() by OF */ | ||
420 | if(!send_cmd(SD_SET_BLOCKLEN, card_info.blocksize, MCI_NO_RESP, | ||
421 | NULL)) | ||
422 | return -12; | ||
423 | |||
424 | card_info.initialized = 1; | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static void sd_thread(void) __attribute__((noreturn)); | ||
430 | static void sd_thread(void) | ||
431 | { | ||
432 | struct queue_event ev; | ||
433 | bool idle_notified = false; | ||
434 | |||
435 | while (1) | ||
436 | { | ||
437 | queue_wait_w_tmo(&sd_queue, &ev, HZ); | ||
438 | |||
439 | switch ( ev.id ) | ||
440 | { | ||
441 | case SYS_TIMEOUT: | ||
442 | if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ))) | ||
443 | { | ||
444 | idle_notified = false; | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | /* never let a timer wrap confuse us */ | ||
449 | next_yield = current_tick; | ||
450 | |||
451 | if (!idle_notified) | ||
452 | { | ||
453 | call_storage_idle_notifys(false); | ||
454 | idle_notified = true; | ||
455 | } | ||
456 | } | ||
457 | break; | ||
458 | #if 0 | ||
459 | case SYS_USB_CONNECTED: | ||
460 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
461 | /* Wait until the USB cable is extracted again */ | ||
462 | usb_wait_for_disconnect(&sd_queue); | ||
463 | |||
464 | break; | ||
465 | case SYS_USB_DISCONNECTED: | ||
466 | usb_acknowledge(SYS_USB_DISCONNECTED_ACK); | ||
467 | break; | ||
468 | #endif | ||
469 | } | ||
470 | } | ||
471 | } | ||
472 | |||
473 | static void init_controller(void) | ||
474 | { | ||
475 | int tmp = (*(volatile unsigned long *) (SD_BASE+0x70)); | ||
476 | int shift = 1 + ((tmp << 26) >> 27); | ||
477 | |||
478 | (*(volatile unsigned long *) (SD_BASE+0x04)) &= ~((1 << shift) -1); | ||
479 | (*(volatile unsigned long *) (SD_BASE+0x04)) = (1 << shift) -1; | ||
480 | |||
481 | mci_delay(); | ||
482 | |||
483 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 1; | ||
484 | int max = 1000; | ||
485 | while(max-- && !(*(volatile unsigned long *) (SD_BASE+0x00)) & 1) | ||
486 | ; | ||
487 | |||
488 | MCI_CLEAR = 0xffffffff; | ||
489 | MCI_MASK = 0xffffbffe; | ||
490 | |||
491 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 0x10; | ||
492 | (*(volatile unsigned long *) (SD_BASE+0x14)) = 0xffffffff; | ||
493 | |||
494 | (*(volatile unsigned long *) (SD_BASE+0x10)) = (1<<shift) - 1; | ||
495 | |||
496 | MCI_ARGUMENT = 0; | ||
497 | MCI_COMMAND = 0x80202000; | ||
498 | max = 10; | ||
499 | while(max-- && (MCI_COMMAND & (1<<31))) ; | ||
500 | |||
501 | (*(volatile unsigned long *) (SD_BASE+0x64)) = 0xfffff; | ||
502 | |||
503 | (*(volatile unsigned long *) (SD_BASE+0x4c)) = ~0x7fff0fff; // interrupt mask ? | ||
504 | (*(volatile unsigned long *) (SD_BASE+0x4c)) |= 0x503f0080; | ||
505 | |||
506 | MCI_MASK = 0xffffbffe; | ||
507 | } | ||
508 | |||
509 | int sd_init(void) | ||
510 | { | ||
511 | int ret; | ||
512 | CGU_PERI |= CGU_MCI_CLOCK_ENABLE; | ||
513 | |||
514 | CGU_IDE = (1<<7) /* AHB interface enable */ | | ||
515 | (1<<6) /* interface enable */ | | ||
516 | ((CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1) << 2) | | ||
517 | 1; /* clock source = PLLA */ | ||
518 | |||
519 | CGU_MEMSTICK = (1<<8) | (1<<7) | | ||
520 | (CLK_DIV(AS3525_PLLA_FREQ, AS3525_MS_FREQ) -1) | 1; | ||
521 | |||
522 | /* ?? */ | ||
523 | *(volatile int*)0xC80F003C = (1<<7) | | ||
524 | (CLK_DIV(AS3525_PLLA_FREQ, 24000000) -1) | 1; | ||
525 | |||
526 | wakeup_init(&transfer_completion_signal); | ||
527 | |||
528 | VIC_INT_ENABLE |= INTERRUPT_NAND; | ||
529 | |||
530 | init_controller(); | ||
531 | ret = sd_init_card(); | ||
532 | if(ret < 0) | ||
533 | return ret; | ||
534 | |||
535 | /* init mutex */ | ||
536 | mutex_init(&sd_mtx); | ||
537 | |||
538 | queue_init(&sd_queue, true); | ||
539 | create_thread(sd_thread, sd_stack, sizeof(sd_stack), 0, | ||
540 | sd_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); | ||
541 | |||
542 | #ifndef BOOTLOADER | ||
543 | sd_enabled = true; | ||
544 | sd_enable(false); | ||
545 | #endif | ||
546 | return 0; | ||
547 | } | ||
548 | |||
549 | #ifdef STORAGE_GET_INFO | ||
550 | void sd_get_info(struct storage_info *info) | ||
551 | { | ||
552 | info->sector_size=card_info.blocksize; | ||
553 | info->num_sectors=card_info.numblocks; | ||
554 | info->vendor="Rockbox"; | ||
555 | info->product = "Internal Storage"; | ||
556 | info->revision="0.00"; | ||
557 | } | ||
558 | #endif | ||
559 | |||
560 | static int sd_wait_for_state(unsigned int state) | ||
561 | { | ||
562 | unsigned long response; | ||
563 | unsigned int timeout = 100; /* ticks */ | ||
564 | long t = current_tick; | ||
565 | |||
566 | while (1) | ||
567 | { | ||
568 | long tick; | ||
569 | |||
570 | if(!send_cmd(SD_SEND_STATUS, card_info.rca, | ||
571 | MCI_RESP, &response)) | ||
572 | return -1; | ||
573 | |||
574 | if (((response >> 9) & 0xf) == state) | ||
575 | return 0; | ||
576 | |||
577 | if(TIME_AFTER(current_tick, t + timeout)) | ||
578 | return -10 * ((response >> 9) & 0xf); | ||
579 | |||
580 | if (TIME_AFTER((tick = current_tick), next_yield)) | ||
581 | { | ||
582 | yield(); | ||
583 | timeout += current_tick - tick; | ||
584 | next_yield = tick + MIN_YIELD_PERIOD; | ||
585 | } | ||
586 | } | ||
587 | } | ||
588 | |||
589 | static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool write) | ||
590 | { | ||
591 | int ret = 0; | ||
592 | |||
593 | if((int)buf & 3) | ||
594 | panicf("unaligned transfer"); | ||
595 | |||
596 | /* skip SanDisk OF */ | ||
597 | start += 0xf000; | ||
598 | |||
599 | mutex_lock(&sd_mtx); | ||
600 | #ifndef BOOTLOADER | ||
601 | sd_enable(true); | ||
602 | #endif | ||
603 | |||
604 | if (card_info.initialized <= 0) | ||
605 | { | ||
606 | ret = sd_init_card(); | ||
607 | if (!(card_info.initialized)) | ||
608 | { | ||
609 | panicf("card not initialised (%d)", ret); | ||
610 | goto sd_transfer_error; | ||
611 | } | ||
612 | } | ||
613 | |||
614 | last_disk_activity = current_tick; | ||
615 | ret = sd_wait_for_state(SD_TRAN); | ||
616 | if (ret < 0) | ||
617 | { | ||
618 | static const char *st[9] = { | ||
619 | "IDLE", "RDY", "IDENT", "STBY", "TRAN", "DATA", "RCV", "PRG", "DIS" | ||
620 | }; | ||
621 | if(ret <= -10) | ||
622 | panicf("wait for state failed (%s)", st[(-ret / 10) % 9]); | ||
623 | else | ||
624 | panicf("wait for state failed"); | ||
625 | goto sd_transfer_error; | ||
626 | } | ||
627 | |||
628 | dma_retain(); | ||
629 | |||
630 | while(count) | ||
631 | { | ||
632 | /* Interrupt handler might set this to true during transfer */ | ||
633 | retry = false; | ||
634 | /* 128 * 512 = 2^16, and doesn't fit in the 16 bits of DATA_LENGTH | ||
635 | * register, so we have to transfer maximum 127 sectors at a time. */ | ||
636 | //unsigned int transfer = (count >= 128) ? 127 : count; /* sectors */ | ||
637 | unsigned int transfer = count; | ||
638 | |||
639 | const int cmd = | ||
640 | write ? SD_WRITE_MULTIPLE_BLOCK : SD_READ_MULTIPLE_BLOCK; | ||
641 | |||
642 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 2; | ||
643 | while(( *(volatile unsigned long *) (SD_BASE+0x00)) & 2) ; | ||
644 | |||
645 | //(*(volatile unsigned long *) (SD_BASE+0x1c)) = 512; | ||
646 | (*(volatile unsigned long *) (SD_BASE+0x20)) = transfer * 512; | ||
647 | |||
648 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 2; | ||
649 | while(( *(volatile unsigned long *) (SD_BASE+0x00)) & 2) ; | ||
650 | |||
651 | (*(volatile unsigned long *) (SD_BASE+0x4c)) &= ~0x7fff0fff; | ||
652 | |||
653 | if(0) | ||
654 | { | ||
655 | (*(volatile unsigned long *) (SD_BASE+0x00)) |= 0x20; | ||
656 | MCI_MASK = 0xBE8C; | ||
657 | (*(volatile unsigned long *) (SD_BASE+0x4c)) |= 0x503f0080; | ||
658 | } | ||
659 | else | ||
660 | { | ||
661 | MCI_MASK = 0xBEB8; | ||
662 | (*(volatile unsigned long *) (SD_BASE+0x4c)) |= 0x3f0030; | ||
663 | } | ||
664 | |||
665 | if(card_info.ocr & (1<<30) ) /* SDHC */ | ||
666 | ret = send_cmd(cmd, start, MCI_NO_RESP, NULL); | ||
667 | else | ||
668 | ret = send_cmd(cmd, start * SD_BLOCK_SIZE, | ||
669 | MCI_NO_RESP, NULL); | ||
670 | |||
671 | if (ret < 0) | ||
672 | panicf("transfer multiple blocks failed (%d)", ret); | ||
673 | |||
674 | if(write) | ||
675 | dma_enable_channel(0, buf, MCI_FIFO, DMA_PERI_SD, | ||
676 | DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL); | ||
677 | else | ||
678 | dma_enable_channel(0, MCI_FIFO, buf, DMA_PERI_SD, | ||
679 | DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); | ||
680 | |||
681 | line = 0; | ||
682 | lcd_clear_display(); | ||
683 | printf("dma ->"); | ||
684 | |||
685 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | ||
686 | |||
687 | printf("dma <-"); | ||
688 | int delay = 0x1000000; while(delay--) ; | ||
689 | |||
690 | if(!retry) | ||
691 | { | ||
692 | buf += transfer * SECTOR_SIZE; | ||
693 | start += transfer; | ||
694 | count -= transfer; | ||
695 | } | ||
696 | |||
697 | last_disk_activity = current_tick; | ||
698 | |||
699 | if(!send_cmd(SD_STOP_TRANSMISSION, 0, MCI_NO_RESP, NULL)) | ||
700 | { | ||
701 | ret = -666; | ||
702 | panicf("STOP TRANSMISSION failed"); | ||
703 | goto sd_transfer_error; | ||
704 | } | ||
705 | |||
706 | ret = sd_wait_for_state(SD_TRAN); | ||
707 | if (ret < 0) | ||
708 | { | ||
709 | panicf(" wait for state TRAN failed (%d)", ret); | ||
710 | goto sd_transfer_error; | ||
711 | } | ||
712 | } | ||
713 | |||
714 | dma_release(); | ||
715 | |||
716 | #ifndef BOOTLOADER | ||
717 | sd_enable(false); | ||
718 | #endif | ||
719 | mutex_unlock(&sd_mtx); | ||
720 | return 0; | ||
721 | |||
722 | sd_transfer_error: | ||
723 | panicf("transfer error : %d",ret); | ||
724 | card_info.initialized = 0; | ||
725 | return ret; | ||
726 | } | ||
727 | |||
728 | int sd_read_sectors(unsigned long start, int count, void* buf) | ||
729 | { | ||
730 | return sd_transfer_sectors(start, count, buf, false); | ||
731 | } | ||
732 | |||
733 | int sd_write_sectors(unsigned long start, int count, const void* buf) | ||
734 | { | ||
735 | #if defined(BOOTLOADER) /* we don't need write support in bootloader */ | ||
736 | (void) start; | ||
737 | (void) count; | ||
738 | (void) buf; | ||
739 | return -1; | ||
740 | #else | ||
741 | return sd_transfer_sectors(start, count, (void*)buf, true); | ||
742 | #endif | ||
743 | } | ||
744 | |||
745 | #ifndef BOOTLOADER | ||
746 | void sd_sleep(void) | ||
747 | { | ||
748 | } | ||
749 | |||
750 | void sd_spin(void) | ||
751 | { | ||
752 | } | ||
753 | |||
754 | void sd_spindown(int seconds) | ||
755 | { | ||
756 | (void)seconds; | ||
757 | } | ||
758 | |||
759 | long sd_last_disk_activity(void) | ||
760 | { | ||
761 | return last_disk_activity; | ||
762 | } | ||
763 | |||
764 | void sd_enable(bool on) | ||
765 | { | ||
766 | /* TODO */ | ||
767 | (void)on; | ||
768 | return; | ||
769 | } | ||
770 | |||
771 | tCardInfo *card_get_info_target(int card_no) | ||
772 | { | ||
773 | (void)card_no; | ||
774 | return &card_info; | ||
775 | } | ||
776 | |||
777 | #endif /* BOOTLOADER */ | ||
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 6d16c1bfca..75539ba8d7 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -161,7 +161,7 @@ void fiq_handler(void) | |||
161 | ); | 161 | ); |
162 | } | 162 | } |
163 | 163 | ||
164 | #ifdef BOOTLOADER | 164 | #if defined(BOOTLOADER) && (CONFIG_CPU == AS3525) /* not v2 */ |
165 | static void sdram_delay(void) | 165 | static void sdram_delay(void) |
166 | { | 166 | { |
167 | int delay = 1024; /* arbitrary */ | 167 | int delay = 1024; /* arbitrary */ |
@@ -205,7 +205,7 @@ static void sdram_init(void) | |||
205 | /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ | 205 | /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ |
206 | #define MEMORY_MODEL 0x21 | 206 | #define MEMORY_MODEL 0x21 |
207 | 207 | ||
208 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) | 208 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_CLIPV2) |
209 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ | 209 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ |
210 | #define MEMORY_MODEL 0x5 | 210 | #define MEMORY_MODEL 0x5 |
211 | 211 | ||
@@ -256,6 +256,21 @@ void memory_init(void) | |||
256 | 256 | ||
257 | void system_init(void) | 257 | void system_init(void) |
258 | { | 258 | { |
259 | #ifdef SANSA_CLIPV2 | ||
260 | /* Init procedure isn't fully understood yet | ||
261 | * CCU_* registers differ from AS3525 | ||
262 | */ | ||
263 | unsigned int reset_loops = 640; | ||
264 | |||
265 | CCU_SRC = 0x57D7BF0; | ||
266 | while(reset_loops--) | ||
267 | CCU_SRL = CCU_SRL_MAGIC_NUMBER; | ||
268 | CCU_SRC = CCU_SRL = 0; | ||
269 | |||
270 | CGU_PERI &= ~0x7f; /* pclk 24 MHz */ | ||
271 | CGU_PERI |= ((CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1) << 2) | ||
272 | | 1; /* clk_in = PLLA */ | ||
273 | #else /* SANSA_CLIPV2 */ | ||
259 | unsigned int reset_loops = 640; | 274 | unsigned int reset_loops = 640; |
260 | 275 | ||
261 | CCU_SRC = 0x1fffff0 | 276 | CCU_SRC = 0x1fffff0 |
@@ -293,6 +308,8 @@ void system_init(void) | |||
293 | sdram_init(); | 308 | sdram_init(); |
294 | #endif /* BOOTLOADER */ | 309 | #endif /* BOOTLOADER */ |
295 | 310 | ||
311 | #endif /* SANSA_CLIPV2 */ | ||
312 | |||
296 | #if 0 /* the GPIO clock is already enabled by the dualboot function */ | 313 | #if 0 /* the GPIO clock is already enabled by the dualboot function */ |
297 | CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; | 314 | CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; |
298 | #endif | 315 | #endif |
diff --git a/tools/configure b/tools/configure index 91082785d5..d14875aef1 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -2005,8 +2005,6 @@ fi | |||
2005 | ;; | 2005 | ;; |
2006 | 2006 | ||
2007 | 60|sansaclipv2) | 2007 | 60|sansaclipv2) |
2008 | echo "Sansa Clipv2 is not yet supported !" | ||
2009 | exit 1 | ||
2010 | target_id=60 | 2008 | target_id=60 |
2011 | modelname="sansaclipv2" | 2009 | modelname="sansaclipv2" |
2012 | target="-DSANSA_CLIPV2" | 2010 | target="-DSANSA_CLIPV2" |
diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h index 7fc9d520a4..5dfb9c5c2b 100644 --- a/uisimulator/sdl/uisdl.h +++ b/uisimulator/sdl/uisdl.h | |||
@@ -294,7 +294,7 @@ | |||
294 | #define UI_LCD_POSX 30 /* x position of lcd */ | 294 | #define UI_LCD_POSX 30 /* x position of lcd */ |
295 | #define UI_LCD_POSY 31 /* y position of lcd */ | 295 | #define UI_LCD_POSY 31 /* y position of lcd */ |
296 | 296 | ||
297 | #elif defined(SANSA_CLIP) | 297 | #elif defined(SANSA_CLIP) || defined(SANSA_CLIPV2) |
298 | #define UI_TITLE "Sansa Clip" | 298 | #define UI_TITLE "Sansa Clip" |
299 | #define UI_WIDTH 205 /* width of GUI window */ | 299 | #define UI_WIDTH 205 /* width of GUI window */ |
300 | #define UI_HEIGHT 325 /* height of GUI window */ | 300 | #define UI_HEIGHT 325 /* height of GUI window */ |