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>
10 #include "tsx1x-common.h"
13 * QNAP TS-x1x Boards flash
16 /****************************************************************************
17 * 16 MiB NOR flash. The struct mtd_partition is not in the same order as the
18 * partitions on the device because we want to keep compatibility with
20 * Layout as used by QNAP:
21 * 0x00000000-0x00080000 : "U-Boot"
22 * 0x00200000-0x00400000 : "Kernel"
23 * 0x00400000-0x00d00000 : "RootFS"
24 * 0x00d00000-0x01000000 : "RootFS2"
25 * 0x00080000-0x000c0000 : "U-Boot Config"
26 * 0x000c0000-0x00200000 : "NAS Config"
28 * We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout
29 * used by the QNAP TS-109/TS-209.
31 ***************************************************************************/
33 static struct mtd_partition qnap_tsx1x_partitions
[] = {
38 .mask_flags
= MTD_WRITEABLE
,
52 .name
= "U-Boot Config",
62 static const struct flash_platform_data qnap_tsx1x_flash
= {
65 .parts
= qnap_tsx1x_partitions
,
66 .nr_parts
= ARRAY_SIZE(qnap_tsx1x_partitions
),
69 static struct spi_board_info __initdata qnap_tsx1x_spi_slave_info
[] = {
72 .platform_data
= &qnap_tsx1x_flash
,
74 .max_speed_hz
= 20000000,
80 void __init
qnap_tsx1x_register_flash(void)
82 spi_register_board_info(qnap_tsx1x_spi_slave_info
,
83 ARRAY_SIZE(qnap_tsx1x_spi_slave_info
));
88 /*****************************************************************************
89 * QNAP TS-x1x specific power off method via UART1-attached PIC
90 ****************************************************************************/
92 #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
94 void qnap_tsx1x_power_off(void)
96 /* 19200 baud divisor */
97 const unsigned divisor
= ((kirkwood_tclk
+ (8 * 19200)) / (16 * 19200));
99 pr_info("%s: triggering power-off...\n", __func__
);
101 /* hijack UART1 and reset into sane state (19200,8n1) */
102 writel(0x83, UART1_REG(LCR
));
103 writel(divisor
& 0xff, UART1_REG(DLL
));
104 writel((divisor
>> 8) & 0xff, UART1_REG(DLM
));
105 writel(0x03, UART1_REG(LCR
));
106 writel(0x00, UART1_REG(IER
));
107 writel(0x00, UART1_REG(FCR
));
108 writel(0x00, UART1_REG(MCR
));
110 /* send the power-off command 'A' to PIC */
111 writel('A', UART1_REG(TX
));