Added battery profile change to correct file, removed unused powermgmt-as3525.c
[kugel-rb.git] / firmware / target / arm / as3525 / ascodec-target.h
blob37947541c2867d47743dd0126c7dbc7fca7145f9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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
28 #ifndef SIMULATOR
30 #include "as3514.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*/
44 #define CVDD_1_20 0
45 #define CVDD_1_15 1
46 #define CVDD_1_10 2
47 #define CVDD_1_05 3
49 #define ASCODEC_REQ_READ 0
50 #define ASCODEC_REQ_WRITE 1
53 * How many bytes we using in struct ascodec_request for the data buffer.
54 * 4 fits the alignment best right now.
55 * We don't actually use more than 2 at the moment (in adc_read).
56 * Upper limit would be 255 since DACNT is 8 bits!
58 #define ASCODEC_REQ_MAXLEN 4
60 typedef void (ascodec_cb_fn)(unsigned const char *data, unsigned cnt);
62 struct ascodec_request {
63 unsigned char type;
64 unsigned char index;
65 unsigned char status;
66 unsigned char cnt;
67 unsigned char data[ASCODEC_REQ_MAXLEN];
68 struct wakeup wkup;
69 ascodec_cb_fn *callback;
70 struct ascodec_request *next;
73 void ascodec_init(void);
75 int ascodec_write(unsigned int index, unsigned int value);
77 #if CONFIG_CPU == AS3525v2
78 static inline void ascodec_write_pmu(unsigned int index, unsigned int subreg,
79 unsigned int value)
81 /* we disable interrupts to make sure no operation happen on the i2c bus
82 * between selecting the sub register and writing to it */
83 int oldstatus = disable_irq_save();
84 ascodec_write(AS3543_PMU_ENABLE, 8|subreg);
85 ascodec_write(index, value);
86 restore_irq(oldstatus);
88 #endif
90 int ascodec_read(unsigned int index);
92 int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
95 * The request struct passed in must be allocated statically.
96 * If you call ascodec_async_write from different places, each
97 * call needs it's own request struct.
98 * This comment is duplicated in .c and .h for your convenience.
100 void ascodec_async_write(unsigned index, unsigned int value, struct ascodec_request *req);
103 * The request struct passed in must be allocated statically.
104 * If you call ascodec_async_read from different places, each
105 * call needs it's own request struct.
106 * If len is bigger than ASCODEC_REQ_MAXLEN it will be
107 * set to ASCODEC_REQ_MAXLEN.
108 * This comment is duplicated in .c and .h for your convenience.
110 void ascodec_async_read(unsigned index, unsigned int len,
111 struct ascodec_request *req, ascodec_cb_fn *cb);
113 void ascodec_req_init(struct ascodec_request *req, int type,
114 unsigned int index, unsigned int cnt);
116 void ascodec_submit(struct ascodec_request *req);
118 void ascodec_lock(void);
120 void ascodec_unlock(void);
122 #if CONFIG_CPU == AS3525
123 void ascodec_wait_adc_finished(void);
124 #else
125 static inline void ascodec_wait_adc_finished(void)
127 /* FIXME: Doesn't work yet on AS3525v2 */
129 #endif
131 void ascodec_enable_endofch_irq(void);
133 void ascodec_disable_endofch_irq(void);
135 #endif /* !SIMULATOR */
137 #endif /* !_ASCODEC_TARGET_H */