blob: f2cd2966212da1381d677d47abb147f4b5c88879 [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
Lennert Buytenhekc680b772006-09-18 23:24:52 +010078
79/*
80 * IQ31244 I/O.
81 */
82static struct map_desc iq31244_io_desc[] __initdata = {
83 { /* on-board devices */
84 .virtual = IQ31244_UART,
85 .pfn = __phys_to_pfn(IQ31244_UART),
86 .length = 0x00100000,
87 .type = MT_DEVICE,
88 },
89};
90
91void __init iq31244_map_io(void)
92{
93 iop3xx_map_io();
94 iotable_init(iq31244_io_desc, ARRAY_SIZE(iq31244_io_desc));
95}
96
97
98/*
99 * EP80219/IQ31244 PCI.
100 */
Dan Williamsd73d8012007-05-15 01:03:36 +0100101static int __init
Ralf Baechled5341942011-06-10 15:30:21 +0100102ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100103{
104 int irq;
105
106 if (slot == 0) {
107 /* CFlash */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100108 irq = IRQ_IOP32X_XINT1;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100109 } else if (slot == 1) {
110 /* 82551 Pro 100 */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100111 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100112 } else if (slot == 2) {
113 /* PCI-X Slot */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100114 irq = IRQ_IOP32X_XINT3;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100115 } else if (slot == 3) {
116 /* SATA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100117 irq = IRQ_IOP32X_XINT2;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100118 } else {
119 printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
120 "device PCI:%d:%d:%d\n", dev->bus->number,
121 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
122 irq = -1;
123 }
124
125 return irq;
126}
127
128static struct hw_pci ep80219_pci __initdata = {
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100129 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +0000130 .ops = &iop3xx_ops,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100131 .setup = iop3xx_pci_setup,
132 .preinit = iop3xx_pci_preinit,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100133 .map_irq = ep80219_pci_map_irq,
134};
135
Dan Williamsd73d8012007-05-15 01:03:36 +0100136static int __init
Ralf Baechled5341942011-06-10 15:30:21 +0100137iq31244_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100138{
139 int irq;
140
141 if (slot == 0) {
142 /* CFlash */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100143 irq = IRQ_IOP32X_XINT1;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100144 } else if (slot == 1) {
145 /* SATA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100146 irq = IRQ_IOP32X_XINT2;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100147 } else if (slot == 2) {
148 /* PCI-X Slot */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100149 irq = IRQ_IOP32X_XINT3;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100150 } else if (slot == 3) {
151 /* 82546 GigE */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100152 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100153 } else {
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100154 printk(KERN_ERR "iq31244_pci_map_irq called for unknown "
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100155 "device PCI:%d:%d:%d\n", dev->bus->number,
156 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
157 irq = -1;
158 }
159
160 return irq;
161}
162
163static struct hw_pci iq31244_pci __initdata = {
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100164 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +0000165 .ops = &iop3xx_ops,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100166 .setup = iop3xx_pci_setup,
167 .preinit = iop3xx_pci_preinit,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100168 .map_irq = iq31244_pci_map_irq,
169};
170
171static int __init iq31244_pci_init(void)
172{
Dan Williamsc34002c2008-03-26 19:12:38 -0700173 if (is_ep80219())
174 pci_common_init(&ep80219_pci);
175 else if (machine_is_iq31244()) {
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100176 if (is_80219()) {
Dan Williams094f1272007-03-16 19:31:06 +0100177 printk("note: iq31244 board type has been selected\n");
178 printk("note: to select ep80219 operation:\n");
179 printk("\t1/ specify \"force_ep80219\" on the kernel"
180 " command line\n");
181 printk("\t2/ update boot loader to pass"
182 " the ep80219 id: %d\n", MACH_TYPE_EP80219);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100183 }
Dan Williamsc34002c2008-03-26 19:12:38 -0700184 pci_common_init(&iq31244_pci);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100185 }
186
187 return 0;
188}
189
190subsys_initcall(iq31244_pci_init);
191
192
193/*
194 * IQ31244 machine initialisation.
195 */
196static struct physmap_flash_data iq31244_flash_data = {
197 .width = 2,
198};
199
200static struct resource iq31244_flash_resource = {
201 .start = 0xf0000000,
202 .end = 0xf07fffff,
203 .flags = IORESOURCE_MEM,
204};
205
206static struct platform_device iq31244_flash_device = {
207 .name = "physmap-flash",
208 .id = 0,
209 .dev = {
210 .platform_data = &iq31244_flash_data,
211 },
212 .num_resources = 1,
213 .resource = &iq31244_flash_resource,
214};
215
216static struct plat_serial8250_port iq31244_serial_port[] = {
217 {
218 .mapbase = IQ31244_UART,
219 .membase = (char *)IQ31244_UART,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100220 .irq = IRQ_IOP32X_XINT1,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100221 .flags = UPF_SKIP_TEST,
222 .iotype = UPIO_MEM,
223 .regshift = 0,
224 .uartclk = 1843200,
225 },
226 { },
227};
228
229static struct resource iq31244_uart_resource = {
230 .start = IQ31244_UART,
231 .end = IQ31244_UART + 7,
232 .flags = IORESOURCE_MEM,
233};
234
235static struct platform_device iq31244_serial_device = {
236 .name = "serial8250",
237 .id = PLAT8250_DEV_PLATFORM,
238 .dev = {
239 .platform_data = iq31244_serial_port,
240 },
241 .num_resources = 1,
242 .resource = &iq31244_uart_resource,
243};
244
245/*
246 * This function will send a SHUTDOWN_COMPLETE message to the PIC
247 * controller over I2C. We are not using the i2c subsystem since
248 * we are going to power off and it may be removed
249 */
250void ep80219_power_off(void)
251{
252 /*
253 * Send the Address byte w/ the start condition
254 */
255 *IOP3XX_IDBR1 = 0x60;
256 *IOP3XX_ICR1 = 0xE9;
257 mdelay(1);
258
259 /*
260 * Send the START_MSG byte w/ no start or stop condition
261 */
262 *IOP3XX_IDBR1 = 0x0F;
263 *IOP3XX_ICR1 = 0xE8;
264 mdelay(1);
265
266 /*
267 * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
268 * stop condition
269 */
270 *IOP3XX_IDBR1 = 0x03;
271 *IOP3XX_ICR1 = 0xE8;
272 mdelay(1);
273
274 /*
275 * Send an ignored byte w/ stop condition
276 */
277 *IOP3XX_IDBR1 = 0x00;
278 *IOP3XX_ICR1 = 0xEA;
279
280 while (1)
281 ;
282}
283
284static void __init iq31244_init_machine(void)
285{
286 platform_device_register(&iop3xx_i2c0_device);
287 platform_device_register(&iop3xx_i2c1_device);
288 platform_device_register(&iq31244_flash_device);
289 platform_device_register(&iq31244_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700290 platform_device_register(&iop3xx_dma_0_channel);
291 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100292
Dan Williams094f1272007-03-16 19:31:06 +0100293 if (is_ep80219())
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100294 pm_power_off = ep80219_power_off;
Dan Williams2492c842007-01-02 13:52:31 -0700295
296 if (!is_80219())
297 platform_device_register(&iop3xx_aau_channel);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100298}
299
Dan Williams094f1272007-03-16 19:31:06 +0100300static int __init force_ep80219_setup(char *str)
301{
302 force_ep80219 = 1;
303 return 1;
304}
305
306__setup("force_ep80219", force_ep80219_setup);
307
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100308MACHINE_START(IQ31244, "Intel IQ31244")
309 /* Maintainer: Intel Corp. */
Nicolas Pitre18967462011-07-05 22:38:12 -0400310 .atag_offset = 0x100,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100311 .map_io = iq31244_map_io,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100312 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700313 .init_time = iq31244_timer_init,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100314 .init_machine = iq31244_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000315 .restart = iop3xx_restart,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100316MACHINE_END
Dan Williams094f1272007-03-16 19:31:06 +0100317
318/* There should have been an ep80219 machine identifier from the beginning.
319 * Boot roms older than March 2007 do not know the ep80219 machine id. Pass
320 * "force_ep80219" on the kernel command line, otherwise iq31244 operation
321 * will be selected.
322 */
323MACHINE_START(EP80219, "Intel EP80219")
324 /* Maintainer: Intel Corp. */
Nicolas Pitre18967462011-07-05 22:38:12 -0400325 .atag_offset = 0x100,
Dan Williams094f1272007-03-16 19:31:06 +0100326 .map_io = iq31244_map_io,
327 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700328 .init_time = iq31244_timer_init,
Dan Williams094f1272007-03-16 19:31:06 +0100329 .init_machine = iq31244_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000330 .restart = iop3xx_restart,
Dan Williams094f1272007-03-16 19:31:06 +0100331MACHINE_END