diff options
Diffstat (limited to 'firmware/target/coldfire')
-rw-r--r-- | firmware/target/coldfire/crt0.S | 2 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/backlight-m3.c | 42 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/backlight-target.h | 27 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/button-m3.c | 101 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/button-target.h | 71 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/lcd-m3.c | 496 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/power-m3.c | 71 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/system-m3.c | 112 |
8 files changed, 922 insertions, 0 deletions
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 | |||
26 | bool _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 | |||
34 | void _backlight_on(void) | ||
35 | { | ||
36 | and_l(~0x00000008, &GPIO1_OUT); | ||
37 | } | ||
38 | |||
39 | void _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 | |||
23 | bool _backlight_init(void); | ||
24 | void _backlight_on(void); | ||
25 | void _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 | |||
26 | static bool hold_button = false; | ||
27 | static bool remote_hold_button = false; | ||
28 | |||
29 | void button_init_device(void) | ||
30 | { | ||
31 | /* Remote Play */ | ||
32 | GPIO_FUNCTION |= 0x80000000; | ||
33 | GPIO_ENABLE &= ~0x80000000; | ||
34 | } | ||
35 | |||
36 | bool button_hold(void) | ||
37 | { | ||
38 | return (GPIO1_READ & 0x00000200) == 0; | ||
39 | } | ||
40 | |||
41 | bool remote_button_hold(void) | ||
42 | { | ||
43 | return remote_hold_button; | ||
44 | } | ||
45 | |||
46 | int 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 | |||
29 | bool button_hold(void); | ||
30 | bool remote_button_hold(void); | ||
31 | void button_init_device(void); | ||
32 | int 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 */ | ||
57 | static bool cached_invert = false; | ||
58 | static bool cached_flip = false; | ||
59 | static int cached_contrast = DEFAULT_CONTRAST_SETTING; | ||
60 | |||
61 | bool initialized = false; | ||
62 | |||
63 | static void lcd_tick(void); | ||
64 | |||
65 | /* Standard low-level byte writer. Requires CLK high on entry */ | ||
66 | static 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 */ | ||
159 | static 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 | |||
256 | void lcd_write_command(int cmd) | ||
257 | { | ||
258 | RS_LO; | ||
259 | CS_LO; | ||
260 | _write_byte(cmd); | ||
261 | CS_HI; | ||
262 | } | ||
263 | |||
264 | void 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 | |||
273 | void 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 | |||
293 | int lcd_default_contrast(void) | ||
294 | { | ||
295 | return DEFAULT_CONTRAST_SETTING; | ||
296 | } | ||
297 | |||
298 | void 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 | |||
310 | bool remote_detect(void) | ||
311 | { | ||
312 | return (GPIO_READ & 0x40000000) == 0; | ||
313 | } | ||
314 | |||
315 | void 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 | |||
333 | void 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 | |||
374 | void lcd_off(void) | ||
375 | { | ||
376 | initialized = false; | ||
377 | CS_HI; | ||
378 | RS_HI; | ||
379 | } | ||
380 | |||
381 | void 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 */ | ||
389 | static 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. */ | ||
428 | void lcd_update(void) ICODE_ATTR; | ||
429 | void 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. */ | ||
446 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
447 | void 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 | |||
475 | void lcd_set_invert_display(bool yesno) | ||
476 | { | ||
477 | cached_invert = yesno; | ||
478 | if(initialized) | ||
479 | lcd_write_command(LCD_REVERSE | yesno); | ||
480 | } | ||
481 | |||
482 | void 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 | |||
29 | void 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 | |||
41 | bool charger_inserted(void) | ||
42 | { | ||
43 | return (GPIO1_READ & 0x00000020) == 0; | ||
44 | } | ||
45 | |||
46 | void 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 | |||
58 | bool ide_powered(void) | ||
59 | { | ||
60 | return false; | ||
61 | } | ||
62 | |||
63 | void 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 | ||
54 | void set_cpu_frequency (long) __attribute__ ((section (".icode"))); | ||
55 | void set_cpu_frequency(long frequency) | ||
56 | #else | ||
57 | void cf_set_cpu_frequency (long) __attribute__ ((section (".icode"))); | ||
58 | void 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 | } | ||