diff options
Diffstat (limited to 'firmware/target/arm/pp/i2s-pp.c')
-rw-r--r-- | firmware/target/arm/pp/i2s-pp.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/firmware/target/arm/pp/i2s-pp.c b/firmware/target/arm/pp/i2s-pp.c new file mode 100644 index 0000000000..83f39515c4 --- /dev/null +++ b/firmware/target/arm/pp/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 | * 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. | ||
23 | * | ||
24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
25 | * KIND, either express or implied. | ||
26 | * | ||
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 | ||
35 | |||
36 | #if CONFIG_CPU == PP5002 | ||
37 | void i2s_reset(void) | ||
38 | { | ||
39 | /* I2S device reset */ | ||
40 | DEV_RS |= DEV_I2S; | ||
41 | DEV_RS &= ~DEV_I2S; | ||
42 | |||
43 | /* I2S controller enable */ | ||
44 | IISCONFIG |= IIS_ENABLE; | ||
45 | |||
46 | /* reset DAC and ADC fifo */ | ||
47 | IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR; | ||
48 | } | ||
49 | #else /* PP502X */ | ||
50 | |||
51 | /* | ||
52 | * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit | ||
53 | */ | ||
54 | void i2s_reset(void) | ||
55 | { | ||
56 | /* I2S soft reset */ | ||
57 | IISCONFIG |= IIS_RESET; | ||
58 | IISCONFIG &= ~IIS_RESET; | ||
59 | |||
60 | /* BIT.FORMAT */ | ||
61 | IISCONFIG = ((IISCONFIG & ~IIS_FORMAT_MASK) | IIS_FORMAT_IIS); | ||
62 | /* BIT.SIZE */ | ||
63 | IISCONFIG = ((IISCONFIG & ~IIS_SIZE_MASK) | IIS_SIZE_16BIT); | ||
64 | |||
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; | ||
70 | |||
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 */ | ||
84 | |||
85 | IISCONFIG = ((IISCONFIG & ~IIS_FIFO_FORMAT_MASK) | IIS_FIFO_FORMAT_LE16_2); | ||
86 | |||
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; | ||
90 | |||
91 | /* Rx.CLR = 1, TX.CLR = 1 */ | ||
92 | IISFIFO_CFG |= IIS_RXCLR | IIS_TXCLR; | ||
93 | } | ||
94 | |||
95 | #endif /* CONFIG_CPU == */ | ||