mach-fritz300e.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * AVM FRITZ!WLAN Repeater 300E board support
  3. *
  4. * Copyright (C) 2017 Mathias Kresin <dev@kresin.me>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include "dev-ap9x-pci.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "machtypes.h"
  19. #define FRITZ300E_KEYS_POLL_INTERVAL 20 /* msecs */
  20. #define FRITZ300E_KEYS_DEBOUNCE_INTERVAL (3 * FRITZ300E_KEYS_POLL_INTERVAL)
  21. static struct mtd_partition fritz300e_flash_partitions[] = {
  22. {
  23. .name = "urloader",
  24. .offset = 0,
  25. .size = 0x0020000,
  26. .mask_flags = MTD_WRITEABLE,
  27. }, {
  28. .name = "firmware",
  29. .offset = 0x0020000,
  30. .size = 0x0ee0000,
  31. }, {
  32. .name = "tffs (1)",
  33. .offset = 0x0f00000,
  34. .size = 0x0080000,
  35. .mask_flags = MTD_WRITEABLE,
  36. }, {
  37. .name = "tffs (2)",
  38. .offset = 0x0f80000,
  39. .size = 0x0080000,
  40. .mask_flags = MTD_WRITEABLE,
  41. }
  42. };
  43. static struct flash_platform_data fritz300e_flash_data = {
  44. .parts = fritz300e_flash_partitions,
  45. .nr_parts = ARRAY_SIZE(fritz300e_flash_partitions),
  46. };
  47. static struct gpio_led fritz300e_leds_gpio[] __initdata = {
  48. {
  49. .name = "fritz300e:green:power",
  50. .gpio = 13,
  51. .active_low = 1,
  52. }, {
  53. .name = "fritz300e:green:lan",
  54. .gpio = 15,
  55. .active_low = 1,
  56. }, {
  57. .name = "fritz300e:green:wlan",
  58. .gpio = 16,
  59. .active_low = 1,
  60. }
  61. };
  62. static struct gpio_led fritz300e_wmac_leds_gpio[] = {
  63. {
  64. .name = "fritz300e:green:rssi0",
  65. .gpio = 10,
  66. .active_low = 1,
  67. }, {
  68. .name = "fritz300e:green:rssi1",
  69. .gpio = 4,
  70. .active_low = 1,
  71. }, {
  72. .name = "fritz300e:green:rssi2",
  73. .gpio = 6,
  74. .active_low = 1,
  75. }, {
  76. .name = "fritz300e:green:rssi3",
  77. .gpio = 7,
  78. .active_low = 1,
  79. }, {
  80. .name = "fritz300e:green:rssi4",
  81. .gpio = 5,
  82. .active_low = 1,
  83. }
  84. };
  85. static struct gpio_keys_button fritz300e_gpio_keys[] __initdata = {
  86. {
  87. .desc = "wps",
  88. .type = EV_KEY,
  89. .code = KEY_WPS_BUTTON,
  90. .debounce_interval = FRITZ300E_KEYS_DEBOUNCE_INTERVAL,
  91. .gpio = 12,
  92. .active_low = 1,
  93. },
  94. };
  95. static void __init fritz300e_setup(void)
  96. {
  97. /* get the Lantiq PEF7071V phy out of reset */
  98. gpio_request_one(11, GPIOF_OUT_INIT_HIGH, "phy reset");
  99. ath79_register_m25p80(&fritz300e_flash_data);
  100. ath79_register_mdio(0, ~(BIT(0)));
  101. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  102. ath79_eth0_data.speed = SPEED_1000;
  103. ath79_eth0_data.duplex = DUPLEX_FULL;
  104. ath79_eth0_data.phy_mask = BIT(0);
  105. ath79_register_eth(0);
  106. ath79_register_leds_gpio(-1, ARRAY_SIZE(fritz300e_leds_gpio),
  107. fritz300e_leds_gpio);
  108. ath79_register_gpio_keys_polled(-1, FRITZ300E_KEYS_POLL_INTERVAL,
  109. ARRAY_SIZE(fritz300e_gpio_keys),
  110. fritz300e_gpio_keys);
  111. ap9x_pci_setup_wmac_leds(0, fritz300e_wmac_leds_gpio,
  112. ARRAY_SIZE(fritz300e_wmac_leds_gpio));
  113. ap91_pci_init_simple();
  114. }
  115. MIPS_MACHINE(ATH79_MACH_FRITZ300E, "FRITZ300E",
  116. "AVM FRITZ!WLAN Repeater 300E", fritz300e_setup);