From 11c043f18b6d6ef9892b2765ba79f41d7eb4b895 Mon Sep 17 00:00:00 2001 From: bertrik Date: Wed, 5 Aug 2009 16:16:17 +0000 Subject: [PATCH] Samsung YP-S3: allow player to stay powered up without the USB cable plugged and implement power_off git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22175 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/samsung_yps3.c | 6 ++++++ firmware/target/arm/s5l8700/yps3/power-yps3.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bootloader/samsung_yps3.c b/bootloader/samsung_yps3.c index 33115a92ac..e541ff2f53 100644 --- a/bootloader/samsung_yps3.c +++ b/bootloader/samsung_yps3.c @@ -266,6 +266,12 @@ void main(void) lcd_puts(0, line++, mystring); #endif +#if 1 /* power off using power button */ + button = button_read_device(); + if (button & BUTTON_POWER) { + power_off(); + } +#endif #if 1 /* button info */ snprintf(mystring, 64, "BUTTONS %08X, %s", button_read_device(), 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 @@ /* Power handling for the S5L8700 based Samsung YP-S3 - Pins involved in with power management: + Pins involved in power management: + * P0.1: stay powered up (even with the USB cable unplugged) * P1.1: USB power detect * P4.7: tuner power/enable * P5.2: unknown output @@ -36,19 +37,26 @@ void power_off(void) { - /* don't know how to do this yet */ + /* take down P0.1 to power off (plugged USB cable overrides this though) */ + PDAT0 &= ~(1 << 1); + + while(1); /* wait for system to shut down */ } void power_init(void) { - /* configure pin P1.1 as input for USB power detect */ + /* configure P0.1 as output for power-up and stay powered up */ + PCON0 = (PCON0 & ~(3 << 2)) | (1 << 2); + PDAT0 |= (1 << 1); + + /* configure P1.1 as input for USB power detect */ PCON1 = (PCON1 & ~0x000000F0) | 0x00000000; - /* enable tuner power pin on P4.7 and turn power off */ + /* configure P4.7 as output for tuner power and turn power off */ PCON4 = (PCON4 & ~0xF0000000) | 0x10000000; PDAT4 &= ~(1 << 7); - /* configure pins P5.2 / P5.3 / P5.6 as output, P5.4 as input */ + /* configure P5.2 / P5.3 / P5.6 as output, P5.4 as input */ PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100; PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6)); } @@ -66,8 +74,9 @@ unsigned int power_input_status(void) bool charging_state(void) { + /* check if charger is enabled */ if (PDAT5 & (1 << 6)) { - /* charger is enabled, check if charging is busy */ + /* check if charging is busy */ return (PDAT5 & (1 << 4)); } return false; -- 2.11.4.GIT