glantank.c 4.9 KB

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