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