2
0

mach-antminer-s3.c 2.5 KB

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