Fix include problem
[kugel-rb.git] / firmware / target / arm / samsung / akcodec-yh82x_yh92x.c
blob55442e8837930908a8c8a1e7b9a82c7985d34ec6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2009 Mark Arigo
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "system.h"
23 #include "audiohw.h"
24 #include "i2c-pp.h"
25 #include "i2s.h"
26 #include "akcodec.h"
28 /*#define LOGF_ENABLE*/
29 #include "logf.h"
31 #define I2C_AUDIO_ADDRESS 0x10
34 * Initialise the PP I2C and I2S.
36 void audiohw_init(void)
38 unsigned long tmp;
40 logf("audiohw_init");
42 /* I2S device enable */
43 DEV_EN |= (DEV_I2S | DEV_EXTCLOCKS);
45 /* I2S device reset */
46 DEV_RS |= DEV_I2S;
47 asm volatile ("nop\n");
48 DEV_RS &= ~DEV_I2S;
50 DEV_INIT1 &= ~0x3000000;
52 tmp = DEV_INIT1;
53 DEV_INIT1 = tmp;
55 DEV_INIT2 &= ~0x100;
57 /* reset the I2S controller into known state */
58 i2s_reset();
60 /* this gpio pin maybe powers the codec chip */
61 GPIOB_ENABLE |= 0x01;
62 GPIOB_OUTPUT_EN |= 0x01;
63 GPIOB_OUTPUT_VAL |= 0x01;
65 GPIOL_ENABLE |= 0x20;
66 GPIOL_OUTPUT_VAL &= ~0x20;
67 GPIOL_OUTPUT_EN |= 0x20;
69 #ifdef SAMSUNG_YH920
70 GPO32_ENABLE |= 0x00000002;
71 GPO32_VAL &= ~0x00000002;
72 #endif
74 GPO32_VAL |= 0x00000020;
75 GPO32_ENABLE |= 0x00000020;
77 GPIOF_ENABLE |= 0x80;
78 GPIOF_OUTPUT_VAL |= 0x80;
79 GPIOF_OUTPUT_EN |= 0x80;
81 audiohw_preinit();
83 GPIOL_ENABLE |= 0x20;
84 GPIOL_OUTPUT_VAL |= 0x20;
85 GPIOL_OUTPUT_EN |= 0x20;
88 void akcodec_close(void)
90 GPIOF_ENABLE |= 0x80;
91 GPIOF_OUTPUT_VAL &= ~0x80;
92 GPIOF_OUTPUT_EN |= 0x80;
94 GPIOB_ENABLE |= 0x01;
95 GPIOB_OUTPUT_EN |= 0x01;
96 GPIOB_OUTPUT_VAL |= 0x01;
99 void akcodec_write(int reg, int data)
101 pp_i2c_send(I2C_AUDIO_ADDRESS, reg, data);
104 int akcodec_read(int reg)
106 return i2c_readbyte(I2C_AUDIO_ADDRESS, reg);