diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-08-14 22:06:23 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-08-14 22:06:23 +0000 |
commit | 8a177345ce7b96a00f1f14387412c2dfacfeaf34 (patch) | |
tree | fbb8dfa828cf578d535e3d77deebf077b24d2970 /firmware/target/sh/archos/recorder | |
parent | 360d951271659af590103dd81efb8166f5b226a2 (diff) | |
download | rockbox-8a177345ce7b96a00f1f14387412c2dfacfeaf34.tar.gz rockbox-8a177345ce7b96a00f1f14387412c2dfacfeaf34.zip |
Moved archos power handling into target tree. * Tuner power handling cleaned up a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14345 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/sh/archos/recorder')
-rw-r--r-- | firmware/target/sh/archos/recorder/power-recorder.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/firmware/target/sh/archos/recorder/power-recorder.c b/firmware/target/sh/archos/recorder/power-recorder.c new file mode 100644 index 0000000000..2af8df1bb6 --- /dev/null +++ b/firmware/target/sh/archos/recorder/power-recorder.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "adc.h" | ||
23 | #include "kernel.h" | ||
24 | #include "system.h" | ||
25 | #include "power.h" | ||
26 | #include "usb.h" | ||
27 | |||
28 | bool charger_enabled; | ||
29 | |||
30 | void power_init(void) | ||
31 | { | ||
32 | PBCR2 &= ~0x0c00; /* GPIO for PB5 */ | ||
33 | or_b(0x20, &PBIORL); /* Set charging control bit to output */ | ||
34 | charger_enable(false); /* Default to charger OFF */ | ||
35 | } | ||
36 | |||
37 | bool charger_inserted(void) | ||
38 | { | ||
39 | /* Recorder */ | ||
40 | return adc_read(ADC_EXT_POWER) > 0x100; | ||
41 | } | ||
42 | |||
43 | void charger_enable(bool on) | ||
44 | { | ||
45 | if(on) | ||
46 | { | ||
47 | and_b(~0x20, &PBDRL); | ||
48 | charger_enabled = 1; | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | or_b(0x20, &PBDRL); | ||
53 | charger_enabled = 0; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | void ide_power_enable(bool on) | ||
58 | { | ||
59 | bool touched = false; | ||
60 | |||
61 | if(on) | ||
62 | { | ||
63 | or_b(0x20, &PADRL); | ||
64 | touched = true; | ||
65 | } | ||
66 | #ifdef HAVE_ATA_POWER_OFF | ||
67 | if(!on) | ||
68 | { | ||
69 | and_b(~0x20, &PADRL); | ||
70 | touched = true; | ||
71 | } | ||
72 | #endif /* HAVE_ATA_POWER_OFF */ | ||
73 | |||
74 | /* late port preparation, else problems with read/modify/write | ||
75 | of other bits on same port, while input and floating high */ | ||
76 | if (touched) | ||
77 | { | ||
78 | or_b(0x20, &PAIORL); /* PA5 is an output */ | ||
79 | PACR2 &= 0xFBFF; /* GPIO for PA5 */ | ||
80 | } | ||
81 | } | ||
82 | |||
83 | |||
84 | bool ide_powered(void) | ||
85 | { | ||
86 | #ifdef HAVE_ATA_POWER_OFF | ||
87 | if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */ | ||
88 | return true; /* would be floating high, disk on */ | ||
89 | else | ||
90 | return (PADRL & 0x20) != 0; | ||
91 | #else /* !defined(NEEDS_ATA_POWER_ON) && !defined(HAVE_ATA_POWER_OFF) */ | ||
92 | return true; /* pretend always powered if not controlable */ | ||
93 | #endif | ||
94 | } | ||
95 | |||
96 | void power_off(void) | ||
97 | { | ||
98 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
99 | and_b(~0x10, &PBDRL); | ||
100 | or_b(0x10, &PBIORL); | ||
101 | while(1) | ||
102 | yield(); | ||
103 | } | ||