mach-antminer-s3.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Bitmain Antminer S3 board support
  3. *
  4. * Copyright (C) 2015 L. D. Pinney <ldpinney@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 <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-wmac.h"
  19. #include "machtypes.h"
  20. #include "dev-usb.h"
  21. #define ANTMINER_S3_GPIO_LED_WLAN 0
  22. #define ANTMINER_S3_GPIO_LED_SYSTEM 17
  23. #define ANTMINER_S3_GPIO_LED_LAN 22
  24. #define ANTMINER_S3_GPIO_USB_POWER 26
  25. #define ANTMINER_S3_GPIO_BTN_RESET 11
  26. #define ANTMINER_S3_KEYSPOLL_INTERVAL 88 /* msecs */
  27. #define ANTMINER_S3_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S3_KEYSPOLL_INTERVAL)
  28. static const char *ANTMINER_S3_part_probes[] = {
  29. "tp-link",
  30. NULL,
  31. };
  32. static struct flash_platform_data ANTMINER_S3_flash_data = {
  33. .part_probes = ANTMINER_S3_part_probes,
  34. };
  35. static struct gpio_led ANTMINER_S3_leds_gpio[] __initdata = {
  36. {
  37. .name = "antminer-s3:green:wlan",
  38. .gpio = ANTMINER_S3_GPIO_LED_WLAN,
  39. .active_low = 0,
  40. },{
  41. .name = "antminer-s3:green:system",
  42. .gpio = ANTMINER_S3_GPIO_LED_SYSTEM,
  43. .active_low = 0,
  44. },{
  45. .name = "antminer-s3:yellow:lan",
  46. .gpio = ANTMINER_S3_GPIO_LED_LAN,
  47. .active_low = 0,
  48. },
  49. };
  50. static struct gpio_keys_button ANTMINER_S3_GPIO_keys[] __initdata = {
  51. {
  52. .desc = "reset",
  53. .type = EV_KEY,
  54. .code = KEY_RESTART,
  55. .debounce_interval = ANTMINER_S3_KEYSDEBOUNCE_INTERVAL,
  56. .gpio = ANTMINER_S3_GPIO_BTN_RESET,
  57. .active_low = 0,
  58. },
  59. };
  60. static void __init antminer_s3_setup(void)
  61. {
  62. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  63. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  64. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  65. ath79_setup_ar933x_phy4_switch(false, false);
  66. ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S3_leds_gpio),
  67. ANTMINER_S3_leds_gpio);
  68. ath79_register_gpio_keys_polled(-1, ANTMINER_S3_KEYSPOLL_INTERVAL,
  69. ARRAY_SIZE(ANTMINER_S3_GPIO_keys),
  70. ANTMINER_S3_GPIO_keys);
  71. gpio_request_one(ANTMINER_S3_GPIO_USB_POWER,
  72. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  73. "USB power");
  74. ath79_register_usb();
  75. ath79_register_m25p80(&ANTMINER_S3_flash_data);
  76. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  77. ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  78. ath79_register_mdio(0, 0x0);
  79. ath79_register_eth(0);
  80. ath79_register_eth(1);
  81. ath79_register_wmac(ee, mac);
  82. }
  83. MIPS_MACHINE(ATH79_MACH_ANTMINER_S3, "ANTMINER-S3",
  84. "Antminer-S3", antminer_s3_setup);