1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Driver for AS3514 audio codec
12 * Copyright (c) 2007 Daniel Ankers
13 * Copyright (c) 2007 Christian Gmeiner
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
25 #ifndef _ASCODEC_TARGET_H
26 #define _ASCODEC_TARGET_H
31 #include "kernel.h" /* for struct wakeup */
32 #include "clock-target.h" /* for AS3525_I2C_PRESCALER */
33 #include "system-arm.h"
35 /* Charge Pump and Power management Settings */
36 #define AS314_CP_DCDC3_SETTING \
37 ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \
38 (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \
39 (0<<5) | /* LREG_CPnot Always write 0 */ \
40 (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \
41 (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\
42 (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/
49 void ascodec_init(void) INIT_ATTR
;
51 int ascodec_write(unsigned int index
, unsigned int value
);
53 int ascodec_read(unsigned int index
);
55 int ascodec_readbytes(unsigned int index
, unsigned int len
, unsigned char *data
);
57 void ascodec_lock(void);
59 void ascodec_unlock(void);
61 void ascodec_wait_adc_finished(void);
63 static inline void ascodec_monitor_endofch(void) {} /* already enabled */
65 bool ascodec_endofch(void);
67 bool ascodec_chg_status(void);
69 #if CONFIG_CPU == AS3525v2
70 static inline void ascodec_write_pmu(unsigned int index
, unsigned int subreg
,
73 /* we disable interrupts to make sure no operation happen on the i2c bus
74 * between selecting the sub register and writing to it */
75 int oldstatus
= disable_irq_save();
76 ascodec_write(AS3543_PMU_ENABLE
, 8|subreg
);
77 ascodec_write(index
, value
);
78 restore_irq(oldstatus
);
81 static inline int ascodec_read_pmu(unsigned int index
, unsigned int subreg
)
83 /* we disable interrupts to make sure no operation happen on the i2c bus
84 * between selecting the sub register and reading it */
85 int oldstatus
= disable_irq_save();
86 ascodec_write(AS3543_PMU_ENABLE
, subreg
);
87 int ret
= ascodec_read(index
);
88 restore_irq(oldstatus
);
91 #endif /* CONFIG_CPU == AS3525v2 */
93 static inline void ascodec_write_charger(int value
)
95 #if CONFIG_CPU == AS3525
96 ascodec_write(AS3514_CHARGER
, value
);
98 ascodec_write_pmu(AS3543_CHARGER
, 1, value
);
102 static inline int ascodec_read_charger(void)
104 #if CONFIG_CPU == AS3525
105 return ascodec_read(AS3514_CHARGER
);
107 return ascodec_read_pmu(AS3543_CHARGER
, 1);
111 #endif /* !SIMULATOR */
113 #endif /* !_ASCODEC_TARGET_H */