devices.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * arch/arm/mach-ks8695/devices.c
  3. *
  4. * Copyright (C) 2006 Andrew Victor
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/map.h>
  21. #include <linux/platform_device.h>
  22. #include <mach/irqs.h>
  23. #include <mach/regs-wan.h>
  24. #include <mach/regs-lan.h>
  25. #include <mach/regs-hpna.h>
  26. #include <mach/regs-switch.h>
  27. #include <mach/regs-misc.h>
  28. /* --------------------------------------------------------------------
  29. * Ethernet
  30. * -------------------------------------------------------------------- */
  31. static u64 eth_dmamask = 0xffffffffUL;
  32. static struct resource ks8695_wan_resources[] = {
  33. [0] = {
  34. .start = KS8695_WAN_PA,
  35. .end = KS8695_WAN_PA + 0x00ff,
  36. .flags = IORESOURCE_MEM,
  37. },
  38. [1] = {
  39. .name = "WAN RX",
  40. .start = KS8695_IRQ_WAN_RX_STATUS,
  41. .end = KS8695_IRQ_WAN_RX_STATUS,
  42. .flags = IORESOURCE_IRQ,
  43. },
  44. [2] = {
  45. .name = "WAN TX",
  46. .start = KS8695_IRQ_WAN_TX_STATUS,
  47. .end = KS8695_IRQ_WAN_TX_STATUS,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. [3] = {
  51. .name = "WAN Link",
  52. .start = KS8695_IRQ_WAN_LINK,
  53. .end = KS8695_IRQ_WAN_LINK,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. [4] = {
  57. .name = "WAN PHY",
  58. .start = KS8695_MISC_PA,
  59. .end = KS8695_MISC_PA + 0x1f,
  60. .flags = IORESOURCE_MEM,
  61. },
  62. };
  63. static struct platform_device ks8695_wan_device = {
  64. .name = "ks8695_ether",
  65. .id = 0,
  66. .dev = {
  67. .dma_mask = &eth_dmamask,
  68. .coherent_dma_mask = 0xffffffff,
  69. },
  70. .resource = ks8695_wan_resources,
  71. .num_resources = ARRAY_SIZE(ks8695_wan_resources),
  72. };
  73. static struct resource ks8695_lan_resources[] = {
  74. [0] = {
  75. .start = KS8695_LAN_PA,
  76. .end = KS8695_LAN_PA + 0x00ff,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. [1] = {
  80. .name = "LAN RX",
  81. .start = KS8695_IRQ_LAN_RX_STATUS,
  82. .end = KS8695_IRQ_LAN_RX_STATUS,
  83. .flags = IORESOURCE_IRQ,
  84. },
  85. [2] = {
  86. .name = "LAN TX",
  87. .start = KS8695_IRQ_LAN_TX_STATUS,
  88. .end = KS8695_IRQ_LAN_TX_STATUS,
  89. .flags = IORESOURCE_IRQ,
  90. },
  91. [3] = {
  92. .name = "LAN SWITCH",
  93. .start = KS8695_SWITCH_PA,
  94. .end = KS8695_SWITCH_PA + 0x4f,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. };
  98. static struct platform_device ks8695_lan_device = {
  99. .name = "ks8695_ether",
  100. .id = 1,
  101. .dev = {
  102. .dma_mask = &eth_dmamask,
  103. .coherent_dma_mask = 0xffffffff,
  104. },
  105. .resource = ks8695_lan_resources,
  106. .num_resources = ARRAY_SIZE(ks8695_lan_resources),
  107. };
  108. static struct resource ks8695_hpna_resources[] = {
  109. [0] = {
  110. .start = KS8695_HPNA_PA,
  111. .end = KS8695_HPNA_PA + 0x00ff,
  112. .flags = IORESOURCE_MEM,
  113. },
  114. [1] = {
  115. .name = "HPNA RX",
  116. .start = KS8695_IRQ_HPNA_RX_STATUS,
  117. .end = KS8695_IRQ_HPNA_RX_STATUS,
  118. .flags = IORESOURCE_IRQ,
  119. },
  120. [2] = {
  121. .name = "HPNA TX",
  122. .start = KS8695_IRQ_HPNA_TX_STATUS,
  123. .end = KS8695_IRQ_HPNA_TX_STATUS,
  124. .flags = IORESOURCE_IRQ,
  125. },
  126. };
  127. static struct platform_device ks8695_hpna_device = {
  128. .name = "ks8695_ether",
  129. .id = 2,
  130. .dev = {
  131. .dma_mask = &eth_dmamask,
  132. .coherent_dma_mask = 0xffffffff,
  133. },
  134. .resource = ks8695_hpna_resources,
  135. .num_resources = ARRAY_SIZE(ks8695_hpna_resources),
  136. };
  137. void __init ks8695_add_device_wan(void)
  138. {
  139. platform_device_register(&ks8695_wan_device);
  140. }
  141. void __init ks8695_add_device_lan(void)
  142. {
  143. platform_device_register(&ks8695_lan_device);
  144. }
  145. void __init ks8696_add_device_hpna(void)
  146. {
  147. platform_device_register(&ks8695_hpna_device);
  148. }
  149. /* --------------------------------------------------------------------
  150. * Watchdog
  151. * -------------------------------------------------------------------- */
  152. static struct platform_device ks8695_wdt_device = {
  153. .name = "ks8695_wdt",
  154. .id = -1,
  155. .num_resources = 0,
  156. };
  157. static void __init ks8695_add_device_watchdog(void)
  158. {
  159. platform_device_register(&ks8695_wdt_device);
  160. }
  161. /* --------------------------------------------------------------------
  162. * LEDs
  163. * -------------------------------------------------------------------- */
  164. #if defined(CONFIG_LEDS)
  165. short ks8695_leds_cpu = -1;
  166. short ks8695_leds_timer = -1;
  167. void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
  168. {
  169. /* Enable GPIO to access the LEDs */
  170. gpio_direction_output(cpu_led, 1);
  171. gpio_direction_output(timer_led, 1);
  172. ks8695_leds_cpu = cpu_led;
  173. ks8695_leds_timer = timer_led;
  174. }
  175. #else
  176. void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
  177. #endif
  178. /* -------------------------------------------------------------------- */
  179. /*
  180. * These devices are always present and don't need any board-specific
  181. * setup.
  182. */
  183. static int __init ks8695_add_standard_devices(void)
  184. {
  185. ks8695_add_device_watchdog();
  186. return 0;
  187. }
  188. arch_initcall(ks8695_add_standard_devices);