From acbbe82a243b0675fb7a156627687234bd277996 Mon Sep 17 00:00:00 2001 From: Daniel Ankers Date: Sat, 9 Dec 2006 19:18:18 +0000 Subject: Move I2S initialisation out of the Wolfson codec driver git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11700 a1c6a512-1295-4272-9138-f99709370657 --- firmware/SOURCES | 11 +++++ firmware/drivers/wm8731l.c | 1 + firmware/drivers/wm8758.c | 1 + firmware/drivers/wm8975.c | 1 + firmware/export/i2s.h | 20 +++++++++ firmware/export/wmcodec.h | 1 - firmware/target/arm/i2s-pp.c | 95 ++++++++++++++++++++++++++++++++++++++++ firmware/target/arm/wmcodec-pp.c | 54 +---------------------- 8 files changed, 130 insertions(+), 54 deletions(-) create mode 100644 firmware/export/i2s.h create mode 100644 firmware/target/arm/i2s-pp.c diff --git a/firmware/SOURCES b/firmware/SOURCES index 77c257879a..30431d71b2 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -328,6 +328,7 @@ target/arm/sandisk/sansa-e200/backlight-e200.c target/arm/sandisk/sansa-e200/usb-e200.c target/arm/sandisk/sansa-e200/button-e200.c target/arm/sandisk/sansa-e200/power-e200.c +target/arm/i2s-pp.c #endif /* SIMULATOR */ #endif /* SANSA_E200 */ @@ -403,6 +404,7 @@ target/coldfire/iriver/h100/usb-h100.c #ifndef SIMULATOR target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/iriver/h10/adc-h10.c target/arm/iriver/h10/backlight-h10.c target/arm/iriver/h10/button-h10.c @@ -416,6 +418,7 @@ target/arm/iriver/h10/usb-h10.c #ifndef SIMULATOR target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/iriver/h10/adc-h10.c target/arm/iriver/h10/backlight-h10.c target/arm/iriver/h10/button-h10.c @@ -445,6 +448,7 @@ target/arm/gigabeat/meg-fx/wmcodec-meg-fx.c #ifndef SIMULATOR target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/tatung/tpj1022/adc-tpj1022.c target/arm/tatung/tpj1022/backlight-tpj1022.c target/arm/tatung/tpj1022/button-tpj1022.c @@ -459,6 +463,7 @@ target/arm/tatung/tpj1022/usb-tpj1022.c drivers/lcd-ipod.c drivers/pcf50605.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ata-pp5020.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-4g_color.c @@ -474,6 +479,7 @@ drivers/lcd-ipod.c drivers/pcf50605.c target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-4g_color.c target/arm/ipod/button-clickwheel.c @@ -488,6 +494,7 @@ drivers/lcd-ipod.c drivers/pcf50605.c target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-nano_video.c target/arm/ipod/button-clickwheel.c @@ -502,6 +509,7 @@ drivers/lcd-ipodvideo.c drivers/pcf50605.c target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-nano_video.c target/arm/ipod/button-clickwheel.c @@ -516,6 +524,7 @@ drivers/lcd-ipod.c drivers/pcf50605.c target/arm/ata-pp5002.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/3g/backlight-3g.c target/arm/ipod/3g/button-3g.c @@ -530,6 +539,7 @@ drivers/lcd-ipod.c drivers/pcf50605.c target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-mini1g_mini2g.c target/arm/ipod/button-mini1g.c @@ -544,6 +554,7 @@ drivers/lcd-ipod.c drivers/pcf50605.c target/arm/ata-pp5020.c target/arm/wmcodec-pp.c +target/arm/i2s-pp.c target/arm/ipod/adc-ipod.c target/arm/ipod/backlight-mini1g_mini2g.c target/arm/ipod/button-clickwheel.c diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c index 30521339e9..a690aade48 100644 --- a/firmware/drivers/wm8731l.c +++ b/firmware/drivers/wm8731l.c @@ -39,6 +39,7 @@ #include "wmcodec.h" #include "wm8731l.h" +#include "i2s.h" #define IPOD_PCM_LEVEL 0x65 /* -6dB */ diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c index 268df13f07..22bef73e45 100644 --- a/firmware/drivers/wm8758.c +++ b/firmware/drivers/wm8758.c @@ -39,6 +39,7 @@ #include "wmcodec.h" #include "wm8758.h" +#include "i2s.h" /* convert tenth of dB volume (-57..6) to master volume register value */ int tenthdb2master(int db) diff --git a/firmware/drivers/wm8975.c b/firmware/drivers/wm8975.c index 7f2f2c4a7d..d2b1fa64b2 100644 --- a/firmware/drivers/wm8975.c +++ b/firmware/drivers/wm8975.c @@ -39,6 +39,7 @@ #include "wmcodec.h" #include "wm8975.h" +#include "i2s.h" /* convert tenth of dB volume (-730..60) to master volume register value */ int tenthdb2master(int db) diff --git a/firmware/export/i2s.h b/firmware/export/i2s.h new file mode 100644 index 0000000000..13dba68391 --- /dev/null +++ b/firmware/export/i2s.h @@ -0,0 +1,20 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Daniel Ankers + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +void i2s_reset(void); diff --git a/firmware/export/wmcodec.h b/firmware/export/wmcodec.h index 1079a80498..d810469d02 100644 --- a/firmware/export/wmcodec.h +++ b/firmware/export/wmcodec.h @@ -17,7 +17,6 @@ * ****************************************************************************/ -void i2s_reset(void); int audiohw_init(void); void wmcodec_write(int reg, int data); 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Portalplayer specific code for I2S + * + * Based on code from the ipodlinux project - http://ipodlinux.org/ + * Adapted for Rockbox in December 2005 + * + * Original file: linux/arch/armnommu/mach-ipod/audio.c + * + * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org) + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "system.h" + +/* TODO: Add in PP5002 defs */ +#if CONFIG_CPU == PP5002 +void i2s_reset(void) +{ + /* I2S device reset */ + DEV_RS |= 0x80; + DEV_RS &= ~0x80; + + /* I2S controller enable */ + IISCONFIG |= 1; + + /* BIT.FORMAT [11:10] = I2S (default) */ + /* BIT.SIZE [9:8] = 24bit */ + /* FIFO.FORMAT = 24 bit LSB */ + + /* reset DAC and ADC fifo */ + IISFIFO_CFG |= 0x30000; +} +#else /* PP502X */ + +/* Data format on the I2S bus */ +#define FORMAT_MASK (0x3 << 10) +#define FORMAT_I2S (0x00 << 10) +/* Other formats not yet known */ + +/* Data size on I2S bus */ +#define SIZE_MASK (0x3 << 8) +#define SIZE_16BIT (0x00 << 10) +/* Other sizes not yet known */ + +/* Data size/format on I2S FIFO */ +#define FIFO_FORMAT_MASK (0x7 << 4) +#define FIFO_FORMAT_32LSB (0x03 << 4) +/* Other formats not yet known */ + +/* Are we I2S Master or slave? */ +#define I2S_MASTER (0x25) + +#define I2S_RESET (0x1 << 31) + +/* + * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit + */ +void i2s_reset(void) +{ + /* I2S soft reset */ + IISCONFIG |= I2S_RESET; + IISCONFIG &= ~I2S_RESET; + + /* BIT.FORMAT */ + IISCONFIG = ((IISCONFIG & ~FORMAT_MASK) | FORMAT_I2S); + + /* BIT.SIZE */ + IISCONFIG = ((IISCONFIG & ~SIZE_MASK) | SIZE_16BIT); + + /* FIFO.FORMAT */ + /* If BIT.SIZE < FIFO.FORMAT low bits will be 0 */ + IISCONFIG = ((IISCONFIG & ~FIFO_FORMAT_MASK) | FIFO_FORMAT_32LSB); + + /* RX_ATN_LVL=1 == when 12 slots full */ + /* TX_ATN_LVL=1 == when 12 slots empty */ + IISFIFO_CFG |= 0x33; + + /* Rx.CLR = 1, TX.CLR = 1 */ + IISFIFO_CFG |= 0x1100; +} +#endif diff --git a/firmware/target/arm/wmcodec-pp.c b/firmware/target/arm/wmcodec-pp.c index 8aa862c187..471cd8f4a5 100644 --- a/firmware/target/arm/wmcodec-pp.c +++ b/firmware/target/arm/wmcodec-pp.c @@ -23,19 +23,8 @@ * KIND, either express or implied. * ****************************************************************************/ -#include "lcd.h" -#include "cpu.h" -#include "kernel.h" -#include "thread.h" -#include "power.h" -#include "debug.h" + #include "system.h" -#include "sprintf.h" -#include "button.h" -#include "string.h" -#include "file.h" -#include "buffer.h" -#include "audio.h" #if CONFIG_CPU == PP5020 #include "i2c-pp5020.h" @@ -51,47 +40,6 @@ #define I2C_AUDIO_ADDRESS 0x1a #endif -/* - * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit - */ -void i2s_reset(void) -{ -#if CONFIG_CPU == PP5020 - /* I2S soft reset */ - outl(inl(0x70002800) | 0x80000000, 0x70002800); - outl(inl(0x70002800) & ~0x80000000, 0x70002800); - - /* BIT.FORMAT [11:10] = I2S (default) */ - outl(inl(0x70002800) & ~0xc00, 0x70002800); - /* BIT.SIZE [9:8] = 16bit (default) */ - outl(inl(0x70002800) & ~0x300, 0x70002800); - - /* FIFO.FORMAT [6:4] = 32 bit LSB */ - /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */ - outl(inl(0x70002800) | 0x30, 0x70002800); - - /* RX_ATN_LVL=1 == when 12 slots full */ - /* TX_ATN_LVL=1 == when 12 slots empty */ - outl(inl(0x7000280c) | 0x33, 0x7000280c); - - /* Rx.CLR = 1, TX.CLR = 1 */ - outl(inl(0x7000280c) | 0x1100, 0x7000280c); -#elif CONFIG_CPU == PP5002 - /* I2S device reset */ - outl(inl(0xcf005030) | 0x80, 0xcf005030); - outl(inl(0xcf005030) & ~0x80, 0xcf005030); - - /* I2S controller enable */ - outl(inl(0xc0002500) | 0x1, 0xc0002500); - - /* BIT.FORMAT [11:10] = I2S (default) */ - /* BIT.SIZE [9:8] = 24bit */ - /* FIFO.FORMAT = 24 bit LSB */ - - /* reset DAC and ADC fifo */ - outl(inl(0xc000251c) | 0x30000, 0xc000251c); -#endif -} /* * Initialise the WM8975 for playback via headphone and line out. -- cgit v1.2.3