Fix issues with iPod nano 2G displays reported on the forums. The voltage supply...
[kugel-rb.git] / firmware / target / arm / s5l8700 / ipodnano2g / power-nano2g.c
blob10d96fd59cdf29e62d86eea0df27cd9d65dd1d92
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright © 2009 Bertrik Sikken
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 ****************************************************************************/
21 #include <stdbool.h>
22 #include "config.h"
23 #include "inttypes.h"
24 #include "s5l8700.h"
25 #include "power.h"
26 #include "panic.h"
27 #include "pmu-target.h"
28 #include "usb_core.h" /* for usb_charging_maxcurrent_change */
30 void power_off(void)
32 pmu_ldo_on_in_standby(0, 0);
33 pmu_ldo_on_in_standby(1, 0);
34 pmu_ldo_on_in_standby(2, 0);
35 pmu_ldo_on_in_standby(3, 0);
36 pmu_ldo_on_in_standby(4, 0);
37 pmu_ldo_on_in_standby(5, 0);
38 pmu_ldo_on_in_standby(6, 0);
39 pmu_ldo_on_in_standby(7, 0);
40 pmu_set_wake_condition(0x42); /* USB inserted or EXTON1 */
41 pmu_enter_standby();
43 while(1);
46 void power_init(void)
48 pmu_write(0x1e, 0xf); /* Vcore = 1.000V */
49 pmu_ldo_set_voltage(2, 0x13); /* LCD = 2.800V */
52 #if CONFIG_CHARGING
54 #ifdef HAVE_USB_CHARGING_ENABLE
55 void usb_charging_maxcurrent_change(int maxcurrent)
57 bool on = (maxcurrent >= 500);
58 PDAT11 = (PDAT11 & ~1) | (on ? 1 : 0);
60 #endif
62 unsigned int power_input_status(void)
64 return (PDAT14 & 8) ? POWER_INPUT_NONE : POWER_INPUT_MAIN_CHARGER;
67 bool charging_state(void)
69 return (PDAT11 & 0x10) ? false : true;
71 #endif /* CONFIG_CHARGING */