iq31244.c 7.7 KB

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