summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/tcc77x
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
committerDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
commitd462a64a918117991e11dade2d7fa3a28196e07a (patch)
tree0a6f5ed8777b18bb1641fbb3608f10374901706c /firmware/target/arm/tcc77x
parentb87715f670f04c9adbe358c32a385c6771d99a81 (diff)
downloadrockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz
rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.bz2
rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r--firmware/target/arm/tcc77x/adc-tcc77x.c3
-rw-r--r--firmware/target/arm/tcc77x/app.lds123
-rw-r--r--firmware/target/arm/tcc77x/boot.lds5
-rw-r--r--firmware/target/arm/tcc77x/crt0.S5
-rw-r--r--firmware/target/arm/tcc77x/debug-tcc77x.c5
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/adc-target.h28
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c124
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.h27
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c99
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/backlight-target.h (renamed from firmware/target/arm/tcc77x/pcm-tcc77x.c)63
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c81
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-target.h57
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c252
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c146
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c11
-rw-r--r--firmware/target/arm/tcc77x/usb-tcc77x.c8
16 files changed, 905 insertions, 132 deletions
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c
index 37bd15398b..f48528639e 100644
--- a/firmware/target/arm/tcc77x/adc-tcc77x.c
+++ b/firmware/target/arm/tcc77x/adc-tcc77x.c
@@ -104,6 +104,9 @@ unsigned short adc_read(int channel)
void adc_init(void)
{
+ /* Initialize ADC clocks */
+ PCLKCFG6 = (PCLKCFG6 & 0xffff0000) | 4004;
+
ADCCON = (1<<4); /* Leave standby mode */
/* IRQ enable, auto power-down, single-mode */
diff --git a/firmware/target/arm/tcc77x/app.lds b/firmware/target/arm/tcc77x/app.lds
index 03a427f76b..c50367cb08 100644
--- a/firmware/target/arm/tcc77x/app.lds
+++ b/firmware/target/arm/tcc77x/app.lds
@@ -1,21 +1,25 @@
#include "config.h"
ENTRY(start)
-
OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
STARTUP(target/arm/tcc77x/crt0.o)
#define PLUGINSIZE PLUGIN_BUFFER_SIZE
#define CODECSIZE CODEC_SIZE
+
+#ifdef DEBUG
+#define STUBOFFSET 0x10000
+#else
+#define STUBOFFSET 0
+#endif
-#include "imx31l.h"
-
-#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
+#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
#define DRAMORIG 0x20000000
#define IRAMORIG 0x00000000
-#define IRAMSIZE IRAM_SIZE
+#define IRAMSIZE 64K
+
/* End of the audio buffer, where the codec buffer starts */
#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
@@ -23,100 +27,58 @@ STARTUP(target/arm/tcc77x/crt0.o)
/* Where the codec buffer ends, and the plugin buffer starts */
#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
+
MEMORY
{
- DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
- IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
+#ifdef TCCBOOT
+ DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
+#else
+ DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
+#endif
+ IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
SECTIONS
{
- .text :
- {
- loadaddress = .;
- _loadaddress = .;
- . = ALIGN(0x200);
+ .text : {
+ loadaddress = .;
+ _loadaddress = .;
+ . = ALIGN(0x200);
*(.init.text)
+ *(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
- . = ALIGN(0x4);
- } > DRAM
-
- .rodata :
- {
- *(.rodata) /* problems without this, dunno why */
- *(.rodata*)
- *(.rodata.str1.1)
- *(.rodata.str1.4)
- . = ALIGN(0x4);
+ } > DRAM
- /* Pseudo-allocate the copies of the data sections */
- _datacopy = .;
- } > DRAM
-
- /* TRICK ALERT! For RAM execution, we put the .data section at the
- same load address as the copy. Thus, we don't waste extra RAM
- when we don't actually need the copy. */
- .data : AT ( _datacopy )
- {
- _datastart = .;
- *(.data*)
- . = ALIGN(0x4);
- _dataend = .;
- } > DRAM
-
- /DISCARD/ :
- {
- *(.eh_frame)
- }
-
- .vectors 0x0 :
- {
- _vectorsstart = .;
- *(.vectors);
- _vectorsend = .;
- } AT> DRAM
-
- _vectorscopy = LOADADDR(.vectors);
-
- .iram :
- {
- _iramstart = .;
+ .data : {
*(.icode)
*(.irodata)
*(.idata)
+ *(.data*)
+ *(.rodata.*)
+ *(.rodata)
. = ALIGN(0x4);
- _iramend = .;
- } > DRAM
-
- _iramcopy = LOADADDR(.iram);
-
- .ibss (NOLOAD) :
- {
- _iedata = .;
- *(.ibss)
- . = ALIGN(0x4);
- _iend = .;
+ _dataend = . ;
} > DRAM
.stack :
{
- *(.stack)
- stackbegin = .;
- . += 0x2000;
- stackend = .;
- } > DRAM
-
- .bss :
- {
- _edata = .;
- *(.bss*)
- *(COMMON)
- . = ALIGN(0x4);
- _end = .;
+ *(.stack)
+ _stackbegin = .;
+ stackbegin = .;
+ . += 0x2000;
+ _stackend = .;
+ stackend = .;
} > DRAM
+ .bss : {
+ _edata = .;
+ *(.bss*);
+ *(.ibss);
+ *(COMMON)
+ _end = .;
+ } > DRAM
.audiobuf ALIGN(4) :
{
_audiobuffer = .;
@@ -128,7 +90,7 @@ SECTIONS
audiobufend = .;
_audiobufend = .;
} > DRAM
-
+
.codec ENDAUDIOADDR:
{
codecbuf = .;
@@ -139,6 +101,5 @@ SECTIONS
{
_pluginbuf = .;
pluginbuf = .;
- }
+ }
}
-
diff --git a/firmware/target/arm/tcc77x/boot.lds b/firmware/target/arm/tcc77x/boot.lds
index 890c4ec785..2fd6964d57 100644
--- a/firmware/target/arm/tcc77x/boot.lds
+++ b/firmware/target/arm/tcc77x/boot.lds
@@ -14,7 +14,11 @@ STARTUP(target/arm/tcc77x/crt0.o)
MEMORY
{
+#ifdef TCCBOOT
DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
+#else
+ DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
+#endif
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
@@ -34,6 +38,7 @@ SECTIONS
*(.idata)
*(.data*)
*(.rodata.*)
+ *(.rodata)
. = ALIGN(0x4);
_dataend = . ;
} > DRAM
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
index e144c16fae..569930352a 100644
--- a/firmware/target/arm/tcc77x/crt0.S
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -82,12 +82,15 @@ start_loc:
#ifdef TCCBOOT
mov r0, #0x80000000
-#ifdef LOGIK_DAX
+#if defined(LOGIK_DAX)
ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
tst r0, #0x2
#elif defined(SANSA_M200)
ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
tst r0, #0x200
+#elif defined(IAUDIO_7)
+ ldr r0, [r0, #0x300] /* Hold button is !GPIO A, pin 0x2 */
+ tst r0, #0x2
#else
#error No bootup key detection implemented for this target
#endif
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c
index 4566c7ea73..203a6010ce 100644
--- a/firmware/target/arm/tcc77x/debug-tcc77x.c
+++ b/firmware/target/arm/tcc77x/debug-tcc77x.c
@@ -56,8 +56,11 @@ bool __dbg_hw_info(void)
button = button_get(false);
button &= ~BUTTON_REPEAT;
-
+#ifdef BUTTON_SELECT
if (button == BUTTON_SELECT)
+#else
+ if (button == BUTTON_STOP)
+#endif
done=true;
snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
new file mode 100644
index 0000000000..1916d93598
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 Dave Chapman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _ADC_TARGET_H_
+#define _ADC_TARGET_H_
+
+#define NUM_ADC_CHANNELS 8
+
+#define ADC_BUTTONS 0
+
+#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
new file mode 100644
index 0000000000..fa165d9d0d
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
@@ -0,0 +1,124 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Vitja Makarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+#include "button.h"
+
+#include "ata2501.h"
+
+#define STB (1<<5)
+#define SDATA (1<<4)
+#define RESET (1<<6)
+#define SIFMD (1<<7)
+#define STB_DELAY 200
+
+#define udelay _udelay
+
+/* do we really need it? */
+static void _udelay(int cycles)
+{
+ cycles /= 8;
+ while (cycles--) {
+ asm("nop;nop;");
+ }
+}
+
+/*
+ TODO: sensitivity using GPIOS
+*/
+void ata2501_init(void)
+{
+ GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
+ GPIOD_DIR &= ~(SDATA);
+
+ GPIOD &= ~RESET;
+ udelay(1000);
+
+ GPIOD |= RESET;
+
+ GPIOD &= ~STB;
+
+#if 1
+ GPIOD &= ~((1 << 9) | (1 << 8));
+ GPIOD |= ((1 << 8) | SIFMD) | (1 << 9);
+#else
+ GPIOD |= ((1 << 9) | (1 << 8));
+ GPIOD &= ~(SIFMD);
+#endif
+}
+
+unsigned short ata2501_read(void)
+{
+ unsigned short ret = 0;
+ int i;
+
+ for (i = 0; i < 12; i++) {
+ GPIOD |= STB;
+ udelay(50);
+
+ ret <<= 1;
+ if (GPIOD & SDATA)
+ ret |= 1;
+ udelay(50);
+ GPIOD &= ~STB;
+ udelay(100);
+ }
+
+ return ret;
+}
+
+#define ATA2501_TEST
+#ifdef ATA2501_TEST
+#include "lcd.h"
+#include "sprintf.h"
+
+static
+void bits(char *str, unsigned short val)
+{
+ int i;
+
+ for (i = 0; i < 12; i++)
+ str[i] = (val & (1 << i)) ? '1' : '0';
+ str[i] = 0;
+}
+
+void ata2501_test(void)
+{
+ char buf[100];
+ ata2501_init();
+
+ while (1) {
+ unsigned short data;
+ int i, line = 0;
+
+ data = ata2501_read();
+ lcd_clear_display();
+ lcd_puts(0, line++, "ATA2501 test");
+
+ bits(buf, data);
+ lcd_puts(0, line++, buf);
+
+ lcd_update();
+ udelay(2000);
+ }
+}
+#endif
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
new file mode 100644
index 0000000000..465d0b199c
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Vitja Makarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _ATA2501_H_
+#define _ATA2501_H_
+
+void ata2501_init(void);
+unsigned short ata2501_read(void);
+
+#endif /* _ATA2501_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
new file mode 100644
index 0000000000..4e7f58df47
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Michael Sevakis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "system.h"
+#include "cpu.h"
+#include "audio.h"
+#include "sound.h"
+
+int audio_channels = 2;
+int audio_output_source = AUDIO_SRC_PLAYBACK;
+
+void audiohw_enable_output(bool on)
+{
+ (void) on;
+}
+
+void audio_set_output_source(int source)
+{
+ int oldmode = set_fiq_status(FIQ_DISABLED);
+
+ if ((unsigned)source >= AUDIO_NUM_SOURCES)
+ source = AUDIO_SRC_PLAYBACK;
+
+ audio_output_source = source;
+ set_fiq_status(oldmode);
+}
+
+void audio_input_mux(int source, unsigned flags)
+{
+ static int last_source = AUDIO_SRC_PLAYBACK;
+ static bool last_recording = false;
+ bool recording = flags & SRCF_RECORDING;
+
+ switch (source)
+ {
+ default: /* playback - no recording */
+ source = AUDIO_SRC_PLAYBACK;
+ case AUDIO_SRC_PLAYBACK:
+ audio_channels = 2;
+ if (source != last_source)
+ {
+ audiohw_set_monitor(false);
+ /* audiohw_disable_recording();*/
+ }
+ break;
+
+ case AUDIO_SRC_MIC: /* recording only */
+ GPIOD |= 0x1;
+
+ audio_channels = 1;
+ if (source != last_source)
+ {
+ /*audiohw_set_monitor(false);
+ audiohw_enable_recording(true); /. source mic */
+ }
+ break;
+
+ case AUDIO_SRC_FMRADIO: /* recording and playback */
+ GPIOD &= ~0x1;
+
+ audio_channels = 2;
+
+ if (source == last_source && recording == last_recording)
+ break;
+
+ last_recording = recording;
+
+ if (recording)
+ {
+ /*audiohw_set_monitor(false);
+ audiohw_enable_recording(false);*/
+ }
+ else
+ {
+ /*audiohw_disable_recording(); */
+ audiohw_set_monitor(true); /* line 1 analog audio path */
+ }
+ break;
+ } /* end switch */
+
+ last_source = source;
+} /* audio_input_mux */
diff --git a/firmware/target/arm/tcc77x/pcm-tcc77x.c b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
index 184a264858..597583b16f 100644
--- a/firmware/target/arm/tcc77x/pcm-tcc77x.c
+++ b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2008 by [whoever fills in these functions]
+ * Copyright (C) 2008 Vitja Makarov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,60 +18,29 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include "system.h"
-#include "kernel.h"
-#include "logf.h"
-#include "audio.h"
-#include "sound.h"
-#include "file.h"
+#ifndef BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
-void pcm_postinit(void)
-{
-}
-
-const void * pcm_play_dma_get_peak_buffer(int *count)
-{
- (void)count;
- return 0;
-}
-
-void pcm_play_dma_init(void)
-{
-}
-
-void pcm_apply_settings(void)
-{
-}
+#include <stdbool.h>
+#include "tcc77x.h"
-void pcm_set_frequency(unsigned int frequency)
-{
- (void)frequency;
-}
-
-void pcm_play_dma_start(const void *addr, size_t size)
-{
- (void)addr;
- (void)size;
-}
-
-void pcm_play_dma_stop(void)
-{
-}
-
-void pcm_play_lock(void)
-{
-}
+void power_touch_panel(bool on);
-void pcm_play_unlock(void)
+static inline bool _backlight_init(void)
{
+ GPIOD_DIR |= 0x2;
+ return true;
}
-void pcm_play_dma_pause(bool pause)
+static inline void _backlight_on(void)
{
- (void)pause;
+ GPIOD |= 0x2;
+ power_touch_panel(true);
}
-size_t pcm_get_bytes_waiting(void)
+static inline void _backlight_off(void)
{
- return 0;
+ GPIOD &= ~0x2;
+ power_touch_panel(false);
}
+#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
new file mode 100644
index 0000000000..3aad4f75a4
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Vitja Makarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include "cpu.h"
+#include "button.h"
+#include "adc.h"
+
+#include "button-target.h"
+#include "ata2501.h"
+
+void button_init_device(void)
+{
+ ata2501_init();
+}
+
+/*
+ touchpad:
+ 0: stop
+ 1-8: between next & prev
+ 9: play
+ 10: next
+ 11: prev
+*/
+
+int button_read_device(void)
+{
+ int btn = BUTTON_NONE;
+ int adc;
+ int sensor;
+
+ if (button_hold())
+ return BUTTON_NONE;
+
+ adc = adc_read(0);
+ sensor = ata2501_read();
+
+ if (0 == (GPIOA & 4))
+ btn |= BUTTON_POWER;
+
+ /* seems they can't be hold together */
+ if (adc < 0x120)
+ btn |= BUTTON_VOLUP;
+ else if (adc < 0x270)
+ btn |= BUTTON_VOLDOWN;
+ else if (adc < 0x300)
+ btn |= BUTTON_MENU;
+
+ if (sensor & (1 << 0))
+ btn |= BUTTON_STOP;
+ if (sensor & (1 << 9))
+ btn |= BUTTON_PLAY;
+ if (sensor & ((1 << 10) | 0x1c0))
+ btn |= BUTTON_RIGHT;
+ if (sensor & ((1 << 11) | 0xe))
+ btn |= BUTTON_LEFT;
+
+ return btn;
+}
+
+bool button_hold(void)
+{
+ return !(GPIOA & 0x2);
+}
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h
new file mode 100644
index 0000000000..fafaf4a303
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/button-target.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Vitja Makarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _IAUDIO7_BUTTON_TARGET_H_
+#define _IAUDIO7_BUTTON_TARGET_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+#define HAS_BUTTON_HOLD
+
+bool button_hold(void);
+void button_init_device(void);
+int button_read_device(void);
+
+/* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+#define BUTTON_VOLUP 0x00000002
+#define BUTTON_VOLDOWN 0x00000004
+#define BUTTON_MENU 0x00000008
+
+#define BUTTON_LEFT 0x00000010
+#define BUTTON_RIGHT 0x00000020
+#define BUTTON_PLAY 0x00000040
+#define BUTTON_STOP 0x00000080
+
+#define BUTTON_ON BUTTON_POWER
+
+#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \
+ BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \
+ BUTTON_PLAY|BUTTON_STOP)
+
+/* No remote */
+#define BUTTON_REMOTE 0
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
+
+#endif /* _IAUDIO7_BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
new file mode 100644
index 0000000000..bbc20b6860
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
@@ -0,0 +1,252 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2004 by Linus Nielsen Feltzing
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/*
+ Thanks Hein-Pieter van Braam for initial work.
+
+ Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov
+ */
+
+#include <config.h>
+
+#include <kernel.h>
+#include <cpu.h>
+#include <lcd.h>
+#include <system-target.h>
+
+#include "hd66789r.h"
+
+static bool display_on = false; /* is the display turned on? */
+
+static inline void lcd_write_reg(int reg, int data)
+{
+ GPIOA &= ~0x400;
+ outw(0, 0x50010000);
+ outw(reg << 1, 0x50010000);
+ GPIOA |= 0x400;
+
+ outw((data & 0xff00) >> 7, 0x50010008);
+ outw((data << 24) >> 23, 0x50010008);
+}
+
+static void lcd_write_cmd(int reg)
+{
+ GPIOA &= ~0x400;
+ outw(0, 0x50010000);
+ outw(reg << 1, 0x50010000);
+ GPIOA |= 0x400;
+}
+
+/* Do what OF do */
+static void lcd_delay(int x)
+{
+ int i;
+
+ x *= 0xc35;
+ for (i = 0; i < x * 8; i++) {
+ }
+}
+
+
+static void _display_on(void)
+{
+ GPIOA_DIR |= 0x8000 | 0x400;
+ GPIOA |= 0x8000;
+
+ /* power setup */
+ lcd_write_reg(R_START_OSC, 0x0001);
+ lcd_delay(0xf);
+ lcd_write_reg(R_DISP_CONTROL1, 0x000);
+ lcd_delay(0xa);
+ lcd_write_reg(R_POWER_CONTROL2, 0x0002);
+ lcd_write_reg(R_POWER_CONTROL3, 0x000a);
+ lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
+ lcd_write_reg(R_POWER_CONTROL1, 0x0004);
+ lcd_write_reg(R_POWER_CONTROL1, 0x0134);
+ lcd_write_reg(R_POWER_CONTROL2, 0x0111);
+ lcd_write_reg(R_POWER_CONTROL3, 0x001c);
+ lcd_delay(0x28);
+ lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
+ lcd_write_reg(R_POWER_CONTROL1, 0x0510);
+ lcd_delay(0x3c);
+
+ /* lcd init 2 */
+ lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
+ lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
+ lcd_write_reg(R_ENTRY_MODE, 0x1038);
+ lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
+ lcd_write_reg(R_DISP_CONTROL3, 0x0000);
+ lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
+ lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
+ lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
+ lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
+ lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
+ lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
+ lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
+ lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
+ lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
+ lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
+ lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
+
+ /* lcd init 3 */
+ lcd_write_reg(R_POWER_CONTROL1, 0x4510);
+ lcd_write_reg(R_DISP_CONTROL1, 0x0005);
+ lcd_delay(0x28);
+ lcd_write_reg(R_DISP_CONTROL1, 0x0025);
+ lcd_write_reg(R_DISP_CONTROL1, 0x0027);
+ lcd_delay(0x28);
+ lcd_write_reg(R_DISP_CONTROL1, 0x0037);
+
+ display_on = true;
+}
+
+void lcd_init_device(void)
+{
+ /* Configure external memory banks */
+ CSCFG1 = 0x3d500023;
+
+ /* may be reset */
+ GPIOA |= 0x8000;
+
+ _display_on();
+}
+
+void lcd_enable(bool on)
+{
+ if (display_on == on)
+ return;
+
+ if (on) {
+ _display_on();
+// lcd_call_enable_hook();
+ } else {
+ /** Off sequence according to datasheet, p. 130 **/
+ lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
+ lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
+ sleep(2);
+
+ lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
+ sleep(2);
+
+ lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
+
+ lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
+ lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
+ lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
+
+ /* datasheet p. 131 */
+ lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
+
+ display_on = false;
+ }
+}
+
+bool lcd_enabled(void)
+{
+ return display_on;
+}
+
+
+#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
+
+
+void lcd_update(void)
+{
+ lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
+}
+
+/* todo: need tests */
+void lcd_update_rect(int sx, int sy, int width, int height)
+{
+ int x, y;
+
+ if (!display_on)
+ return;
+
+ if (width <= 0 || height <= 0) /* nothing to do */
+ return;
+
+ width += sx;
+ height += sy;
+
+ if (width > LCD_WIDTH)
+ width = LCD_WIDTH;
+ if (height > LCD_HEIGHT)
+ height = LCD_HEIGHT;
+
+ lcd_write_reg(R_ENTRY_MODE, 0x1028);
+ /* set update window */
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
+ lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
+ lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
+ lcd_write_cmd(R_WRITE_DATA_2_GRAM);
+
+ for (y = sy; y < height; y++) {
+ for (x = sx; x < width; x++) {
+ fb_data c;
+ unsigned long color;
+
+ c = lcd_framebuffer[y][x];
+ color =
+ ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
+ 2);
+
+ /* TODO: our color is 18-bit */
+ outw((color >> 9) & 0x1ff, 0x50010008);
+ outw((color) & 0x1ff, 0x50010008);
+ }
+ }
+}
+
+void lcd_set_contrast(int val)
+{
+ (void) val;
+}
+
+void lcd_set_invert_display(bool yesno)
+{
+ (void) yesno;
+}
+
+void lcd_set_flip(bool yesno)
+{
+ (void) yesno;
+}
+
+/* TODO: implement me */
+void lcd_blit_yuv(unsigned char *const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height)
+{
+ if (!display_on)
+ return;
+
+ width &= ~1; /* stay on the safe side */
+ height &= ~1;
+
+ panicf("%s", __func__);
+}
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
new file mode 100644
index 0000000000..ef012cbbdf
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
@@ -0,0 +1,146 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 Vitja Makarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <stdbool.h>
+
+#include "config.h"
+#include "cpu.h"
+#include "kernel.h"
+#include "system.h"
+#include "power.h"
+
+#include "pcf50606.h"
+
+void power_init(void)
+{
+ pcf50606_write(PCF5060X_DCDC1, 0x90);
+ pcf50606_write(PCF5060X_DCDC2, 0x48);
+ pcf50606_write(PCF5060X_DCDC3, 0xfc);
+ pcf50606_write(PCF5060X_DCDC4, 0xb1);
+
+ pcf50606_write(PCF5060X_IOREGC, 0xe9);
+ /* 3.3V, touch-panel */
+ pcf50606_write(PCF5060X_D1REGC1, 0xf8);
+ pcf50606_write(PCF5060X_D2REGC1, 0xf2);
+ pcf50606_write(PCF5060X_D3REGC1, 0xf5);
+
+ pcf50606_write(PCF5060X_LPREGC1, 0x00);
+ pcf50606_write(PCF5060X_LPREGC2, 0x02);
+
+ pcf50606_write(PCF5060X_DCUDC1, 0xe6);
+ pcf50606_write(PCF5060X_DCUDC2, 0x30);
+
+ pcf50606_write(PCF5060X_DCDEC1, 0xe7);
+ pcf50606_write(PCF5060X_DCDEC2, 0x02);
+
+ pcf50606_write(PCF5060X_INT1M, 0x5b);
+ pcf50606_write(PCF5060X_INT1M, 0xaf);
+ pcf50606_write(PCF5060X_INT1M, 0x8f);
+
+ pcf50606_write(PCF5060X_OOCC1, 0x40);
+ pcf50606_write(PCF5060X_OOCC2, 0x05);
+
+ pcf50606_write(PCF5060X_MBCC3, 0x3a);
+ pcf50606_write(PCF5060X_GPOC1, 0x00);
+ pcf50606_write(PCF5060X_BBCC, 0xf8);
+}
+
+/* Control leds on ata2501 board */
+void power_touch_panel(bool on)
+{
+ if (on)
+ pcf50606_write(PCF5060X_D1REGC1, 0xf8);
+ else
+ pcf50606_write(PCF5060X_D1REGC1, 0x00);
+}
+
+void ide_power_enable(bool on)
+{
+}
+
+bool ide_powered(void)
+{
+ return true;
+}
+
+void power_off(void)
+{
+ /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
+ pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
+}
+
+#if CONFIG_TUNER
+#include "tuner.h"
+
+/** Tuner **/
+static bool powered = false;
+
+#define TUNNER_CLK (1 << 5)
+#define TUNNER_DATA (1 << 6)
+#define TUNNER_NR_W (1 << 7)
+
+bool tuner_power(bool status)
+{
+ bool old_status;
+ lv24020lp_lock();
+
+ old_status = powered;
+
+ if (status != old_status)
+ {
+ if (status)
+ {
+ /* When power up, host should initialize the 3-wire bus
+ in host read mode: */
+
+ /* 1. Set direction of the DATA-line to input-mode. */
+ GPIOA_DIR &= ~TUNNER_DATA;
+
+ /* 2. Drive NR_W low */
+ GPIOA &= ~TUNNER_NR_W;
+ GPIOA_DIR |= TUNNER_NR_W;
+
+ /* 3. Drive CLOCK high */
+ GPIOA |= TUNNER_CLK;
+ GPIOA_DIR |= TUNNER_CLK;
+
+ lv24020lp_power(true);
+ }
+ else
+ {
+ lv24020lp_power(false);
+
+ /* set all as inputs */
+ GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
+ }
+
+ powered = status;
+ }
+
+ lv24020lp_unlock();
+ return old_status;
+}
+
+#endif /* CONFIG_TUNER */
+
+bool charger_inserted(void)
+{
+ return (GPIOA & 0x1) ? true : false;
+}
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
index c50a8a6651..2c8959fded 100644
--- a/firmware/target/arm/tcc77x/system-tcc77x.c
+++ b/firmware/target/arm/tcc77x/system-tcc77x.c
@@ -26,6 +26,7 @@
/* Externally defined interrupt handlers */
extern void TIMER(void);
extern void ADC(void);
+extern void USBD_IRQ(void);
void irq(void)
{
@@ -36,14 +37,22 @@ void irq(void)
TIMER();
else if (irq & ADC_IRQ_MASK)
ADC();
+#ifdef HAVE_USBSTACK
+ else if (irq & USBD_IRQ_MASK)
+ USBD_IRQ();
+#endif
else
panicf("Unhandled IRQ 0x%08X", irq);
}
+void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked));
+
+#ifdef BOOTLOADER
void fiq_handler(void)
{
/* TODO */
}
+#endif
void system_reboot(void)
{
@@ -94,7 +103,7 @@ static void gpio_init(void)
GPIOC = 0;
GPIOD = 0x180;
GPIOE = 0;
- GPIOA_DIR = 0x84b0
+ GPIOA_DIR = 0x84b0;
GPIOB_DIR = 0x80800;
GPIOC_DIR = 0x2000000;
GPIOD_DIR = 0x3e3;
diff --git a/firmware/target/arm/tcc77x/usb-tcc77x.c b/firmware/target/arm/tcc77x/usb-tcc77x.c
index 85c8bed3ef..9cfcb503e0 100644
--- a/firmware/target/arm/tcc77x/usb-tcc77x.c
+++ b/firmware/target/arm/tcc77x/usb-tcc77x.c
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2008 by [whoever fills in these functions]
+ * Copyright (C) 2008 by Vitja Makarov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -21,9 +21,15 @@
#include "config.h"
#include "usb.h"
+#include "system.h"
+#include "usb-tcc7xx.h"
void usb_init_device(void)
{
+ /* simply switch USB off for now */
+ BCLKCTR |= DEV_USBD;
+ TCC7xx_USB_PHY_CFG = 0x3e4c;
+ BCLKCTR &= ~DEV_USBD;
}
void usb_enable(bool on)