summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8700/yps3/power-yps3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/s5l8700/yps3/power-yps3.c')
-rw-r--r--firmware/target/arm/s5l8700/yps3/power-yps3.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/yps3/power-yps3.c b/firmware/target/arm/s5l8700/yps3/power-yps3.c
new file mode 100644
index 0000000000..784a5a9629
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/power-yps3.c
@@ -0,0 +1,95 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 Bertrik Sikken
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 <stdbool.h>
22#include "config.h"
23#include "s5l8700.h"
24#include "power.h"
25
26/* Power handling for the S5L8700 based Samsung YP-S3
27
28 Pins involved in with power management:
29 * P1.1: USB power detect
30 * P4.7: tuner power/enable
31 * P5.2: unknown output
32 * P5.3: unknown output, related to charging (perhaps charge current?)
33 * P5.4: charge status input (only valid if charger enabled)
34 * P5.6: charger enable
35*/
36
37void power_off(void)
38{
39 /* don't know how to do this yet */
40}
41
42void power_init(void)
43{
44 /* configure pin P1.1 as input for USB power detect */
45 PCON1 = (PCON1 & ~0x000000F0) | 0x00000000;
46
47 /* enable tuner power pin on P4.7 and turn power off */
48 PCON4 = (PCON4 & ~0xF0000000) | 0x10000000;
49 PDAT4 &= ~(1 << 7);
50
51 /* configure pins P5.2 / P5.3 / P5.6 as output, P5.4 as input */
52 PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100;
53 PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6));
54}
55
56#if CONFIG_CHARGING
57unsigned int power_input_status(void)
58{
59 /* check USB power on P1.1 */
60 if (PDAT1 & (1 << 1)) {
61 return POWER_INPUT_USB;
62 }
63
64 return POWER_INPUT_NONE;
65}
66
67bool charging_state(void)
68{
69 if (PDAT5 & (1 << 6)) {
70 /* charger is enabled, check if charging is busy */
71 return (PDAT5 & (1 << 4));
72 }
73 return false;
74}
75#endif /* CONFIG_CHARGING */
76
77#if CONFIG_TUNER
78bool tuner_power(bool status)
79{
80 if (status) {
81 PDAT4 |= (1 << 7);
82 }
83 else {
84 PDAT4 &= ~(1 << 7);
85 }
86 /* TODO what should we return here? */
87 return status;
88}
89
90bool tuner_powered(void)
91{
92 return (PDAT4 & (1 << 7));
93}
94#endif /* CONFIG_TUNER */
95