mach-wzr-hp-g450h.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
  80. {
  81. .desc = "reset",
  82. .type = EV_KEY,
  83. .code = KEY_RESTART,
  84. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  85. .gpio = 6,
  86. .active_low = 1,
  87. }, {
  88. .desc = "usb",
  89. .type = EV_KEY,
  90. .code = BTN_2,
  91. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  92. .gpio = 1,
  93. .active_low = 1,
  94. }, {
  95. .desc = "aoss",
  96. .type = EV_KEY,
  97. .code = KEY_WPS_BUTTON,
  98. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  99. .gpio = 8,
  100. .active_low = 1,
  101. }, {
  102. .desc = "movie_engine",
  103. .type = EV_KEY,
  104. .code = BTN_6,
  105. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  106. .gpio = 7,
  107. .active_low = 0,
  108. }, {
  109. .desc = "router_off",
  110. .type = EV_KEY,
  111. .code = BTN_5,
  112. .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
  113. .gpio = 12,
  114. .active_low = 0,
  115. }
  116. };
  117. static void __init wzrhpg450h_init(void)
  118. {
  119. u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
  120. u8 *mac = (u8 *) ee + 2;
  121. ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
  122. ath79_register_mdio(0, ~BIT(0));
  123. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  124. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  125. ath79_eth0_data.speed = SPEED_1000;
  126. ath79_eth0_data.duplex = DUPLEX_FULL;
  127. ath79_eth0_data.phy_mask = BIT(0);
  128. ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
  129. wzrhpg450h_leds_gpio);
  130. ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
  131. ARRAY_SIZE(wzrhpg450h_gpio_keys),
  132. wzrhpg450h_gpio_keys);
  133. ath79_register_eth(0);
  134. gpio_request_one(16, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  135. "USB power");
  136. ath79_register_usb();
  137. ap91_pci_init(ee, NULL);
  138. ap9x_pci_get_wmac_data(0)->tx_gain_buffalo = true;
  139. ap9x_pci_get_wmac_data(1)->tx_gain_buffalo = true;
  140. ap9x_pci_setup_wmac_led_pin(0, 15);
  141. ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
  142. ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
  143. }
  144. MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
  145. wzrhpg450h_init);