diff options
Diffstat (limited to 'firmware/target/coldfire/iaudio')
17 files changed, 735 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/adc-iaudio.c index 1895cacfe9..1895cacfe9 100644 --- a/firmware/target/coldfire/iaudio/x5/adc-x5.c +++ b/firmware/target/coldfire/iaudio/adc-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/x5/adc-target.h b/firmware/target/coldfire/iaudio/adc-target.h index 28ba6225d1..28ba6225d1 100644 --- a/firmware/target/coldfire/iaudio/x5/adc-target.h +++ b/firmware/target/coldfire/iaudio/adc-target.h | |||
diff --git a/firmware/target/coldfire/iaudio/x5/ata-x5.c b/firmware/target/coldfire/iaudio/ata-iaudio.c index 21c088288a..21c088288a 100644 --- a/firmware/target/coldfire/iaudio/x5/ata-x5.c +++ b/firmware/target/coldfire/iaudio/ata-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/x5/button-target.h b/firmware/target/coldfire/iaudio/button-target.h index af1088dfed..af1088dfed 100644 --- a/firmware/target/coldfire/iaudio/x5/button-target.h +++ b/firmware/target/coldfire/iaudio/button-target.h | |||
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c index 139ebbc2a3..139ebbc2a3 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c +++ b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/lcd-remote-target.h index 86c361097b..86c361097b 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h +++ b/firmware/target/coldfire/iaudio/lcd-remote-target.h | |||
diff --git a/firmware/target/coldfire/iaudio/m5/audio-m5.c b/firmware/target/coldfire/iaudio/m5/audio-m5.c new file mode 100644 index 0000000000..fcedbcad78 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/audio-m5.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Michael Sevakis | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "system.h" | ||
20 | #include "cpu.h" | ||
21 | #include "audio.h" | ||
22 | #include "sound.h" | ||
23 | |||
24 | void audio_set_output_source(int source) | ||
25 | { | ||
26 | unsigned long txsrc; | ||
27 | |||
28 | if ((unsigned)source >= AUDIO_NUM_SOURCES) | ||
29 | txsrc = (3 << 8); /* playback, PDOR3 */ | ||
30 | else | ||
31 | txsrc = (4 << 8); /* recording, iis1RcvData */ | ||
32 | |||
33 | IIS1CONFIG = (IIS1CONFIG & ~(7 << 8)) | txsrc; | ||
34 | } /* audio_set_output_source */ | ||
35 | |||
36 | void audio_set_source(int source, unsigned flags) | ||
37 | { | ||
38 | /* Prevent pops from unneeded switching */ | ||
39 | static int last_source = AUDIO_SRC_PLAYBACK; | ||
40 | |||
41 | (void)flags; | ||
42 | |||
43 | switch (source) | ||
44 | { | ||
45 | default: /* playback - no recording */ | ||
46 | source = AUDIO_SRC_PLAYBACK; | ||
47 | case AUDIO_SRC_PLAYBACK: | ||
48 | if (source != last_source) | ||
49 | { | ||
50 | audiohw_disable_recording(); | ||
51 | audiohw_set_monitor(false); | ||
52 | /* Reset PDIR2 data flow */ | ||
53 | DATAINCONTROL = (1 << 9); | ||
54 | } | ||
55 | break; | ||
56 | |||
57 | case AUDIO_SRC_MIC: /* recording only */ | ||
58 | if (source != last_source) | ||
59 | { | ||
60 | audiohw_enable_recording(true); /* source mic */ | ||
61 | /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ | ||
62 | DATAINCONTROL = (3 << 14) | (4 << 3); | ||
63 | } | ||
64 | break; | ||
65 | |||
66 | case AUDIO_SRC_LINEIN: /* recording only */ | ||
67 | if (source != last_source) | ||
68 | { | ||
69 | audiohw_enable_recording(false); /* source line */ | ||
70 | /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ | ||
71 | DATAINCONTROL = (3 << 14) | (4 << 3); | ||
72 | } | ||
73 | break; | ||
74 | } /* end switch */ | ||
75 | |||
76 | or_l((1 << 29), &GPIO_OUT); /* Line In */ | ||
77 | or_l((1 << 29), &GPIO_ENABLE); | ||
78 | or_l((1 << 29), &GPIO_FUNCTION); | ||
79 | |||
80 | last_source = source; | ||
81 | } /* audio_set_source */ | ||
82 | |||
diff --git a/firmware/target/coldfire/iaudio/m5/backlight-m5.c b/firmware/target/coldfire/iaudio/m5/backlight-m5.c new file mode 100644 index 0000000000..63bc5bc30e --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/backlight-m5.c | |||
@@ -0,0 +1,58 @@ | |||
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 "system.h" | ||
22 | #include "backlight.h" | ||
23 | #include "backlight-target.h" | ||
24 | #include "pcf50606.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | bool __backlight_init(void) | ||
28 | { | ||
29 | __backlight_on(); | ||
30 | |||
31 | return true; /* Backlight always ON after boot. */ | ||
32 | } | ||
33 | |||
34 | void __backlight_on(void) | ||
35 | { | ||
36 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
37 | |||
38 | pcf50606_write(0x39, 0x07); | ||
39 | set_irq_level(level); | ||
40 | } | ||
41 | |||
42 | void __backlight_off(void) | ||
43 | { | ||
44 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
45 | |||
46 | pcf50606_write(0x39, 0x00); | ||
47 | set_irq_level(level); | ||
48 | } | ||
49 | |||
50 | void __remote_backlight_on(void) | ||
51 | { | ||
52 | and_l(~0x00200000, &GPIO_OUT); | ||
53 | } | ||
54 | |||
55 | void __remote_backlight_off(void) | ||
56 | { | ||
57 | or_l(0x00200000, &GPIO_OUT); | ||
58 | } | ||
diff --git a/firmware/target/coldfire/iaudio/m5/backlight-target.h b/firmware/target/coldfire/iaudio/m5/backlight-target.h new file mode 100644 index 0000000000..d9c116803e --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/backlight-target.h | |||
@@ -0,0 +1,29 @@ | |||
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 | #ifndef BACKLIGHT_TARGET_H | ||
20 | #define BACKLIGHT_TARGET_H | ||
21 | |||
22 | #define __BACKLIGHT_INIT | ||
23 | bool __backlight_init(void); | ||
24 | void __backlight_on(void); | ||
25 | void __backlight_off(void); | ||
26 | void __remote_backlight_on(void); | ||
27 | void __remote_backlight_off(void); | ||
28 | |||
29 | #endif | ||
diff --git a/firmware/target/coldfire/iaudio/m5/button-m5.c b/firmware/target/coldfire/iaudio/m5/button-m5.c new file mode 100644 index 0000000000..a5fdd79fde --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/button-m5.c | |||
@@ -0,0 +1,151 @@ | |||
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 "system.h" | ||
21 | #include "button.h" | ||
22 | #include "backlight.h" | ||
23 | #include "adc.h" | ||
24 | #include "lcd-remote-target.h" | ||
25 | |||
26 | /* have buttons scan by default */ | ||
27 | static bool button_scan_on = true; | ||
28 | static bool hold_button = false; | ||
29 | static bool remote_hold_button = false; | ||
30 | |||
31 | void button_init_device(void) | ||
32 | { | ||
33 | /* Power, Remote Play & Hold switch */ | ||
34 | GPIO_FUNCTION |= 0x0e000000; | ||
35 | GPIO_ENABLE &= ~0x0e000000; | ||
36 | } | ||
37 | |||
38 | void button_enable_scan(bool enable) | ||
39 | { | ||
40 | button_scan_on = enable; | ||
41 | } | ||
42 | |||
43 | bool button_scan_enabled(void) | ||
44 | { | ||
45 | return button_scan_on; | ||
46 | } | ||
47 | |||
48 | bool button_hold(void) | ||
49 | { | ||
50 | return (GPIO_READ & 0x08000000) == 0; | ||
51 | } | ||
52 | |||
53 | bool remote_button_hold(void) | ||
54 | { | ||
55 | return remote_hold_button; | ||
56 | } | ||
57 | |||
58 | int button_read_device(void) | ||
59 | { | ||
60 | int btn = BUTTON_NONE; | ||
61 | bool hold_button_old; | ||
62 | bool remote_hold_button_old; | ||
63 | int data; | ||
64 | |||
65 | /* normal buttons */ | ||
66 | hold_button_old = hold_button; | ||
67 | hold_button = button_hold(); | ||
68 | |||
69 | #ifndef BOOTLOADER | ||
70 | /* give BL notice if HB state chaged */ | ||
71 | if (hold_button != hold_button_old) | ||
72 | backlight_hold_changed(hold_button); | ||
73 | #endif | ||
74 | |||
75 | if (button_scan_on && !hold_button) | ||
76 | { | ||
77 | data = adc_scan(ADC_BUTTONS); | ||
78 | |||
79 | if (data < 0xf0) | ||
80 | { | ||
81 | if(data < 0x7c) | ||
82 | if(data < 0x42) | ||
83 | btn = BUTTON_LEFT; | ||
84 | else | ||
85 | if(data < 0x62) | ||
86 | btn = BUTTON_RIGHT; | ||
87 | else | ||
88 | btn = BUTTON_SELECT; | ||
89 | else | ||
90 | if(data < 0xb6) | ||
91 | if(data < 0x98) | ||
92 | btn = BUTTON_PLAY; | ||
93 | else | ||
94 | btn = BUTTON_REC; | ||
95 | else | ||
96 | if(data < 0xd3) | ||
97 | btn = BUTTON_DOWN; | ||
98 | else | ||
99 | btn = BUTTON_UP; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | /* remote buttons */ | ||
104 | data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff; | ||
105 | |||
106 | remote_hold_button_old = remote_hold_button; | ||
107 | remote_hold_button = data < 0x17; | ||
108 | |||
109 | #ifndef BOOTLOADER | ||
110 | if (remote_hold_button != remote_hold_button_old) | ||
111 | remote_backlight_hold_changed(remote_hold_button); | ||
112 | #endif | ||
113 | |||
114 | if (!remote_hold_button) | ||
115 | { | ||
116 | if (data < 0xee) | ||
117 | { | ||
118 | if(data < 0x7a) | ||
119 | if(data < 0x41) | ||
120 | btn |= BUTTON_RC_FF; | ||
121 | else | ||
122 | if(data < 0x61) | ||
123 | btn |= BUTTON_RC_REW; | ||
124 | else | ||
125 | btn |= BUTTON_RC_MODE; | ||
126 | else | ||
127 | if(data < 0xb4) | ||
128 | if(data < 0x96) | ||
129 | btn |= BUTTON_RC_REC; | ||
130 | else | ||
131 | btn |= BUTTON_RC_MENU; | ||
132 | else | ||
133 | if(data < 0xd1) | ||
134 | btn |= BUTTON_RC_VOL_UP; | ||
135 | else | ||
136 | btn |= BUTTON_RC_VOL_DOWN; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | data = GPIO_READ; | ||
141 | |||
142 | /* hold and power are mutually exclusive */ | ||
143 | if (!(data & 0x04000000)) | ||
144 | btn |= BUTTON_POWER; | ||
145 | |||
146 | /* remote play button should be dead if hold */ | ||
147 | if (!remote_hold_button && !(data & 0x02000000)) | ||
148 | btn |= BUTTON_RC_PLAY; | ||
149 | |||
150 | return btn; | ||
151 | } | ||
diff --git a/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S b/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S new file mode 100644 index 0000000000..c973dc2c40 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/lcd-as-m5.S | |||
@@ -0,0 +1,83 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 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 | |||
23 | .section .icode,"ax",@progbits | ||
24 | |||
25 | .align 2 | ||
26 | .global lcd_write_command | ||
27 | .type lcd_write_command,@function | ||
28 | |||
29 | lcd_write_command: | ||
30 | move.l (4, %sp), %d0 | ||
31 | move.w %d0, 0xf0008000 | ||
32 | rts | ||
33 | .wc_end: | ||
34 | .size lcd_write_command,.wc_end-lcd_write_command | ||
35 | |||
36 | |||
37 | .align 2 | ||
38 | .global lcd_write_command_ex | ||
39 | .type lcd_write_command_ex,@function | ||
40 | |||
41 | lcd_write_command_ex: | ||
42 | lea.l 0xf0008000, %a0 | ||
43 | |||
44 | move.l (4, %sp), %d0 /* Command */ | ||
45 | move.w %d0, (%a0)+ /* Write to LCD, set A0 = 1 */ | ||
46 | |||
47 | move.l (8, %sp), %d0 /* Data */ | ||
48 | cmp.l #-1, %d0 /* -1? */ | ||
49 | beq.b .last | ||
50 | move.w %d0, (%a0) /* Write to LCD */ | ||
51 | |||
52 | move.l (12, %sp), %d0 /* Data */ | ||
53 | cmp.l #-1, %d0 /* -1? */ | ||
54 | beq.b .last | ||
55 | move.w %d0, (%a0) /* Write to LCD */ | ||
56 | |||
57 | .last: | ||
58 | rts | ||
59 | .wcex_end: | ||
60 | .size lcd_write_command_ex,.wcex_end-lcd_write_command_ex | ||
61 | |||
62 | |||
63 | .align 2 | ||
64 | .global lcd_write_data | ||
65 | .type lcd_write_data,@function | ||
66 | |||
67 | lcd_write_data: | ||
68 | move.l (4,%sp), %a0 /* Data pointer */ | ||
69 | move.l (8,%sp), %d0 /* Length */ | ||
70 | |||
71 | lea 0xf0008002, %a1 | ||
72 | .loop: | ||
73 | /* When running in IRAM, this loop takes 7 cycles plus the LCD write. | ||
74 | The 7 cycles are necessary to follow the LCD timing specs | ||
75 | at 140MHz */ | ||
76 | move.b (%a0)+, %d1 /* 3(1/0) */ | ||
77 | move.w %d1, (%a1) /* 1(0/1) */ | ||
78 | subq.l #1, %d0 /* 1(0/0) */ | ||
79 | nop /* 1(0/0) */ | ||
80 | bne .loop /* 2(0/0) */ | ||
81 | rts | ||
82 | .wd_end: | ||
83 | .size lcd_write_data,.wd_end-lcd_write_data | ||
diff --git a/firmware/target/coldfire/iaudio/m5/lcd-m5.c b/firmware/target/coldfire/iaudio/m5/lcd-m5.c new file mode 100644 index 0000000000..2af46b3145 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/lcd-m5.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 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 | #include "config.h" | ||
20 | |||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "lcd.h" | ||
24 | |||
25 | /*** definitions ***/ | ||
26 | |||
27 | /* LCD command codes */ | ||
28 | #define LCD_CNTL_POWER_CONTROL 0x25 | ||
29 | #define LCD_CNTL_VOLTAGE_SELECT 0x2b | ||
30 | #define LCD_CNTL_LINE_INVERT_DRIVE 0x36 | ||
31 | #define LCD_CNTL_GRAY_SCALE_PATTERN 0x39 | ||
32 | #define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e | ||
33 | #define LCD_CNTL_OSC_FREQUENCY 0x5f | ||
34 | #define LCD_CNTL_ON_OFF 0xae | ||
35 | #define LCD_CNTL_OSC_ON_OFF 0xaa | ||
36 | #define LCD_CNTL_OFF_MODE 0xbe | ||
37 | #define LCD_CNTL_POWER_SAVE 0xa8 | ||
38 | #define LCD_CNTL_REVERSE 0xa6 | ||
39 | #define LCD_CNTL_ALL_LIGHTING 0xa4 | ||
40 | #define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4 | ||
41 | #define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0 | ||
42 | #define LCD_CNTL_NLINE_ON_OFF 0xe4 | ||
43 | #define LCD_CNTL_DISPLAY_MODE 0x66 | ||
44 | #define LCD_CNTL_DUTY_SET 0x6d | ||
45 | #define LCD_CNTL_ELECTRONIC_VOLUME 0x81 | ||
46 | #define LCD_CNTL_DATA_INPUT_DIR 0x84 | ||
47 | #define LCD_CNTL_DISPLAY_START_LINE 0x8a | ||
48 | #define LCD_CNTL_AREA_SCROLL 0x10 | ||
49 | |||
50 | #define LCD_CNTL_PAGE 0xb1 | ||
51 | #define LCD_CNTL_COLUMN 0x13 | ||
52 | #define LCD_CNTL_DATA_WRITE 0x1d | ||
53 | |||
54 | /*** shared semi-private declarations ***/ | ||
55 | extern const unsigned char lcd_dibits[16] ICONST_ATTR; | ||
56 | |||
57 | /*** hardware configuration ***/ | ||
58 | int lcd_default_contrast(void) | ||
59 | { | ||
60 | return DEFAULT_CONTRAST_SETTING; | ||
61 | } | ||
62 | |||
63 | void lcd_set_contrast(int val) | ||
64 | { | ||
65 | /* Keep val in acceptable hw range */ | ||
66 | if (val < 0) | ||
67 | val = 0; | ||
68 | else if (val > 127) | ||
69 | val = 127; | ||
70 | |||
71 | lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, val, -1); | ||
72 | } | ||
73 | |||
74 | void lcd_set_invert_display(bool yesno) | ||
75 | { | ||
76 | lcd_write_command(LCD_CNTL_REVERSE | (yesno?1:0)); | ||
77 | } | ||
78 | |||
79 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
80 | void lcd_set_flip(bool yesno) | ||
81 | { | ||
82 | if (yesno) | ||
83 | { | ||
84 | lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); | ||
85 | lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 1); | ||
86 | lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 2); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 1); | ||
91 | lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); | ||
92 | lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void lcd_init_device(void) | ||
97 | { | ||
98 | /* LCD Reset */ | ||
99 | and_l(~0x00000010, &GPIO1_OUT); | ||
100 | or_l(0x00000010, &GPIO1_ENABLE); | ||
101 | or_l(0x00000010, &GPIO1_FUNCTION); | ||
102 | sleep(1); | ||
103 | or_l(0x00000010, &GPIO1_OUT); | ||
104 | sleep(1); | ||
105 | |||
106 | lcd_write_command(LCD_CNTL_ON_OFF | 1); /* LCD ON */ | ||
107 | lcd_write_command(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */ | ||
108 | lcd_write_command(LCD_CNTL_REVERSE | 0); /* Reverse OFF */ | ||
109 | lcd_write_command(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */ | ||
110 | lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal dir */ | ||
111 | lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, 4, -1); | ||
112 | lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 1); /* Reverse */ | ||
113 | lcd_write_command_ex(LCD_CNTL_DISPLAY_MODE, 0, -1); /* Greyscale mode */ | ||
114 | lcd_write_command_ex(LCD_CNTL_GRAY_SCALE_PATTERN, 0x53, -1); | ||
115 | lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1); | ||
116 | lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, 40, -1); | ||
117 | |||
118 | lcd_write_command(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */ | ||
119 | lcd_write_command(LCD_CNTL_POWER_SAVE | 0); | ||
120 | lcd_write_command_ex(LCD_CNTL_VOLTAGE_SELECT, 3, -1); | ||
121 | lcd_write_command_ex(LCD_CNTL_POWER_CONTROL, 0x17, -1); | ||
122 | lcd_write_command_ex(LCD_CNTL_OSC_FREQUENCY, 3, -1); | ||
123 | lcd_write_command(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */ | ||
124 | lcd_write_command_ex(LCD_CNTL_LINE_INVERT_DRIVE, 0x10, -1); | ||
125 | lcd_write_command_ex(LCD_CNTL_TEMP_GRADIENT_SELECT, 0, -1); | ||
126 | |||
127 | lcd_update(); | ||
128 | } | ||
129 | |||
130 | /*** update functions ***/ | ||
131 | |||
132 | /* Performance function that works with an external buffer | ||
133 | note that by and bheight are in 8-pixel units! */ | ||
134 | void lcd_blit(const unsigned char* data, int x, int by, int width, | ||
135 | int bheight, int stride) | ||
136 | { | ||
137 | const unsigned char *src, *src_end; | ||
138 | unsigned char *dst_u, *dst_l; | ||
139 | static unsigned char upper[LCD_WIDTH] IBSS_ATTR; | ||
140 | static unsigned char lower[LCD_WIDTH] IBSS_ATTR; | ||
141 | unsigned int byte; | ||
142 | |||
143 | by *= 2; | ||
144 | |||
145 | while (bheight--) | ||
146 | { | ||
147 | src = data; | ||
148 | src_end = data + width; | ||
149 | dst_u = upper; | ||
150 | dst_l = lower; | ||
151 | do | ||
152 | { | ||
153 | byte = *src++; | ||
154 | *dst_u++ = lcd_dibits[byte & 0x0F]; | ||
155 | byte >>= 4; | ||
156 | *dst_l++ = lcd_dibits[byte & 0x0F]; | ||
157 | } | ||
158 | while (src < src_end); | ||
159 | |||
160 | lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1); | ||
161 | lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); | ||
162 | lcd_write_command(LCD_CNTL_DATA_WRITE); | ||
163 | lcd_write_data(upper, width); | ||
164 | |||
165 | lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1); | ||
166 | lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); | ||
167 | lcd_write_command(LCD_CNTL_DATA_WRITE); | ||
168 | lcd_write_data(lower, width); | ||
169 | |||
170 | data += stride; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | |||
175 | /* Update the display. | ||
176 | This must be called after all other LCD functions that change the display. */ | ||
177 | void lcd_update(void) ICODE_ATTR; | ||
178 | void lcd_update(void) | ||
179 | { | ||
180 | int y; | ||
181 | |||
182 | /* Copy display bitmap to hardware */ | ||
183 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
184 | { | ||
185 | lcd_write_command_ex(LCD_CNTL_PAGE, y, -1); | ||
186 | lcd_write_command_ex(LCD_CNTL_COLUMN, 0, -1); | ||
187 | |||
188 | lcd_write_command(LCD_CNTL_DATA_WRITE); | ||
189 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | /* Update a fraction of the display. */ | ||
194 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
195 | void lcd_update_rect(int x, int y, int width, int height) | ||
196 | { | ||
197 | int ymax; | ||
198 | |||
199 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
200 | ymax = (y + height-1) >> 2; | ||
201 | y >>= 2; | ||
202 | |||
203 | if(x + width > LCD_WIDTH) | ||
204 | width = LCD_WIDTH - x; | ||
205 | if (width <= 0) | ||
206 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
207 | if(ymax >= LCD_FBHEIGHT) | ||
208 | ymax = LCD_FBHEIGHT-1; | ||
209 | |||
210 | /* Copy specified rectange bitmap to hardware */ | ||
211 | for (; y <= ymax; y++) | ||
212 | { | ||
213 | lcd_write_command_ex(LCD_CNTL_PAGE, y, -1); | ||
214 | lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1); | ||
215 | |||
216 | lcd_write_command(LCD_CNTL_DATA_WRITE); | ||
217 | lcd_write_data (&lcd_framebuffer[y][x], width); | ||
218 | } | ||
219 | } | ||
diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c new file mode 100644 index 0000000000..c689488bfe --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/power-m5.c | |||
@@ -0,0 +1,89 @@ | |||
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 <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | #include "pcf50606.h" | ||
26 | #include "lcd-remote-target.h" | ||
27 | |||
28 | #ifndef SIMULATOR | ||
29 | |||
30 | void power_init(void) | ||
31 | { | ||
32 | /* Charger detect */ | ||
33 | and_l(~0x01000000, &GPIO1_ENABLE); | ||
34 | or_l(0x01000000, &GPIO1_FUNCTION); | ||
35 | |||
36 | pcf50606_init(); | ||
37 | } | ||
38 | |||
39 | bool charger_inserted(void) | ||
40 | { | ||
41 | return (GPIO1_READ & 0x01000000)?true:false; | ||
42 | } | ||
43 | |||
44 | void ide_power_enable(bool on) | ||
45 | { | ||
46 | /* GPOOD3 */ | ||
47 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
48 | if(on) | ||
49 | pcf50606_write(0x3c, 0x07); | ||
50 | else | ||
51 | pcf50606_write(0x3c, 0x00); | ||
52 | set_irq_level(level); | ||
53 | } | ||
54 | |||
55 | bool ide_powered(void) | ||
56 | { | ||
57 | return false; | ||
58 | } | ||
59 | |||
60 | void power_off(void) | ||
61 | { | ||
62 | lcd_remote_poweroff(); | ||
63 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
64 | and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */ | ||
65 | asm("halt"); | ||
66 | } | ||
67 | |||
68 | #else | ||
69 | |||
70 | bool charger_inserted(void) | ||
71 | { | ||
72 | return false; | ||
73 | } | ||
74 | |||
75 | void charger_enable(bool on) | ||
76 | { | ||
77 | (void)on; | ||
78 | } | ||
79 | |||
80 | void power_off(void) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | void ide_power_enable(bool on) | ||
85 | { | ||
86 | (void)on; | ||
87 | } | ||
88 | |||
89 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/pcf50606-iaudio.c index f8f6c1d675..f8f6c1d675 100644 --- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c +++ b/firmware/target/coldfire/iaudio/pcf50606-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/x5/system-x5.c b/firmware/target/coldfire/iaudio/system-iaudio.c index 30a4f6e71b..30a4f6e71b 100644 --- a/firmware/target/coldfire/iaudio/x5/system-x5.c +++ b/firmware/target/coldfire/iaudio/system-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/x5/usb-x5.c b/firmware/target/coldfire/iaudio/usb-iaudio.c index 3bd1a7a458..3bd1a7a458 100644 --- a/firmware/target/coldfire/iaudio/x5/usb-x5.c +++ b/firmware/target/coldfire/iaudio/usb-iaudio.c | |||
diff --git a/firmware/target/coldfire/iaudio/usb-target.h b/firmware/target/coldfire/iaudio/usb-target.h new file mode 100644 index 0000000000..ab8cac6f99 --- /dev/null +++ b/firmware/target/coldfire/iaudio/usb-target.h | |||
@@ -0,0 +1,24 @@ | |||
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 | #ifndef USB_TARGET_H | ||
20 | #define USB_TARGET_H | ||
21 | |||
22 | bool usb_init_device(void); | ||
23 | |||
24 | #endif | ||