diff options
author | Michael Walle <michael@walle.cc> | 2012-07-30 10:47:12 (GMT) |
---|---|---|
committer | Prafulla Wadaskar <prafulla@marvell.com> | 2012-09-03 12:18:51 (GMT) |
commit | a9f1a4893364ddbb8b7942cded91d4c17c4f5948 (patch) | |
tree | 35737bd084e46966349c4b17d8ee8e217bff8b9f /board/buffalo/lsxl | |
parent | 1ff1f89c57e69eb151ab2eca87a4f119bb4413c1 (diff) | |
download | u-boot-a9f1a4893364ddbb8b7942cded91d4c17c4f5948.tar.xz |
lsxl: support power switch
This patch restores the Linkstation's original behaviour when powering off.
Once the (soft) power switch is turned off, linux will reboot and the
bootloader turns off HDD and USB power. Then it loops as long as the switch
is in the off position, before continuing the boot process again.
Additionally, this patch fixes the board function set_led(LED_OFF).
Signed-off-by: Michael Walle <michael@walle.cc>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
Diffstat (limited to 'board/buffalo/lsxl')
-rw-r--r-- | board/buffalo/lsxl/lsxl.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c index fe15511..b3f31d6 100644 --- a/board/buffalo/lsxl/lsxl.c +++ b/board/buffalo/lsxl/lsxl.c @@ -158,7 +158,7 @@ static void set_led(int state) { switch (state) { case LED_OFF: - __set_led(0, 0, 0, 0, 0, 0); + __set_led(0, 0, 0, 1, 1, 1); break; case LED_ALARM_ON: __set_led(0, 0, 0, 0, 1, 1); @@ -192,6 +192,25 @@ int board_init(void) } #ifdef CONFIG_MISC_INIT_R +static void check_power_switch(void) +{ + if (kw_gpio_get_value(GPIO_POWER_SWITCH)) { + /* turn off HDD and USB power */ + kw_gpio_set_value(GPIO_HDD_POWER, 0); + kw_gpio_set_value(GPIO_USB_VBUS, 0); + set_led(LED_OFF); + + /* loop until released */ + while (kw_gpio_get_value(GPIO_POWER_SWITCH)) + ; + + /* turn power on again */ + kw_gpio_set_value(GPIO_HDD_POWER, 1); + kw_gpio_set_value(GPIO_USB_VBUS, 1); + set_led(LED_POWER_BLINKING); + } +} + void check_enetaddr(void) { uchar enetaddr[6]; @@ -261,6 +280,7 @@ static void check_push_button(void) int misc_init_r(void) { + check_power_switch(); check_enetaddr(); check_push_button(); |