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 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
29 #include "i2c-imx31.h"
31 /* NOTE: Some port-specific bits will have to be moved away (node and GPIO
32 * writes) for cleanest implementation. */
34 static struct i2c_node wm8978_i2c_node
=
37 .ifdr
= I2C_IFDR_DIV192
, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
38 /* Just hard-code for now - scaling may require
43 void audiohw_init(void)
47 i2c_enable_node(&wm8978_i2c_node
, true);
51 imx31_regset32(&GPIO3_DR
, (1 << 21)); /* Turn on analogue LDO */
54 void audiohw_enable_headphone_jack(bool enable
)
56 /* Turn headphone jack output on or off. */
57 imx31_regmod32(&GPIO3_DR
, enable
? (1 << 22) : 0, (1 << 22));
60 void wmcodec_write(int reg
, int data
)
63 /* |aaaaaaad|dddddddd| */
64 d
[0] = (reg
<< 1) | ((data
& 0x100) >> 8);
66 i2c_write(&wm8978_i2c_node
, d
, 2);