summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c61
-rw-r--r--firmware/target/arm/wmcodec-pp.c156
2 files changed, 217 insertions, 0 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c
new file mode 100644
index 0000000000..a793f5a1f4
--- /dev/null
+++ b/firmware/target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c
@@ -0,0 +1,61 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Gigabeat specific code for the Wolfson codec
11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
14 *
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
16 *
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
18 *
19 * All files in this archive are subject to the GNU General Public License.
20 * See the file COPYING in the source tree root for full license agreement.
21 *
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
24 *
25 ****************************************************************************/
26#include "lcd.h"
27#include "cpu.h"
28#include "kernel.h"
29#include "thread.h"
30#include "power.h"
31#include "debug.h"
32#include "system.h"
33#include "sprintf.h"
34#include "button.h"
35#include "string.h"
36#include "file.h"
37#include "buffer.h"
38#include "audio.h"
39#include "i2c.h"
40/*
41 * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
42 */
43void i2s_reset(void)
44{
45}
46
47/*
48 * Initialise the WM8975 for playback via headphone and line out.
49 * Note, I'm using the WM8750 datasheet as its apparently close.
50 */
51int wmcodec_init(void) {
52 /* reset I2C */
53 i2c_init();
54
55 return 0;
56}
57
58void wmcodec_write(int reg, int data)
59{
60 i2c_send(0x34, (reg<<1) | ((data&0x100)>>8),data&0xff);
61}
diff --git a/firmware/target/arm/wmcodec-pp.c b/firmware/target/arm/wmcodec-pp.c
new file mode 100644
index 0000000000..e9626220e7
--- /dev/null
+++ b/firmware/target/arm/wmcodec-pp.c
@@ -0,0 +1,156 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Portalplayer specific code for Wolfson audio codecs
11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
14 *
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
16 *
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
18 *
19 * All files in this archive are subject to the GNU General Public License.
20 * See the file COPYING in the source tree root for full license agreement.
21 *
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
24 *
25 ****************************************************************************/
26#include "lcd.h"
27#include "cpu.h"
28#include "kernel.h"
29#include "thread.h"
30#include "power.h"
31#include "debug.h"
32#include "system.h"
33#include "sprintf.h"
34#include "button.h"
35#include "string.h"
36#include "file.h"
37#include "buffer.h"
38#include "audio.h"
39
40#if CONFIG_CPU == PP5020
41#include "i2c-pp5020.h"
42#elif CONFIG_CPU == PP5002
43#include "i2c-pp5002.h"
44#endif
45
46/*
47 * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
48 */
49void i2s_reset(void)
50{
51#if CONFIG_CPU == PP5020
52 /* I2S soft reset */
53 outl(inl(0x70002800) | 0x80000000, 0x70002800);
54 outl(inl(0x70002800) & ~0x80000000, 0x70002800);
55
56 /* BIT.FORMAT [11:10] = I2S (default) */
57 outl(inl(0x70002800) & ~0xc00, 0x70002800);
58 /* BIT.SIZE [9:8] = 16bit (default) */
59 outl(inl(0x70002800) & ~0x300, 0x70002800);
60
61 /* FIFO.FORMAT [6:4] = 32 bit LSB */
62 /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
63 outl(inl(0x70002800) | 0x30, 0x70002800);
64
65 /* RX_ATN_LVL=1 == when 12 slots full */
66 /* TX_ATN_LVL=1 == when 12 slots empty */
67 outl(inl(0x7000280c) | 0x33, 0x7000280c);
68
69 /* Rx.CLR = 1, TX.CLR = 1 */
70 outl(inl(0x7000280c) | 0x1100, 0x7000280c);
71#elif CONFIG_CPU == PP5002
72 /* I2S device reset */
73 outl(inl(0xcf005030) | 0x80, 0xcf005030);
74 outl(inl(0xcf005030) & ~0x80, 0xcf005030);
75
76 /* I2S controller enable */
77 outl(inl(0xc0002500) | 0x1, 0xc0002500);
78
79 /* BIT.FORMAT [11:10] = I2S (default) */
80 /* BIT.SIZE [9:8] = 24bit */
81 /* FIFO.FORMAT = 24 bit LSB */
82
83 /* reset DAC and ADC fifo */
84 outl(inl(0xc000251c) | 0x30000, 0xc000251c);
85#endif
86}
87
88/*
89 * Initialise the WM8975 for playback via headphone and line out.
90 * Note, I'm using the WM8750 datasheet as its apparently close.
91 */
92int wmcodec_init(void) {
93 /* reset I2C */
94 i2c_init();
95
96#if CONFIG_CPU == PP5020
97 /* normal outputs for CDI and I2S pin groups */
98 outl(inl(0x70000020) & ~0x300, 0x70000020);
99
100 /*mini2?*/
101 outl(inl(0x70000010) & ~0x3000000, 0x70000010);
102 /*mini2?*/
103
104 /* device reset */
105 outl(inl(0x60006004) | 0x800, 0x60006004);
106 outl(inl(0x60006004) & ~0x800, 0x60006004);
107
108 /* device enable */
109 outl(inl(0x6000600C) | 0x807, 0x6000600C);
110
111 /* enable external dev clock clocks */
112 outl(inl(0x6000600c) | 0x2, 0x6000600c);
113
114 /* external dev clock to 24MHz */
115 outl(inl(0x70000018) & ~0xc, 0x70000018);
116#else
117 /* device reset */
118 outl(inl(0xcf005030) | 0x80, 0xcf005030);
119 outl(inl(0xcf005030) & ~0x80, 0xcf005030);
120
121 /* device enable */
122 outl(inl(0xcf005000) | 0x80, 0xcf005000);
123
124 /* GPIO D06 enable for output */
125 outl(inl(0xcf00000c) | 0x40, 0xcf00000c);
126 outl(inl(0xcf00001c) & ~0x40, 0xcf00001c);
127 /* bits 11,10 == 01 */
128 outl(inl(0xcf004040) | 0x400, 0xcf004040);
129 outl(inl(0xcf004040) & ~0x800, 0xcf004040);
130
131 outl(inl(0xcf004048) & ~0x1, 0xcf004048);
132
133 outl(inl(0xcf000004) & ~0xf, 0xcf000004);
134 outl(inl(0xcf004044) & ~0xf, 0xcf004044);
135
136 /* C03 = 0 */
137 outl(inl(0xcf000008) | 0x8, 0xcf000008);
138 outl(inl(0xcf000018) | 0x8, 0xcf000018);
139 outl(inl(0xcf000028) & ~0x8, 0xcf000028);
140#endif
141
142 return 0;
143}
144
145void wmcodec_write(int reg, int data)
146{
147/* Todo: Since the ipod_i2c_* functions also work on H10 and possibly other PP
148 targets, these functions should probably be renamed */
149#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
150 /* The H10's audio codec uses an I2C address of 0x1b */
151 ipod_i2c_send(0x1b, (reg<<1) | ((data&0x100)>>8),data&0xff);
152#else
153 /* The iPod's audio codecs use an I2C address of 0x1a */
154 ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
155#endif
156}