driver-cairnsmore.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2012 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #include "fpgautils.h"
  10. #include "icarus-common.h"
  11. #include "miner.h"
  12. #define CAIRNSMORE1_IO_SPEED 115200
  13. #define CAIRNSMORE1_HASH_TIME 0.0000000024484
  14. struct device_api cairnsmore_api;
  15. static bool cairnsmore_detect_one(const char *devpath)
  16. {
  17. struct ICARUS_INFO *info = calloc(1, sizeof(struct ICARUS_INFO));
  18. if (unlikely(!info))
  19. quit(1, "Failed to malloc ICARUS_INFO");
  20. info->baud = CAIRNSMORE1_IO_SPEED;
  21. info->work_division = 2;
  22. info->fpga_count = 2;
  23. info->quirk_reopen = false;
  24. info->Hs = CAIRNSMORE1_HASH_TIME;
  25. if (!icarus_detect_custom(devpath, &cairnsmore_api, info)) {
  26. free(info);
  27. return false;
  28. }
  29. return true;
  30. }
  31. static int cairnsmore_detect_auto(void)
  32. {
  33. return
  34. serial_autodetect_udev (cairnsmore_detect_one, "*Cairnsmore1*") ?:
  35. serial_autodetect_devserial(cairnsmore_detect_one, "Cairnsmore1") ?:
  36. serial_autodetect_ftdi (cairnsmore_detect_one, "Cairnsmore1", NULL) ?:
  37. 0;
  38. }
  39. static void cairnsmore_detect()
  40. {
  41. // Actual serial detection is handled by Icarus driver
  42. serial_detect_auto_byname(cairnsmore_api.dname, cairnsmore_detect_one, cairnsmore_detect_auto);
  43. }
  44. void convert_icarus_to_cairnsmore(struct cgpu_info *cm1)
  45. {
  46. struct ICARUS_INFO *info = cm1->cgpu_data;
  47. info->Hs = CAIRNSMORE1_HASH_TIME;
  48. info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
  49. info->read_count = (int)(info->fullnonce * TIME_FACTOR) - 1;
  50. cm1->api = &cairnsmore_api;
  51. renumber_cgpu(cm1);
  52. }
  53. extern struct device_api icarus_api;
  54. __attribute__((constructor(1000)))
  55. static void cairnsmore_api_init()
  56. {
  57. cairnsmore_api = icarus_api;
  58. cairnsmore_api.dname = "cairnsmore";
  59. cairnsmore_api.name = "ECM";
  60. cairnsmore_api.api_detect = cairnsmore_detect;
  61. }