diff options
author | Dave Chapman <dave@dchapman.com> | 2008-10-31 00:16:42 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-10-31 00:16:42 +0000 |
commit | 42f77d4eb027afed4f4ef80f10c16112c2b7fe2b (patch) | |
tree | 2da09bcab257322dce48ddccc4a71d915318aa3a /firmware/target | |
parent | 324816f0190dec308f3496a288820a47926b1c17 (diff) |
Abstract the PortalPlayer AS3514 handling with an "ascodec" API - inspired by the wmcodec API used with the Wolfson codecs. The intention is to implement this API for the AS3525 and then share code with the Sansa V2 ports.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18940 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/adc-as3514.c | 10 | ||||
-rw-r--r-- | firmware/target/arm/ascodec-pp.c | 66 | ||||
-rw-r--r-- | firmware/target/arm/ascodec-target.h | 69 | ||||
-rw-r--r-- | firmware/target/arm/i2c-pp.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/philips/sa9200/backlight-sa9200.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/philips/sa9200/power-sa9200.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/backlight-c200_e200.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/power-c200_e200.c | 6 |
8 files changed, 153 insertions, 17 deletions
diff --git a/firmware/target/arm/adc-as3514.c b/firmware/target/arm/adc-as3514.c index 26cdc76f0d..9c2a421441 100644 --- a/firmware/target/arm/adc-as3514.c +++ b/firmware/target/arm/adc-as3514.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include "adc.h" #include "kernel.h" -#include "i2c-pp.h" +#include "ascodec.h" #include "as3514.h" /* Read 10-bit channel data */ @@ -30,21 +30,21 @@ unsigned short adc_read(int channel) if ((unsigned)channel < NUM_ADC_CHANNELS) { - i2c_lock(); + ascodec_lock(); /* Select channel */ - if (pp_i2c_send( AS3514_I2C_ADDR, AS3514_ADC_0, (channel << 4)) >= 0) + if (ascodec_write(AS3514_ADC_0, (channel << 4)) >= 0) { unsigned char buf[2]; /* Read data */ - if (i2c_readbytes( AS3514_I2C_ADDR, AS3514_ADC_0, 2, buf) >= 0) + if (ascodec_readbytes(AS3514_ADC_0, 2, buf) >= 0) { data = (((buf[0] & 0x3) << 8) | buf[1]); } } - i2c_unlock(); + ascodec_unlock(); } return data; diff --git a/firmware/target/arm/ascodec-pp.c b/firmware/target/arm/ascodec-pp.c new file mode 100644 index 0000000000..30b6b1f8de --- /dev/null +++ b/firmware/target/arm/ascodec-pp.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Driver for AS3514 audio codec + * + * Copyright (c) 2007 Daniel Ankers + * Copyright (c) 2007 Christian Gmeiner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "cpu.h" +#include "system.h" + +#include "audiohw.h" +#include "i2s.h" + +/* + * Initialise the PP I2C and I2S. + */ +void audiohw_init(void) +{ + /* normal outputs for CDI and I2S pin groups */ + DEV_INIT2 &= ~0x300; + + /*mini2?*/ + DEV_INIT1 &=~0x3000000; + /*mini2?*/ + + /* device reset */ + DEV_RS |= DEV_I2S; + DEV_RS &=~DEV_I2S; + + /* I2S device reset */ + DEV_RS |= DEV_I2S; + DEV_RS &=~DEV_I2S; + + /* I2S device enable */ + DEV_EN |= DEV_I2S; + + /* enable external dev clock clocks */ + DEV_EN |= DEV_EXTCLOCKS; + + /* external dev clock to 24MHz */ + outl(inl(0x70000018) & ~0xc, 0x70000018); + + i2s_reset(); + + audiohw_preinit(); +} + +void audiohw_postinit(void) +{ +} diff --git a/firmware/target/arm/ascodec-target.h b/firmware/target/arm/ascodec-target.h new file mode 100644 index 0000000000..19b1644541 --- /dev/null +++ b/firmware/target/arm/ascodec-target.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Driver for AS3514 audio codec + * + * Copyright (c) 2007 Daniel Ankers + * Copyright (c) 2007 Christian Gmeiner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _ASCODEC_TARGET_H +#define _ASCODEC_TARGET_H + +#include "config.h" + +#ifdef CPU_PP +/* TODO: This header is actually portalplayer specific, and should be + * moved into an appropriate subdir */ + +#include "i2c-pp.h" + +#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) +#define AS3514_I2C_ADDR 0x46 +#else +#error Unknown target! +#endif + +static inline int ascodec_write(unsigned int reg, unsigned int value) +{ + return pp_i2c_send(AS3514_I2C_ADDR, reg, value); +} + +static inline int ascodec_read(unsigned int reg) +{ + return i2c_readbyte(AS3514_I2C_ADDR, reg); +} + +static inline int ascodec_readbytes(int addr, int len, unsigned char *data) +{ + return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data); +} + +static inline void ascodec_lock(void) +{ + i2c_lock(); +} + +static inline void ascodec_unlock(void) +{ + i2c_unlock(); +} + +#endif /* CPU_PP */ + +#endif /* !_ASCODEC_TARGET_H */ diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c index 4d83208d91..3db25c027c 100644 --- a/firmware/target/arm/i2c-pp.c +++ b/firmware/target/arm/i2c-pp.c @@ -32,6 +32,7 @@ #include "logf.h" #include "system.h" #include "i2c-pp.h" +#include "ascodec.h" #include "as3514.h" /* Local functions definitions */ @@ -230,7 +231,7 @@ void i2c_init(void) outl(0, 0x600060a4); outl(0x1e, 0x600060a4); - pp_i2c_send(AS3514_I2C_ADDR, AS3514_SUPERVISOR, 5); + ascodec_write(AS3514_SUPERVISOR, 5); #endif #endif diff --git a/firmware/target/arm/philips/sa9200/backlight-sa9200.c b/firmware/target/arm/philips/sa9200/backlight-sa9200.c index 33342d19f1..b3984ca9ad 100644 --- a/firmware/target/arm/philips/sa9200/backlight-sa9200.c +++ b/firmware/target/arm/philips/sa9200/backlight-sa9200.c @@ -23,7 +23,7 @@ #include "system.h" #include "lcd.h" #include "backlight.h" -#include "i2c-pp.h" +#include "ascodec.h" #include "as3514.h" static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; @@ -46,12 +46,12 @@ void _backlight_on(void) #ifdef HAVE_LCD_ENABLE lcd_enable(true); /* power on lcd + visible display */ #endif - pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness); + ascodec_write(AS3514_DCDC15, backlight_brightness); } void _backlight_off(void) { - pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0); + ascodec_write(AS3514_DCDC15, 0x0); #ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off visible display */ #endif diff --git a/firmware/target/arm/philips/sa9200/power-sa9200.c b/firmware/target/arm/philips/sa9200/power-sa9200.c index a559f65ec4..b005a86651 100644 --- a/firmware/target/arm/philips/sa9200/power-sa9200.c +++ b/firmware/target/arm/philips/sa9200/power-sa9200.c @@ -36,9 +36,9 @@ void power_off(void) char byte; /* Send shutdown command to PMU */ - byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM); + byte = ascodec_read(AS3514_SYSTEM); byte &= ~0x1; - pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte); + ascodec_write(AS3514_SYSTEM, byte); /* Stop interrupts on both cores */ disable_interrupt(IRQ_FIQ_STATUS); diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c index 33342d19f1..b3984ca9ad 100644 --- a/firmware/target/arm/sandisk/backlight-c200_e200.c +++ b/firmware/target/arm/sandisk/backlight-c200_e200.c @@ -23,7 +23,7 @@ #include "system.h" #include "lcd.h" #include "backlight.h" -#include "i2c-pp.h" +#include "ascodec.h" #include "as3514.h" static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; @@ -46,12 +46,12 @@ void _backlight_on(void) #ifdef HAVE_LCD_ENABLE lcd_enable(true); /* power on lcd + visible display */ #endif - pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness); + ascodec_write(AS3514_DCDC15, backlight_brightness); } void _backlight_off(void) { - pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0); + ascodec_write(AS3514_DCDC15, 0x0); #ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off visible display */ #endif diff --git a/firmware/target/arm/sandisk/power-c200_e200.c b/firmware/target/arm/sandisk/power-c200_e200.c index a559f65ec4..d6319f44bb 100644 --- a/firmware/target/arm/sandisk/power-c200_e200.c +++ b/firmware/target/arm/sandisk/power-c200_e200.c @@ -22,7 +22,7 @@ #include <stdbool.h> #include "system.h" #include "cpu.h" -#include "i2c-pp.h" +#include "ascodec.h" #include "tuner.h" #include "as3514.h" #include "power.h" @@ -36,9 +36,9 @@ void power_off(void) char byte; /* Send shutdown command to PMU */ - byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM); + byte = ascodec_read(AS3514_SYSTEM); byte &= ~0x1; - pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte); + ascodec_write(AS3514_SYSTEM, byte); /* Stop interrupts on both cores */ disable_interrupt(IRQ_FIQ_STATUS); |