e200v1/c200v1: Implement limited samplerate switching. Rates 24kHz and below are...
[kugel-rb.git] / firmware / target / arm / i2s-pp.c
blob83f39515c4a31f217b66aae7cd1c087706041a01
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"
31 #if defined (SANSA_E200) || defined (SANSA_C200)
32 #include "audiohw.h"
33 #include "pcm_sampr.h"
34 #endif
36 #if CONFIG_CPU == PP5002
37 void i2s_reset(void)
39 /* I2S device reset */
40 DEV_RS |= DEV_I2S;
41 DEV_RS &= ~DEV_I2S;
43 /* I2S controller enable */
44 IISCONFIG |= IIS_ENABLE;
46 /* reset DAC and ADC fifo */
47 IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR;
49 #else /* PP502X */
52 * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
54 void i2s_reset(void)
56 /* I2S soft reset */
57 IISCONFIG |= IIS_RESET;
58 IISCONFIG &= ~IIS_RESET;
60 /* BIT.FORMAT */
61 IISCONFIG = ((IISCONFIG & ~IIS_FORMAT_MASK) | IIS_FORMAT_IIS);
62 /* BIT.SIZE */
63 IISCONFIG = ((IISCONFIG & ~IIS_SIZE_MASK) | IIS_SIZE_16BIT);
65 /* FIFO.FORMAT */
66 /* If BIT.SIZE < FIFO.FORMAT low bits will be 0 */
67 #ifdef HAVE_AS3514
68 /* AS3514 can only operate as I2S Slave */
69 IISCONFIG |= IIS_MASTER;
71 /* Set I2S to 44.1kHz */
72 #ifdef PHILIPS_SA9200
73 /* values taken from the SA9200 OF */
74 IISCLK = (IISCLK & ~0x1ff) | 31;
75 IISDIV = (IISDIV & ~0xc0000000) | (2 << 30);
76 IISDIV = (IISDIV & ~0x3f) | 16;
77 #elif defined (SANSA_E200) || defined (SANSA_C200)
78 audiohw_set_sampr_dividers(HW_FREQ_DEFAULT);
79 #else
80 IISCLK = (IISCLK & ~0x1ff) | 33;
81 IISDIV = 7;
82 #endif
83 #endif /* HAVE_AS3514 */
85 IISCONFIG = ((IISCONFIG & ~IIS_FIFO_FORMAT_MASK) | IIS_FIFO_FORMAT_LE16_2);
87 /* RX_ATN_LVL = when 12 slots full */
88 /* TX_ATN_LVL = DMA request when 4 slots empty */
89 IISFIFO_CFG |= IIS_RX_FULL_LVL_12 | IIS_TX_EMPTY_LVL_4;
91 /* Rx.CLR = 1, TX.CLR = 1 */
92 IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR;
95 #endif /* CONFIG_CPU == */