Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
arch
sh
kernel
cpu
adc.c
Go to the documentation of this file.
1
/*
2
* linux/arch/sh/kernel/adc.c -- SH3 on-chip ADC support
3
*
4
* Copyright (C) 2004 Andriy Skulysh <
[email protected]
>
5
*/
6
7
#include <linux/module.h>
8
#include <
asm/adc.h
>
9
#include <asm/io.h>
10
11
12
int
adc_single
(
unsigned
int
channel
)
13
{
14
int
off;
15
unsigned
char
csr
;
16
17
if
(channel >= 8)
return
-1;
18
19
off = (channel & 0x03) << 2;
20
21
csr =
__raw_readb
(
ADCSR
);
22
csr = channel |
ADCSR_ADST
|
ADCSR_CKS
;
23
__raw_writeb
(csr,
ADCSR
);
24
25
do
{
26
csr =
__raw_readb
(
ADCSR
);
27
}
while
((csr &
ADCSR_ADF
) == 0);
28
29
csr &= ~(ADCSR_ADF |
ADCSR_ADST
);
30
__raw_writeb
(csr,
ADCSR
);
31
32
return
(((
__raw_readb
(
ADDRAH
+ off) << 8) |
33
__raw_readb
(
ADDRAL
+ off)) >> 6);
34
}
35
36
EXPORT_SYMBOL
(
adc_single
);
Generated on Thu Jan 10 2013 13:03:22 for Linux Kernel by
1.8.2