iq80321.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * arch/arm/mach-iop32x/iq80321.c
  4. *
  5. * Board support code for the Intel IQ80321 platform.
  6. *
  7. * Author: Rory Bolt <[email protected]>
  8. * Copyright (C) 2002 Rory Bolt
  9. * Copyright (C) 2004 Intel Corp.
  10. */
  11. #include <linux/mm.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/string.h>
  16. #include <linux/serial_core.h>
  17. #include <linux/serial_8250.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/gpio/machine.h>
  22. #include <asm/irq.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/pci.h>
  26. #include <asm/mach/time.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/page.h>
  29. #include "hardware.h"
  30. #include "irqs.h"
  31. #include "gpio-iop32x.h"
  32. /*
  33. * IQ80321 timer tick configuration.
  34. */
  35. static void __init iq80321_timer_init(void)
  36. {
  37. /* 33.333 MHz crystal. */
  38. iop_init_time(200000000);
  39. }
  40. /*
  41. * IQ80321 I/O.
  42. */
  43. static struct map_desc iq80321_io_desc[] __initdata = {
  44. { /* on-board devices */
  45. .virtual = IQ80321_UART,
  46. .pfn = __phys_to_pfn(IQ80321_UART),
  47. .length = 0x00100000,
  48. .type = MT_DEVICE,
  49. },
  50. };
  51. void __init iq80321_map_io(void)
  52. {
  53. iop3xx_map_io();
  54. iotable_init(iq80321_io_desc, ARRAY_SIZE(iq80321_io_desc));
  55. }
  56. /*
  57. * IQ80321 PCI.
  58. */
  59. static int __init
  60. iq80321_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  61. {
  62. int irq;
  63. if ((slot == 2 || slot == 6) && pin == 1) {
  64. /* PCI-X Slot INTA */
  65. irq = IRQ_IOP32X_XINT2;
  66. } else if ((slot == 2 || slot == 6) && pin == 2) {
  67. /* PCI-X Slot INTA */
  68. irq = IRQ_IOP32X_XINT3;
  69. } else if ((slot == 2 || slot == 6) && pin == 3) {
  70. /* PCI-X Slot INTA */
  71. irq = IRQ_IOP32X_XINT0;
  72. } else if ((slot == 2 || slot == 6) && pin == 4) {
  73. /* PCI-X Slot INTA */
  74. irq = IRQ_IOP32X_XINT1;
  75. } else if (slot == 4 || slot == 8) {
  76. /* Gig-E */
  77. irq = IRQ_IOP32X_XINT0;
  78. } else {
  79. printk(KERN_ERR "iq80321_pci_map_irq() called for unknown "
  80. "device PCI:%d:%d:%d\n", dev->bus->number,
  81. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  82. irq = -1;
  83. }
  84. return irq;
  85. }
  86. static struct hw_pci iq80321_pci __initdata = {
  87. .nr_controllers = 1,
  88. .ops = &iop3xx_ops,
  89. .setup = iop3xx_pci_setup,
  90. .preinit = iop3xx_pci_preinit_cond,
  91. .map_irq = iq80321_pci_map_irq,
  92. };
  93. static int __init iq80321_pci_init(void)
  94. {
  95. if ((iop3xx_get_init_atu() == IOP3XX_INIT_ATU_ENABLE) &&
  96. machine_is_iq80321())
  97. pci_common_init(&iq80321_pci);
  98. return 0;
  99. }
  100. subsys_initcall(iq80321_pci_init);
  101. /*
  102. * IQ80321 machine initialisation.
  103. */
  104. static struct physmap_flash_data iq80321_flash_data = {
  105. .width = 1,
  106. };
  107. static struct resource iq80321_flash_resource = {
  108. .start = 0xf0000000,
  109. .end = 0xf07fffff,
  110. .flags = IORESOURCE_MEM,
  111. };
  112. static struct platform_device iq80321_flash_device = {
  113. .name = "physmap-flash",
  114. .id = 0,
  115. .dev = {
  116. .platform_data = &iq80321_flash_data,
  117. },
  118. .num_resources = 1,
  119. .resource = &iq80321_flash_resource,
  120. };
  121. static struct plat_serial8250_port iq80321_serial_port[] = {
  122. {
  123. .mapbase = IQ80321_UART,
  124. .membase = (char *)IQ80321_UART,
  125. .irq = IRQ_IOP32X_XINT1,
  126. .flags = UPF_SKIP_TEST,
  127. .iotype = UPIO_MEM,
  128. .regshift = 0,
  129. .uartclk = 1843200,
  130. },
  131. { },
  132. };
  133. static struct resource iq80321_uart_resource = {
  134. .start = IQ80321_UART,
  135. .end = IQ80321_UART + 7,
  136. .flags = IORESOURCE_MEM,
  137. };
  138. static struct platform_device iq80321_serial_device = {
  139. .name = "serial8250",
  140. .id = PLAT8250_DEV_PLATFORM,
  141. .dev = {
  142. .platform_data = iq80321_serial_port,
  143. },
  144. .num_resources = 1,
  145. .resource = &iq80321_uart_resource,
  146. };
  147. static void __init iq80321_init_machine(void)
  148. {
  149. register_iop32x_gpio();
  150. gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
  151. gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
  152. platform_device_register(&iop3xx_i2c0_device);
  153. platform_device_register(&iop3xx_i2c1_device);
  154. platform_device_register(&iq80321_flash_device);
  155. platform_device_register(&iq80321_serial_device);
  156. platform_device_register(&iop3xx_dma_0_channel);
  157. platform_device_register(&iop3xx_dma_1_channel);
  158. platform_device_register(&iop3xx_aau_channel);
  159. }
  160. MACHINE_START(IQ80321, "Intel IQ80321")
  161. /* Maintainer: Intel Corp. */
  162. .atag_offset = 0x100,
  163. .nr_irqs = IOP32X_NR_IRQS,
  164. .map_io = iq80321_map_io,
  165. .init_irq = iop32x_init_irq,
  166. .init_time = iq80321_timer_init,
  167. .init_machine = iq80321_init_machine,
  168. .restart = iop3xx_restart,
  169. MACHINE_END