Hibernation: Pass CR3 in the image header on x86_64
[linux-2.6] / arch / ppc / syslib / virtex_devices.c
1 /*
2  * Virtex hard ppc405 core common device listing
3  *
4  * Copyright 2005-2007 Secret Lab Technologies Ltd.
5  * Copyright 2005 Freescale Semiconductor Inc.
6  * Copyright 2002-2004 MontaVista Software, Inc.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/device.h>
17 #include <linux/serial_8250.h>
18 #include <syslib/virtex_devices.h>
19 #include <platforms/4xx/xparameters/xparameters.h>
20 #include <asm/io.h>
21
22 /*
23  * UARTLITE: shortcut macro for single instance
24  */
25 #define XPAR_UARTLITE(num) { \
26         .name = "uartlite", \
27         .id = num, \
28         .num_resources = 2, \
29         .resource = (struct resource[]) { \
30                 { \
31                         .start = XPAR_UARTLITE_##num##_BASEADDR + 3, \
32                         .end = XPAR_UARTLITE_##num##_HIGHADDR, \
33                         .flags = IORESOURCE_MEM, \
34                 }, \
35                 { \
36                         .start = XPAR_INTC_0_UARTLITE_##num##_VEC_ID, \
37                         .flags = IORESOURCE_IRQ, \
38                 }, \
39         }, \
40 }
41
42 /*
43  * Full UART: shortcut macro for single instance + platform data structure
44  */
45 #define XPAR_UART(num) { \
46         .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
47         .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
48         .iotype = UPIO_MEM, \
49         .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
50         .flags = UPF_BOOT_AUTOCONF, \
51         .regshift = 2, \
52 }
53
54 /*
55  * SystemACE: shortcut macro for single instance
56  */
57 #define XPAR_SYSACE(num) { \
58         .name           = "xsysace", \
59         .id             = XPAR_SYSACE_##num##_DEVICE_ID, \
60         .num_resources  = 2, \
61         .resource = (struct resource[]) { \
62                 { \
63                         .start  = XPAR_SYSACE_##num##_BASEADDR, \
64                         .end    = XPAR_SYSACE_##num##_HIGHADDR, \
65                         .flags  = IORESOURCE_MEM, \
66                 }, \
67                 { \
68                         .start  = XPAR_INTC_0_SYSACE_##num##_VEC_ID, \
69                         .flags  = IORESOURCE_IRQ, \
70                 }, \
71         }, \
72 }
73
74 /*
75  * ML300/ML403 Video Device: shortcut macro for single instance
76  */
77 #define XPAR_TFT(num) { \
78         .name = "xilinxfb", \
79         .id = num, \
80         .num_resources = 1, \
81         .resource = (struct resource[]) { \
82                 { \
83                         .start = XPAR_TFT_##num##_BASEADDR, \
84                         .end = XPAR_TFT_##num##_BASEADDR+7, \
85                         .flags = IORESOURCE_IO, \
86                 }, \
87         }, \
88 }
89
90 /* UART 8250 driver platform data table */
91 struct plat_serial8250_port virtex_serial_platform_data[] = {
92 #if defined(XPAR_UARTNS550_0_BASEADDR)
93         XPAR_UART(0),
94 #endif
95 #if defined(XPAR_UARTNS550_1_BASEADDR)
96         XPAR_UART(1),
97 #endif
98 #if defined(XPAR_UARTNS550_2_BASEADDR)
99         XPAR_UART(2),
100 #endif
101 #if defined(XPAR_UARTNS550_3_BASEADDR)
102         XPAR_UART(3),
103 #endif
104 #if defined(XPAR_UARTNS550_4_BASEADDR)
105         XPAR_UART(4),
106 #endif
107 #if defined(XPAR_UARTNS550_5_BASEADDR)
108         XPAR_UART(5),
109 #endif
110 #if defined(XPAR_UARTNS550_6_BASEADDR)
111         XPAR_UART(6),
112 #endif
113 #if defined(XPAR_UARTNS550_7_BASEADDR)
114         XPAR_UART(7),
115 #endif
116         { }, /* terminated by empty record */
117 };
118
119
120 struct platform_device virtex_platform_devices[] = {
121         /* UARTLITE instances */
122 #if defined(XPAR_UARTLITE_0_BASEADDR)
123         XPAR_UARTLITE(0),
124 #endif
125 #if defined(XPAR_UARTLITE_1_BASEADDR)
126         XPAR_UARTLITE(1),
127 #endif
128 #if defined(XPAR_UARTLITE_2_BASEADDR)
129         XPAR_UARTLITE(2),
130 #endif
131 #if defined(XPAR_UARTLITE_3_BASEADDR)
132         XPAR_UARTLITE(3),
133 #endif
134 #if defined(XPAR_UARTLITE_4_BASEADDR)
135         XPAR_UARTLITE(4),
136 #endif
137 #if defined(XPAR_UARTLITE_5_BASEADDR)
138         XPAR_UARTLITE(5),
139 #endif
140 #if defined(XPAR_UARTLITE_6_BASEADDR)
141         XPAR_UARTLITE(6),
142 #endif
143 #if defined(XPAR_UARTLITE_7_BASEADDR)
144         XPAR_UARTLITE(7),
145 #endif
146
147         /* Full UART instances */
148 #if defined(XPAR_UARTNS550_0_BASEADDR)
149         {
150                 .name           = "serial8250",
151                 .id             = 0,
152                 .dev.platform_data = virtex_serial_platform_data,
153         },
154 #endif
155
156         /* SystemACE instances */
157 #if defined(XPAR_SYSACE_0_BASEADDR)
158         XPAR_SYSACE(0),
159 #endif
160 #if defined(XPAR_SYSACE_1_BASEADDR)
161         XPAR_SYSACE(1),
162 #endif
163
164 #if defined(XPAR_TFT_0_BASEADDR)
165         XPAR_TFT(0),
166 #endif
167 #if defined(XPAR_TFT_1_BASEADDR)
168         XPAR_TFT(1),
169 #endif
170 #if defined(XPAR_TFT_2_BASEADDR)
171         XPAR_TFT(2),
172 #endif
173 #if defined(XPAR_TFT_3_BASEADDR)
174         XPAR_TFT(3),
175 #endif
176 };
177
178 /* Early serial support functions */
179 static void __init
180 virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
181 {
182 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
183         struct uart_port serial_req;
184
185         memset(&serial_req, 0, sizeof(serial_req));
186         serial_req.mapbase      = pdata->mapbase;
187         serial_req.membase      = pdata->membase;
188         serial_req.irq          = pdata->irq;
189         serial_req.uartclk      = pdata->uartclk;
190         serial_req.regshift     = pdata->regshift;
191         serial_req.iotype       = pdata->iotype;
192         serial_req.flags        = pdata->flags;
193         gen550_init(num, &serial_req);
194 #endif
195 }
196
197 void __init
198 virtex_early_serial_map(void)
199 {
200 #ifdef CONFIG_SERIAL_8250
201         struct plat_serial8250_port *pdata;
202         int i = 0;
203
204         pdata = virtex_serial_platform_data;
205         while(pdata && pdata->flags) {
206                 pdata->membase = ioremap(pdata->mapbase, 0x100);
207                 virtex_early_serial_init(i, pdata);
208                 pdata++;
209                 i++;
210         }
211 #endif /* CONFIG_SERIAL_8250 */
212 }
213
214 /*
215  * default fixup routine; do nothing and return success.
216  *
217  * Reimplement this routine in your custom board support file to
218  * override the default behaviour
219  */
220 int __attribute__ ((weak))
221 virtex_device_fixup(struct platform_device *dev)
222 {
223         return 0;
224 }
225
226 static int __init virtex_init(void)
227 {
228         struct platform_device *index = virtex_platform_devices;
229         unsigned int ret = 0;
230         int i;
231
232         for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
233                 if (virtex_device_fixup(index) != 0)
234                         continue;
235
236                 if (platform_device_register(index)) {
237                         ret = 1;
238                         printk(KERN_ERR "cannot register dev %s:%d\n",
239                                index->name, index->id);
240                 }
241         }
242         return ret;
243 }
244
245 subsys_initcall(virtex_init);