board-og.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * board-og.c -- support for the OpenGear KS8695 based boards.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/types.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/init.h>
  12. #include <linux/delay.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/gpio.h>
  16. #include <linux/irq.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/devices.h>
  21. #include <mach/regs-gpio.h>
  22. #include <mach/gpio-ks8695.h>
  23. #include "generic.h"
  24. static int og_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  25. {
  26. if (machine_is_im4004() && (slot == 8))
  27. return KS8695_IRQ_EXTERN1;
  28. return KS8695_IRQ_EXTERN0;
  29. }
  30. static struct ks8695_pci_cfg __initdata og_pci = {
  31. .mode = KS8695_MODE_PCI,
  32. .map_irq = og_pci_map_irq,
  33. };
  34. static void __init og_register_pci(void)
  35. {
  36. /* Initialize the GPIO lines for interrupt mode */
  37. ks8695_gpio_interrupt(KS8695_GPIO_0, IRQ_TYPE_LEVEL_LOW);
  38. /* Cardbus Slot */
  39. if (machine_is_im4004())
  40. ks8695_gpio_interrupt(KS8695_GPIO_1, IRQ_TYPE_LEVEL_LOW);
  41. ks8695_init_pci(&og_pci);
  42. }
  43. /*
  44. * The PCI bus reset is driven by a dedicated GPIO line. Toggle it here
  45. * and bring the PCI bus out of reset.
  46. */
  47. static void __init og_pci_bus_reset(void)
  48. {
  49. unsigned int rstline = 1;
  50. /* Some boards use a different GPIO as the PCI reset line */
  51. if (machine_is_im4004())
  52. rstline = 2;
  53. else if (machine_is_im42xx())
  54. rstline = 0;
  55. gpio_request(rstline, "PCI reset");
  56. gpio_direction_output(rstline, 0);
  57. /* Drive a reset on the PCI reset line */
  58. gpio_set_value(rstline, 1);
  59. gpio_set_value(rstline, 0);
  60. mdelay(100);
  61. gpio_set_value(rstline, 1);
  62. mdelay(100);
  63. }
  64. /*
  65. * Direct connect serial ports (non-PCI that is).
  66. */
  67. #define S8250_PHYS 0x03800000
  68. #define S8250_VIRT 0xf4000000
  69. #define S8250_SIZE 0x00100000
  70. static struct __initdata map_desc og_io_desc[] = {
  71. {
  72. .virtual = S8250_VIRT,
  73. .pfn = __phys_to_pfn(S8250_PHYS),
  74. .length = S8250_SIZE,
  75. .type = MT_DEVICE,
  76. }
  77. };
  78. static struct resource og_uart_resources[] = {
  79. {
  80. .start = S8250_VIRT,
  81. .end = S8250_VIRT + S8250_SIZE,
  82. .flags = IORESOURCE_MEM
  83. },
  84. };
  85. static struct plat_serial8250_port og_uart_data[] = {
  86. {
  87. .mapbase = S8250_VIRT,
  88. .membase = (char *) S8250_VIRT,
  89. .irq = 3,
  90. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  91. .iotype = UPIO_MEM,
  92. .regshift = 2,
  93. .uartclk = 115200 * 16,
  94. },
  95. { },
  96. };
  97. static struct platform_device og_uart = {
  98. .name = "serial8250",
  99. .id = 0,
  100. .dev.platform_data = og_uart_data,
  101. .num_resources = 1,
  102. .resource = og_uart_resources
  103. };
  104. static struct platform_device *og_devices[] __initdata = {
  105. &og_uart
  106. };
  107. static void __init og_init(void)
  108. {
  109. ks8695_register_gpios();
  110. if (machine_is_cm4002()) {
  111. ks8695_gpio_interrupt(KS8695_GPIO_1, IRQ_TYPE_LEVEL_HIGH);
  112. iotable_init(og_io_desc, ARRAY_SIZE(og_io_desc));
  113. platform_add_devices(og_devices, ARRAY_SIZE(og_devices));
  114. } else {
  115. og_pci_bus_reset();
  116. og_register_pci();
  117. }
  118. ks8695_add_device_lan();
  119. ks8695_add_device_wan();
  120. }
  121. #ifdef CONFIG_MACH_CM4002
  122. MACHINE_START(CM4002, "OpenGear/CM4002")
  123. /* OpenGear Inc. */
  124. .atag_offset = 0x100,
  125. .map_io = ks8695_map_io,
  126. .init_irq = ks8695_init_irq,
  127. .init_machine = og_init,
  128. .timer = &ks8695_timer,
  129. .restart = ks8695_restart,
  130. MACHINE_END
  131. #endif
  132. #ifdef CONFIG_MACH_CM4008
  133. MACHINE_START(CM4008, "OpenGear/CM4008")
  134. /* OpenGear Inc. */
  135. .atag_offset = 0x100,
  136. .map_io = ks8695_map_io,
  137. .init_irq = ks8695_init_irq,
  138. .init_machine = og_init,
  139. .timer = &ks8695_timer,
  140. .restart = ks8695_restart,
  141. MACHINE_END
  142. #endif
  143. #ifdef CONFIG_MACH_CM41xx
  144. MACHINE_START(CM41XX, "OpenGear/CM41xx")
  145. /* OpenGear Inc. */
  146. .atag_offset = 0x100,
  147. .map_io = ks8695_map_io,
  148. .init_irq = ks8695_init_irq,
  149. .init_machine = og_init,
  150. .timer = &ks8695_timer,
  151. .restart = ks8695_restart,
  152. MACHINE_END
  153. #endif
  154. #ifdef CONFIG_MACH_IM4004
  155. MACHINE_START(IM4004, "OpenGear/IM4004")
  156. /* OpenGear Inc. */
  157. .atag_offset = 0x100,
  158. .map_io = ks8695_map_io,
  159. .init_irq = ks8695_init_irq,
  160. .init_machine = og_init,
  161. .timer = &ks8695_timer,
  162. .restart = ks8695_restart,
  163. MACHINE_END
  164. #endif
  165. #ifdef CONFIG_MACH_IM42xx
  166. MACHINE_START(IM42XX, "OpenGear/IM42xx")
  167. /* OpenGear Inc. */
  168. .atag_offset = 0x100,
  169. .map_io = ks8695_map_io,
  170. .init_irq = ks8695_init_irq,
  171. .init_machine = og_init,
  172. .timer = &ks8695_timer,
  173. .restart = ks8695_restart,
  174. MACHINE_END
  175. #endif