forked from len0rd/rockbox
Fix line endings and set svn properties
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18892 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1b9991c229
commit
e5d72ac5f7
2 changed files with 65 additions and 65 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 by Bertrik Sikken
|
* Copyright (C) 2008 by Bertrik Sikken
|
||||||
*
|
*
|
||||||
|
|
@ -40,93 +40,93 @@
|
||||||
#include "as3525-codec.h"
|
#include "as3525-codec.h"
|
||||||
#include "as3525.h"
|
#include "as3525.h"
|
||||||
|
|
||||||
#define AUDIO_I2C_ADDR 0x46
|
#define AUDIO_I2C_ADDR 0x46
|
||||||
|
|
||||||
#define I2C2_DATA *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x00))
|
#define I2C2_DATA *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x00))
|
||||||
#define I2C2_SLAD0 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x04))
|
#define I2C2_SLAD0 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x04))
|
||||||
#define I2C2_CNTRL *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x0C))
|
#define I2C2_CNTRL *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x0C))
|
||||||
#define I2C2_DACNT *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x10))
|
#define I2C2_DACNT *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x10))
|
||||||
#define I2C2_CPSR0 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x1C))
|
#define I2C2_CPSR0 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x1C))
|
||||||
#define I2C2_CPSR1 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x20))
|
#define I2C2_CPSR1 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x20))
|
||||||
#define I2C2_IMR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x24))
|
#define I2C2_IMR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x24))
|
||||||
#define I2C2_RIS *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x28))
|
#define I2C2_RIS *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x28))
|
||||||
#define I2C2_MIS *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x2C))
|
#define I2C2_MIS *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x2C))
|
||||||
#define I2C2_SR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x30))
|
#define I2C2_SR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x30))
|
||||||
#define I2C2_INT_CLR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x40))
|
#define I2C2_INT_CLR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x40))
|
||||||
#define I2C2_SADDR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x44))
|
#define I2C2_SADDR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x44))
|
||||||
|
|
||||||
|
|
||||||
/* initialises the internal i2c bus and prepares for transfers to the codec */
|
/* initialises the internal i2c bus and prepares for transfers to the codec */
|
||||||
void as3525_codec_init(void)
|
void as3525_codec_init(void)
|
||||||
{
|
{
|
||||||
/* reset device */
|
/* reset device */
|
||||||
CCU_SRC = CCU_SRC_I2C_AUDIO_EN;
|
CCU_SRC = CCU_SRC_I2C_AUDIO_EN;
|
||||||
CCU_SRL = CCU_SRL_MAGIC_NUMBER;
|
CCU_SRL = CCU_SRL_MAGIC_NUMBER;
|
||||||
CCU_SRL = 0;
|
CCU_SRL = 0;
|
||||||
|
|
||||||
/* enable clock */
|
/* enable clock */
|
||||||
CGU_PERI |= CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE;
|
CGU_PERI |= CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE;
|
||||||
|
|
||||||
/* prescaler for i2c clock */
|
/* prescaler for i2c clock */
|
||||||
I2C2_CPSR0 = 60; /* 24 MHz / 400 kHz */
|
I2C2_CPSR0 = 60; /* 24 MHz / 400 kHz */
|
||||||
I2C2_CPSR1 = 0; /* MSB */
|
I2C2_CPSR1 = 0; /* MSB */
|
||||||
|
|
||||||
/* set i2c slave address of codec part */
|
/* set i2c slave address of codec part */
|
||||||
I2C2_SLAD0 = AUDIO_I2C_ADDR << 1;
|
I2C2_SLAD0 = AUDIO_I2C_ADDR << 1;
|
||||||
|
|
||||||
I2C2_CNTRL = 0x51;
|
I2C2_CNTRL = 0x51;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returns != 0 when busy */
|
|
||||||
static int i2c_busy(void)
|
|
||||||
{
|
|
||||||
return (I2C2_SR & 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* returns 0 on success, <0 otherwise */
|
/* returns != 0 when busy */
|
||||||
int as3525_codec_write(int index, int value)
|
static int i2c_busy(void)
|
||||||
{
|
{
|
||||||
if (index == 0x21) {
|
return (I2C2_SR & 1);
|
||||||
/* prevent setting of the LREG_CP_not bit */
|
}
|
||||||
value &= ~(1 << 5);
|
|
||||||
}
|
|
||||||
|
/* returns 0 on success, <0 otherwise */
|
||||||
/* check if still busy */
|
int as3525_codec_write(int index, int value)
|
||||||
|
{
|
||||||
|
if (index == 0x21) {
|
||||||
|
/* prevent setting of the LREG_CP_not bit */
|
||||||
|
value &= ~(1 << 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if still busy */
|
||||||
if (i2c_busy()) {
|
if (i2c_busy()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start transfer */
|
/* start transfer */
|
||||||
I2C2_SADDR = index;
|
I2C2_SADDR = index;
|
||||||
I2C2_CNTRL &= ~(1 << 1);
|
I2C2_CNTRL &= ~(1 << 1);
|
||||||
I2C2_DATA = value;
|
I2C2_DATA = value;
|
||||||
I2C2_DACNT = 1;
|
I2C2_DACNT = 1;
|
||||||
|
|
||||||
/* wait for transfer*/
|
/* wait for transfer*/
|
||||||
while (i2c_busy());
|
while (i2c_busy());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* returns value read on success, <0 otherwise */
|
/* returns value read on success, <0 otherwise */
|
||||||
int as3525_codec_read(int index)
|
int as3525_codec_read(int index)
|
||||||
{
|
{
|
||||||
/* check if still busy */
|
/* check if still busy */
|
||||||
if (i2c_busy()) {
|
if (i2c_busy()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start transfer */
|
/* start transfer */
|
||||||
I2C2_SADDR = index;
|
I2C2_SADDR = index;
|
||||||
I2C2_CNTRL |= (1 << 1);
|
I2C2_CNTRL |= (1 << 1);
|
||||||
I2C2_DACNT = 1;
|
I2C2_DACNT = 1;
|
||||||
|
|
||||||
/* wait for transfer*/
|
/* wait for transfer*/
|
||||||
while (i2c_busy());
|
while (i2c_busy());
|
||||||
|
|
||||||
return I2C2_DATA;
|
return I2C2_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 by Bertrik Sikken
|
* Copyright (C) 2008 by Bertrik Sikken
|
||||||
*
|
*
|
||||||
|
|
@ -22,6 +22,6 @@
|
||||||
void as3525_codec_init(void);
|
void as3525_codec_init(void);
|
||||||
|
|
||||||
int as3525_codec_write(int index, int value);
|
int as3525_codec_write(int index, int value);
|
||||||
int as3525_codec_read(int index);
|
int as3525_codec_read(int index);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue