Gigabeat S/i.MX31: Sort files in the /target tree into things that are SoC-generic...
[kugel-rb.git] / firmware / target / arm / imx31 / gigabeat-s / wmcodec-gigabeat-s.c
blob96324cc1624ce24cb9b744327b7d3b7d5045c881
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
23 #include "config.h"
24 #include "system.h"
25 #include "kernel.h"
26 #include "sound.h"
27 #include "wmcodec.h"
28 #include "i2s.h"
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 =
36 .num = I2C1_NUM,
37 .ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
38 /* Just hard-code for now - scaling may require
39 * updating */
40 .addr = WMC_I2C_ADDR,
43 void audiohw_init(void)
45 i2s_reset();
47 i2c_enable_node(&wm8978_i2c_node, true);
49 audiohw_preinit();
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)
62 unsigned char d[2];
63 /* |aaaaaaad|dddddddd| */
64 d[0] = (reg << 1) | ((data & 0x100) >> 8);
65 d[1] = data;
66 i2c_write(&wm8978_i2c_node, d, 2);