mach-dlan-hotspot.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * devolo dLAN Hotspot board support
  3. *
  4. * Copyright (C) 2015 Torsten Schnuis <torsten.schnuis@gik.de>
  5. * Copyright (C) 2015 devolo AG
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/gpio.h>
  12. #include <asm/mach-ath79/ath79.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 DLAN_HOTSPOT_GPIO_LED_WIFI 0
  21. #define DLAN_HOTSPOT_GPIO_BTN_RESET 11
  22. #define DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING 12
  23. #define DLAN_HOTSPOT_GPIO_BTN_WIFI 21
  24. #define DLAN_HOTSPOT_GPIO_PLC_POWER 22
  25. #define DLAN_HOTSPOT_GPIO_PLC_RESET 20
  26. #define DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS 18
  27. #define DLAN_HOTSPOT_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_HOTSPOT_KEYS_POLL_INTERVAL)
  29. #define DLAN_HOTSPOT_ART_ADDRESS 0x1fff0000
  30. #define DLAN_HOTSPOT_CALDATA_OFFSET 0x00001000
  31. #define DLAN_HOTSPOT_MAC_ADDRESS_OFFSET 0x00001002
  32. static struct gpio_led dlan_hotspot_leds_gpio[] __initdata = {
  33. {
  34. .name = "devolo:green:wifi",
  35. .gpio = DLAN_HOTSPOT_GPIO_LED_WIFI,
  36. .active_low = 0,
  37. }
  38. };
  39. static struct gpio_keys_button dlan_hotspot_gpio_keys[] __initdata = {
  40. {
  41. .desc = "Reset button",
  42. .type = EV_KEY,
  43. .code = KEY_RESTART,
  44. .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  45. .gpio = DLAN_HOTSPOT_GPIO_BTN_RESET,
  46. .active_low = 0,
  47. },
  48. {
  49. .desc = "Pairing button",
  50. .type = EV_KEY,
  51. .code = BTN_0,
  52. .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING,
  54. .active_low = 0,
  55. },
  56. {
  57. .desc = "WLAN button",
  58. .type = EV_KEY,
  59. .code = KEY_WPS_BUTTON,
  60. .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
  61. .gpio = DLAN_HOTSPOT_GPIO_BTN_WIFI,
  62. .active_low = 0,
  63. }
  64. };
  65. static void __init dlan_hotspot_setup(void)
  66. {
  67. u8 *art = (u8 *) KSEG1ADDR(DLAN_HOTSPOT_ART_ADDRESS);
  68. u8 *cal = art + DLAN_HOTSPOT_CALDATA_OFFSET;
  69. u8 *wifi_mac = art + DLAN_HOTSPOT_MAC_ADDRESS_OFFSET;
  70. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  71. ath79_setup_ar933x_phy4_switch(false, false);
  72. ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_hotspot_leds_gpio),
  73. dlan_hotspot_leds_gpio);
  74. ath79_register_gpio_keys_polled(-1, DLAN_HOTSPOT_KEYS_POLL_INTERVAL,
  75. ARRAY_SIZE(dlan_hotspot_gpio_keys),
  76. dlan_hotspot_gpio_keys);
  77. gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_POWER,
  78. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  79. "PLC power");
  80. gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_RESET,
  81. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  82. "PLC reset");
  83. gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS,
  84. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  85. "PLC LEDs");
  86. ath79_register_usb();
  87. ath79_register_m25p80(NULL);
  88. ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 1);
  89. ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 2);
  90. ath79_register_mdio(0, 0x0);
  91. ath79_register_eth(0);
  92. ath79_register_eth(1);
  93. ath79_register_wmac(cal, wifi_mac);
  94. }
  95. MIPS_MACHINE(ATH79_MACH_DLAN_HOTSPOT, "dLAN-Hotspot",
  96. "dLAN Hotspot", dlan_hotspot_setup);