mach-pqi-air-pen.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * PQI Air Pen stick support
  3. *
  4. * Copyright (C) 2016 YuheiOKAWA <tochiro.srchack@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 <asm/mach-ath79/ath79.h>
  12. #include "common.h"
  13. #include "dev-eth.h"
  14. #include "dev-gpio-buttons.h"
  15. #include "dev-leds-gpio.h"
  16. #include "dev-m25p80.h"
  17. #include "dev-usb.h"
  18. #include "dev-wmac.h"
  19. #include "machtypes.h"
  20. #define PQI_AIR_PEN_GPIO_LED_WLAN 0
  21. #define PQI_AIR_PEN_GPIO_LED_WPS 23
  22. #define PQI_AIR_PEN_GPIO_BTN_WPS 22
  23. #define PQI_AIR_PEN_GPIO_BTN_RESET 12
  24. #define PQI_AIR_PEN_KEYS_POLL_INTERVAL 20 /* msecs */
  25. #define PQI_AIR_PEN_KEYS_DEBOUNCE_INTERVAL (3 * PQI_AIR_PEN_KEYS_POLL_INTERVAL)
  26. #define PQI_AIR_PEN_WMAC_CALDATA_OFFSET 0x1000
  27. #define PQI_AIR_PEN_LAN_MAC_OFFSET 0x1002
  28. #define PQI_AIR_PEN_WMAC_MAC_OFFSET 0x1002
  29. static struct gpio_led pqi_air_pen_leds_gpio[] __initdata = {
  30. {
  31. .name = "pqi-air-pen:blue:wlan",
  32. .gpio = PQI_AIR_PEN_GPIO_LED_WLAN,
  33. .active_low = 0,
  34. },
  35. {
  36. .name = "pqi-air-pen:blue:wps",
  37. .gpio = PQI_AIR_PEN_GPIO_LED_WPS,
  38. .active_low = 0,
  39. },
  40. };
  41. static struct gpio_keys_button pqi_air_pen_gpio_keys[] __initdata = {
  42. {
  43. .desc = "wps",
  44. .type = EV_KEY,
  45. .code = KEY_WPS_BUTTON,
  46. .debounce_interval = PQI_AIR_PEN_KEYS_DEBOUNCE_INTERVAL,
  47. .gpio = PQI_AIR_PEN_GPIO_BTN_WPS,
  48. .active_low = 0,
  49. },
  50. {
  51. .desc = "reset",
  52. .type = EV_KEY,
  53. .code = KEY_RESTART,
  54. .debounce_interval = PQI_AIR_PEN_KEYS_DEBOUNCE_INTERVAL,
  55. .gpio = PQI_AIR_PEN_GPIO_BTN_RESET,
  56. .active_low = 0,
  57. },
  58. };
  59. static void __init pqi_air_pen_setup(void)
  60. {
  61. /* ART base address */
  62. u8 *art = (u8 *) KSEG1ADDR(0x9f050000);
  63. /* register flash. */
  64. ath79_register_m25p80(NULL);
  65. /* register wireless mac with cal data */
  66. ath79_register_wmac(art + PQI_AIR_PEN_WMAC_CALDATA_OFFSET, art + PQI_AIR_PEN_WMAC_MAC_OFFSET);
  67. /* false PHY_SWAP and PHY_ADDR_SWAP bits */
  68. ath79_setup_ar933x_phy4_switch(false, false);
  69. /* register gpio LEDs and keys */
  70. ath79_register_leds_gpio(-1, ARRAY_SIZE(pqi_air_pen_leds_gpio),
  71. pqi_air_pen_leds_gpio);
  72. ath79_register_gpio_keys_polled(-1, PQI_AIR_PEN_KEYS_POLL_INTERVAL,
  73. ARRAY_SIZE(pqi_air_pen_gpio_keys),
  74. pqi_air_pen_gpio_keys);
  75. /* enable usb */
  76. ath79_register_usb();
  77. /* register eth0 as LAN */
  78. ath79_init_mac(ath79_eth0_data.mac_addr, art + PQI_AIR_PEN_LAN_MAC_OFFSET, 0);
  79. ath79_register_mdio(0, 0x0);
  80. ath79_register_eth(0);
  81. }
  82. MIPS_MACHINE(ATH79_MACH_PQI_AIR_PEN, "PQI-AIR-PEN", "PQI Air Pen",pqi_air_pen_setup);