wrt350n-v2-setup.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. * arch/arm/mach-orion5x/wrt350n-v2-setup.c
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/pci.h>
  12. #include <linux/irq.h>
  13. #include <linux/delay.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/ethtool.h>
  17. #include <linux/leds.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <net/dsa.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/gpio.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/pci.h>
  25. #include <mach/orion5x.h>
  26. #include "common.h"
  27. #include "mpp.h"
  28. /*
  29. * LEDs attached to GPIO
  30. */
  31. static struct gpio_led wrt350n_v2_led_pins[] = {
  32. {
  33. .name = "wrt350nv2:green:power",
  34. .gpio = 0,
  35. .active_low = 1,
  36. }, {
  37. .name = "wrt350nv2:green:security",
  38. .gpio = 1,
  39. .active_low = 1,
  40. }, {
  41. .name = "wrt350nv2:orange:power",
  42. .gpio = 5,
  43. .active_low = 1,
  44. }, {
  45. .name = "wrt350nv2:green:usb",
  46. .gpio = 6,
  47. .active_low = 1,
  48. }, {
  49. .name = "wrt350nv2:green:wireless",
  50. .gpio = 7,
  51. .active_low = 1,
  52. },
  53. };
  54. static struct gpio_led_platform_data wrt350n_v2_led_data = {
  55. .leds = wrt350n_v2_led_pins,
  56. .num_leds = ARRAY_SIZE(wrt350n_v2_led_pins),
  57. };
  58. static struct platform_device wrt350n_v2_leds = {
  59. .name = "leds-gpio",
  60. .id = -1,
  61. .dev = {
  62. .platform_data = &wrt350n_v2_led_data,
  63. },
  64. };
  65. /*
  66. * Buttons attached to GPIO
  67. */
  68. static struct gpio_keys_button wrt350n_v2_buttons[] = {
  69. {
  70. .code = KEY_RESTART,
  71. .gpio = 3,
  72. .desc = "Reset Button",
  73. .active_low = 1,
  74. }, {
  75. .code = KEY_WPS_BUTTON,
  76. .gpio = 2,
  77. .desc = "WPS Button",
  78. .active_low = 1,
  79. },
  80. };
  81. static struct gpio_keys_platform_data wrt350n_v2_button_data = {
  82. .buttons = wrt350n_v2_buttons,
  83. .nbuttons = ARRAY_SIZE(wrt350n_v2_buttons),
  84. };
  85. static struct platform_device wrt350n_v2_button_device = {
  86. .name = "gpio-keys",
  87. .id = -1,
  88. .num_resources = 0,
  89. .dev = {
  90. .platform_data = &wrt350n_v2_button_data,
  91. },
  92. };
  93. /*
  94. * General setup
  95. */
  96. static struct orion5x_mpp_mode wrt350n_v2_mpp_modes[] __initdata = {
  97. { 0, MPP_GPIO }, /* Power LED green (0=on) */
  98. { 1, MPP_GPIO }, /* Security LED (0=on) */
  99. { 2, MPP_GPIO }, /* Internal Button (0=on) */
  100. { 3, MPP_GPIO }, /* Reset Button (0=on) */
  101. { 4, MPP_GPIO }, /* PCI int */
  102. { 5, MPP_GPIO }, /* Power LED orange (0=on) */
  103. { 6, MPP_GPIO }, /* USB LED (0=on) */
  104. { 7, MPP_GPIO }, /* Wireless LED (0=on) */
  105. { 8, MPP_UNUSED }, /* ??? */
  106. { 9, MPP_GIGE }, /* GE_RXERR */
  107. { 10, MPP_UNUSED }, /* ??? */
  108. { 11, MPP_UNUSED }, /* ??? */
  109. { 12, MPP_GIGE }, /* GE_TXD[4] */
  110. { 13, MPP_GIGE }, /* GE_TXD[5] */
  111. { 14, MPP_GIGE }, /* GE_TXD[6] */
  112. { 15, MPP_GIGE }, /* GE_TXD[7] */
  113. { 16, MPP_GIGE }, /* GE_RXD[4] */
  114. { 17, MPP_GIGE }, /* GE_RXD[5] */
  115. { 18, MPP_GIGE }, /* GE_RXD[6] */
  116. { 19, MPP_GIGE }, /* GE_RXD[7] */
  117. { -1 },
  118. };
  119. /*
  120. * 8M NOR flash Device bus boot chip select
  121. */
  122. #define WRT350N_V2_NOR_BOOT_BASE 0xf4000000
  123. #define WRT350N_V2_NOR_BOOT_SIZE SZ_8M
  124. static struct mtd_partition wrt350n_v2_nor_flash_partitions[] = {
  125. {
  126. .name = "kernel",
  127. .offset = 0x00000000,
  128. .size = 0x00760000,
  129. }, {
  130. .name = "rootfs",
  131. .offset = 0x001a0000,
  132. .size = 0x005c0000,
  133. }, {
  134. .name = "lang",
  135. .offset = 0x00760000,
  136. .size = 0x00040000,
  137. }, {
  138. .name = "nvram",
  139. .offset = 0x007a0000,
  140. .size = 0x00020000,
  141. }, {
  142. .name = "u-boot",
  143. .offset = 0x007c0000,
  144. .size = 0x00040000,
  145. },
  146. };
  147. static struct physmap_flash_data wrt350n_v2_nor_flash_data = {
  148. .width = 1,
  149. .parts = wrt350n_v2_nor_flash_partitions,
  150. .nr_parts = ARRAY_SIZE(wrt350n_v2_nor_flash_partitions),
  151. };
  152. static struct resource wrt350n_v2_nor_flash_resource = {
  153. .flags = IORESOURCE_MEM,
  154. .start = WRT350N_V2_NOR_BOOT_BASE,
  155. .end = WRT350N_V2_NOR_BOOT_BASE + WRT350N_V2_NOR_BOOT_SIZE - 1,
  156. };
  157. static struct platform_device wrt350n_v2_nor_flash = {
  158. .name = "physmap-flash",
  159. .id = 0,
  160. .dev = {
  161. .platform_data = &wrt350n_v2_nor_flash_data,
  162. },
  163. .num_resources = 1,
  164. .resource = &wrt350n_v2_nor_flash_resource,
  165. };
  166. static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = {
  167. .phy_addr = MV643XX_ETH_PHY_NONE,
  168. .speed = SPEED_1000,
  169. .duplex = DUPLEX_FULL,
  170. };
  171. static struct dsa_chip_data wrt350n_v2_switch_chip_data = {
  172. .port_names[0] = "lan2",
  173. .port_names[1] = "lan1",
  174. .port_names[2] = "wan",
  175. .port_names[3] = "cpu",
  176. .port_names[5] = "lan3",
  177. .port_names[7] = "lan4",
  178. };
  179. static struct dsa_platform_data wrt350n_v2_switch_plat_data = {
  180. .nr_chips = 1,
  181. .chip = &wrt350n_v2_switch_chip_data,
  182. };
  183. static void __init wrt350n_v2_init(void)
  184. {
  185. /*
  186. * Setup basic Orion functions. Need to be called early.
  187. */
  188. orion5x_init();
  189. orion5x_mpp_conf(wrt350n_v2_mpp_modes);
  190. /*
  191. * Configure peripherals.
  192. */
  193. orion5x_ehci0_init();
  194. orion5x_eth_init(&wrt350n_v2_eth_data);
  195. orion5x_eth_switch_init(&wrt350n_v2_switch_plat_data, NO_IRQ);
  196. orion5x_uart0_init();
  197. orion5x_setup_dev_boot_win(WRT350N_V2_NOR_BOOT_BASE,
  198. WRT350N_V2_NOR_BOOT_SIZE);
  199. platform_device_register(&wrt350n_v2_nor_flash);
  200. platform_device_register(&wrt350n_v2_leds);
  201. platform_device_register(&wrt350n_v2_button_device);
  202. }
  203. static int __init wrt350n_v2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  204. {
  205. int irq;
  206. /*
  207. * Check for devices with hard-wired IRQs.
  208. */
  209. irq = orion5x_pci_map_irq(dev, slot, pin);
  210. if (irq != -1)
  211. return irq;
  212. /*
  213. * Mini-PCI slot.
  214. */
  215. if (slot == 7)
  216. return gpio_to_irq(4);
  217. return -1;
  218. }
  219. static struct hw_pci wrt350n_v2_pci __initdata = {
  220. .nr_controllers = 2,
  221. .swizzle = pci_std_swizzle,
  222. .setup = orion5x_pci_sys_setup,
  223. .scan = orion5x_pci_sys_scan_bus,
  224. .map_irq = wrt350n_v2_pci_map_irq,
  225. };
  226. static int __init wrt350n_v2_pci_init(void)
  227. {
  228. if (machine_is_wrt350n_v2())
  229. pci_common_init(&wrt350n_v2_pci);
  230. return 0;
  231. }
  232. subsys_initcall(wrt350n_v2_pci_init);
  233. MACHINE_START(WRT350N_V2, "Linksys WRT350N v2")
  234. /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
  235. .boot_params = 0x00000100,
  236. .init_machine = wrt350n_v2_init,
  237. .map_io = orion5x_map_io,
  238. .init_early = orion5x_init_early,
  239. .init_irq = orion5x_init_irq,
  240. .timer = &orion5x_timer,
  241. .fixup = tag_fixup_mem32,
  242. MACHINE_END