1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
28 /*#define LOGF_ENABLE*/
31 #define I2C_AUDIO_ADDRESS 0x10
34 * Initialise the PP I2C and I2S.
36 void audiohw_init(void)
42 /* I2S device enable */
43 DEV_EN
|= (DEV_I2S
| DEV_EXTCLOCKS
);
45 /* I2S device reset */
47 asm volatile ("nop\n");
50 DEV_INIT1
&= ~0x3000000;
57 /* reset the I2S controller into known state */
60 /* this gpio pin maybe powers the codec chip */
62 GPIOB_OUTPUT_EN
|= 0x01;
63 GPIOB_OUTPUT_VAL
|= 0x01;
66 GPIOL_OUTPUT_VAL
&= ~0x20;
67 GPIOL_OUTPUT_EN
|= 0x20;
70 GPO32_ENABLE
|= 0x00000002;
71 GPO32_VAL
&= ~0x00000002;
74 GPO32_VAL
|= 0x00000020;
75 GPO32_ENABLE
|= 0x00000020;
78 GPIOF_OUTPUT_VAL
|= 0x80;
79 GPIOF_OUTPUT_EN
|= 0x80;
84 GPIOL_OUTPUT_VAL
|= 0x20;
85 GPIOL_OUTPUT_EN
|= 0x20;
88 void akcodec_close(void)
91 GPIOF_OUTPUT_VAL
&= ~0x80;
92 GPIOF_OUTPUT_EN
|= 0x80;
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
);