x86/xen: resume timer irqs early
[linux/fpc-iii.git] / arch / arm / mach-kirkwood / tsx1x-common.c
blobcec87cef76ca00ed7b7f458228e8a51567a26d1c
1 #include <linux/kernel.h>
2 #include <linux/pci.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>
9 #include "common.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
19 * the QNAP firmware.
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[] = {
35 .name = "U-Boot",
36 .size = 0x00080000,
37 .offset = 0,
38 .mask_flags = MTD_WRITEABLE,
39 }, {
40 .name = "Kernel",
41 .size = 0x00200000,
42 .offset = 0x00200000,
43 }, {
44 .name = "RootFS1",
45 .size = 0x00900000,
46 .offset = 0x00400000,
47 }, {
48 .name = "RootFS2",
49 .size = 0x00300000,
50 .offset = 0x00d00000,
51 }, {
52 .name = "U-Boot Config",
53 .size = 0x00040000,
54 .offset = 0x00080000,
55 }, {
56 .name = "NAS Config",
57 .size = 0x00140000,
58 .offset = 0x000c0000,
62 static const struct flash_platform_data qnap_tsx1x_flash = {
63 .type = "m25p128",
64 .name = "spi_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[] = {
71 .modalias = "m25p80",
72 .platform_data = &qnap_tsx1x_flash,
73 .irq = -1,
74 .max_speed_hz = 20000000,
75 .bus_num = 0,
76 .chip_select = 0,
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));
84 kirkwood_spi_init();
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));