blob: d6ac85ff109deef02935213bc33577f0be2da42a [file] [log] [blame]
Lennert Buytenhekc680b772006-09-18 23:24:52 +01001/*
2 * arch/arm/mach-iop32x/iq31244.c
3 *
4 * Board support code for the Intel EP80219 and IQ31244 platforms.
5 *
6 * Author: Rory Bolt <rorybolt@pacbell.net>
7 * Copyright (C) 2002 Rory Bolt
8 * Copyright 2003 (c) MontaVista, Software, Inc.
9 * Copyright (C) 2004 Intel Corp.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16
17#include <linux/mm.h>
18#include <linux/init.h>
19#include <linux/delay.h>
20#include <linux/kernel.h>
21#include <linux/pci.h>
22#include <linux/pm.h>
23#include <linux/string.h>
Lennert Buytenhekc680b772006-09-18 23:24:52 +010024#include <linux/serial_core.h>
25#include <linux/serial_8250.h>
26#include <linux/mtd/physmap.h>
27#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010028#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Russell King0ba8b9b2008-08-10 18:08:10 +010030#include <asm/cputype.h>
Lennert Buytenhekc680b772006-09-18 23:24:52 +010031#include <asm/irq.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34#include <asm/mach/pci.h>
35#include <asm/mach/time.h>
36#include <asm/mach-types.h>
37#include <asm/page.h>
38#include <asm/pgtable.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010039#include <mach/time.h>
Lennert Buytenhekc680b772006-09-18 23:24:52 +010040
41/*
Dan Williams094f1272007-03-16 19:31:06 +010042 * Until March of 2007 iq31244 platforms and ep80219 platforms shared the
43 * same machine id, and the processor type was used to select board type.
44 * However this assumption breaks for an iq80219 board which is an iop219
45 * processor on an iq31244 board. The force_ep80219 flag has been added
46 * for old boot loaders using the iq31244 machine id for an ep80219 platform.
Lennert Buytenhekc680b772006-09-18 23:24:52 +010047 */
Dan Williams094f1272007-03-16 19:31:06 +010048static int force_ep80219;
49
Lennert Buytenhekc680b772006-09-18 23:24:52 +010050static int is_80219(void)
51{
Russell King0ba8b9b2008-08-10 18:08:10 +010052 return !!((read_cpuid_id() & 0xffffffe0) == 0x69052e20);
Lennert Buytenhekc680b772006-09-18 23:24:52 +010053}
54
Dan Williams094f1272007-03-16 19:31:06 +010055static int is_ep80219(void)
56{
57 if (machine_is_ep80219() || force_ep80219)
58 return 1;
59 else
60 return 0;
61}
62
Lennert Buytenhekc680b772006-09-18 23:24:52 +010063
64/*
65 * EP80219/IQ31244 timer tick configuration.
66 */
67static void __init iq31244_timer_init(void)
68{
Dan Williams094f1272007-03-16 19:31:06 +010069 if (is_ep80219()) {
Lennert Buytenhekc680b772006-09-18 23:24:52 +010070 /* 33.333 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010071 iop_init_time(200000000);
Lennert Buytenhekc680b772006-09-18 23:24:52 +010072 } else {
73 /* 33.000 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010074 iop_init_time(198000000);
Lennert Buytenhekc680b772006-09-18 23:24:52 +010075 }
76}
77
78static struct sys_timer iq31244_timer = {
79 .init = iq31244_timer_init,
Lennert Buytenhekc680b772006-09-18 23:24:52 +010080};
81
82
83/*
84 * IQ31244 I/O.
85 */
86static struct map_desc iq31244_io_desc[] __initdata = {
87 { /* on-board devices */
88 .virtual = IQ31244_UART,
89 .pfn = __phys_to_pfn(IQ31244_UART),
90 .length = 0x00100000,
91 .type = MT_DEVICE,
92 },
93};
94
95void __init iq31244_map_io(void)
96{
97 iop3xx_map_io();
98 iotable_init(iq31244_io_desc, ARRAY_SIZE(iq31244_io_desc));
99}
100
101
102/*
103 * EP80219/IQ31244 PCI.
104 */
Dan Williamsd73d8012007-05-15 01:03:36 +0100105static int __init
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100106ep80219_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
107{
108 int irq;
109
110 if (slot == 0) {
111 /* CFlash */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100112 irq = IRQ_IOP32X_XINT1;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100113 } else if (slot == 1) {
114 /* 82551 Pro 100 */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100115 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100116 } else if (slot == 2) {
117 /* PCI-X Slot */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100118 irq = IRQ_IOP32X_XINT3;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100119 } else if (slot == 3) {
120 /* SATA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100121 irq = IRQ_IOP32X_XINT2;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100122 } else {
123 printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
124 "device PCI:%d:%d:%d\n", dev->bus->number,
125 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
126 irq = -1;
127 }
128
129 return irq;
130}
131
132static struct hw_pci ep80219_pci __initdata = {
133 .swizzle = pci_std_swizzle,
134 .nr_controllers = 1,
135 .setup = iop3xx_pci_setup,
136 .preinit = iop3xx_pci_preinit,
137 .scan = iop3xx_pci_scan_bus,
138 .map_irq = ep80219_pci_map_irq,
139};
140
Dan Williamsd73d8012007-05-15 01:03:36 +0100141static int __init
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100142iq31244_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
143{
144 int irq;
145
146 if (slot == 0) {
147 /* CFlash */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100148 irq = IRQ_IOP32X_XINT1;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100149 } else if (slot == 1) {
150 /* SATA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100151 irq = IRQ_IOP32X_XINT2;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100152 } else if (slot == 2) {
153 /* PCI-X Slot */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100154 irq = IRQ_IOP32X_XINT3;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100155 } else if (slot == 3) {
156 /* 82546 GigE */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100157 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100158 } else {
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100159 printk(KERN_ERR "iq31244_pci_map_irq called for unknown "
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100160 "device PCI:%d:%d:%d\n", dev->bus->number,
161 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
162 irq = -1;
163 }
164
165 return irq;
166}
167
168static struct hw_pci iq31244_pci __initdata = {
169 .swizzle = pci_std_swizzle,
170 .nr_controllers = 1,
171 .setup = iop3xx_pci_setup,
172 .preinit = iop3xx_pci_preinit,
173 .scan = iop3xx_pci_scan_bus,
174 .map_irq = iq31244_pci_map_irq,
175};
176
177static int __init iq31244_pci_init(void)
178{
Dan Williamsc34002c2008-03-26 19:12:38 -0700179 if (is_ep80219())
180 pci_common_init(&ep80219_pci);
181 else if (machine_is_iq31244()) {
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100182 if (is_80219()) {
Dan Williams094f1272007-03-16 19:31:06 +0100183 printk("note: iq31244 board type has been selected\n");
184 printk("note: to select ep80219 operation:\n");
185 printk("\t1/ specify \"force_ep80219\" on the kernel"
186 " command line\n");
187 printk("\t2/ update boot loader to pass"
188 " the ep80219 id: %d\n", MACH_TYPE_EP80219);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100189 }
Dan Williamsc34002c2008-03-26 19:12:38 -0700190 pci_common_init(&iq31244_pci);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100191 }
192
193 return 0;
194}
195
196subsys_initcall(iq31244_pci_init);
197
198
199/*
200 * IQ31244 machine initialisation.
201 */
202static struct physmap_flash_data iq31244_flash_data = {
203 .width = 2,
204};
205
206static struct resource iq31244_flash_resource = {
207 .start = 0xf0000000,
208 .end = 0xf07fffff,
209 .flags = IORESOURCE_MEM,
210};
211
212static struct platform_device iq31244_flash_device = {
213 .name = "physmap-flash",
214 .id = 0,
215 .dev = {
216 .platform_data = &iq31244_flash_data,
217 },
218 .num_resources = 1,
219 .resource = &iq31244_flash_resource,
220};
221
222static struct plat_serial8250_port iq31244_serial_port[] = {
223 {
224 .mapbase = IQ31244_UART,
225 .membase = (char *)IQ31244_UART,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100226 .irq = IRQ_IOP32X_XINT1,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100227 .flags = UPF_SKIP_TEST,
228 .iotype = UPIO_MEM,
229 .regshift = 0,
230 .uartclk = 1843200,
231 },
232 { },
233};
234
235static struct resource iq31244_uart_resource = {
236 .start = IQ31244_UART,
237 .end = IQ31244_UART + 7,
238 .flags = IORESOURCE_MEM,
239};
240
241static struct platform_device iq31244_serial_device = {
242 .name = "serial8250",
243 .id = PLAT8250_DEV_PLATFORM,
244 .dev = {
245 .platform_data = iq31244_serial_port,
246 },
247 .num_resources = 1,
248 .resource = &iq31244_uart_resource,
249};
250
251/*
252 * This function will send a SHUTDOWN_COMPLETE message to the PIC
253 * controller over I2C. We are not using the i2c subsystem since
254 * we are going to power off and it may be removed
255 */
256void ep80219_power_off(void)
257{
258 /*
259 * Send the Address byte w/ the start condition
260 */
261 *IOP3XX_IDBR1 = 0x60;
262 *IOP3XX_ICR1 = 0xE9;
263 mdelay(1);
264
265 /*
266 * Send the START_MSG byte w/ no start or stop condition
267 */
268 *IOP3XX_IDBR1 = 0x0F;
269 *IOP3XX_ICR1 = 0xE8;
270 mdelay(1);
271
272 /*
273 * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
274 * stop condition
275 */
276 *IOP3XX_IDBR1 = 0x03;
277 *IOP3XX_ICR1 = 0xE8;
278 mdelay(1);
279
280 /*
281 * Send an ignored byte w/ stop condition
282 */
283 *IOP3XX_IDBR1 = 0x00;
284 *IOP3XX_ICR1 = 0xEA;
285
286 while (1)
287 ;
288}
289
290static void __init iq31244_init_machine(void)
291{
292 platform_device_register(&iop3xx_i2c0_device);
293 platform_device_register(&iop3xx_i2c1_device);
294 platform_device_register(&iq31244_flash_device);
295 platform_device_register(&iq31244_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700296 platform_device_register(&iop3xx_dma_0_channel);
297 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100298
Dan Williams094f1272007-03-16 19:31:06 +0100299 if (is_ep80219())
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100300 pm_power_off = ep80219_power_off;
Dan Williams2492c842007-01-02 13:52:31 -0700301
302 if (!is_80219())
303 platform_device_register(&iop3xx_aau_channel);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100304}
305
Dan Williams094f1272007-03-16 19:31:06 +0100306static int __init force_ep80219_setup(char *str)
307{
308 force_ep80219 = 1;
309 return 1;
310}
311
312__setup("force_ep80219", force_ep80219_setup);
313
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100314MACHINE_START(IQ31244, "Intel IQ31244")
315 /* Maintainer: Intel Corp. */
316 .phys_io = IQ31244_UART,
317 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
318 .boot_params = 0xa0000100,
319 .map_io = iq31244_map_io,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100320 .init_irq = iop32x_init_irq,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100321 .timer = &iq31244_timer,
322 .init_machine = iq31244_init_machine,
323MACHINE_END
Dan Williams094f1272007-03-16 19:31:06 +0100324
325/* There should have been an ep80219 machine identifier from the beginning.
326 * Boot roms older than March 2007 do not know the ep80219 machine id. Pass
327 * "force_ep80219" on the kernel command line, otherwise iq31244 operation
328 * will be selected.
329 */
330MACHINE_START(EP80219, "Intel EP80219")
331 /* Maintainer: Intel Corp. */
332 .phys_io = IQ31244_UART,
333 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
334 .boot_params = 0xa0000100,
335 .map_io = iq31244_map_io,
336 .init_irq = iop32x_init_irq,
337 .timer = &iq31244_timer,
338 .init_machine = iq31244_init_machine,
339MACHINE_END