1. Index: sd-as3525.c
  2. ===================================================================
  3. --- sd-as3525.c (revision 27074)
  4. +++ sd-as3525.c (working copy)
  5. @@ -788,6 +786,27 @@
  6.              goto sd_transfer_error;
  7.          }
  8.  
  9. +        static int cur_bus_width = 1;
  10. +        int new_bus_width;
  11. +
  12. +        if (write)
  13. +            new_bus_width = 1; /* 4bit causes write errors somehow, switch back to 1bit for writes */
  14. +        else
  15. +            new_bus_width = 4;
  16. +
  17. +        if (cur_bus_width != new_bus_width) {
  18. +            unsigned long response;
  19. +            cur_bus_width = new_bus_width;
  20. +            /* ACMD6  */
  21. +            if(!send_cmd(drive, SD_SET_BUS_WIDTH, new_bus_width == 1 ? 0 : 2, MCI_ARG|MCI_RESP, &response))
  22. +                goto sd_transfer_error;
  23. +            /* Update controller setting */
  24. +            if (new_bus_width == 1)
  25. +                MCI_CLOCK(drive) &= ~MCI_CLOCK_WIDEBUS;
  26. +            else
  27. +                MCI_CLOCK(drive) |= MCI_CLOCK_WIDEBUS;
  28. +        }
  29. +
  30.          if(!send_cmd(drive, cmd, bank_start, MCI_ARG, NULL))
  31.          {
  32.              ret -= 3*20;