mach-ap121f.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * ALFA Network AP121F board support
  3. *
  4. * Copyright (C) 2017 Piotr Dymacz <pepe2k@gmail.com>
  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/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define AP121F_GPIO_LED_LAN 17
  23. #define AP121F_GPIO_LED_VPN 27
  24. #define AP121F_GPIO_LED_WLAN 0
  25. #define AP121F_GPIO_MICROSD_EN 26
  26. #define AP121F_GPIO_BTN_RESET 12
  27. #define AP121F_GPIO_BTN_SWITCH 21
  28. #define AP121F_KEYS_POLL_INTERVAL 20
  29. #define AP121F_KEYS_DEBOUNCE_INTERVAL (3 * AP121F_KEYS_POLL_INTERVAL)
  30. #define AP121F_WMAC_CALDATA_OFFSET 0x1000
  31. static struct gpio_led ap121f_leds_gpio[] __initdata = {
  32. {
  33. .name = "ap121f:green:lan",
  34. .gpio = AP121F_GPIO_LED_LAN,
  35. .active_low = 1,
  36. }, {
  37. .name = "ap121f:green:vpn",
  38. .gpio = AP121F_GPIO_LED_VPN,
  39. .active_low = 1,
  40. }, {
  41. .name = "ap121f:green:wlan",
  42. .gpio = AP121F_GPIO_LED_WLAN,
  43. .active_low = 0,
  44. },
  45. };
  46. static struct gpio_keys_button ap121f_gpio_keys[] __initdata = {
  47. {
  48. .desc = "reset",
  49. .type = EV_KEY,
  50. .code = KEY_RESTART,
  51. .debounce_interval = AP121F_KEYS_DEBOUNCE_INTERVAL,
  52. .gpio = AP121F_GPIO_BTN_RESET,
  53. .active_low = 1,
  54. }, {
  55. .desc = "switch",
  56. .type = EV_KEY,
  57. .code = BTN_0,
  58. .debounce_interval = AP121F_KEYS_DEBOUNCE_INTERVAL,
  59. .gpio = AP121F_GPIO_BTN_SWITCH,
  60. .active_low = 0,
  61. },
  62. };
  63. static void __init ap121f_setup(void)
  64. {
  65. u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
  66. ath79_register_m25p80(NULL);
  67. ath79_setup_ar933x_phy4_switch(false, false);
  68. /* LAN */
  69. ath79_register_mdio(0, 0x0);
  70. ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
  71. ath79_register_eth(0);
  72. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121f_leds_gpio),
  73. ap121f_leds_gpio);
  74. ath79_register_gpio_keys_polled(-1, AP121F_KEYS_POLL_INTERVAL,
  75. ARRAY_SIZE(ap121f_gpio_keys),
  76. ap121f_gpio_keys);
  77. gpio_request_one(AP121F_GPIO_MICROSD_EN,
  78. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  79. "microSD enable");
  80. ath79_register_wmac(art + AP121F_WMAC_CALDATA_OFFSET, NULL);
  81. ath79_register_usb();
  82. }
  83. MIPS_MACHINE(ATH79_MACH_AP121F, "AP121F", "ALFA Network AP121F", ap121f_setup);