summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/recorder/power-recorder.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/archos/recorder/power-recorder.c')
-rw-r--r--firmware/target/sh/archos/recorder/power-recorder.c107
1 files changed, 0 insertions, 107 deletions
diff --git a/firmware/target/sh/archos/recorder/power-recorder.c b/firmware/target/sh/archos/recorder/power-recorder.c
deleted file mode 100644
index 48cfdc1e17..0000000000
--- a/firmware/target/sh/archos/recorder/power-recorder.c
+++ /dev/null
@@ -1,107 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#include "config.h"
22#include "cpu.h"
23#include <stdbool.h>
24#include "adc.h"
25#include "kernel.h"
26#include "system.h"
27#include "power.h"
28#include "powermgmt-target.h"
29#include "usb.h"
30
31static bool charger_on;
32
33void power_init(void)
34{
35 PBCR2 &= ~0x0c00; /* GPIO for PB5 */
36 or_b(0x20, &PBIORL); /* Set charging control bit to output */
37 charger_enable(false); /* Default to charger OFF */
38}
39
40unsigned int power_input_status(void)
41{
42 /* Recorder */
43 return (adc_read(ADC_EXT_POWER) > 0x100) ?
44 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
45}
46
47void charger_enable(bool on)
48{
49 if(on)
50 {
51 and_b(~0x20, &PBDRL);
52 }
53 else
54 {
55 or_b(0x20, &PBDRL);
56 }
57
58 charger_on = on;
59}
60
61bool charger_enabled(void)
62{
63 return charger_on;
64}
65
66void ide_power_enable(bool on)
67{
68 bool touched = false;
69
70 if(on)
71 {
72 or_b(0x20, &PADRL);
73 touched = true;
74 }
75#ifdef HAVE_ATA_POWER_OFF
76 if(!on)
77 {
78 and_b(~0x20, &PADRL);
79 touched = true;
80 }
81#endif /* HAVE_ATA_POWER_OFF */
82
83/* late port preparation, else problems with read/modify/write
84 of other bits on same port, while input and floating high */
85 if (touched)
86 {
87 or_b(0x20, &PAIORL); /* PA5 is an output */
88 PACR2 &= 0xFBFF; /* GPIO for PA5 */
89 }
90}
91
92
93bool ide_powered(void)
94{
95 if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */
96 return true; /* would be floating high, disk on */
97 else
98 return (PADRL & 0x20) != 0;
99}
100
101void power_off(void)
102{
103 disable_irq();
104 and_b(~0x10, &PBDRL);
105 or_b(0x10, &PBIORL);
106 while(1);
107}