mach-r6100.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * NETGEAR R6100 board support
  3. *
  4. * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2014 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/pci.h>
  12. #include <linux/phy.h>
  13. #include <linux/gpio.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/ath9k_platform.h>
  16. #include <linux/platform/ar934x_nfc.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h>
  18. #include "common.h"
  19. #include "dev-ap9x-pci.h"
  20. #include "dev-eth.h"
  21. #include "dev-gpio-buttons.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-nfc.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #include "machtypes.h"
  27. #define R6100_GPIO_LED_WLAN 0
  28. #define R6100_GPIO_LED_USB 11
  29. #define R6100_GPIO_LED_WAN_GREEN 13
  30. #define R6100_GPIO_LED_POWER_AMBER 14
  31. #define R6100_GPIO_LED_WAN_AMBER 15
  32. #define R6100_GPIO_LED_POWER_GREEN 17
  33. #define R6100_GPIO_BTN_WIRELESS 1
  34. #define R6100_GPIO_BTN_WPS 3
  35. #define R6100_GPIO_BTN_RESET 12
  36. #define R6100_GPIO_USB_POWER 16
  37. #define R6100_KEYS_POLL_INTERVAL 20 /* msecs */
  38. #define R6100_KEYS_DEBOUNCE_INTERVAL (3 * R6100_KEYS_POLL_INTERVAL)
  39. static struct gpio_led r6100_leds_gpio[] __initdata = {
  40. {
  41. .name = "netgear:green:power",
  42. .gpio = R6100_GPIO_LED_POWER_GREEN,
  43. .active_low = 1,
  44. },
  45. {
  46. .name = "netgear:amber:power",
  47. .gpio = R6100_GPIO_LED_POWER_AMBER,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "netgear:green:wan",
  52. .gpio = R6100_GPIO_LED_WAN_GREEN,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "netgear:amber:wan",
  57. .gpio = R6100_GPIO_LED_WAN_AMBER,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "netgear:blue:usb",
  62. .gpio = R6100_GPIO_LED_USB,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "netgear:blue:wlan",
  67. .gpio = R6100_GPIO_LED_WLAN,
  68. .active_low = 1,
  69. },
  70. };
  71. static struct gpio_keys_button r6100_gpio_keys[] __initdata = {
  72. {
  73. .desc = "Reset button",
  74. .type = EV_KEY,
  75. .code = KEY_RESTART,
  76. .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = R6100_GPIO_BTN_RESET,
  78. .active_low = 0,
  79. },
  80. {
  81. .desc = "WPS button",
  82. .type = EV_KEY,
  83. .code = KEY_WPS_BUTTON,
  84. .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  85. .gpio = R6100_GPIO_BTN_WPS,
  86. .active_low = 0,
  87. },
  88. {
  89. .desc = "RFKILL switch",
  90. .type = EV_SW,
  91. .code = KEY_RFKILL,
  92. .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
  93. .gpio = R6100_GPIO_BTN_WIRELESS,
  94. .active_low = 0,
  95. },
  96. };
  97. static void __init r6100_setup(void)
  98. {
  99. ath79_register_leds_gpio(-1, ARRAY_SIZE(r6100_leds_gpio),
  100. r6100_leds_gpio);
  101. ath79_register_gpio_keys_polled(-1, R6100_KEYS_POLL_INTERVAL,
  102. ARRAY_SIZE(r6100_gpio_keys),
  103. r6100_gpio_keys);
  104. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  105. ath79_register_mdio(1, 0x0);
  106. /* GMAC0 is connected to the PHY0 of the internal switch */
  107. ath79_switch_data.phy4_mii_en = 1;
  108. ath79_switch_data.phy_poll_mask = BIT(0);
  109. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  110. ath79_eth0_data.phy_mask = BIT(0);
  111. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  112. ath79_register_eth(0);
  113. /* GMAC1 is connected to the internal switch */
  114. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  115. ath79_register_eth(1);
  116. gpio_request_one(R6100_GPIO_USB_POWER,
  117. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  118. "USB power");
  119. ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
  120. ath79_register_nfc();
  121. ath79_register_usb();
  122. ath79_register_wmac_simple();
  123. ap91_pci_init_simple();
  124. }
  125. MIPS_MACHINE(ATH79_MACH_R6100, "R6100", "NETGEAR R6100",
  126. r6100_setup);