summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-03-12 20:35:42 +0000
committerJens Arnold <amiconn@rockbox.org>2008-03-12 20:35:42 +0000
commit769fcbd4d9425d0de1fa1628acdce1a2ffbdcd98 (patch)
tree91b000f711fc6f4037768013d20c0f788794a029
parent78017a0b3861a3238ac7845f7be95a5e5b981fe4 (diff)
downloadrockbox-769fcbd4d9425d0de1fa1628acdce1a2ffbdcd98.tar.gz
rockbox-769fcbd4d9425d0de1fa1628acdce1a2ffbdcd98.zip
More iAudio M3 work. Bootloader compiles, but doesn't work yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16645 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/SOURCES2
-rw-r--r--firmware/SOURCES17
-rw-r--r--firmware/boot.lds12
-rw-r--r--firmware/export/config-iaudiom3.h2
-rw-r--r--firmware/export/lcd.h9
-rw-r--r--firmware/target/coldfire/crt0.S2
-rw-r--r--firmware/target/coldfire/iaudio/m3/backlight-m3.c42
-rw-r--r--firmware/target/coldfire/iaudio/m3/backlight-target.h27
-rw-r--r--firmware/target/coldfire/iaudio/m3/button-m3.c101
-rw-r--r--firmware/target/coldfire/iaudio/m3/button-target.h71
-rw-r--r--firmware/target/coldfire/iaudio/m3/lcd-m3.c496
-rw-r--r--firmware/target/coldfire/iaudio/m3/power-m3.c71
-rw-r--r--firmware/target/coldfire/iaudio/m3/system-m3.c112
-rw-r--r--tools/scramble.c12
14 files changed, 967 insertions, 9 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 2753debe77..ea83fa6277 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -17,7 +17,7 @@ main-pp.c
17#endif 17#endif
18#elif defined(ELIO_TPJ1022) 18#elif defined(ELIO_TPJ1022)
19tpj1022.c 19tpj1022.c
20#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) 20#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
21iaudio_x5.c 21iaudio_x5.c
22#elif defined(IRIVER_H300_SERIES) 22#elif defined(IRIVER_H300_SERIES)
23iriver_h300.c 23iriver_h300.c
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 97a33ad7e7..1e1085a880 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -80,6 +80,8 @@ drivers/lcd-1bit-vert.c
80drivers/lcd-2bit-horz.c 80drivers/lcd-2bit-horz.c
81#elif LCD_PIXELFORMAT == VERTICAL_PACKING 81#elif LCD_PIXELFORMAT == VERTICAL_PACKING
82drivers/lcd-2bit-vert.c 82drivers/lcd-2bit-vert.c
83#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
84drivers/lcd-2bit-vi.c
83#endif /* LCD_PIXELFORMAT */ 85#endif /* LCD_PIXELFORMAT */
84#elif LCD_DEPTH == 16 86#elif LCD_DEPTH == 16
85drivers/lcd-16bit.c 87drivers/lcd-16bit.c
@@ -275,7 +277,7 @@ target/coldfire/memcpy-coldfire.S
275target/coldfire/memmove-coldfire.S 277target/coldfire/memmove-coldfire.S
276target/coldfire/memset-coldfire.S 278target/coldfire/memset-coldfire.S
277target/coldfire/strlen-coldfire.S 279target/coldfire/strlen-coldfire.S
278#if defined(HAVE_LCD_COLOR) \ 280#if defined(HAVE_LCD_COLOR) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \
279 || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) 281 || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)
280target/coldfire/memset16-coldfire.S 282target/coldfire/memset16-coldfire.S
281#endif 283#endif
@@ -491,6 +493,19 @@ target/coldfire/iaudio/m5/audio-m5.c
491#endif /* SIMULATOR */ 493#endif /* SIMULATOR */
492#endif /* IAUDIO_M5 */ 494#endif /* IAUDIO_M5 */
493 495
496#ifdef IAUDIO_M3
497#ifndef SIMULATOR
498target/coldfire/ata-as-coldfire.S
499target/coldfire/iaudio/ata-iaudio.c
500target/coldfire/iaudio/m3/backlight-m3.c
501target/coldfire/iaudio/m3/button-m3.c
502target/coldfire/iaudio/m3/lcd-m3.c
503target/coldfire/iaudio/m3/power-m3.c
504target/coldfire/iaudio/m3/system-m3.c
505target/coldfire/iaudio/powermgmt-iaudio.c
506#endif /* SIMULATOR */
507#endif /* IAUDIO_M3 */
508
494#ifdef IRIVER_IFP7XX_SERIES 509#ifdef IRIVER_IFP7XX_SERIES
495#ifdef STUB 510#ifdef STUB
496ifp_usb_serial.c 511ifp_usb_serial.c
diff --git a/firmware/boot.lds b/firmware/boot.lds
index fc876b1d20..e6c9326c7c 100644
--- a/firmware/boot.lds
+++ b/firmware/boot.lds
@@ -47,6 +47,12 @@ INPUT(target/sh/crt0.o)
47#define IRAMSIZE 0x20000 47#define IRAMSIZE 0x20000
48#define FLASHORIG 0x00010000 48#define FLASHORIG 0x00010000
49#define FLASHSIZE 4M 49#define FLASHSIZE 4M
50#elif defined(IAUDIO_M3)
51#define DRAMORIG 0x31000000
52#define IRAMORIG 0x10000000
53#define IRAMSIZE 0x18000
54#define FLASHORIG 0x00010000
55#define FLASHSIZE 4M
50#elif CONFIG_CPU == PP5020 56#elif CONFIG_CPU == PP5020
51#define DRAMORIG 0x10000000 57#define DRAMORIG 0x10000000
52#define IRAMORIG 0x40000000 58#define IRAMORIG 0x40000000
@@ -375,7 +381,7 @@ SECTIONS
375{ 381{
376 .vectors : 382 .vectors :
377 { 383 {
378#if defined(IAUDIO_X5) || defined(IAUDIO_M5) 384#if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
379 *(.init.text) 385 *(.init.text)
380#endif 386#endif
381 _datacopy = .; 387 _datacopy = .;
@@ -426,7 +432,7 @@ SECTIONS
426 } > IRAM 432 } > IRAM
427 433
428#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \ 434#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
429 || defined(IAUDIO_X5) || defined(IAUDIO_M5) 435 || defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
430 .bss DRAMORIG+0x800000: 436 .bss DRAMORIG+0x800000:
431#else 437#else
432 .bss : 438 .bss :
@@ -438,7 +444,7 @@ SECTIONS
438 *(COMMON) 444 *(COMMON)
439 _end = .; 445 _end = .;
440#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \ 446#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
441 || defined(IAUDIO_X5) || defined(IAUDIO_M5) 447 || defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
442 } > DRAM 448 } > DRAM
443#else 449#else
444 } > IRAM 450 } > IRAM
diff --git a/firmware/export/config-iaudiom3.h b/firmware/export/config-iaudiom3.h
index 3556e09d38..efac5bb893 100644
--- a/firmware/export/config-iaudiom3.h
+++ b/firmware/export/config-iaudiom3.h
@@ -45,7 +45,7 @@
45#define LCD_HEIGHT 96 45#define LCD_HEIGHT 96
46#define LCD_DEPTH 2 46#define LCD_DEPTH 2
47 47
48#define LCD_PIXELFORMAT VERTICAL_INTRLEAVED 48#define LCD_PIXELFORMAT VERTICAL_INTERLEAVED
49 49
50#define CONFIG_KEYPAD IAUDIO_M3_PAD 50#define CONFIG_KEYPAD IAUDIO_M3_PAD
51 51
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 669ef67f02..a6ecc975c2 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -71,7 +71,12 @@ struct viewport {
71#endif /* SIMULATOR */ 71#endif /* SIMULATOR */
72 72
73#if LCD_DEPTH <=8 73#if LCD_DEPTH <=8
74#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \
75 || (LCD_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
76typedef unsigned short fb_data;
77#else
74typedef unsigned char fb_data; 78typedef unsigned char fb_data;
79#endif
75#elif LCD_DEPTH <= 16 80#elif LCD_DEPTH <= 16
76typedef unsigned short fb_data; 81typedef unsigned short fb_data;
77#else /* LCD_DEPTH > 16 */ 82#else /* LCD_DEPTH > 16 */
@@ -303,8 +308,10 @@ static inline unsigned lcd_color_to_native(unsigned color)
303#elif LCD_DEPTH == 2 308#elif LCD_DEPTH == 2
304#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 309#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
305#define LCD_FBWIDTH ((LCD_WIDTH+3)/4) 310#define LCD_FBWIDTH ((LCD_WIDTH+3)/4)
306#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 311#elif LCD_PIXELFORMAT == VERTICAL_PACKING
307#define LCD_FBHEIGHT ((LCD_HEIGHT+3)/4) 312#define LCD_FBHEIGHT ((LCD_HEIGHT+3)/4)
313#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
314#define LCD_FBHEIGHT ((LCD_HEIGHT+7)/8)
308#endif /* LCD_PIXELFORMAT */ 315#endif /* LCD_PIXELFORMAT */
309#endif /* LCD_DEPTH */ 316#endif /* LCD_DEPTH */
310/* Set defaults if not defined different yet. The defaults apply to both 317/* Set defaults if not defined different yet. The defaults apply to both
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index 1f5a20a028..cb08dbb7db 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -61,6 +61,7 @@ start:
61 move.l #0x00000180,%d0 /* CSCR0 - no wait states, 16 bits, no bursts */ 61 move.l #0x00000180,%d0 /* CSCR0 - no wait states, 16 bits, no bursts */
62 move.l %d0,(0x088,%a0) 62 move.l %d0,(0x088,%a0)
63 63
64#ifndef IAUDIO_M3
64 /* Chip select 1 - LCD controller */ 65 /* Chip select 1 - LCD controller */
65 move.l #0xf0000000,%d0 /* CSAR1 - Base = 0xf0000000 */ 66 move.l #0xf0000000,%d0 /* CSAR1 - Base = 0xf0000000 */
66 move.l %d0,(0x08c,%a0) 67 move.l %d0,(0x08c,%a0)
@@ -68,6 +69,7 @@ start:
68 move.l %d0,(0x090,%a0) 69 move.l %d0,(0x090,%a0)
69 move.l #0x00000180,%d0 /* CSCR1 - no wait states, 16 bits, no bursts */ 70 move.l #0x00000180,%d0 /* CSCR1 - no wait states, 16 bits, no bursts */
70 move.l %d0,(0x094,%a0) 71 move.l %d0,(0x094,%a0)
72#endif
71 73
72 /* Chip select 2 - ATA controller */ 74 /* Chip select 2 - ATA controller */
73 move.l #0x20000000,%d0 /* CSAR2 - Base = 0x20000000 */ 75 move.l #0x20000000,%d0 /* CSAR2 - Base = 0x20000000 */
diff --git a/firmware/target/coldfire/iaudio/m3/backlight-m3.c b/firmware/target/coldfire/iaudio/m3/backlight-m3.c
new file mode 100644
index 0000000000..b1b95a898e
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/backlight-m3.c
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "backlight.h"
24#include "backlight-target.h"
25
26bool _backlight_init(void)
27{
28 and_l(~0x00000008, &GPIO1_OUT);
29 or_l(0x00000008, &GPIO1_ENABLE);
30 or_l(0x00000008, &GPIO1_FUNCTION);
31 return true; /* Backlight always ON after boot. */
32}
33
34void _backlight_on(void)
35{
36 and_l(~0x00000008, &GPIO1_OUT);
37}
38
39void _backlight_off(void)
40{
41 or_l(0x00000008, &GPIO1_OUT);
42}
diff --git a/firmware/target/coldfire/iaudio/m3/backlight-target.h b/firmware/target/coldfire/iaudio/m3/backlight-target.h
new file mode 100644
index 0000000000..88bd7f6d14
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/backlight-target.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef BACKLIGHT_TARGET_H
21#define BACKLIGHT_TARGET_H
22
23bool _backlight_init(void);
24void _backlight_on(void);
25void _backlight_off(void);
26
27#endif
diff --git a/firmware/target/coldfire/iaudio/m3/button-m3.c b/firmware/target/coldfire/iaudio/m3/button-m3.c
new file mode 100644
index 0000000000..1a27af93f5
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/button-m3.c
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26static bool hold_button = false;
27static bool remote_hold_button = false;
28
29void button_init_device(void)
30{
31 /* Remote Play */
32 GPIO_FUNCTION |= 0x80000000;
33 GPIO_ENABLE &= ~0x80000000;
34}
35
36bool button_hold(void)
37{
38 return (GPIO1_READ & 0x00000200) == 0;
39}
40
41bool remote_button_hold(void)
42{
43 return remote_hold_button;
44}
45
46int button_read_device(void)
47{
48 int btn = BUTTON_NONE;
49 bool hold_button_old;
50 bool remote_hold_button_old;
51 int data = 0xff; /* FIXME */
52
53 /* normal buttons */
54 hold_button_old = hold_button;
55 hold_button = button_hold();
56
57#ifndef BOOTLOADER
58 /* give BL notice if HB state chaged */
59 if (hold_button != hold_button_old)
60 backlight_hold_changed(hold_button);
61#endif
62
63 if (!hold_button)
64 {
65#if 0 /* TODO: implement ADC */
66 data = adc_scan(ADC_BUTTONS);
67
68 if (data < 0xf0)
69 {
70 }
71#endif
72 if (!(GPIO1_READ & 0x00000002))
73 btn |= BUTTON_PLAY;
74 }
75
76 /* remote buttons */
77#if 0 /* TODO: implement ADC */
78 data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff;
79#endif
80
81 remote_hold_button_old = remote_hold_button;
82 remote_hold_button = data < 0x17;
83
84#ifndef BOOTLOADER
85 if (remote_hold_button != remote_hold_button_old)
86 remote_backlight_hold_changed(remote_hold_button);
87#endif
88
89 if (!remote_hold_button)
90 {
91#if 0 /* TODO: implement ADC */
92 if (data < 0xee)
93 {
94 }
95#endif
96 if ((GPIO_READ & 0x80000000) == 0)
97 btn |= BUTTON_RC_PLAY;
98 }
99
100 return btn;
101}
diff --git a/firmware/target/coldfire/iaudio/m3/button-target.h b/firmware/target/coldfire/iaudio/m3/button-target.h
new file mode 100644
index 0000000000..d273766c31
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/button-target.h
@@ -0,0 +1,71 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
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#define HAS_BUTTON_HOLD
27#define HAS_REMOTE_BUTTON_HOLD
28
29bool button_hold(void);
30bool remote_button_hold(void);
31void button_init_device(void);
32int button_read_device(void);
33
34/* iaudio M3 specific button codes */
35
36 /* Main unit's buttons */
37#define BUTTON_PLAY 0x00000001
38
39#define BUTTON_LEFT 0x00000002
40#define BUTTON_RIGHT 0x00000004
41#define BUTTON_VOL_UP 0x00000008
42#define BUTTON_VOL_DOWN 0x00000010
43
44#define BUTTON_MODE 0x00000020
45#define BUTTON_REC 0x00000040
46
47
48#define BUTTON_MAIN (BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\
49 |BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_MODE|BUTTON_REC)
50
51 /* Remote control's buttons */
52#define BUTTON_RC_PLAY 0x00100000
53
54#define BUTTON_RC_REW 0x00080000
55#define BUTTON_RC_FF 0x00040000
56#define BUTTON_RC_VOL_UP 0x00020000
57#define BUTTON_RC_VOL_DOWN 0x00010000
58
59#define BUTTON_RC_REC 0x00008000
60#define BUTTON_RC_MENU 0x00004000
61#define BUTTON_RC_MODE 0x00002000
62
63#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\
64 |BUTTON_RC_REW|BUTTON_RC_FF\
65 |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE)
66
67#define POWEROFF_BUTTON BUTTON_PLAY
68#define RC_POWEROFF_BUTTON BUTTON_RC_PLAY
69#define POWEROFF_COUNT 30
70
71#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/coldfire/iaudio/m3/lcd-m3.c b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
new file mode 100644
index 0000000000..ac60006565
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
@@ -0,0 +1,496 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 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#include "config.h"
21#include "system.h"
22#include "file.h"
23#include "lcd.h"
24#include "scroll_engine.h"
25
26/* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */
27
28#define LCD_SET_DUTY_RATIO 0x48
29#define LCD_SELECT_ADC 0xa0
30#define LCD_SELECT_SHL 0xc0
31#define LCD_SET_COM0 0x44
32#define LCD_OSC_ON 0xab
33#define LCD_SELECT_DCDC 0x64
34#define LCD_SELECT_RES 0x20
35#define LCD_SET_VOLUME 0x81
36#define LCD_SET_BIAS 0x50
37#define LCD_CONTROL_POWER 0x28
38#define LCD_DISPLAY_ON 0xae
39#define LCD_SET_INITLINE 0x40
40#define LCD_SET_COLUMN 0x10
41#define LCD_SET_PAGE 0xb0
42#define LCD_SET_GRAY 0x88
43#define LCD_SET_PWM_FRC 0x90
44#define LCD_SET_POWER_SAVE 0xa8
45#define LCD_REVERSE 0xa6
46
47#define CS_LO and_l(~0x00010000, &GPIO1_OUT)
48#define CS_HI or_l( 0x00010000, &GPIO1_OUT)
49#define CLK_LO and_l(~0x20000000, &GPIO_OUT)
50#define CLK_HI or_l( 0x20000000, &GPIO_OUT)
51#define DATA_LO and_l(~0x04000000, &GPIO_OUT)
52#define DATA_HI or_l( 0x04000000, &GPIO_OUT)
53#define RS_LO and_l(~0x00001000, &GPIO1_OUT)
54#define RS_HI or_l( 0x00001000, &GPIO1_OUT)
55
56/* cached settings values */
57static bool cached_invert = false;
58static bool cached_flip = false;
59static int cached_contrast = DEFAULT_CONTRAST_SETTING;
60
61bool initialized = false;
62
63static void lcd_tick(void);
64
65/* Standard low-level byte writer. Requires CLK high on entry */
66static inline void _write_byte(unsigned data)
67{
68 asm volatile (
69 "move.l (%[gpo0]), %%d0 \n" /* Get current state of data line */
70 "and.l %[dbit], %%d0 \n"
71 "beq.s 1f \n" /* and set it as previous-state bit */
72 "bset #8, %[data] \n"
73 "1: \n"
74 "move.l %[data], %%d0 \n" /* Compute the 'bit derivative', i.e. a value */
75 "lsr.l #1, %%d0 \n" /* with 1's where the data changes from the */
76 "eor.l %%d0, %[data] \n" /* previous state, and 0's where it doesn't */
77 "swap %[data] \n" /* Shift data to upper byte */
78 "lsl.l #8, %[data] \n"
79
80 "move.l %[cbit], %%d1 \n" /* Prepare mask for flipping CLK */
81 "or.l %[dbit], %%d1 \n" /* and DATA at once */
82
83 "lsl.l #1,%[data] \n" /* Shift out MSB */
84 "bcc.s 1f \n"
85 "eor.l %%d1, (%[gpo0]) \n" /* 1: Flip both CLK and DATA */
86 ".word 0x51fa \n" /* (trapf.w - shadow next insn) */
87 "1: \n"
88 "eor.l %[cbit], (%[gpo0]) \n" /* else flip CLK only */
89 "eor.l %[cbit], (%[gpo0]) \n" /* Flip CLK again */
90
91 "lsl.l #1,%[data] \n" /* ..unrolled.. */
92 "bcc.s 1f \n"
93 "eor.l %%d1, (%[gpo0]) \n"
94 ".word 0x51fa \n"
95 "1: \n"
96 "eor.l %[cbit], (%[gpo0]) \n"
97 "eor.l %[cbit], (%[gpo0]) \n"
98
99 "lsl.l #1,%[data] \n"
100 "bcc.s 1f \n"
101 "eor.l %%d1, (%[gpo0]) \n"
102 ".word 0x51fa \n"
103 "1: \n"
104 "eor.l %[cbit], (%[gpo0]) \n"
105 "eor.l %[cbit], (%[gpo0]) \n"
106
107 "lsl.l #1,%[data] \n"
108 "bcc.s 1f \n"
109 "eor.l %%d1, (%[gpo0]) \n"
110 ".word 0x51fa \n"
111 "1: \n"
112 "eor.l %[cbit], (%[gpo0]) \n"
113 "eor.l %[cbit], (%[gpo0]) \n"
114
115 "lsl.l #1,%[data] \n"
116 "bcc.s 1f \n"
117 "eor.l %%d1, (%[gpo0]) \n"
118 ".word 0x51fa \n"
119 "1: \n"
120 "eor.l %[cbit], (%[gpo0]) \n"
121 "eor.l %[cbit], (%[gpo0]) \n"
122
123 "lsl.l #1,%[data] \n"
124 "bcc.s 1f \n"
125 "eor.l %%d1, (%[gpo0]) \n"
126 ".word 0x51fa \n"
127 "1: \n"
128 "eor.l %[cbit], (%[gpo0]) \n"
129 "eor.l %[cbit], (%[gpo0]) \n"
130
131 "lsl.l #1,%[data] \n"
132 "bcc.s 1f \n"
133 "eor.l %%d1, (%[gpo0]) \n"
134 ".word 0x51fa \n"
135 "1: \n"
136 "eor.l %[cbit], (%[gpo0]) \n"
137 "eor.l %[cbit], (%[gpo0]) \n"
138
139 "lsl.l #1,%[data] \n"
140 "bcc.s 1f \n"
141 "eor.l %%d1, (%[gpo0]) \n"
142 ".word 0x51fa \n"
143 "1: \n"
144 "eor.l %[cbit], (%[gpo0]) \n"
145 "eor.l %[cbit], (%[gpo0]) \n"
146 : /* outputs */
147 [data]"+d"(data)
148 : /* inputs */
149 [gpo0]"a"(&GPIO_OUT),
150 [cbit]"d"(0x20000000),
151 [dbit]"d"(0x04000000)
152 : /* clobbers */
153 "d0", "d1"
154 );
155}
156
157/* Fast low-level byte writer. Don't use with high CPU clock.
158 * Requires CLK high on entry */
159static inline void _write_fast(unsigned data)
160{
161 asm volatile (
162 "move.w %%sr,%%d3 \n" /* Get current interrupt level */
163 "move.w #0x2700,%%sr \n" /* Disable interrupts */
164
165 "move.l (%[gpo0]), %%d0 \n" /* Get current state of data port */
166 "move.l %%d0, %%d1 \n"
167 "and.l %[dbit], %%d1 \n" /* Check current state of data line */
168 "beq.s 1f \n" /* and set it as previous-state bit */
169 "bset #8, %[data] \n"
170 "1: \n"
171 "move.l %[data], %%d1 \n" /* Compute the 'bit derivative', i.e. a value */
172 "lsr.l #1, %%d1 \n" /* with 1's where the data changes from the */
173 "eor.l %%d1, %[data] \n" /* previous state, and 0's where it doesn't */
174 "swap %[data] \n" /* Shift data to upper byte */
175 "lsl.l #8, %[data] \n"
176
177 "move.l %%d0, %%d1 \n" /* precalculate opposite state of clock line */
178 "eor.l %[cbit], %%d1 \n"
179
180 "lsl.l #1,%[data] \n" /* Shift out MSB */
181 "bcc.s 1f \n"
182 "eor.l %[dbit], %%d0 \n" /* 1: Flip data bit */
183 "eor.l %[dbit], %%d1 \n" /* for both clock states */
184 "1: \n"
185 "move.l %%d1, (%[gpo0]) \n" /* Output new state and set CLK */
186 "move.l %%d0, (%[gpo0]) \n" /* reset CLK */
187
188 "lsl.l #1,%[data] \n" /* ..unrolled.. */
189 "bcc.s 1f \n"
190 "eor.l %[dbit], %%d0 \n"
191 "eor.l %[dbit], %%d1 \n"
192 "1: \n"
193 "move.l %%d1, (%[gpo0]) \n"
194 "move.l %%d0, (%[gpo0]) \n"
195
196 "lsl.l #1,%[data] \n"
197 "bcc.s 1f \n"
198 "eor.l %[dbit], %%d0 \n"
199 "eor.l %[dbit], %%d1 \n"
200 "1: \n"
201 "move.l %%d1, (%[gpo0]) \n"
202 "move.l %%d0, (%[gpo0]) \n"
203
204 "lsl.l #1,%[data] \n"
205 "bcc.s 1f \n"
206 "eor.l %[dbit], %%d0 \n"
207 "eor.l %[dbit], %%d1 \n"
208 "1: \n"
209 "move.l %%d1, (%[gpo0]) \n"
210 "move.l %%d0, (%[gpo0]) \n"
211
212 "lsl.l #1,%[data] \n"
213 "bcc.s 1f \n"
214 "eor.l %[dbit], %%d0 \n"
215 "eor.l %[dbit], %%d1 \n"
216 "1: \n"
217 "move.l %%d1, (%[gpo0]) \n"
218 "move.l %%d0, (%[gpo0]) \n"
219
220 "lsl.l #1,%[data] \n"
221 "bcc.s 1f \n"
222 "eor.l %[dbit], %%d0 \n"
223 "eor.l %[dbit], %%d1 \n"
224 "1: \n"
225 "move.l %%d1, (%[gpo0]) \n"
226 "move.l %%d0, (%[gpo0]) \n"
227
228 "lsl.l #1,%[data] \n"
229 "bcc.s 1f \n"
230 "eor.l %[dbit], %%d0 \n"
231 "eor.l %[dbit], %%d1 \n"
232 "1: \n"
233 "move.l %%d1, (%[gpo0]) \n"
234 "move.l %%d0, (%[gpo0]) \n"
235
236 "lsl.l #1,%[data] \n"
237 "bcc.s 1f \n"
238 "eor.l %[dbit], %%d0 \n"
239 "eor.l %[dbit], %%d1 \n"
240 "1: \n"
241 "move.l %%d1, (%[gpo0]) \n"
242 "move.l %%d0, (%[gpo0]) \n"
243
244 "move.w %%d3, %%sr \n" /* Restore interrupt level */
245 : /* outputs */
246 [data]"+d"(data)
247 : /* inputs */
248 [gpo0]"a"(&GPIO_OUT),
249 [cbit]"d"(0x20000000),
250 [dbit]"d"(0x04000000)
251 : /* clobbers */
252 "d0", "d1", "d2", "d3"
253 );
254}
255
256void lcd_write_command(int cmd)
257{
258 RS_LO;
259 CS_LO;
260 _write_byte(cmd);
261 CS_HI;
262}
263
264void lcd_write_command_e(int cmd, int data)
265{
266 RS_LO;
267 CS_LO;
268 _write_byte(cmd);
269 _write_byte(data);
270 CS_HI;
271}
272
273void lcd_write_data(const fb_data *p_words, int count)
274{
275 const unsigned char *p_bytes = (const unsigned char *)p_words;
276 const unsigned char *p_end = (const unsigned char *)(p_words + count);
277
278 RS_HI;
279 CS_LO;
280 if (cpu_frequency < 50000000)
281 {
282 while (p_bytes < p_end)
283 _write_fast(*p_bytes++);
284 }
285 else
286 {
287 while (p_bytes < p_end)
288 _write_byte(*p_bytes++);
289 }
290 CS_HI;
291}
292
293int lcd_default_contrast(void)
294{
295 return DEFAULT_CONTRAST_SETTING;
296}
297
298void lcdset_contrast(int val)
299{
300 if (val < 0)
301 val = 0;
302 else if (val > 63)
303 val = 63;
304
305 cached_contrast = val;
306 if (initialized)
307 lcd_write_command_e(LCD_SET_VOLUME, val);
308}
309
310bool remote_detect(void)
311{
312 return (GPIO_READ & 0x40000000) == 0;
313}
314
315void lcd_init_device(void)
316{
317 or_l(0x24000000, &GPIO_OUT);
318 or_l(0x24000000, &GPIO_ENABLE);
319 or_l(0x24000000, &GPIO_FUNCTION);
320
321 or_l(0x00011000, &GPIO1_OUT);
322 or_l(0x00011000, &GPIO1_ENABLE);
323 or_l(0x00011000, &GPIO1_FUNCTION);
324
325 and_l(~0x40000000, &GPIO_OUT);
326 and_l(~0x40000000, &GPIO_ENABLE);
327 or_l(0x40000000, &GPIO_FUNCTION);
328
329 lcd_clear_display();
330 tick_add_task(lcd_tick);
331}
332
333void lcd_on(void)
334{
335 CS_HI;
336 CLK_HI;
337 sleep(10);
338
339 lcd_write_command(LCD_SET_DUTY_RATIO);
340 lcd_write_command(0x70); /* 1/128 */
341
342 lcd_write_command(LCD_OSC_ON);
343
344 lcd_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */
345
346 lcd_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */
347
348 lcd_write_command(LCD_SET_BIAS | 6); /* 1/11 */
349
350 lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */
351
352 sleep(30);
353
354 lcd_write_command_e(LCD_SET_GRAY | 0, 0x00);
355 lcd_write_command_e(LCD_SET_GRAY | 1, 0x00);
356 lcd_write_command_e(LCD_SET_GRAY | 2, 0x0c);
357 lcd_write_command_e(LCD_SET_GRAY | 3, 0x00);
358 lcd_write_command_e(LCD_SET_GRAY | 4, 0xcc);
359 lcd_write_command_e(LCD_SET_GRAY | 5, 0x00);
360 lcd_write_command_e(LCD_SET_GRAY | 6, 0xcc);
361 lcd_write_command_e(LCD_SET_GRAY | 7, 0x0c);
362
363 lcd_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */
364
365 lcd_write_command(LCD_DISPLAY_ON | 1); /* display on */
366
367 initialized = true;
368
369 lcd_set_flip(cached_flip);
370 lcd_set_contrast(cached_contrast);
371 lcd_set_invert_display(cached_invert);
372}
373
374void lcd_off(void)
375{
376 initialized = false;
377 CS_HI;
378 RS_HI;
379}
380
381void lcd_poweroff(void)
382{
383 /* Set power save -> Power OFF (VDD - VSS) .. that's it */
384 if (initialized && remote_detect())
385 lcd_write_command(LCD_SET_POWER_SAVE | 1);
386}
387
388/* Monitor remote hotswap */
389static void lcd_tick(void)
390{
391 static bool last_status = false;
392 static int countdown = 0;
393 bool current_status;
394
395 current_status = remote_detect();
396
397 /* Only report when the status has changed */
398 if (current_status != last_status)
399 {
400 last_status = current_status;
401 countdown = current_status ? 20*HZ : 1;
402 }
403 else
404 {
405 /* Count down until it gets negative */
406 if (countdown >= 0)
407 countdown--;
408
409 if (current_status)
410 {
411 if (!(countdown % 48))
412 {
413 queue_broadcast(SYS_REMOTE_PLUGGED, 0);
414 }
415 }
416 else
417 {
418 if (countdown == 0)
419 {
420 queue_broadcast(SYS_REMOTE_UNPLUGGED, 0);
421 }
422 }
423 }
424}
425
426/* Update the display.
427 This must be called after all other LCD functions that change the display. */
428void lcd_update(void) ICODE_ATTR;
429void lcd_update(void)
430{
431 int y;
432 if(initialized) {
433 for(y = 0;y < LCD_FBHEIGHT;y++) {
434 /* Copy display bitmap to hardware.
435 The COM48-COM63 lines are not connected so we have to skip
436 them. Further, the column address doesn't wrap, so we
437 have to update one page at a time. */
438 lcd_write_command(LCD_SET_PAGE | (y>5?y+2:y));
439 lcd_write_command_e(LCD_SET_COLUMN | 0, 0);
440 lcd_write_data(lcd_framebuffer[y], LCD_WIDTH);
441 }
442 }
443}
444
445/* Update a fraction of the display. */
446void lcd_update_rect(int, int, int, int) ICODE_ATTR;
447void lcd_update_rect(int x, int y, int width, int height)
448{
449 if(initialized) {
450 int ymax;
451
452 /* The Y coordinates have to work on even 8 pixel rows */
453 ymax = (y + height-1) >> 3;
454 y >>= 3;
455
456 if(x + width > LCD_WIDTH)
457 width = LCD_WIDTH - x;
458 if (width <= 0)
459 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
460 if(ymax >= LCD_FBHEIGHT)
461 ymax = LCD_FBHEIGHT-1;
462
463 /* Copy specified rectangle bitmap to hardware
464 COM48-COM63 are not connected, so we need to skip those */
465 for (; y <= ymax; y++)
466 {
467 lcd_write_command(LCD_SET_PAGE | ((y > 5?y + 2:y) & 0xf));
468 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
469
470 lcd_write_data(&lcd_framebuffer[y][x], width);
471 }
472 }
473}
474
475void lcd_set_invert_display(bool yesno)
476{
477 cached_invert = yesno;
478 if(initialized)
479 lcd_write_command(LCD_REVERSE | yesno);
480}
481
482void lcd_set_flip(bool yesno)
483{
484 cached_flip = yesno;
485 if(initialized) {
486 if(yesno) {
487 lcd_write_command(LCD_SELECT_ADC | 0);
488 lcd_write_command(LCD_SELECT_SHL | 0);
489 lcd_write_command_e(LCD_SET_COM0, 16);
490 } else {
491 lcd_write_command(LCD_SELECT_ADC | 1);
492 lcd_write_command(LCD_SELECT_SHL | 8);
493 lcd_write_command_e(LCD_SET_COM0, 0);
494 }
495 }
496}
diff --git a/firmware/target/coldfire/iaudio/m3/power-m3.c b/firmware/target/coldfire/iaudio/m3/power-m3.c
new file mode 100644
index 0000000000..624e3b44a5
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/power-m3.c
@@ -0,0 +1,71 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include <stdbool.h>
23#include "kernel.h"
24#include "system.h"
25#include "power.h"
26
27#ifndef SIMULATOR
28
29void power_init(void)
30{
31 /* Set KEEPACT */
32 or_l(0x00040000, &GPIO_OUT);
33 or_l(0x00040000, &GPIO_ENABLE);
34 or_l(0x00040000, &GPIO_FUNCTION);
35
36 /* Charger detect */
37 and_l(~0x00000020, &GPIO1_ENABLE);
38 or_l(0x00000020, &GPIO1_FUNCTION);
39}
40
41bool charger_inserted(void)
42{
43 return (GPIO1_READ & 0x00000020) == 0;
44}
45
46void ide_power_enable(bool on)
47{
48 if (on)
49 {
50 or_l(0x00800000, &GPIO_OUT);
51 }
52 else
53 {
54 and_l(~0x00800000, &GPIO_OUT);
55 }
56}
57
58bool ide_powered(void)
59{
60 return false;
61}
62
63void power_off(void)
64{
65 lcd_poweroff();
66 set_irq_level(DISABLE_INTERRUPTS);
67 and_l(~0x00040000, &GPIO_OUT); /* Set KEEPACT low */
68 asm("halt");
69}
70
71#endif /* SIMULATOR */
diff --git a/firmware/target/coldfire/iaudio/m3/system-m3.c b/firmware/target/coldfire/iaudio/m3/system-m3.c
new file mode 100644
index 0000000000..bf15caa8e0
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/system-m3.c
@@ -0,0 +1,112 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 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#include "config.h"
20#include "cpu.h"
21#include "kernel.h"
22#include "system.h"
23#include "power.h"
24#include "timer.h"
25
26/* Settings for all possible clock frequencies (with properly working timers)
27 * NOTE: Some 5249 chips don't like having PLLDIV set to 0. We must avoid that!
28 *
29 * xxx_REFRESH_TIMER below
30 * system.h, CPUFREQ_xxx_MULT |
31 * | |
32 * V V
33 * PLLCR & Rftim. IDECONFIG1/IDECONFIG2
34 * CPUCLK/Hz MULT ~0x70400000 16MB CSCR0 CS2Pre CS2Post CS2Wait
35 * -----------------------------------------------------------------
36 * 11289600 1 0x00800200 4 0x0180 1 1 0
37 * 22579200 2 0x0589e025 10 0x0180 1 1 0
38 * 33868800 3 0x0388e025 15 0x0180 1 1 0
39 * 45158400 4 0x0589e021 21 0x0580 1 1 0
40 * 56448000 5 0x0289e025 26 0x0580 2 1 0
41 * 67737600 6 0x0388e021 32 0x0980 2 1 0
42 * 79027200 7 0x038a6021 37 0x0980 2 1 0
43 * 90316800 8 0x038be021 43 0x0d80 2 1 0
44 * 101606400 9 0x01892025 48 0x0d80 2 1 0
45 * 112896000 10 0x0189e025 54 0x1180 3 1 0
46 * 124185600 11 0x018ae025 59 0x1180 3 1 1
47 */
48
49#define MAX_REFRESH_TIMER 59
50#define NORMAL_REFRESH_TIMER 21
51#define DEFAULT_REFRESH_TIMER 4
52
53#ifdef HAVE_ADJUSTABLE_CPU_FREQ
54void set_cpu_frequency (long) __attribute__ ((section (".icode")));
55void set_cpu_frequency(long frequency)
56#else
57void cf_set_cpu_frequency (long) __attribute__ ((section (".icode")));
58void cf_set_cpu_frequency(long frequency)
59#endif
60{
61 switch(frequency)
62 {
63 case CPUFREQ_MAX:
64 DCR = (0x8200 | DEFAULT_REFRESH_TIMER);
65 /* Refresh timer for bypass frequency */
66 PLLCR &= ~1; /* Bypass mode */
67 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
68 PLLCR = 0x018ae025 | (PLLCR & 0x70400000);
69 CSCR0 = 0x00001180; /* Flash: 4 wait states */
70 while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
71 This may take up to 10ms! */
72 timers_adjust_prescale(CPUFREQ_MAX_MULT, true);
73 DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */
74 cpu_frequency = CPUFREQ_MAX;
75 IDECONFIG1 = 0x100000 | (1 << 13) | (3 << 10);
76 /* SBUFEN2 enable | CS2Post | CS2Pre */
77 IDECONFIG2 = 0x40000 | (1 << 8); /* TA enable + CS2wait */
78 break;
79
80 case CPUFREQ_NORMAL:
81 DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
82 /* Refresh timer for bypass frequency */
83 PLLCR &= ~1; /* Bypass mode */
84 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false);
85 PLLCR = 0x0589e021 | (PLLCR & 0x70400000);
86 CSCR0 = 0x00000580; /* Flash: 1 wait state */
87 while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked.
88 This may take up to 10ms! */
89 timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true);
90 DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */
91 cpu_frequency = CPUFREQ_NORMAL;
92 IDECONFIG1 = 0x100000 | (1 << 13) | (1 << 10);
93 /* BUFEN2 enable | CS2Post | CS2Pre */
94 IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */
95 break;
96
97 default:
98 DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER;
99 /* Refresh timer for bypass frequency */
100 PLLCR &= ~1; /* Bypass mode */
101 timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true);
102 /* Power down PLL, but keep CRSEL and CLSEL */
103 PLLCR = 0x00800200 | (PLLCR & 0x70400000);
104 CSCR0 = 0x00000180; /* Flash: 0 wait states */
105 DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */
106 cpu_frequency = CPUFREQ_DEFAULT;
107 IDECONFIG1 = 0x100000 | (1 << 13) | (1 << 10);
108 /* BUFEN2 enable | CS2Post | CS2Pre */
109 IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */
110 break;
111 }
112}
diff --git a/tools/scramble.c b/tools/scramble.c
index ee731cfd0d..0a5230068c 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -91,6 +91,7 @@ void usage(void)
91 "\t-iaudiox5 iAudio X5 format\n" 91 "\t-iaudiox5 iAudio X5 format\n"
92 "\t-iaudiox5v iAudio X5V format\n" 92 "\t-iaudiox5v iAudio X5V format\n"
93 "\t-iaudiom5 iAudio M5 format\n" 93 "\t-iaudiom5 iAudio M5 format\n"
94 "\t-iaudiom3 iAudio M3 format\n"
94 "\t-ipod3g ipod firmware partition format (3rd Gen)\n" 95 "\t-ipod3g ipod firmware partition format (3rd Gen)\n"
95 "\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n" 96 "\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n"
96 "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n" 97 "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n"
@@ -107,8 +108,8 @@ void usage(void)
107 "\t-tcc=X Telechips generic firmware format (X values: sum, crc)\n" 108 "\t-tcc=X Telechips generic firmware format (X values: sum, crc)\n"
108 "\t-add=X Rockbox generic \"add-up\" checksum format\n" 109 "\t-add=X Rockbox generic \"add-up\" checksum format\n"
109 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n" 110 "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n"
110 "\t ip3g, ip4g, mini, iax5, h10, h10_5gb, tpj2,\n" 111 "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n"
111 "\t c200, e200, giga, gigs, m100, m500, d2)\n" 112 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2)\n"
112 "\nNo option results in Archos standard player/recorder format.\n"); 113 "\nNo option results in Archos standard player/recorder format.\n");
113 114
114 exit(1); 115 exit(1);
@@ -258,6 +259,8 @@ int main (int argc, char** argv)
258 modelnum = 23; 259 modelnum = 23;
259 else if(!strcmp(&argv[1][5], "d2")) 260 else if(!strcmp(&argv[1][5], "d2"))
260 modelnum = 24; 261 modelnum = 24;
262 else if(!strcmp(&argv[1][5], "iam3"))
263 modelnum = 25;
261 else { 264 else {
262 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 265 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
263 return 2; 266 return 2;
@@ -302,6 +305,11 @@ int main (int argc, char** argv)
302 oname = argv[3]; 305 oname = argv[3];
303 return iaudio_encode(iname, oname, "COWON_M5_FW"); 306 return iaudio_encode(iname, oname, "COWON_M5_FW");
304 } 307 }
308 else if(!strcmp(argv[1], "-iaudiom3")) {
309 iname = argv[2];
310 oname = argv[3];
311 return iaudio_encode(iname, oname, "COWON_M3_FW");
312 }
305 else if(!strcmp(argv[1], "-ipod3g")) { 313 else if(!strcmp(argv[1], "-ipod3g")) {
306 iname = argv[2]; 314 iname = argv[2];
307 oname = argv[3]; 315 oname = argv[3];