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.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/firmware/target/arm/s5l8700/yps3/power-yps3.c b/firmware/target/arm/s5l8700/yps3/power-yps3.c
index 784a5a9629..ea41b861cf 100644
--- a/firmware/target/arm/s5l8700/yps3/power-yps3.c
+++ b/firmware/target/arm/s5l8700/yps3/power-yps3.c
@@ -25,7 +25,8 @@
25 25
26/* Power handling for the S5L8700 based Samsung YP-S3 26/* Power handling for the S5L8700 based Samsung YP-S3
27 27
28 Pins involved in with power management: 28 Pins involved in power management:
29 * P0.1: stay powered up (even with the USB cable unplugged)
29 * P1.1: USB power detect 30 * P1.1: USB power detect
30 * P4.7: tuner power/enable 31 * P4.7: tuner power/enable
31 * P5.2: unknown output 32 * P5.2: unknown output
@@ -36,19 +37,26 @@
36 37
37void power_off(void) 38void power_off(void)
38{ 39{
39 /* don't know how to do this yet */ 40 /* take down P0.1 to power off (plugged USB cable overrides this though) */
41 PDAT0 &= ~(1 << 1);
42
43 while(1); /* wait for system to shut down */
40} 44}
41 45
42void power_init(void) 46void power_init(void)
43{ 47{
44 /* configure pin P1.1 as input for USB power detect */ 48 /* configure P0.1 as output for power-up and stay powered up */
49 PCON0 = (PCON0 & ~(3 << 2)) | (1 << 2);
50 PDAT0 |= (1 << 1);
51
52 /* configure P1.1 as input for USB power detect */
45 PCON1 = (PCON1 & ~0x000000F0) | 0x00000000; 53 PCON1 = (PCON1 & ~0x000000F0) | 0x00000000;
46 54
47 /* enable tuner power pin on P4.7 and turn power off */ 55 /* configure P4.7 as output for tuner power and turn power off */
48 PCON4 = (PCON4 & ~0xF0000000) | 0x10000000; 56 PCON4 = (PCON4 & ~0xF0000000) | 0x10000000;
49 PDAT4 &= ~(1 << 7); 57 PDAT4 &= ~(1 << 7);
50 58
51 /* configure pins P5.2 / P5.3 / P5.6 as output, P5.4 as input */ 59 /* configure P5.2 / P5.3 / P5.6 as output, P5.4 as input */
52 PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100; 60 PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100;
53 PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6)); 61 PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6));
54} 62}
@@ -66,8 +74,9 @@ unsigned int power_input_status(void)
66 74
67bool charging_state(void) 75bool charging_state(void)
68{ 76{
77 /* check if charger is enabled */
69 if (PDAT5 & (1 << 6)) { 78 if (PDAT5 & (1 << 6)) {
70 /* charger is enabled, check if charging is busy */ 79 /* check if charging is busy */
71 return (PDAT5 & (1 << 4)); 80 return (PDAT5 & (1 << 4));
72 } 81 }
73 return false; 82 return false;