mach-tellstick-znet-lite.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Telldus TellStick ZNet Lite board support
  3. *
  4. * Copyright (C) 2016 Micke Prag <micke.prag@telldus.se>
  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 <asm/mach-ath79/ar71xx_regs.h>
  13. #include "common.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define TELLSTICK_GPIO_LED_SYSTEM 27
  22. #define TELLSTICK_GPIO_LED_BLUE 0
  23. #define TELLSTICK_GPIO_LED_RED 14
  24. #define TELLSTICK_GPIO_LED_GREEN 15
  25. #define TELLSTICK_GPIO_LED_LAN_GREEN 16
  26. #define TELLSTICK_GPIO_LED_LAN_ORANGE 17
  27. #define TELLSTICK_GPIO_BTN_RESET 11
  28. #define TELLSTICK_GPIO_RF433_RESET 13
  29. #define TELLSTICK_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TELLSTICK_KEYS_DEBOUNCE_INTERVAL (3 * TELLSTICK_KEYS_POLL_INTERVAL)
  31. static const char *tellstick_part_probes[] = {
  32. "tp-link",
  33. NULL,
  34. };
  35. static struct flash_platform_data tellstick_flash_data = {
  36. .part_probes = tellstick_part_probes,
  37. };
  38. static struct gpio_led tellstick_leds_gpio[] __initdata = {
  39. {
  40. .name = "tellstick:white:system",
  41. .gpio = TELLSTICK_GPIO_LED_SYSTEM,
  42. .active_low = 0,
  43. },
  44. {
  45. .name = "tellstick:blue:status",
  46. .gpio = TELLSTICK_GPIO_LED_BLUE,
  47. .active_low = 0,
  48. },
  49. {
  50. .name = "tellstick:red:status",
  51. .gpio = TELLSTICK_GPIO_LED_RED,
  52. .active_low = 0,
  53. },
  54. {
  55. .name = "tellstick:green:status",
  56. .gpio = TELLSTICK_GPIO_LED_GREEN,
  57. .active_low = 0,
  58. },
  59. {
  60. .name = "tellstick:green:lan",
  61. .gpio = TELLSTICK_GPIO_LED_LAN_GREEN,
  62. .active_low = 0,
  63. },
  64. {
  65. .name = "tellstick:orange:lan",
  66. .gpio = TELLSTICK_GPIO_LED_LAN_ORANGE,
  67. .active_low = 0,
  68. },
  69. };
  70. static struct gpio_keys_button tellstick_gpio_keys[] __initdata = {
  71. {
  72. .desc = "reset",
  73. .type = EV_KEY,
  74. .code = KEY_RESTART,
  75. .debounce_interval = TELLSTICK_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = TELLSTICK_GPIO_BTN_RESET,
  77. .active_low = 0,
  78. }
  79. };
  80. static void __init tellstick_znet_lite_setup(void)
  81. {
  82. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  83. u8 mac[ETH_ALEN];
  84. memcpy(&mac, (u8 *) KSEG1ADDR(0x1f01fc00), sizeof(mac));
  85. ath79_gpio_function_disable(
  86. AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  87. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  88. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  89. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  90. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
  91. );
  92. ath79_register_m25p80(&tellstick_flash_data);
  93. ath79_register_leds_gpio(-1, ARRAY_SIZE(tellstick_leds_gpio),
  94. tellstick_leds_gpio);
  95. ath79_register_gpio_keys_polled(-1, TELLSTICK_KEYS_POLL_INTERVAL,
  96. ARRAY_SIZE(tellstick_gpio_keys),
  97. tellstick_gpio_keys);
  98. gpio_request_one(TELLSTICK_GPIO_RF433_RESET,
  99. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  100. "rf433 reset");
  101. ath79_register_usb();
  102. ath79_init_mac(ath79_eth0_data.mac_addr, (u8 *)mac, 0);
  103. ath79_register_mdio(0, 0x0);
  104. ath79_register_eth(0);
  105. // wlan0 mac needs to be different then eth0
  106. mac[3] += 1;
  107. ath79_register_wmac(ee, (u8 *)mac);
  108. }
  109. MIPS_MACHINE(ATH79_MACH_TELLSTICK_ZNET_LITE, "TELLSTICK-ZNET-LITE", "Telldus TellStick ZNet Lite",
  110. tellstick_znet_lite_setup);