board-og.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 "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. if (IS_ENABLED(CONFIG_PCI))
  42. ks8695_init_pci(&og_pci);
  43. }
  44. /*
  45. * The PCI bus reset is driven by a dedicated GPIO line. Toggle it here
  46. * and bring the PCI bus out of reset.
  47. */
  48. static void __init og_pci_bus_reset(void)
  49. {
  50. unsigned int rstline = 1;
  51. /* Some boards use a different GPIO as the PCI reset line */
  52. if (machine_is_im4004())
  53. rstline = 2;
  54. else if (machine_is_im42xx())
  55. rstline = 0;
  56. gpio_request(rstline, "PCI reset");
  57. gpio_direction_output(rstline, 0);
  58. /* Drive a reset on the PCI reset line */
  59. gpio_set_value(rstline, 1);
  60. gpio_set_value(rstline, 0);
  61. mdelay(100);
  62. gpio_set_value(rstline, 1);
  63. mdelay(100);
  64. }
  65. /*
  66. * Direct connect serial ports (non-PCI that is).
  67. */
  68. #define S8250_PHYS 0x03800000
  69. #define S8250_VIRT 0xf4000000
  70. #define S8250_SIZE 0x00100000
  71. static struct map_desc og_io_desc[] __initdata = {
  72. {
  73. .virtual = S8250_VIRT,
  74. .pfn = __phys_to_pfn(S8250_PHYS),
  75. .length = S8250_SIZE,
  76. .type = MT_DEVICE,
  77. }
  78. };
  79. static struct resource og_uart_resources[] = {
  80. {
  81. .start = S8250_VIRT,
  82. .end = S8250_VIRT + S8250_SIZE,
  83. .flags = IORESOURCE_MEM
  84. },
  85. };
  86. static struct plat_serial8250_port og_uart_data[] = {
  87. {
  88. .mapbase = S8250_VIRT,
  89. .membase = (char *) S8250_VIRT,
  90. .irq = 3,
  91. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  92. .iotype = UPIO_MEM,
  93. .regshift = 2,
  94. .uartclk = 115200 * 16,
  95. },
  96. { },
  97. };
  98. static struct platform_device og_uart = {
  99. .name = "serial8250",
  100. .id = 0,
  101. .dev.platform_data = og_uart_data,
  102. .num_resources = 1,
  103. .resource = og_uart_resources
  104. };
  105. static struct platform_device *og_devices[] __initdata = {
  106. &og_uart
  107. };
  108. static void __init og_init(void)
  109. {
  110. ks8695_register_gpios();
  111. if (machine_is_cm4002()) {
  112. ks8695_gpio_interrupt(KS8695_GPIO_1, IRQ_TYPE_LEVEL_HIGH);
  113. iotable_init(og_io_desc, ARRAY_SIZE(og_io_desc));
  114. platform_add_devices(og_devices, ARRAY_SIZE(og_devices));
  115. } else {
  116. og_pci_bus_reset();
  117. og_register_pci();
  118. }
  119. ks8695_add_device_lan();
  120. ks8695_add_device_wan();
  121. }
  122. #ifdef CONFIG_MACH_CM4002
  123. MACHINE_START(CM4002, "OpenGear/CM4002")
  124. /* OpenGear Inc. */
  125. .atag_offset = 0x100,
  126. .map_io = ks8695_map_io,
  127. .init_irq = ks8695_init_irq,
  128. .init_machine = og_init,
  129. .init_time = ks8695_timer_init,
  130. .restart = ks8695_restart,
  131. MACHINE_END
  132. #endif
  133. #ifdef CONFIG_MACH_CM4008
  134. MACHINE_START(CM4008, "OpenGear/CM4008")
  135. /* OpenGear Inc. */
  136. .atag_offset = 0x100,
  137. .map_io = ks8695_map_io,
  138. .init_irq = ks8695_init_irq,
  139. .init_machine = og_init,
  140. .init_time = ks8695_timer_init,
  141. .restart = ks8695_restart,
  142. MACHINE_END
  143. #endif
  144. #ifdef CONFIG_MACH_CM41xx
  145. MACHINE_START(CM41XX, "OpenGear/CM41xx")
  146. /* OpenGear Inc. */
  147. .atag_offset = 0x100,
  148. .map_io = ks8695_map_io,
  149. .init_irq = ks8695_init_irq,
  150. .init_machine = og_init,
  151. .init_time = ks8695_timer_init,
  152. .restart = ks8695_restart,
  153. MACHINE_END
  154. #endif
  155. #ifdef CONFIG_MACH_IM4004
  156. MACHINE_START(IM4004, "OpenGear/IM4004")
  157. /* OpenGear Inc. */
  158. .atag_offset = 0x100,
  159. .map_io = ks8695_map_io,
  160. .init_irq = ks8695_init_irq,
  161. .init_machine = og_init,
  162. .init_time = ks8695_timer_init,
  163. .restart = ks8695_restart,
  164. MACHINE_END
  165. #endif
  166. #ifdef CONFIG_MACH_IM42xx
  167. MACHINE_START(IM42XX, "OpenGear/IM42xx")
  168. /* OpenGear Inc. */
  169. .atag_offset = 0x100,
  170. .map_io = ks8695_map_io,
  171. .init_irq = ks8695_init_irq,
  172. .init_machine = og_init,
  173. .init_time = ks8695_timer_init,
  174. .restart = ks8695_restart,
  175. MACHINE_END
  176. #endif