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