summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/player/power-player.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-08-14 22:06:23 +0000
committerJens Arnold <amiconn@rockbox.org>2007-08-14 22:06:23 +0000
commit8a177345ce7b96a00f1f14387412c2dfacfeaf34 (patch)
treefbb8dfa828cf578d535e3d77deebf077b24d2970 /firmware/target/sh/archos/player/power-player.c
parent360d951271659af590103dd81efb8166f5b226a2 (diff)
downloadrockbox-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/player/power-player.c')
-rw-r--r--firmware/target/sh/archos/player/power-player.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/firmware/target/sh/archos/player/power-player.c b/firmware/target/sh/archos/player/power-player.c
new file mode 100644
index 0000000000..7d9d0d7d16
--- /dev/null
+++ b/firmware/target/sh/archos/player/power-player.c
@@ -0,0 +1,87 @@
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
28void power_init(void)
29{
30}
31
32bool charger_inserted(void)
33{
34 /* Player */
35 return (PADR & 1) == 0;
36}
37
38void ide_power_enable(bool on)
39{
40 bool touched = false;
41
42 if(on)
43 {
44 or_b(0x10, &PBDRL);
45 touched = true;
46 }
47#ifdef HAVE_ATA_POWER_OFF
48 if(!on)
49 {
50 and_b(~0x10, &PBDRL);
51 touched = true;
52 }
53#endif /* HAVE_ATA_POWER_OFF */
54
55/* late port preparation, else problems with read/modify/write
56 of other bits on same port, while input and floating high */
57 if (touched)
58 {
59 or_b(0x10, &PBIORL); /* PB4 is an output */
60 PBCR2 &= ~0x0300; /* GPIO for PB4 */
61 }
62}
63
64
65bool ide_powered(void)
66{
67#ifdef HAVE_ATA_POWER_OFF
68 /* This is not correct for very old players, since these are unable to
69 * control hd power. However, driving the pin doesn't hurt, because it
70 * is not connected anywhere */
71 if ((PBCR2 & 0x0300) || !(PBIORL & 0x10)) /* not configured for output */
72 return false; /* would be floating low, disk off */
73 else
74 return (PBDRL & 0x10) != 0;
75#else /* !defined(NEEDS_ATA_POWER_ON) && !defined(HAVE_ATA_POWER_OFF) */
76 return true; /* pretend always powered if not controlable */
77#endif
78}
79
80void power_off(void)
81{
82 set_irq_level(HIGHEST_IRQ_LEVEL);
83 and_b(~0x08, &PADRH);
84 or_b(0x08, &PAIORH);
85 while(1)
86 yield();
87}