mach-eap300v2.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * EnGenius EAP300 v2 board support
  3. *
  4. * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  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 <linux/platform_device.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include <asm/mach-ath79/ath79.h>
  16. #include "common.h"
  17. #include "dev-eth.h"
  18. #include "dev-gpio-buttons.h"
  19. #include "dev-leds-gpio.h"
  20. #include "dev-m25p80.h"
  21. #include "dev-wmac.h"
  22. #include "machtypes.h"
  23. #define EAP300V2_GPIO_LED_POWER 0
  24. #define EAP300V2_GPIO_LED_LAN 16
  25. #define EAP300V2_GPIO_LED_WLAN 17
  26. #define EAP300V2_GPIO_BTN_RESET 1
  27. #define EAP300V2_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define EAP300V2_KEYS_DEBOUNCE_INTERVAL (3 * EAP300V2_KEYS_POLL_INTERVAL)
  29. static struct gpio_led eap300v2_leds_gpio[] __initdata = {
  30. {
  31. .name = "engenius:blue:power",
  32. .gpio = EAP300V2_GPIO_LED_POWER,
  33. .active_low = 1,
  34. }, {
  35. .name = "engenius:blue:lan",
  36. .gpio = EAP300V2_GPIO_LED_LAN,
  37. .active_low = 1,
  38. }, {
  39. .name = "engenius:blue:wlan",
  40. .gpio = EAP300V2_GPIO_LED_WLAN,
  41. .active_low = 1,
  42. }
  43. };
  44. static struct gpio_keys_button eap300v2_gpio_keys[] __initdata = {
  45. {
  46. .desc = "reset",
  47. .type = EV_KEY,
  48. .code = KEY_RESTART,
  49. .debounce_interval = EAP300V2_KEYS_DEBOUNCE_INTERVAL,
  50. .gpio = EAP300V2_GPIO_BTN_RESET,
  51. .active_low = 1,
  52. }
  53. };
  54. #define EAP300V2_ART_MAC_OFFSET 2
  55. #define EAP300V2_LAN_PHYMASK BIT(0)
  56. static void __init eap300v2_setup(void)
  57. {
  58. u8 *art = (u8 *)KSEG1ADDR(0x1fff1000);
  59. ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  60. ath79_gpio_output_select(EAP300V2_GPIO_LED_POWER, AR934X_GPIO_OUT_GPIO);
  61. ath79_gpio_output_select(EAP300V2_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
  62. ath79_gpio_output_select(EAP300V2_GPIO_LED_WLAN, AR934X_GPIO_OUT_GPIO);
  63. ath79_register_leds_gpio(-1, ARRAY_SIZE(eap300v2_leds_gpio),
  64. eap300v2_leds_gpio);
  65. ath79_register_gpio_keys_polled(-1, EAP300V2_KEYS_POLL_INTERVAL,
  66. ARRAY_SIZE(eap300v2_gpio_keys),
  67. eap300v2_gpio_keys);
  68. ath79_register_m25p80(NULL);
  69. ath79_register_wmac(art, NULL);
  70. ath79_register_mdio(1, 0x0);
  71. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  72. ath79_init_mac(ath79_eth0_data.mac_addr,
  73. art + EAP300V2_ART_MAC_OFFSET, 0);
  74. ath79_switch_data.phy4_mii_en = 1;
  75. ath79_switch_data.phy_poll_mask = EAP300V2_LAN_PHYMASK;
  76. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  77. ath79_eth0_data.phy_mask = EAP300V2_LAN_PHYMASK;
  78. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  79. ath79_register_eth(0);
  80. }
  81. MIPS_MACHINE(ATH79_MACH_EAP300V2, "EAP300V2", "EnGenius EAP300 v2",
  82. eap300v2_setup);