diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/kernel/cpu/adc.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/sh/kernel/cpu/adc.c')
-rw-r--r-- | arch/sh/kernel/cpu/adc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/adc.c b/arch/sh/kernel/cpu/adc.c new file mode 100644 index 000000000000..da3d6877f93d --- /dev/null +++ b/arch/sh/kernel/cpu/adc.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * linux/arch/sh/kernel/adc.c -- SH3 on-chip ADC support | ||
3 | * | ||
4 | * Copyright (C) 2004 Andriy Skulysh <askulysh@image.kiev.ua> | ||
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 = ctrl_inb(ADCSR); | ||
22 | csr = channel | ADCSR_ADST | ADCSR_CKS; | ||
23 | ctrl_outb(csr, ADCSR); | ||
24 | |||
25 | do { | ||
26 | csr = ctrl_inb(ADCSR); | ||
27 | } while ((csr & ADCSR_ADF) == 0); | ||
28 | |||
29 | csr &= ~(ADCSR_ADF | ADCSR_ADST); | ||
30 | ctrl_outb(csr, ADCSR); | ||
31 | |||
32 | return (((ctrl_inb(ADDRAH + off) << 8) | | ||
33 | ctrl_inb(ADDRAL + off)) >> 6); | ||
34 | } | ||
35 | |||
36 | EXPORT_SYMBOL(adc_single); | ||