summaryrefslogtreecommitdiff
path: root/firmware
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
parentb87715f670f04c9adbe358c32a385c6771d99a81 (diff)
downloadrockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz
rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES23
-rw-r--r--firmware/drivers/audio/wm8731.c4
-rw-r--r--firmware/drivers/tuner/lv24020lp.c15
-rw-r--r--firmware/export/config-iaudio7.h163
-rw-r--r--firmware/export/config.h1
-rw-r--r--firmware/export/hd66789r.h68
-rw-r--r--firmware/export/tcc77x.h102
-rw-r--r--firmware/export/usb-tcc7xx.h104
-rw-r--r--firmware/target/arm/ata-nand-telechips.c2
-rw-r--r--firmware/target/arm/pcm-telechips.c (renamed from firmware/target/arm/tcc780x/pcm-tcc780x.c)128
-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
-rw-r--r--firmware/target/arm/wmcodec-telechips.c5
27 files changed, 1507 insertions, 145 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 2075f80891..4be623fada 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -988,7 +988,7 @@ target/arm/tcc77x/logikdax/button-logikdax.c
988target/arm/tcc77x/logikdax/power-logikdax.c 988target/arm/tcc77x/logikdax/power-logikdax.c
989#ifndef BOOTLOADER 989#ifndef BOOTLOADER
990target/arm/tcc77x/debug-tcc77x.c 990target/arm/tcc77x/debug-tcc77x.c
991target/arm/tcc77x/pcm-tcc77x.c 991target/arm/pcm-telechips.c
992#endif /* BOOTLOADER */ 992#endif /* BOOTLOADER */
993#endif /* SIMULATOR */ 993#endif /* SIMULATOR */
994#endif /* LOGIK_DAX */ 994#endif /* LOGIK_DAX */
@@ -1008,7 +1008,7 @@ target/arm/tcc77x/m200/button-m200.c
1008target/arm/tcc77x/m200/power-m200.c 1008target/arm/tcc77x/m200/power-m200.c
1009#ifndef BOOTLOADER 1009#ifndef BOOTLOADER
1010target/arm/tcc77x/debug-tcc77x.c 1010target/arm/tcc77x/debug-tcc77x.c
1011target/arm/tcc77x/pcm-tcc77x.c 1011target/arm/pcm-telechips.c
1012#endif /* BOOTLOADER */ 1012#endif /* BOOTLOADER */
1013#endif /* SIMULATOR */ 1013#endif /* SIMULATOR */
1014#endif /* SANSA_M200 */ 1014#endif /* SANSA_M200 */
@@ -1028,7 +1028,7 @@ target/arm/tcc77x/c100/button-c100.c
1028target/arm/tcc77x/c100/power-c100.c 1028target/arm/tcc77x/c100/power-c100.c
1029#ifndef BOOTLOADER 1029#ifndef BOOTLOADER
1030target/arm/tcc77x/debug-tcc77x.c 1030target/arm/tcc77x/debug-tcc77x.c
1031target/arm/tcc77x/pcm-tcc77x.c 1031target/arm/pcm-telechips.c
1032#endif /* BOOTLOADER */ 1032#endif /* BOOTLOADER */
1033#endif /* SIMULATOR */ 1033#endif /* SIMULATOR */
1034#endif /* SANSA_C100 */ 1034#endif /* SANSA_C100 */
@@ -1036,11 +1036,24 @@ target/arm/tcc77x/pcm-tcc77x.c
1036#ifdef IAUDIO_7 1036#ifdef IAUDIO_7
1037#ifndef SIMULATOR 1037#ifndef SIMULATOR
1038drivers/nand_id.c 1038drivers/nand_id.c
1039drivers/pcf50606.c
1039target/arm/ata-nand-telechips.c 1040target/arm/ata-nand-telechips.c
1040target/arm/tcc77x/adc-tcc77x.c
1041target/arm/tcc77x/system-tcc77x.c 1041target/arm/tcc77x/system-tcc77x.c
1042target/arm/tcc77x/kernel-tcc77x.c
1043target/arm/tcc77x/timer-tcc77x.c
1044target/arm/tcc77x/adc-tcc77x.c
1045target/arm/tcc77x/powermgmt-tcc77x.c
1046target/arm/tcc77x/usb-tcc77x.c
1042target/arm/tcc77x/iaudio7/lcd-iaudio7.c 1047target/arm/tcc77x/iaudio7/lcd-iaudio7.c
1043target/arm/tcc77x/iaudio7/power-iaudio7.c 1048target/arm/tcc77x/iaudio7/power-iaudio7.c
1049target/arm/tcc77x/iaudio7/button-iaudio7.c
1050target/arm/tcc77x/iaudio7/ata2501.c
1051#ifndef BOOTLOADER
1052target/arm/wmcodec-telechips.c
1053target/arm/pcm-telechips.c
1054target/arm/tcc77x/debug-tcc77x.c
1055target/arm/tcc77x/iaudio7/audio-iaudio7.c
1056#endif /* BOOTLOADER */
1044#endif /* SIMULATOR */ 1057#endif /* SIMULATOR */
1045#endif /* IAUDIO_7 */ 1058#endif /* IAUDIO_7 */
1046 1059
@@ -1063,7 +1076,7 @@ target/arm/tcc780x/kernel-tcc780x.c
1063target/arm/tcc780x/timer-tcc780x.c 1076target/arm/tcc780x/timer-tcc780x.c
1064target/arm/wmcodec-telechips.c 1077target/arm/wmcodec-telechips.c
1065target/arm/tcc780x/debug-tcc780x.c 1078target/arm/tcc780x/debug-tcc780x.c
1066target/arm/tcc780x/pcm-tcc780x.c 1079target/arm/pcm-telechips.c
1067target/arm/tcc780x/cowond2/audio-cowond2.c 1080target/arm/tcc780x/cowond2/audio-cowond2.c
1068#endif /* BOOTLOADER */ 1081#endif /* BOOTLOADER */
1069#endif /* SIMULATOR */ 1082#endif /* SIMULATOR */
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c
index 3d378d0072..59fa4cffcf 100644
--- a/firmware/drivers/audio/wm8731.c
+++ b/firmware/drivers/audio/wm8731.c
@@ -167,7 +167,11 @@ void audiohw_preinit(void)
167 167
168 /* 3) Set required values in all other registers except 12h (Active). */ 168 /* 3) Set required values in all other registers except 12h (Active). */
169 wmcodec_write(AINTFCE, AINTFCE_FORMAT_I2S | AINTFCE_IWL_16BIT | 169 wmcodec_write(AINTFCE, AINTFCE_FORMAT_I2S | AINTFCE_IWL_16BIT |
170#ifdef CODEC_SLAVE
171 0);
172#else
170 AINTFCE_MS); 173 AINTFCE_MS);
174#endif
171 wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]); 175 wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]);
172 wm8731_write(DAPCTRL, wm8731_regs[DAPCTRL]); 176 wm8731_write(DAPCTRL, wm8731_regs[DAPCTRL]);
173 wmcodec_write(SAMPCTRL, WM8731_USB24_44100HZ); 177 wmcodec_write(SAMPCTRL, WM8731_USB24_44100HZ);
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index 0f61e5d72b..0f05d90ea2 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -67,6 +67,21 @@ static int fd_log = -1;
67#define FM_NRW_PIN 3 67#define FM_NRW_PIN 3
68#define FM_CLOCK_PIN 4 68#define FM_CLOCK_PIN 4
69#define FM_DATA_PIN 5 69#define FM_DATA_PIN 5
70#elif defined(IAUDIO_7)
71#define GPIO_OUTPUT_EN GPIOA_DIR
72#define GPIO_OUTPUT_VAL GPIOA
73#define GPIO_INPUT_VAL GPIOA
74#define FM_CLOCK_PIN 5
75#define FM_DATA_PIN 6
76#define FM_NRW_PIN 7
77//#define udelay(x) /* Remove hack when D2 has udelay */
78
79static void udelay(int usecs)
80{
81 while (usecs--)
82 asm("nop;nop;");
83}
84
70#elif defined(COWON_D2) 85#elif defined(COWON_D2)
71#define GPIO_OUTPUT_EN GPIOC_DIR 86#define GPIO_OUTPUT_EN GPIOC_DIR
72#define GPIO_OUTPUT_VAL GPIOC 87#define GPIO_OUTPUT_VAL GPIOC
diff --git a/firmware/export/config-iaudio7.h b/firmware/export/config-iaudio7.h
new file mode 100644
index 0000000000..8bc73fa41c
--- /dev/null
+++ b/firmware/export/config-iaudio7.h
@@ -0,0 +1,163 @@
1/*
2 * This config file is for the Iaudio7 series
3 */
4#define TARGET_TREE /* this target is using the target tree system */
5
6/* For Rolo and boot loader */
7#define MODEL_NUMBER 32
8
9/* define this if you have recording possibility */
10#define HAVE_RECORDING
11
12/* Define bitmask of input sources - recordable bitmask can be defined
13 explicitly if different */
14#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
15
16/* define hardware samples rate caps mask */
17#define HW_SAMPR_CAPS (/*SAMPR_CAP_88 | */SAMPR_CAP_44/* | SAMPR_CAP_22 | SAMPR_CAP_11*/)
18
19/* define the bitmask of recording sample rates */
20#define REC_SAMPR_CAPS (SAMPR_CAP_44/* | SAMPR_CAP_22 | SAMPR_CAP_11*/)
21
22/* define this if you have a bitmap LCD display */
23#define HAVE_LCD_BITMAP
24
25/* define this if you have a colour LCD */
26#define HAVE_LCD_COLOR
27
28/* define this if you can flip your LCD */
29//#define HAVE_LCD_FLIP
30
31/* define this if you can invert the colours on your LCD */
32//#define HAVE_LCD_INVERT
33
34/* define this if you have access to the quickscreen */
35#define HAVE_QUICKSCREEN
36
37/* define this if you have access to the pitchscreen */
38#define HAVE_PITCHSCREEN
39
40/* define this if you have LCD enable function */
41#define HAVE_LCD_ENABLE
42
43/* define this if you would like tagcache to build on this target */
44#define HAVE_TAGCACHE
45
46#define HAVE_FAT16SUPPORT
47
48#if 0 /* Enable for USB driver test */
49#define HAVE_USBSTACK
50#define USE_HIGH_SPEED
51#define USB_VENDOR_ID 0x0e21
52#define USB_PRODUCT_ID 0x0750
53
54#define USB_STORAGE
55#define USB_SERIAL
56#endif
57
58/* define this if you have a flash memory storage */
59#define HAVE_FLASH_STORAGE
60
61/* LCD dimensions */
62#define LCD_WIDTH 160
63#define LCD_HEIGHT 128
64/* 16bits for now... */
65#define LCD_DEPTH 16 /* 262144 colours */
66#define LCD_PIXELFORMAT RGB565 /*rgb565*/
67
68/*#define LCD_PIXELFORMAT VERTICAL_PACKING*/
69
70/* define this to indicate your device's keypad */
71#define CONFIG_KEYPAD IAUDIO67_PAD
72
73/* #define HAVE_BUTTON_DATA */
74
75/* define this if you have a real-time clock */
76#define CONFIG_RTC RTC_PCF50606
77
78/* define this if you have RTC RAM available for settings */
79//#define HAVE_RTC_RAM
80
81/* Define this if you have a software controlled poweroff */
82#define HAVE_SW_POWEROFF
83
84/* Reduce Tremor's ICODE usage */
85#define ICODE_ATTR_TREMOR_NOT_MDCT
86
87/* The number of bytes reserved for loadable codecs */
88#define CODEC_SIZE 0x80000
89
90/* The number of bytes reserved for loadable plugins */
91#define PLUGIN_BUFFER_SIZE 0x80000
92
93#define AB_REPEAT_ENABLE 1
94
95/* Define this if you do software codec */
96#define CONFIG_CODEC SWCODEC
97
98/* The iaudio7 uses built-in WM8731 codec */
99#define HAVE_WM8731
100/* Codec is slave on serial bus */
101#define CODEC_SLAVE
102
103/* Define this if you have the TLV320 audio codec */
104//#define HAVE_TLV320
105
106/* TLV320 has no tone controls, so we use the software ones */
107//#define HAVE_SW_TONE_CONTROLS
108
109/* Define this for LCD backlight available */
110#define HAVE_BACKLIGHT
111
112#define CONFIG_I2C I2C_TCC77X
113
114#define BATTERY_CAPACITY_DEFAULT 540 /* default battery capacity */
115#define BATTERY_CAPACITY_MIN 540 /* min. capacity selectable */
116#define BATTERY_CAPACITY_MAX 540 /* max. capacity selectable */
117#define BATTERY_CAPACITY_INC 50 /* capacity increment */
118#define BATTERY_TYPES_COUNT 1 /* only one type */
119
120/* define this if the unit should not shut down on low battery. */
121#define NO_LOW_BATTERY_SHUTDOWN
122#define CONFIG_CHARGING CHARGING_SIMPLE
123
124#ifndef SIMULATOR
125
126/* Define this if you have a TCC770 */
127#define CONFIG_CPU TCC770
128
129/* Define this if you have ATA power-off control */
130#define HAVE_ATA_POWER_OFF
131
132/* Define this to the CPU frequency */
133#define CPU_FREQ 120000000
134
135/* Offset ( in the firmware file's header ) to the file length */
136//#define FIRMWARE_OFFSET_FILE_LENGTH 0
137
138/* Offset ( in the firmware file's header ) to the file CRC */
139#define FIRMWARE_OFFSET_FILE_CRC 0
140
141/* Offset ( in the firmware file's header ) to the real data */
142#define FIRMWARE_OFFSET_FILE_DATA 8
143
144/* Software controlled LED */
145#define CONFIG_LED LED_VIRTUAL
146
147#define CONFIG_LCD LCD_IAUDIO67
148
149/* FM Tuner */
150#define CONFIG_TUNER LV24020LP
151#define HAVE_TUNER_PWR_CTRL
152
153/* Define this for FM radio input available */
154#define HAVE_FMRADIO_IN
155
156#define BOOTFILE_EXT "iaudio"
157#define BOOTFILE "rockbox." BOOTFILE_EXT
158#define BOOTDIR "/"
159
160#ifdef BOOTLOADER
161#define TCCBOOT
162#endif
163#endif /* SIMULATOR */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index bdf8743942..fe2cff0ea6 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -481,7 +481,6 @@
481 (((CONFIG_CPU == SH7034) && !defined(PLUGIN)) || /* SH1 archos: core only */ \ 481 (((CONFIG_CPU == SH7034) && !defined(PLUGIN)) || /* SH1 archos: core only */ \
482 defined(CPU_COLDFIRE) || /* Coldfire: core, plugins, codecs */ \ 482 defined(CPU_COLDFIRE) || /* Coldfire: core, plugins, codecs */ \
483 defined(CPU_PP) || /* PortalPlayer: core, plugins, codecs */ \ 483 defined(CPU_PP) || /* PortalPlayer: core, plugins, codecs */ \
484 defined(CPU_TCC77X) || /* Telechips: core, plugins, codecs */ \
485 (CONFIG_CPU == PNX0101) || \ 484 (CONFIG_CPU == PNX0101) || \
486 (CONFIG_CPU == S5L8700)) /* Samsung S5L8700: core, plugins, codecs */ 485 (CONFIG_CPU == S5L8700)) /* Samsung S5L8700: core, plugins, codecs */
487#define ICODE_ATTR __attribute__ ((section(".icode"))) 486#define ICODE_ATTR __attribute__ ((section(".icode")))
diff --git a/firmware/export/hd66789r.h b/firmware/export/hd66789r.h
new file mode 100644
index 0000000000..464ddbab4f
--- /dev/null
+++ b/firmware/export/hd66789r.h
@@ -0,0 +1,68 @@
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#ifndef _HD66789R_H_
23#define _HD66789R_H_
24
25/* HD66789R registers */
26#define R_START_OSC 0x00
27#define R_DRV_OUTPUT_CONTROL 0x01
28#define R_DRV_WAVEFORM_CONTROL 0x02
29#define R_ENTRY_MODE 0x03
30#define R_COMPARE_REG1 0x04
31#define R_COMPARE_REG2 0x05
32
33#define R_DISP_CONTROL1 0x07
34#define R_DISP_CONTROL2 0x08
35#define R_DISP_CONTROL3 0x09
36
37#define R_FRAME_CYCLE_CONTROL 0x0b
38#define R_EXT_DISP_IF_CONTROL 0x0c
39
40#define R_POWER_CONTROL1 0x10
41#define R_POWER_CONTROL2 0x11
42#define R_POWER_CONTROL3 0x12
43#define R_POWER_CONTROL4 0x13
44
45#define R_RAM_ADDR_SET 0x21
46#define R_WRITE_DATA_2_GRAM 0x22
47
48#define R_GAMMA_FINE_ADJ_POS1 0x30
49#define R_GAMMA_FINE_ADJ_POS2 0x31
50#define R_GAMMA_FINE_ADJ_POS3 0x32
51#define R_GAMMA_GRAD_ADJ_POS 0x33
52
53#define R_GAMMA_FINE_ADJ_NEG1 0x34
54#define R_GAMMA_FINE_ADJ_NEG2 0x35
55#define R_GAMMA_FINE_ADJ_NEG3 0x36
56#define R_GAMMA_GRAD_ADJ_NEG 0x37
57
58#define R_GAMMA_AMP_ADJ_RES_POS 0x38
59#define R_GAMMA_AMP_AVG_ADJ_RES_NEG 0x39
60
61#define R_GATE_SCAN_POS 0x40
62#define R_VERT_SCROLL_CONTROL 0x41
63#define R_1ST_SCR_DRV_POS 0x42
64#define R_2ND_SCR_DRV_POS 0x43
65#define R_HORIZ_RAM_ADDR_POS 0x44
66#define R_VERT_RAM_ADDR_POS 0x45
67
68#endif /* _HD66789R_H_ */
diff --git a/firmware/export/tcc77x.h b/firmware/export/tcc77x.h
index b17865e257..9ff8adea3e 100644
--- a/firmware/export/tcc77x.h
+++ b/firmware/export/tcc77x.h
@@ -59,8 +59,13 @@
59#define PCLKCFG5 (*(volatile unsigned long *)0x80000430) 59#define PCLKCFG5 (*(volatile unsigned long *)0x80000430)
60#define PCLKCFG6 (*(volatile unsigned long *)0x80000434) 60#define PCLKCFG6 (*(volatile unsigned long *)0x80000434)
61 61
62#define PCLK_DAI PCLKCFG6
63
62/* Device bits for SWRESET & BCLKCTR */ 64/* Device bits for SWRESET & BCLKCTR */
63 65
66#define DEV_DAI (1<<0)
67#define DEV_USBD (1<<4)
68#define DEV_ECC (1<<9)
64#define DEV_NAND (1<<16) 69#define DEV_NAND (1<<16)
65 70
66/* ADC */ 71/* ADC */
@@ -86,9 +91,23 @@
86 91
87 92
88/* IRQ Controller */ 93/* IRQ Controller */
94#define EXT0_IRQ_MASK (1<<0)
95#define EXT1_IRQ_MASK (1<<1)
96#define EXT2_IRQ_MASK (1<<2)
97#define EXT3_IRQ_MASK (1<<3)
98#define I2SR_IRQ_MASK (1<<4)
99#define I2ST_IRQ_MASK (1<<5)
100#define TIMER0_IRQ_MASK (1<<6)
101#define USBD_IRQ_MASK (1<<8) /* USB 2.0 device */
102#define USBH_IRQ_MASK (1<<10) /* USB 1.1 host */
103#define ADC_IRQ_MASK (1<<16)
104#define USB_DMA_IRQ_MASK (1<<26) /* USB DMA */
105#define ECC_IRQ_MASK (1<<27)
106
107#define DAI_RX_IRQ_MASK I2SR_IRQ_MASK
108#define DAI_TX_IRQ_MASK I2ST_IRQ_MASK
89 109
90#define TIMER0_IRQ_MASK (1<<6) 110#define USB_DMA_IRQ_MASK (1<<26) /* USB DMA */
91#define ADC_IRQ_MASK (1<<16)
92 111
93#define IEN (*(volatile unsigned long *)0x80000100) 112#define IEN (*(volatile unsigned long *)0x80000100)
94#define CREQ (*(volatile unsigned long *)0x80000104) 113#define CREQ (*(volatile unsigned long *)0x80000104)
@@ -160,4 +179,83 @@
160#define NFC_IREQ (*(volatile unsigned long *)0x90000060) 179#define NFC_IREQ (*(volatile unsigned long *)0x90000060)
161#define NFC_RST (*(volatile unsigned long *)0x90000064) 180#define NFC_RST (*(volatile unsigned long *)0x90000064)
162 181
182
183/* ECC controller */
184
185#define ECC_CTRL (*(volatile unsigned long *)0x80000900)
186 #define ECC_DMA_REQ (1<<28)
187 #define ECC_ENC (1<<27) /* MLC ECC3/4 */
188 #define ECC_FLG (1<<26)
189 #define ECC_IEN (1<<25)
190 #define ECC_MANUAL (1<<22)
191 #define ECC_WCNT (1<<12) /* [21:12] */
192 #define ECC_HOLD (1<<7)
193 #define ECC_M4EN (1<<6)
194 #define ECC_ZERO (1<<5)
195 #define ECC_M3EN (1<<4)
196 #define ECC_CNT_MASK (7<<1)
197 #define ECC_CNT (1<<1)
198 #define ECC_SLC (1<<0)
199
200#define ECC_BASE (*(volatile unsigned long *)0x80000904)
201#define ECC_MASK (*(volatile unsigned long *)0x80000908)
202#define ECC_CLR (*(volatile unsigned long *)0x8000090c)
203#define SLC_ECC0 (*(volatile unsigned long *)0x80000910)
204#define SLC_ECC1 (*(volatile unsigned long *)0x80000914)
205#define SLC_ECC2 (*(volatile unsigned long *)0x80000918)
206#define SLC_ECC3 (*(volatile unsigned long *)0x8000091c)
207#define SLC_ECC4 (*(volatile unsigned long *)0x80000920)
208#define SLC_ECC5 (*(volatile unsigned long *)0x80000924)
209#define SLC_ECC6 (*(volatile unsigned long *)0x80000928)
210#define SLC_ECC7 (*(volatile unsigned long *)0x8000092c)
211#define MLC_ECC0W (*(volatile unsigned long *)0x80000930)
212#define MLC_ECC1W (*(volatile unsigned long *)0x80000934)
213#define MLC_ECC2W (*(volatile unsigned long *)0x80000938)
214#define MLC_ECC0R (*(volatile unsigned long *)0x80000940)
215#define MLC_ECC1R (*(volatile unsigned long *)0x80000944)
216#define MLC_ECC2R (*(volatile unsigned long *)0x80000948)
217#define ECC_CORR_START (*(volatile unsigned long *)0x8000094c)
218#define ECC_ERRADDR1 (*(volatile unsigned long *)0x80000950)
219#define ECC_ERRADDR2 (*(volatile unsigned long *)0x80000954)
220#define ECC_ERRADDR3 (*(volatile unsigned long *)0x80000958)
221#define ECC_ERRADDR4 (*(volatile unsigned long *)0x8000095c)
222#define ECC_ERRDATA1 (*(volatile unsigned long *)0x80000960)
223#define ECC_ERRDATA2 (*(volatile unsigned long *)0x80000964)
224#define ECC_ERRDATA3 (*(volatile unsigned long *)0x80000968)
225#define ECC_ERRDATA4 (*(volatile unsigned long *)0x8000096c)
226#define ECC_ERR_NUM (*(volatile unsigned long *)0x80000970)
227
228#define ECC_ERRDATA(x) (*(volatile unsigned long *)(0x80000960 + (x) * 4))
229#define ECC_ERRADDR(x) (*(volatile unsigned long *)(0x80000950 + (x) * 4))
230
231/* Digital Audio Interface */
232#define DADI_L0 (*(volatile unsigned long *)0x80000000)
233#define DADI_R0 (*(volatile unsigned long *)0x80000004)
234#define DADI_L1 (*(volatile unsigned long *)0x80000008)
235#define DADI_R1 (*(volatile unsigned long *)0x8000000C)
236#define DADI_L2 (*(volatile unsigned long *)0x80000010)
237#define DADI_R2 (*(volatile unsigned long *)0x80000014)
238#define DADI_L3 (*(volatile unsigned long *)0x80000018)
239#define DADI_R3 (*(volatile unsigned long *)0x8000001c)
240
241#define DADO_L0 (*(volatile unsigned long *)0x80000020)
242#define DADO_R0 (*(volatile unsigned long *)0x80000024)
243#define DADO_L1 (*(volatile unsigned long *)0x80000028)
244#define DADO_R1 (*(volatile unsigned long *)0x8000002C)
245#define DADO_L2 (*(volatile unsigned long *)0x80000030)
246#define DADO_R2 (*(volatile unsigned long *)0x80000034)
247#define DADO_L3 (*(volatile unsigned long *)0x80000038)
248#define DADO_R3 (*(volatile unsigned long *)0x8000003c)
249
250#define DAMR (*(volatile unsigned long *)0x80000040)
251#define DAVC (*(volatile unsigned long *)0x80000044)
252
253#define DADI_L(x) (*(volatile unsigned long *)(0x80000000 + (x) * 8))
254#define DADI_R(x) (*(volatile unsigned long *)(0x80000004 + (x) * 8))
255#define DADO_L(x) (*(volatile unsigned long *)(0x80000020 + (x) * 8))
256#define DADO_R(x) (*(volatile unsigned long *)(0x80000024 + (x) * 8))
257
258/* USB 2.0 device system MMR base address */
259#define USB_BASE 0x90000b00
260
163#endif 261#endif
diff --git a/firmware/export/usb-tcc7xx.h b/firmware/export/usb-tcc7xx.h
new file mode 100644
index 0000000000..dc091ad671
--- /dev/null
+++ b/firmware/export/usb-tcc7xx.h
@@ -0,0 +1,104 @@
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 USB_TCC7XX_H
22#define USB_TCC7XX_H
23
24#define MMR_REG16(base, x) (*(volatile unsigned short *) ((base) + (x)))
25
26/* USB PHY registers */
27#define TCC7xx_USB_PHY_CFG MMR_REG16(USB_BASE, 0xc4)
28 #define TCC7xx_USB_PHY_CFG_XSEL (1<<13) /* FS/HS Transceiver enable */
29 #define TCC7xx_USB_PHY_CFG_DWS (1<<6) /* Host mode */
30 #define TCC7xx_USB_PHY_XO (1<<5) /* Enable XO_OUT */
31 #define TCC7xx_USB_PHY_CKSEL_12 0
32 #define TCC7xx_USB_PHY_CKSEL_24 1
33 #define TCC7xx_USB_PHY_CKSEL_48 2
34
35/* USB 2.0 device registers */
36#define TCC7xx_USB_INDEX MMR_REG16(USB_BASE, 0x00) /* Endpoint Index register */
37#define TCC7xx_USB_EPIF MMR_REG16(USB_BASE, 0x04) /* Endpoint interrupt flag register */
38#define TCC7xx_USB_EPIE MMR_REG16(USB_BASE, 0x08) /* Endpoint interrupt enable register */
39#define TCC7xx_USB_FUNC MMR_REG16(USB_BASE, 0x0c) /* Function address register */
40#define TCC7xx_USB_EP_DIR MMR_REG16(USB_BASE, 0x14) /* Endpoint direction register */
41#define TCC7xx_USB_TST MMR_REG16(USB_BASE, 0x14) /* Test registerregister */
42#define TCC7xx_USB_SYS_STAT MMR_REG16(USB_BASE, 0x1c) /* System status register */
43 #define TCC7xx_USB_SYS_STAT_RESET (1<<0) /* Host forced reced */
44 #define TCC7xx_USB_SYS_STAT_SUSPEND (1<<1) /* Host forced suspend */
45 #define TCC7xx_USB_SYS_STAT_RESUME (1<<2) /* Host forced resume */
46 #define TCC7xx_USB_SYS_STAT_HIGH (1<<4) /* High speed */
47 #define TCC7xx_USB_SYS_STAT_VBON (1<<8)
48 #define TCC7xx_USB_SYS_STAT_VBOF (1<<9)
49 #define TCC7xx_USB_SYS_STAT_EOERR (1<<10) /* overrun error */
50 #define TCC7xx_USB_SYS_STAT_DCERR (1<<11) /* Data CRC error */
51 #define TCC7xx_USB_SYS_STAT_TCERR (1<<12) /* Token CRC error */
52 #define TCC7xx_USB_SYS_STAT_BSERR (1<<13) /* Bit-stuff error */
53 #define TCC7xx_USB_SYS_STAT_TMERR (1<<14) /* Timeout error */
54 #define TCC7xx_USB_SYS_STAT_BAERR (1<<15) /* Byte align error */
55
56#define TCC7xx_USB_SYS_STAT_ERRORS (TCC7xx_USB_SYS_STAT_EOERR | \
57 TCC7xx_USB_SYS_STAT_DCERR | \
58 TCC7xx_USB_SYS_STAT_TCERR | \
59 TCC7xx_USB_SYS_STAT_BSERR | \
60 TCC7xx_USB_SYS_STAT_TMERR | \
61 TCC7xx_USB_SYS_STAT_BAERR)
62
63#define TCC7xx_USB_SYS_CTRL MMR_REG16(USB_BASE, 0x20) /* System control register */
64 #define TCC7xx_USB_SYS_CTRL_RESET (1<<0) /* Reset enable */
65 #define TCC7xx_USB_SYS_CTRL_SUSPEND (1<<1) /* Suspend enable */
66 #define TCC7xx_USB_SYS_CTRL_RESUME (1<<2) /* Resume enable */
67 #define TCC7xx_USB_SYS_CTRL_IPS (1<<4) /* Interrupt polarity */
68 #define TCC7xx_USB_SYS_CTRL_RFRE (1<<5) /* Reverse read data enable */
69 #define TCC7xx_USB_SYS_CTRL_SPDEN (1<<6) /* Speed detection interrupt enable */
70 #define TCC7xx_USB_SYS_CTRL_BUS16 (1<<7) /* Select bus width 8/16 */
71 #define TCC7xx_USB_SYS_CTRL_EIEN (1<<8) /* Error interrupt enable */
72 #define TCC7xx_USB_SYS_CTRL_RWDE (1<<9) /* Reverse write data enable */
73 #define TCC7xx_USB_SYS_CTRL_VBONE (1<<10) /* VBus On enable */
74 #define TCC7xx_USB_SYS_CTRL_VBOFE (1<<11) /* VBus Off enable */
75 #define TCC7xx_USB_SYS_CTRL_DUAL (1<<12) /* Dual interrupt enable*/
76 #define TCC7xx_USB_SYS_CTRL_DMAZ (1<<14) /* DMA total count zero int */
77
78#define TCC7xx_USB_EP0_STAT MMR_REG16(USB_BASE, 0x24) /* EP0 status register */
79#define TCC7xx_USB_EP0_CTRL MMR_REG16(USB_BASE, 0x28) /* EP0 control register */
80
81#define TCC7xx_USB_EP0_BUF MMR_REG16(USB_BASE, 0x60) /* EP0 buffer register */
82#define TCC7xx_USB_EP1_BUF MMR_REG16(USB_BASE, 0x64) /* EP1 buffer register */
83#define TCC7xx_USB_EP2_BUF MMR_REG16(USB_BASE, 0x68) /* EP2 buffer register */
84#define TCC7xx_USB_EP3_BUF MMR_REG16(USB_BASE, 0x6c) /* EP3 buffer register */
85
86/* Indexed registers, write endpoint number to TCC7xx_USB_INDEX */
87#define TCC7xx_USB_EP_STAT MMR_REG16(USB_BASE, 0x2c) /* EP status register */
88#define TCC7xx_USB_EP_CTRL MMR_REG16(USB_BASE, 0x30) /* EP control register */
89 #define TCC7xx_USB_EP_CTRL_CDP (1 << 2) /* Clear Data PID */
90 #define TCC7xx_USB_EP_CTRL_FLUSH (1 << 6) /* Flush FIFO */
91#define TCC7xx_USB_EP_BRCR MMR_REG16(USB_BASE, 0x34) /* EP byte read count register */
92#define TCC7xx_USB_EP_BWCR MMR_REG16(USB_BASE, 0x38) /* EP byte write count register */
93#define TCC7xx_USB_EP_MAXP MMR_REG16(USB_BASE, 0x3c) /* EP max packet register */
94
95#define TCC7xx_USB_EP_DMA_CTRL MMR_REG16(USB_BASE, 0x40) /* EP DMA control register */
96#define TCC7xx_USB_EP_DMA_TCNTR MMR_REG16(USB_BASE, 0x44) /* EP DMA transfer counter register */
97#define TCC7xx_USB_EP_DMA_FCNTR MMR_REG16(USB_BASE, 0x48) /* EP DMA fifo counter register */
98#define TCC7xx_USB_EP_DMA_TTCNTR1 MMR_REG16(USB_BASE, 0x4c) /* EP DMA total trasfer counter1 register */
99#define TCC7xx_USB_EP_DMA_TTCNTR2 MMR_REG16(USB_BASE, 0x50) /* EP DMA total trasfer counter2 register */
100#define TCC7xx_USB_EP_DMA_ADDR1 MMR_REG16(USB_BASE, 0xa0) /* EP DMA MCU addr1 register */
101#define TCC7xx_USB_EP_DMA_ADDR2 MMR_REG16(USB_BASE, 0xa4) /* EP DMA MCU addr2 register */
102#define TCC7xx_USB_EP_DMA_STAT MMR_REG16(USB_BASE, 0xc0) /* EP DMA Transfer Status register */
103#define TCC7xx_USB_DELAY_CTRL MMR_REG16(USB_BASE, 0x80) /* Delay control register */
104#endif /* USB_TCC7XX_H */
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index de688b4ff7..668c8a9d69 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -48,7 +48,7 @@ static struct mutex ata_mtx SHAREDBSS_ATTR;
48 48
49#define SECTOR_SIZE 512 49#define SECTOR_SIZE 512
50 50
51#ifdef COWON_D2 51#if defined(COWON_D2) || defined(IAUDIO_7)
52#define SEGMENT_ID_BIGENDIAN 52#define SEGMENT_ID_BIGENDIAN
53#define BLOCKS_PER_SEGMENT 4 53#define BLOCKS_PER_SEGMENT 4
54#else 54#else
diff --git a/firmware/target/arm/tcc780x/pcm-tcc780x.c b/firmware/target/arm/pcm-telechips.c
index 375274438a..a0ad00eb22 100644
--- a/firmware/target/arm/tcc780x/pcm-tcc780x.c
+++ b/firmware/target/arm/pcm-telechips.c
@@ -27,6 +27,9 @@
27#include "sound.h" 27#include "sound.h"
28#include "pcm.h" 28#include "pcm.h"
29 29
30/* Just for tests enable it to play simple tone */
31//#define PCM_TELECHIPS_TEST
32
30struct dma_data 33struct dma_data
31{ 34{
32/* NOTE: The order of size and p is important if you use assembler 35/* NOTE: The order of size and p is important if you use assembler
@@ -59,7 +62,9 @@ static unsigned long pcm_freq SHAREDDATA_ATTR = HW_SAMPR_DEFAULT; /* 44.1 is def
59 62
60void pcm_postinit(void) 63void pcm_postinit(void)
61{ 64{
62 /*audiohw_postinit();*/ 65#if defined(IAUDIO_7)
66 audiohw_postinit(); /* implemented not for all codecs */
67#endif
63 pcm_apply_settings(); 68 pcm_apply_settings();
64} 69}
65 70
@@ -73,6 +78,8 @@ const void * pcm_play_dma_get_peak_buffer(int *count)
73 78
74void pcm_play_dma_init(void) 79void pcm_play_dma_init(void)
75{ 80{
81 DAVC = 0x0; /* Digital Volume = max */
82#ifdef COWON_D2
76 /* Set DAI clock divided from PLL0 (192MHz). 83 /* Set DAI clock divided from PLL0 (192MHz).
77 The best approximation of 256*44.1kHz is 11.291MHz. */ 84 The best approximation of 256*44.1kHz is 11.291MHz. */
78 BCLKCTR &= ~DEV_DAI; 85 BCLKCTR &= ~DEV_DAI;
@@ -81,8 +88,15 @@ void pcm_play_dma_init(void)
81 88
82 /* Enable DAI block in Master mode, 256fs->32fs, 16bit LSB */ 89 /* Enable DAI block in Master mode, 256fs->32fs, 16bit LSB */
83 DAMR = 0x3c8e80; 90 DAMR = 0x3c8e80;
84 DAVC = 0x0; /* Digital Volume = max */ 91#elif defined(IAUDIO_7)
85 92 BCLKCTR &= ~DEV_DAI;
93 PCLK_DAI = (0x800b << 16) | (PCLK_DAI & 0xffff);
94 BCLKCTR |= DEV_DAI;
95 /* Master mode, 256->64fs, 16bit LSB*/
96 DAMR = 0x3cce20;
97#else
98#error "Target isn't supported"
99#endif
86 /* Set DAI interrupts as FIQs */ 100 /* Set DAI interrupts as FIQs */
87 IRQSEL = ~(DAI_RX_IRQ_MASK | DAI_TX_IRQ_MASK); 101 IRQSEL = ~(DAI_RX_IRQ_MASK | DAI_TX_IRQ_MASK);
88 102
@@ -201,7 +215,47 @@ size_t pcm_get_bytes_waiting(void)
201 return dma_play_data.size & ~3; 215 return dma_play_data.size & ~3;
202} 216}
203 217
204#if 1 218#ifdef HAVE_RECORDING
219/* TODO: implement */
220void pcm_rec_dma_init(void)
221{
222}
223
224void pcm_rec_dma_close(void)
225{
226}
227
228void pcm_rec_dma_start(void *addr, size_t size)
229{
230 (void) addr;
231 (void) size;
232}
233
234void pcm_rec_dma_stop(void)
235{
236}
237
238void pcm_rec_lock(void)
239{
240}
241
242void pcm_rec_unlock(void)
243{
244}
245
246const void * pcm_rec_dma_get_peak_buffer(int *count)
247{
248 *count = 0;
249 return NULL;
250}
251
252void pcm_record_more(void *start, size_t size)
253{
254}
255#endif
256
257#if defined(COWON_D2)
258/* TODO: hardcoded hex values differs for tcc7xx and tcc8xx */
205void fiq_handler(void) ICODE_ATTR __attribute__((naked)); 259void fiq_handler(void) ICODE_ATTR __attribute__((naked));
206void fiq_handler(void) 260void fiq_handler(void)
207{ 261{
@@ -312,3 +366,69 @@ void fiq_handler(void)
312 "subs pc, lr, #4 \n"); /* Return from FIQ */ 366 "subs pc, lr, #4 \n"); /* Return from FIQ */
313} 367}
314#endif 368#endif
369
370/* TODO: required by wm8531 codec, why not to implement */
371void i2s_reset(void)
372{
373/* DAMR = 0; */
374}
375
376#ifdef PCM_TELECHIPS_TEST
377#include "lcd.h"
378#include "sprintf.h"
379#include "backlight-target.h"
380
381static int frame = 0;
382static void test_callback_for_more(unsigned char **start, size_t *size)
383{
384 static unsigned short data[8];
385 static int cntr = 0;
386 int i;
387
388 for (i = 0; i < 8; i ++) {
389 unsigned short val;
390
391 if (0x100 == (cntr & 0x100))
392 val = 0x0fff;
393 else
394 val = 0x0000;
395 data[i] = val;
396 cntr++;
397 }
398
399 *start = data;
400 *size = sizeof(data);
401
402 frame++;
403}
404
405void pcm_telechips_test(void)
406{
407 static char buf[100];
408 unsigned char *data;
409 size_t size;
410
411 _backlight_on();
412
413 audiohw_preinit();
414 pcm_play_dma_init();
415 pcm_postinit();
416
417 audiohw_mute(false);
418 audiohw_set_master_vol(0x7f, 0x7f);
419
420 pcm_callback_for_more = test_callback_for_more;
421 test_callback_for_more(&data, &size);
422 pcm_play_dma_start(data, size);
423
424 while (1) {
425 int line = 0;
426 lcd_clear_display();
427 lcd_puts(0, line++, __func__);
428 snprintf(buf, sizeof(buf), "frame: %d", frame);
429 lcd_puts(0, line++, buf);
430 lcd_update();
431 sleep(1);
432 }
433}
434#endif
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c
index 37bd15398b..f48528639e 100644
--- a/firmware/target/arm/tcc77x/adc-tcc77x.c
+++ b/firmware/target/arm/tcc77x/adc-tcc77x.c
@@ -104,6 +104,9 @@ unsigned short adc_read(int channel)
104 104
105void adc_init(void) 105void adc_init(void)
106{ 106{
107 /* Initialize ADC clocks */
108 PCLKCFG6 = (PCLKCFG6 & 0xffff0000) | 4004;
109
107 ADCCON = (1<<4); /* Leave standby mode */ 110 ADCCON = (1<<4); /* Leave standby mode */
108 111
109 /* IRQ enable, auto power-down, single-mode */ 112 /* IRQ enable, auto power-down, single-mode */
diff --git a/firmware/target/arm/tcc77x/app.lds b/firmware/target/arm/tcc77x/app.lds
index 03a427f76b..c50367cb08 100644
--- a/firmware/target/arm/tcc77x/app.lds
+++ b/firmware/target/arm/tcc77x/app.lds
@@ -1,21 +1,25 @@
1#include "config.h" 1#include "config.h"
2 2
3ENTRY(start) 3ENTRY(start)
4
5OUTPUT_FORMAT(elf32-littlearm) 4OUTPUT_FORMAT(elf32-littlearm)
6OUTPUT_ARCH(arm) 5OUTPUT_ARCH(arm)
7STARTUP(target/arm/tcc77x/crt0.o) 6STARTUP(target/arm/tcc77x/crt0.o)
8 7
9#define PLUGINSIZE PLUGIN_BUFFER_SIZE 8#define PLUGINSIZE PLUGIN_BUFFER_SIZE
10#define CODECSIZE CODEC_SIZE 9#define CODECSIZE CODEC_SIZE
10
11#ifdef DEBUG
12#define STUBOFFSET 0x10000
13#else
14#define STUBOFFSET 0
15#endif
11 16
12#include "imx31l.h" 17#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
13
14#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
15 18
16#define DRAMORIG 0x20000000 19#define DRAMORIG 0x20000000
17#define IRAMORIG 0x00000000 20#define IRAMORIG 0x00000000
18#define IRAMSIZE IRAM_SIZE 21#define IRAMSIZE 64K
22
19 23
20/* End of the audio buffer, where the codec buffer starts */ 24/* End of the audio buffer, where the codec buffer starts */
21#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 25#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
@@ -23,100 +27,58 @@ STARTUP(target/arm/tcc77x/crt0.o)
23/* Where the codec buffer ends, and the plugin buffer starts */ 27/* Where the codec buffer ends, and the plugin buffer starts */
24#define ENDADDR (ENDAUDIOADDR + CODECSIZE) 28#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
25 29
30
26MEMORY 31MEMORY
27{ 32{
28 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE 33#ifdef TCCBOOT
29 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE 34 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
35#else
36 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
37#endif
38 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
30} 39}
31 40
32SECTIONS 41SECTIONS
33{ 42{
34 .text : 43 .text : {
35 { 44 loadaddress = .;
36 loadaddress = .; 45 _loadaddress = .;
37 _loadaddress = .; 46 . = ALIGN(0x200);
38 . = ALIGN(0x200);
39 *(.init.text) 47 *(.init.text)
48 *(.text)
40 *(.text*) 49 *(.text*)
41 *(.glue_7) 50 *(.glue_7)
42 *(.glue_7t) 51 *(.glue_7t)
43 . = ALIGN(0x4); 52 } > DRAM
44 } > DRAM
45
46 .rodata :
47 {
48 *(.rodata) /* problems without this, dunno why */
49 *(.rodata*)
50 *(.rodata.str1.1)
51 *(.rodata.str1.4)
52 . = ALIGN(0x4);
53 53
54 /* Pseudo-allocate the copies of the data sections */ 54 .data : {
55 _datacopy = .;
56 } > DRAM
57
58 /* TRICK ALERT! For RAM execution, we put the .data section at the
59 same load address as the copy. Thus, we don't waste extra RAM
60 when we don't actually need the copy. */
61 .data : AT ( _datacopy )
62 {
63 _datastart = .;
64 *(.data*)
65 . = ALIGN(0x4);
66 _dataend = .;
67 } > DRAM
68
69 /DISCARD/ :
70 {
71 *(.eh_frame)
72 }
73
74 .vectors 0x0 :
75 {
76 _vectorsstart = .;
77 *(.vectors);
78 _vectorsend = .;
79 } AT> DRAM
80
81 _vectorscopy = LOADADDR(.vectors);
82
83 .iram :
84 {
85 _iramstart = .;
86 *(.icode) 55 *(.icode)
87 *(.irodata) 56 *(.irodata)
88 *(.idata) 57 *(.idata)
58 *(.data*)
59 *(.rodata.*)
60 *(.rodata)
89 . = ALIGN(0x4); 61 . = ALIGN(0x4);
90 _iramend = .; 62 _dataend = . ;
91 } > DRAM
92
93 _iramcopy = LOADADDR(.iram);
94
95 .ibss (NOLOAD) :
96 {
97 _iedata = .;
98 *(.ibss)
99 . = ALIGN(0x4);
100 _iend = .;
101 } > DRAM 63 } > DRAM
102 64
103 .stack : 65 .stack :
104 { 66 {
105 *(.stack) 67 *(.stack)
106 stackbegin = .; 68 _stackbegin = .;
107 . += 0x2000; 69 stackbegin = .;
108 stackend = .; 70 . += 0x2000;
109 } > DRAM 71 _stackend = .;
110 72 stackend = .;
111 .bss :
112 {
113 _edata = .;
114 *(.bss*)
115 *(COMMON)
116 . = ALIGN(0x4);
117 _end = .;
118 } > DRAM 73 } > DRAM
119 74
75 .bss : {
76 _edata = .;
77 *(.bss*);
78 *(.ibss);
79 *(COMMON)
80 _end = .;
81 } > DRAM
120 .audiobuf ALIGN(4) : 82 .audiobuf ALIGN(4) :
121 { 83 {
122 _audiobuffer = .; 84 _audiobuffer = .;
@@ -128,7 +90,7 @@ SECTIONS
128 audiobufend = .; 90 audiobufend = .;
129 _audiobufend = .; 91 _audiobufend = .;
130 } > DRAM 92 } > DRAM
131 93
132 .codec ENDAUDIOADDR: 94 .codec ENDAUDIOADDR:
133 { 95 {
134 codecbuf = .; 96 codecbuf = .;
@@ -139,6 +101,5 @@ SECTIONS
139 { 101 {
140 _pluginbuf = .; 102 _pluginbuf = .;
141 pluginbuf = .; 103 pluginbuf = .;
142 } 104 }
143} 105}
144
diff --git a/firmware/target/arm/tcc77x/boot.lds b/firmware/target/arm/tcc77x/boot.lds
index 890c4ec785..2fd6964d57 100644
--- a/firmware/target/arm/tcc77x/boot.lds
+++ b/firmware/target/arm/tcc77x/boot.lds
@@ -14,7 +14,11 @@ STARTUP(target/arm/tcc77x/crt0.o)
14 14
15MEMORY 15MEMORY
16{ 16{
17#ifdef TCCBOOT
17 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000 18 DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
19#else
20 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
21#endif
18 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE 22 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
19} 23}
20 24
@@ -34,6 +38,7 @@ SECTIONS
34 *(.idata) 38 *(.idata)
35 *(.data*) 39 *(.data*)
36 *(.rodata.*) 40 *(.rodata.*)
41 *(.rodata)
37 . = ALIGN(0x4); 42 . = ALIGN(0x4);
38 _dataend = . ; 43 _dataend = . ;
39 } > DRAM 44 } > DRAM
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
index e144c16fae..569930352a 100644
--- a/firmware/target/arm/tcc77x/crt0.S
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -82,12 +82,15 @@ start_loc:
82 82
83#ifdef TCCBOOT 83#ifdef TCCBOOT
84 mov r0, #0x80000000 84 mov r0, #0x80000000
85#ifdef LOGIK_DAX 85#if defined(LOGIK_DAX)
86 ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */ 86 ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
87 tst r0, #0x2 87 tst r0, #0x2
88#elif defined(SANSA_M200) 88#elif defined(SANSA_M200)
89 ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */ 89 ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
90 tst r0, #0x200 90 tst r0, #0x200
91#elif defined(IAUDIO_7)
92 ldr r0, [r0, #0x300] /* Hold button is !GPIO A, pin 0x2 */
93 tst r0, #0x2
91#else 94#else
92 #error No bootup key detection implemented for this target 95 #error No bootup key detection implemented for this target
93#endif 96#endif
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c
index 4566c7ea73..203a6010ce 100644
--- a/firmware/target/arm/tcc77x/debug-tcc77x.c
+++ b/firmware/target/arm/tcc77x/debug-tcc77x.c
@@ -56,8 +56,11 @@ bool __dbg_hw_info(void)
56 button = button_get(false); 56 button = button_get(false);
57 57
58 button &= ~BUTTON_REPEAT; 58 button &= ~BUTTON_REPEAT;
59 59#ifdef BUTTON_SELECT
60 if (button == BUTTON_SELECT) 60 if (button == BUTTON_SELECT)
61#else
62 if (button == BUTTON_STOP)
63#endif
61 done=true; 64 done=true;
62 65
63 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", 66 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
new file mode 100644
index 0000000000..1916d93598
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/adc-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#define NUM_ADC_CHANNELS 8
25
26#define ADC_BUTTONS 0
27
28#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
new file mode 100644
index 0000000000..fa165d9d0d
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
@@ -0,0 +1,124 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "cpu.h"
24#include "button.h"
25
26#include "ata2501.h"
27
28#define STB (1<<5)
29#define SDATA (1<<4)
30#define RESET (1<<6)
31#define SIFMD (1<<7)
32#define STB_DELAY 200
33
34#define udelay _udelay
35
36/* do we really need it? */
37static void _udelay(int cycles)
38{
39 cycles /= 8;
40 while (cycles--) {
41 asm("nop;nop;");
42 }
43}
44
45/*
46 TODO: sensitivity using GPIOS
47*/
48void ata2501_init(void)
49{
50 GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
51 GPIOD_DIR &= ~(SDATA);
52
53 GPIOD &= ~RESET;
54 udelay(1000);
55
56 GPIOD |= RESET;
57
58 GPIOD &= ~STB;
59
60#if 1
61 GPIOD &= ~((1 << 9) | (1 << 8));
62 GPIOD |= ((1 << 8) | SIFMD) | (1 << 9);
63#else
64 GPIOD |= ((1 << 9) | (1 << 8));
65 GPIOD &= ~(SIFMD);
66#endif
67}
68
69unsigned short ata2501_read(void)
70{
71 unsigned short ret = 0;
72 int i;
73
74 for (i = 0; i < 12; i++) {
75 GPIOD |= STB;
76 udelay(50);
77
78 ret <<= 1;
79 if (GPIOD & SDATA)
80 ret |= 1;
81 udelay(50);
82 GPIOD &= ~STB;
83 udelay(100);
84 }
85
86 return ret;
87}
88
89#define ATA2501_TEST
90#ifdef ATA2501_TEST
91#include "lcd.h"
92#include "sprintf.h"
93
94static
95void bits(char *str, unsigned short val)
96{
97 int i;
98
99 for (i = 0; i < 12; i++)
100 str[i] = (val & (1 << i)) ? '1' : '0';
101 str[i] = 0;
102}
103
104void ata2501_test(void)
105{
106 char buf[100];
107 ata2501_init();
108
109 while (1) {
110 unsigned short data;
111 int i, line = 0;
112
113 data = ata2501_read();
114 lcd_clear_display();
115 lcd_puts(0, line++, "ATA2501 test");
116
117 bits(buf, data);
118 lcd_puts(0, line++, buf);
119
120 lcd_update();
121 udelay(2000);
122 }
123}
124#endif
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
new file mode 100644
index 0000000000..465d0b199c
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _ATA2501_H_
22#define _ATA2501_H_
23
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
new file mode 100644
index 0000000000..4e7f58df47
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c
@@ -0,0 +1,99 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "system.h"
22#include "cpu.h"
23#include "audio.h"
24#include "sound.h"
25
26int audio_channels = 2;
27int audio_output_source = AUDIO_SRC_PLAYBACK;
28
29void audiohw_enable_output(bool on)
30{
31 (void) on;
32}
33
34void audio_set_output_source(int source)
35{
36 int oldmode = set_fiq_status(FIQ_DISABLED);
37
38 if ((unsigned)source >= AUDIO_NUM_SOURCES)
39 source = AUDIO_SRC_PLAYBACK;
40
41 audio_output_source = source;
42 set_fiq_status(oldmode);
43}
44
45void audio_input_mux(int source, unsigned flags)
46{
47 static int last_source = AUDIO_SRC_PLAYBACK;
48 static bool last_recording = false;
49 bool recording = flags & SRCF_RECORDING;
50
51 switch (source)
52 {
53 default: /* playback - no recording */
54 source = AUDIO_SRC_PLAYBACK;
55 case AUDIO_SRC_PLAYBACK:
56 audio_channels = 2;
57 if (source != last_source)
58 {
59 audiohw_set_monitor(false);
60 /* audiohw_disable_recording();*/
61 }
62 break;
63
64 case AUDIO_SRC_MIC: /* recording only */
65 GPIOD |= 0x1;
66
67 audio_channels = 1;
68 if (source != last_source)
69 {
70 /*audiohw_set_monitor(false);
71 audiohw_enable_recording(true); /. source mic */
72 }
73 break;
74
75 case AUDIO_SRC_FMRADIO: /* recording and playback */
76 GPIOD &= ~0x1;
77
78 audio_channels = 2;
79
80 if (source == last_source && recording == last_recording)
81 break;
82
83 last_recording = recording;
84
85 if (recording)
86 {
87 /*audiohw_set_monitor(false);
88 audiohw_enable_recording(false);*/
89 }
90 else
91 {
92 /*audiohw_disable_recording(); */
93 audiohw_set_monitor(true); /* line 1 analog audio path */
94 }
95 break;
96 } /* end switch */
97
98 last_source = source;
99} /* audio_input_mux */
diff --git a/firmware/target/arm/tcc77x/pcm-tcc77x.c b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
index 184a264858..597583b16f 100644
--- a/firmware/target/arm/tcc77x/pcm-tcc77x.c
+++ b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2008 by [whoever fills in these functions] 10 * Copyright (C) 2008 Vitja Makarov
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -18,60 +18,29 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "system.h" 21#ifndef BACKLIGHT_TARGET_H
22#include "kernel.h" 22#define BACKLIGHT_TARGET_H
23#include "logf.h"
24#include "audio.h"
25#include "sound.h"
26#include "file.h"
27 23
28void pcm_postinit(void) 24#include <stdbool.h>
29{ 25#include "tcc77x.h"
30}
31
32const void * pcm_play_dma_get_peak_buffer(int *count)
33{
34 (void)count;
35 return 0;
36}
37
38void pcm_play_dma_init(void)
39{
40}
41
42void pcm_apply_settings(void)
43{
44}
45 26
46void pcm_set_frequency(unsigned int frequency) 27void power_touch_panel(bool on);
47{
48 (void)frequency;
49}
50
51void pcm_play_dma_start(const void *addr, size_t size)
52{
53 (void)addr;
54 (void)size;
55}
56
57void pcm_play_dma_stop(void)
58{
59}
60
61void pcm_play_lock(void)
62{
63}
64 28
65void pcm_play_unlock(void) 29static inline bool _backlight_init(void)
66{ 30{
31 GPIOD_DIR |= 0x2;
32 return true;
67} 33}
68 34
69void pcm_play_dma_pause(bool pause) 35static inline void _backlight_on(void)
70{ 36{
71 (void)pause; 37 GPIOD |= 0x2;
38 power_touch_panel(true);
72} 39}
73 40
74size_t pcm_get_bytes_waiting(void) 41static inline void _backlight_off(void)
75{ 42{
76 return 0; 43 GPIOD &= ~0x2;
44 power_touch_panel(false);
77} 45}
46#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
new file mode 100644
index 0000000000..3aad4f75a4
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "cpu.h"
23#include "button.h"
24#include "adc.h"
25
26#include "button-target.h"
27#include "ata2501.h"
28
29void button_init_device(void)
30{
31 ata2501_init();
32}
33
34/*
35 touchpad:
36 0: stop
37 1-8: between next & prev
38 9: play
39 10: next
40 11: prev
41*/
42
43int button_read_device(void)
44{
45 int btn = BUTTON_NONE;
46 int adc;
47 int sensor;
48
49 if (button_hold())
50 return BUTTON_NONE;
51
52 adc = adc_read(0);
53 sensor = ata2501_read();
54
55 if (0 == (GPIOA & 4))
56 btn |= BUTTON_POWER;
57
58 /* seems they can't be hold together */
59 if (adc < 0x120)
60 btn |= BUTTON_VOLUP;
61 else if (adc < 0x270)
62 btn |= BUTTON_VOLDOWN;
63 else if (adc < 0x300)
64 btn |= BUTTON_MENU;
65
66 if (sensor & (1 << 0))
67 btn |= BUTTON_STOP;
68 if (sensor & (1 << 9))
69 btn |= BUTTON_PLAY;
70 if (sensor & ((1 << 10) | 0x1c0))
71 btn |= BUTTON_RIGHT;
72 if (sensor & ((1 << 11) | 0xe))
73 btn |= BUTTON_LEFT;
74
75 return btn;
76}
77
78bool button_hold(void)
79{
80 return !(GPIOA & 0x2);
81}
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h
new file mode 100644
index 0000000000..fafaf4a303
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/button-target.h
@@ -0,0 +1,57 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _IAUDIO7_BUTTON_TARGET_H_
22#define _IAUDIO7_BUTTON_TARGET_H_
23
24#include <stdbool.h>
25#include "config.h"
26
27#define HAS_BUTTON_HOLD
28
29bool button_hold(void);
30void button_init_device(void);
31int button_read_device(void);
32
33/* Main unit's buttons */
34#define BUTTON_POWER 0x00000001
35#define BUTTON_VOLUP 0x00000002
36#define BUTTON_VOLDOWN 0x00000004
37#define BUTTON_MENU 0x00000008
38
39#define BUTTON_LEFT 0x00000010
40#define BUTTON_RIGHT 0x00000020
41#define BUTTON_PLAY 0x00000040
42#define BUTTON_STOP 0x00000080
43
44#define BUTTON_ON BUTTON_POWER
45
46#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \
47 BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \
48 BUTTON_PLAY|BUTTON_STOP)
49
50/* No remote */
51#define BUTTON_REMOTE 0
52
53/* Software power-off */
54#define POWEROFF_BUTTON BUTTON_POWER
55#define POWEROFF_COUNT 10
56
57#endif /* _IAUDIO7_BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
new file mode 100644
index 0000000000..bbc20b6860
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
@@ -0,0 +1,252 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/*
23 Thanks Hein-Pieter van Braam for initial work.
24
25 Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov
26 */
27
28#include <config.h>
29
30#include <kernel.h>
31#include <cpu.h>
32#include <lcd.h>
33#include <system-target.h>
34
35#include "hd66789r.h"
36
37static bool display_on = false; /* is the display turned on? */
38
39static inline void lcd_write_reg(int reg, int data)
40{
41 GPIOA &= ~0x400;
42 outw(0, 0x50010000);
43 outw(reg << 1, 0x50010000);
44 GPIOA |= 0x400;
45
46 outw((data & 0xff00) >> 7, 0x50010008);
47 outw((data << 24) >> 23, 0x50010008);
48}
49
50static void lcd_write_cmd(int reg)
51{
52 GPIOA &= ~0x400;
53 outw(0, 0x50010000);
54 outw(reg << 1, 0x50010000);
55 GPIOA |= 0x400;
56}
57
58/* Do what OF do */
59static void lcd_delay(int x)
60{
61 int i;
62
63 x *= 0xc35;
64 for (i = 0; i < x * 8; i++) {
65 }
66}
67
68
69static void _display_on(void)
70{
71 GPIOA_DIR |= 0x8000 | 0x400;
72 GPIOA |= 0x8000;
73
74 /* power setup */
75 lcd_write_reg(R_START_OSC, 0x0001);
76 lcd_delay(0xf);
77 lcd_write_reg(R_DISP_CONTROL1, 0x000);
78 lcd_delay(0xa);
79 lcd_write_reg(R_POWER_CONTROL2, 0x0002);
80 lcd_write_reg(R_POWER_CONTROL3, 0x000a);
81 lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
82 lcd_write_reg(R_POWER_CONTROL1, 0x0004);
83 lcd_write_reg(R_POWER_CONTROL1, 0x0134);
84 lcd_write_reg(R_POWER_CONTROL2, 0x0111);
85 lcd_write_reg(R_POWER_CONTROL3, 0x001c);
86 lcd_delay(0x28);
87 lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
88 lcd_write_reg(R_POWER_CONTROL1, 0x0510);
89 lcd_delay(0x3c);
90
91 /* lcd init 2 */
92 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
93 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
94 lcd_write_reg(R_ENTRY_MODE, 0x1038);
95 lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
96 lcd_write_reg(R_DISP_CONTROL3, 0x0000);
97 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
98 lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
99 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
100 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
101 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
102 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
103 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
104 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
105 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
106 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
107 lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
108 lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
109 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
110 lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
111 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
112 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
113 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
114
115 /* lcd init 3 */
116 lcd_write_reg(R_POWER_CONTROL1, 0x4510);
117 lcd_write_reg(R_DISP_CONTROL1, 0x0005);
118 lcd_delay(0x28);
119 lcd_write_reg(R_DISP_CONTROL1, 0x0025);
120 lcd_write_reg(R_DISP_CONTROL1, 0x0027);
121 lcd_delay(0x28);
122 lcd_write_reg(R_DISP_CONTROL1, 0x0037);
123
124 display_on = true;
125}
126
127void lcd_init_device(void)
128{
129 /* Configure external memory banks */
130 CSCFG1 = 0x3d500023;
131
132 /* may be reset */
133 GPIOA |= 0x8000;
134
135 _display_on();
136}
137
138void lcd_enable(bool on)
139{
140 if (display_on == on)
141 return;
142
143 if (on) {
144 _display_on();
145// lcd_call_enable_hook();
146 } else {
147 /** Off sequence according to datasheet, p. 130 **/
148 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
149 lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
150 sleep(2);
151
152 lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
153 sleep(2);
154
155 lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
156
157 lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
158 lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
159 lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
160
161 /* datasheet p. 131 */
162 lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
163
164 display_on = false;
165 }
166}
167
168bool lcd_enabled(void)
169{
170 return display_on;
171}
172
173
174#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
175
176
177void lcd_update(void)
178{
179 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
180}
181
182/* todo: need tests */
183void lcd_update_rect(int sx, int sy, int width, int height)
184{
185 int x, y;
186
187 if (!display_on)
188 return;
189
190 if (width <= 0 || height <= 0) /* nothing to do */
191 return;
192
193 width += sx;
194 height += sy;
195
196 if (width > LCD_WIDTH)
197 width = LCD_WIDTH;
198 if (height > LCD_HEIGHT)
199 height = LCD_HEIGHT;
200
201 lcd_write_reg(R_ENTRY_MODE, 0x1028);
202 /* set update window */
203 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
204 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
205 lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
206 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
207
208 for (y = sy; y < height; y++) {
209 for (x = sx; x < width; x++) {
210 fb_data c;
211 unsigned long color;
212
213 c = lcd_framebuffer[y][x];
214 color =
215 ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
216 2);
217
218 /* TODO: our color is 18-bit */
219 outw((color >> 9) & 0x1ff, 0x50010008);
220 outw((color) & 0x1ff, 0x50010008);
221 }
222 }
223}
224
225void lcd_set_contrast(int val)
226{
227 (void) val;
228}
229
230void lcd_set_invert_display(bool yesno)
231{
232 (void) yesno;
233}
234
235void lcd_set_flip(bool yesno)
236{
237 (void) yesno;
238}
239
240/* TODO: implement me */
241void lcd_blit_yuv(unsigned char *const src[3],
242 int src_x, int src_y, int stride,
243 int x, int y, int width, int height)
244{
245 if (!display_on)
246 return;
247
248 width &= ~1; /* stay on the safe side */
249 height &= ~1;
250
251 panicf("%s", __func__);
252}
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
new file mode 100644
index 0000000000..ef012cbbdf
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
@@ -0,0 +1,146 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22
23#include "config.h"
24#include "cpu.h"
25#include "kernel.h"
26#include "system.h"
27#include "power.h"
28
29#include "pcf50606.h"
30
31void power_init(void)
32{
33 pcf50606_write(PCF5060X_DCDC1, 0x90);
34 pcf50606_write(PCF5060X_DCDC2, 0x48);
35 pcf50606_write(PCF5060X_DCDC3, 0xfc);
36 pcf50606_write(PCF5060X_DCDC4, 0xb1);
37
38 pcf50606_write(PCF5060X_IOREGC, 0xe9);
39 /* 3.3V, touch-panel */
40 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
41 pcf50606_write(PCF5060X_D2REGC1, 0xf2);
42 pcf50606_write(PCF5060X_D3REGC1, 0xf5);
43
44 pcf50606_write(PCF5060X_LPREGC1, 0x00);
45 pcf50606_write(PCF5060X_LPREGC2, 0x02);
46
47 pcf50606_write(PCF5060X_DCUDC1, 0xe6);
48 pcf50606_write(PCF5060X_DCUDC2, 0x30);
49
50 pcf50606_write(PCF5060X_DCDEC1, 0xe7);
51 pcf50606_write(PCF5060X_DCDEC2, 0x02);
52
53 pcf50606_write(PCF5060X_INT1M, 0x5b);
54 pcf50606_write(PCF5060X_INT1M, 0xaf);
55 pcf50606_write(PCF5060X_INT1M, 0x8f);
56
57 pcf50606_write(PCF5060X_OOCC1, 0x40);
58 pcf50606_write(PCF5060X_OOCC2, 0x05);
59
60 pcf50606_write(PCF5060X_MBCC3, 0x3a);
61 pcf50606_write(PCF5060X_GPOC1, 0x00);
62 pcf50606_write(PCF5060X_BBCC, 0xf8);
63}
64
65/* Control leds on ata2501 board */
66void power_touch_panel(bool on)
67{
68 if (on)
69 pcf50606_write(PCF5060X_D1REGC1, 0xf8);
70 else
71 pcf50606_write(PCF5060X_D1REGC1, 0x00);
72}
73
74void ide_power_enable(bool on)
75{
76}
77
78bool ide_powered(void)
79{
80 return true;
81}
82
83void power_off(void)
84{
85 /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
86 pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
87}
88
89#if CONFIG_TUNER
90#include "tuner.h"
91
92/** Tuner **/
93static bool powered = false;
94
95#define TUNNER_CLK (1 << 5)
96#define TUNNER_DATA (1 << 6)
97#define TUNNER_NR_W (1 << 7)
98
99bool tuner_power(bool status)
100{
101 bool old_status;
102 lv24020lp_lock();
103
104 old_status = powered;
105
106 if (status != old_status)
107 {
108 if (status)
109 {
110 /* When power up, host should initialize the 3-wire bus
111 in host read mode: */
112
113 /* 1. Set direction of the DATA-line to input-mode. */
114 GPIOA_DIR &= ~TUNNER_DATA;
115
116 /* 2. Drive NR_W low */
117 GPIOA &= ~TUNNER_NR_W;
118 GPIOA_DIR |= TUNNER_NR_W;
119
120 /* 3. Drive CLOCK high */
121 GPIOA |= TUNNER_CLK;
122 GPIOA_DIR |= TUNNER_CLK;
123
124 lv24020lp_power(true);
125 }
126 else
127 {
128 lv24020lp_power(false);
129
130 /* set all as inputs */
131 GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
132 }
133
134 powered = status;
135 }
136
137 lv24020lp_unlock();
138 return old_status;
139}
140
141#endif /* CONFIG_TUNER */
142
143bool charger_inserted(void)
144{
145 return (GPIOA & 0x1) ? true : false;
146}
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
index c50a8a6651..2c8959fded 100644
--- a/firmware/target/arm/tcc77x/system-tcc77x.c
+++ b/firmware/target/arm/tcc77x/system-tcc77x.c
@@ -26,6 +26,7 @@
26/* Externally defined interrupt handlers */ 26/* Externally defined interrupt handlers */
27extern void TIMER(void); 27extern void TIMER(void);
28extern void ADC(void); 28extern void ADC(void);
29extern void USBD_IRQ(void);
29 30
30void irq(void) 31void irq(void)
31{ 32{
@@ -36,14 +37,22 @@ void irq(void)
36 TIMER(); 37 TIMER();
37 else if (irq & ADC_IRQ_MASK) 38 else if (irq & ADC_IRQ_MASK)
38 ADC(); 39 ADC();
40#ifdef HAVE_USBSTACK
41 else if (irq & USBD_IRQ_MASK)
42 USBD_IRQ();
43#endif
39 else 44 else
40 panicf("Unhandled IRQ 0x%08X", irq); 45 panicf("Unhandled IRQ 0x%08X", irq);
41} 46}
42 47
48void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked));
49
50#ifdef BOOTLOADER
43void fiq_handler(void) 51void fiq_handler(void)
44{ 52{
45 /* TODO */ 53 /* TODO */
46} 54}
55#endif
47 56
48void system_reboot(void) 57void system_reboot(void)
49{ 58{
@@ -94,7 +103,7 @@ static void gpio_init(void)
94 GPIOC = 0; 103 GPIOC = 0;
95 GPIOD = 0x180; 104 GPIOD = 0x180;
96 GPIOE = 0; 105 GPIOE = 0;
97 GPIOA_DIR = 0x84b0 106 GPIOA_DIR = 0x84b0;
98 GPIOB_DIR = 0x80800; 107 GPIOB_DIR = 0x80800;
99 GPIOC_DIR = 0x2000000; 108 GPIOC_DIR = 0x2000000;
100 GPIOD_DIR = 0x3e3; 109 GPIOD_DIR = 0x3e3;
diff --git a/firmware/target/arm/tcc77x/usb-tcc77x.c b/firmware/target/arm/tcc77x/usb-tcc77x.c
index 85c8bed3ef..9cfcb503e0 100644
--- a/firmware/target/arm/tcc77x/usb-tcc77x.c
+++ b/firmware/target/arm/tcc77x/usb-tcc77x.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2008 by [whoever fills in these functions] 10 * Copyright (C) 2008 by Vitja Makarov
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -21,9 +21,15 @@
21 21
22#include "config.h" 22#include "config.h"
23#include "usb.h" 23#include "usb.h"
24#include "system.h"
25#include "usb-tcc7xx.h"
24 26
25void usb_init_device(void) 27void usb_init_device(void)
26{ 28{
29 /* simply switch USB off for now */
30 BCLKCTR |= DEV_USBD;
31 TCC7xx_USB_PHY_CFG = 0x3e4c;
32 BCLKCTR &= ~DEV_USBD;
27} 33}
28 34
29void usb_enable(bool on) 35void usb_enable(bool on)
diff --git a/firmware/target/arm/wmcodec-telechips.c b/firmware/target/arm/wmcodec-telechips.c
index 985a72dccc..5fcc46154b 100644
--- a/firmware/target/arm/wmcodec-telechips.c
+++ b/firmware/target/arm/wmcodec-telechips.c
@@ -34,6 +34,8 @@
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)
38#define I2C_AUDIO_ADDRESS 0x34
37#else 39#else
38#error wmcodec not implemented for this target! 40#error wmcodec not implemented for this target!
39#endif 41#endif
@@ -41,6 +43,9 @@
41 43
42void audiohw_init(void) 44void audiohw_init(void)
43{ 45{
46#if defined(HAVE_WM8731) || defined(HAVE_WM8751)
47 audiohw_preinit();
48#endif
44} 49}
45 50
46void wmcodec_write(int reg, int data) 51void wmcodec_write(int reg, int data)