diff options
author | Dave Chapman <dave@dchapman.com> | 2008-09-06 17:50:59 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-09-06 17:50:59 +0000 |
commit | d462a64a918117991e11dade2d7fa3a28196e07a (patch) | |
tree | 0a6f5ed8777b18bb1641fbb3608f10374901706c /firmware/target/arm/tcc77x/iaudio7 | |
parent | b87715f670f04c9adbe358c32a385c6771d99a81 (diff) | |
download | rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip |
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7')
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/adc-target.h | 28 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/ata2501.c | 124 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/ata2501.h | 27 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c | 99 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/backlight-target.h | 46 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c | 81 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/button-target.h | 57 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c | 252 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c | 146 |
9 files changed, 860 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h new file mode 100644 index 0000000000..1916d93598 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/adc-target.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 8 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | |||
28 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c new file mode 100644 index 0000000000..fa165d9d0d --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "button.h" | ||
25 | |||
26 | #include "ata2501.h" | ||
27 | |||
28 | #define STB (1<<5) | ||
29 | #define SDATA (1<<4) | ||
30 | #define RESET (1<<6) | ||
31 | #define SIFMD (1<<7) | ||
32 | #define STB_DELAY 200 | ||
33 | |||
34 | #define udelay _udelay | ||
35 | |||
36 | /* do we really need it? */ | ||
37 | static void _udelay(int cycles) | ||
38 | { | ||
39 | cycles /= 8; | ||
40 | while (cycles--) { | ||
41 | asm("nop;nop;"); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | TODO: sensitivity using GPIOS | ||
47 | */ | ||
48 | void ata2501_init(void) | ||
49 | { | ||
50 | GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9)); | ||
51 | GPIOD_DIR &= ~(SDATA); | ||
52 | |||
53 | GPIOD &= ~RESET; | ||
54 | udelay(1000); | ||
55 | |||
56 | GPIOD |= RESET; | ||
57 | |||
58 | GPIOD &= ~STB; | ||
59 | |||
60 | #if 1 | ||
61 | GPIOD &= ~((1 << 9) | (1 << 8)); | ||
62 | GPIOD |= ((1 << 8) | SIFMD) | (1 << 9); | ||
63 | #else | ||
64 | GPIOD |= ((1 << 9) | (1 << 8)); | ||
65 | GPIOD &= ~(SIFMD); | ||
66 | #endif | ||
67 | } | ||
68 | |||
69 | unsigned short ata2501_read(void) | ||
70 | { | ||
71 | unsigned short ret = 0; | ||
72 | int i; | ||
73 | |||
74 | for (i = 0; i < 12; i++) { | ||
75 | GPIOD |= STB; | ||
76 | udelay(50); | ||
77 | |||
78 | ret <<= 1; | ||
79 | if (GPIOD & SDATA) | ||
80 | ret |= 1; | ||
81 | udelay(50); | ||
82 | GPIOD &= ~STB; | ||
83 | udelay(100); | ||
84 | } | ||
85 | |||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | #define ATA2501_TEST | ||
90 | #ifdef ATA2501_TEST | ||
91 | #include "lcd.h" | ||
92 | #include "sprintf.h" | ||
93 | |||
94 | static | ||
95 | void bits(char *str, unsigned short val) | ||
96 | { | ||
97 | int i; | ||
98 | |||
99 | for (i = 0; i < 12; i++) | ||
100 | str[i] = (val & (1 << i)) ? '1' : '0'; | ||
101 | str[i] = 0; | ||
102 | } | ||
103 | |||
104 | void ata2501_test(void) | ||
105 | { | ||
106 | char buf[100]; | ||
107 | ata2501_init(); | ||
108 | |||
109 | while (1) { | ||
110 | unsigned short data; | ||
111 | int i, line = 0; | ||
112 | |||
113 | data = ata2501_read(); | ||
114 | lcd_clear_display(); | ||
115 | lcd_puts(0, line++, "ATA2501 test"); | ||
116 | |||
117 | bits(buf, data); | ||
118 | lcd_puts(0, line++, buf); | ||
119 | |||
120 | lcd_update(); | ||
121 | udelay(2000); | ||
122 | } | ||
123 | } | ||
124 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h new file mode 100644 index 0000000000..465d0b199c --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ATA2501_H_ | ||
22 | #define _ATA2501_H_ | ||
23 | |||
24 | void ata2501_init(void); | ||
25 | unsigned short ata2501_read(void); | ||
26 | |||
27 | #endif /* _ATA2501_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c new file mode 100644 index 0000000000..4e7f58df47 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Michael Sevakis | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "system.h" | ||
22 | #include "cpu.h" | ||
23 | #include "audio.h" | ||
24 | #include "sound.h" | ||
25 | |||
26 | int audio_channels = 2; | ||
27 | int audio_output_source = AUDIO_SRC_PLAYBACK; | ||
28 | |||
29 | void audiohw_enable_output(bool on) | ||
30 | { | ||
31 | (void) on; | ||
32 | } | ||
33 | |||
34 | void audio_set_output_source(int source) | ||
35 | { | ||
36 | int oldmode = set_fiq_status(FIQ_DISABLED); | ||
37 | |||
38 | if ((unsigned)source >= AUDIO_NUM_SOURCES) | ||
39 | source = AUDIO_SRC_PLAYBACK; | ||
40 | |||
41 | audio_output_source = source; | ||
42 | set_fiq_status(oldmode); | ||
43 | } | ||
44 | |||
45 | void audio_input_mux(int source, unsigned flags) | ||
46 | { | ||
47 | static int last_source = AUDIO_SRC_PLAYBACK; | ||
48 | static bool last_recording = false; | ||
49 | bool recording = flags & SRCF_RECORDING; | ||
50 | |||
51 | switch (source) | ||
52 | { | ||
53 | default: /* playback - no recording */ | ||
54 | source = AUDIO_SRC_PLAYBACK; | ||
55 | case AUDIO_SRC_PLAYBACK: | ||
56 | audio_channels = 2; | ||
57 | if (source != last_source) | ||
58 | { | ||
59 | audiohw_set_monitor(false); | ||
60 | /* audiohw_disable_recording();*/ | ||
61 | } | ||
62 | break; | ||
63 | |||
64 | case AUDIO_SRC_MIC: /* recording only */ | ||
65 | GPIOD |= 0x1; | ||
66 | |||
67 | audio_channels = 1; | ||
68 | if (source != last_source) | ||
69 | { | ||
70 | /*audiohw_set_monitor(false); | ||
71 | audiohw_enable_recording(true); /. source mic */ | ||
72 | } | ||
73 | break; | ||
74 | |||
75 | case AUDIO_SRC_FMRADIO: /* recording and playback */ | ||
76 | GPIOD &= ~0x1; | ||
77 | |||
78 | audio_channels = 2; | ||
79 | |||
80 | if (source == last_source && recording == last_recording) | ||
81 | break; | ||
82 | |||
83 | last_recording = recording; | ||
84 | |||
85 | if (recording) | ||
86 | { | ||
87 | /*audiohw_set_monitor(false); | ||
88 | audiohw_enable_recording(false);*/ | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | /*audiohw_disable_recording(); */ | ||
93 | audiohw_set_monitor(true); /* line 1 analog audio path */ | ||
94 | } | ||
95 | break; | ||
96 | } /* end switch */ | ||
97 | |||
98 | last_source = source; | ||
99 | } /* audio_input_mux */ | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h new file mode 100644 index 0000000000..597583b16f --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | #include "tcc77x.h" | ||
26 | |||
27 | void power_touch_panel(bool on); | ||
28 | |||
29 | static inline bool _backlight_init(void) | ||
30 | { | ||
31 | GPIOD_DIR |= 0x2; | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | static inline void _backlight_on(void) | ||
36 | { | ||
37 | GPIOD |= 0x2; | ||
38 | power_touch_panel(true); | ||
39 | } | ||
40 | |||
41 | static inline void _backlight_off(void) | ||
42 | { | ||
43 | GPIOD &= ~0x2; | ||
44 | power_touch_panel(false); | ||
45 | } | ||
46 | #endif /* BACKLIGHT_TARGET_H */ | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c new file mode 100644 index 0000000000..3aad4f75a4 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "button.h" | ||
24 | #include "adc.h" | ||
25 | |||
26 | #include "button-target.h" | ||
27 | #include "ata2501.h" | ||
28 | |||
29 | void button_init_device(void) | ||
30 | { | ||
31 | ata2501_init(); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | touchpad: | ||
36 | 0: stop | ||
37 | 1-8: between next & prev | ||
38 | 9: play | ||
39 | 10: next | ||
40 | 11: prev | ||
41 | */ | ||
42 | |||
43 | int button_read_device(void) | ||
44 | { | ||
45 | int btn = BUTTON_NONE; | ||
46 | int adc; | ||
47 | int sensor; | ||
48 | |||
49 | if (button_hold()) | ||
50 | return BUTTON_NONE; | ||
51 | |||
52 | adc = adc_read(0); | ||
53 | sensor = ata2501_read(); | ||
54 | |||
55 | if (0 == (GPIOA & 4)) | ||
56 | btn |= BUTTON_POWER; | ||
57 | |||
58 | /* seems they can't be hold together */ | ||
59 | if (adc < 0x120) | ||
60 | btn |= BUTTON_VOLUP; | ||
61 | else if (adc < 0x270) | ||
62 | btn |= BUTTON_VOLDOWN; | ||
63 | else if (adc < 0x300) | ||
64 | btn |= BUTTON_MENU; | ||
65 | |||
66 | if (sensor & (1 << 0)) | ||
67 | btn |= BUTTON_STOP; | ||
68 | if (sensor & (1 << 9)) | ||
69 | btn |= BUTTON_PLAY; | ||
70 | if (sensor & ((1 << 10) | 0x1c0)) | ||
71 | btn |= BUTTON_RIGHT; | ||
72 | if (sensor & ((1 << 11) | 0xe)) | ||
73 | btn |= BUTTON_LEFT; | ||
74 | |||
75 | return btn; | ||
76 | } | ||
77 | |||
78 | bool button_hold(void) | ||
79 | { | ||
80 | return !(GPIOA & 0x2); | ||
81 | } | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h new file mode 100644 index 0000000000..fafaf4a303 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/button-target.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _IAUDIO7_BUTTON_TARGET_H_ | ||
22 | #define _IAUDIO7_BUTTON_TARGET_H_ | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | #include "config.h" | ||
26 | |||
27 | #define HAS_BUTTON_HOLD | ||
28 | |||
29 | bool button_hold(void); | ||
30 | void button_init_device(void); | ||
31 | int button_read_device(void); | ||
32 | |||
33 | /* Main unit's buttons */ | ||
34 | #define BUTTON_POWER 0x00000001 | ||
35 | #define BUTTON_VOLUP 0x00000002 | ||
36 | #define BUTTON_VOLDOWN 0x00000004 | ||
37 | #define BUTTON_MENU 0x00000008 | ||
38 | |||
39 | #define BUTTON_LEFT 0x00000010 | ||
40 | #define BUTTON_RIGHT 0x00000020 | ||
41 | #define BUTTON_PLAY 0x00000040 | ||
42 | #define BUTTON_STOP 0x00000080 | ||
43 | |||
44 | #define BUTTON_ON BUTTON_POWER | ||
45 | |||
46 | #define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \ | ||
47 | BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \ | ||
48 | BUTTON_PLAY|BUTTON_STOP) | ||
49 | |||
50 | /* No remote */ | ||
51 | #define BUTTON_REMOTE 0 | ||
52 | |||
53 | /* Software power-off */ | ||
54 | #define POWEROFF_BUTTON BUTTON_POWER | ||
55 | #define POWEROFF_COUNT 10 | ||
56 | |||
57 | #endif /* _IAUDIO7_BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c new file mode 100644 index 0000000000..bbc20b6860 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c | |||
@@ -0,0 +1,252 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2004 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | /* | ||
23 | Thanks Hein-Pieter van Braam for initial work. | ||
24 | |||
25 | Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov | ||
26 | */ | ||
27 | |||
28 | #include <config.h> | ||
29 | |||
30 | #include <kernel.h> | ||
31 | #include <cpu.h> | ||
32 | #include <lcd.h> | ||
33 | #include <system-target.h> | ||
34 | |||
35 | #include "hd66789r.h" | ||
36 | |||
37 | static bool display_on = false; /* is the display turned on? */ | ||
38 | |||
39 | static inline void lcd_write_reg(int reg, int data) | ||
40 | { | ||
41 | GPIOA &= ~0x400; | ||
42 | outw(0, 0x50010000); | ||
43 | outw(reg << 1, 0x50010000); | ||
44 | GPIOA |= 0x400; | ||
45 | |||
46 | outw((data & 0xff00) >> 7, 0x50010008); | ||
47 | outw((data << 24) >> 23, 0x50010008); | ||
48 | } | ||
49 | |||
50 | static void lcd_write_cmd(int reg) | ||
51 | { | ||
52 | GPIOA &= ~0x400; | ||
53 | outw(0, 0x50010000); | ||
54 | outw(reg << 1, 0x50010000); | ||
55 | GPIOA |= 0x400; | ||
56 | } | ||
57 | |||
58 | /* Do what OF do */ | ||
59 | static void lcd_delay(int x) | ||
60 | { | ||
61 | int i; | ||
62 | |||
63 | x *= 0xc35; | ||
64 | for (i = 0; i < x * 8; i++) { | ||
65 | } | ||
66 | } | ||
67 | |||
68 | |||
69 | static void _display_on(void) | ||
70 | { | ||
71 | GPIOA_DIR |= 0x8000 | 0x400; | ||
72 | GPIOA |= 0x8000; | ||
73 | |||
74 | /* power setup */ | ||
75 | lcd_write_reg(R_START_OSC, 0x0001); | ||
76 | lcd_delay(0xf); | ||
77 | lcd_write_reg(R_DISP_CONTROL1, 0x000); | ||
78 | lcd_delay(0xa); | ||
79 | lcd_write_reg(R_POWER_CONTROL2, 0x0002); | ||
80 | lcd_write_reg(R_POWER_CONTROL3, 0x000a); | ||
81 | lcd_write_reg(R_POWER_CONTROL4, 0xc5a); | ||
82 | lcd_write_reg(R_POWER_CONTROL1, 0x0004); | ||
83 | lcd_write_reg(R_POWER_CONTROL1, 0x0134); | ||
84 | lcd_write_reg(R_POWER_CONTROL2, 0x0111); | ||
85 | lcd_write_reg(R_POWER_CONTROL3, 0x001c); | ||
86 | lcd_delay(0x28); | ||
87 | lcd_write_reg(R_POWER_CONTROL4, 0x2c40); | ||
88 | lcd_write_reg(R_POWER_CONTROL1, 0x0510); | ||
89 | lcd_delay(0x3c); | ||
90 | |||
91 | /* lcd init 2 */ | ||
92 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113); | ||
93 | lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700); | ||
94 | lcd_write_reg(R_ENTRY_MODE, 0x1038); | ||
95 | lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM | ||
96 | lcd_write_reg(R_DISP_CONTROL3, 0x0000); | ||
97 | lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003); | ||
98 | lcd_write_reg(R_RAM_ADDR_SET, 0x0000); | ||
99 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406); | ||
100 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303); | ||
101 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000); | ||
102 | lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305); | ||
103 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404); | ||
104 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000); | ||
105 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000); | ||
106 | lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503); | ||
107 | lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05); | ||
108 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05); | ||
109 | lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000); | ||
110 | lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00); | ||
111 | lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00); | ||
112 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00); | ||
113 | lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00); | ||
114 | |||
115 | /* lcd init 3 */ | ||
116 | lcd_write_reg(R_POWER_CONTROL1, 0x4510); | ||
117 | lcd_write_reg(R_DISP_CONTROL1, 0x0005); | ||
118 | lcd_delay(0x28); | ||
119 | lcd_write_reg(R_DISP_CONTROL1, 0x0025); | ||
120 | lcd_write_reg(R_DISP_CONTROL1, 0x0027); | ||
121 | lcd_delay(0x28); | ||
122 | lcd_write_reg(R_DISP_CONTROL1, 0x0037); | ||
123 | |||
124 | display_on = true; | ||
125 | } | ||
126 | |||
127 | void lcd_init_device(void) | ||
128 | { | ||
129 | /* Configure external memory banks */ | ||
130 | CSCFG1 = 0x3d500023; | ||
131 | |||
132 | /* may be reset */ | ||
133 | GPIOA |= 0x8000; | ||
134 | |||
135 | _display_on(); | ||
136 | } | ||
137 | |||
138 | void lcd_enable(bool on) | ||
139 | { | ||
140 | if (display_on == on) | ||
141 | return; | ||
142 | |||
143 | if (on) { | ||
144 | _display_on(); | ||
145 | // lcd_call_enable_hook(); | ||
146 | } else { | ||
147 | /** Off sequence according to datasheet, p. 130 **/ | ||
148 | lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */ | ||
149 | lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */ | ||
150 | sleep(2); | ||
151 | |||
152 | lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */ | ||
153 | sleep(2); | ||
154 | |||
155 | lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */ | ||
156 | |||
157 | lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */ | ||
158 | lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */ | ||
159 | lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */ | ||
160 | |||
161 | /* datasheet p. 131 */ | ||
162 | lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */ | ||
163 | |||
164 | display_on = false; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | bool lcd_enabled(void) | ||
169 | { | ||
170 | return display_on; | ||
171 | } | ||
172 | |||
173 | |||
174 | #define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f))) | ||
175 | |||
176 | |||
177 | void lcd_update(void) | ||
178 | { | ||
179 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
180 | } | ||
181 | |||
182 | /* todo: need tests */ | ||
183 | void lcd_update_rect(int sx, int sy, int width, int height) | ||
184 | { | ||
185 | int x, y; | ||
186 | |||
187 | if (!display_on) | ||
188 | return; | ||
189 | |||
190 | if (width <= 0 || height <= 0) /* nothing to do */ | ||
191 | return; | ||
192 | |||
193 | width += sx; | ||
194 | height += sy; | ||
195 | |||
196 | if (width > LCD_WIDTH) | ||
197 | width = LCD_WIDTH; | ||
198 | if (height > LCD_HEIGHT) | ||
199 | height = LCD_HEIGHT; | ||
200 | |||
201 | lcd_write_reg(R_ENTRY_MODE, 0x1028); | ||
202 | /* set update window */ | ||
203 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8); | ||
204 | lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx); | ||
205 | lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1)); | ||
206 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
207 | |||
208 | for (y = sy; y < height; y++) { | ||
209 | for (x = sx; x < width; x++) { | ||
210 | fb_data c; | ||
211 | unsigned long color; | ||
212 | |||
213 | c = lcd_framebuffer[y][x]; | ||
214 | color = | ||
215 | ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) << | ||
216 | 2); | ||
217 | |||
218 | /* TODO: our color is 18-bit */ | ||
219 | outw((color >> 9) & 0x1ff, 0x50010008); | ||
220 | outw((color) & 0x1ff, 0x50010008); | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | void lcd_set_contrast(int val) | ||
226 | { | ||
227 | (void) val; | ||
228 | } | ||
229 | |||
230 | void lcd_set_invert_display(bool yesno) | ||
231 | { | ||
232 | (void) yesno; | ||
233 | } | ||
234 | |||
235 | void lcd_set_flip(bool yesno) | ||
236 | { | ||
237 | (void) yesno; | ||
238 | } | ||
239 | |||
240 | /* TODO: implement me */ | ||
241 | void lcd_blit_yuv(unsigned char *const src[3], | ||
242 | int src_x, int src_y, int stride, | ||
243 | int x, int y, int width, int height) | ||
244 | { | ||
245 | if (!display_on) | ||
246 | return; | ||
247 | |||
248 | width &= ~1; /* stay on the safe side */ | ||
249 | height &= ~1; | ||
250 | |||
251 | panicf("%s", __func__); | ||
252 | } | ||
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c new file mode 100644 index 0000000000..ef012cbbdf --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c | |||
@@ -0,0 +1,146 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdbool.h> | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "kernel.h" | ||
26 | #include "system.h" | ||
27 | #include "power.h" | ||
28 | |||
29 | #include "pcf50606.h" | ||
30 | |||
31 | void power_init(void) | ||
32 | { | ||
33 | pcf50606_write(PCF5060X_DCDC1, 0x90); | ||
34 | pcf50606_write(PCF5060X_DCDC2, 0x48); | ||
35 | pcf50606_write(PCF5060X_DCDC3, 0xfc); | ||
36 | pcf50606_write(PCF5060X_DCDC4, 0xb1); | ||
37 | |||
38 | pcf50606_write(PCF5060X_IOREGC, 0xe9); | ||
39 | /* 3.3V, touch-panel */ | ||
40 | pcf50606_write(PCF5060X_D1REGC1, 0xf8); | ||
41 | pcf50606_write(PCF5060X_D2REGC1, 0xf2); | ||
42 | pcf50606_write(PCF5060X_D3REGC1, 0xf5); | ||
43 | |||
44 | pcf50606_write(PCF5060X_LPREGC1, 0x00); | ||
45 | pcf50606_write(PCF5060X_LPREGC2, 0x02); | ||
46 | |||
47 | pcf50606_write(PCF5060X_DCUDC1, 0xe6); | ||
48 | pcf50606_write(PCF5060X_DCUDC2, 0x30); | ||
49 | |||
50 | pcf50606_write(PCF5060X_DCDEC1, 0xe7); | ||
51 | pcf50606_write(PCF5060X_DCDEC2, 0x02); | ||
52 | |||
53 | pcf50606_write(PCF5060X_INT1M, 0x5b); | ||
54 | pcf50606_write(PCF5060X_INT1M, 0xaf); | ||
55 | pcf50606_write(PCF5060X_INT1M, 0x8f); | ||
56 | |||
57 | pcf50606_write(PCF5060X_OOCC1, 0x40); | ||
58 | pcf50606_write(PCF5060X_OOCC2, 0x05); | ||
59 | |||
60 | pcf50606_write(PCF5060X_MBCC3, 0x3a); | ||
61 | pcf50606_write(PCF5060X_GPOC1, 0x00); | ||
62 | pcf50606_write(PCF5060X_BBCC, 0xf8); | ||
63 | } | ||
64 | |||
65 | /* Control leds on ata2501 board */ | ||
66 | void power_touch_panel(bool on) | ||
67 | { | ||
68 | if (on) | ||
69 | pcf50606_write(PCF5060X_D1REGC1, 0xf8); | ||
70 | else | ||
71 | pcf50606_write(PCF5060X_D1REGC1, 0x00); | ||
72 | } | ||
73 | |||
74 | void ide_power_enable(bool on) | ||
75 | { | ||
76 | } | ||
77 | |||
78 | bool ide_powered(void) | ||
79 | { | ||
80 | return true; | ||
81 | } | ||
82 | |||
83 | void power_off(void) | ||
84 | { | ||
85 | /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */ | ||
86 | pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK); | ||
87 | } | ||
88 | |||
89 | #if CONFIG_TUNER | ||
90 | #include "tuner.h" | ||
91 | |||
92 | /** Tuner **/ | ||
93 | static bool powered = false; | ||
94 | |||
95 | #define TUNNER_CLK (1 << 5) | ||
96 | #define TUNNER_DATA (1 << 6) | ||
97 | #define TUNNER_NR_W (1 << 7) | ||
98 | |||
99 | bool tuner_power(bool status) | ||
100 | { | ||
101 | bool old_status; | ||
102 | lv24020lp_lock(); | ||
103 | |||
104 | old_status = powered; | ||
105 | |||
106 | if (status != old_status) | ||
107 | { | ||
108 | if (status) | ||
109 | { | ||
110 | /* When power up, host should initialize the 3-wire bus | ||
111 | in host read mode: */ | ||
112 | |||
113 | /* 1. Set direction of the DATA-line to input-mode. */ | ||
114 | GPIOA_DIR &= ~TUNNER_DATA; | ||
115 | |||
116 | /* 2. Drive NR_W low */ | ||
117 | GPIOA &= ~TUNNER_NR_W; | ||
118 | GPIOA_DIR |= TUNNER_NR_W; | ||
119 | |||
120 | /* 3. Drive CLOCK high */ | ||
121 | GPIOA |= TUNNER_CLK; | ||
122 | GPIOA_DIR |= TUNNER_CLK; | ||
123 | |||
124 | lv24020lp_power(true); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | lv24020lp_power(false); | ||
129 | |||
130 | /* set all as inputs */ | ||
131 | GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W); | ||
132 | } | ||
133 | |||
134 | powered = status; | ||
135 | } | ||
136 | |||
137 | lv24020lp_unlock(); | ||
138 | return old_status; | ||
139 | } | ||
140 | |||
141 | #endif /* CONFIG_TUNER */ | ||
142 | |||
143 | bool charger_inserted(void) | ||
144 | { | ||
145 | return (GPIOA & 0x1) ? true : false; | ||
146 | } | ||