mach-ew-balin.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * EW Balin board support
  3. * (based on Atheros DB120 reference board support)
  4. *
  5. * Copyright (c) 2011 Qualcomm Atheros
  6. * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  7. * Copyright (C) 2017 Embedded Wireless GmbH www.80211.de
  8. *
  9. * Permission to use, copy, modify, and/or distribute this software for any
  10. * purpose with or without fee is hereby granted, provided that the above
  11. * copyright notice and this permission notice appear in all copies.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  14. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  16. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  18. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  19. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20. *
  21. */
  22. #include <linux/pci.h>
  23. #include <linux/phy.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/ath9k_platform.h>
  26. #include <linux/ar8216_platform.h>
  27. #include <asm/mach-ath79/ar71xx_regs.h>
  28. #include "common.h"
  29. #include "dev-ap9x-pci.h"
  30. #include "dev-eth.h"
  31. #include "dev-gpio-buttons.h"
  32. #include "dev-leds-gpio.h"
  33. #include "dev-m25p80.h"
  34. #include "dev-spi.h"
  35. #include "dev-usb.h"
  36. #include "dev-wmac.h"
  37. #include "machtypes.h"
  38. #include "pci.h"
  39. #define BALIN_GPIO_LED_STATUS 14
  40. #define BALIN_GPIO_BTN_WPS 18
  41. #define BALIN_KEYS_POLL_INTERVAL 20 /* msecs */
  42. #define BALIN_KEYS_DEBOUNCE_INTERVAL (3 * BALIN_KEYS_POLL_INTERVAL)
  43. #define BALIN_CALDATA_OFFSET 0x1000
  44. #define BALIN_WMAC_MAC_OFFSET (BALIN_CALDATA_OFFSET + 0x02)
  45. static struct gpio_led balin_leds_gpio[] __initdata = {
  46. {
  47. .name = "balin:green:status",
  48. .gpio = BALIN_GPIO_LED_STATUS,
  49. .active_low = 1,
  50. },
  51. };
  52. static struct gpio_keys_button balin_gpio_keys[] __initdata = {
  53. {
  54. .desc = "WPS button",
  55. .type = EV_KEY,
  56. .code = KEY_WPS_BUTTON,
  57. .debounce_interval = BALIN_KEYS_DEBOUNCE_INTERVAL,
  58. .gpio = BALIN_GPIO_BTN_WPS,
  59. .active_low = 0,
  60. },
  61. };
  62. static void __init balin_setup(void)
  63. {
  64. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  65. static u8 mac[6];
  66. ath79_register_m25p80(NULL);
  67. ath79_register_leds_gpio(-1, ARRAY_SIZE(balin_leds_gpio),
  68. balin_leds_gpio);
  69. ath79_register_gpio_keys_polled(-1, BALIN_KEYS_POLL_INTERVAL,
  70. ARRAY_SIZE(balin_gpio_keys),
  71. balin_gpio_keys);
  72. ath79_register_usb();
  73. ath79_register_wmac(art + BALIN_CALDATA_OFFSET, NULL);
  74. ath79_register_pci();
  75. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  76. AR934X_ETH_CFG_SW_ONLY_MODE);
  77. ath79_register_mdio(1, 0x0);
  78. /* GMAC1 is connected to the internal switch */
  79. memcpy(mac, art + BALIN_WMAC_MAC_OFFSET, sizeof(mac));
  80. mac[3] |= 0x40;
  81. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  82. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  83. ath79_eth1_data.speed = SPEED_1000;
  84. ath79_eth1_data.duplex = DUPLEX_FULL;
  85. ath79_register_eth(1);
  86. }
  87. MIPS_MACHINE(ATH79_MACH_EW_BALIN, "EW-BALIN", "EmbWir-Balin",
  88. balin_setup);