Hopefully fix FS#8506 (OF cant be loaded on some PP targets). also hopefully fixes...
[Rockbox.git] / firmware / target / arm / wmcodec-pp.c
blobcfdd311c5215eb74b775346f7045692f46eb2671
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Portalplayer specific code for Wolfson audio codecs
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
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.
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
25 ****************************************************************************/
27 #include "system.h"
28 #include "audiohw.h"
29 #include "i2c-pp.h"
31 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100)
32 /* The H10's audio codec uses an I2C address of 0x1b */
33 #define I2C_AUDIO_ADDRESS 0x1b
34 #else
35 /* The iPod's audio codecs use an I2C address of 0x1a */
36 #define I2C_AUDIO_ADDRESS 0x1a
37 #endif
41 * Initialise the PP I2C and I2S.
43 void audiohw_init(void) {
44 #ifdef CPU_PP502x
45 /* normal outputs for CDI and I2S pin groups */
46 DEV_INIT2 &= ~0x300;
48 /*mini2?*/
49 DEV_INIT1 &=~0x3000000;
50 /*mini2?*/
52 /* I2S device reset */
53 DEV_RS |= DEV_I2S;
54 DEV_RS &=~DEV_I2S;
56 /* I2S device enable */
57 DEV_EN |= DEV_I2S;
59 /* enable external dev clock clocks */
60 DEV_EN |= DEV_EXTCLOCKS;
62 /* external dev clock to 24MHz */
63 outl(inl(0x70000018) & ~0xc, 0x70000018);
64 #else
65 /* device reset */
66 outl(inl(0xcf005030) | 0x80, 0xcf005030);
67 outl(inl(0xcf005030) & ~0x80, 0xcf005030);
69 /* device enable */
70 outl(inl(0xcf005000) | 0x80, 0xcf005000);
72 /* GPIO D06 enable for output */
73 outl(inl(0xcf00000c) | 0x40, 0xcf00000c);
74 outl(inl(0xcf00001c) & ~0x40, 0xcf00001c);
75 #ifdef IPOD_1G2G
76 /* bits 11,10 == 10 */
77 outl(inl(0xcf004040) & ~0x400, 0xcf004040);
78 outl(inl(0xcf004040) | 0x800, 0xcf004040);
79 #else /* IPOD_3G */
80 /* bits 11,10 == 01 */
81 outl(inl(0xcf004040) | 0x400, 0xcf004040);
82 outl(inl(0xcf004040) & ~0x800, 0xcf004040);
84 outl(inl(0xcf004048) & ~0x1, 0xcf004048);
86 outl(inl(0xcf000004) & ~0xf, 0xcf000004);
87 outl(inl(0xcf004044) & ~0xf, 0xcf004044);
89 /* C03 = 0 */
90 outl(inl(0xcf000008) | 0x8, 0xcf000008);
91 outl(inl(0xcf000018) | 0x8, 0xcf000018);
92 outl(inl(0xcf000028) & ~0x8, 0xcf000028);
93 #endif /* IPOD_1G2G/3G */
94 #endif
96 #if defined(HAVE_WM8731) || defined(HAVE_WM8751)
97 audiohw_preinit();
98 #endif
102 #if !defined(HAVE_WM8731) && !defined(HAVE_WM8751)
103 void audiohw_postinit(void)
106 #endif
108 void wmcodec_write(int reg, int data)
110 pp_i2c_send(I2C_AUDIO_ADDRESS, (reg<<1) | ((data&0x100)>>8),data&0xff);