mach-wndr3700.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Netgear WNDR3700 board support
  3. *
  4. * Copyright (C) 2009 Marco Porsch
  5. * Copyright (C) 2009-2012 Gabor Juhos <juhosg@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/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/delay.h>
  15. #include <linux/rtl8366.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include "dev-ap9x-pci.h"
  18. #include "dev-eth.h"
  19. #include "dev-gpio-buttons.h"
  20. #include "dev-leds-gpio.h"
  21. #include "dev-m25p80.h"
  22. #include "dev-usb.h"
  23. #include "machtypes.h"
  24. #define WNDR3700_GPIO_LED_WPS_ORANGE 0
  25. #define WNDR3700_GPIO_LED_POWER_ORANGE 1
  26. #define WNDR3700_GPIO_LED_POWER_GREEN 2
  27. #define WNDR3700_GPIO_LED_WPS_GREEN 4
  28. #define WNDR3700_GPIO_LED_WAN_GREEN 6
  29. #define WNDR3700_GPIO_BTN_WPS 3
  30. #define WNDR3700_GPIO_BTN_RESET 8
  31. #define WNDR3700_GPIO_BTN_WIFI 11
  32. #define WNDR3700_GPIO_RTL8366_SDA 5
  33. #define WNDR3700_GPIO_RTL8366_SCK 7
  34. #define WNDR3700_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define WNDR3700_KEYS_DEBOUNCE_INTERVAL (3 * WNDR3700_KEYS_POLL_INTERVAL)
  36. #define WNDR3700_ETH0_MAC_OFFSET 0
  37. #define WNDR3700_ETH1_MAC_OFFSET 0x6
  38. #define WNDR3700_WMAC0_MAC_OFFSET 0
  39. #define WNDR3700_WMAC1_MAC_OFFSET 0xc
  40. #define WNDR3700_CALDATA0_OFFSET 0x1000
  41. #define WNDR3700_CALDATA1_OFFSET 0x5000
  42. static struct gpio_led wndr3700_leds_gpio[] __initdata = {
  43. {
  44. .name = "netgear:green:power",
  45. .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
  46. .active_low = 1,
  47. }, {
  48. .name = "netgear:orange:power",
  49. .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
  50. .active_low = 1,
  51. }, {
  52. .name = "netgear:green:wps",
  53. .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
  54. .active_low = 1,
  55. }, {
  56. .name = "netgear:orange:wps",
  57. .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
  58. .active_low = 1,
  59. }, {
  60. .name = "netgear:green:wan",
  61. .gpio = WNDR3700_GPIO_LED_WAN_GREEN,
  62. .active_low = 1,
  63. }
  64. };
  65. static struct gpio_keys_button wndr3700_gpio_keys[] __initdata = {
  66. {
  67. .desc = "reset",
  68. .type = EV_KEY,
  69. .code = KEY_RESTART,
  70. .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  71. .gpio = WNDR3700_GPIO_BTN_RESET,
  72. .active_low = 1,
  73. }, {
  74. .desc = "wps",
  75. .type = EV_KEY,
  76. .code = KEY_WPS_BUTTON,
  77. .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  78. .gpio = WNDR3700_GPIO_BTN_WPS,
  79. .active_low = 1,
  80. }, {
  81. .desc = "wifi",
  82. .type = EV_KEY,
  83. .code = BTN_2,
  84. .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
  85. .gpio = WNDR3700_GPIO_BTN_WIFI,
  86. .active_low = 1,
  87. }
  88. };
  89. static struct rtl8366_platform_data wndr3700_rtl8366s_data = {
  90. .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
  91. .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
  92. };
  93. static struct platform_device wndr3700_rtl8366s_device = {
  94. .name = RTL8366S_DRIVER_NAME,
  95. .id = -1,
  96. .dev = {
  97. .platform_data = &wndr3700_rtl8366s_data,
  98. }
  99. };
  100. static void __init wndr3700_setup(void)
  101. {
  102. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  103. /*
  104. * The eth0 and wmac0 interfaces share the same MAC address which
  105. * can lead to problems if operated unbridged. Set the locally
  106. * administered bit on the eth0 MAC to make it unique.
  107. */
  108. ath79_init_local_mac(ath79_eth0_data.mac_addr,
  109. art + WNDR3700_ETH0_MAC_OFFSET);
  110. ath79_eth0_pll_data.pll_1000 = 0x11110000;
  111. ath79_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  112. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  113. ath79_eth0_data.speed = SPEED_1000;
  114. ath79_eth0_data.duplex = DUPLEX_FULL;
  115. ath79_init_mac(ath79_eth1_data.mac_addr,
  116. art + WNDR3700_ETH1_MAC_OFFSET, 0);
  117. ath79_eth1_pll_data.pll_1000 = 0x11110000;
  118. ath79_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  119. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  120. ath79_eth1_data.phy_mask = 0x10;
  121. ath79_register_eth(0);
  122. ath79_register_eth(1);
  123. ath79_register_usb();
  124. ath79_register_m25p80(NULL);
  125. ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
  126. wndr3700_leds_gpio);
  127. ath79_register_gpio_keys_polled(-1, WNDR3700_KEYS_POLL_INTERVAL,
  128. ARRAY_SIZE(wndr3700_gpio_keys),
  129. wndr3700_gpio_keys);
  130. platform_device_register(&wndr3700_rtl8366s_device);
  131. platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
  132. ap9x_pci_setup_wmac_led_pin(0, 5);
  133. ap9x_pci_setup_wmac_led_pin(1, 5);
  134. /* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
  135. ap9x_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));
  136. /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
  137. ap9x_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
  138. ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
  139. art + WNDR3700_WMAC0_MAC_OFFSET,
  140. art + WNDR3700_CALDATA1_OFFSET,
  141. art + WNDR3700_WMAC1_MAC_OFFSET);
  142. }
  143. MIPS_MACHINE(ATH79_MACH_WNDR3700, "WNDR3700",
  144. "NETGEAR WNDR3700/WNDR3800/WNDRMAC",
  145. wndr3700_setup);