Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 1 | /* |
| 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> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/serial_core.h> |
| 26 | #include <linux/serial_8250.h> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 29 | #include <linux/io.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | #include <mach/hardware.h> |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 31 | #include <asm/cputype.h> |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 32 | #include <asm/irq.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/map.h> |
| 35 | #include <asm/mach/pci.h> |
| 36 | #include <asm/mach/time.h> |
| 37 | #include <asm/mach-types.h> |
| 38 | #include <asm/page.h> |
| 39 | #include <asm/pgtable.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 40 | #include <mach/time.h> |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 41 | |
| 42 | /* |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 43 | * Until March of 2007 iq31244 platforms and ep80219 platforms shared the |
| 44 | * same machine id, and the processor type was used to select board type. |
| 45 | * However this assumption breaks for an iq80219 board which is an iop219 |
| 46 | * processor on an iq31244 board. The force_ep80219 flag has been added |
| 47 | * for old boot loaders using the iq31244 machine id for an ep80219 platform. |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 48 | */ |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 49 | static int force_ep80219; |
| 50 | |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 51 | static int is_80219(void) |
| 52 | { |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 53 | return !!((read_cpuid_id() & 0xffffffe0) == 0x69052e20); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 54 | } |
| 55 | |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 56 | static int is_ep80219(void) |
| 57 | { |
| 58 | if (machine_is_ep80219() || force_ep80219) |
| 59 | return 1; |
| 60 | else |
| 61 | return 0; |
| 62 | } |
| 63 | |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | * EP80219/IQ31244 timer tick configuration. |
| 67 | */ |
| 68 | static void __init iq31244_timer_init(void) |
| 69 | { |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 70 | if (is_ep80219()) { |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 71 | /* 33.333 MHz crystal. */ |
Dan Williams | 3668b45 | 2007-02-13 17:13:34 +0100 | [diff] [blame] | 72 | iop_init_time(200000000); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 73 | } else { |
| 74 | /* 33.000 MHz crystal. */ |
Dan Williams | 3668b45 | 2007-02-13 17:13:34 +0100 | [diff] [blame] | 75 | iop_init_time(198000000); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
| 79 | static struct sys_timer iq31244_timer = { |
| 80 | .init = iq31244_timer_init, |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | * IQ31244 I/O. |
| 86 | */ |
| 87 | static struct map_desc iq31244_io_desc[] __initdata = { |
| 88 | { /* on-board devices */ |
| 89 | .virtual = IQ31244_UART, |
| 90 | .pfn = __phys_to_pfn(IQ31244_UART), |
| 91 | .length = 0x00100000, |
| 92 | .type = MT_DEVICE, |
| 93 | }, |
| 94 | }; |
| 95 | |
| 96 | void __init iq31244_map_io(void) |
| 97 | { |
| 98 | iop3xx_map_io(); |
| 99 | iotable_init(iq31244_io_desc, ARRAY_SIZE(iq31244_io_desc)); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /* |
| 104 | * EP80219/IQ31244 PCI. |
| 105 | */ |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 106 | static int __init |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 107 | ep80219_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 108 | { |
| 109 | int irq; |
| 110 | |
| 111 | if (slot == 0) { |
| 112 | /* CFlash */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 113 | irq = IRQ_IOP32X_XINT1; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 114 | } else if (slot == 1) { |
| 115 | /* 82551 Pro 100 */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 116 | irq = IRQ_IOP32X_XINT0; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 117 | } else if (slot == 2) { |
| 118 | /* PCI-X Slot */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 119 | irq = IRQ_IOP32X_XINT3; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 120 | } else if (slot == 3) { |
| 121 | /* SATA */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 122 | irq = IRQ_IOP32X_XINT2; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 123 | } else { |
| 124 | printk(KERN_ERR "ep80219_pci_map_irq() called for unknown " |
| 125 | "device PCI:%d:%d:%d\n", dev->bus->number, |
| 126 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); |
| 127 | irq = -1; |
| 128 | } |
| 129 | |
| 130 | return irq; |
| 131 | } |
| 132 | |
| 133 | static struct hw_pci ep80219_pci __initdata = { |
| 134 | .swizzle = pci_std_swizzle, |
| 135 | .nr_controllers = 1, |
| 136 | .setup = iop3xx_pci_setup, |
| 137 | .preinit = iop3xx_pci_preinit, |
| 138 | .scan = iop3xx_pci_scan_bus, |
| 139 | .map_irq = ep80219_pci_map_irq, |
| 140 | }; |
| 141 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 142 | static int __init |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 143 | iq31244_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 144 | { |
| 145 | int irq; |
| 146 | |
| 147 | if (slot == 0) { |
| 148 | /* CFlash */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 149 | irq = IRQ_IOP32X_XINT1; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 150 | } else if (slot == 1) { |
| 151 | /* SATA */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 152 | irq = IRQ_IOP32X_XINT2; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 153 | } else if (slot == 2) { |
| 154 | /* PCI-X Slot */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 155 | irq = IRQ_IOP32X_XINT3; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 156 | } else if (slot == 3) { |
| 157 | /* 82546 GigE */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 158 | irq = IRQ_IOP32X_XINT0; |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 159 | } else { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 160 | printk(KERN_ERR "iq31244_pci_map_irq called for unknown " |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 161 | "device PCI:%d:%d:%d\n", dev->bus->number, |
| 162 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); |
| 163 | irq = -1; |
| 164 | } |
| 165 | |
| 166 | return irq; |
| 167 | } |
| 168 | |
| 169 | static struct hw_pci iq31244_pci __initdata = { |
| 170 | .swizzle = pci_std_swizzle, |
| 171 | .nr_controllers = 1, |
| 172 | .setup = iop3xx_pci_setup, |
| 173 | .preinit = iop3xx_pci_preinit, |
| 174 | .scan = iop3xx_pci_scan_bus, |
| 175 | .map_irq = iq31244_pci_map_irq, |
| 176 | }; |
| 177 | |
| 178 | static int __init iq31244_pci_init(void) |
| 179 | { |
Dan Williams | c34002c | 2008-03-26 19:12:38 -0700 | [diff] [blame] | 180 | if (is_ep80219()) |
| 181 | pci_common_init(&ep80219_pci); |
| 182 | else if (machine_is_iq31244()) { |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 183 | if (is_80219()) { |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 184 | printk("note: iq31244 board type has been selected\n"); |
| 185 | printk("note: to select ep80219 operation:\n"); |
| 186 | printk("\t1/ specify \"force_ep80219\" on the kernel" |
| 187 | " command line\n"); |
| 188 | printk("\t2/ update boot loader to pass" |
| 189 | " the ep80219 id: %d\n", MACH_TYPE_EP80219); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 190 | } |
Dan Williams | c34002c | 2008-03-26 19:12:38 -0700 | [diff] [blame] | 191 | pci_common_init(&iq31244_pci); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | subsys_initcall(iq31244_pci_init); |
| 198 | |
| 199 | |
| 200 | /* |
| 201 | * IQ31244 machine initialisation. |
| 202 | */ |
| 203 | static struct physmap_flash_data iq31244_flash_data = { |
| 204 | .width = 2, |
| 205 | }; |
| 206 | |
| 207 | static struct resource iq31244_flash_resource = { |
| 208 | .start = 0xf0000000, |
| 209 | .end = 0xf07fffff, |
| 210 | .flags = IORESOURCE_MEM, |
| 211 | }; |
| 212 | |
| 213 | static struct platform_device iq31244_flash_device = { |
| 214 | .name = "physmap-flash", |
| 215 | .id = 0, |
| 216 | .dev = { |
| 217 | .platform_data = &iq31244_flash_data, |
| 218 | }, |
| 219 | .num_resources = 1, |
| 220 | .resource = &iq31244_flash_resource, |
| 221 | }; |
| 222 | |
| 223 | static struct plat_serial8250_port iq31244_serial_port[] = { |
| 224 | { |
| 225 | .mapbase = IQ31244_UART, |
| 226 | .membase = (char *)IQ31244_UART, |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 227 | .irq = IRQ_IOP32X_XINT1, |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 228 | .flags = UPF_SKIP_TEST, |
| 229 | .iotype = UPIO_MEM, |
| 230 | .regshift = 0, |
| 231 | .uartclk = 1843200, |
| 232 | }, |
| 233 | { }, |
| 234 | }; |
| 235 | |
| 236 | static struct resource iq31244_uart_resource = { |
| 237 | .start = IQ31244_UART, |
| 238 | .end = IQ31244_UART + 7, |
| 239 | .flags = IORESOURCE_MEM, |
| 240 | }; |
| 241 | |
| 242 | static struct platform_device iq31244_serial_device = { |
| 243 | .name = "serial8250", |
| 244 | .id = PLAT8250_DEV_PLATFORM, |
| 245 | .dev = { |
| 246 | .platform_data = iq31244_serial_port, |
| 247 | }, |
| 248 | .num_resources = 1, |
| 249 | .resource = &iq31244_uart_resource, |
| 250 | }; |
| 251 | |
| 252 | /* |
| 253 | * This function will send a SHUTDOWN_COMPLETE message to the PIC |
| 254 | * controller over I2C. We are not using the i2c subsystem since |
| 255 | * we are going to power off and it may be removed |
| 256 | */ |
| 257 | void ep80219_power_off(void) |
| 258 | { |
| 259 | /* |
| 260 | * Send the Address byte w/ the start condition |
| 261 | */ |
| 262 | *IOP3XX_IDBR1 = 0x60; |
| 263 | *IOP3XX_ICR1 = 0xE9; |
| 264 | mdelay(1); |
| 265 | |
| 266 | /* |
| 267 | * Send the START_MSG byte w/ no start or stop condition |
| 268 | */ |
| 269 | *IOP3XX_IDBR1 = 0x0F; |
| 270 | *IOP3XX_ICR1 = 0xE8; |
| 271 | mdelay(1); |
| 272 | |
| 273 | /* |
| 274 | * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or |
| 275 | * stop condition |
| 276 | */ |
| 277 | *IOP3XX_IDBR1 = 0x03; |
| 278 | *IOP3XX_ICR1 = 0xE8; |
| 279 | mdelay(1); |
| 280 | |
| 281 | /* |
| 282 | * Send an ignored byte w/ stop condition |
| 283 | */ |
| 284 | *IOP3XX_IDBR1 = 0x00; |
| 285 | *IOP3XX_ICR1 = 0xEA; |
| 286 | |
| 287 | while (1) |
| 288 | ; |
| 289 | } |
| 290 | |
| 291 | static void __init iq31244_init_machine(void) |
| 292 | { |
| 293 | platform_device_register(&iop3xx_i2c0_device); |
| 294 | platform_device_register(&iop3xx_i2c1_device); |
| 295 | platform_device_register(&iq31244_flash_device); |
| 296 | platform_device_register(&iq31244_serial_device); |
Dan Williams | 2492c84 | 2007-01-02 13:52:31 -0700 | [diff] [blame] | 297 | platform_device_register(&iop3xx_dma_0_channel); |
| 298 | platform_device_register(&iop3xx_dma_1_channel); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 299 | |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 300 | if (is_ep80219()) |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 301 | pm_power_off = ep80219_power_off; |
Dan Williams | 2492c84 | 2007-01-02 13:52:31 -0700 | [diff] [blame] | 302 | |
| 303 | if (!is_80219()) |
| 304 | platform_device_register(&iop3xx_aau_channel); |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 305 | } |
| 306 | |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 307 | static int __init force_ep80219_setup(char *str) |
| 308 | { |
| 309 | force_ep80219 = 1; |
| 310 | return 1; |
| 311 | } |
| 312 | |
| 313 | __setup("force_ep80219", force_ep80219_setup); |
| 314 | |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 315 | MACHINE_START(IQ31244, "Intel IQ31244") |
| 316 | /* Maintainer: Intel Corp. */ |
| 317 | .phys_io = IQ31244_UART, |
| 318 | .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc, |
| 319 | .boot_params = 0xa0000100, |
| 320 | .map_io = iq31244_map_io, |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 321 | .init_irq = iop32x_init_irq, |
Lennert Buytenhek | c680b77 | 2006-09-18 23:24:52 +0100 | [diff] [blame] | 322 | .timer = &iq31244_timer, |
| 323 | .init_machine = iq31244_init_machine, |
| 324 | MACHINE_END |
Dan Williams | 094f127 | 2007-03-16 19:31:06 +0100 | [diff] [blame] | 325 | |
| 326 | /* There should have been an ep80219 machine identifier from the beginning. |
| 327 | * Boot roms older than March 2007 do not know the ep80219 machine id. Pass |
| 328 | * "force_ep80219" on the kernel command line, otherwise iq31244 operation |
| 329 | * will be selected. |
| 330 | */ |
| 331 | MACHINE_START(EP80219, "Intel EP80219") |
| 332 | /* Maintainer: Intel Corp. */ |
| 333 | .phys_io = IQ31244_UART, |
| 334 | .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc, |
| 335 | .boot_params = 0xa0000100, |
| 336 | .map_io = iq31244_map_io, |
| 337 | .init_irq = iop32x_init_irq, |
| 338 | .timer = &iq31244_timer, |
| 339 | .init_machine = iq31244_init_machine, |
| 340 | MACHINE_END |