wrt350n-v2-setup.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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/gpio.h>
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/pci.h>
  13. #include <linux/irq.h>
  14. #include <linux/delay.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/ethtool.h>
  18. #include <linux/leds.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/input.h>
  21. #include <linux/platform_data/dsa.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/pci.h>
  25. #include "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 unsigned int wrt350n_v2_mpp_modes[] __initdata = {
  97. MPP0_GPIO, /* Power LED green (0=on) */
  98. MPP1_GPIO, /* Security LED (0=on) */
  99. MPP2_GPIO, /* Internal Button (0=on) */
  100. MPP3_GPIO, /* Reset Button (0=on) */
  101. MPP4_GPIO, /* PCI int */
  102. MPP5_GPIO, /* Power LED orange (0=on) */
  103. MPP6_GPIO, /* USB LED (0=on) */
  104. MPP7_GPIO, /* Wireless LED (0=on) */
  105. MPP8_UNUSED, /* ??? */
  106. MPP9_GIGE, /* GE_RXERR */
  107. MPP10_UNUSED, /* ??? */
  108. MPP11_UNUSED, /* ??? */
  109. MPP12_GIGE, /* GE_TXD[4] */
  110. MPP13_GIGE, /* GE_TXD[5] */
  111. MPP14_GIGE, /* GE_TXD[6] */
  112. MPP15_GIGE, /* GE_TXD[7] */
  113. MPP16_GIGE, /* GE_RXD[4] */
  114. MPP17_GIGE, /* GE_RXD[5] */
  115. MPP18_GIGE, /* GE_RXD[6] */
  116. MPP19_GIGE, /* GE_RXD[7] */
  117. 0,
  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 void __init wrt350n_v2_init(void)
  180. {
  181. /*
  182. * Setup basic Orion functions. Need to be called early.
  183. */
  184. orion5x_init();
  185. orion5x_mpp_conf(wrt350n_v2_mpp_modes);
  186. /*
  187. * Configure peripherals.
  188. */
  189. orion5x_ehci0_init();
  190. orion5x_eth_init(&wrt350n_v2_eth_data);
  191. orion5x_eth_switch_init(&wrt350n_v2_switch_chip_data);
  192. orion5x_uart0_init();
  193. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  194. ORION_MBUS_DEVBUS_BOOT_ATTR,
  195. WRT350N_V2_NOR_BOOT_BASE,
  196. WRT350N_V2_NOR_BOOT_SIZE);
  197. platform_device_register(&wrt350n_v2_nor_flash);
  198. platform_device_register(&wrt350n_v2_leds);
  199. platform_device_register(&wrt350n_v2_button_device);
  200. }
  201. static int __init wrt350n_v2_pci_map_irq(const struct pci_dev *dev, u8 slot,
  202. u8 pin)
  203. {
  204. int irq;
  205. /*
  206. * Check for devices with hard-wired IRQs.
  207. */
  208. irq = orion5x_pci_map_irq(dev, slot, pin);
  209. if (irq != -1)
  210. return irq;
  211. /*
  212. * Mini-PCI slot.
  213. */
  214. if (slot == 7)
  215. return gpio_to_irq(4);
  216. return -1;
  217. }
  218. static struct hw_pci wrt350n_v2_pci __initdata = {
  219. .nr_controllers = 2,
  220. .setup = orion5x_pci_sys_setup,
  221. .scan = orion5x_pci_sys_scan_bus,
  222. .map_irq = wrt350n_v2_pci_map_irq,
  223. };
  224. static int __init wrt350n_v2_pci_init(void)
  225. {
  226. if (machine_is_wrt350n_v2())
  227. pci_common_init(&wrt350n_v2_pci);
  228. return 0;
  229. }
  230. subsys_initcall(wrt350n_v2_pci_init);
  231. MACHINE_START(WRT350N_V2, "Linksys WRT350N v2")
  232. /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
  233. .atag_offset = 0x100,
  234. .nr_irqs = ORION5X_NR_IRQS,
  235. .init_machine = wrt350n_v2_init,
  236. .map_io = orion5x_map_io,
  237. .init_early = orion5x_init_early,
  238. .init_irq = orion5x_init_irq,
  239. .init_time = orion5x_timer_init,
  240. .fixup = tag_fixup_mem32,
  241. .restart = orion5x_restart,
  242. MACHINE_END