iq31244.c 7.4 KB

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