diff options
-rw-r--r-- | firmware/export/config.h | 3 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/adc-s5l8700.c | 94 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/adc-target.h (renamed from firmware/target/arm/s5l8700/meizu-m3/adc-target.h) | 10 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sl/adc-target.h | 35 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sp/adc-target.h | 35 |
5 files changed, 100 insertions, 77 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h index 5148096a30..6e4f9d05c9 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -554,7 +554,8 @@ Lyre prototype 1*/ | |||
554 | #endif /* BOOTLOADER */ | 554 | #endif /* BOOTLOADER */ |
555 | 555 | ||
556 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ | 556 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ |
557 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == S3C2440) | 557 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == S3C2440) \ |
558 | || (CONFIG_CPU == S5L8700) | ||
558 | #define HAVE_WAKEUP_OBJECTS | 559 | #define HAVE_WAKEUP_OBJECTS |
559 | #endif | 560 | #endif |
560 | 561 | ||
diff --git a/firmware/target/arm/s5l8700/adc-s5l8700.c b/firmware/target/arm/s5l8700/adc-s5l8700.c new file mode 100644 index 0000000000..4407334099 --- /dev/null +++ b/firmware/target/arm/s5l8700/adc-s5l8700.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | |||
24 | #include "inttypes.h" | ||
25 | #include "s5l8700.h" | ||
26 | #include "adc.h" | ||
27 | #include "adc-target.h" | ||
28 | #include "kernel.h" | ||
29 | |||
30 | /* Driver for the built-in ADC of the s5l8700 | ||
31 | |||
32 | The ADC is put into standby mode after each conversion. | ||
33 | */ | ||
34 | |||
35 | #define ADC_PRESCALER 100 /* 1MHz ADC clock, assuming 100 MHz PCLK */ | ||
36 | #define ADC_DEFAULT (1<<14) | /* prescale enable */ \ | ||
37 | ((ADC_PRESCALER-1)<<6) | /* prescaler */ \ | ||
38 | (0<<3) | /* sel_mux */ \ | ||
39 | (0<<2) | /* stdbm */ \ | ||
40 | (0<<1) | /* read_start */ \ | ||
41 | (0<<0) /* enable start */ \ | ||
42 | |||
43 | |||
44 | static struct mutex adc_mtx; | ||
45 | static struct wakeup adc_wakeup; | ||
46 | |||
47 | void INT_ADC(void) | ||
48 | { | ||
49 | wakeup_signal(&adc_wakeup); | ||
50 | } | ||
51 | |||
52 | unsigned short adc_read(int channel) | ||
53 | { | ||
54 | unsigned short data; | ||
55 | |||
56 | mutex_lock(&adc_mtx); | ||
57 | |||
58 | /* set channel and start conversion */ | ||
59 | ADCCON = ADC_DEFAULT | | ||
60 | (channel << 3) | | ||
61 | (1 << 0); /* enable start */ | ||
62 | |||
63 | /* wait for conversion */ | ||
64 | wakeup_wait(&adc_wakeup, TIMEOUT_BLOCK); | ||
65 | |||
66 | /* get the converted data */ | ||
67 | data = ADCDAT0; | ||
68 | |||
69 | /* put ADC back into standby */ | ||
70 | ADCCON |= (1 << 2); | ||
71 | |||
72 | mutex_unlock(&adc_mtx); | ||
73 | |||
74 | return data; | ||
75 | } | ||
76 | |||
77 | void adc_init(void) | ||
78 | { | ||
79 | mutex_init(&adc_mtx); | ||
80 | wakeup_init(&adc_wakeup); | ||
81 | |||
82 | /* enable clock to ADC */ | ||
83 | PWRCON &= ~(1 << 10); | ||
84 | |||
85 | /* configure ADC and put in standby */ | ||
86 | ADCCON = ADC_DEFAULT | (1 << 2); | ||
87 | |||
88 | /* configure conversion delay (use default) */ | ||
89 | ADCDLY = 0xFF; | ||
90 | |||
91 | /* enable interrupt */ | ||
92 | INTMSK |= (1 << 31); | ||
93 | } | ||
94 | |||
diff --git a/firmware/target/arm/s5l8700/meizu-m3/adc-target.h b/firmware/target/arm/s5l8700/adc-target.h index d21d401735..b54d1bf4cc 100644 --- a/firmware/target/arm/s5l8700/meizu-m3/adc-target.h +++ b/firmware/target/arm/s5l8700/adc-target.h | |||
@@ -21,15 +21,13 @@ | |||
21 | #ifndef _ADC_TARGET_H_ | 21 | #ifndef _ADC_TARGET_H_ |
22 | #define _ADC_TARGET_H_ | 22 | #define _ADC_TARGET_H_ |
23 | 23 | ||
24 | /* only two channels used by the Gigabeat */ | 24 | #define NUM_ADC_CHANNELS 4 |
25 | #define NUM_ADC_CHANNELS 1 | ||
26 | 25 | ||
27 | #define ADC_UNKNOWN_1 0 | 26 | #define ADC_UNKNOWN_0 0 |
28 | #define ADC_UNKNOWN_2 1 | 27 | #define ADC_UNKNOWN_1 1 |
29 | #define ADC_BATTERY 2 | 28 | #define ADC_BATTERY 2 |
30 | #define ADC_UNKNOWN_4 3 | 29 | #define ADC_UNKNOWN_3 3 |
31 | 30 | ||
32 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | 31 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ |
33 | #define ADC_READ_ERROR 0xFFFF | ||
34 | 32 | ||
35 | #endif | 33 | #endif |
diff --git a/firmware/target/arm/s5l8700/meizu-m6sl/adc-target.h b/firmware/target/arm/s5l8700/meizu-m6sl/adc-target.h deleted file mode 100644 index d21d401735..0000000000 --- a/firmware/target/arm/s5l8700/meizu-m6sl/adc-target.h +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | /* only two channels used by the Gigabeat */ | ||
25 | #define NUM_ADC_CHANNELS 1 | ||
26 | |||
27 | #define ADC_UNKNOWN_1 0 | ||
28 | #define ADC_UNKNOWN_2 1 | ||
29 | #define ADC_BATTERY 2 | ||
30 | #define ADC_UNKNOWN_4 3 | ||
31 | |||
32 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
33 | #define ADC_READ_ERROR 0xFFFF | ||
34 | |||
35 | #endif | ||
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/adc-target.h b/firmware/target/arm/s5l8700/meizu-m6sp/adc-target.h deleted file mode 100644 index d21d401735..0000000000 --- a/firmware/target/arm/s5l8700/meizu-m6sp/adc-target.h +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | /* only two channels used by the Gigabeat */ | ||
25 | #define NUM_ADC_CHANNELS 1 | ||
26 | |||
27 | #define ADC_UNKNOWN_1 0 | ||
28 | #define ADC_UNKNOWN_2 1 | ||
29 | #define ADC_BATTERY 2 | ||
30 | #define ADC_UNKNOWN_4 3 | ||
31 | |||
32 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
33 | #define ADC_READ_ERROR 0xFFFF | ||
34 | |||
35 | #endif | ||