c9d66d53aec4d95ce8d55bbff3eb6c8b9a328ff3
[kugel-rb.git] / firmware / target / arm / i2s-pp.c
blobc9d66d53aec4d95ce8d55bbff3eb6c8b9a328ff3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Portalplayer specific code for I2S
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
25 * KIND, either express or implied.
27 ****************************************************************************/
28 #include "system.h"
29 #include "cpu.h"
30 #include "i2s.h"
32 #if CONFIG_CPU == PP5002
33 void i2s_reset(void)
35 /* I2S device reset */
36 DEV_RS |= DEV_I2S;
37 DEV_RS &= ~DEV_I2S;
39 /* I2S controller enable */
40 IISCONFIG |= IIS_ENABLE;
42 /* reset DAC and ADC fifo */
43 IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR;
45 #else /* PP502X */
48 * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
50 void i2s_reset(void)
52 /* I2S soft reset */
53 IISCONFIG |= IIS_RESET;
54 IISCONFIG &= ~IIS_RESET;
56 /* BIT.FORMAT */
57 IISCONFIG = ((IISCONFIG & ~IIS_FORMAT_MASK) | IIS_FORMAT_IIS);
58 /* BIT.SIZE */
59 IISCONFIG = ((IISCONFIG & ~IIS_SIZE_MASK) | IIS_SIZE_16BIT);
61 /* FIFO.FORMAT */
62 /* If BIT.SIZE < FIFO.FORMAT low bits will be 0 */
63 #ifdef HAVE_AS3514
64 /* AS3514 can only operate as I2S Slave */
65 IISCONFIG |= IIS_MASTER;
67 /* Set I2S to 44.1kHz */
68 #ifdef PHILIPS_SA9200
69 /* values taken from the SA9200 OF */
70 IISCLK = (IISCLK & ~0x1ff) | 31;
71 IISDIV = (IISDIV & ~0xc0000000) | (2 << 30);
72 IISDIV = (IISDIV & ~0x3f) | 16;
73 #else
74 IISCLK = (IISCLK & ~0x1ff) | 33;
75 IISDIV = 7;
76 #endif
77 #endif /* HAVE_AS3514 */
79 IISCONFIG = ((IISCONFIG & ~IIS_FIFO_FORMAT_MASK) | IIS_FIFO_FORMAT_LE16_2);
81 /* RX_ATN_LVL = when 12 slots full */
82 /* TX_ATN_LVL = DMA request when 4 slots empty */
83 IISFIFO_CFG |= IIS_RX_FULL_LVL_12 | IIS_TX_EMPTY_LVL_4;
85 /* Rx.CLR = 1, TX.CLR = 1 */
86 IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR;
89 #endif /* CONFIG_CPU == */