static int tsp2_miconwrite(const unsigned char *buf, int count) { int i = 0; while (count--) { while (!(readl(UART1_REG(LSR)) & UART_LSR_THRE)) barrier(); writel(buf[i++], UART1_REG(TX)); } return 0; }
static int tsp2_miconread(unsigned char *buf, int count) { int i; int timeout; for (i = 0; i < count; i++) { timeout = 10; while (!(readl(UART1_REG(LSR)) & UART_LSR_DR)) { if (--timeout == 0) break; udelay(1000); } if (timeout == 0) break; buf[i] = readl(UART1_REG(RX)); } /* return read bytes */ return i; }
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'); }
void qnap_ts219_power_off(void) { /* 19200 baud divisor */ const unsigned divisor = ((kirkwood_tclk + (8 * 19200)) / (16 * 19200)); pr_info("%s: triggering power-off...\n", __func__); /* hijack UART1 and reset into sane state (19200,8n1) */ writel(0x83, UART1_REG(LCR)); writel(divisor & 0xff, UART1_REG(DLL)); writel((divisor >> 8) & 0xff, UART1_REG(DLM)); writel(0x03, UART1_REG(LCR)); writel(0x00, UART1_REG(IER)); writel(0x00, UART1_REG(FCR)); writel(0x00, UART1_REG(MCR)); /* send the power-off command 'A' to PIC */ writel('A', UART1_REG(TX)); }
void qnap_tsx09_power_off(void) { const unsigned divisor = ((orion5x_tclk + (8 * 19200)) / (16 * 19200)); pr_info("%s: triggering power-off...\n", __func__); writel(0x83, UART1_REG(LCR)); writel(divisor & 0xff, UART1_REG(DLL)); writel((divisor >> 8) & 0xff, UART1_REG(DLM)); writel(0x03, UART1_REG(LCR)); writel(0x00, UART1_REG(IER)); writel(0x00, UART1_REG(FCR)); writel(0x00, UART1_REG(MCR)); writel('A', UART1_REG(TX)); }
static void tsp2_power_off(void) { const unsigned char watchdogkill[] = {0x01, 0x35, 0x00}; const unsigned char shutdownwait[] = {0x00, 0x0c}; const unsigned char poweroff[] = {0x00, 0x06}; /* 38400 baud divisor */ const unsigned divisor = ((orion5x_tclk + (8 * 38400)) / (16 * 38400)); pr_info("%s: triggering power-off...\n", __func__); /* hijack uart1 and reset into sane state (38400,8n1,even parity) */ writel(0x83, UART1_REG(LCR)); writel(divisor & 0xff, UART1_REG(DLL)); writel((divisor >> 8) & 0xff, UART1_REG(DLM)); writel(0x1b, UART1_REG(LCR)); writel(0x00, UART1_REG(IER)); writel(0x07, UART1_REG(FCR)); writel(0x00, UART1_REG(MCR)); /* Send the commands to shutdown the Terastation Pro II */ tsp2_miconsend(watchdogkill, sizeof(watchdogkill)) ; tsp2_miconsend(shutdownwait, sizeof(shutdownwait)) ; tsp2_miconsend(poweroff, sizeof(poweroff)); }
static void kurobox_pro_power_off(void) { const unsigned char watchdogkill[] = {0x01, 0x35, 0x00}; const unsigned char shutdownwait[] = {0x00, 0x0c}; const unsigned char poweroff[] = {0x00, 0x06}; const unsigned divisor = ((orion5x_tclk + (8 * 38400)) / (16 * 38400)); pr_info("%s: triggering power-off...\n", __func__); writel(0x83, UART1_REG(LCR)); writel(divisor & 0xff, UART1_REG(DLL)); writel((divisor >> 8) & 0xff, UART1_REG(DLM)); writel(0x1b, UART1_REG(LCR)); writel(0x00, UART1_REG(IER)); writel(0x07, UART1_REG(FCR)); writel(0x00, UART1_REG(MCR)); kurobox_pro_miconsend(watchdogkill, sizeof(watchdogkill)) ; kurobox_pro_miconsend(shutdownwait, sizeof(shutdownwait)) ; kurobox_pro_miconsend(poweroff, sizeof(poweroff)); }