1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Daniel Ankers
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 ****************************************************************************/
39 /* Send shutdown command to PMU */
40 byte
= ascodec_read(AS3514_SYSTEM
);
42 ascodec_write(AS3514_SYSTEM
, byte
);
44 /* Stop interrupts on both cores */
45 disable_interrupt(IRQ_FIQ_STATUS
);
49 /* Halt everything and wait for device to power off */
57 unsigned int power_input_status(void)
59 unsigned int status
= POWER_INPUT_NONE
;
61 #if defined(SANSA_E200)
62 #define _charger_present() (GPIOB_INPUT_VAL & 0x10)
63 #elif defined(SANSA_C200)
64 #define _charger_present() (GPIOH_INPUT_VAL & 0x2)
66 #define _charger_present() 0
69 if (_charger_present())
70 status
= POWER_INPUT_MAIN_CHARGER
;
72 /* No separate source for USB */
77 void ide_power_enable(bool on
)
85 static bool powered
= false;
87 bool tuner_power(bool status
)
94 if (status
!= old_status
)
98 /* init mystery amplification device */
99 #if defined(SANSA_E200)
101 #else /* SANSA_C200 */
106 /* When power up, host should initialize the 3-wire bus
107 in host read mode: */
109 /* 1. Set direction of the DATA-line to input-mode. */
110 GPIO_CLEAR_BITWISE(GPIOH_OUTPUT_EN
, 1 << 5);
111 GPIO_SET_BITWISE(GPIOH_ENABLE
, 1 << 5);
113 /* 2. Drive NR_W low */
114 GPIO_CLEAR_BITWISE(GPIOH_OUTPUT_VAL
, 1 << 3);
115 GPIO_SET_BITWISE(GPIOH_OUTPUT_EN
, 1 << 3);
116 GPIO_SET_BITWISE(GPIOH_ENABLE
, 1 << 3);
118 /* 3. Drive CLOCK high */
119 GPIO_SET_BITWISE(GPIOH_OUTPUT_VAL
, 1 << 4);
120 GPIO_SET_BITWISE(GPIOH_OUTPUT_EN
, 1 << 4);
121 GPIO_SET_BITWISE(GPIOH_ENABLE
, 1 << 4);
123 lv24020lp_power(true);
127 lv24020lp_power(false);
129 /* set all as inputs */
130 GPIO_CLEAR_BITWISE(GPIOH_OUTPUT_EN
, (1 << 5) | (1 << 3) | (1 << 4));
131 GPIO_CLEAR_BITWISE(GPIOH_ENABLE
, (1 << 3) | (1 << 4));
133 /* turn off mystery amplification device */
134 #if defined (SANSA_E200)
135 GPO32_ENABLE
&= ~0x1;
148 #endif /* CONFIG_TUNER */