iq31244.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 <asm/hardware.h>
  29. #include <asm/io.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 <asm/arch/time.h>
  39. /*
  40. * Until March of 2007 iq31244 platforms and ep80219 platforms shared the
  41. * same machine id, and the processor type was used to select board type.
  42. * However this assumption breaks for an iq80219 board which is an iop219
  43. * processor on an iq31244 board. The force_ep80219 flag has been added
  44. * for old boot loaders using the iq31244 machine id for an ep80219 platform.
  45. */
  46. static int force_ep80219;
  47. static int is_80219(void)
  48. {
  49. extern int processor_id;
  50. return !!((processor_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. if (iop3xx_get_init_atu() == IOP3XX_INIT_ATU_ENABLE)
  163. pci_common_init(&ep80219_pci);
  164. } else if (machine_is_iq31244()) {
  165. if (is_80219()) {
  166. printk("note: iq31244 board type has been selected\n");
  167. printk("note: to select ep80219 operation:\n");
  168. printk("\t1/ specify \"force_ep80219\" on the kernel"
  169. " command line\n");
  170. printk("\t2/ update boot loader to pass"
  171. " the ep80219 id: %d\n", MACH_TYPE_EP80219);
  172. }
  173. if (iop3xx_get_init_atu() == IOP3XX_INIT_ATU_ENABLE)
  174. pci_common_init(&iq31244_pci);
  175. }
  176. return 0;
  177. }
  178. subsys_initcall(iq31244_pci_init);
  179. /*
  180. * IQ31244 machine initialisation.
  181. */
  182. static struct physmap_flash_data iq31244_flash_data = {
  183. .width = 2,
  184. };
  185. static struct resource iq31244_flash_resource = {
  186. .start = 0xf0000000,
  187. .end = 0xf07fffff,
  188. .flags = IORESOURCE_MEM,
  189. };
  190. static struct platform_device iq31244_flash_device = {
  191. .name = "physmap-flash",
  192. .id = 0,
  193. .dev = {
  194. .platform_data = &iq31244_flash_data,
  195. },
  196. .num_resources = 1,
  197. .resource = &iq31244_flash_resource,
  198. };
  199. static struct plat_serial8250_port iq31244_serial_port[] = {
  200. {
  201. .mapbase = IQ31244_UART,
  202. .membase = (char *)IQ31244_UART,
  203. .irq = IRQ_IOP32X_XINT1,
  204. .flags = UPF_SKIP_TEST,
  205. .iotype = UPIO_MEM,
  206. .regshift = 0,
  207. .uartclk = 1843200,
  208. },
  209. { },
  210. };
  211. static struct resource iq31244_uart_resource = {
  212. .start = IQ31244_UART,
  213. .end = IQ31244_UART + 7,
  214. .flags = IORESOURCE_MEM,
  215. };
  216. static struct platform_device iq31244_serial_device = {
  217. .name = "serial8250",
  218. .id = PLAT8250_DEV_PLATFORM,
  219. .dev = {
  220. .platform_data = iq31244_serial_port,
  221. },
  222. .num_resources = 1,
  223. .resource = &iq31244_uart_resource,
  224. };
  225. /*
  226. * This function will send a SHUTDOWN_COMPLETE message to the PIC
  227. * controller over I2C. We are not using the i2c subsystem since
  228. * we are going to power off and it may be removed
  229. */
  230. void ep80219_power_off(void)
  231. {
  232. /*
  233. * Send the Address byte w/ the start condition
  234. */
  235. *IOP3XX_IDBR1 = 0x60;
  236. *IOP3XX_ICR1 = 0xE9;
  237. mdelay(1);
  238. /*
  239. * Send the START_MSG byte w/ no start or stop condition
  240. */
  241. *IOP3XX_IDBR1 = 0x0F;
  242. *IOP3XX_ICR1 = 0xE8;
  243. mdelay(1);
  244. /*
  245. * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
  246. * stop condition
  247. */
  248. *IOP3XX_IDBR1 = 0x03;
  249. *IOP3XX_ICR1 = 0xE8;
  250. mdelay(1);
  251. /*
  252. * Send an ignored byte w/ stop condition
  253. */
  254. *IOP3XX_IDBR1 = 0x00;
  255. *IOP3XX_ICR1 = 0xEA;
  256. while (1)
  257. ;
  258. }
  259. static void __init iq31244_init_machine(void)
  260. {
  261. platform_device_register(&iop3xx_i2c0_device);
  262. platform_device_register(&iop3xx_i2c1_device);
  263. platform_device_register(&iq31244_flash_device);
  264. platform_device_register(&iq31244_serial_device);
  265. if (is_ep80219())
  266. pm_power_off = ep80219_power_off;
  267. }
  268. static int __init force_ep80219_setup(char *str)
  269. {
  270. force_ep80219 = 1;
  271. return 1;
  272. }
  273. __setup("force_ep80219", force_ep80219_setup);
  274. MACHINE_START(IQ31244, "Intel IQ31244")
  275. /* Maintainer: Intel Corp. */
  276. .phys_io = IQ31244_UART,
  277. .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
  278. .boot_params = 0xa0000100,
  279. .map_io = iq31244_map_io,
  280. .init_irq = iop32x_init_irq,
  281. .timer = &iq31244_timer,
  282. .init_machine = iq31244_init_machine,
  283. MACHINE_END
  284. /* There should have been an ep80219 machine identifier from the beginning.
  285. * Boot roms older than March 2007 do not know the ep80219 machine id. Pass
  286. * "force_ep80219" on the kernel command line, otherwise iq31244 operation
  287. * will be selected.
  288. */
  289. MACHINE_START(EP80219, "Intel EP80219")
  290. /* Maintainer: Intel Corp. */
  291. .phys_io = IQ31244_UART,
  292. .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
  293. .boot_params = 0xa0000100,
  294. .map_io = iq31244_map_io,
  295. .init_irq = iop32x_init_irq,
  296. .timer = &iq31244_timer,
  297. .init_machine = iq31244_init_machine,
  298. MACHINE_END