devices.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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/regs-wan.h>
  23. #include <mach/regs-lan.h>
  24. #include <mach/regs-hpna.h>
  25. #include <mach/regs-switch.h>
  26. #include <mach/regs-misc.h>
  27. /* --------------------------------------------------------------------
  28. * Ethernet
  29. * -------------------------------------------------------------------- */
  30. static u64 eth_dmamask = 0xffffffffUL;
  31. static struct resource ks8695_wan_resources[] = {
  32. [0] = {
  33. .start = KS8695_WAN_PA,
  34. .end = KS8695_WAN_PA + 0x00ff,
  35. .flags = IORESOURCE_MEM,
  36. },
  37. [1] = {
  38. .name = "WAN RX",
  39. .start = KS8695_IRQ_WAN_RX_STATUS,
  40. .end = KS8695_IRQ_WAN_RX_STATUS,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. [2] = {
  44. .name = "WAN TX",
  45. .start = KS8695_IRQ_WAN_TX_STATUS,
  46. .end = KS8695_IRQ_WAN_TX_STATUS,
  47. .flags = IORESOURCE_IRQ,
  48. },
  49. [3] = {
  50. .name = "WAN Link",
  51. .start = KS8695_IRQ_WAN_LINK,
  52. .end = KS8695_IRQ_WAN_LINK,
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. [4] = {
  56. .name = "WAN PHY",
  57. .start = KS8695_MISC_PA,
  58. .end = KS8695_MISC_PA + 0x1f,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. };
  62. static struct platform_device ks8695_wan_device = {
  63. .name = "ks8695_ether",
  64. .id = 0,
  65. .dev = {
  66. .dma_mask = &eth_dmamask,
  67. .coherent_dma_mask = 0xffffffff,
  68. },
  69. .resource = ks8695_wan_resources,
  70. .num_resources = ARRAY_SIZE(ks8695_wan_resources),
  71. };
  72. static struct resource ks8695_lan_resources[] = {
  73. [0] = {
  74. .start = KS8695_LAN_PA,
  75. .end = KS8695_LAN_PA + 0x00ff,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .name = "LAN RX",
  80. .start = KS8695_IRQ_LAN_RX_STATUS,
  81. .end = KS8695_IRQ_LAN_RX_STATUS,
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. [2] = {
  85. .name = "LAN TX",
  86. .start = KS8695_IRQ_LAN_TX_STATUS,
  87. .end = KS8695_IRQ_LAN_TX_STATUS,
  88. .flags = IORESOURCE_IRQ,
  89. },
  90. [3] = {
  91. .name = "LAN SWITCH",
  92. .start = KS8695_SWITCH_PA,
  93. .end = KS8695_SWITCH_PA + 0x4f,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. };
  97. static struct platform_device ks8695_lan_device = {
  98. .name = "ks8695_ether",
  99. .id = 1,
  100. .dev = {
  101. .dma_mask = &eth_dmamask,
  102. .coherent_dma_mask = 0xffffffff,
  103. },
  104. .resource = ks8695_lan_resources,
  105. .num_resources = ARRAY_SIZE(ks8695_lan_resources),
  106. };
  107. static struct resource ks8695_hpna_resources[] = {
  108. [0] = {
  109. .start = KS8695_HPNA_PA,
  110. .end = KS8695_HPNA_PA + 0x00ff,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. [1] = {
  114. .name = "HPNA RX",
  115. .start = KS8695_IRQ_HPNA_RX_STATUS,
  116. .end = KS8695_IRQ_HPNA_RX_STATUS,
  117. .flags = IORESOURCE_IRQ,
  118. },
  119. [2] = {
  120. .name = "HPNA TX",
  121. .start = KS8695_IRQ_HPNA_TX_STATUS,
  122. .end = KS8695_IRQ_HPNA_TX_STATUS,
  123. .flags = IORESOURCE_IRQ,
  124. },
  125. };
  126. static struct platform_device ks8695_hpna_device = {
  127. .name = "ks8695_ether",
  128. .id = 2,
  129. .dev = {
  130. .dma_mask = &eth_dmamask,
  131. .coherent_dma_mask = 0xffffffff,
  132. },
  133. .resource = ks8695_hpna_resources,
  134. .num_resources = ARRAY_SIZE(ks8695_hpna_resources),
  135. };
  136. void __init ks8695_add_device_wan(void)
  137. {
  138. platform_device_register(&ks8695_wan_device);
  139. }
  140. void __init ks8695_add_device_lan(void)
  141. {
  142. platform_device_register(&ks8695_lan_device);
  143. }
  144. void __init ks8696_add_device_hpna(void)
  145. {
  146. platform_device_register(&ks8695_hpna_device);
  147. }
  148. /* --------------------------------------------------------------------
  149. * Watchdog
  150. * -------------------------------------------------------------------- */
  151. static struct platform_device ks8695_wdt_device = {
  152. .name = "ks8695_wdt",
  153. .id = -1,
  154. .num_resources = 0,
  155. };
  156. static void __init ks8695_add_device_watchdog(void)
  157. {
  158. platform_device_register(&ks8695_wdt_device);
  159. }
  160. /* --------------------------------------------------------------------
  161. * LEDs
  162. * -------------------------------------------------------------------- */
  163. #if defined(CONFIG_LEDS)
  164. short ks8695_leds_cpu = -1;
  165. short ks8695_leds_timer = -1;
  166. void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
  167. {
  168. /* Enable GPIO to access the LEDs */
  169. gpio_direction_output(cpu_led, 1);
  170. gpio_direction_output(timer_led, 1);
  171. ks8695_leds_cpu = cpu_led;
  172. ks8695_leds_timer = timer_led;
  173. }
  174. #else
  175. void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
  176. #endif
  177. /* -------------------------------------------------------------------- */
  178. /*
  179. * These devices are always present and don't need any board-specific
  180. * setup.
  181. */
  182. static int __init ks8695_add_standard_devices(void)
  183. {
  184. ks8695_add_device_watchdog();
  185. return 0;
  186. }
  187. arch_initcall(ks8695_add_standard_devices);