mach-anonabox-pro.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * AnonaBox QCA9531 board support
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License version 2 as published
  6. * by the Free Software Foundation.
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/ath9k_platform.h>
  21. #include <linux/ar8216_platform.h>
  22. #include <asm/mach-ath79/ar71xx_regs.h>
  23. #include "common.h"
  24. #include "dev-eth.h"
  25. #include "dev-gpio-buttons.h"
  26. #include "dev-leds-gpio.h"
  27. #include "dev-m25p80.h"
  28. #include "dev-spi.h"
  29. #include "dev-usb.h"
  30. #include "dev-wmac.h"
  31. #include "machtypes.h"
  32. #define ANONABOX_PRO_GPIO_LED_STATUS 14
  33. #define ANONABOX_PRO_GPIO_BTN_RST 17
  34. #define ANONABOX_PRO_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL (3 * ANONABOX_PRO_KEYS_POLL_INTERVAL)
  36. #define ANONABOX_PRO_MAC0_OFFSET 0
  37. #define ANONABOX_PRO_MAC1_OFFSET 6
  38. #define ANONABOX_PRO_WMAC_CALDATA_OFFSET 0x1000
  39. static struct gpio_led anonabox_pro_leds_gpio[] __initdata = {
  40. {
  41. .name = "anonabox_pro:green:status",
  42. .gpio = ANONABOX_PRO_GPIO_LED_STATUS,
  43. .active_low = 1,
  44. },
  45. };
  46. static struct gpio_keys_button anonabox_pro_gpio_keys[] __initdata = {
  47. {
  48. .desc = "reset button",
  49. .type = EV_KEY,
  50. .code = KEY_RESTART,
  51. .debounce_interval = ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL,
  52. .gpio = ANONABOX_PRO_GPIO_BTN_RST,
  53. .active_low = 1,
  54. },
  55. };
  56. static void __init anonabox_pro_gpio_led_setup(void)
  57. {
  58. ath79_register_leds_gpio(-1, ARRAY_SIZE(anonabox_pro_leds_gpio),
  59. anonabox_pro_leds_gpio);
  60. ath79_register_gpio_keys_polled(-1, ANONABOX_PRO_KEYS_POLL_INTERVAL,
  61. ARRAY_SIZE(anonabox_pro_gpio_keys),
  62. anonabox_pro_gpio_keys);
  63. }
  64. static void __init anonabox_pro_setup(void)
  65. {
  66. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  67. ath79_register_m25p80(NULL);
  68. anonabox_pro_gpio_led_setup();
  69. ath79_register_usb();
  70. ath79_register_wmac(art + ANONABOX_PRO_WMAC_CALDATA_OFFSET, NULL);
  71. ath79_register_mdio(0, 0x0);
  72. ath79_register_mdio(1, 0x0);
  73. ath79_init_mac(ath79_eth0_data.mac_addr, art + ANONABOX_PRO_MAC0_OFFSET, 0);
  74. ath79_init_mac(ath79_eth1_data.mac_addr, art + ANONABOX_PRO_MAC1_OFFSET, 0);
  75. /* WAN port */
  76. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  77. ath79_eth0_data.speed = SPEED_100;
  78. ath79_eth0_data.duplex = DUPLEX_FULL;
  79. ath79_eth0_data.phy_mask = BIT(4);
  80. ath79_register_eth(0);
  81. /* LAN ports */
  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_switch_data.phy_poll_mask |= BIT(4);
  86. ath79_switch_data.phy4_mii_en = 1;
  87. ath79_register_eth(1);
  88. }
  89. MIPS_MACHINE(ATH79_MACH_ANONABOX_PRO, "ANONABOX_PRO", "Anonabox QCA9531",
  90. anonabox_pro_setup);