driver-cairnsmore.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // This is a general ballpark
  14. #define CAIRNSMORE1_HASH_TIME 0.0000000024484
  15. struct device_api cairnsmore_api;
  16. static bool cairnsmore_detect_one(const char *devpath)
  17. {
  18. struct ICARUS_INFO *info = calloc(1, sizeof(struct ICARUS_INFO));
  19. if (unlikely(!info))
  20. quit(1, "Failed to malloc ICARUS_INFO");
  21. info->baud = CAIRNSMORE1_IO_SPEED;
  22. info->work_division = 2;
  23. info->fpga_count = 2;
  24. info->quirk_reopen = false;
  25. info->Hs = CAIRNSMORE1_HASH_TIME;
  26. info->timing_mode = MODE_SHORT;
  27. info->do_icarus_timing = true;
  28. if (!icarus_detect_custom(devpath, &cairnsmore_api, info)) {
  29. free(info);
  30. return false;
  31. }
  32. return true;
  33. }
  34. static int cairnsmore_detect_auto(void)
  35. {
  36. return
  37. serial_autodetect_udev (cairnsmore_detect_one, "*Cairnsmore1*") ?:
  38. serial_autodetect_devserial(cairnsmore_detect_one, "Cairnsmore1") ?:
  39. serial_autodetect_ftdi (cairnsmore_detect_one, "Cairnsmore1", NULL) ?:
  40. 0;
  41. }
  42. static void cairnsmore_detect()
  43. {
  44. // Actual serial detection is handled by Icarus driver
  45. serial_detect_auto_byname(cairnsmore_api.dname, cairnsmore_detect_one, cairnsmore_detect_auto);
  46. }
  47. void convert_icarus_to_cairnsmore(struct cgpu_info *cm1)
  48. {
  49. struct ICARUS_INFO *info = cm1->cgpu_data;
  50. info->Hs = CAIRNSMORE1_HASH_TIME;
  51. info->fullnonce = info->Hs * (((double)0xffffffff) + 1);
  52. info->timing_mode = MODE_SHORT;
  53. info->do_icarus_timing = true;
  54. cm1->api = &cairnsmore_api;
  55. renumber_cgpu(cm1);
  56. }
  57. extern struct device_api icarus_api;
  58. __attribute__((constructor(1000)))
  59. static void cairnsmore_api_init()
  60. {
  61. cairnsmore_api = icarus_api;
  62. cairnsmore_api.dname = "cairnsmore";
  63. cairnsmore_api.name = "ECM";
  64. cairnsmore_api.api_detect = cairnsmore_detect;
  65. }