glantank.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * arch/arm/mach-iop32x/glantank.c
  4. *
  5. * Board support code for the GLAN Tank.
  6. *
  7. * Copyright (C) 2006, 2007 Martin Michlmayr <[email protected]>
  8. * Copyright (C) 2006 Lennert Buytenhek <[email protected]>
  9. */
  10. #include <linux/mm.h>
  11. #include <linux/init.h>
  12. #include <linux/f75375s.h>
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/pm.h>
  16. #include <linux/string.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/serial_8250.h>
  19. #include <linux/mtd/physmap.h>
  20. #include <linux/i2c.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/io.h>
  23. #include <linux/gpio/machine.h>
  24. #include <asm/irq.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/pci.h>
  28. #include <asm/mach/time.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/page.h>
  31. #include "hardware.h"
  32. #include "gpio-iop32x.h"
  33. #include "irqs.h"
  34. /*
  35. * GLAN Tank timer tick configuration.
  36. */
  37. static void __init glantank_timer_init(void)
  38. {
  39. /* 33.333 MHz crystal. */
  40. iop_init_time(200000000);
  41. }
  42. /*
  43. * GLAN Tank I/O.
  44. */
  45. static struct map_desc glantank_io_desc[] __initdata = {
  46. { /* on-board devices */
  47. .virtual = GLANTANK_UART,
  48. .pfn = __phys_to_pfn(GLANTANK_UART),
  49. .length = 0x00100000,
  50. .type = MT_DEVICE
  51. },
  52. };
  53. void __init glantank_map_io(void)
  54. {
  55. iop3xx_map_io();
  56. iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
  57. }
  58. /*
  59. * GLAN Tank PCI.
  60. */
  61. #define INTA IRQ_IOP32X_XINT0
  62. #define INTB IRQ_IOP32X_XINT1
  63. #define INTC IRQ_IOP32X_XINT2
  64. #define INTD IRQ_IOP32X_XINT3
  65. static int __init
  66. glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  67. {
  68. static int pci_irq_table[][4] = {
  69. /*
  70. * PCI IDSEL/INTPIN->INTLINE
  71. * A B C D
  72. */
  73. {INTD, INTD, INTD, INTD}, /* UART (8250) */
  74. {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
  75. {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
  76. {INTC, INTC, INTC, INTC}, /* USB (NEC) */
  77. };
  78. BUG_ON(pin < 1 || pin > 4);
  79. return pci_irq_table[slot % 4][pin - 1];
  80. }
  81. static struct hw_pci glantank_pci __initdata = {
  82. .nr_controllers = 1,
  83. .ops = &iop3xx_ops,
  84. .setup = iop3xx_pci_setup,
  85. .preinit = iop3xx_pci_preinit,
  86. .map_irq = glantank_pci_map_irq,
  87. };
  88. static int __init glantank_pci_init(void)
  89. {
  90. if (machine_is_glantank())
  91. pci_common_init(&glantank_pci);
  92. return 0;
  93. }
  94. subsys_initcall(glantank_pci_init);
  95. /*
  96. * GLAN Tank machine initialization.
  97. */
  98. static struct physmap_flash_data glantank_flash_data = {
  99. .width = 2,
  100. };
  101. static struct resource glantank_flash_resource = {
  102. .start = 0xf0000000,
  103. .end = 0xf007ffff,
  104. .flags = IORESOURCE_MEM,
  105. };
  106. static struct platform_device glantank_flash_device = {
  107. .name = "physmap-flash",
  108. .id = 0,
  109. .dev = {
  110. .platform_data = &glantank_flash_data,
  111. },
  112. .num_resources = 1,
  113. .resource = &glantank_flash_resource,
  114. };
  115. static struct plat_serial8250_port glantank_serial_port[] = {
  116. {
  117. .mapbase = GLANTANK_UART,
  118. .membase = (char *)GLANTANK_UART,
  119. .irq = IRQ_IOP32X_XINT3,
  120. .flags = UPF_SKIP_TEST,
  121. .iotype = UPIO_MEM,
  122. .regshift = 0,
  123. .uartclk = 1843200,
  124. },
  125. { },
  126. };
  127. static struct resource glantank_uart_resource = {
  128. .start = GLANTANK_UART,
  129. .end = GLANTANK_UART + 7,
  130. .flags = IORESOURCE_MEM,
  131. };
  132. static struct platform_device glantank_serial_device = {
  133. .name = "serial8250",
  134. .id = PLAT8250_DEV_PLATFORM,
  135. .dev = {
  136. .platform_data = glantank_serial_port,
  137. },
  138. .num_resources = 1,
  139. .resource = &glantank_uart_resource,
  140. };
  141. static struct f75375s_platform_data glantank_f75375s = {
  142. .pwm = { 255, 255 },
  143. .pwm_enable = { 0, 0 },
  144. };
  145. static struct i2c_board_info __initdata glantank_i2c_devices[] = {
  146. {
  147. I2C_BOARD_INFO("rs5c372a", 0x32),
  148. },
  149. {
  150. I2C_BOARD_INFO("f75375", 0x2e),
  151. .platform_data = &glantank_f75375s,
  152. },
  153. };
  154. static void glantank_power_off(void)
  155. {
  156. __raw_writeb(0x01, IOMEM(0xfe8d0004));
  157. while (1)
  158. ;
  159. }
  160. static void __init glantank_init_machine(void)
  161. {
  162. register_iop32x_gpio();
  163. gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
  164. gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
  165. platform_device_register(&iop3xx_i2c0_device);
  166. platform_device_register(&iop3xx_i2c1_device);
  167. platform_device_register(&glantank_flash_device);
  168. platform_device_register(&glantank_serial_device);
  169. platform_device_register(&iop3xx_dma_0_channel);
  170. platform_device_register(&iop3xx_dma_1_channel);
  171. i2c_register_board_info(0, glantank_i2c_devices,
  172. ARRAY_SIZE(glantank_i2c_devices));
  173. pm_power_off = glantank_power_off;
  174. }
  175. MACHINE_START(GLANTANK, "GLAN Tank")
  176. /* Maintainer: Lennert Buytenhek <[email protected]> */
  177. .atag_offset = 0x100,
  178. .nr_irqs = IOP32X_NR_IRQS,
  179. .map_io = glantank_map_io,
  180. .init_irq = iop32x_init_irq,
  181. .init_time = glantank_timer_init,
  182. .init_machine = glantank_init_machine,
  183. .restart = iop3xx_restart,
  184. MACHINE_END