iq31244.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. /*
  39. * The EP80219 and IQ31244 use the same machine ID. To find out
  40. * which of the two we're running on, we look at the processor ID.
  41. */
  42. static int is_80219(void)
  43. {
  44. extern int processor_id;
  45. return !!((processor_id & 0xffffffe0) == 0x69052e20);
  46. }
  47. /*
  48. * EP80219/IQ31244 timer tick configuration.
  49. */
  50. static void __init iq31244_timer_init(void)
  51. {
  52. if (is_80219()) {
  53. /* 33.333 MHz crystal. */
  54. iop3xx_init_time(200000000);
  55. } else {
  56. /* 33.000 MHz crystal. */
  57. iop3xx_init_time(198000000);
  58. }
  59. }
  60. static struct sys_timer iq31244_timer = {
  61. .init = iq31244_timer_init,
  62. .offset = iop3xx_gettimeoffset,
  63. };
  64. /*
  65. * IQ31244 I/O.
  66. */
  67. static struct map_desc iq31244_io_desc[] __initdata = {
  68. { /* on-board devices */
  69. .virtual = IQ31244_UART,
  70. .pfn = __phys_to_pfn(IQ31244_UART),
  71. .length = 0x00100000,
  72. .type = MT_DEVICE,
  73. },
  74. };
  75. void __init iq31244_map_io(void)
  76. {
  77. iop3xx_map_io();
  78. iotable_init(iq31244_io_desc, ARRAY_SIZE(iq31244_io_desc));
  79. }
  80. /*
  81. * EP80219/IQ31244 PCI.
  82. */
  83. static inline int __init
  84. ep80219_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  85. {
  86. int irq;
  87. if (slot == 0) {
  88. /* CFlash */
  89. irq = IRQ_IOP32X_XINT1;
  90. } else if (slot == 1) {
  91. /* 82551 Pro 100 */
  92. irq = IRQ_IOP32X_XINT0;
  93. } else if (slot == 2) {
  94. /* PCI-X Slot */
  95. irq = IRQ_IOP32X_XINT3;
  96. } else if (slot == 3) {
  97. /* SATA */
  98. irq = IRQ_IOP32X_XINT2;
  99. } else {
  100. printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
  101. "device PCI:%d:%d:%d\n", dev->bus->number,
  102. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  103. irq = -1;
  104. }
  105. return irq;
  106. }
  107. static struct hw_pci ep80219_pci __initdata = {
  108. .swizzle = pci_std_swizzle,
  109. .nr_controllers = 1,
  110. .setup = iop3xx_pci_setup,
  111. .preinit = iop3xx_pci_preinit,
  112. .scan = iop3xx_pci_scan_bus,
  113. .map_irq = ep80219_pci_map_irq,
  114. };
  115. static inline int __init
  116. iq31244_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  117. {
  118. int irq;
  119. if (slot == 0) {
  120. /* CFlash */
  121. irq = IRQ_IOP32X_XINT1;
  122. } else if (slot == 1) {
  123. /* SATA */
  124. irq = IRQ_IOP32X_XINT2;
  125. } else if (slot == 2) {
  126. /* PCI-X Slot */
  127. irq = IRQ_IOP32X_XINT3;
  128. } else if (slot == 3) {
  129. /* 82546 GigE */
  130. irq = IRQ_IOP32X_XINT0;
  131. } else {
  132. printk(KERN_ERR "iq31244_pci_map_irq called for unknown "
  133. "device PCI:%d:%d:%d\n", dev->bus->number,
  134. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  135. irq = -1;
  136. }
  137. return irq;
  138. }
  139. static struct hw_pci iq31244_pci __initdata = {
  140. .swizzle = pci_std_swizzle,
  141. .nr_controllers = 1,
  142. .setup = iop3xx_pci_setup,
  143. .preinit = iop3xx_pci_preinit,
  144. .scan = iop3xx_pci_scan_bus,
  145. .map_irq = iq31244_pci_map_irq,
  146. };
  147. static int __init iq31244_pci_init(void)
  148. {
  149. if (machine_is_iq31244()) {
  150. if (is_80219()) {
  151. pci_common_init(&ep80219_pci);
  152. } else {
  153. pci_common_init(&iq31244_pci);
  154. }
  155. }
  156. return 0;
  157. }
  158. subsys_initcall(iq31244_pci_init);
  159. /*
  160. * IQ31244 machine initialisation.
  161. */
  162. static struct physmap_flash_data iq31244_flash_data = {
  163. .width = 2,
  164. };
  165. static struct resource iq31244_flash_resource = {
  166. .start = 0xf0000000,
  167. .end = 0xf07fffff,
  168. .flags = IORESOURCE_MEM,
  169. };
  170. static struct platform_device iq31244_flash_device = {
  171. .name = "physmap-flash",
  172. .id = 0,
  173. .dev = {
  174. .platform_data = &iq31244_flash_data,
  175. },
  176. .num_resources = 1,
  177. .resource = &iq31244_flash_resource,
  178. };
  179. static struct plat_serial8250_port iq31244_serial_port[] = {
  180. {
  181. .mapbase = IQ31244_UART,
  182. .membase = (char *)IQ31244_UART,
  183. .irq = IRQ_IOP32X_XINT1,
  184. .flags = UPF_SKIP_TEST,
  185. .iotype = UPIO_MEM,
  186. .regshift = 0,
  187. .uartclk = 1843200,
  188. },
  189. { },
  190. };
  191. static struct resource iq31244_uart_resource = {
  192. .start = IQ31244_UART,
  193. .end = IQ31244_UART + 7,
  194. .flags = IORESOURCE_MEM,
  195. };
  196. static struct platform_device iq31244_serial_device = {
  197. .name = "serial8250",
  198. .id = PLAT8250_DEV_PLATFORM,
  199. .dev = {
  200. .platform_data = iq31244_serial_port,
  201. },
  202. .num_resources = 1,
  203. .resource = &iq31244_uart_resource,
  204. };
  205. /*
  206. * This function will send a SHUTDOWN_COMPLETE message to the PIC
  207. * controller over I2C. We are not using the i2c subsystem since
  208. * we are going to power off and it may be removed
  209. */
  210. void ep80219_power_off(void)
  211. {
  212. /*
  213. * Send the Address byte w/ the start condition
  214. */
  215. *IOP3XX_IDBR1 = 0x60;
  216. *IOP3XX_ICR1 = 0xE9;
  217. mdelay(1);
  218. /*
  219. * Send the START_MSG byte w/ no start or stop condition
  220. */
  221. *IOP3XX_IDBR1 = 0x0F;
  222. *IOP3XX_ICR1 = 0xE8;
  223. mdelay(1);
  224. /*
  225. * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
  226. * stop condition
  227. */
  228. *IOP3XX_IDBR1 = 0x03;
  229. *IOP3XX_ICR1 = 0xE8;
  230. mdelay(1);
  231. /*
  232. * Send an ignored byte w/ stop condition
  233. */
  234. *IOP3XX_IDBR1 = 0x00;
  235. *IOP3XX_ICR1 = 0xEA;
  236. while (1)
  237. ;
  238. }
  239. static void __init iq31244_init_machine(void)
  240. {
  241. platform_device_register(&iop3xx_i2c0_device);
  242. platform_device_register(&iop3xx_i2c1_device);
  243. platform_device_register(&iq31244_flash_device);
  244. platform_device_register(&iq31244_serial_device);
  245. if (is_80219())
  246. pm_power_off = ep80219_power_off;
  247. }
  248. MACHINE_START(IQ31244, "Intel IQ31244")
  249. /* Maintainer: Intel Corp. */
  250. .phys_io = IQ31244_UART,
  251. .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
  252. .boot_params = 0xa0000100,
  253. .map_io = iq31244_map_io,
  254. .init_irq = iop32x_init_irq,
  255. .timer = &iq31244_timer,
  256. .init_machine = iq31244_init_machine,
  257. MACHINE_END