Index: sd-as3525.c =================================================================== --- sd-as3525.c (revision 27074) +++ sd-as3525.c (working copy) @@ -788,6 +786,27 @@ goto sd_transfer_error; } + static int cur_bus_width = 1; + int new_bus_width; + + if (write) + new_bus_width = 1; /* 4bit causes write errors somehow, switch back to 1bit for writes */ + else + new_bus_width = 4; + + if (cur_bus_width != new_bus_width) { + unsigned long response; + cur_bus_width = new_bus_width; + /* ACMD6 */ + if(!send_cmd(drive, SD_SET_BUS_WIDTH, new_bus_width == 1 ? 0 : 2, MCI_ARG|MCI_RESP, &response)) + goto sd_transfer_error; + /* Update controller setting */ + if (new_bus_width == 1) + MCI_CLOCK(drive) &= ~MCI_CLOCK_WIDEBUS; + else + MCI_CLOCK(drive) |= MCI_CLOCK_WIDEBUS; + } + if(!send_cmd(drive, cmd, bank_start, MCI_ARG, NULL)) { ret -= 3*20;