Advertisement
Guest User

Untitled

a guest
Jan 13th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.88 KB | None | 0 0
  1. diff --git a/litesdcard/firmware/sdcard.c b/litesdcard/firmware/sdcard.c
  2. index f819953..4e44d39 100644
  3. --- a/litesdcard/firmware/sdcard.c
  4. +++ b/litesdcard/firmware/sdcard.c
  5. @@ -204,45 +204,13 @@ int sdcard_wait_data_done(void) {
  6.  }
  7.  
  8.  int sdcard_wait_response(void) {
  9. -       int i;
  10. -       int status;
  11. +       int status = sdcard_wait_cmd_done();
  12.  
  13. -#if CSR_DATA_WIDTH == 8
  14. -       unsigned int r;
  15. -
  16. -       status = sdcard_wait_cmd_done();
  17. -
  18. -       // LSB is located at RESPONSE_ADDR + (RESPONSE_SIZE - 1) * 4
  19. -       int offset;
  20. -       for(i=0; i<4; i++) {
  21. -         r = 0;
  22. -         for( j = 0; j < 4; j++ ) {
  23. -           offset = ((CSR_SDCORE_RESPONSE_SIZE - 1) * 4) - j * 4 - i * 16;
  24. -           if( offset >= 0 ) {
  25. -             r |= ((csr_readl(CSR_SDCORE_RESPONSE_ADDR + offset) & 0xFF) << (j * 8));
  26. -           }
  27. -         }
  28. -#ifdef SDCARD_DEBUG
  29. -         printf("%08x ", r);
  30. -#endif
  31. -         sdcard_response[3 - i] = r;  // NOTE: this is "backwards" but sticking with this because it's compatible with CSR32
  32. -       }
  33. -#ifdef SDCARD_DEBUG
  34. -       printf( "\n" );
  35. -#endif
  36. -
  37. -
  38. -#else
  39. -       volatile unsigned int *buffer = (unsigned int *)CSR_SDCORE_RESPONSE_ADDR;
  40. -
  41. -       status = sdcard_wait_cmd_done();
  42. -
  43. -       for(i=0; i<4; i++) {
  44. +       csr_rd_buf_uint32(CSR_SDCORE_RESPONSE_ADDR, sdcard_response, 4);
  45.  #ifdef SDCARD_DEBUG
  46. -               printf("%08x\n", buffer[i]);
  47. -#endif
  48. -               sdcard_response[i] = buffer[i];
  49. -       }
  50. +       printf("sdcard_response = [%08x, %08x, %08x, %08x];\n",
  51. +               sdcard_response[0], sdcard_response[1],
  52. +               sdcard_response[2], sdcard_response[3]);
  53.  #endif
  54.  
  55.         return status;
  56. @@ -657,6 +625,8 @@ int sdcard_init(void) {
  57.         return 0;
  58.  }
  59.  
  60. +#define SD_BLK_TEST_OFFSET 31250001
  61. +
  62.  int sdcard_test(unsigned int loops) {
  63.         unsigned int i;
  64.         unsigned int length;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement