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 */
34 /* Charge Pump and Power management Settings */
35 #define AS314_CP_DCDC3_SETTING \
36 ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \
37 (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \
38 (0<<5) | /* LREG_CPnot Always write 0 */ \
39 (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \
40 (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\
41 (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/
48 #define ASCODEC_REQ_READ 0
49 #define ASCODEC_REQ_WRITE 1
52 * How many bytes we using in struct ascodec_request for the data buffer.
53 * 4 fits the alignment best right now.
54 * We don't actually use more than 2 at the moment (in adc_read).
55 * Upper limit would be 255 since DACNT is 8 bits!
57 #define ASCODEC_REQ_MAXLEN 4
59 typedef void (ascodec_cb_fn
)(unsigned const char *data
, unsigned cnt
);
61 struct ascodec_request
{
66 unsigned char data
[ASCODEC_REQ_MAXLEN
];
68 ascodec_cb_fn
*callback
;
69 struct ascodec_request
*next
;
72 void ascodec_init(void);
74 int ascodec_write(unsigned int index
, unsigned int value
);
76 int ascodec_read(unsigned int index
);
78 int ascodec_readbytes(unsigned int index
, unsigned int len
, unsigned char *data
);
81 * The request struct passed in must be allocated statically.
82 * If you call ascodec_async_write from different places, each
83 * call needs it's own request struct.
84 * This comment is duplicated in .c and .h for your convenience.
86 void ascodec_async_write(unsigned index
, unsigned int value
, struct ascodec_request
*req
);
89 * The request struct passed in must be allocated statically.
90 * If you call ascodec_async_read from different places, each
91 * call needs it's own request struct.
92 * If len is bigger than ASCODEC_REQ_MAXLEN it will be
93 * set to ASCODEC_REQ_MAXLEN.
94 * This comment is duplicated in .c and .h for your convenience.
96 void ascodec_async_read(unsigned index
, unsigned int len
,
97 struct ascodec_request
*req
, ascodec_cb_fn
*cb
);
99 void ascodec_req_init(struct ascodec_request
*req
, int type
,
100 unsigned int index
, unsigned int cnt
);
102 void ascodec_submit(struct ascodec_request
*req
);
104 void ascodec_lock(void);
106 void ascodec_unlock(void);
108 #if CONFIG_CPU == AS3525
109 void ascodec_wait_adc_finished(void);
111 static inline void ascodec_wait_adc_finished(void)
113 /* FIXME: Doesn't work yet on AS3525v2 */
117 void ascodec_enable_endofch_irq(void);
119 void ascodec_disable_endofch_irq(void);
121 #endif /* !SIMULATOR */
123 #endif /* !_ASCODEC_TARGET_H */