glantank.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * arch/arm/mach-iop32x/glantank.c
  3. *
  4. * Board support code for the GLAN Tank.
  5. *
  6. * Copyright (C) 2006 Martin Michlmayr <tbm@cyrius.com>
  7. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/mm.h>
  15. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/pci.h>
  18. #include <linux/string.h>
  19. #include <linux/slab.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial_8250.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/platform_device.h>
  24. #include <asm/hardware.h>
  25. #include <asm/io.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. /*
  34. * GLAN Tank timer tick configuration.
  35. */
  36. static void __init glantank_timer_init(void)
  37. {
  38. /* 33.333 MHz crystal. */
  39. iop3xx_init_time(200000000);
  40. }
  41. static struct sys_timer glantank_timer = {
  42. .init = glantank_timer_init,
  43. .offset = iop3xx_gettimeoffset,
  44. };
  45. /*
  46. * GLAN Tank I/O.
  47. */
  48. static struct map_desc glantank_io_desc[] __initdata = {
  49. { /* on-board devices */
  50. .virtual = GLANTANK_UART,
  51. .pfn = __phys_to_pfn(GLANTANK_UART),
  52. .length = 0x00100000,
  53. .type = MT_DEVICE
  54. },
  55. };
  56. void __init glantank_map_io(void)
  57. {
  58. iop3xx_map_io();
  59. iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
  60. }
  61. /*
  62. * GLAN Tank PCI.
  63. */
  64. #define INTA IRQ_IOP32X_XINT0
  65. #define INTB IRQ_IOP32X_XINT1
  66. #define INTC IRQ_IOP32X_XINT2
  67. #define INTD IRQ_IOP32X_XINT3
  68. static inline int __init
  69. glantank_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  70. {
  71. static int pci_irq_table[][4] = {
  72. /*
  73. * PCI IDSEL/INTPIN->INTLINE
  74. * A B C D
  75. */
  76. {INTD, INTD, INTD, INTD}, /* UART (8250) */
  77. {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
  78. {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
  79. {INTC, INTC, INTC, INTC}, /* USB (NEC) */
  80. };
  81. BUG_ON(pin < 1 || pin > 4);
  82. return pci_irq_table[slot % 4][pin - 1];
  83. }
  84. static struct hw_pci glantank_pci __initdata = {
  85. .swizzle = pci_std_swizzle,
  86. .nr_controllers = 1,
  87. .setup = iop3xx_pci_setup,
  88. .preinit = iop3xx_pci_preinit,
  89. .scan = iop3xx_pci_scan_bus,
  90. .map_irq = glantank_pci_map_irq,
  91. };
  92. static int __init glantank_pci_init(void)
  93. {
  94. if (machine_is_glantank())
  95. pci_common_init(&glantank_pci);
  96. return 0;
  97. }
  98. subsys_initcall(glantank_pci_init);
  99. /*
  100. * GLAN Tank machine initialization.
  101. */
  102. static struct physmap_flash_data glantank_flash_data = {
  103. .width = 1,
  104. };
  105. static struct resource glantank_flash_resource = {
  106. .start = 0xf0000000,
  107. .end = 0xf007ffff,
  108. .flags = IORESOURCE_MEM,
  109. };
  110. static struct platform_device glantank_flash_device = {
  111. .name = "physmap-flash",
  112. .id = 0,
  113. .dev = {
  114. .platform_data = &glantank_flash_data,
  115. },
  116. .num_resources = 1,
  117. .resource = &glantank_flash_resource,
  118. };
  119. static struct plat_serial8250_port glantank_serial_port[] = {
  120. {
  121. .mapbase = GLANTANK_UART,
  122. .membase = (char *)GLANTANK_UART,
  123. .irq = IRQ_IOP32X_XINT3,
  124. .flags = UPF_SKIP_TEST,
  125. .iotype = UPIO_MEM,
  126. .regshift = 0,
  127. .uartclk = 1843200,
  128. },
  129. { },
  130. };
  131. static struct resource glantank_uart_resource = {
  132. .start = GLANTANK_UART,
  133. .end = GLANTANK_UART + 7,
  134. .flags = IORESOURCE_MEM,
  135. };
  136. static struct platform_device glantank_serial_device = {
  137. .name = "serial8250",
  138. .id = PLAT8250_DEV_PLATFORM,
  139. .dev = {
  140. .platform_data = glantank_serial_port,
  141. },
  142. .num_resources = 1,
  143. .resource = &glantank_uart_resource,
  144. };
  145. static void glantank_power_off(void)
  146. {
  147. __raw_writeb(0x01, 0xfe8d0004);
  148. while (1)
  149. ;
  150. }
  151. static void __init glantank_init_machine(void)
  152. {
  153. platform_device_register(&iop3xx_i2c0_device);
  154. platform_device_register(&iop3xx_i2c1_device);
  155. platform_device_register(&glantank_flash_device);
  156. platform_device_register(&glantank_serial_device);
  157. pm_power_off = glantank_power_off;
  158. }
  159. MACHINE_START(GLANTANK, "GLAN Tank")
  160. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  161. .phys_io = GLANTANK_UART,
  162. .io_pg_offst = ((GLANTANK_UART) >> 18) & 0xfffc,
  163. .boot_params = 0xa0000100,
  164. .map_io = glantank_map_io,
  165. .init_irq = iop32x_init_irq,
  166. .timer = &glantank_timer,
  167. .init_machine = glantank_init_machine,
  168. MACHINE_END