1 #include <linux/kernel.h>
3 #include <linux/platform_device.h>
4 #include <linux/mtd/physmap.h>
5 #include <linux/spi/flash.h>
6 #include <linux/spi/spi.h>
7 #include <linux/serial_reg.h>
8 #include <mach/kirkwood.h>
12 * QNAP TS-x1x Boards flash
15 /****************************************************************************
16 * 16 MiB NOR flash. The struct mtd_partition is not in the same order as the
17 * partitions on the device because we want to keep compatibility with
19 * Layout as used by QNAP:
20 * 0x00000000-0x00080000 : "U-Boot"
21 * 0x00200000-0x00400000 : "Kernel"
22 * 0x00400000-0x00d00000 : "RootFS"
23 * 0x00d00000-0x01000000 : "RootFS2"
24 * 0x00080000-0x000c0000 : "U-Boot Config"
25 * 0x000c0000-0x00200000 : "NAS Config"
27 * We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout
28 * used by the QNAP TS-109/TS-209.
30 ***************************************************************************/
32 struct mtd_partition qnap_tsx1x_partitions[] = {
37 .mask_flags = MTD_WRITEABLE,
51 .name = "U-Boot Config",
61 const struct flash_platform_data qnap_tsx1x_flash = {
64 .parts = qnap_tsx1x_partitions,
65 .nr_parts = ARRAY_SIZE(qnap_tsx1x_partitions),
68 struct spi_board_info __initdata qnap_tsx1x_spi_slave_info[] = {
71 .platform_data = &qnap_tsx1x_flash,
73 .max_speed_hz = 20000000,
79 void __init qnap_tsx1x_register_flash(void)
81 spi_register_board_info(qnap_tsx1x_spi_slave_info,
82 ARRAY_SIZE(qnap_tsx1x_spi_slave_info));
87 /*****************************************************************************
88 * QNAP TS-x1x specific power off method via UART1-attached PIC
89 ****************************************************************************/
91 #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
93 void qnap_tsx1x_power_off(void)
95 /* 19200 baud divisor */
96 const unsigned divisor = ((kirkwood_tclk + (8 * 19200)) / (16 * 19200));
98 pr_info("%s: triggering power-off...\n", __func__);
100 /* hijack UART1 and reset into sane state (19200,8n1) */
101 writel(0x83, UART1_REG(LCR));
102 writel(divisor & 0xff, UART1_REG(DLL));
103 writel((divisor >> 8) & 0xff, UART1_REG(DLM));
104 writel(0x03, UART1_REG(LCR));
105 writel(0x00, UART1_REG(IER));
106 writel(0x00, UART1_REG(FCR));
107 writel(0x00, UART1_REG(MCR));
109 /* send the power-off command 'A' to PIC */
110 writel('A', UART1_REG(TX));