1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Gigabeat S specific code for the WM8978 codec
12 * Copyright (C) 2008 Michael Sevakis
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include "i2c-imx31.h"
27 /* NOTE: Some port-specific bits will have to be moved away (node and GPIO
28 * writes) for cleanest implementation. */
30 static struct i2c_node wm8978_i2c_node
=
33 .ifdr
= I2C_IFDR_DIV192
, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
34 /* Just hard-code for now - scaling may require
39 void audiohw_init(void)
41 /* USB PLL = 338.688MHz, /30 = 11.2896MHz = 256Fs */
42 imx31_regmod32(&CLKCTL_PDR1
,
43 PDR1_SSI1_PODFw(64-1) | PDR1_SSI2_PODFw(5-1),
44 PDR1_SSI1_PODF
| PDR1_SSI2_PODF
);
45 imx31_regmod32(&CLKCTL_PDR1
,
46 PDR1_SSI1_PRE_PODFw(4-1) | PDR1_SSI2_PRE_PODFw(1-1),
47 PDR1_SSI1_PRE_PODF
| PDR1_SSI2_PRE_PODF
);
48 i2c_enable_node(&wm8978_i2c_node
, true);
52 GPIO3_DR
|= (1 << 21); /* Turn on analogue LDO */
55 void audiohw_enable_headphone_jack(bool enable
)
59 GPIO3_DR
|= (1 << 22); /* Turn on headphone jack output */
63 GPIO3_DR
&= ~(1 << 22); /* Turn off headphone jack output */
67 void wmcodec_write(int reg
, int data
)
70 /* |aaaaaaad|dddddddd| */
71 d
[0] = (reg
<< 1) | ((data
& 0x100) >> 8);
73 i2c_write(&wm8978_i2c_node
, d
, 2);