summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2012-01-08 01:43:16 +0000
committerRafaël Carré <rafael.carre@gmail.com>2012-01-08 01:43:16 +0000
commit85528242844b71ac45e5331363a48a2956c38275 (patch)
tree10d8af9068c4f12b2f8f673f3a835bb3211c2f0e
parent2737a66471a640d83aba07578bd67b811a340034 (diff)
downloadrockbox-85528242844b71ac45e5331363a48a2956c38275.tar.gz
rockbox-85528242844b71ac45e5331363a48a2956c38275.zip
ascodec-target.h: remove
move prototypes to ascodec.h move code to ascodec*.c YPR0: use adc-as3514.c instead of duplicating it TODO: merge as3514.h and ascodec.h ? git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31626 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c8
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/audio/as3514.c10
-rw-r--r--firmware/export/ascodec.h37
-rw-r--r--firmware/target/arm/as3525/ascodec-as3525.c25
-rw-r--r--firmware/target/arm/as3525/ascodec-target.h96
-rw-r--r--firmware/target/arm/as3525/backlight-e200v2-fuze.c2
-rw-r--r--firmware/target/arm/as3525/debug-as3525.c2
-rw-r--r--firmware/target/arm/as3525/power-as3525.c2
-rw-r--r--firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c2
-rw-r--r--firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c2
-rw-r--r--firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c2
-rw-r--r--firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c2
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c2
-rw-r--r--firmware/target/arm/as3525/system-as3525.c16
-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
-rw-r--r--firmware/target/hosted/ypr0/ascodec-target.h80
-rw-r--r--firmware/target/hosted/ypr0/ascodec-ypr0.c37
-rw-r--r--firmware/target/hosted/ypr0/backlight-ypr0.c3
-rw-r--r--firmware/target/hosted/ypr0/gpio_ypr0.c3
-rw-r--r--firmware/target/hosted/ypr0/gpio_ypr0.h3
-rw-r--r--firmware/target/hosted/ypr0/powermgmt-ypr0.c1
-rw-r--r--firmware/target/hosted/ypr0/system-ypr0.c2
25 files changed, 179 insertions, 336 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 2a742408d2..e940d24fb0 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -108,11 +108,8 @@
108#include "debug-target.h" 108#include "debug-target.h"
109#endif 109#endif
110 110
111#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \ 111#if defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
112 || (CONFIG_CPU == AS3525 && defined(CONFIG_CHARGING)) \
113 || CONFIG_CPU == AS3525v2
114#include "ascodec.h" 112#include "ascodec.h"
115#include "as3514.h"
116#endif 113#endif
117 114
118#ifdef IPOD_NANO2G 115#ifdef IPOD_NANO2G
@@ -1129,8 +1126,7 @@ static bool view_battery(void)
1129 lcd_puts(0, line++, "T Battery: ?"); 1126 lcd_puts(0, line++, "T Battery: ?");
1130 } 1127 }
1131 1128
1132#elif defined(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \ 1129#if defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
1133 CONFIG_CPU == AS3525v2
1134 static const char * const chrgstate_strings[] = 1130 static const char * const chrgstate_strings[] =
1135 { 1131 {
1136 [CHARGE_STATE_DISABLED - CHARGE_STATE_DISABLED]= "Disabled", 1132 [CHARGE_STATE_DISABLED - CHARGE_STATE_DISABLED]= "Disabled",
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 2dd8b7b5b4..2c3f9ca0a7 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -64,6 +64,7 @@ target/hosted/sdl/app/button-application.c
64#endif 64#endif
65 65
66#ifdef SAMSUNG_YPR0 66#ifdef SAMSUNG_YPR0
67target/arm/adc-as3514.c
67#if (CONFIG_RTC == RTC_AS3514) 68#if (CONFIG_RTC == RTC_AS3514)
68drivers/rtc/rtc_as3514.c 69drivers/rtc/rtc_as3514.c
69#else 70#else
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c
index f07ee80d3c..22609621df 100644
--- a/firmware/drivers/audio/as3514.c
+++ b/firmware/drivers/audio/as3514.c
@@ -252,8 +252,9 @@ void audiohw_postinit(void)
252 /* wait until outputs have stabilized */ 252 /* wait until outputs have stabilized */
253 sleep(HZ/4); 253 sleep(HZ/4);
254 254
255#ifdef CPU_PP 255#ifdef SANSA_E200 /* check C200 */
256 ascodec_suppressor_on(false); 256 /* Release pop prevention */
257 GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x08);
257#endif 258#endif
258 259
259#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200) 260#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200)
@@ -334,8 +335,9 @@ void audiohw_close(void)
334 /* mute headphones */ 335 /* mute headphones */
335 audiohw_mute(true); 336 audiohw_mute(true);
336 337
337#ifdef CPU_PP 338#ifdef SANSA_E200 /* check C200 */
338 ascodec_suppressor_on(true); 339 /* Set pop prevention */
340 GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x08);
339#endif 341#endif
340 342
341 /* turn on common */ 343 /* turn on common */
diff --git a/firmware/export/ascodec.h b/firmware/export/ascodec.h
index 658153e420..3e104cbd07 100644
--- a/firmware/export/ascodec.h
+++ b/firmware/export/ascodec.h
@@ -23,13 +23,42 @@
23#define _ASCODEC_H 23#define _ASCODEC_H
24 24
25#include "config.h" 25#include "config.h"
26#include <stdbool.h>
26 27
27#ifdef HAVE_AS3514 28#include "as3514.h"
28#include "ascodec-target.h" 29
30#ifndef HAVE_AS3514
31# error Only for AS3514!
32#endif
33
34void ascodec_init(void) INIT_ATTR;
35void ascodec_close(void);
36
37void ascodec_lock(void);
38void ascodec_unlock(void);
39
40int ascodec_write(unsigned int index, unsigned int value);
41
42int ascodec_read(unsigned int index);
43
44int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
45
46void ascodec_wait_adc_finished(void);
47
48#ifdef CONFIG_CHARGING
49bool ascodec_endofch(void);
50bool ascodec_chg_status(void);
51void ascodec_monitor_endofch(void);
52void ascodec_write_charger(int value);
53int ascodec_read_charger(void);
29#endif 54#endif
30 55
31#ifdef SAMSUNG_YPR0 56#ifdef HAVE_AS3543
32#include "ascodec-target.h" 57void ascodec_write_pmu(unsigned int index, unsigned int subreg,
58 unsigned int value);
59int ascodec_read_pmu(unsigned int index, unsigned int subreg);
33#endif 60#endif
34 61
62void ascodec_suppressor_on(bool on); /* PP-only */
63
35#endif 64#endif
diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c
index ddf6786409..be81178859 100644
--- a/firmware/target/arm/as3525/ascodec-as3525.c
+++ b/firmware/target/arm/as3525/ascodec-as3525.c
@@ -44,7 +44,7 @@
44 interrupt bit 7 is raised and DACNT is not decremented after the transfer. 44 interrupt bit 7 is raised and DACNT is not decremented after the transfer.
45 */ 45 */
46 46
47#include "ascodec-target.h" 47#include "ascodec.h"
48#include "clock-target.h" 48#include "clock-target.h"
49#include "kernel.h" 49#include "kernel.h"
50#include "system.h" 50#include "system.h"
@@ -534,6 +534,29 @@ bool ascodec_chg_status(void)
534{ 534{
535 return ascodec_enrd0_shadow & CHG_STATUS; 535 return ascodec_enrd0_shadow & CHG_STATUS;
536} 536}
537
538void ascodec_monitor_endofch(void)
539{
540 /* already enabled */
541}
542
543void ascodec_write_charger(int value)
544{
545#if CONFIG_CPU == AS3525
546 ascodec_write(AS3514_CHARGER, value);
547#else
548 ascodec_write_pmu(AS3543_CHARGER, 1, value);
549#endif
550}
551
552int ascodec_read_charger(void)
553{
554#if CONFIG_CPU == AS3525
555 return ascodec_read(AS3514_CHARGER);
556#else
557 return ascodec_read_pmu(AS3543_CHARGER, 1);
558#endif
559}
537#endif /* CONFIG_CHARGING */ 560#endif /* CONFIG_CHARGING */
538 561
539/* 562/*
diff --git a/firmware/target/arm/as3525/ascodec-target.h b/firmware/target/arm/as3525/ascodec-target.h
deleted file mode 100644
index ece8c21dd0..0000000000
--- a/firmware/target/arm/as3525/ascodec-target.h
+++ /dev/null
@@ -1,96 +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#ifndef SIMULATOR
29
30#include "config.h"
31#include "as3514.h"
32#include "kernel.h" /* for struct semaphore */
33#include "clock-target.h" /* for AS3525_I2C_PRESCALER */
34#include "system-arm.h"
35
36/* Charge Pump and Power management Settings */
37#define AS314_CP_DCDC3_SETTING \
38 ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \
39 (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \
40 (0<<5) | /* LREG_CPnot Always write 0 */ \
41 (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \
42 (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\
43 (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/
44
45#define CVDD_1_20 0
46#define CVDD_1_15 1
47#define CVDD_1_10 2
48#define CVDD_1_05 3
49
50void ascodec_init(void) INIT_ATTR;
51
52int ascodec_write(unsigned int index, unsigned int value);
53
54int ascodec_read(unsigned int index);
55
56int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
57
58void ascodec_lock(void);
59
60void ascodec_unlock(void);
61
62void ascodec_wait_adc_finished(void);
63
64static inline void ascodec_monitor_endofch(void) {} /* already enabled */
65
66bool ascodec_endofch(void);
67
68bool ascodec_chg_status(void);
69
70#if CONFIG_CPU == AS3525v2
71void ascodec_write_pmu(unsigned int index, unsigned int subreg,
72 unsigned int value);
73int ascodec_read_pmu(unsigned int index, unsigned int subreg);
74#endif /* CONFIG_CPU == AS3525v2 */
75
76static inline void ascodec_write_charger(int value)
77{
78#if CONFIG_CPU == AS3525
79 ascodec_write(AS3514_CHARGER, value);
80#else
81 ascodec_write_pmu(AS3543_CHARGER, 1, value);
82#endif
83}
84
85static inline int ascodec_read_charger(void)
86{
87#if CONFIG_CPU == AS3525
88 return ascodec_read(AS3514_CHARGER);
89#else
90 return ascodec_read_pmu(AS3543_CHARGER, 1);
91#endif
92}
93
94#endif /* !SIMULATOR */
95
96#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/arm/as3525/backlight-e200v2-fuze.c b/firmware/target/arm/as3525/backlight-e200v2-fuze.c
index 61c2b1db79..91e1ef4d0c 100644
--- a/firmware/target/arm/as3525/backlight-e200v2-fuze.c
+++ b/firmware/target/arm/as3525/backlight-e200v2-fuze.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "lcd.h" 24#include "lcd.h"
25#include "backlight.h" 25#include "backlight.h"
26#include "ascodec-target.h" 26#include "ascodec.h"
27#include "as3514.h" 27#include "as3514.h"
28 28
29int buttonlight_is_on = 0; 29int buttonlight_is_on = 0;
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c
index 783f3f68a4..3e546bb5e3 100644
--- a/firmware/target/arm/as3525/debug-as3525.c
+++ b/firmware/target/arm/as3525/debug-as3525.c
@@ -26,7 +26,7 @@
26#include "system.h" 26#include "system.h"
27#include "cpu.h" 27#include "cpu.h"
28#include "pl180.h" 28#include "pl180.h"
29#include "ascodec-target.h" 29#include "ascodec.h"
30#include "adc.h" 30#include "adc.h"
31#include "storage.h" 31#include "storage.h"
32 32
diff --git a/firmware/target/arm/as3525/power-as3525.c b/firmware/target/arm/as3525/power-as3525.c
index 21ce98bd75..e6f1cfd24d 100644
--- a/firmware/target/arm/as3525/power-as3525.c
+++ b/firmware/target/arm/as3525/power-as3525.c
@@ -20,7 +20,7 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdbool.h> 21#include <stdbool.h>
22#include "config.h" 22#include "config.h"
23#include "ascodec-target.h" 23#include "ascodec.h"
24#include "as3514.h" 24#include "as3514.h"
25#include "power.h" 25#include "power.h"
26 26
diff --git a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c
index 0f4dd4dbbb..1da57de93a 100644
--- a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c
+++ b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "lcd.h" 24#include "lcd.h"
25#include "backlight.h" 25#include "backlight.h"
26#include "ascodec-target.h" 26#include "ascodec.h"
27#include "as3514.h" 27#include "as3514.h"
28 28
29int buttonlight_is_on = 0; 29int buttonlight_is_on = 0;
diff --git a/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c b/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c
index ef727608b5..e3b518b3f8 100644
--- a/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c
+++ b/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c
@@ -22,7 +22,7 @@
22#include "backlight-target.h" 22#include "backlight-target.h"
23#include "lcd.h" 23#include "lcd.h"
24#include "as3525v2.h" 24#include "as3525v2.h"
25#include "ascodec-target.h" 25#include "ascodec.h"
26 26
27void _backlight_on(void) 27void _backlight_on(void)
28{ 28{
diff --git a/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c b/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c
index bf28bd6108..f4927ba5bf 100644
--- a/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c
+++ b/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c
@@ -22,7 +22,7 @@
22#include "backlight-target.h" 22#include "backlight-target.h"
23#include "lcd.h" 23#include "lcd.h"
24#include "as3525v2.h" 24#include "as3525v2.h"
25#include "ascodec-target.h" 25#include "ascodec.h"
26 26
27void _backlight_on(void) 27void _backlight_on(void)
28{ 28{
diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
index 589f80436e..fd44d76cac 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c
@@ -24,7 +24,7 @@
24#include "backlight-target.h" 24#include "backlight-target.h"
25#include "lcd.h" 25#include "lcd.h"
26#include "as3525v2.h" 26#include "as3525v2.h"
27#include "ascodec-target.h" 27#include "ascodec.h"
28#include "lcd-target.h" 28#include "lcd-target.h"
29 29
30bool _backlight_init() 30bool _backlight_init()
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
index 68c626d829..a01b168b71 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "lcd.h" 24#include "lcd.h"
25#include "backlight.h" 25#include "backlight.h"
26#include "ascodec-target.h" 26#include "ascodec.h"
27#include "as3514.h" 27#include "as3514.h"
28 28
29void _backlight_set_brightness(int brightness) 29void _backlight_set_brightness(int brightness)
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index 89a07939b6..01aaeaccbe 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -24,7 +24,7 @@
24#include "kernel.h" 24#include "kernel.h"
25#include "system.h" 25#include "system.h"
26#include "panic.h" 26#include "panic.h"
27#include "ascodec-target.h" 27#include "ascodec.h"
28#include "adc.h" 28#include "adc.h"
29#include "dma-target.h" 29#include "dma-target.h"
30#include "clock-target.h" 30#include "clock-target.h"
@@ -33,6 +33,20 @@
33#include "backlight-target.h" 33#include "backlight-target.h"
34#include "lcd.h" 34#include "lcd.h"
35 35
36/* Charge Pump and Power management Settings */
37#define AS314_CP_DCDC3_SETTING \
38 ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \
39 (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \
40 (0<<5) | /* LREG_CPnot Always write 0 */ \
41 (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \
42 (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\
43 (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/
44
45#define CVDD_1_20 0
46#define CVDD_1_15 1
47#define CVDD_1_10 2
48#define CVDD_1_05 3
49
36#define default_interrupt(name) \ 50#define default_interrupt(name) \
37 extern __attribute__((weak,alias("UIRQ"))) void name (void) 51 extern __attribute__((weak,alias("UIRQ"))) void name (void)
38 52
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))
diff --git a/firmware/target/hosted/ypr0/ascodec-target.h b/firmware/target/hosted/ypr0/ascodec-target.h
deleted file mode 100644
index 2274d5f073..0000000000
--- a/firmware/target/hosted/ypr0/ascodec-target.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 *
10 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
11 *
12 * Copyright (c) 2011 Lorenzo Miori
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#ifndef _ASCODEC_TARGET_H
25#define _ASCODEC_TARGET_H
26
27#include "as3514.h"
28#include "kernel.h"
29#include "adc.h"
30#include "ascodec.h"
31
32int ascodec_init(void);
33void ascodec_close(void);
34int ascodec_write(unsigned int reg, unsigned int value);
35int ascodec_read(unsigned int reg);
36void ascodec_write_pmu(unsigned int index, unsigned int subreg, unsigned int value);
37int ascodec_read_pmu(unsigned int index, unsigned int subreg);
38int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
39unsigned short adc_read(int channel);
40void ascodec_lock(void);
41void ascodec_unlock(void);
42
43static inline bool ascodec_chg_status(void)
44{
45 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
46}
47
48static inline bool ascodec_endofch(void)
49{
50 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
51}
52
53static inline void ascodec_monitor_endofch(void)
54{
55 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
56}
57
58static inline void ascodec_wait_adc_finished(void)
59{
60 /*
61 * FIXME: not implemented
62 *
63 * If irqs are not available on the target platform,
64 * this should be most likely implemented by polling
65 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
66 * is polling IRQ_ENDOFCH.
67 */
68}
69
70static inline void ascodec_write_charger(int value)
71{
72 ascodec_write_pmu(AS3543_CHARGER, 1, value);
73}
74
75static inline int ascodec_read_charger(void)
76{
77 return ascodec_read_pmu(AS3543_CHARGER, 1);
78}
79
80#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/ypr0/ascodec-ypr0.c
index ec5568554b..954b4d95ef 100644
--- a/firmware/target/hosted/ypr0/ascodec-ypr0.c
+++ b/firmware/target/hosted/ypr0/ascodec-ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 9 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
11 * 10 *
@@ -28,7 +27,7 @@
28#include "sys/ioctl.h" 27#include "sys/ioctl.h"
29#include "stdlib.h" 28#include "stdlib.h"
30 29
31#include "ascodec-target.h" 30#include "ascodec.h"
32 31
33int afe_dev = -1; 32int afe_dev = -1;
34 33
@@ -134,24 +133,32 @@ void ascodec_unlock(void)
134{ 133{
135} 134}
136 135
137/* Read 10-bit channel data */ 136bool ascodec_chg_status(void)
138unsigned short adc_read(int channel)
139{ 137{
140 if ((unsigned)channel >= NUM_ADC_CHANNELS) 138 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
141 return 0; 139}
142 140
143 /* Select channel */ 141bool ascodec_endofch(void)
144 ascodec_write(AS3514_ADC_0, (channel << 4)); 142{
145 unsigned char buf[2]; 143 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
144}
145
146void ascodec_monitor_endofch(void)
147{
148 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
149}
146 150
147 /* Read data */
148 if (ascodec_readbytes(AS3514_ADC_0, 2, buf) < 0)
149 return 0;
150 151
151 /* decode to 10-bit and return */ 152void ascodec_write_charger(int value)
152 return (((buf[0] & 0x3) << 8) | buf[1]); 153{
154 ascodec_write_pmu(AS3543_CHARGER, 1, value);
155}
156
157int ascodec_read_charger(void)
158{
159 return ascodec_read_pmu(AS3543_CHARGER, 1);
153} 160}
154 161
155void adc_init(void) 162void ascodec_wait_adc_finished(void)
156{ 163{
157} 164}
diff --git a/firmware/target/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c
index 930b56be2e..551b386f19 100644
--- a/firmware/target/hosted/ypr0/backlight-ypr0.c
+++ b/firmware/target/hosted/ypr0/backlight-ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: backlight-gigabeat-s.c 25800 2010-05-04 10:07:53Z jethead71 $
9 * 8 *
10 * Copyright (C) 2011 by Lorenzo Miori 9 * Copyright (C) 2011 by Lorenzo Miori
11 * 10 *
@@ -24,7 +23,7 @@
24#include "backlight-target.h" 23#include "backlight-target.h"
25#include "lcd.h" 24#include "lcd.h"
26#include "as3514.h" 25#include "as3514.h"
27#include "ascodec-target.h" 26#include "ascodec.h"
28#include <fcntl.h> 27#include <fcntl.h>
29#include "unistd.h" 28#include "unistd.h"
30 29
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.c b/firmware/target/hosted/ypr0/gpio_ypr0.c
index 9c3f186a6b..3ee371d562 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.c
+++ b/firmware/target/hosted/ypr0/gpio_ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 9 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
11 * 10 *
@@ -51,4 +50,4 @@ int gpio_control(int request, int num, int mode, int val)
51{ 50{
52 R0GPIOInfo r = { .num = num, .mode = mode, .val = val, }; 51 R0GPIOInfo r = { .num = num, .mode = mode, .val = val, };
53 return ioctl(r0_gpio_dev, request, &r); 52 return ioctl(r0_gpio_dev, request, &r);
54} \ No newline at end of file 53}
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.h b/firmware/target/hosted/ypr0/gpio_ypr0.h
index 9fc7444887..ddf7100b2f 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.h
+++ b/firmware/target/hosted/ypr0/gpio_ypr0.h
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 9 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
11 * 10 *
@@ -39,4 +38,4 @@ void gpio_close(void);
39int gpio_control_struct(int request, R0GPIOInfo pin); 38int gpio_control_struct(int request, R0GPIOInfo pin);
40int gpio_control(int request, int num, int mode, int val); 39int gpio_control(int request, int num, int mode, int val);
41 40
42#endif \ No newline at end of file 41#endif
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
index 9c90f7ea02..6aba9c7ef5 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -22,7 +22,6 @@
22#include "powermgmt.h" 22#include "powermgmt.h"
23#include "power.h" 23#include "power.h"
24#include "file.h" 24#include "file.h"
25#include "ascodec-target.h"
26#include "as3514.h" 25#include "as3514.h"
27#include "sc900776.h" 26#include "sc900776.h"
28 27
diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c
index 784b4fe48e..11275c7809 100644
--- a/firmware/target/hosted/ypr0/system-ypr0.c
+++ b/firmware/target/hosted/ypr0/system-ypr0.c
@@ -30,7 +30,7 @@
30#include <SDL.h> 30#include <SDL.h>
31#endif 31#endif
32 32
33#include "ascodec-target.h" 33#include "ascodec.h"
34#include "gpio_ypr0.h" 34#include "gpio_ypr0.h"
35 35
36void power_off(void) 36void power_off(void)