summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/ata-nand-telechips.c9
-rw-r--r--firmware/target/arm/lcd-ssd1815.c75
-rw-r--r--firmware/target/arm/pcm-telechips.c18
-rw-r--r--firmware/target/arm/system-arm.h2
-rw-r--r--firmware/target/arm/tcc77x/adc-tcc77x.c121
-rw-r--r--firmware/target/arm/tcc77x/app.lds99
-rw-r--r--firmware/target/arm/tcc77x/ata-nand-target.h33
-rw-r--r--firmware/target/arm/tcc77x/boot.lds63
-rw-r--r--firmware/target/arm/tcc77x/c100/adc-target.h26
-rw-r--r--firmware/target/arm/tcc77x/c100/backlight-target.h40
-rw-r--r--firmware/target/arm/tcc77x/c100/button-c100.c64
-rw-r--r--firmware/target/arm/tcc77x/c100/button-target.h45
-rw-r--r--firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c286
-rw-r--r--firmware/target/arm/tcc77x/c100/power-c100.c43
-rw-r--r--firmware/target/arm/tcc77x/crt0.S230
-rw-r--r--firmware/target/arm/tcc77x/debug-tcc77x.c77
-rw-r--r--firmware/target/arm/tcc77x/i2c-target.h39
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/adc-target.h28
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c110
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.h27
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c94
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/backlight-target.h48
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c93
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-target.h47
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c260
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c149
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c84
-rw-r--r--firmware/target/arm/tcc77x/kernel-tcc77x.c47
-rw-r--r--firmware/target/arm/tcc77x/logikdax/adc-target.h28
-rw-r--r--firmware/target/arm/tcc77x/logikdax/audio-logikdax.c40
-rw-r--r--firmware/target/arm/tcc77x/logikdax/backlight-target.h40
-rw-r--r--firmware/target/arm/tcc77x/logikdax/button-logikdax.c100
-rw-r--r--firmware/target/arm/tcc77x/logikdax/button-target.h45
-rw-r--r--firmware/target/arm/tcc77x/logikdax/power-logikdax.c44
-rw-r--r--firmware/target/arm/tcc77x/m200/adc-target.h28
-rw-r--r--firmware/target/arm/tcc77x/m200/audio-m200.c38
-rw-r--r--firmware/target/arm/tcc77x/m200/backlight-target.h44
-rw-r--r--firmware/target/arm/tcc77x/m200/button-m200.c99
-rw-r--r--firmware/target/arm/tcc77x/m200/button-target.h45
-rw-r--r--firmware/target/arm/tcc77x/m200/power-m200.c43
-rw-r--r--firmware/target/arm/tcc77x/powermgmt-tcc77x.c66
-rw-r--r--firmware/target/arm/tcc77x/system-target.h59
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c326
-rw-r--r--firmware/target/arm/tcc77x/timer-tcc77x.c69
-rw-r--r--firmware/target/arm/wmcodec-telechips.c2
45 files changed, 3 insertions, 3370 deletions
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index 73d92a5215..55f6b1f3f7 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -48,7 +48,7 @@ static long next_yield = 0;
48 48
49static struct mutex ata_mtx SHAREDBSS_ATTR; 49static struct mutex ata_mtx SHAREDBSS_ATTR;
50 50
51#if defined(COWON_D2) || defined(IAUDIO_7) 51#if defined(COWON_D2)
52#define FTL_V2 52#define FTL_V2
53#define MAX_WRITE_CACHES 8 53#define MAX_WRITE_CACHES 8
54#else 54#else
@@ -906,13 +906,6 @@ int nand_init(void)
906 906
907 mutex_init(&ata_mtx); 907 mutex_init(&ata_mtx);
908 908
909#ifdef CPU_TCC77X
910 CSCFG2 = 0x018a8010 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW8);
911
912 GPIOC_FUNC &= ~(CS_GPIO_BIT | WE_GPIO_BIT);
913 GPIOC_FUNC |= 0x1;
914#endif
915
916 /* Set GPIO direction for chip select & write protect */ 909 /* Set GPIO direction for chip select & write protect */
917 NAND_GPIO_OUT_EN(CS_GPIO_BIT | WE_GPIO_BIT); 910 NAND_GPIO_OUT_EN(CS_GPIO_BIT | WE_GPIO_BIT);
918 911
diff --git a/firmware/target/arm/lcd-ssd1815.c b/firmware/target/arm/lcd-ssd1815.c
index 891d4ef64d..028362f91c 100644
--- a/firmware/target/arm/lcd-ssd1815.c
+++ b/firmware/target/arm/lcd-ssd1815.c
@@ -144,81 +144,6 @@ void lcd_init_device(void)
144 lcd_write_command(LCD_SET_NORMAL_DISPLAY); 144 lcd_write_command(LCD_SET_NORMAL_DISPLAY);
145} 145}
146 146
147
148#elif defined(CPU_TCC77X)
149
150/* TCC77x specific defines */
151#define LCD_BASE 0x50000000
152#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
153#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
154
155void lcd_write_command(int byte)
156{
157 LCD_CMD = byte;
158
159 asm volatile (
160 "nop \n\t"
161 "nop \n\t"
162 "nop \n\t"
163 );
164}
165
166void lcd_write_data(const fb_data* p_bytes, int count)
167{
168 while (count--)
169 {
170 LCD_DATA = *(p_bytes++);
171
172 asm volatile (
173 "nop \n\t"
174 "nop \n\t"
175 "nop \n\t"
176 );
177 }
178}
179
180/* LCD init */
181void lcd_init_device(void)
182{
183 uint32_t bus_width;
184
185 /* Telechips init the same as the original firmware */
186 CSCFG1 &= 0xc3ffc000;
187 CSCFG1 |= 0x3400101a;
188 CSCFG1 |= (1 << 21);
189 CSCFG1 &= ~(1 << 21);
190
191 bus_width = ((MCFG >> 11) & 0x3) ^ 3;
192
193 CSCFG1 = (bus_width << 28) |
194 (3 << 26) | /* MTYPE = 3 */
195 ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
196 (1 << 20) | /* Unknown */
197 (3 << 11) | /* Setup time = 3 cycles */
198 (3 << 3) | /* Pulse width = 3+1 cycles */
199 (1 << 0); /* Hold time = 1 cycle */
200
201 /* SSD1815 inits like the original firmware */
202 lcd_write_command(LCD_SET_DISPLAY_OFF);
203 lcd_set_flip(false);
204 lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5);
205 lcd_set_contrast(lcd_default_contrast());
206 lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7);
207 /* power control register: op-amp=1, regulator=1, booster=1 */
208 lcd_write_command(LCD_SET_BIAS_TC_OSC);
209
210 /* 0xc2 = 110 000 10: Osc. Freq 110 - ???
211 TC value 000 - "-0.01%/C (TC0, POR)"
212 Bias ratio 10 - "1/9, 1/7 (POR)"
213 */
214 lcd_write_command(0xc2);
215 lcd_write_command(LCD_SET_DISPLAY_ON);
216
217 lcd_clear_display();
218 lcd_update();
219}
220
221/* End of TCC77x specific defines */
222#endif 147#endif
223 148
224 149
diff --git a/firmware/target/arm/pcm-telechips.c b/firmware/target/arm/pcm-telechips.c
index 68bae1b0a9..ff550b14d6 100644
--- a/firmware/target/arm/pcm-telechips.c
+++ b/firmware/target/arm/pcm-telechips.c
@@ -82,19 +82,6 @@ void pcm_play_dma_init(void)
82 82
83 /* Enable DAI block in Master mode, 256fs->32fs, 16bit LSB */ 83 /* Enable DAI block in Master mode, 256fs->32fs, 16bit LSB */
84 DAMR = 0x3c8e80; 84 DAMR = 0x3c8e80;
85#elif defined(IAUDIO_7)
86 BCLKCTR &= ~DEV_DAI;
87 PCLK_DAI = (0x800a << 16) | (PCLK_DAI & 0xffff);
88 BCLKCTR |= DEV_DAI;
89
90 /* Master mode, 256->64fs, 16bit LSB*/
91 DAMR = 0x3cce20;
92#elif defined(LOGIK_DAX)
93 /* TODO */
94#elif defined(SANSA_M200)
95 /* TODO */
96#elif defined(SANSA_C100)
97 /* TODO */
98#else 85#else
99#error "Target isn't supported" 86#error "Target isn't supported"
100#endif 87#endif
@@ -228,7 +215,7 @@ const void * pcm_rec_dma_get_peak_buffer(void)
228} 215}
229#endif 216#endif
230 217
231#if defined(CPU_TCC77X) || defined(CPU_TCC780X) 218#if defined(CPU_TCC780X)
232void fiq_handler(void) ICODE_ATTR __attribute__((naked)); 219void fiq_handler(void) ICODE_ATTR __attribute__((naked));
233void fiq_handler(void) 220void fiq_handler(void)
234{ 221{
@@ -245,9 +232,6 @@ void fiq_handler(void)
245#if defined(CPU_TCC780X) 232#if defined(CPU_TCC780X)
246 "mov r8, #0xc000 \n" /* DAI_TX_IRQ_MASK | DAI_RX_IRQ_MASK */ 233 "mov r8, #0xc000 \n" /* DAI_TX_IRQ_MASK | DAI_RX_IRQ_MASK */
247 "ldr r9, =0xf3001004 \n" /* CREQ */ 234 "ldr r9, =0xf3001004 \n" /* CREQ */
248#elif defined(CPU_TCC77X)
249 "mov r8, #0x0030 \n" /* DAI_TX_IRQ_MASK | DAI_RX_IRQ_MASK */
250 "ldr r9, =0x80000104 \n" /* CREQ */
251#endif 235#endif
252 "str r8, [r9] \n" /* clear DAI IRQs */ 236 "str r8, [r9] \n" /* clear DAI IRQs */
253 "ldmia r11, { r8-r9 } \n" /* r8 = p, r9 = size */ 237 "ldmia r11, { r8-r9 } \n" /* r8 = p, r9 = size */
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h
index e5d3f35001..af16346b51 100644
--- a/firmware/target/arm/system-arm.h
+++ b/firmware/target/arm/system-arm.h
@@ -382,7 +382,7 @@ static inline uint32_t swaw32_hw(uint32_t value)
382 382
383} 383}
384 384
385#if defined(CPU_TCC780X) || defined(CPU_TCC77X) /* Single core only for now */ \ 385#if defined(CPU_TCC780X) /* Single core only for now */ \
386|| CONFIG_CPU == IMX31L || CONFIG_CPU == DM320 || CONFIG_CPU == AS3525 \ 386|| CONFIG_CPU == IMX31L || CONFIG_CPU == DM320 || CONFIG_CPU == AS3525 \
387|| CONFIG_CPU == S3C2440 || CONFIG_CPU == S5L8701 || CONFIG_CPU == AS3525v2 \ 387|| CONFIG_CPU == S3C2440 || CONFIG_CPU == S5L8701 || CONFIG_CPU == AS3525v2 \
388|| CONFIG_CPU == S5L8702 388|| CONFIG_CPU == S5L8702
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c
deleted file mode 100644
index f48528639e..0000000000
--- a/firmware/target/arm/tcc77x/adc-tcc77x.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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#include "config.h"
22#include "cpu.h"
23#include "system.h"
24#include "kernel.h"
25#include "thread.h"
26#include "string.h"
27#include "adc.h"
28
29/**************************************************************************
30 ** The A/D conversion is done every tick, in three steps:
31 **
32 ** 1) On the tick interrupt, the conversion of channels 0-3 is started, and
33 ** the A/D interrupt is enabled.
34 **
35 ** 2) After the conversion is done, an interrupt
36 ** is generated at level 1, which is the same level as the tick interrupt
37 ** itself. This interrupt will be pending until the tick interrupt is
38 ** finished.
39 ** When the A/D interrupt is finally served, it will read the results
40 ** from the first conversion and start the conversion of channels 4-7.
41 **
42 ** 3) When the conversion of channels 4-7 is finished, the interrupt is
43 ** triggered again, and the results are read. This time, no new
44 ** conversion is started, it will be done in the next tick interrupt.
45 **
46 ** Thus, each channel will be updated HZ times per second.
47 **
48 *************************************************************************/
49
50static int channel_group;
51static unsigned short adcdata[8];
52
53/* Tick task */
54static void adc_tick(void)
55{
56 /* Start a conversion of channels 0-3. This will trigger an interrupt,
57 and the interrupt handler will take care of channels 4-7. */
58
59 int i;
60
61 PCLKCFG6 |= (1<<15); /* Enable ADC clock */
62
63 channel_group = 0;
64
65 /* Start converting the first 4 channels */
66 for (i = 0; i < 4; i++)
67 ADCCON = i;
68
69}
70
71/* IRQ handler */
72void ADC(void)
73{
74 int num;
75 int i;
76 uint32_t adc_status;
77
78 do
79 {
80 adc_status = ADCSTATUS;
81 num = (adc_status>>24) & 7;
82 if (num) adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff;
83 } while (num);
84
85
86 if (channel_group == 0)
87 {
88 /* Start conversion of channels 4-7 */
89 for (i = 4; i < 8; i++)
90 ADCCON = i;
91
92 channel_group = 1;
93 }
94 else
95 {
96 PCLKCFG6 &= ~(1<<15); /* Disable ADC clock */
97 }
98}
99
100unsigned short adc_read(int channel)
101{
102 return adcdata[channel];
103}
104
105void adc_init(void)
106{
107 /* Initialize ADC clocks */
108 PCLKCFG6 = (PCLKCFG6 & 0xffff0000) | 4004;
109
110 ADCCON = (1<<4); /* Leave standby mode */
111
112 /* IRQ enable, auto power-down, single-mode */
113 ADCCFG |= (1<<3) | (1<<1) | (1<<0);
114
115 /* Unmask ADC IRQ */
116 IEN |= ADC_IRQ_MASK;
117
118 tick_add_task(adc_tick);
119
120 sleep(2); /* Ensure adc_data[] contains data before returning */
121}
diff --git a/firmware/target/arm/tcc77x/app.lds b/firmware/target/arm/tcc77x/app.lds
deleted file mode 100644
index 991b7156fe..0000000000
--- a/firmware/target/arm/tcc77x/app.lds
+++ /dev/null
@@ -1,99 +0,0 @@
1#include "config.h"
2
3ENTRY(start)
4OUTPUT_FORMAT(elf32-littlearm)
5OUTPUT_ARCH(arm)
6STARTUP(target/arm/tcc77x/crt0.o)
7
8#define PLUGINSIZE PLUGIN_BUFFER_SIZE
9#define CODECSIZE CODEC_SIZE
10
11#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
12
13#define DRAMORIG 0x20000000
14#define IRAMORIG 0x00000000
15#define IRAMSIZE 64K
16
17
18/* End of the audio buffer, where the codec buffer starts */
19#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
20
21/* Where the codec buffer ends, and the plugin buffer starts */
22#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
23
24
25MEMORY
26{
27#ifdef TCCBOOT
28 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
29#else
30 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
31#endif
32 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
33}
34
35SECTIONS
36{
37 .text : {
38 loadaddress = .;
39 _loadaddress = .;
40 . = ALIGN(0x200);
41 *(.init.text)
42 *(.text)
43 *(.text*)
44 *(.glue_7)
45 *(.glue_7t)
46 } > DRAM
47
48 .data : {
49 *(.icode)
50 *(.irodata)
51 *(.idata)
52 *(.data*)
53 *(.rodata.*)
54 *(.rodata)
55 . = ALIGN(0x4);
56 _dataend = . ;
57 } > DRAM
58
59 .stack :
60 {
61 *(.stack)
62 _stackbegin = .;
63 stackbegin = .;
64 . += 0x2000;
65 _stackend = .;
66 stackend = .;
67 } > DRAM
68
69 .bss : {
70 _edata = .;
71 *(.bss*);
72 *(.ibss);
73 *(COMMON)
74 _end = .;
75 } > DRAM
76 .audiobuf ALIGN(4) :
77 {
78 _audiobuffer = .;
79 audiobuffer = .;
80 } > DRAM
81
82 .audiobufend ENDAUDIOADDR:
83 {
84 audiobufend = .;
85 _audiobufend = .;
86 } > DRAM
87
88 .codec ENDAUDIOADDR:
89 {
90 codecbuf = .;
91 _codecbuf = .;
92 }
93
94 .plugin ENDADDR:
95 {
96 _pluginbuf = .;
97 pluginbuf = .;
98 }
99}
diff --git a/firmware/target/arm/tcc77x/ata-nand-target.h b/firmware/target/arm/tcc77x/ata-nand-target.h
deleted file mode 100644
index 93139a16d5..0000000000
--- a/firmware/target/arm/tcc77x/ata-nand-target.h
+++ /dev/null
@@ -1,33 +0,0 @@
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 ATA_TARGET_H
22#define ATA_TARGET_H
23
24/* GPIOs */
25
26#define NAND_GPIO_SET(n) GPIOC |= n
27#define NAND_GPIO_CLEAR(n) GPIOC &= (~n)
28#define NAND_GPIO_OUT_EN(n) GPIOC_DIR |= n
29
30#define CS_GPIO_BIT (1<<24) /* Chip Select */
31#define WE_GPIO_BIT (1<<25) /* Write Enable */
32
33#endif
diff --git a/firmware/target/arm/tcc77x/boot.lds b/firmware/target/arm/tcc77x/boot.lds
deleted file mode 100644
index 6303de0c34..0000000000
--- a/firmware/target/arm/tcc77x/boot.lds
+++ /dev/null
@@ -1,63 +0,0 @@
1#include "config.h"
2
3ENTRY(start)
4OUTPUT_FORMAT(elf32-littlearm)
5OUTPUT_ARCH(arm)
6STARTUP(target/arm/tcc77x/crt0.o)
7
8#define DRAMSIZE (MEMORYSIZE * 0x100000)
9
10#define DRAMORIG 0x20000000
11#define IRAMORIG 0x00000000
12#define IRAMSIZE 64K
13
14
15MEMORY
16{
17#ifdef TCCBOOT
18 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
19#else
20 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
21#endif
22 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
23}
24
25SECTIONS
26{
27 .text : {
28 *(.init.text)
29 *(.text)
30 *(.text*)
31 *(.glue_7)
32 *(.glue_7t)
33 } > DRAM
34
35 .data : {
36 *(.icode)
37 *(.irodata)
38 *(.idata)
39 *(.data*)
40 *(.rodata.*)
41 *(.rodata)
42 . = ALIGN(0x4);
43 _dataend = . ;
44 } > DRAM
45
46 .stack (NOLOAD) :
47 {
48 *(.stack)
49 _stackbegin = .;
50 stackbegin = .;
51 . += 0x2000;
52 _stackend = .;
53 stackend = .;
54 } > DRAM
55
56 .bss (NOLOAD) : {
57 _edata = .;
58 *(.bss*);
59 *(.ibss);
60 *(COMMON)
61 _end = .;
62 } > DRAM
63}
diff --git a/firmware/target/arm/tcc77x/c100/adc-target.h b/firmware/target/arm/tcc77x/c100/adc-target.h
deleted file mode 100644
index 0990d4d62d..0000000000
--- a/firmware/target/arm/tcc77x/c100/adc-target.h
+++ /dev/null
@@ -1,26 +0,0 @@
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#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/c100/backlight-target.h b/firmware/target/arm/tcc77x/c100/backlight-target.h
deleted file mode 100644
index 7ae71022f0..0000000000
--- a/firmware/target/arm/tcc77x/c100/backlight-target.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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 BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24#include "tcc77x.h"
25
26#define backlight_hw_init() true
27
28static inline void backlight_hw_on(void)
29{
30 /* Enable backlight */
31 GPIOE |= 0x2;
32}
33
34static inline void backlight_hw_off(void)
35{
36 /* Disable backlight */
37 GPIOE &= ~0x2;
38}
39
40#endif
diff --git a/firmware/target/arm/tcc77x/c100/button-c100.c b/firmware/target/arm/tcc77x/c100/button-c100.c
deleted file mode 100644
index 47b004eb61..0000000000
--- a/firmware/target/arm/tcc77x/c100/button-c100.c
+++ /dev/null
@@ -1,64 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#include "config.h"
23#include "cpu.h"
24#include "button.h"
25
26void button_init_device(void)
27{
28 GPIOA_DIR |= 0xC;
29}
30
31int button_read_device(void)
32{
33 int btn = BUTTON_NONE;
34
35 if (!button_hold())
36 {
37 GPIOA |= 0x4;
38 GPIOA &= ~0x8;
39
40 int i=20; while (i--);
41
42 if (GPIOA & 0x10) btn |= BUTTON_UP;
43 if (GPIOA & 0x20) btn |= BUTTON_RIGHT;
44 if (GPIOA & 0x40) btn |= BUTTON_LEFT;
45
46 GPIOA |= 0x8;
47 GPIOA &= ~0x4;
48
49 i=20; while (i--);
50
51 if (GPIOA & 0x10) btn |= BUTTON_VOLUP;
52 if (GPIOA & 0x20) btn |= BUTTON_VOLDOWN;
53 if (GPIOA & 0x40) btn |= BUTTON_DOWN;
54
55 if (GPIOA & 0x80) btn |= BUTTON_SELECT;
56 if (GPIOA & 0x100) btn |= BUTTON_POWER;
57 }
58 return btn;
59}
60
61bool button_hold(void)
62{
63 return (GPIOA & 0x2);
64}
diff --git a/firmware/target/arm/tcc77x/c100/button-target.h b/firmware/target/arm/tcc77x/c100/button-target.h
deleted file mode 100644
index 0e8b7e8f1c..0000000000
--- a/firmware/target/arm/tcc77x/c100/button-target.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25#define HAS_BUTTON_HOLD
26
27/* Main unit's buttons */
28#define BUTTON_POWER 0x00000001
29#define BUTTON_VOLUP 0x00000002
30#define BUTTON_VOLDOWN 0x00000004
31#define BUTTON_UP 0x00000008
32#define BUTTON_DOWN 0x00000010
33#define BUTTON_LEFT 0x00000020
34#define BUTTON_RIGHT 0x00000040
35#define BUTTON_SELECT 0x00000080
36
37#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN\
38 |BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT\
39 |BUTTON_RIGHT|BUTTON_SELECT)
40
41/* Software power-off */
42#define POWEROFF_BUTTON BUTTON_POWER
43#define POWEROFF_COUNT 40
44
45#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c b/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c
deleted file mode 100644
index c53aadaf30..0000000000
--- a/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c
+++ /dev/null
@@ -1,286 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Mark Arigo
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 "lcd.h"
24#include "kernel.h"
25#include "system.h"
26
27/* Display status */
28static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
29
30/* LCD command set for Samsung S6B33B2 */
31#define R_NOP 0x00
32#define R_OSCILLATION_MODE 0x02
33#define R_DRIVER_OUTPUT_MODE 0x10
34#define R_DCDC_SET 0x20
35#define R_BIAS_SET 0x22
36#define R_DCDC_CLOCK_DIV 0x24
37#define R_DCDC_AMP_ONOFF 0x26
38#define R_TEMP_COMPENSATION 0x28
39#define R_CONTRAST_CONTROL1 0x2a
40#define R_CONTRAST_CONTROL2 0x2b
41#define R_STANDBY_OFF 0x2c
42#define R_STANDBY_ON 0x2d
43#define R_DDRAM_BURST_OFF 0x2e
44#define R_DDRAM_BURST_ON 0x2f
45#define R_ADDRESSING_MODE 0x30
46#define R_ROW_VECTOR_MODE 0x32
47#define R_N_LINE_INVERSION 0x34
48#define R_FRAME_FREQ_CONTROL 0x36
49#define R_RED_PALETTE 0x38
50#define R_GREEN_PALETTE 0x3a
51#define R_BLUE_PALETTE 0x3c
52#define R_ENTRY_MODE 0x40
53#define R_X_ADDR_AREA 0x42
54#define R_Y_ADDR_AREA 0x43
55#define R_RAM_SKIP_AREA 0x45
56#define R_DISPLAY_OFF 0x50
57#define R_DISPLAY_ON 0x51
58#define R_SPEC_DISPLAY_PATTERN 0x53
59#define R_PARTIAL_DISPLAY_MODE 0x55
60#define R_PARTIAL_START_LINE 0x56
61#define R_PARTIAL_END_LINE 0x57
62#define R_AREA_SCROLL_MODE 0x59
63#define R_SCROLL_START_LINE 0x5a
64#define R_DATA_FORMAT_SELECT 0x60
65
66/* TCC77x specific defines */
67#define LCD_BASE 0x50000000
68#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
69#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
70
71static void lcd_send_command(unsigned cmd)
72{
73 LCD_CMD = cmd;
74
75 asm volatile (
76 "nop \n\t"
77 "nop \n\t"
78 "nop \n\t"
79 );
80}
81
82static void lcd_send_data(unsigned data)
83{
84 LCD_DATA = (data & 0xff00) >> 8;
85 LCD_DATA = (data & 0x00ff);
86}
87
88/* End of TCC77x specific defines */
89
90/* LCD init */
91void lcd_init_device(void)
92{
93 uint32_t bus_width;
94
95 /* Telechips init the same as the original firmware */
96 bus_width = ((MCFG >> 11) & 0x3) ^ 3;
97
98 CSCFG1 = (bus_width << 28) |
99 (3 << 26) | /* MTYPE = 3 */
100 ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
101 (1 << 20) | /* Unknown */
102 (2 << 11) | /* Setup time = 2 cycles */
103 (2 << 3) | /* Pulse width = 2+1 cycles */
104 (2 << 0); /* Hold time = 2 cycle */
105
106 GPIOE &= ~0x8;
107 sleep(HZ/100); /* 10ms */
108
109 GPIOE |= 0x08;
110 sleep(HZ/100); /* 10ms */
111
112 lcd_send_command(R_STANDBY_OFF);
113 sleep(HZ/20); /* 50ms */
114
115 lcd_send_command(R_OSCILLATION_MODE);
116 lcd_send_command(0x01);
117 sleep(HZ/100); /* 10ms */
118
119 lcd_send_command(R_DCDC_AMP_ONOFF);
120 lcd_send_command(0x01);
121 sleep(HZ/100); /* 10ms */
122
123 lcd_send_command(R_DCDC_AMP_ONOFF);
124 lcd_send_command(0x09);
125 sleep(HZ/100); /* 10ms */
126
127 lcd_send_command(R_DCDC_AMP_ONOFF);
128 lcd_send_command(0x0b);
129 sleep(HZ/100); /* 10ms */
130
131 lcd_send_command(R_DCDC_AMP_ONOFF);
132 lcd_send_command(0x0f);
133 sleep(HZ/100); /* 10ms */
134
135 lcd_send_command(R_DCDC_SET);
136 lcd_send_command(0x01);
137 sleep(HZ/100); /* 10ms */
138 sleep(HZ/10); /* 100ms */
139
140 lcd_send_command(R_TEMP_COMPENSATION);
141 lcd_send_command(0x01);
142 sleep(HZ/100); /* 10ms */
143
144 lcd_send_command(R_DRIVER_OUTPUT_MODE);
145 lcd_send_command(0x03);
146
147 lcd_send_command(R_ENTRY_MODE);
148 lcd_send_command(0x81);
149
150 lcd_send_command(R_N_LINE_INVERSION);
151 lcd_send_command(0x04);
152 lcd_send_command(0xfa);
153 lcd_send_command(0x5f);
154
155 lcd_set_contrast(0x28);
156
157 lcd_send_command(R_SPEC_DISPLAY_PATTERN);
158 lcd_send_command(0x0);
159 sleep(HZ/100); /* 10ms */
160
161 lcd_send_command(R_ADDRESSING_MODE);
162 lcd_send_command(0x0);
163 sleep(HZ/100); /* 10ms */
164
165 lcd_send_command(R_PARTIAL_DISPLAY_MODE);
166 lcd_send_command(0x0);
167 sleep(HZ/100); /* 10ms */
168
169 lcd_send_command(R_X_ADDR_AREA);
170 lcd_send_command(0);
171 lcd_send_command(0x80);
172
173 lcd_send_command(R_Y_ADDR_AREA);
174 lcd_send_command(0x0);
175 lcd_send_command(0x80);
176
177 lcd_send_command(R_DISPLAY_ON);
178
179 lcd_send_command(R_SPEC_DISPLAY_PATTERN);
180 lcd_send_command(0x0);
181
182 /* Rockbox init */
183 lcd_clear_display();
184 lcd_update();
185}
186
187/*** hardware configuration ***/
188int lcd_default_contrast(void)
189{
190 return 0x28;
191}
192
193void lcd_set_contrast(int val)
194{
195 //val &= 0xFF;
196 lcd_send_command(R_CONTRAST_CONTROL1);
197 lcd_send_command(val);
198}
199
200void lcd_set_invert_display(bool yesno)
201{
202 /* TODO: Implement lcd_set_invert_display() */
203 (void)yesno;
204}
205
206/* turn the display upside down (call lcd_update() afterwards) */
207void lcd_set_flip(bool yesno)
208{
209 lcd_send_command(R_DRIVER_OUTPUT_MODE);
210 lcd_send_command(yesno ? 0x02 : 0x07);
211}
212
213/*** update functions ***/
214void lcd_yuv_set_options(unsigned options)
215{
216 lcd_yuv_options = options;
217}
218
219/* TODO: implement me */
220void lcd_blit_yuv(unsigned char *const src[3],
221 int src_x, int src_y, int stride,
222 int x, int y, int width, int height)
223{
224 (void) src;
225 (void) src_x;
226 (void) src_y;
227 (void) stride;
228 (void) x;
229 (void) y;
230
231 return;
232
233}
234
235/* Update the display.
236 This must be called after all other LCD functions that change the display. */
237void lcd_update(void)
238{
239 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
240}
241
242/* Update a fraction of the display. */
243void lcd_update_rect(int x, int y, int width, int height)
244{
245 const fb_data *addr;
246
247 if (x + width >= LCD_WIDTH)
248 width = LCD_WIDTH - x;
249 if (y + height >= LCD_HEIGHT)
250 height = LCD_HEIGHT - y;
251
252 if ((width <= 0) || (height <= 0))
253 return; /* Nothing left to do. */
254
255 addr = FBADDR(x,y);
256
257 if (width <= 1) {
258 lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */
259 lcd_send_command(0x80); /* that the X start address, so we */
260 lcd_send_command(R_X_ADDR_AREA); /* switch to vertical mode for */
261 lcd_send_command(x); /* single column updates and set */
262 lcd_send_command(x + 1); /* the window width to 2 */
263 } else {
264 lcd_send_command(R_ENTRY_MODE);
265 lcd_send_command(0x82);
266 lcd_send_command(R_X_ADDR_AREA);
267 lcd_send_command(x);
268 lcd_send_command(x + width - 1);
269 }
270
271 lcd_send_command(R_Y_ADDR_AREA);
272 lcd_send_command(y);
273 lcd_send_command(y + height - 1);
274
275 /* NOP needed because on some c200s, the previous lcd_send_command is
276 interpreted as a separate command instead of part of R_Y_ADDR_AREA. */
277 lcd_send_command(R_NOP);
278
279 do {
280 int w = width;
281 do {
282 lcd_send_data(*addr++);
283 } while (--w > 0);
284 addr += LCD_WIDTH - width;
285 } while (--height > 0);
286}
diff --git a/firmware/target/arm/tcc77x/c100/power-c100.c b/firmware/target/arm/tcc77x/c100/power-c100.c
deleted file mode 100644
index e84ff1c852..0000000000
--- a/firmware/target/arm/tcc77x/c100/power-c100.c
+++ /dev/null
@@ -1,43 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34}
35
36bool ide_powered(void)
37{
38 return true;
39}
40
41void power_off(void)
42{
43}
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
deleted file mode 100644
index aebd8974da..0000000000
--- a/firmware/target/arm/tcc77x/crt0.S
+++ /dev/null
@@ -1,230 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 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/* Arm bootloader and startup code based on startup.s from the iPodLinux loader
23 *
24 * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
25 * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
26 *
27 */
28
29#include "config.h"
30#include "cpu.h"
31
32 .section .init.text,"ax",%progbits
33
34 .extern irq
35 .extern fiq
36 .extern UIE
37 .extern main
38
39 .global start
40
41/* Telechips firmware files start with a 32-byte header, as part of the code. */
42
43start:
44#ifdef TCCBOOT
45 /* Add -DTCCBOOT to EXTRA_DEFINES in the bootloader Makefile to
46 enable building the bootloader to be appended to the end of the
47 original firmware, dual-booting based on a key-press.
48
49 The following two values are filled in by mktccboot.
50 */
51of_entrypoint: .word 0 /* Saved entrypoint of original firmware*/
52bl_entrypoint: .word 0 /* Location in RAM of the start of our bootloader */
53
54#else
55// ldr pc, =start_loc /* jump to the main entry point */
56 b start_loc
57
58 .word 0xffff0601 /* Unknown magic */
59 .word 0x3a726556 /* "Ver:" */
60 .word 0x31373030 /* "0071" */
61 .word 0 /* First CRC32 */
62 .word 0 /* Unknown - always 0 */
63 .word 0 /* Second CRC32 */
64 .word 0 /* length of firmware file */
65
66#if defined(LOGIK_DAX) || defined(SANSA_C100)
67 /* Some original firmwares have 0x40 bytes of zeroes here - we
68 don't know why, but err on the side of caution and include it
69 here. */
70 .space 0x40
71#endif
72#endif
73
74start_loc:
75
76#ifdef BOOTLOADER
77
78/*
79 If we are appended to the OF (i.e. dual-booting), do a simple GPIO
80 button check, and branch to the OF's entry point (saved by mktccboot)
81 if not active
82*/
83
84#ifdef TCCBOOT
85 mov r0, #0x80000000
86#if defined(LOGIK_DAX) || defined(SANSA_C100)
87 ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
88 tst r0, #0x2
89#elif defined(SANSA_M200)
90 ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
91 tst r0, #0x200
92#elif defined(IAUDIO_7)
93 ldr r0, [r0, #0x300] /* Hold button is !GPIO A, pin 0x2 */
94 tst r0, #0x2
95#else
96 #error No bootup key detection implemented for this target
97#endif
98
99 ldrne pc, of_entrypoint /* Jump to OF if HOLD button not pressed */
100#endif /* TCCBOOT */
101
102/* We are now definitely executing the bootloader, so we relocate to the
103 linked address (see boot.lds) - 1MB from the end of DRAM.
104*/
105
106#ifdef TCCBOOT
107 ldr r0, bl_entrypoint
108#else
109 mov r0, #0x20000000 /* Otherwise, load address is the start of DRAM */
110#endif
111 mov r1, #0x20000000 /* Destination: 1MB from end of DRAM */
112 add r1, r1, #((MEMORYSIZE - 1) * 0x100000)
113
114 ldr r2, =_dataend
1151:
116 cmp r2, r1
117 ldrhi r3, [r0], #4
118 strhi r3, [r1], #4
119 bhi 1b
120
121 ldr pc, =copied_start /* jump to the relocated start_loc: */
122copied_start:
123#endif /* BOOTLOADER */
124
125 /* Set up stack for IRQ mode */
126 mov r0,#0xd2
127 msr cpsr, r0
128 ldr sp, =irq_stack
129
130 /* Set up stack for FIQ mode */
131 mov r0,#0xd1
132 msr cpsr, r0
133 ldr sp, =fiq_stack
134
135#ifndef BOOTLOADER
136 /* Load the banked FIQ mode registers with useful values here.
137 These values will be used in the FIQ handler in pcm-telechips.c */
138 .equ DADO_BASE, 0x80000020
139
140 ldr r10, =DADO_BASE
141 ldr r11, =dma_play_data
142#endif
143
144 /* Let svc, abort and undefined modes use irq stack */
145 msr cpsr, #0xd3
146 ldr sp, =irq_stack
147 msr cpsr, #0xd7
148 ldr sp, =irq_stack
149 msr cpsr, #0xdb
150 ldr sp, =irq_stack
151
152 /* Switch to sys mode */
153 mov r0,#0xdf
154 msr cpsr, r0
155 ldr sp, =stackend
156
157 /* Copy exception handler code to address 0 */
158 mov r2, #0x0
159 ldr r3, =vectors_start
160 ldr r4, =vectors_end
1611:
162 cmp r4, r3
163 ldrhi r5, [r3], #4
164 strhi r5, [r2], #4
165 bhi 1b
166
167 /* Initialise bss section to zero */
168 ldr r2, =_edata
169 ldr r3, =_end
170 mov r4, #0
1711:
172 cmp r3, r2
173 strhi r4, [r2], #4
174 bhi 1b
175
176 /* Set up some stack and munge it with 0xdeadbeef */
177 ldr sp, =stackend
178 mov r3, sp
179 ldr r2, =stackbegin
180 ldr r4, =0xdeadbeef
1811:
182 cmp r3, r2
183 strhi r4, [r2], #4
184 bhi 1b
185
186 bl main
187 /* main() should never return */
188
189/* Exception handlers. Will be copied to address 0 after memory remapping */
190vectors_start:
191 ldr pc, [pc, #24]
192 ldr pc, [pc, #24]
193 ldr pc, [pc, #24]
194 ldr pc, [pc, #24]
195 ldr pc, [pc, #24]
196 ldr pc, [pc, #24]
197 ldr pc, [pc, #24]
198 ldr pc, [pc, #24]
199
200 /* Exception vectors */
201 .global vectors
202vectors:
203 .word start
204 .word undef_instr_handler
205 .word software_int_handler
206 .word prefetch_abort_handler
207 .word data_abort_handler
208 .word reserved_handler
209 .word irq_handler
210 .word fiq_handler
211vectors_end:
212
213 .text
214
215irq_handler:
216 stmfd sp!, {r0-r3, r12, lr}
217 bl irq
218 ldmfd sp!, {r0-r3, r12, lr}
219 subs pc, lr, #4
220
221/* Align stacks to cache line boundary */
222 .balign 16
223
224/* 256 words of IRQ stack */
225 .space 256*4
226irq_stack:
227
228/* 256 words of FIQ stack */
229 .space 256*4
230fiq_stack:
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c
deleted file mode 100644
index 5a97706722..0000000000
--- a/firmware/target/arm/tcc77x/debug-tcc77x.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Rob Purchase
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 "system.h"
25#include "string.h"
26#include <stdio.h>
27#include <stdbool.h>
28#include "button.h"
29#include "lcd.h"
30#include "font.h"
31#include "adc.h"
32
33bool dbg_ports(void)
34{
35 return false;
36}
37
38bool dbg_hw_info(void)
39{
40 int line = 0, i, button, oldline;
41 bool done=false;
42
43 lcd_setfont(FONT_SYSFIXED);
44 lcd_clear_display();
45
46 /* Put all the static text before the while loop */
47 lcd_puts(0, line++, "[Hardware info]");
48
49 line++;
50 oldline=line;
51 while(!done)
52 {
53 line = oldline;
54 button = button_get(false);
55
56 button &= ~BUTTON_REPEAT;
57#ifdef BUTTON_SELECT
58 if (button == BUTTON_SELECT)
59#else
60 if (button == BUTTON_STOP)
61#endif
62 done=true;
63
64 lcd_putsf(0, line++, "current tick: %08lx Seconds running: %08ld",
65 current_tick, current_tick/HZ);
66
67 lcd_putsf(0, line++, "GPIOA: 0x%08lx GPIOB: 0x%08lx", GPIOA, GPIOB);
68 lcd_putsf(0, line++, "GPIOC: 0x%08lx GPIOD: 0x%08lx", GPIOC, GPIOD);
69 lcd_putsf(0, line++, "GPIOE: 0x%08lx", GPIOE);
70
71 for (i = 0; i<4; i++)
72 lcd_putsf(0, line++, "ADC%d: 0x%04x", i, adc_read(i));
73
74 lcd_update();
75 }
76 return false;
77}
diff --git a/firmware/target/arm/tcc77x/i2c-target.h b/firmware/target/arm/tcc77x/i2c-target.h
deleted file mode 100644
index 9b9a74b4d2..0000000000
--- a/firmware/target/arm/tcc77x/i2c-target.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Rob Purchase
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 I2C_TARGET_H
22#define I2C_TARGET_H
23
24/* Definitions for the TCC77X I2C bus */
25
26#define SDA_BIT (1<<10)
27#define SCL_BIT (1<<11)
28
29#define SCL (GPIOB & SCL_BIT)
30#define SCL_HI GPIOB |= SCL_BIT
31#define SCL_LO GPIOB &= ~SCL_BIT
32
33#define SDA (GPIOB & SDA_BIT)
34#define SDA_HI GPIOB |= SDA_BIT
35#define SDA_LO GPIOB &= ~SDA_BIT
36#define SDA_INPUT GPIOB_DIR &= ~SDA_BIT
37#define SDA_OUTPUT GPIOB_DIR |= SDA_BIT
38
39#endif /* I2C_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
deleted file mode 100644
index 1916d93598..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/adc-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
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
deleted file mode 100644
index f7526b2b9a..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.c
+++ /dev/null
@@ -1,110 +0,0 @@
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 "system.h"
24#include "cpu.h"
25#include "button.h"
26
27#include "ata2501.h"
28
29#define STB (1<<5)
30#define SDATA (1<<4)
31#define RESET (1<<6)
32#define SIFMD (1<<7)
33#define STB_DELAY 200
34
35static inline void ndelay(unsigned long nsecs)
36{
37 nsecs /= 8;
38 while (nsecs)
39 nsecs--;
40}
41
42/*
43 TODO: sensitivity
44*/
45void ata2501_init(void)
46{
47 GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
48 GPIOD_DIR &= ~SDATA;
49
50 GPIOD &= ~STB;
51 GPIOD |= (1 << 8) | SIFMD | (1 << 9);
52
53 GPIOD &= ~RESET;
54 ndelay(1000);
55 GPIOD |= RESET;
56}
57
58unsigned short ata2501_read(void)
59{
60 unsigned short ret = 0;
61 int i;
62
63 for (i = 0; i < 12; i++) {
64 GPIOD |= STB;
65 ndelay(100);
66 ret <<= 1;
67 if (GPIOD & SDATA)
68 ret |= 1;
69 GPIOD &= ~STB;
70 ndelay(100);
71 }
72
73 return ret;
74}
75
76//#define ATA2501_TEST
77#ifdef ATA2501_TEST
78#include "lcd.h"
79
80static
81void bits(char *str, unsigned short val)
82{
83 int i;
84
85 for (i = 0; i < 12; i++)
86 str[i] = (val & (1 << i)) ? '1' : '0';
87 str[i] = 0;
88}
89
90void ata2501_test(void)
91{
92 char buf[100];
93 ata2501_init();
94
95 while (1) {
96 unsigned short data;
97 int line = 0;
98
99 data = ata2501_read();
100 lcd_clear_display();
101 lcd_puts(0, line++, "ATA2501 test");
102
103 bits(buf, data);
104 lcd_puts(0, line++, buf);
105
106 lcd_update();
107 sleep(HZ/10);
108 }
109}
110#endif
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
deleted file mode 100644
index 465d0b199c..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.h
+++ /dev/null
@@ -1,27 +0,0 @@
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
24void ata2501_init(void);
25unsigned 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
deleted file mode 100644
index bcb6843286..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
+++ /dev/null
@@ -1,94 +0,0 @@
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
26int audio_channels = 2;
27int audio_output_source = AUDIO_SRC_PLAYBACK;
28
29void audio_set_output_source(int source)
30{
31 int oldmode = set_fiq_status(FIQ_DISABLED);
32
33 if ((unsigned)source >= AUDIO_NUM_SOURCES)
34 source = AUDIO_SRC_PLAYBACK;
35
36 audio_output_source = source;
37 set_fiq_status(oldmode);
38}
39
40void audio_input_mux(int source, unsigned flags)
41{
42 static int last_source = AUDIO_SRC_PLAYBACK;
43 static bool last_recording = false;
44 bool recording = flags & SRCF_RECORDING;
45
46 switch (source)
47 {
48 default: /* playback - no recording */
49 source = AUDIO_SRC_PLAYBACK;
50 case AUDIO_SRC_PLAYBACK:
51 audio_channels = 2;
52 if (source != last_source)
53 {
54 audiohw_set_monitor(false);
55 /* audiohw_disable_recording();*/
56 }
57 break;
58
59 case AUDIO_SRC_MIC: /* recording only */
60 GPIOD |= 0x1;
61
62 audio_channels = 1;
63 if (source != last_source)
64 {
65 /*audiohw_set_monitor(false);
66 audiohw_enable_recording(true); /. source mic */
67 }
68 break;
69
70 case AUDIO_SRC_FMRADIO: /* recording and playback */
71 GPIOD &= ~0x1;
72
73 audio_channels = 2;
74
75 if (source == last_source && recording == last_recording)
76 break;
77
78 last_recording = recording;
79
80 if (recording)
81 {
82 /*audiohw_set_monitor(false);
83 audiohw_enable_recording(false);*/
84 }
85 else
86 {
87 /*audiohw_disable_recording(); */
88 audiohw_set_monitor(true); /* line 1 analog audio path */
89 }
90 break;
91 } /* end switch */
92
93 last_source = source;
94} /* audio_input_mux */
diff --git a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
deleted file mode 100644
index 0b227cd11c..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
+++ /dev/null
@@ -1,48 +0,0 @@
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
27void power_touch_panel(bool on);
28
29static inline bool backlight_hw_init(void)
30{
31 GPIOD_DIR |= 0x2;
32 /* set backlight on by default, since the screen is unreadable without it */
33 GPIOD |= 0x2;
34 return true;
35}
36
37static inline void backlight_hw_on(void)
38{
39 GPIOD |= 0x2;
40 power_touch_panel(true);
41}
42
43static inline void backlight_hw_off(void)
44{
45 GPIOD &= ~0x2;
46 power_touch_panel(false);
47}
48#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
deleted file mode 100644
index abf31b4feb..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
+++ /dev/null
@@ -1,93 +0,0 @@
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 "backlight.h"
25#include "adc.h"
26
27#include "button-target.h"
28#include "ata2501.h"
29
30void button_init_device(void)
31{
32 ata2501_init();
33}
34
35/*
36 touchpad:
37 0: stop
38 1-8: between next & prev
39 9: play
40 10: next
41 11: prev
42*/
43
44int button_read_device(void)
45{
46 static bool hold_button = false;
47 bool hold_button_old;
48
49 int btn = BUTTON_NONE;
50 int adc;
51 int sensor;
52
53 hold_button_old = hold_button;
54 hold_button = button_hold();
55
56#ifndef BOOTLOADER
57 if (hold_button != hold_button_old)
58 backlight_hold_changed(hold_button);
59#endif
60
61 if (button_hold())
62 return BUTTON_NONE;
63
64 adc = adc_read(0);
65 sensor = ata2501_read();
66
67 if (0 == (GPIOA & 4))
68 btn |= BUTTON_POWER;
69
70 /* seems they can't be hold together */
71 if (adc < 0x120)
72 btn |= BUTTON_VOLUP;
73 else if (adc < 0x270)
74 btn |= BUTTON_VOLDOWN;
75 else if (adc < 0x300)
76 btn |= BUTTON_MENU;
77
78 if (sensor & (1 << 0))
79 btn |= BUTTON_STOP;
80 if (sensor & (1 << 9))
81 btn |= BUTTON_PLAY;
82 if (sensor & ((1 << 10) | 0x1c0))
83 btn |= BUTTON_RIGHT;
84 if (sensor & ((1 << 11) | 0xe))
85 btn |= BUTTON_LEFT;
86
87 return btn;
88}
89
90bool button_hold(void)
91{
92 return !(GPIOA & 0x2);
93}
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h
deleted file mode 100644
index 9d232d9ae8..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/button-target.h
+++ /dev/null
@@ -1,47 +0,0 @@
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#define HAS_BUTTON_HOLD
25
26/* Main unit's buttons */
27#define BUTTON_POWER 0x00000001
28#define BUTTON_VOLUP 0x00000002
29#define BUTTON_VOLDOWN 0x00000004
30#define BUTTON_MENU 0x00000008
31
32#define BUTTON_LEFT 0x00000010
33#define BUTTON_RIGHT 0x00000020
34#define BUTTON_PLAY 0x00000040
35#define BUTTON_STOP 0x00000080
36
37#define BUTTON_ON BUTTON_POWER
38
39#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \
40 BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \
41 BUTTON_PLAY|BUTTON_STOP)
42
43/* Software power-off */
44#define POWEROFF_BUTTON BUTTON_POWER
45#define POWEROFF_COUNT 10
46
47#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
deleted file mode 100644
index e681e1eff7..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
+++ /dev/null
@@ -1,260 +0,0 @@
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#include <panic.h>
35
36#include "hd66789r.h"
37
38static bool display_on = false; /* is the display turned on? */
39
40static inline void lcd_write_reg(int reg, int data)
41{
42 GPIOA &= ~0x400;
43 outw(0, 0x50010000);
44 outw(reg << 1, 0x50010000);
45 GPIOA |= 0x400;
46
47 outw((data & 0xff00) >> 7, 0x50010008);
48 outw((data << 24) >> 23, 0x50010008);
49}
50
51static void lcd_write_cmd(int reg)
52{
53 GPIOA &= ~0x400;
54 outw(0, 0x50010000);
55 outw(reg << 1, 0x50010000);
56 GPIOA |= 0x400;
57}
58
59/* Do what OF do */
60static void lcd_delay(int x)
61{
62 int i;
63
64 x *= 0xc35;
65 for (i = 0; i < x * 8; i++) {
66 }
67}
68
69
70static void _display_on(void)
71{
72 GPIOA_DIR |= 0x8000 | 0x400;
73 GPIOA |= 0x8000;
74
75 /* power setup */
76 lcd_write_reg(R_START_OSC, 0x0001);
77 lcd_delay(0xf);
78 lcd_write_reg(R_DISP_CONTROL1, 0x000);
79 lcd_delay(0xa);
80 lcd_write_reg(R_POWER_CONTROL2, 0x0002);
81 lcd_write_reg(R_POWER_CONTROL3, 0x000a);
82 lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
83 lcd_write_reg(R_POWER_CONTROL1, 0x0004);
84 lcd_write_reg(R_POWER_CONTROL1, 0x0134);
85 lcd_write_reg(R_POWER_CONTROL2, 0x0111);
86 lcd_write_reg(R_POWER_CONTROL3, 0x001c);
87 lcd_delay(0x28);
88 lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
89 lcd_write_reg(R_POWER_CONTROL1, 0x0510);
90 lcd_delay(0x3c);
91
92 /* lcd init 2 */
93 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
94 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
95 lcd_write_reg(R_ENTRY_MODE, 0x1038);
96 lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
97 lcd_write_reg(R_DISP_CONTROL3, 0x0000);
98 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
99 lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
100 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
101 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
102 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
103 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
104 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
105 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
106 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
107 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
108 lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
109 lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
110 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
111 lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
112 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
113 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
114 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
115
116 /* lcd init 3 */
117 lcd_write_reg(R_POWER_CONTROL1, 0x4510);
118 lcd_write_reg(R_DISP_CONTROL1, 0x0005);
119 lcd_delay(0x28);
120 lcd_write_reg(R_DISP_CONTROL1, 0x0025);
121 lcd_write_reg(R_DISP_CONTROL1, 0x0027);
122 lcd_delay(0x28);
123 lcd_write_reg(R_DISP_CONTROL1, 0x0037);
124
125 display_on = true;
126}
127
128void lcd_init_device(void)
129{
130 /* Configure external memory banks */
131 CSCFG1 = 0x0d500023 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW16);
132
133 /* may be reset */
134 GPIOA |= 0x8000;
135
136 _display_on();
137}
138
139void lcd_enable(bool on)
140{
141 if (display_on == on)
142 return;
143
144 if (on) {
145 _display_on();
146 send_event(LCD_EVENT_ACTIVATION, NULL);
147 } else {
148 /** Off sequence according to datasheet, p. 130 **/
149 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
150 lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
151 sleep(2);
152
153 lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
154 sleep(2);
155
156 lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
157
158 lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
159 lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
160 lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
161
162 /* datasheet p. 131 */
163 lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
164
165 display_on = false;
166 }
167}
168
169bool lcd_active(void)
170{
171 return display_on;
172}
173
174
175#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
176
177
178void lcd_update(void)
179{
180 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
181}
182
183/* todo: need tests */
184void lcd_update_rect(int sx, int sy, int width, int height)
185{
186 int x, y;
187
188 if (!display_on)
189 return;
190
191 if (width <= 0 || height <= 0) /* nothing to do */
192 return;
193
194 width += sx;
195 height += sy;
196
197 if (width > LCD_WIDTH)
198 width = LCD_WIDTH;
199 if (height > LCD_HEIGHT)
200 height = LCD_HEIGHT;
201
202 lcd_write_reg(R_ENTRY_MODE, 0x1028);
203 /* set update window */
204 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
205 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
206 lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
207 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
208
209 for (y = sy; y < height; y++) {
210 for (x = sx; x < width; x++) {
211 fb_data c;
212 unsigned long color;
213
214 c = *FBADDR(x,y);
215 color =
216 ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
217 2);
218
219 /* TODO: our color is 18-bit */
220 outw((color >> 9) & 0x1ff, 0x50010008);
221 outw((color) & 0x1ff, 0x50010008);
222 }
223 }
224}
225
226void lcd_set_contrast(int val)
227{
228 (void) val;
229}
230
231void lcd_set_invert_display(bool yesno)
232{
233 (void) yesno;
234}
235
236void lcd_set_flip(bool yesno)
237{
238 (void) yesno;
239}
240
241/* TODO: implement me */
242void lcd_blit_yuv(unsigned char *const src[3],
243 int src_x, int src_y, int stride,
244 int x, int y, int width, int height)
245{
246 (void) src;
247 (void) src_x;
248 (void) src_y;
249 (void) stride;
250 (void) x;
251 (void) y;
252
253 if (!display_on)
254 return;
255
256 width &= ~1; /* stay on the safe side */
257 height &= ~1;
258
259 panicf("%s", __func__);
260}
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
deleted file mode 100644
index baf93b73aa..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
+++ /dev/null
@@ -1,149 +0,0 @@
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#include "backlight-target.h"
29
30#include "pcf50606.h"
31
32void power_init(void)
33{
34 pcf50606_write(PCF5060X_DCDC1, 0x90);
35 pcf50606_write(PCF5060X_DCDC2, 0x48);
36 pcf50606_write(PCF5060X_DCDC3, 0xfc);
37 pcf50606_write(PCF5060X_DCDC4, 0xb1);
38
39 pcf50606_write(PCF5060X_IOREGC, 0xe9);
40 /* 3.3V, touch-panel */
41 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
42 pcf50606_write(PCF5060X_D2REGC1, 0xf2);
43 pcf50606_write(PCF5060X_D3REGC1, 0xf5);
44
45 pcf50606_write(PCF5060X_LPREGC1, 0x00);
46 pcf50606_write(PCF5060X_LPREGC2, 0x02);
47
48 pcf50606_write(PCF5060X_DCUDC1, 0xe6);
49 pcf50606_write(PCF5060X_DCUDC2, 0x30);
50
51 pcf50606_write(PCF5060X_DCDEC1, 0xe7);
52 pcf50606_write(PCF5060X_DCDEC2, 0x02);
53
54 pcf50606_write(PCF5060X_INT1M, 0x5b);
55 pcf50606_write(PCF5060X_INT1M, 0xaf);
56 pcf50606_write(PCF5060X_INT1M, 0x8f);
57
58 pcf50606_write(PCF5060X_OOCC1, 0x40);
59 pcf50606_write(PCF5060X_OOCC2, 0x05);
60
61 pcf50606_write(PCF5060X_MBCC3, 0x3a);
62 pcf50606_write(PCF5060X_GPOC1, 0x00);
63 pcf50606_write(PCF5060X_BBCC, 0xf8);
64}
65
66/* Control leds on ata2501 board */
67void power_touch_panel(bool on)
68{
69 if (on)
70 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
71 else
72 pcf50606_write(PCF5060X_D1REGC1, 0x00);
73}
74
75void ide_power_enable(bool on)
76{
77 (void) on;
78}
79
80bool ide_powered(void)
81{
82 return true;
83}
84
85void power_off(void)
86{
87 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
88 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
89}
90
91#if CONFIG_TUNER
92#include "tuner.h"
93
94/** Tuner **/
95static bool powered = false;
96
97#define TUNNER_CLK (1 << 5)
98#define TUNNER_DATA (1 << 6)
99#define TUNNER_NR_W (1 << 7)
100
101bool tuner_power(bool status)
102{
103 bool old_status;
104 lv24020lp_lock();
105
106 old_status = powered;
107
108 if (status != old_status)
109 {
110 if (status)
111 {
112 /* When power up, host should initialize the 3-wire bus
113 in host read mode: */
114
115 /* 1. Set direction of the DATA-line to input-mode. */
116 GPIOA_DIR &= ~TUNNER_DATA;
117
118 /* 2. Drive NR_W low */
119 GPIOA &= ~TUNNER_NR_W;
120 GPIOA_DIR |= TUNNER_NR_W;
121
122 /* 3. Drive CLOCK high */
123 GPIOA |= TUNNER_CLK;
124 GPIOA_DIR |= TUNNER_CLK;
125
126 lv24020lp_power(true);
127 }
128 else
129 {
130 lv24020lp_power(false);
131
132 /* set all as inputs */
133 GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
134 }
135
136 powered = status;
137 }
138
139 lv24020lp_unlock();
140 return old_status;
141}
142
143#endif /* CONFIG_TUNER */
144
145unsigned int power_input_status(void)
146{
147 return (GPIOA & 0x1) ?
148 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
149}
diff --git a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
deleted file mode 100644
index bc7ead61f0..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: powermgmt-cowond2.c 17847 2008-06-28 18:10:04Z bagder $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "adc.h"
24#include "powermgmt.h"
25#include "kernel.h"
26#include "pcf50606.h"
27
28unsigned short current_voltage = 5150;
29
30const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
31{
32 /* FIXME: calibrate value */
33 4400
34};
35
36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
37{
38 /* FIXME: calibrate value */
39 4600
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
43const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
44{
45 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
46 { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
47};
48
49#if CONFIG_CHARGING
50/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
51const unsigned short percent_to_volt_charge[11] =
52{
53 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
54 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
55};
56#endif /* CONFIG_CHARGING */
57
58#define BATTERY_SCALE_FACTOR 6000
59/* full-scale ADC readout (2^10) in millivolt */
60
61/* Returns battery voltage from ADC [millivolts] */
62int _battery_voltage(void)
63{
64 static unsigned last_tick = 0;
65
66 if (0 == last_tick || TIME_BEFORE(last_tick+HZ, current_tick))
67 {
68 int adc_val, irq_status;
69 unsigned char buf[2];
70
71 irq_status = disable_irq_save();
72 pcf50606_write(PCF5060X_ADCC2, 0x1);
73 pcf50606_read_multiple(PCF5060X_ADCS1, buf, 2);
74 restore_interrupt(irq_status);
75
76 adc_val = (buf[0]<<2) | (buf[1] & 3); //ADCDAT1H+ADCDAT1L
77 current_voltage = (adc_val * BATTERY_SCALE_FACTOR) >> 10;
78
79 last_tick = current_tick;
80 }
81
82 return current_voltage;
83}
84
diff --git a/firmware/target/arm/tcc77x/kernel-tcc77x.c b/firmware/target/arm/tcc77x/kernel-tcc77x.c
deleted file mode 100644
index bbfc29d915..0000000000
--- a/firmware/target/arm/tcc77x/kernel-tcc77x.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Rob Purchase
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 "system.h"
24#include "kernel.h"
25#include "timer.h"
26#include "thread.h"
27
28void tick_start(unsigned int interval_in_ms)
29{
30 /* configure Timer T-Clock to 2Mhz (clock source 4 (Xin) divided by 6) */
31 PCLKCFG4 = (1 << 31) | (4 << 28) | (5 << 16);
32
33 /* disable Timer0 */
34 TCFG0 &= ~1;
35
36 /* set counter reference value based on 1Mhz tick */
37 TREF0 = interval_in_ms * 1000;
38
39 /* Timer0 = reset to 0, divide=2, IRQ enable, enable (continuous) */
40 TCFG0 = (1<<8) | (0<<4) | (1<<3) | 1;
41
42 /* Unmask timer IRQ */
43 IEN |= TIMER0_IRQ_MASK;
44}
45
46/* NB: Since we are using a single timer IRQ, tick tasks are dispatched as
47 part of the central timer IRQ processing in timer-tcc77x.c */
diff --git a/firmware/target/arm/tcc77x/logikdax/adc-target.h b/firmware/target/arm/tcc77x/logikdax/adc-target.h
deleted file mode 100644
index 1916d93598..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/adc-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
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/logikdax/audio-logikdax.c b/firmware/target/arm/tcc77x/logikdax/audio-logikdax.c
deleted file mode 100644
index 90c9a68827..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/audio-logikdax.c
+++ /dev/null
@@ -1,40 +0,0 @@
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
26int audio_channels = 2;
27int audio_output_source = AUDIO_SRC_PLAYBACK;
28
29#if INPUT_SRC_CAPS != 0
30void audio_set_output_source(int source)
31{
32 (void)source;
33}
34
35void audio_input_mux(int source, unsigned flags)
36{
37 (void)source;
38 (void)flags;
39}
40#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
deleted file mode 100644
index 202e118606..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/backlight-target.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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 BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24#include "tcc77x.h"
25
26#define backlight_hw_init() true
27
28static inline void backlight_hw_on(void)
29{
30 /* Enable backlight */
31 GPIOD |= 0x10;
32}
33
34static inline void backlight_hw_off(void)
35{
36 /* Disable backlight */
37 GPIOD &= ~0x10;
38}
39
40#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/button-logikdax.c b/firmware/target/arm/tcc77x/logikdax/button-logikdax.c
deleted file mode 100644
index abf939753a..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/button-logikdax.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#include "config.h"
23#include "cpu.h"
24#include "button.h"
25#include "adc.h"
26
27/*
28
29Results of button testing:
30
31HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
32POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
33
34ADC[0]: (approx values)
35
36RIGHT - 0x37
37LEFT - 0x7f
38JOYSTICK PRESS - 0xc7
39UP - 0x11e
40DOWN - 0x184
41MODE - 0x1f0/0x1ff
42PRESET - 0x268/0x269
43REC - 0x2dd
44
45Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
46
47*/
48
49void button_init_device(void)
50{
51 /* Nothing to do */
52}
53
54int button_read_device(void)
55{
56 int btn = BUTTON_NONE;
57 int adc;
58
59 adc = adc_read(ADC_BUTTONS);
60
61 if (adc < 0x384) {
62 if (adc < 0x140) {
63 if (adc < 0x96) {
64 if (adc < 0x50) {
65 btn |= BUTTON_RIGHT; /* 0x00..0x4f */
66 } else {
67 btn |= BUTTON_LEFT; /* 0x50..0x95 */
68 }
69 } else {
70 if (adc < 0xe0) {
71 btn |= BUTTON_SELECT; /* 0x96..0xdf */
72 } else {
73 btn |= BUTTON_UP; /* 0xe0..0x13f */
74 }
75 }
76 } else {
77 if (adc < 0x208) {
78 if (adc < 0x1b0) {
79 btn |= BUTTON_DOWN; /* 0x140..0x1af */
80 } else {
81 btn |= BUTTON_MODE; /* 0x1b0..0x207 */
82 }
83 } else {
84 if (adc < 0x290) {
85 btn |= BUTTON_PRESET; /* 0x208..0x28f */
86 } else {
87 btn |= BUTTON_REC; /* 0x290..0x383 */
88 }
89 }
90 }
91 }
92
93 if (!(GPIOA & 0x2))
94 btn |= BUTTON_HOLD;
95
96 if (!(GPIOA & 0x8000))
97 btn |= BUTTON_POWERPLAY;
98
99 return btn;
100}
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h
deleted file mode 100644
index 505fe438ed..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/button-target.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25/* Main unit's buttons */
26#define BUTTON_POWERPLAY 0x00000001
27#define BUTTON_MODE 0x00000002
28#define BUTTON_HOLD 0x00000004
29#define BUTTON_REC 0x00000008
30#define BUTTON_PRESET 0x00000010
31#define BUTTON_LEFT 0x00000020
32#define BUTTON_RIGHT 0x00000040
33#define BUTTON_UP 0x00000080
34#define BUTTON_DOWN 0x00000100
35#define BUTTON_SELECT 0x00000200
36
37#define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\
38 |BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\
39 |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT)
40
41/* Software power-off */
42#define POWEROFF_BUTTON BUTTON_POWERPLAY
43#define POWEROFF_COUNT 40
44
45#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
deleted file mode 100644
index 840b02a2a5..0000000000
--- a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
+++ /dev/null
@@ -1,44 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34 (void)on;
35}
36
37bool ide_powered(void)
38{
39 return true;
40}
41
42void power_off(void)
43{
44}
diff --git a/firmware/target/arm/tcc77x/m200/adc-target.h b/firmware/target/arm/tcc77x/m200/adc-target.h
deleted file mode 100644
index e9640cc9da..0000000000
--- a/firmware/target/arm/tcc77x/m200/adc-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
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 1
27
28#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/audio-m200.c b/firmware/target/arm/tcc77x/m200/audio-m200.c
deleted file mode 100644
index 107b2743ae..0000000000
--- a/firmware/target/arm/tcc77x/m200/audio-m200.c
+++ /dev/null
@@ -1,38 +0,0 @@
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
26int audio_channels = 2;
27int audio_output_source = AUDIO_SRC_PLAYBACK;
28
29void audio_set_output_source(int source)
30{
31 (void)source;
32}
33
34void audio_input_mux(int source, unsigned flags)
35{
36 (void)source;
37 (void)flags;
38}
diff --git a/firmware/target/arm/tcc77x/m200/backlight-target.h b/firmware/target/arm/tcc77x/m200/backlight-target.h
deleted file mode 100644
index d73ac78852..0000000000
--- a/firmware/target/arm/tcc77x/m200/backlight-target.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by 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 BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24#include "tcc77x.h"
25
26static inline bool backlight_hw_init(void)
27{
28 GPIOA_DIR |= 0x40;
29 return true;
30}
31
32static inline void backlight_hw_on(void)
33{
34 /* Enable backlight */
35 GPIOA |= 0x40;
36}
37
38static inline void backlight_hw_off(void)
39{
40 /* Disable backlight */
41 GPIOA &= ~0x40;
42}
43
44#endif
diff --git a/firmware/target/arm/tcc77x/m200/button-m200.c b/firmware/target/arm/tcc77x/m200/button-m200.c
deleted file mode 100644
index a37fe1302c..0000000000
--- a/firmware/target/arm/tcc77x/m200/button-m200.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#include "config.h"
23#include "cpu.h"
24#include "button.h"
25#include "adc.h"
26
27/*
28
29Results of button testing (viewing ADC values whilst pressing buttons):
30
31HOLD: GPIOB & 0x0200 (0=hold active, 0x0200 = hold inactive)
32
33ADC[1]: (approx values)
34
35Idle - 0x3ff
36MENU - unknown
37
38REPEAT/AB - 0x03?
39LEFT - 0x07?-0x08?
40SELECT - 0x0c?
41RIGHT - 0x11?
42
43PLAY/PAUSE - 0x17?-0x018?
44VOL UP - 0x1e?-0x01f?
45VOL DOWN - 0x26?
46
47*/
48
49void button_init_device(void)
50{
51 /* Nothing to do */
52}
53
54int button_read_device(void)
55{
56 int btn = BUTTON_NONE;
57 int adc;
58
59 /* TODO - determine how to detect BUTTON_MENU - it doesn't appear to
60 be connected to a GPIO or to an ADC
61 */
62
63 adc = adc_read(ADC_BUTTONS);
64
65 if (adc < 0x384) {
66 if (adc < 0x140) {
67 if (adc < 0x96) {
68 if (adc < 0x50) {
69 btn |= BUTTON_REPEATAB; /* 0x00..0x4f */
70 } else {
71 btn |= BUTTON_LEFT; /* 0x50..0x95 */
72 }
73 } else {
74 if (adc < 0xe0) {
75 btn |= BUTTON_SELECT; /* 0x96..0xdf */
76 } else {
77 btn |= BUTTON_RIGHT; /* 0xe0..0x13f */
78 }
79 }
80 } else {
81 if (adc < 0x208) {
82 if (adc < 0x1b0) {
83 btn |= BUTTON_PLAYPAUSE; /* 0x140..0x1af */
84 } else {
85 btn |= BUTTON_VOLUP; /* 0x1b0..0x207 */
86 }
87 } else {
88 btn |= BUTTON_VOLDOWN; /* 0x209..0x383 */
89 }
90 }
91 }
92
93 return btn;
94}
95
96bool button_hold(void)
97{
98 return (GPIOB & 0x200)?false:true;
99}
diff --git a/firmware/target/arm/tcc77x/m200/button-target.h b/firmware/target/arm/tcc77x/m200/button-target.h
deleted file mode 100644
index b96df22edc..0000000000
--- a/firmware/target/arm/tcc77x/m200/button-target.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25#define HAS_BUTTON_HOLD
26
27/* Main unit's buttons */
28#define BUTTON_MENU 0x00000001
29#define BUTTON_VOLUP 0x00000002
30#define BUTTON_VOLDOWN 0x00000004
31#define BUTTON_PLAYPAUSE 0x00000008
32#define BUTTON_REPEATAB 0x00000010
33#define BUTTON_LEFT 0x00000020
34#define BUTTON_RIGHT 0x00000040
35#define BUTTON_SELECT 0x00000080
36
37#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
38 |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
39 |BUTTON_RIGHT|BUTTON_SELECT)
40
41/* Software power-off */
42#define POWEROFF_BUTTON BUTTON_MENU
43#define POWEROFF_COUNT 40
44
45#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/power-m200.c b/firmware/target/arm/tcc77x/m200/power-m200.c
deleted file mode 100644
index e84ff1c852..0000000000
--- a/firmware/target/arm/tcc77x/m200/power-m200.c
+++ /dev/null
@@ -1,43 +0,0 @@
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#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "kernel.h"
25#include "system.h"
26#include "power.h"
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34}
35
36bool ide_powered(void)
37{
38 return true;
39}
40
41void power_off(void)
42{
43}
diff --git a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
deleted file mode 100644
index 07a56777d0..0000000000
--- a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
+++ /dev/null
@@ -1,66 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "adc.h"
24#include "powermgmt.h"
25#include "kernel.h"
26#include "pcf50606.h"
27
28unsigned short current_voltage = 3910;
29
30const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
31{
32 /* FIXME: calibrate value */
33 3380
34};
35
36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
37{
38 /* FIXME: calibrate value */
39 3300
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
43const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
44{
45 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
46 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
47};
48
49#if CONFIG_CHARGING
50/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
51const unsigned short percent_to_volt_charge[11] =
52{
53 /* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
54 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160
55};
56#endif /* CONFIG_CHARGING */
57
58#define BATTERY_SCALE_FACTOR 6000
59/* full-scale ADC readout (2^10) in millivolt */
60
61/* Returns battery voltage from ADC [millivolts] */
62int _battery_voltage(void)
63{
64 return current_voltage;
65}
66
diff --git a/firmware/target/arm/tcc77x/system-target.h b/firmware/target/arm/tcc77x/system-target.h
deleted file mode 100644
index beeeac05c6..0000000000
--- a/firmware/target/arm/tcc77x/system-target.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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 SYSTEM_TARGET_H
22#define SYSTEM_TARGET_H
23
24#include "system-arm.h"
25
26#define CPUFREQ_DEFAULT 98784000
27#define CPUFREQ_NORMAL 98784000
28#define CPUFREQ_MAX 120000000
29
30#define inl(a) (*(volatile unsigned long *) (a))
31#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
32#define inb(a) (*(volatile unsigned char *) (a))
33#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
34#define inw(a) (*(volatile unsigned short *) (a))
35#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
36
37/* TC32 is configured to 1MHz in clock_init() */
38#define USEC_TIMER TC32MCNT
39
40static inline void udelay(unsigned usecs)
41{
42 unsigned stop = USEC_TIMER + usecs;
43 while (TIME_BEFORE(USEC_TIMER, stop));
44}
45
46
47#define TCC77X_CSCFG_BW8 0
48#define TCC77X_CSCFG_BW16 1
49
50/* Due to hardware bug or "feature" this hack is needed to set bus width bits */
51static inline
52unsigned long tcc77x_cscfg_bw(int bw) {
53 if (bw == TCC77X_CSCFG_BW8)
54 return (((MCFG >> 11) & 3) ^ 3) << 28;
55 else
56 return (((MCFG >> 11) & 3) ^ 2) << 28;
57}
58
59#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
deleted file mode 100644
index cffb4deba4..0000000000
--- a/firmware/target/arm/tcc77x/system-tcc77x.c
+++ /dev/null
@@ -1,326 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by 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
22#include "kernel.h"
23#include "system.h"
24#include "panic.h"
25
26/* Externally defined interrupt handlers */
27extern void TIMER(void);
28extern void ADC(void);
29extern void USB_DEVICE(void);
30
31void irq(void)
32{
33 int irq = IREQ & 0x7fffffff;
34 CREQ = irq; /* Clears the corresponding IRQ status */
35
36 if (irq & TIMER0_IRQ_MASK)
37 TIMER();
38 else if (irq & ADC_IRQ_MASK)
39 ADC();
40#ifdef HAVE_USBSTACK
41 else if (irq & USBD_IRQ_MASK)
42 USB_DEVICE();
43#endif
44 else
45 panicf("Unhandled IRQ 0x%08X", irq);
46}
47
48void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked));
49
50#ifdef BOOTLOADER
51void fiq_handler(void)
52{
53 /* TODO */
54}
55#endif
56
57void system_reboot(void)
58{
59}
60
61void system_exception_wait(void)
62{
63 while (1);
64}
65
66/* TODO - these should live in the target-specific directories and
67 once we understand what all the GPIO pins do, move the init to the
68 specific driver for that hardware. For now, we just perform the
69 same GPIO init as the original firmware - this makes it easier to
70 investigate what the GPIO pins do.
71*/
72
73#ifdef LOGIK_DAX
74static void gpio_init(void)
75{
76 /* Do what the original firmware does */
77 GPIOD_FUNC = 0;
78 GPIOD_DIR = 0x3f0;
79 GPIOD = 0xe0;
80
81 GPIOE_FUNC = 0;
82 GPIOE_DIR = 0xe0;
83 GPIOE = 0;
84
85 GPIOA_FUNC = 0;
86 GPIOA_DIR = 0xffff1000; /* 0 - 0xf000 */
87 GPIOA = 0x1080;
88
89 GPIOB_FUNC = 0x16a3;
90 GPIOB_DIR = 0x6ffff;
91 GPIOB = 0;
92
93 GPIOC_FUNC = 1;
94 GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
95 GPIOC = 0;
96}
97#elif defined(IAUDIO_7)
98static void gpio_init(void)
99{
100 /* Do what the original firmware does */
101 GPIOA_FUNC = 0;
102 GPIOB_FUNC = 0x1623;
103 GPIOC_FUNC = 1;
104 GPIOD_FUNC = 0;
105 GPIOE_FUNC = 0;
106 GPIOA = 0x30;
107 GPIOB = 0x00c00;
108 GPIOC = 0;
109 GPIOD = 0x180;
110 GPIOE = 0x80;
111 GPIOA_DIR = 0x84b0;
112 GPIOB_DIR = 0x80c00;
113 GPIOC_DIR = 0x2000000;
114 GPIOD_DIR = 0x3e3;
115 GPIOE_DIR = 0x88;
116}
117#elif defined(SANSA_M200)
118static void gpio_init(void)
119{
120 /* TODO - Implement for M200 */
121}
122#elif defined(SANSA_C100)
123static void gpio_init(void)
124{
125 /* Do what the original firmware does */
126 GPIOA_FUNC = 0;
127 GPIOB_FUNC = 0x16A3;
128 GPIOC_FUNC = 1;
129 GPIOD_FUNC |= 2;
130 GPIOE_FUNC = 0;
131
132 GPIOA_DIR = 0xFFFF0E00;
133 GPIOB_DIR = 0x6FFFF;
134 GPIOC_DIR = 0x03FFFFFF;
135 GPIOD_DIR = 0x3F7;
136 GPIOE_DIR = 0x9B;
137
138 GPIOA = 0x80;
139 GPIOB = 0;
140 GPIOC = 0;
141 GPIOD |= 0xC0;
142 GPIOE = 0x9B;
143}
144#endif
145
146/* Second function called in the original firmware's startup code - we just
147 set up the clocks in the same way as the original firmware for now. */
148static void clock_init(void)
149{
150 unsigned int i;
151
152 /* STP = 0x1, PW = 0x04 , HLD = 0x0 */
153 CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
154
155 /* XIN=External main, Fcpu=Fsys, BCKDIV=1 (Fbus = Fsys / 2) */
156 CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
157
158 if (BMI & 0x20)
159 PCLKCFG0 = 0xc82d7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0x2d, P1 = 1 */
160 else
161 PCLKCFG0 = 0xc8ba7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0xba, P1 = 1 */
162
163 MCFG |= 0x2000;
164
165#ifdef LOGIK_DAX
166 /* Only seen in the Logik DAX original firmware */
167 SDCFG = (SDCFG & ~0x7000) | 0x2000;
168#endif
169
170 /* Disable PLL */
171 PLL0CFG |= 0x80000000;
172
173 /* Enable PLL, M=0xcf, P=0x13. m=M+8, p=P+2, S = 0
174 Fout = (215/21)*12MHz = 122857142Hz */
175 PLL0CFG = 0x0000cf13;
176
177 i = 8000;
178 while (--i) {};
179
180 /* Enable PLL0 */
181 CLKDIVC = 0x81000000;
182
183 /* Fsys = PLL0, Fcpu = Fsys, Fbus=Fsys / 2 */
184 CLKCTRL = 0x80000010;
185
186 asm volatile (
187 "nop \n\t"
188 "nop \n\t"
189 );
190
191 /* Enable Z-Clock */
192 PCLKCFG5 |= (1<<31) | (4<<28); /* Timer Z-Clock enable, XIN direct*/
193
194 /* Set TC32 timer to be our USEC_TIMER (Xin divided by 12 = 1MHz) */
195 TC32MCNT = 0;
196 TC32LDV = 0;
197 TC32EN = (1<<24) | 11;
198}
199
200static void cpu_init(void)
201{
202 /* Memory protection - see page 48 of ARM946 TRM
203http://infocenter.arm.com/help/topic/com.arm.doc.ddi0201d/DDI0201D_arm946es_r1p1_trm.pdf
204 */
205 asm volatile (
206 /* Region 0 - addr=0, size=4GB, enabled */
207 "mov r0, #0x3f \n\t"
208 "mcr p15, 0, r0, c6, c0, 0 \n\t"
209 "mcr p15, 0, r0, c6, c0, 1 \n\t"
210
211#if defined(LOGIK_DAX) || defined(SANSA_C100)
212 /* Address region 1 - addr 0x2fff0000, size=64KB, enabled*/
213 "ldr r0, =0x2fff001f \n\t"
214#elif defined(IAUDIO_7)
215 /* Address region 1 - addr 0x20000000, size=8KB, enabled*/
216 "mov r0, #0x19 \n\t"
217 "add r0, r0, #0x20000000 \n\t"
218#elif defined(SANSA_M200)
219 /* Address region 1 - addr 0x20000000, size=256MB, enabled*/
220 "mov r0, #0x37 \n\t"
221 "add r0, r0, #0x20000000 \n\t"
222#endif
223 "mcr p15, 0, r0, c6, c1, 0 \n\t"
224 "mcr p15, 0, r0, c6, c1, 1 \n\t"
225
226 /* Address region 2 - addr 0x30000000, size=256MB, enabled*/
227 "mov r0, #0x37 \n\t"
228 "add r0, r0, #0x30000000 \n\t"
229 "mcr p15, 0, r0, c6, c2, 0 \n\t"
230 "mcr p15, 0, r0, c6, c2, 1 \n\t"
231
232 /* Address region 2 - addr 0x40000000, size=512MB, enabled*/
233 "mov r0, #0x39 \n\t"
234 "add r0, r0, #0x40000000 \n\t"
235 "mcr p15, 0, r0, c6, c3, 0 \n\t"
236 "mcr p15, 0, r0, c6, c3, 1 \n\t"
237
238 /* Address region 4 - addr 0x60000000, size=256MB, enabled*/
239 "mov r0, #0x37 \n\t"
240 "add r0, r0, #0x60000000 \n\t"
241 "mcr p15, 0, r0, c6, c4, 0 \n\t"
242 "mcr p15, 0, r0, c6, c4, 1 \n\t"
243
244 /* Address region 5 - addr 0x10000000, size=256MB, enabled*/
245 "mov r0, #0x37 \n\t"
246 "add r0, r0, #0x10000000 \n\t"
247 "mcr p15, 0, r0, c6, c5, 0 \n\t"
248 "mcr p15, 0, r0, c6, c5, 1 \n\t"
249
250 /* Address region 6 - addr 0x80000000, size=2GB, enabled*/
251 "mov r0, #0x37 \n\t"
252 "add r0, r0, #0x80000006 \n\t"
253 "mcr p15, 0, r0, c6, c6, 0 \n\t"
254 "mcr p15, 0, r0, c6, c6, 1 \n\t"
255
256 /* Address region 7 - addr 0x3000f000, size=4KB, enabled*/
257 "ldr r0, =0x3000f017 \n\t"
258 "mcr p15, 0, r0, c6, c7, 0 \n\t"
259 "mcr p15, 0, r0, c6, c7, 1 \n\t"
260
261
262 /* Register 5 - Access Permission Registers */
263
264 "ldr r0, =0xffff \n\t"
265 "mcr p15, 0, r0, c5, c0, 0 \n\t" /* write data access permission bits */
266 "mcr p15, 0, r0, c5, c0, 1 \n\t" /* write instruction access permission bits */
267
268 "mov r0, #0xa7 \n\t"
269 "mcr p15, 0, r0, c3, c0, 0 \n\t" /* set write buffer control register */
270
271#if defined(LOGIK_DAX) || defined(SANSA_C100)
272 "mov r0, #0xa5 \n\t"
273#elif defined(IAUDIO_7) || defined(SANSA_M200)
274 "mov r0, #0xa7 \n\t"
275#else
276 #error NOT DEFINED FOR THIS TARGET!
277#endif
278 "mcr p15, 0, r0, c2, c0, 0 \n\t"
279 "mcr p15, 0, r0, c2, c0, 1 \n\t"
280
281 "mov r0, #0xa0000006 \n\t"
282 "mcr p15, 0, r0, c9, c1, 0 \n\t"
283
284 "ldr r1, =0x1107d \n\t"
285 "mov r0, #0x0 \n\t"
286 "mcr p15, 0, r0, c7, c5, 0 \n\t" /* Flush instruction cache */
287 "mcr p15, 0, r0, c7, c6, 0 \n\t" /* Flush data cache */
288
289 "mcr p15, 0, r1, c1, c0, 0 \n\t" /* CPU control bits */
290 : : : "r0", "r1"
291 );
292}
293
294
295
296void system_init(void)
297{
298 /* mask all interrupts */
299 IEN = 0;
300
301 /* Set all interrupts as IRQ for now - some may need to be FIQ in future */
302 IRQSEL = 0xffffffff;
303
304 /* Set master enable bit */
305 IEN = 0x80000000;
306
307 cpu_init();
308 clock_init();
309 gpio_init();
310
311 enable_irq();
312}
313
314int system_memory_guard(int newmode)
315{
316 (void)newmode;
317 return 0;
318}
319
320#ifdef HAVE_ADJUSTABLE_CPU_FREQ
321
322void set_cpu_frequency(long frequency)
323{
324}
325
326#endif
diff --git a/firmware/target/arm/tcc77x/timer-tcc77x.c b/firmware/target/arm/tcc77x/timer-tcc77x.c
deleted file mode 100644
index 6e8764d9ce..0000000000
--- a/firmware/target/arm/tcc77x/timer-tcc77x.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2008 by Rob Purchase
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 "system.h"
25#include "timer.h"
26#include "logf.h"
27
28/* Use the TC32 counter [sourced by Xin:12Mhz] for this timer, as it's the
29 only one that allows a 32-bit counter (Timer0-5 are 16/20 bit only). */
30
31bool timer_set(long cycles, bool start)
32{
33 #warning function not implemented
34
35 (void)cycles;
36 (void)start;
37 return false;
38}
39
40bool timer_start(void)
41{
42 #warning function not implemented
43
44 return false;
45}
46
47void timer_stop(void)
48{
49 #warning function not implemented
50}
51
52
53/* Timer interrupt processing - all timers (inc. tick) have a single IRQ */
54void TIMER(void)
55{
56 if (TIREQ & TF0) /* Timer0 reached ref value */
57 {
58 /* Run through the list of tick tasks */
59 call_tick_tasks();
60
61 /* reset Timer 0 IRQ & ref flags */
62 TIREQ |= TI0 | TF0;
63 }
64
65 if (TC32IRQ & (1<<3)) /* end of TC32 prescale */
66 {
67 /* dispatch timer */
68 }
69}
diff --git a/firmware/target/arm/wmcodec-telechips.c b/firmware/target/arm/wmcodec-telechips.c
index 8fb035bdfa..deaced2682 100644
--- a/firmware/target/arm/wmcodec-telechips.c
+++ b/firmware/target/arm/wmcodec-telechips.c
@@ -34,8 +34,6 @@
34#if defined(COWON_D2) 34#if defined(COWON_D2)
35/* The D2's audio codec uses an I2C address of 0x34 */ 35/* The D2's audio codec uses an I2C address of 0x34 */
36#define I2C_AUDIO_ADDRESS 0x34 36#define I2C_AUDIO_ADDRESS 0x34
37#elif defined (IAUDIO_7) || defined(LOGIK_DAX) || defined(SANSA_M200)
38#define I2C_AUDIO_ADDRESS 0x34
39#else 37#else
40#error wmcodec not implemented for this target! 38#error wmcodec not implemented for this target!
41#endif 39#endif