glantank.c 4.7 KB

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