Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
arch
arm
mach-kirkwood
tsx1x-common.c
Go to the documentation of this file.
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
11
/*
12
* QNAP TS-x1x Boards flash
13
*/
14
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
18
* the QNAP firmware.
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"
26
*
27
* We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout
28
* used by the QNAP TS-109/TS-209.
29
*
30
***************************************************************************/
31
32
struct
mtd_partition
qnap_tsx1x_partitions
[] = {
33
{
34
.name =
"U-Boot"
,
35
.size = 0x00080000,
36
.offset = 0,
37
.mask_flags =
MTD_WRITEABLE
,
38
}, {
39
.name =
"Kernel"
,
40
.size = 0x00200000,
41
.offset = 0x00200000,
42
}, {
43
.name =
"RootFS1"
,
44
.size = 0x00900000,
45
.offset = 0x00400000,
46
}, {
47
.name =
"RootFS2"
,
48
.size = 0x00300000,
49
.offset = 0x00d00000,
50
}, {
51
.name =
"U-Boot Config"
,
52
.size = 0x00040000,
53
.offset = 0x00080000,
54
}, {
55
.name =
"NAS Config"
,
56
.size = 0x00140000,
57
.offset = 0x000c0000,
58
},
59
};
60
61
const
struct
flash_platform_data
qnap_tsx1x_flash
= {
62
.type =
"m25p128"
,
63
.name =
"spi_flash"
,
64
.parts =
qnap_tsx1x_partitions
,
65
.nr_parts =
ARRAY_SIZE
(qnap_tsx1x_partitions),
66
};
67
68
struct
spi_board_info
__initdata
qnap_tsx1x_spi_slave_info
[] = {
69
{
70
.modalias =
"m25p80"
,
71
.platform_data = &
qnap_tsx1x_flash
,
72
.irq = -1,
73
.max_speed_hz = 20000000,
74
.bus_num = 0,
75
.chip_select = 0,
76
},
77
};
78
79
void
__init
qnap_tsx1x_register_flash
(
void
)
80
{
81
spi_register_board_info
(qnap_tsx1x_spi_slave_info,
82
ARRAY_SIZE
(qnap_tsx1x_spi_slave_info));
83
kirkwood_spi_init
();
84
}
85
86
87
/*****************************************************************************
88
* QNAP TS-x1x specific power off method via UART1-attached PIC
89
****************************************************************************/
90
91
#define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
92
93
void
qnap_tsx1x_power_off
(
void
)
94
{
95
/* 19200 baud divisor */
96
const
unsigned
divisor
= ((
kirkwood_tclk
+ (8 * 19200)) / (16 * 19200));
97
98
pr_info
(
"%s: triggering power-off...\n"
, __func__);
99
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
));
108
109
/* send the power-off command 'A' to PIC */
110
writel
(
'A'
,
UART1_REG
(
TX
));
111
}
112
Generated on Thu Jan 10 2013 12:59:36 for Linux Kernel by
1.8.2