Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iq31244.c
Go to the documentation of this file.
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 <[email protected]>
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/serial_core.h>
25 #include <linux/serial_8250.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/platform_device.h>
28 #include <linux/io.h>
29 #include <mach/hardware.h>
30 #include <asm/cputype.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>
39 #include <mach/time.h>
40 
41 /*
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.
47  */
48 static int force_ep80219;
49 
50 static int is_80219(void)
51 {
52  return !!((read_cpuid_id() & 0xffffffe0) == 0x69052e20);
53 }
54 
55 static int is_ep80219(void)
56 {
57  if (machine_is_ep80219() || force_ep80219)
58  return 1;
59  else
60  return 0;
61 }
62 
63 
64 /*
65  * EP80219/IQ31244 timer tick configuration.
66  */
67 static void __init iq31244_timer_init(void)
68 {
69  if (is_ep80219()) {
70  /* 33.333 MHz crystal. */
71  iop_init_time(200000000);
72  } else {
73  /* 33.000 MHz crystal. */
74  iop_init_time(198000000);
75  }
76 }
77 
78 static struct sys_timer iq31244_timer = {
79  .init = iq31244_timer_init,
80 };
81 
82 
83 /*
84  * IQ31244 I/O.
85  */
86 static struct map_desc iq31244_io_desc[] __initdata = {
87  { /* on-board devices */
88  .virtual = IQ31244_UART,
90  .length = 0x00100000,
91  .type = MT_DEVICE,
92  },
93 };
94 
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  */
105 static int __init
106 ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
107 {
108  int irq;
109 
110  if (slot == 0) {
111  /* CFlash */
112  irq = IRQ_IOP32X_XINT1;
113  } else if (slot == 1) {
114  /* 82551 Pro 100 */
115  irq = IRQ_IOP32X_XINT0;
116  } else if (slot == 2) {
117  /* PCI-X Slot */
118  irq = IRQ_IOP32X_XINT3;
119  } else if (slot == 3) {
120  /* SATA */
121  irq = IRQ_IOP32X_XINT2;
122  } 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 
132 static struct hw_pci ep80219_pci __initdata = {
133  .nr_controllers = 1,
134  .ops = &iop3xx_ops,
135  .setup = iop3xx_pci_setup,
136  .preinit = iop3xx_pci_preinit,
137  .map_irq = ep80219_pci_map_irq,
138 };
139 
140 static int __init
141 iq31244_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
142 {
143  int irq;
144 
145  if (slot == 0) {
146  /* CFlash */
147  irq = IRQ_IOP32X_XINT1;
148  } else if (slot == 1) {
149  /* SATA */
150  irq = IRQ_IOP32X_XINT2;
151  } else if (slot == 2) {
152  /* PCI-X Slot */
153  irq = IRQ_IOP32X_XINT3;
154  } else if (slot == 3) {
155  /* 82546 GigE */
156  irq = IRQ_IOP32X_XINT0;
157  } else {
158  printk(KERN_ERR "iq31244_pci_map_irq called for unknown "
159  "device PCI:%d:%d:%d\n", dev->bus->number,
160  PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
161  irq = -1;
162  }
163 
164  return irq;
165 }
166 
167 static struct hw_pci iq31244_pci __initdata = {
168  .nr_controllers = 1,
169  .ops = &iop3xx_ops,
170  .setup = iop3xx_pci_setup,
171  .preinit = iop3xx_pci_preinit,
172  .map_irq = iq31244_pci_map_irq,
173 };
174 
175 static int __init iq31244_pci_init(void)
176 {
177  if (is_ep80219())
178  pci_common_init(&ep80219_pci);
179  else if (machine_is_iq31244()) {
180  if (is_80219()) {
181  printk("note: iq31244 board type has been selected\n");
182  printk("note: to select ep80219 operation:\n");
183  printk("\t1/ specify \"force_ep80219\" on the kernel"
184  " command line\n");
185  printk("\t2/ update boot loader to pass"
186  " the ep80219 id: %d\n", MACH_TYPE_EP80219);
187  }
188  pci_common_init(&iq31244_pci);
189  }
190 
191  return 0;
192 }
193 
194 subsys_initcall(iq31244_pci_init);
195 
196 
197 /*
198  * IQ31244 machine initialisation.
199  */
200 static struct physmap_flash_data iq31244_flash_data = {
201  .width = 2,
202 };
203 
204 static struct resource iq31244_flash_resource = {
205  .start = 0xf0000000,
206  .end = 0xf07fffff,
207  .flags = IORESOURCE_MEM,
208 };
209 
210 static struct platform_device iq31244_flash_device = {
211  .name = "physmap-flash",
212  .id = 0,
213  .dev = {
214  .platform_data = &iq31244_flash_data,
215  },
216  .num_resources = 1,
217  .resource = &iq31244_flash_resource,
218 };
219 
220 static struct plat_serial8250_port iq31244_serial_port[] = {
221  {
222  .mapbase = IQ31244_UART,
223  .membase = (char *)IQ31244_UART,
224  .irq = IRQ_IOP32X_XINT1,
225  .flags = UPF_SKIP_TEST,
226  .iotype = UPIO_MEM,
227  .regshift = 0,
228  .uartclk = 1843200,
229  },
230  { },
231 };
232 
233 static struct resource iq31244_uart_resource = {
234  .start = IQ31244_UART,
235  .end = IQ31244_UART + 7,
236  .flags = IORESOURCE_MEM,
237 };
238 
239 static struct platform_device iq31244_serial_device = {
240  .name = "serial8250",
241  .id = PLAT8250_DEV_PLATFORM,
242  .dev = {
243  .platform_data = iq31244_serial_port,
244  },
245  .num_resources = 1,
246  .resource = &iq31244_uart_resource,
247 };
248 
249 /*
250  * This function will send a SHUTDOWN_COMPLETE message to the PIC
251  * controller over I2C. We are not using the i2c subsystem since
252  * we are going to power off and it may be removed
253  */
255 {
256  /*
257  * Send the Address byte w/ the start condition
258  */
259  *IOP3XX_IDBR1 = 0x60;
260  *IOP3XX_ICR1 = 0xE9;
261  mdelay(1);
262 
263  /*
264  * Send the START_MSG byte w/ no start or stop condition
265  */
266  *IOP3XX_IDBR1 = 0x0F;
267  *IOP3XX_ICR1 = 0xE8;
268  mdelay(1);
269 
270  /*
271  * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
272  * stop condition
273  */
274  *IOP3XX_IDBR1 = 0x03;
275  *IOP3XX_ICR1 = 0xE8;
276  mdelay(1);
277 
278  /*
279  * Send an ignored byte w/ stop condition
280  */
281  *IOP3XX_IDBR1 = 0x00;
282  *IOP3XX_ICR1 = 0xEA;
283 
284  while (1)
285  ;
286 }
287 
288 static void __init iq31244_init_machine(void)
289 {
292  platform_device_register(&iq31244_flash_device);
293  platform_device_register(&iq31244_serial_device);
296 
297  if (is_ep80219())
299 
300  if (!is_80219())
302 }
303 
304 static int __init force_ep80219_setup(char *str)
305 {
306  force_ep80219 = 1;
307  return 1;
308 }
309 
310 __setup("force_ep80219", force_ep80219_setup);
311 
312 MACHINE_START(IQ31244, "Intel IQ31244")
313  /* Maintainer: Intel Corp. */
314  .atag_offset = 0x100,
315  .map_io = iq31244_map_io,
316  .init_irq = iop32x_init_irq,
317  .timer = &iq31244_timer,
318  .init_machine = iq31244_init_machine,
319  .restart = iop3xx_restart,
321 
322 /* There should have been an ep80219 machine identifier from the beginning.
323  * Boot roms older than March 2007 do not know the ep80219 machine id. Pass
324  * "force_ep80219" on the kernel command line, otherwise iq31244 operation
325  * will be selected.
326  */
327 MACHINE_START(EP80219, "Intel EP80219")
328  /* Maintainer: Intel Corp. */
329  .atag_offset = 0x100,
330  .map_io = iq31244_map_io,
331  .init_irq = iop32x_init_irq,
332  .timer = &iq31244_timer,
333  .init_machine = iq31244_init_machine,
334  .restart = iop3xx_restart,