mach-gs-minibox-v32.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Atheros GS_MINIBOX_V3.2 reference board support
  3. *
  4. * Copyright (c) 2018 OpenWRT.org
  5. * Copyright (c) 2013 The Linux Foundation. All rights reserved.
  6. * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  7. *
  8. * Permission to use, copy, modify, and/or distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. *
  20. */
  21. #include <linux/pci.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/ath9k_platform.h>
  24. #include <linux/ar8216_platform.h>
  25. #include <asm/mach-ath79/ar71xx_regs.h>
  26. #include "common.h"
  27. #include "dev-eth.h"
  28. #include "dev-ap9x-pci.h"
  29. #include "dev-gpio-buttons.h"
  30. #include "dev-leds-gpio.h"
  31. #include "dev-m25p80.h"
  32. #include "dev-spi.h"
  33. #include "dev-usb.h"
  34. #include "dev-wmac.h"
  35. #include "machtypes.h"
  36. #include "pci.h"
  37. #define GS_MINIBOX_V3_GPIO_LED_STATUS 14
  38. #define GS_MINIBOX_V3_GPIO_BTN_RST 17
  39. #define GS_MINIBOX_V3_KEYS_POLL_INTERVAL 20 /* msecs */
  40. #define GS_MINIBOX_V3_KEYS_DEBOUNCE_INTERVAL (3 * GS_MINIBOX_V3_KEYS_POLL_INTERVAL)
  41. #define GS_MINIBOX_V3_MAC0_OFFSET 0
  42. #define GS_MINIBOX_V3_MAC1_OFFSET 6
  43. #define GS_MINIBOX_V3_WMAC_CALDATA_OFFSET 0x1000
  44. static const char *gs_minibox_v3_part_probes[] = {
  45. "tp-link",
  46. NULL,
  47. };
  48. static struct flash_platform_data gs_minibox_v3_flash_data = {
  49. .part_probes = gs_minibox_v3_part_probes,
  50. };
  51. static struct gpio_led gs_minibox_v3_leds_gpio[] __initdata = {
  52. {
  53. .name = "minibox_v3.2:green:system",
  54. .gpio = GS_MINIBOX_V3_GPIO_LED_STATUS,
  55. .active_low = 1,
  56. },
  57. };
  58. static struct gpio_keys_button gs_minibox_v3_gpio_keys[] __initdata = {
  59. {
  60. .desc = "reset button",
  61. .type = EV_KEY,
  62. .code = KEY_RESTART,
  63. .debounce_interval = GS_MINIBOX_V3_KEYS_DEBOUNCE_INTERVAL,
  64. .gpio = GS_MINIBOX_V3_GPIO_BTN_RST,
  65. .active_low = 1,
  66. },
  67. };
  68. static void __init gs_minibox_v3_gpio_led_setup(void)
  69. {
  70. ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_minibox_v3_leds_gpio),
  71. gs_minibox_v3_leds_gpio);
  72. ath79_register_gpio_keys_polled(-1, GS_MINIBOX_V3_KEYS_POLL_INTERVAL,
  73. ARRAY_SIZE(gs_minibox_v3_gpio_keys),
  74. gs_minibox_v3_gpio_keys);
  75. }
  76. static void __init gs_minibox_v3_setup(void)
  77. {
  78. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  79. ath79_register_m25p80(&gs_minibox_v3_flash_data);
  80. gs_minibox_v3_gpio_led_setup();
  81. ath79_register_usb();
  82. ath79_register_wmac(art + GS_MINIBOX_V3_WMAC_CALDATA_OFFSET, NULL);
  83. ath79_register_mdio(0, 0x0);
  84. ath79_register_mdio(1, 0x0);
  85. ath79_init_mac(ath79_eth0_data.mac_addr, art + GS_MINIBOX_V3_MAC0_OFFSET, 0);
  86. ath79_init_mac(ath79_eth1_data.mac_addr, art + GS_MINIBOX_V3_MAC1_OFFSET, 0);
  87. /* WAN port */
  88. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  89. ath79_eth0_data.speed = SPEED_100;
  90. ath79_eth0_data.duplex = DUPLEX_FULL;
  91. ath79_eth0_data.phy_mask = BIT(4);
  92. ath79_register_eth(0);
  93. /* LAN ports */
  94. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  95. ath79_eth1_data.speed = SPEED_1000;
  96. ath79_eth1_data.duplex = DUPLEX_FULL;
  97. ath79_switch_data.phy_poll_mask |= BIT(4);
  98. ath79_switch_data.phy4_mii_en = 1;
  99. ath79_register_eth(1);
  100. ath79_register_pci();
  101. }
  102. MIPS_MACHINE(ATH79_MACH_GS_MINIBOX_V32, "MINIBOX-V3.2", "Minibox V3.2",
  103. gs_minibox_v3_setup);