mach-wzr-hp-g300nh2.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Buffalo WZR-HP-G300NH2 board support
  3. *
  4. * Copyright (C) 2011 Felix Fietkau <nbd@nbd.name>
  5. * Copyright (C) 2011 Mark Deneen <mdeneen@gmail.com>
  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/gpio.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <asm/mach-ath79/ath79.h>
  15. #include "dev-ap9x-pci.h"
  16. #include "dev-eth.h"
  17. #include "dev-gpio-buttons.h"
  18. #include "dev-leds-gpio.h"
  19. #include "dev-m25p80.h"
  20. #include "dev-usb.h"
  21. #include "machtypes.h"
  22. #define WZRHPG300NH2_MAC_OFFSET 0x20c
  23. #define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
  24. #define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
  25. static struct mtd_partition wzrhpg300nh2_flash_partitions[] = {
  26. {
  27. .name = "u-boot",
  28. .offset = 0,
  29. .size = 0x0040000,
  30. .mask_flags = MTD_WRITEABLE,
  31. }, {
  32. .name = "u-boot-env",
  33. .offset = 0x0040000,
  34. .size = 0x0010000,
  35. .mask_flags = MTD_WRITEABLE,
  36. }, {
  37. .name = "art",
  38. .offset = 0x0050000,
  39. .size = 0x0010000,
  40. .mask_flags = MTD_WRITEABLE,
  41. }, {
  42. .name = "firmware",
  43. .offset = 0x0060000,
  44. .size = 0x1f90000,
  45. }, {
  46. .name = "user_property",
  47. .offset = 0x1ff0000,
  48. .size = 0x0010000,
  49. .mask_flags = MTD_WRITEABLE,
  50. }
  51. };
  52. static struct flash_platform_data wzrhpg300nh2_flash_data = {
  53. .parts = wzrhpg300nh2_flash_partitions,
  54. .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions),
  55. };
  56. static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = {
  57. {
  58. .name = "buffalo:red:diag",
  59. .gpio = 16,
  60. .active_low = 1,
  61. },
  62. };
  63. static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = {
  64. {
  65. .name = "buffalo:blue:usb",
  66. .gpio = 4,
  67. .active_low = 1,
  68. },
  69. {
  70. .name = "buffalo:orange:security",
  71. .gpio = 6,
  72. .active_low = 1,
  73. },
  74. {
  75. .name = "buffalo:green:router",
  76. .gpio = 7,
  77. .active_low = 1,
  78. },
  79. {
  80. .name = "buffalo:blue:movie_engine_on",
  81. .gpio = 8,
  82. .active_low = 1,
  83. },
  84. {
  85. .name = "buffalo:blue:movie_engine_off",
  86. .gpio = 9,
  87. .active_low = 1,
  88. },
  89. };
  90. /* The AOSS button is wmac gpio 12 */
  91. static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = {
  92. {
  93. .desc = "reset",
  94. .type = EV_KEY,
  95. .code = KEY_RESTART,
  96. .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  97. .gpio = 1,
  98. .active_low = 1,
  99. }, {
  100. .desc = "usb",
  101. .type = EV_KEY,
  102. .code = BTN_2,
  103. .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  104. .gpio = 7,
  105. .active_low = 1,
  106. }, {
  107. .desc = "qos",
  108. .type = EV_KEY,
  109. .code = BTN_3,
  110. .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  111. .gpio = 11,
  112. .active_low = 0,
  113. }, {
  114. .desc = "router_on",
  115. .type = EV_KEY,
  116. .code = BTN_5,
  117. .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
  118. .gpio = 8,
  119. .active_low = 0,
  120. },
  121. };
  122. static void __init wzrhpg300nh2_setup(void)
  123. {
  124. u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000);
  125. u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET;
  126. /* There is an eth1 but it is not connected to the switch */
  127. ath79_register_m25p80_multi(&wzrhpg300nh2_flash_data);
  128. ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  129. ath79_register_mdio(0, ~(BIT(0)));
  130. ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
  131. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  132. ath79_eth0_data.speed = SPEED_1000;
  133. ath79_eth0_data.duplex = DUPLEX_FULL;
  134. ath79_eth0_data.phy_mask = BIT(0);
  135. ath79_register_eth(0);
  136. /* gpio13 is usb power. Turn it on. */
  137. gpio_request_one(13, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  138. "USB power");
  139. ath79_register_usb();
  140. ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
  141. wzrhpg300nh2_leds_gpio);
  142. ath79_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL,
  143. ARRAY_SIZE(wzrhpg300nh2_gpio_keys),
  144. wzrhpg300nh2_gpio_keys);
  145. ap9x_pci_setup_wmac_led_pin(0, 5);
  146. ap9x_pci_setup_wmac_leds(0, wzrhpg300nh2_wmac_leds_gpio,
  147. ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio));
  148. ap91_pci_init(eeprom, mac0);
  149. }
  150. MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH2, "WZR-HP-G300NH2",
  151. "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup);