summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pp
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pp')
-rw-r--r--firmware/target/arm/pp/ascodec-pp.c77
-rw-r--r--firmware/target/arm/pp/ascodec-target.h97
-rw-r--r--firmware/target/arm/pp/i2c-pp.c3
3 files changed, 64 insertions, 113 deletions
diff --git a/firmware/target/arm/pp/ascodec-pp.c b/firmware/target/arm/pp/ascodec-pp.c
index 49a69d1a11..eb8093c841 100644
--- a/firmware/target/arm/pp/ascodec-pp.c
+++ b/firmware/target/arm/pp/ascodec-pp.c
@@ -26,7 +26,8 @@
26 26
27#include "audiohw.h" 27#include "audiohw.h"
28#include "i2s.h" 28#include "i2s.h"
29#include "ascodec-target.h" 29#include "i2c-pp.h"
30#include "ascodec.h"
30 31
31/* 32/*
32 * Initialise the PP I2C and I2S. 33 * Initialise the PP I2C and I2S.
@@ -65,18 +66,64 @@ void audiohw_init(void)
65 audiohw_preinit(); 66 audiohw_preinit();
66} 67}
67 68
68void ascodec_suppressor_on(bool on) 69int ascodec_write(unsigned int reg, unsigned int value)
69{ 70{
70 /* CHECK: Good for c200 too? */ 71 return pp_i2c_send(AS3514_I2C_ADDR, reg, value);
71#ifdef SANSA_E200 72}
72 if (on) { 73
73 /* Set pop prevention */ 74int ascodec_read(unsigned int reg)
74 GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x08); 75{
75 } else { 76 return i2c_readbyte(AS3514_I2C_ADDR, reg);
76 /* Release pop prevention */ 77}
77 GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x08); 78
78 } 79int ascodec_readbytes(unsigned int addr, unsigned int len, unsigned char *data)
79#else 80{
80 (void)on; 81 return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data);
81#endif 82}
82} 83
84void ascodec_lock(void)
85{
86 i2c_lock();
87}
88
89void ascodec_unlock(void)
90{
91 i2c_unlock();
92}
93
94bool ascodec_chg_status(void)
95{
96 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
97}
98
99bool ascodec_endofch(void)
100{
101 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
102}
103
104void ascodec_monitor_endofch(void)
105{
106 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
107}
108
109void ascodec_write_charger(int value)
110{
111 ascodec_write(AS3514_CHARGER, value);
112}
113
114int ascodec_read_charger(void)
115{
116 return ascodec_read(AS3514_CHARGER);
117}
118
119void ascodec_wait_adc_finished(void)
120{
121 /*
122 * FIXME: not implemented
123 *
124 * If irqs are not available on the target platform,
125 * this should be most likely implemented by polling
126 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
127 * is polling IRQ_ENDOFCH.
128 */
129}
diff --git a/firmware/target/arm/pp/ascodec-target.h b/firmware/target/arm/pp/ascodec-target.h
deleted file mode 100644
index e7fd1b3b35..0000000000
--- a/firmware/target/arm/pp/ascodec-target.h
+++ /dev/null
@@ -1,97 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Driver for AS3514 audio codec
11 *
12 * Copyright (c) 2007 Daniel Ankers
13 * Copyright (c) 2007 Christian Gmeiner
14 *
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.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24
25#ifndef _ASCODEC_TARGET_H
26#define _ASCODEC_TARGET_H
27
28#include "config.h"
29
30#include "as3514.h"
31#include "i2c-pp.h"
32
33static inline int ascodec_write(unsigned int reg, unsigned int value)
34{
35 return pp_i2c_send(AS3514_I2C_ADDR, reg, value);
36}
37
38static inline int ascodec_read(unsigned int reg)
39{
40 return i2c_readbyte(AS3514_I2C_ADDR, reg);
41}
42
43static inline int ascodec_readbytes(int addr, int len, unsigned char *data)
44{
45 return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data);
46}
47
48static inline void ascodec_lock(void)
49{
50 i2c_lock();
51}
52
53static inline void ascodec_unlock(void)
54{
55 i2c_unlock();
56}
57
58static inline bool ascodec_chg_status(void)
59{
60 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
61}
62
63static inline bool ascodec_endofch(void)
64{
65 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
66}
67
68static inline void ascodec_monitor_endofch(void)
69{
70 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
71}
72
73static inline void ascodec_wait_adc_finished(void)
74{
75 /*
76 * FIXME: not implemented
77 *
78 * If irqs are not available on the target platform,
79 * this should be most likely implemented by polling
80 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
81 * is polling IRQ_ENDOFCH.
82 */
83}
84
85static inline void ascodec_write_charger(int value)
86{
87 ascodec_write(AS3514_CHARGER, value);
88}
89
90static inline int ascodec_read_charger(void)
91{
92 return ascodec_read(AS3514_CHARGER);
93}
94
95extern void ascodec_suppressor_on(bool on);
96
97#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/arm/pp/i2c-pp.c b/firmware/target/arm/pp/i2c-pp.c
index 58740b5c66..192af0e304 100644
--- a/firmware/target/arm/pp/i2c-pp.c
+++ b/firmware/target/arm/pp/i2c-pp.c
@@ -33,8 +33,9 @@
33#include "system.h" 33#include "system.h"
34#include "i2c.h" 34#include "i2c.h"
35#include "i2c-pp.h" 35#include "i2c-pp.h"
36#ifdef HAVE_AS3514
36#include "ascodec.h" 37#include "ascodec.h"
37#include "as3514.h" 38#endif
38 39
39#define I2C_CTRL (*(volatile unsigned char*)(I2C_BASE+0x00)) 40#define I2C_CTRL (*(volatile unsigned char*)(I2C_BASE+0x00))
40#define I2C_ADDR (*(volatile unsigned char*)(I2C_BASE+0x04)) 41#define I2C_ADDR (*(volatile unsigned char*)(I2C_BASE+0x04))