diff options
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r-- | firmware/target/arm/tcc77x/adc-tcc77x.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/app.lds | 123 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/boot.lds | 5 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/crt0.S | 5 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/debug-tcc77x.c | 5 | ||||
-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 (renamed from firmware/target/arm/tcc77x/pcm-tcc77x.c) | 63 | ||||
-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 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/system-tcc77x.c | 11 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/usb-tcc77x.c | 8 |
16 files changed, 905 insertions, 132 deletions
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c index 37bd15398b..f48528639e 100644 --- a/firmware/target/arm/tcc77x/adc-tcc77x.c +++ b/firmware/target/arm/tcc77x/adc-tcc77x.c | |||
@@ -104,6 +104,9 @@ unsigned short adc_read(int channel) | |||
104 | 104 | ||
105 | void adc_init(void) | 105 | void adc_init(void) |
106 | { | 106 | { |
107 | /* Initialize ADC clocks */ | ||
108 | PCLKCFG6 = (PCLKCFG6 & 0xffff0000) | 4004; | ||
109 | |||
107 | ADCCON = (1<<4); /* Leave standby mode */ | 110 | ADCCON = (1<<4); /* Leave standby mode */ |
108 | 111 | ||
109 | /* IRQ enable, auto power-down, single-mode */ | 112 | /* IRQ enable, auto power-down, single-mode */ |
diff --git a/firmware/target/arm/tcc77x/app.lds b/firmware/target/arm/tcc77x/app.lds index 03a427f76b..c50367cb08 100644 --- a/firmware/target/arm/tcc77x/app.lds +++ b/firmware/target/arm/tcc77x/app.lds | |||
@@ -1,21 +1,25 @@ | |||
1 | #include "config.h" | 1 | #include "config.h" |
2 | 2 | ||
3 | ENTRY(start) | 3 | ENTRY(start) |
4 | |||
5 | OUTPUT_FORMAT(elf32-littlearm) | 4 | OUTPUT_FORMAT(elf32-littlearm) |
6 | OUTPUT_ARCH(arm) | 5 | OUTPUT_ARCH(arm) |
7 | STARTUP(target/arm/tcc77x/crt0.o) | 6 | STARTUP(target/arm/tcc77x/crt0.o) |
8 | 7 | ||
9 | #define PLUGINSIZE PLUGIN_BUFFER_SIZE | 8 | #define PLUGINSIZE PLUGIN_BUFFER_SIZE |
10 | #define CODECSIZE CODEC_SIZE | 9 | #define CODECSIZE CODEC_SIZE |
10 | |||
11 | #ifdef DEBUG | ||
12 | #define STUBOFFSET 0x10000 | ||
13 | #else | ||
14 | #define STUBOFFSET 0 | ||
15 | #endif | ||
11 | 16 | ||
12 | #include "imx31l.h" | 17 | #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE |
13 | |||
14 | #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE | ||
15 | 18 | ||
16 | #define DRAMORIG 0x20000000 | 19 | #define DRAMORIG 0x20000000 |
17 | #define IRAMORIG 0x00000000 | 20 | #define IRAMORIG 0x00000000 |
18 | #define IRAMSIZE IRAM_SIZE | 21 | #define IRAMSIZE 64K |
22 | |||
19 | 23 | ||
20 | /* End of the audio buffer, where the codec buffer starts */ | 24 | /* End of the audio buffer, where the codec buffer starts */ |
21 | #define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) | 25 | #define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) |
@@ -23,100 +27,58 @@ STARTUP(target/arm/tcc77x/crt0.o) | |||
23 | /* Where the codec buffer ends, and the plugin buffer starts */ | 27 | /* Where the codec buffer ends, and the plugin buffer starts */ |
24 | #define ENDADDR (ENDAUDIOADDR + CODECSIZE) | 28 | #define ENDADDR (ENDAUDIOADDR + CODECSIZE) |
25 | 29 | ||
30 | |||
26 | MEMORY | 31 | MEMORY |
27 | { | 32 | { |
28 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | 33 | #ifdef TCCBOOT |
29 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | 34 | DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 |
35 | #else | ||
36 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
37 | #endif | ||
38 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | ||
30 | } | 39 | } |
31 | 40 | ||
32 | SECTIONS | 41 | SECTIONS |
33 | { | 42 | { |
34 | .text : | 43 | .text : { |
35 | { | 44 | loadaddress = .; |
36 | loadaddress = .; | 45 | _loadaddress = .; |
37 | _loadaddress = .; | 46 | . = ALIGN(0x200); |
38 | . = ALIGN(0x200); | ||
39 | *(.init.text) | 47 | *(.init.text) |
48 | *(.text) | ||
40 | *(.text*) | 49 | *(.text*) |
41 | *(.glue_7) | 50 | *(.glue_7) |
42 | *(.glue_7t) | 51 | *(.glue_7t) |
43 | . = ALIGN(0x4); | 52 | } > DRAM |
44 | } > DRAM | ||
45 | |||
46 | .rodata : | ||
47 | { | ||
48 | *(.rodata) /* problems without this, dunno why */ | ||
49 | *(.rodata*) | ||
50 | *(.rodata.str1.1) | ||
51 | *(.rodata.str1.4) | ||
52 | . = ALIGN(0x4); | ||
53 | 53 | ||
54 | /* Pseudo-allocate the copies of the data sections */ | 54 | .data : { |
55 | _datacopy = .; | ||
56 | } > DRAM | ||
57 | |||
58 | /* TRICK ALERT! For RAM execution, we put the .data section at the | ||
59 | same load address as the copy. Thus, we don't waste extra RAM | ||
60 | when we don't actually need the copy. */ | ||
61 | .data : AT ( _datacopy ) | ||
62 | { | ||
63 | _datastart = .; | ||
64 | *(.data*) | ||
65 | . = ALIGN(0x4); | ||
66 | _dataend = .; | ||
67 | } > DRAM | ||
68 | |||
69 | /DISCARD/ : | ||
70 | { | ||
71 | *(.eh_frame) | ||
72 | } | ||
73 | |||
74 | .vectors 0x0 : | ||
75 | { | ||
76 | _vectorsstart = .; | ||
77 | *(.vectors); | ||
78 | _vectorsend = .; | ||
79 | } AT> DRAM | ||
80 | |||
81 | _vectorscopy = LOADADDR(.vectors); | ||
82 | |||
83 | .iram : | ||
84 | { | ||
85 | _iramstart = .; | ||
86 | *(.icode) | 55 | *(.icode) |
87 | *(.irodata) | 56 | *(.irodata) |
88 | *(.idata) | 57 | *(.idata) |
58 | *(.data*) | ||
59 | *(.rodata.*) | ||
60 | *(.rodata) | ||
89 | . = ALIGN(0x4); | 61 | . = ALIGN(0x4); |
90 | _iramend = .; | 62 | _dataend = . ; |
91 | } > DRAM | ||
92 | |||
93 | _iramcopy = LOADADDR(.iram); | ||
94 | |||
95 | .ibss (NOLOAD) : | ||
96 | { | ||
97 | _iedata = .; | ||
98 | *(.ibss) | ||
99 | . = ALIGN(0x4); | ||
100 | _iend = .; | ||
101 | } > DRAM | 63 | } > DRAM |
102 | 64 | ||
103 | .stack : | 65 | .stack : |
104 | { | 66 | { |
105 | *(.stack) | 67 | *(.stack) |
106 | stackbegin = .; | 68 | _stackbegin = .; |
107 | . += 0x2000; | 69 | stackbegin = .; |
108 | stackend = .; | 70 | . += 0x2000; |
109 | } > DRAM | 71 | _stackend = .; |
110 | 72 | stackend = .; | |
111 | .bss : | ||
112 | { | ||
113 | _edata = .; | ||
114 | *(.bss*) | ||
115 | *(COMMON) | ||
116 | . = ALIGN(0x4); | ||
117 | _end = .; | ||
118 | } > DRAM | 73 | } > DRAM |
119 | 74 | ||
75 | .bss : { | ||
76 | _edata = .; | ||
77 | *(.bss*); | ||
78 | *(.ibss); | ||
79 | *(COMMON) | ||
80 | _end = .; | ||
81 | } > DRAM | ||
120 | .audiobuf ALIGN(4) : | 82 | .audiobuf ALIGN(4) : |
121 | { | 83 | { |
122 | _audiobuffer = .; | 84 | _audiobuffer = .; |
@@ -128,7 +90,7 @@ SECTIONS | |||
128 | audiobufend = .; | 90 | audiobufend = .; |
129 | _audiobufend = .; | 91 | _audiobufend = .; |
130 | } > DRAM | 92 | } > DRAM |
131 | 93 | ||
132 | .codec ENDAUDIOADDR: | 94 | .codec ENDAUDIOADDR: |
133 | { | 95 | { |
134 | codecbuf = .; | 96 | codecbuf = .; |
@@ -139,6 +101,5 @@ SECTIONS | |||
139 | { | 101 | { |
140 | _pluginbuf = .; | 102 | _pluginbuf = .; |
141 | pluginbuf = .; | 103 | pluginbuf = .; |
142 | } | 104 | } |
143 | } | 105 | } |
144 | |||
diff --git a/firmware/target/arm/tcc77x/boot.lds b/firmware/target/arm/tcc77x/boot.lds index 890c4ec785..2fd6964d57 100644 --- a/firmware/target/arm/tcc77x/boot.lds +++ b/firmware/target/arm/tcc77x/boot.lds | |||
@@ -14,7 +14,11 @@ STARTUP(target/arm/tcc77x/crt0.o) | |||
14 | 14 | ||
15 | MEMORY | 15 | MEMORY |
16 | { | 16 | { |
17 | #ifdef TCCBOOT | ||
17 | DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 | 18 | DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 |
19 | #else | ||
20 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
21 | #endif | ||
18 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | 22 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE |
19 | } | 23 | } |
20 | 24 | ||
@@ -34,6 +38,7 @@ SECTIONS | |||
34 | *(.idata) | 38 | *(.idata) |
35 | *(.data*) | 39 | *(.data*) |
36 | *(.rodata.*) | 40 | *(.rodata.*) |
41 | *(.rodata) | ||
37 | . = ALIGN(0x4); | 42 | . = ALIGN(0x4); |
38 | _dataend = . ; | 43 | _dataend = . ; |
39 | } > DRAM | 44 | } > DRAM |
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S index e144c16fae..569930352a 100644 --- a/firmware/target/arm/tcc77x/crt0.S +++ b/firmware/target/arm/tcc77x/crt0.S | |||
@@ -82,12 +82,15 @@ start_loc: | |||
82 | 82 | ||
83 | #ifdef TCCBOOT | 83 | #ifdef TCCBOOT |
84 | mov r0, #0x80000000 | 84 | mov r0, #0x80000000 |
85 | #ifdef LOGIK_DAX | 85 | #if defined(LOGIK_DAX) |
86 | ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */ | 86 | ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */ |
87 | tst r0, #0x2 | 87 | tst r0, #0x2 |
88 | #elif defined(SANSA_M200) | 88 | #elif defined(SANSA_M200) |
89 | ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */ | 89 | ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */ |
90 | tst r0, #0x200 | 90 | tst r0, #0x200 |
91 | #elif defined(IAUDIO_7) | ||
92 | ldr r0, [r0, #0x300] /* Hold button is !GPIO A, pin 0x2 */ | ||
93 | tst r0, #0x2 | ||
91 | #else | 94 | #else |
92 | #error No bootup key detection implemented for this target | 95 | #error No bootup key detection implemented for this target |
93 | #endif | 96 | #endif |
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c index 4566c7ea73..203a6010ce 100644 --- a/firmware/target/arm/tcc77x/debug-tcc77x.c +++ b/firmware/target/arm/tcc77x/debug-tcc77x.c | |||
@@ -56,8 +56,11 @@ bool __dbg_hw_info(void) | |||
56 | button = button_get(false); | 56 | button = button_get(false); |
57 | 57 | ||
58 | button &= ~BUTTON_REPEAT; | 58 | button &= ~BUTTON_REPEAT; |
59 | 59 | #ifdef BUTTON_SELECT | |
60 | if (button == BUTTON_SELECT) | 60 | if (button == BUTTON_SELECT) |
61 | #else | ||
62 | if (button == BUTTON_STOP) | ||
63 | #endif | ||
61 | done=true; | 64 | done=true; |
62 | 65 | ||
63 | snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", | 66 | snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", |
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/pcm-tcc77x.c b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h index 184a264858..597583b16f 100644 --- a/firmware/target/arm/tcc77x/pcm-tcc77x.c +++ b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by [whoever fills in these functions] | 10 | * Copyright (C) 2008 Vitja Makarov |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -18,60 +18,29 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "system.h" | 21 | #ifndef BACKLIGHT_TARGET_H |
22 | #include "kernel.h" | 22 | #define BACKLIGHT_TARGET_H |
23 | #include "logf.h" | ||
24 | #include "audio.h" | ||
25 | #include "sound.h" | ||
26 | #include "file.h" | ||
27 | 23 | ||
28 | void pcm_postinit(void) | 24 | #include <stdbool.h> |
29 | { | 25 | #include "tcc77x.h" |
30 | } | ||
31 | |||
32 | const void * pcm_play_dma_get_peak_buffer(int *count) | ||
33 | { | ||
34 | (void)count; | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | void pcm_play_dma_init(void) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | void pcm_apply_settings(void) | ||
43 | { | ||
44 | } | ||
45 | 26 | ||
46 | void pcm_set_frequency(unsigned int frequency) | 27 | void power_touch_panel(bool on); |
47 | { | ||
48 | (void)frequency; | ||
49 | } | ||
50 | |||
51 | void pcm_play_dma_start(const void *addr, size_t size) | ||
52 | { | ||
53 | (void)addr; | ||
54 | (void)size; | ||
55 | } | ||
56 | |||
57 | void pcm_play_dma_stop(void) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | void pcm_play_lock(void) | ||
62 | { | ||
63 | } | ||
64 | 28 | ||
65 | void pcm_play_unlock(void) | 29 | static inline bool _backlight_init(void) |
66 | { | 30 | { |
31 | GPIOD_DIR |= 0x2; | ||
32 | return true; | ||
67 | } | 33 | } |
68 | 34 | ||
69 | void pcm_play_dma_pause(bool pause) | 35 | static inline void _backlight_on(void) |
70 | { | 36 | { |
71 | (void)pause; | 37 | GPIOD |= 0x2; |
38 | power_touch_panel(true); | ||
72 | } | 39 | } |
73 | 40 | ||
74 | size_t pcm_get_bytes_waiting(void) | 41 | static inline void _backlight_off(void) |
75 | { | 42 | { |
76 | return 0; | 43 | GPIOD &= ~0x2; |
44 | power_touch_panel(false); | ||
77 | } | 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 | } | ||
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c index c50a8a6651..2c8959fded 100644 --- a/firmware/target/arm/tcc77x/system-tcc77x.c +++ b/firmware/target/arm/tcc77x/system-tcc77x.c | |||
@@ -26,6 +26,7 @@ | |||
26 | /* Externally defined interrupt handlers */ | 26 | /* Externally defined interrupt handlers */ |
27 | extern void TIMER(void); | 27 | extern void TIMER(void); |
28 | extern void ADC(void); | 28 | extern void ADC(void); |
29 | extern void USBD_IRQ(void); | ||
29 | 30 | ||
30 | void irq(void) | 31 | void irq(void) |
31 | { | 32 | { |
@@ -36,14 +37,22 @@ void irq(void) | |||
36 | TIMER(); | 37 | TIMER(); |
37 | else if (irq & ADC_IRQ_MASK) | 38 | else if (irq & ADC_IRQ_MASK) |
38 | ADC(); | 39 | ADC(); |
40 | #ifdef HAVE_USBSTACK | ||
41 | else if (irq & USBD_IRQ_MASK) | ||
42 | USBD_IRQ(); | ||
43 | #endif | ||
39 | else | 44 | else |
40 | panicf("Unhandled IRQ 0x%08X", irq); | 45 | panicf("Unhandled IRQ 0x%08X", irq); |
41 | } | 46 | } |
42 | 47 | ||
48 | void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked)); | ||
49 | |||
50 | #ifdef BOOTLOADER | ||
43 | void fiq_handler(void) | 51 | void fiq_handler(void) |
44 | { | 52 | { |
45 | /* TODO */ | 53 | /* TODO */ |
46 | } | 54 | } |
55 | #endif | ||
47 | 56 | ||
48 | void system_reboot(void) | 57 | void system_reboot(void) |
49 | { | 58 | { |
@@ -94,7 +103,7 @@ static void gpio_init(void) | |||
94 | GPIOC = 0; | 103 | GPIOC = 0; |
95 | GPIOD = 0x180; | 104 | GPIOD = 0x180; |
96 | GPIOE = 0; | 105 | GPIOE = 0; |
97 | GPIOA_DIR = 0x84b0 | 106 | GPIOA_DIR = 0x84b0; |
98 | GPIOB_DIR = 0x80800; | 107 | GPIOB_DIR = 0x80800; |
99 | GPIOC_DIR = 0x2000000; | 108 | GPIOC_DIR = 0x2000000; |
100 | GPIOD_DIR = 0x3e3; | 109 | GPIOD_DIR = 0x3e3; |
diff --git a/firmware/target/arm/tcc77x/usb-tcc77x.c b/firmware/target/arm/tcc77x/usb-tcc77x.c index 85c8bed3ef..9cfcb503e0 100644 --- a/firmware/target/arm/tcc77x/usb-tcc77x.c +++ b/firmware/target/arm/tcc77x/usb-tcc77x.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by [whoever fills in these functions] | 10 | * Copyright (C) 2008 by Vitja Makarov |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -21,9 +21,15 @@ | |||
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "usb.h" | 23 | #include "usb.h" |
24 | #include "system.h" | ||
25 | #include "usb-tcc7xx.h" | ||
24 | 26 | ||
25 | void usb_init_device(void) | 27 | void usb_init_device(void) |
26 | { | 28 | { |
29 | /* simply switch USB off for now */ | ||
30 | BCLKCTR |= DEV_USBD; | ||
31 | TCC7xx_USB_PHY_CFG = 0x3e4c; | ||
32 | BCLKCTR &= ~DEV_USBD; | ||
27 | } | 33 | } |
28 | 34 | ||
29 | void usb_enable(bool on) | 35 | void usb_enable(bool on) |