2008-11-10 11:04:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-11-10 20:55:56 +00:00
|
|
|
* Driver for AS3514 audio codec
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Daniel Ankers
|
|
|
|
* Copyright (c) 2007 Christian Gmeiner
|
2008-11-10 11:04:43 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
#ifndef _ASCODEC_TARGET_H
|
|
|
|
#define _ASCODEC_TARGET_H
|
|
|
|
|
2010-03-23 07:52:55 +00:00
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
#include "as3514.h"
|
2011-03-02 08:49:38 +00:00
|
|
|
#include "kernel.h" /* for struct semaphore */
|
2010-03-23 11:13:17 +00:00
|
|
|
#include "clock-target.h" /* for AS3525_I2C_PRESCALER */
|
2010-04-03 04:42:04 +00:00
|
|
|
#include "system-arm.h"
|
2008-11-10 20:55:56 +00:00
|
|
|
|
2009-06-30 17:56:21 +00:00
|
|
|
/* Charge Pump and Power management Settings */
|
|
|
|
#define AS314_CP_DCDC3_SETTING \
|
|
|
|
((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \
|
|
|
|
(0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \
|
|
|
|
(0<<5) | /* LREG_CPnot Always write 0 */ \
|
|
|
|
(0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \
|
|
|
|
(1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\
|
|
|
|
(0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/
|
|
|
|
|
|
|
|
#define CVDD_1_20 0
|
|
|
|
#define CVDD_1_15 1
|
|
|
|
#define CVDD_1_10 2
|
|
|
|
#define CVDD_1_05 3
|
|
|
|
|
2010-05-27 12:00:29 +00:00
|
|
|
void ascodec_init(void) INIT_ATTR;
|
2008-11-10 20:59:10 +00:00
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
int ascodec_write(unsigned int index, unsigned int value);
|
|
|
|
|
|
|
|
int ascodec_read(unsigned int index);
|
|
|
|
|
2010-03-23 04:40:38 +00:00
|
|
|
int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
|
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
void ascodec_lock(void);
|
2008-11-10 11:04:43 +00:00
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
void ascodec_unlock(void);
|
2008-11-10 11:04:43 +00:00
|
|
|
|
2010-03-23 05:02:37 +00:00
|
|
|
void ascodec_wait_adc_finished(void);
|
2010-05-17 20:53:25 +00:00
|
|
|
|
|
|
|
static inline void ascodec_monitor_endofch(void) {} /* already enabled */
|
|
|
|
|
|
|
|
bool ascodec_endofch(void);
|
|
|
|
|
|
|
|
bool ascodec_chg_status(void);
|
|
|
|
|
|
|
|
#if CONFIG_CPU == AS3525v2
|
|
|
|
static inline void ascodec_write_pmu(unsigned int index, unsigned int subreg,
|
|
|
|
unsigned int value)
|
|
|
|
{
|
|
|
|
/* we disable interrupts to make sure no operation happen on the i2c bus
|
|
|
|
* between selecting the sub register and writing to it */
|
|
|
|
int oldstatus = disable_irq_save();
|
|
|
|
ascodec_write(AS3543_PMU_ENABLE, 8|subreg);
|
|
|
|
ascodec_write(index, value);
|
|
|
|
restore_irq(oldstatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ascodec_read_pmu(unsigned int index, unsigned int subreg)
|
2010-03-23 11:13:17 +00:00
|
|
|
{
|
2010-05-17 20:53:25 +00:00
|
|
|
/* we disable interrupts to make sure no operation happen on the i2c bus
|
|
|
|
* between selecting the sub register and reading it */
|
|
|
|
int oldstatus = disable_irq_save();
|
2010-05-26 11:14:13 +00:00
|
|
|
ascodec_write(AS3543_PMU_ENABLE, subreg);
|
2010-05-17 20:53:25 +00:00
|
|
|
int ret = ascodec_read(index);
|
|
|
|
restore_irq(oldstatus);
|
|
|
|
return ret;
|
2010-03-23 11:13:17 +00:00
|
|
|
}
|
2010-05-17 20:53:25 +00:00
|
|
|
#endif /* CONFIG_CPU == AS3525v2 */
|
2010-03-23 05:02:37 +00:00
|
|
|
|
2010-05-17 20:53:25 +00:00
|
|
|
static inline void ascodec_write_charger(int value)
|
|
|
|
{
|
|
|
|
#if CONFIG_CPU == AS3525
|
|
|
|
ascodec_write(AS3514_CHARGER, value);
|
|
|
|
#else
|
|
|
|
ascodec_write_pmu(AS3543_CHARGER, 1, value);
|
|
|
|
#endif
|
|
|
|
}
|
2010-03-23 05:02:37 +00:00
|
|
|
|
2010-05-17 20:53:25 +00:00
|
|
|
static inline int ascodec_read_charger(void)
|
|
|
|
{
|
|
|
|
#if CONFIG_CPU == AS3525
|
|
|
|
return ascodec_read(AS3514_CHARGER);
|
|
|
|
#else
|
|
|
|
return ascodec_read_pmu(AS3543_CHARGER, 1);
|
|
|
|
#endif
|
|
|
|
}
|
2010-03-23 05:02:37 +00:00
|
|
|
|
2010-03-23 07:52:55 +00:00
|
|
|
#endif /* !SIMULATOR */
|
|
|
|
|
2008-11-10 20:55:56 +00:00
|
|
|
#endif /* !_ASCODEC_TARGET_H */
|