iq31244.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * arch/arm/mach-iop32x/iq31244.c
  4. *
  5. * Board support code for the Intel EP80219 and IQ31244 platforms.
  6. *
  7. * Author: Rory Bolt <[email protected]>
  8. * Copyright (C) 2002 Rory Bolt
  9. * Copyright 2003 (c) MontaVista, Software, Inc.
  10. * Copyright (C) 2004 Intel Corp.
  11. */
  12. #include <linux/mm.h>
  13. #include <linux/init.h>
  14. #include <linux/delay.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/pm.h>
  18. #include <linux/string.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/serial_8250.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio/machine.h>
  25. #include <asm/cputype.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/pci.h>
  30. #include <asm/mach/time.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/page.h>
  33. #include "hardware.h"
  34. #include "irqs.h"
  35. #include "gpio-iop32x.h"
  36. /*
  37. * Until March of 2007 iq31244 platforms and ep80219 platforms shared the
  38. * same machine id, and the processor type was used to select board type.
  39. * However this assumption breaks for an iq80219 board which is an iop219
  40. * processor on an iq31244 board. The force_ep80219 flag has been added
  41. * for old boot loaders using the iq31244 machine id for an ep80219 platform.
  42. */
  43. static int force_ep80219;
  44. static int is_80219(void)
  45. {
  46. return !!((read_cpuid_id() & 0xffffffe0) == 0x69052e20);
  47. }
  48. static int is_ep80219(void)
  49. {
  50. if (machine_is_ep80219() || force_ep80219)
  51. return 1;
  52. else
  53. return 0;
  54. }
  55. /*
  56. * EP80219/IQ31244 timer tick configuration.
  57. */
  58. static void __init iq31244_timer_init(void)
  59. {
  60. if (is_ep80219()) {
  61. /* 33.333 MHz crystal. */
  62. iop_init_time(200000000);
  63. } else {
  64. /* 33.000 MHz crystal. */
  65. iop_init_time(198000000);
  66. }
  67. }
  68. /*
  69. * IQ31244 I/O.
  70. */
  71. static struct map_desc iq31244_io_desc[] __initdata = {
  72. { /* on-board devices */
  73. .virtual = IQ31244_UART,
  74. .pfn = __phys_to_pfn(IQ31244_UART),
  75. .length = 0x00100000,
  76. .type = MT_DEVICE,
  77. },
  78. };
  79. void __init iq31244_map_io(void)
  80. {
  81. iop3xx_map_io();
  82. iotable_init(iq31244_io_desc, ARRAY_SIZE(iq31244_io_desc));
  83. }
  84. /*
  85. * EP80219/IQ31244 PCI.
  86. */
  87. static int __init
  88. ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  89. {
  90. int irq;
  91. if (slot == 0) {
  92. /* CFlash */
  93. irq = IRQ_IOP32X_XINT1;
  94. } else if (slot == 1) {
  95. /* 82551 Pro 100 */
  96. irq = IRQ_IOP32X_XINT0;
  97. } else if (slot == 2) {
  98. /* PCI-X Slot */
  99. irq = IRQ_IOP32X_XINT3;
  100. } else if (slot == 3) {
  101. /* SATA */
  102. irq = IRQ_IOP32X_XINT2;
  103. } else {
  104. printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
  105. "device PCI:%d:%d:%d\n", dev->bus->number,
  106. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  107. irq = -1;
  108. }
  109. return irq;
  110. }
  111. static struct hw_pci ep80219_pci __initdata = {
  112. .nr_controllers = 1,
  113. .ops = &iop3xx_ops,
  114. .setup = iop3xx_pci_setup,
  115. .preinit = iop3xx_pci_preinit,
  116. .map_irq = ep80219_pci_map_irq,
  117. };
  118. static int __init
  119. iq31244_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  120. {
  121. int irq;
  122. if (slot == 0) {
  123. /* CFlash */
  124. irq = IRQ_IOP32X_XINT1;
  125. } else if (slot == 1) {
  126. /* SATA */
  127. irq = IRQ_IOP32X_XINT2;
  128. } else if (slot == 2) {
  129. /* PCI-X Slot */
  130. irq = IRQ_IOP32X_XINT3;
  131. } else if (slot == 3) {
  132. /* 82546 GigE */
  133. irq = IRQ_IOP32X_XINT0;
  134. } else {
  135. printk(KERN_ERR "iq31244_pci_map_irq called for unknown "
  136. "device PCI:%d:%d:%d\n", dev->bus->number,
  137. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  138. irq = -1;
  139. }
  140. return irq;
  141. }
  142. static struct hw_pci iq31244_pci __initdata = {
  143. .nr_controllers = 1,
  144. .ops = &iop3xx_ops,
  145. .setup = iop3xx_pci_setup,
  146. .preinit = iop3xx_pci_preinit,
  147. .map_irq = iq31244_pci_map_irq,
  148. };
  149. static int __init iq31244_pci_init(void)
  150. {
  151. if (is_ep80219())
  152. pci_common_init(&ep80219_pci);
  153. else if (machine_is_iq31244()) {
  154. if (is_80219()) {
  155. printk("note: iq31244 board type has been selected\n");
  156. printk("note: to select ep80219 operation:\n");
  157. printk("\t1/ specify \"force_ep80219\" on the kernel"
  158. " command line\n");
  159. printk("\t2/ update boot loader to pass"
  160. " the ep80219 id: %d\n", MACH_TYPE_EP80219);
  161. }
  162. pci_common_init(&iq31244_pci);
  163. }
  164. return 0;
  165. }
  166. subsys_initcall(iq31244_pci_init);
  167. /*
  168. * IQ31244 machine initialisation.
  169. */
  170. static struct physmap_flash_data iq31244_flash_data = {
  171. .width = 2,
  172. };
  173. static struct resource iq31244_flash_resource = {
  174. .start = 0xf0000000,
  175. .end = 0xf07fffff,
  176. .flags = IORESOURCE_MEM,
  177. };
  178. static struct platform_device iq31244_flash_device = {
  179. .name = "physmap-flash",
  180. .id = 0,
  181. .dev = {
  182. .platform_data = &iq31244_flash_data,
  183. },
  184. .num_resources = 1,
  185. .resource = &iq31244_flash_resource,
  186. };
  187. static struct plat_serial8250_port iq31244_serial_port[] = {
  188. {
  189. .mapbase = IQ31244_UART,
  190. .membase = (char *)IQ31244_UART,
  191. .irq = IRQ_IOP32X_XINT1,
  192. .flags = UPF_SKIP_TEST,
  193. .iotype = UPIO_MEM,
  194. .regshift = 0,
  195. .uartclk = 1843200,
  196. },
  197. { },
  198. };
  199. static struct resource iq31244_uart_resource = {
  200. .start = IQ31244_UART,
  201. .end = IQ31244_UART + 7,
  202. .flags = IORESOURCE_MEM,
  203. };
  204. static struct platform_device iq31244_serial_device = {
  205. .name = "serial8250",
  206. .id = PLAT8250_DEV_PLATFORM,
  207. .dev = {
  208. .platform_data = iq31244_serial_port,
  209. },
  210. .num_resources = 1,
  211. .resource = &iq31244_uart_resource,
  212. };
  213. /*
  214. * This function will send a SHUTDOWN_COMPLETE message to the PIC
  215. * controller over I2C. We are not using the i2c subsystem since
  216. * we are going to power off and it may be removed
  217. */
  218. void ep80219_power_off(void)
  219. {
  220. /*
  221. * Send the Address byte w/ the start condition
  222. */
  223. *IOP3XX_IDBR1 = 0x60;
  224. *IOP3XX_ICR1 = 0xE9;
  225. mdelay(1);
  226. /*
  227. * Send the START_MSG byte w/ no start or stop condition
  228. */
  229. *IOP3XX_IDBR1 = 0x0F;
  230. *IOP3XX_ICR1 = 0xE8;
  231. mdelay(1);
  232. /*
  233. * Send the SHUTDOWN_COMPLETE Message ID byte w/ no start or
  234. * stop condition
  235. */
  236. *IOP3XX_IDBR1 = 0x03;
  237. *IOP3XX_ICR1 = 0xE8;
  238. mdelay(1);
  239. /*
  240. * Send an ignored byte w/ stop condition
  241. */
  242. *IOP3XX_IDBR1 = 0x00;
  243. *IOP3XX_ICR1 = 0xEA;
  244. while (1)
  245. ;
  246. }
  247. static void __init iq31244_init_machine(void)
  248. {
  249. register_iop32x_gpio();
  250. gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
  251. gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
  252. platform_device_register(&iop3xx_i2c0_device);
  253. platform_device_register(&iop3xx_i2c1_device);
  254. platform_device_register(&iq31244_flash_device);
  255. platform_device_register(&iq31244_serial_device);
  256. platform_device_register(&iop3xx_dma_0_channel);
  257. platform_device_register(&iop3xx_dma_1_channel);
  258. if (is_ep80219())
  259. pm_power_off = ep80219_power_off;
  260. if (!is_80219())
  261. platform_device_register(&iop3xx_aau_channel);
  262. }
  263. static int __init force_ep80219_setup(char *str)
  264. {
  265. force_ep80219 = 1;
  266. return 1;
  267. }
  268. __setup("force_ep80219", force_ep80219_setup);
  269. MACHINE_START(IQ31244, "Intel IQ31244")
  270. /* Maintainer: Intel Corp. */
  271. .atag_offset = 0x100,
  272. .map_io = iq31244_map_io,
  273. .init_irq = iop32x_init_irq,
  274. .init_time = iq31244_timer_init,
  275. .init_machine = iq31244_init_machine,
  276. .restart = iop3xx_restart,
  277. MACHINE_END
  278. /* There should have been an ep80219 machine identifier from the beginning.
  279. * Boot roms older than March 2007 do not know the ep80219 machine id. Pass
  280. * "force_ep80219" on the kernel command line, otherwise iq31244 operation
  281. * will be selected.
  282. */
  283. MACHINE_START(EP80219, "Intel EP80219")
  284. /* Maintainer: Intel Corp. */
  285. .atag_offset = 0x100,
  286. .nr_irqs = IOP32X_NR_IRQS,
  287. .map_io = iq31244_map_io,
  288. .init_irq = iop32x_init_irq,
  289. .init_time = iq31244_timer_init,
  290. .init_machine = iq31244_init_machine,
  291. .restart = iop3xx_restart,
  292. MACHINE_END