mach-wnr2200.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * NETGEAR WNR2200 board support
  3. *
  4. * Copyright (C) 2013 Aidan Kissane <aidankissane at googlemail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  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 "dev-usb.h"
  20. #include "machtypes.h"
  21. #define WNR2200_GPIO_LED_LAN2_AMBER 0
  22. #define WNR2200_GPIO_LED_LAN4_AMBER 1
  23. #define WNR2200_GPIO_LED_WPS 5
  24. #define WNR2200_GPIO_LED_WAN_GREEN 7
  25. #define WNR2200_GPIO_LED_USB 8
  26. #define WNR2200_GPIO_LED_LAN3_AMBER 11
  27. #define WNR2200_GPIO_LED_WAN_AMBER 12
  28. #define WNR2200_GPIO_LED_LAN1_GREEN 13
  29. #define WNR2200_GPIO_LED_LAN2_GREEN 14
  30. #define WNR2200_GPIO_LED_LAN3_GREEN 15
  31. #define WNR2200_GPIO_LED_LAN4_GREEN 16
  32. #define WNR2200_GPIO_LED_PWR_AMBER 21
  33. #define WNR2200_GPIO_LED_PWR_GREEN 22
  34. #define WNR2200_GPIO_USB_POWER 24
  35. #define WNR2200_KEYS_POLL_INTERVAL 20 /* msecs */
  36. #define WNR2200_KEYS_DEBOUNCE_INTERVAL (3 * WNR2200_KEYS_POLL_INTERVAL)
  37. #define WNR2200_MAC0_OFFSET 0
  38. #define WNR2200_MAC1_OFFSET 6
  39. #define WNR2200_PCIE_CALDATA_OFFSET 0x1000
  40. static struct gpio_led wnr2200_leds_gpio[] __initdata = {
  41. {
  42. .name = "netgear:amber:lan2",
  43. .gpio = WNR2200_GPIO_LED_LAN2_AMBER,
  44. .active_low = 1,
  45. }, {
  46. .name = "netgear:amber:lan4",
  47. .gpio = WNR2200_GPIO_LED_LAN4_AMBER,
  48. .active_low = 1,
  49. }, {
  50. .name = "netgear:green:wps",
  51. .gpio = WNR2200_GPIO_LED_WPS,
  52. .active_low = 1,
  53. }, {
  54. .name = "netgear:green:wan",
  55. .gpio = WNR2200_GPIO_LED_WAN_GREEN,
  56. .active_low = 1,
  57. }, {
  58. .name = "netgear:green:usb",
  59. .gpio = WNR2200_GPIO_LED_USB,
  60. .active_low = 1,
  61. }, {
  62. .name = "netgear:amber:lan3",
  63. .gpio = WNR2200_GPIO_LED_LAN3_AMBER,
  64. .active_low = 1,
  65. }, {
  66. .name = "netgear:amber:wan",
  67. .gpio = WNR2200_GPIO_LED_WAN_AMBER,
  68. .active_low = 1,
  69. }, {
  70. .name = "netgear:green:lan1",
  71. .gpio = WNR2200_GPIO_LED_LAN1_GREEN,
  72. .active_low = 1,
  73. }, {
  74. .name = "netgear:green:lan2",
  75. .gpio = WNR2200_GPIO_LED_LAN2_GREEN,
  76. .active_low = 1,
  77. }, {
  78. .name = "netgear:green:lan3",
  79. .gpio = WNR2200_GPIO_LED_LAN3_GREEN,
  80. .active_low = 1,
  81. }, {
  82. .name = "netgear:green:lan4",
  83. .gpio = WNR2200_GPIO_LED_LAN4_GREEN,
  84. .active_low = 1,
  85. }, {
  86. .name = "netgear:amber:power",
  87. .gpio = WNR2200_GPIO_LED_PWR_AMBER,
  88. .active_low = 1,
  89. }, {
  90. .name = "netgear:green:power",
  91. .gpio = WNR2200_GPIO_LED_PWR_GREEN,
  92. .active_low = 1,
  93. }
  94. };
  95. static void __init wnr2200_setup(void)
  96. {
  97. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  98. ath79_register_mdio(0, 0x0);
  99. ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2200_MAC0_OFFSET, 0);
  100. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  101. ath79_eth0_data.speed = SPEED_100;
  102. ath79_eth0_data.duplex = DUPLEX_FULL;
  103. ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2200_MAC1_OFFSET, 0);
  104. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  105. ath79_eth1_data.phy_mask = 0x10;
  106. ath79_register_eth(0);
  107. ath79_register_eth(1);
  108. ath79_register_m25p80(NULL);
  109. ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET,
  110. art + WNR2200_MAC1_OFFSET);
  111. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
  112. wnr2200_leds_gpio);
  113. /* enable power for the USB port */
  114. gpio_request_one(WNR2200_GPIO_USB_POWER,
  115. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  116. "USB power");
  117. ath79_register_usb();
  118. }
  119. MIPS_MACHINE(ATH79_MACH_WNR2200, "WNR2200", "NETGEAR WNR2200", wnr2200_setup);