mach-gl-usb150.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * GL.iNet GL-USB150 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-wmac.h"
  20. #include "machtypes.h"
  21. #define GL_USB150_GPIO_LED_POWER 13
  22. #define GL_USB150_GPIO_LED_WLAN 0
  23. #define GL_USB150_GPIO_LAN_RESET 7
  24. #define GL_USB150_GPIO_BTN_RESET 11
  25. #define GL_USB150_KEYS_POLL_INTERVAL 20
  26. #define GL_USB150_KEYS_DEBOUNCE_INTERVAL \
  27. (3 * GL_USB150_KEYS_POLL_INTERVAL)
  28. #define GL_USB150_WMAC_CALDATA_OFFSET 0x1000
  29. static struct gpio_led gl_usb150_leds_gpio[] __initdata = {
  30. {
  31. .name = "gl-usb150:green:power",
  32. .gpio = GL_USB150_GPIO_LED_POWER,
  33. .active_low = 0,
  34. }, {
  35. .name = "gl-usb150:green:wlan",
  36. .gpio = GL_USB150_GPIO_LED_WLAN,
  37. .active_low = 0,
  38. },
  39. };
  40. static struct gpio_keys_button gl_usb150_gpio_keys[] __initdata = {
  41. {
  42. .desc = "reset",
  43. .type = EV_KEY,
  44. .code = KEY_RESTART,
  45. .debounce_interval = GL_USB150_KEYS_DEBOUNCE_INTERVAL,
  46. .gpio = GL_USB150_GPIO_BTN_RESET,
  47. .active_low = 0,
  48. },
  49. };
  50. static void __init gl_usb150_setup(void)
  51. {
  52. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  53. ath79_register_m25p80(NULL);
  54. ath79_setup_ar933x_phy4_switch(false, false);
  55. /* LAN (PHY4 connected with Realtek RTL8152B) */
  56. ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
  57. ath79_register_mdio(0, 0x0);
  58. ath79_register_eth(0);
  59. ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_usb150_leds_gpio),
  60. gl_usb150_leds_gpio);
  61. ath79_register_gpio_keys_polled(-1, GL_USB150_KEYS_POLL_INTERVAL,
  62. ARRAY_SIZE(gl_usb150_gpio_keys),
  63. gl_usb150_gpio_keys);
  64. gpio_request_one(GL_USB150_GPIO_LAN_RESET,
  65. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  66. "LAN reset");
  67. ath79_register_wmac(art + GL_USB150_WMAC_CALDATA_OFFSET, NULL);
  68. }
  69. MIPS_MACHINE(ATH79_MACH_GL_USB150, "GL-USB150", "GL.iNet GL-USB150",
  70. gl_usb150_setup);