mach-wnr2000.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * NETGEAR WNR2000 board support
  3. *
  4. * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <asm/mach-ath79/ath79.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 "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define WNR2000_GPIO_LED_PWR_GREEN 14
  22. #define WNR2000_GPIO_LED_PWR_AMBER 7
  23. #define WNR2000_GPIO_LED_WPS 4
  24. #define WNR2000_GPIO_LED_WLAN 6
  25. #define WNR2000_GPIO_BTN_RESET 21
  26. #define WNR2000_GPIO_BTN_WPS 8
  27. #define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL)
  29. static struct mtd_partition wnr2000_partitions[] = {
  30. {
  31. .name = "u-boot",
  32. .offset = 0,
  33. .size = 0x040000,
  34. .mask_flags = MTD_WRITEABLE,
  35. }, {
  36. .name = "u-boot-env",
  37. .offset = 0x040000,
  38. .size = 0x010000,
  39. }, {
  40. .name = "rootfs",
  41. .offset = 0x050000,
  42. .size = 0x240000,
  43. }, {
  44. .name = "user-config",
  45. .offset = 0x290000,
  46. .size = 0x010000,
  47. }, {
  48. .name = "uImage",
  49. .offset = 0x2a0000,
  50. .size = 0x120000,
  51. }, {
  52. .name = "language_table",
  53. .offset = 0x3c0000,
  54. .size = 0x020000,
  55. }, {
  56. .name = "rootfs_checksum",
  57. .offset = 0x3e0000,
  58. .size = 0x010000,
  59. }, {
  60. .name = "art",
  61. .offset = 0x3f0000,
  62. .size = 0x010000,
  63. .mask_flags = MTD_WRITEABLE,
  64. }
  65. };
  66. static struct flash_platform_data wnr2000_flash_data = {
  67. .parts = wnr2000_partitions,
  68. .nr_parts = ARRAY_SIZE(wnr2000_partitions),
  69. };
  70. static struct gpio_led wnr2000_leds_gpio[] __initdata = {
  71. {
  72. .name = "netgear:green:power",
  73. .gpio = WNR2000_GPIO_LED_PWR_GREEN,
  74. .active_low = 1,
  75. }, {
  76. .name = "netgear:amber:power",
  77. .gpio = WNR2000_GPIO_LED_PWR_AMBER,
  78. .active_low = 1,
  79. }, {
  80. .name = "netgear:green:wps",
  81. .gpio = WNR2000_GPIO_LED_WPS,
  82. .active_low = 1,
  83. }, {
  84. .name = "netgear:blue:wlan",
  85. .gpio = WNR2000_GPIO_LED_WLAN,
  86. .active_low = 1,
  87. }
  88. };
  89. static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = {
  90. {
  91. .desc = "reset",
  92. .type = EV_KEY,
  93. .code = KEY_RESTART,
  94. .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
  95. .gpio = WNR2000_GPIO_BTN_RESET,
  96. }, {
  97. .desc = "wps",
  98. .type = EV_KEY,
  99. .code = KEY_WPS_BUTTON,
  100. .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
  101. .gpio = WNR2000_GPIO_BTN_WPS,
  102. }
  103. };
  104. static void __init wnr2000_setup(void)
  105. {
  106. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  107. ath79_register_mdio(0, 0x0);
  108. ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  109. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  110. ath79_eth0_data.speed = SPEED_100;
  111. ath79_eth0_data.duplex = DUPLEX_FULL;
  112. ath79_eth0_data.has_ar8216 = 1;
  113. ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  114. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  115. ath79_eth1_data.phy_mask = 0x10;
  116. ath79_register_eth(0);
  117. ath79_register_eth(1);
  118. ath79_register_m25p80(&wnr2000_flash_data);
  119. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
  120. wnr2000_leds_gpio);
  121. ath79_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL,
  122. ARRAY_SIZE(wnr2000_gpio_keys),
  123. wnr2000_gpio_keys);
  124. ath79_register_wmac(eeprom, NULL);
  125. }
  126. MIPS_MACHINE(ATH79_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);