summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/fm_v2/power-fm_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/archos/fm_v2/power-fm_v2.c')
-rw-r--r--firmware/target/sh/archos/fm_v2/power-fm_v2.c115
1 files changed, 0 insertions, 115 deletions
diff --git a/firmware/target/sh/archos/fm_v2/power-fm_v2.c b/firmware/target/sh/archos/fm_v2/power-fm_v2.c
deleted file mode 100644
index ce1ef19970..0000000000
--- a/firmware/target/sh/archos/fm_v2/power-fm_v2.c
+++ /dev/null
@@ -1,115 +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 "usb.h"
29
30#if CONFIG_TUNER
31bool tuner_power(bool status)
32{
33 (void)status;
34 return true;
35}
36
37#endif /* #if CONFIG_TUNER */
38
39void power_init(void)
40{
41 PBCR2 &= ~0x0c00; /* GPIO for PB5 */
42 or_b(0x20, &PBIORL);
43 or_b(0x20, &PBDRL); /* hold power */
44}
45
46unsigned int power_input_status(void)
47{
48 unsigned int status = POWER_INPUT_NONE;
49
50 /* FM or V2 can also charge from the USB port */
51 if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF)
52 status = POWER_INPUT_MAIN_CHARGER;
53
54#ifdef HAVE_USB_POWER
55 if (usb_detect() == USB_INSERTED)
56 status |= POWER_INPUT_USB_CHARGER;
57#endif
58
59 return status;
60}
61
62/* Returns true if the unit is charging the batteries. */
63bool charging_state(void)
64{
65 /* We use the information from the ADC_EXT_POWER ADC channel, which
66 tells us the charging current from the LTC1734. When DC is
67 connected (either via the external adapter, or via USB), we try
68 to determine if it is actively charging or only maintaining the
69 charge. My tests show that ADC readings below about 0x80 means
70 that the LTC1734 is only maintaining the charge. */
71 return adc_read(ADC_EXT_POWER) >= 0x80;
72}
73
74void ide_power_enable(bool on)
75{
76 bool touched = false;
77
78 if(on)
79 {
80 or_b(0x20, &PADRL);
81 touched = true;
82 }
83#ifdef HAVE_ATA_POWER_OFF
84 if(!on)
85 {
86 and_b(~0x20, &PADRL);
87 touched = true;
88 }
89#endif /* HAVE_ATA_POWER_OFF */
90
91/* late port preparation, else problems with read/modify/write
92 of other bits on same port, while input and floating high */
93 if (touched)
94 {
95 or_b(0x20, &PAIORL); /* PA5 is an output */
96 PACR2 &= 0xFBFF; /* GPIO for PA5 */
97 }
98}
99
100
101bool ide_powered(void)
102{
103 if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */
104 return true; /* would be floating high, disk on */
105 else
106 return (PADRL & 0x20) != 0;
107}
108
109void power_off(void)
110{
111 disable_irq();
112 and_b(~0x20, &PBDRL);
113 or_b(0x20, &PBIORL);
114 while(1);
115}