mach-wzr-hp-g450h.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Buffalo WZR-HP-G450G board support
  3. *
  4. * Copyright (C) 2011 Felix Fietkau <nbd@nbd.name>
  5. * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2008 Imre Kaloz <kaloz@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/gpio.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/ath9k_platform.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include "dev-eth.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-ap9x-pci.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-usb.h"
  23. #include "machtypes.h"
  24. #define WZRHPG450H_KEYS_POLL_INTERVAL 20 /* msecs */
  25. #define WZRHPG450H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG450H_KEYS_POLL_INTERVAL)
  26. static struct mtd_partition wzrhpg450h_partitions[] = {
  27. {
  28. .name = "u-boot",
  29. .offset = 0,
  30. .size = 0x0040000,
  31. .mask_flags = MTD_WRITEABLE,
  32. }, {
  33. .name = "u-boot-env",
  34. .offset = 0x0040000,
  35. .size = 0x0010000,
  36. }, {
  37. .name = "ART",
  38. .offset = 0x0050000,
  39. .size = 0x0010000,
  40. .mask_flags = MTD_WRITEABLE,
  41. }, {
  42. .name = "firmware",
  43. .offset = 0x0060000,
  44. .size = 0x1f80000,
  45. }, {
  46. .name = "user_property",
  47. .offset = 0x1fe0000,
  48. .size = 0x0020000,
  49. }
  50. };
  51. static struct flash_platform_data wzrhpg450h_flash_data = {
  52. .parts = wzrhpg450h_partitions,
  53. .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
  54. };
  55. static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
  56. {
  57. .name = "buffalo:red:diag",
  58. .gpio = 14,
  59. .active_low = 1,
  60. },
  61. {
  62. .name = "buffalo:orange:security",
  63. .gpio = 13,
  64. .active_low = 1,
  65. },
  66. };
  67. static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
  68. {
  69. .name = "buffalo:blue:movie_engine",
  70. .gpio = 13,
  71. .active_low = 1,
  72. },
  73. {
  74. .name = "buffalo:green:router",
  75. .gpio = 14,
  76. .active_low = 1,
  77. },
  78. {
  79. .name = "buffalo:green:wireless",
  80. .gpio = 15,
  81. .active_low = 1,
  82. },
  83. };
  84. static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
  85. {
  86. .desc = "reset",
  87. .type = EV_KEY,
  88. .code = KEY_RESTART,
  89. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  90. .gpio = 6,
  91. .active_low = 1,
  92. }, {
  93. .desc = "usb",
  94. .type = EV_KEY,
  95. .code = BTN_2,
  96. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  97. .gpio = 1,
  98. .active_low = 1,
  99. }, {
  100. .desc = "aoss",
  101. .type = EV_KEY,
  102. .code = KEY_WPS_BUTTON,
  103. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  104. .gpio = 8,
  105. .active_low = 1,
  106. }, {
  107. .desc = "movie_engine",
  108. .type = EV_KEY,
  109. .code = BTN_6,
  110. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  111. .gpio = 7,
  112. .active_low = 0,
  113. }, {
  114. .desc = "router_off",
  115. .type = EV_KEY,
  116. .code = BTN_5,
  117. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  118. .gpio = 12,
  119. .active_low = 0,
  120. }
  121. };
  122. static void __init wzrhpg450h_init(void)
  123. {
  124. u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
  125. u8 *mac = (u8 *) ee + 2;
  126. ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
  127. ath79_register_mdio(0, ~BIT(0));
  128. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  129. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  130. ath79_eth0_data.speed = SPEED_1000;
  131. ath79_eth0_data.duplex = DUPLEX_FULL;
  132. ath79_eth0_data.phy_mask = BIT(0);
  133. ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
  134. wzrhpg450h_leds_gpio);
  135. ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
  136. ARRAY_SIZE(wzrhpg450h_gpio_keys),
  137. wzrhpg450h_gpio_keys);
  138. ath79_register_eth(0);
  139. gpio_request_one(16, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  140. "USB power");
  141. ath79_register_usb();
  142. ap91_pci_init(ee, NULL);
  143. ap9x_pci_get_wmac_data(0)->tx_gain_buffalo = true;
  144. ap9x_pci_get_wmac_data(1)->tx_gain_buffalo = true;
  145. ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
  146. ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
  147. }
  148. MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
  149. wzrhpg450h_init);