mach-wrt400n.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Linksys WRT400N board support
  3. *
  4. * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include "dev-ap9x-pci.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "machtypes.h"
  20. #define WRT400N_GPIO_LED_POWER 1
  21. #define WRT400N_GPIO_LED_WPS_BLUE 4
  22. #define WRT400N_GPIO_LED_WPS_AMBER 5
  23. #define WRT400N_GPIO_LED_WLAN 6
  24. #define WRT400N_GPIO_BTN_RESET 8
  25. #define WRT400N_GPIO_BTN_WLSEC 3
  26. #define WRT400N_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define WRT400N_KEYS_DEBOUNE_INTERVAL (3 * WRT400N_KEYS_POLL_INTERVAL)
  28. #define WRT400N_MAC_ADDR_OFFSET 0x120c
  29. #define WRT400N_CALDATA0_OFFSET 0x1000
  30. #define WRT400N_CALDATA1_OFFSET 0x5000
  31. static struct mtd_partition wrt400n_partitions[] = {
  32. {
  33. .name = "uboot",
  34. .offset = 0,
  35. .size = 0x030000,
  36. .mask_flags = MTD_WRITEABLE,
  37. }, {
  38. .name = "env",
  39. .offset = 0x030000,
  40. .size = 0x010000,
  41. .mask_flags = MTD_WRITEABLE,
  42. }, {
  43. .name = "linux",
  44. .offset = 0x040000,
  45. .size = 0x140000,
  46. }, {
  47. .name = "rootfs",
  48. .offset = 0x180000,
  49. .size = 0x630000,
  50. }, {
  51. .name = "nvram",
  52. .offset = 0x7b0000,
  53. .size = 0x010000,
  54. .mask_flags = MTD_WRITEABLE,
  55. }, {
  56. .name = "factory",
  57. .offset = 0x7c0000,
  58. .size = 0x010000,
  59. .mask_flags = MTD_WRITEABLE,
  60. }, {
  61. .name = "language",
  62. .offset = 0x7d0000,
  63. .size = 0x020000,
  64. .mask_flags = MTD_WRITEABLE,
  65. }, {
  66. .name = "caldata",
  67. .offset = 0x7f0000,
  68. .size = 0x010000,
  69. .mask_flags = MTD_WRITEABLE,
  70. }, {
  71. .name = "firmware",
  72. .offset = 0x040000,
  73. .size = 0x770000,
  74. }
  75. };
  76. static struct flash_platform_data wrt400n_flash_data = {
  77. .parts = wrt400n_partitions,
  78. .nr_parts = ARRAY_SIZE(wrt400n_partitions),
  79. };
  80. static struct gpio_led wrt400n_leds_gpio[] __initdata = {
  81. {
  82. .name = "wrt400n:blue:wps",
  83. .gpio = WRT400N_GPIO_LED_WPS_BLUE,
  84. .active_low = 1,
  85. }, {
  86. .name = "wrt400n:amber:wps",
  87. .gpio = WRT400N_GPIO_LED_WPS_AMBER,
  88. .active_low = 1,
  89. }, {
  90. .name = "wrt400n:blue:wlan",
  91. .gpio = WRT400N_GPIO_LED_WLAN,
  92. .active_low = 1,
  93. }, {
  94. .name = "wrt400n:blue:power",
  95. .gpio = WRT400N_GPIO_LED_POWER,
  96. .active_low = 0,
  97. .default_trigger = "default-on",
  98. }
  99. };
  100. static struct gpio_keys_button wrt400n_gpio_keys[] __initdata = {
  101. {
  102. .desc = "reset",
  103. .type = EV_KEY,
  104. .code = KEY_RESTART,
  105. .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
  106. .gpio = WRT400N_GPIO_BTN_RESET,
  107. .active_low = 1,
  108. }, {
  109. .desc = "wlsec",
  110. .type = EV_KEY,
  111. .code = KEY_WPS_BUTTON,
  112. .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
  113. .gpio = WRT400N_GPIO_BTN_WLSEC,
  114. .active_low = 1,
  115. }
  116. };
  117. static void __init wrt400n_setup(void)
  118. {
  119. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  120. u8 *mac = art + WRT400N_MAC_ADDR_OFFSET;
  121. ath79_register_mdio(0, 0x0);
  122. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  123. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  124. ath79_eth0_data.speed = SPEED_100;
  125. ath79_eth0_data.duplex = DUPLEX_FULL;
  126. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
  127. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  128. ath79_eth1_data.phy_mask = 0x10;
  129. ath79_register_eth(0);
  130. ath79_register_eth(1);
  131. ath79_register_m25p80(&wrt400n_flash_data);
  132. ath79_register_leds_gpio(-1, ARRAY_SIZE(wrt400n_leds_gpio),
  133. wrt400n_leds_gpio);
  134. ath79_register_gpio_keys_polled(-1, WRT400N_KEYS_POLL_INTERVAL,
  135. ARRAY_SIZE(wrt400n_gpio_keys),
  136. wrt400n_gpio_keys);
  137. ap94_pci_init(art + WRT400N_CALDATA0_OFFSET, NULL,
  138. art + WRT400N_CALDATA1_OFFSET, NULL);
  139. }
  140. MIPS_MACHINE(ATH79_MACH_WRT400N, "WRT400N", "Linksys WRT400N", wrt400n_setup);