1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
32 #if CONFIG_CPU == PP5022 || CONFIG_CPU == PP5020
38 #if defined(IPOD_1G2G) || defined(IPOD_3G)
39 GPIOC_ENABLE
|= 0x40; /* GPIO C6 is HDD power (low active) */
40 GPIOC_OUTPUT_VAL
&= ~0x40; /* on by default */
41 GPIOC_OUTPUT_EN
|= 0x40; /* enable output */
49 unsigned int power_input_status(void)
51 unsigned int status
= POWER_INPUT_NONE
;
53 #if defined(IPOD_NANO) || defined(IPOD_VIDEO)
54 if ((GPIOL_INPUT_VAL
& 0x08) == 0)
55 status
= POWER_INPUT_MAIN_CHARGER
;
57 if ((GPIOL_INPUT_VAL
& 0x10) != 0)
58 status
|= POWER_INPUT_USB_CHARGER
;
60 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
61 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
62 /* C2 is firewire power */
63 if ((GPIOC_INPUT_VAL
& 0x04) == 0)
64 status
= POWER_INPUT_MAIN_CHARGER
;
66 if ((GPIOD_INPUT_VAL
& 0x08) != 0)
67 status
|= POWER_INPUT_USB_CHARGER
;
69 #elif defined(IPOD_3G)
71 if ((GPIOC_INPUT_VAL
& 0x10) == 0)
72 status
= POWER_INPUT_MAIN_CHARGER
;
75 /* This needs filling in for other ipods. */
81 /* Returns true if the unit is charging the batteries. */
82 bool charging_state(void) {
83 #if defined(IPOD_COLOR)
84 /* 0x70000088 appears to be the input value for GPO32 bits.
85 Write a zero to 0x70000088 before reading.
86 To enable input set the corresponding 0x7000008C bit,
87 and clear the corresponding GPO32_ENABLE bit. */
89 return (inl(0x70000088) & 1)?false:true;
91 return (GPIOB_INPUT_VAL
& 0x01)?false:true;
94 #endif /* CONFIG_CHARGING */
97 void ide_power_enable(bool on
)
99 #if defined(IPOD_1G2G) || defined(IPOD_3G)
101 GPIOC_OUTPUT_VAL
&= ~0x40;
103 GPIOC_OUTPUT_VAL
|= 0x40;
104 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
105 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
108 GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL
, 0x04);
114 GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL
, 0x04);
116 #elif defined(IPOD_VIDEO)
119 GPO32_VAL
&= ~0x40000000;
120 sleep(1); /* only need 4 ms */
124 GPIO_CLEAR_BITWISE(GPIOI_ENABLE
, 0xBF);
125 GPIO_CLEAR_BITWISE(GPIOK_ENABLE
, 0x1F);
134 GPIO_SET_BITWISE(GPIOI_ENABLE
, 0xBF);
135 GPIO_SET_BITWISE(GPIOK_ENABLE
, 0x1F);
136 GPO32_VAL
|= 0x40000000;
139 (void)on
; /* Do nothing. */
143 bool ide_powered(void)
145 #if defined(IPOD_1G2G) || defined(IPOD_3G)
146 return !(GPIOC_OUTPUT_VAL
& 0x40);
147 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
148 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
149 return !(GPIOJ_OUTPUT_VAL
& 0x04);
150 #elif defined(IPOD_VIDEO)
151 return !(GPO32_VAL
& 0x40000000);
153 return true; /* Pretend we are always powered */
159 #if defined(HAVE_LCD_COLOR) && !defined(HAVE_LCD_SHUTDOWN)
160 /* Clear the screen and backdrop to
161 remove ghosting effect on shutdown */
162 lcd_set_backdrop(NULL
);
163 lcd_set_background(LCD_WHITE
);
170 #if CONFIG_CPU == PP5022 || CONFIG_CPU == PP5020
171 /* When shut down by OF, wakeup via alarm is enabled. This resets the
172 alarm time so an unintended wakeup does not occur. */
173 if (!(pcf50605_wakeup_flags
& 0x10))
174 rtc_enable_alarm(false);
176 #if defined(IPOD_1G2G)
177 /* we cannot turn off the 1st gen/ 2nd gen yet. Need to figure out sleep mode. */
179 #elif CONFIG_CPU == PP5022
180 /* The OF in flash assumes boot failed because the battery is low.
181 If there is no charger connected, this leads to a shutdown.
183 memcpy((void *)(0x4001ff00+8), "booting!", 8);
185 #elif CONFIG_CPU == PP5020
186 memcpy((void *)(0x40017f00+8), "booting!", 8);
189 /* We don't turn off the ipod, we put it in a deep sleep */
190 pcf50605_standby_mode();