From 72e7d58a65379334bc2d6cf5889d25369386c0e5 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sun, 16 Dec 2007 17:42:31 +0100 Subject: [PATCH] --- yaml --- r: 77535 b: refs/heads/master c: 8f86dda3ed8f05748f2351ae967926227a91ca2a h: refs/heads/master i: 77533: ea7d8d23618af6000c79101827bc51ced6525ab8 77531: 54ed97eda0bf06483f46c6a4108d973a235e222b 77527: a5d38a4524701ae6c088509b58a70e6c0e204e8f 77519: 15c2f008b486eee0bc51b33dd143b7b4b293d302 77503: 5a9cc99ac2c357d979b4635bd5cb04c0fd77c388 v: v3 --- [refs] | 2 +- trunk/arch/arm/mach-orion/ts209-setup.c | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 710510865c69..6d0a0cbe2cd7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3faf2ee870c26f6a809af3f32368f96c357ed91b +refs/heads/master: 8f86dda3ed8f05748f2351ae967926227a91ca2a diff --git a/trunk/arch/arm/mach-orion/ts209-setup.c b/trunk/arch/arm/mach-orion/ts209-setup.c index 34f88ac24ac8..e3e930efd155 100644 --- a/trunk/arch/arm/mach-orion/ts209-setup.c +++ b/trunk/arch/arm/mach-orion/ts209-setup.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -239,6 +240,32 @@ static struct platform_device *qnap_ts209_devices[] __initdata = { &qnap_ts209_button_device, }; +/* + * QNAP TS-[12]09 specific power off method via UART1-attached PIC + */ + +#define UART1_REG(x) (UART1_BASE + ((UART_##x) << 2)) + +static void qnap_ts209_power_off(void) +{ + /* 19200 baud divisor */ + const unsigned divisor = ((ORION_TCLK + (8 * 19200)) / (16 * 19200)); + + pr_info("%s: triggering power-off...\n", __func__); + + /* hijack uart1 and reset into sane state (19200,8n1) */ + orion_write(UART1_REG(LCR), 0x83); + orion_write(UART1_REG(DLL), divisor & 0xff); + orion_write(UART1_REG(DLM), (divisor >> 8) & 0xff); + orion_write(UART1_REG(LCR), 0x03); + orion_write(UART1_REG(IER), 0x00); + orion_write(UART1_REG(FCR), 0x00); + orion_write(UART1_REG(MCR), 0x00); + + /* send the power-off command 'A' to PIC */ + orion_write(UART1_REG(TX), 'A'); +} + static void __init qnap_ts209_init(void) { /* @@ -287,6 +314,9 @@ static void __init qnap_ts209_init(void) orion_write(MPP_16_19_CTRL, 0x5500); orion_gpio_set_valid_pins(0x3cc0fff); + /* register ts209 specific power-off method */ + pm_power_off = qnap_ts209_power_off; + platform_add_devices(qnap_ts209_devices, ARRAY_SIZE(qnap_ts209_devices)); i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1);