summaryrefslogtreecommitdiff
path: root/firmware/target/arm/i2s-pp.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/i2s-pp.c')
-rw-r--r--firmware/target/arm/i2s-pp.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/firmware/target/arm/i2s-pp.c b/firmware/target/arm/i2s-pp.c
new file mode 100644
index 0000000000..1485147de8
--- /dev/null
+++ b/firmware/target/arm/i2s-pp.c
@@ -0,0 +1,95 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Portalplayer specific code for I2S
11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
14 *
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
16 *
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
18 *
19 * All files in this archive are subject to the GNU General Public License.
20 * See the file COPYING in the source tree root for full license agreement.
21 *
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
24 *
25 ****************************************************************************/
26
27#include "system.h"
28
29/* TODO: Add in PP5002 defs */
30#if CONFIG_CPU == PP5002
31void i2s_reset(void)
32{
33 /* I2S device reset */
34 DEV_RS |= 0x80;
35 DEV_RS &= ~0x80;
36
37 /* I2S controller enable */
38 IISCONFIG |= 1;
39
40 /* BIT.FORMAT [11:10] = I2S (default) */
41 /* BIT.SIZE [9:8] = 24bit */
42 /* FIFO.FORMAT = 24 bit LSB */
43
44 /* reset DAC and ADC fifo */
45 IISFIFO_CFG |= 0x30000;
46}
47#else /* PP502X */
48
49/* Data format on the I2S bus */
50#define FORMAT_MASK (0x3 << 10)
51#define FORMAT_I2S (0x00 << 10)
52/* Other formats not yet known */
53
54/* Data size on I2S bus */
55#define SIZE_MASK (0x3 << 8)
56#define SIZE_16BIT (0x00 << 10)
57/* Other sizes not yet known */
58
59/* Data size/format on I2S FIFO */
60#define FIFO_FORMAT_MASK (0x7 << 4)
61#define FIFO_FORMAT_32LSB (0x03 << 4)
62/* Other formats not yet known */
63
64/* Are we I2S Master or slave? */
65#define I2S_MASTER (0x25)
66
67#define I2S_RESET (0x1 << 31)
68
69/*
70 * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
71 */
72void i2s_reset(void)
73{
74 /* I2S soft reset */
75 IISCONFIG |= I2S_RESET;
76 IISCONFIG &= ~I2S_RESET;
77
78 /* BIT.FORMAT */
79 IISCONFIG = ((IISCONFIG & ~FORMAT_MASK) | FORMAT_I2S);
80
81 /* BIT.SIZE */
82 IISCONFIG = ((IISCONFIG & ~SIZE_MASK) | SIZE_16BIT);
83
84 /* FIFO.FORMAT */
85 /* If BIT.SIZE < FIFO.FORMAT low bits will be 0 */
86 IISCONFIG = ((IISCONFIG & ~FIFO_FORMAT_MASK) | FIFO_FORMAT_32LSB);
87
88 /* RX_ATN_LVL=1 == when 12 slots full */
89 /* TX_ATN_LVL=1 == when 12 slots empty */
90 IISFIFO_CFG |= 0x33;
91
92 /* Rx.CLR = 1, TX.CLR = 1 */
93 IISFIFO_CFG |= 0x1100;
94}
95#endif