ide: fix regression caused by ide_device_{get,put}() addition (take 2)
[linux-2.6.git] / arch / mips / jazz / setup.c
1 /*
2  * Setup pointers to hardware-dependent routines.
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 1996, 1997, 1998, 2001, 07 by Ralf Baechle
9  * Copyright (C) 2001 MIPS Technologies, Inc.
10  * Copyright (C) 2007 by Thomas Bogendoerfer
11  */
12 #include <linux/eisa.h>
13 #include <linux/init.h>
14 #include <linux/ioport.h>
15 #include <linux/sched.h>
16 #include <linux/interrupt.h>
17 #include <linux/mm.h>
18 #include <linux/console.h>
19 #include <linux/fb.h>
20 #include <linux/ide.h>
21 #include <linux/pm.h>
22 #include <linux/screen_info.h>
23 #include <linux/platform_device.h>
24 #include <linux/serial_8250.h>
25
26 #include <asm/bootinfo.h>
27 #include <asm/irq.h>
28 #include <asm/jazz.h>
29 #include <asm/jazzdma.h>
30 #include <asm/reboot.h>
31 #include <asm/io.h>
32 #include <asm/pgtable.h>
33 #include <asm/time.h>
34 #include <asm/traps.h>
35 #include <asm/mc146818-time.h>
36
37 extern asmlinkage void jazz_handle_int(void);
38
39 extern void jazz_machine_restart(char *command);
40
41 static struct resource jazz_io_resources[] = {
42         {
43                 .start  = 0x00,
44                 .end    = 0x1f,
45                 .name   = "dma1",
46                 .flags  = IORESOURCE_BUSY
47         }, {
48                 .start  = 0x40,
49                 .end    = 0x5f,
50                 .name   = "timer",
51                 .flags  = IORESOURCE_BUSY
52         }, {
53                 .start  = 0x80,
54                 .end    = 0x8f,
55                 .name   = "dma page reg",
56                 .flags  = IORESOURCE_BUSY
57         }, {
58                 .start  = 0xc0,
59                 .end    = 0xdf,
60                 .name   = "dma2",
61                 .flags  = IORESOURCE_BUSY
62         }
63 };
64
65 void __init plat_mem_setup(void)
66 {
67         int i;
68
69         /* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */
70         add_wired_entry(0x02000017, 0x03c00017, 0xe0000000, PM_64K);
71         /* Map 0xe2000000 -> 0x0:900005C0, 0xe3010000 -> 0x0:910005C0 */
72         add_wired_entry(0x02400017, 0x02440017, 0xe2000000, PM_16M);
73         /* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */
74         add_wired_entry(0x01800017, 0x01000017, 0xe4000000, PM_4M);
75
76         set_io_port_base(JAZZ_PORT_BASE);
77 #ifdef CONFIG_EISA
78         EISA_bus = 1;
79 #endif
80
81         /* request I/O space for devices used on all i[345]86 PCs */
82         for (i = 0; i < ARRAY_SIZE(jazz_io_resources); i++)
83                 request_resource(&ioport_resource, jazz_io_resources + i);
84
85         /* The RTC is outside the port address space */
86
87         _machine_restart = jazz_machine_restart;
88
89 #ifdef CONFIG_VT
90         screen_info = (struct screen_info) {
91                 0, 0,           /* orig-x, orig-y */
92                 0,              /* unused */
93                 0,              /* orig_video_page */
94                 0,              /* orig_video_mode */
95                 160,            /* orig_video_cols */
96                 0, 0, 0,        /* unused, ega_bx, unused */
97                 64,             /* orig_video_lines */
98                 0,              /* orig_video_isVGA */
99                 16              /* orig_video_points */
100         };
101 #endif
102
103         add_preferred_console("ttyS", 0, "9600");
104 }
105
106 #ifdef CONFIG_OLIVETTI_M700
107 #define UART_CLK  1843200
108 #else
109 /* Some Jazz machines seem to have an 8MHz crystal clock but I don't know
110    exactly which ones ... XXX */
111 #define UART_CLK (8000000 / 16) /* ( 3072000 / 16) */
112 #endif
113
114 #define MEMPORT(_base, _irq)                            \
115         {                                               \
116                 .mapbase        = (_base),              \
117                 .membase        = (void *)(_base),      \
118                 .irq            = (_irq),               \
119                 .uartclk        = UART_CLK,             \
120                 .iotype         = UPIO_MEM,             \
121                 .flags          = UPF_BOOT_AUTOCONF,    \
122         }
123
124 static struct plat_serial8250_port jazz_serial_data[] = {
125         MEMPORT(JAZZ_SERIAL1_BASE, JAZZ_SERIAL1_IRQ),
126         MEMPORT(JAZZ_SERIAL2_BASE, JAZZ_SERIAL2_IRQ),
127         { },
128 };
129
130 static struct platform_device jazz_serial8250_device = {
131         .name                   = "serial8250",
132         .id                     = PLAT8250_DEV_PLATFORM,
133         .dev                    = {
134                 .platform_data  = jazz_serial_data,
135         },
136 };
137
138 static struct resource jazz_esp_rsrc[] = {
139         {
140                 .start = JAZZ_SCSI_BASE,
141                 .end   = JAZZ_SCSI_BASE + 31,
142                 .flags = IORESOURCE_MEM
143         },
144         {
145                 .start = JAZZ_SCSI_DMA,
146                 .end   = JAZZ_SCSI_DMA,
147                 .flags = IORESOURCE_MEM
148         },
149         {
150                 .start = JAZZ_SCSI_IRQ,
151                 .end   = JAZZ_SCSI_IRQ,
152                 .flags = IORESOURCE_IRQ
153         }
154 };
155
156 static struct platform_device jazz_esp_pdev = {
157         .name           = "jazz_esp",
158         .num_resources  = ARRAY_SIZE(jazz_esp_rsrc),
159         .resource       = jazz_esp_rsrc
160 };
161
162 static struct resource jazz_sonic_rsrc[] = {
163         {
164                 .start = JAZZ_ETHERNET_BASE,
165                 .end   = JAZZ_ETHERNET_BASE + 0xff,
166                 .flags = IORESOURCE_MEM
167         },
168         {
169                 .start = JAZZ_ETHERNET_IRQ,
170                 .end   = JAZZ_ETHERNET_IRQ,
171                 .flags = IORESOURCE_IRQ
172         }
173 };
174
175 static struct platform_device jazz_sonic_pdev = {
176         .name           = "jazzsonic",
177         .num_resources  = ARRAY_SIZE(jazz_sonic_rsrc),
178         .resource       = jazz_sonic_rsrc
179 };
180
181 static struct resource jazz_cmos_rsrc[] = {
182         {
183                 .start = 0x70,
184                 .end   = 0x71,
185                 .flags = IORESOURCE_IO
186         },
187         {
188                 .start = 8,
189                 .end   = 8,
190                 .flags = IORESOURCE_IRQ
191         }
192 };
193
194 static struct platform_device jazz_cmos_pdev = {
195         .name           = "rtc_cmos",
196         .num_resources  = ARRAY_SIZE(jazz_cmos_rsrc),
197         .resource       = jazz_cmos_rsrc
198 };
199
200 static struct platform_device pcspeaker_pdev = {
201         .name           = "pcspkr",
202         .id             = -1,
203 };
204
205 static int __init jazz_setup_devinit(void)
206 {
207         platform_device_register(&jazz_serial8250_device);
208         platform_device_register(&jazz_esp_pdev);
209         platform_device_register(&jazz_sonic_pdev);
210         platform_device_register(&jazz_cmos_pdev);
211         platform_device_register(&pcspeaker_pdev);
212
213         return 0;
214 }
215
216 device_initcall(jazz_setup_devinit);