iq31244.c 7.6 KB

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