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 ****************************************************************************/
34 #if defined(IPOD_1G2G) || defined(IPOD_3G)
35 GPIOC_ENABLE
|= 0x40; /* GPIO C6 is HDD power (low active) */
36 GPIOC_OUTPUT_VAL
&= ~0x40; /* on by default */
37 GPIOC_OUTPUT_EN
|= 0x40; /* enable output */
45 unsigned int power_input_status(void)
47 unsigned int status
= POWER_INPUT_NONE
;
49 #if defined(IPOD_NANO) || defined(IPOD_VIDEO)
50 if ((GPIOL_INPUT_VAL
& 0x08) == 0)
51 status
= POWER_INPUT_MAIN_CHARGER
;
53 if ((GPIOL_INPUT_VAL
& 0x10) != 0)
54 status
|= POWER_INPUT_USB_CHARGER
;
56 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
57 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
58 /* C2 is firewire power */
59 if ((GPIOC_INPUT_VAL
& 0x04) == 0)
60 status
= POWER_INPUT_MAIN_CHARGER
;
62 if ((GPIOD_INPUT_VAL
& 0x08) != 0)
63 status
|= POWER_INPUT_USB_CHARGER
;
65 #elif defined(IPOD_3G)
67 if ((GPIOC_INPUT_VAL
& 0x10) == 0)
68 status
= POWER_INPUT_MAIN_CHARGER
;
71 /* This needs filling in for other ipods. */
77 /* Returns true if the unit is charging the batteries. */
78 bool charging_state(void) {
79 #if defined(IPOD_COLOR)
80 /* 0x70000088 appears to be the input value for GPO32 bits.
81 Write a zero to 0x70000088 before reading.
82 To enable input set the corresponding 0x7000008C bit,
83 and clear the corresponding GPO32_ENABLE bit. */
85 return (inl(0x70000088) & 1)?false:true;
87 return (GPIOB_INPUT_VAL
& 0x01)?false:true;
90 #endif /* CONFIG_CHARGING */
93 void ide_power_enable(bool on
)
95 #if defined(IPOD_1G2G) || defined(IPOD_3G)
97 GPIOC_OUTPUT_VAL
&= ~0x40;
99 GPIOC_OUTPUT_VAL
|= 0x40;
100 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
101 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
104 GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL
, 0x04);
110 GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL
, 0x04);
112 #elif defined(IPOD_VIDEO)
115 GPO32_VAL
&= ~0x40000000;
121 GPO32_VAL
|= 0x40000000;
124 (void)on
; /* Do nothing. */
128 bool ide_powered(void)
130 #if defined(IPOD_1G2G) || defined(IPOD_3G)
131 return !(GPIOC_OUTPUT_VAL
& 0x40);
132 #elif defined(IPOD_4G) || defined(IPOD_COLOR) \
133 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
134 return !(GPIOJ_OUTPUT_VAL
& 0x04);
135 #elif defined(IPOD_VIDEO)
136 return !(GPO32_VAL
& 0x40000000);
138 return true; /* Pretend we are always powered */
144 #if defined(HAVE_LCD_COLOR) && !defined(HAVE_LCD_SHUTDOWN)
145 /* Clear the screen and backdrop to
146 remove ghosting effect on shutdown */
147 lcd_set_backdrop(NULL
);
148 lcd_set_background(LCD_WHITE
);
156 /* we cannot turn off the 1st gen/ 2nd gen yet. Need to figure out sleep mode. */
159 /* We don't turn off the ipod, we put it in a deep sleep */
160 pcf50605_standby_mode();