@@ -151,17 +151,19 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
151151
152152 cmd .opcode = MMC_APP_CMD ;
153153 cmd .arg = card -> rca << 16 ;
154- cmd .flags = MMC_RSP_R1 | MMC_CMD_AC ;
154+ cmd .flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC ;
155155
156156 err = mmc_wait_for_cmd (card -> host , & cmd , 0 );
157- if (err || !(cmd .resp [0 ] & R1_APP_CMD ))
157+ if (err )
158+ return (u32 )- 1 ;
159+ if (!mmc_host_is_spi (card -> host ) && !(cmd .resp [0 ] & R1_APP_CMD ))
158160 return (u32 )- 1 ;
159161
160162 memset (& cmd , 0 , sizeof (struct mmc_command ));
161163
162164 cmd .opcode = SD_APP_SEND_NUM_WR_BLKS ;
163165 cmd .arg = 0 ;
164- cmd .flags = MMC_RSP_R1 | MMC_CMD_ADTC ;
166+ cmd .flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC ;
165167
166168 memset (& data , 0 , sizeof (struct mmc_data ));
167169
@@ -220,11 +222,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
220222 brq .cmd .arg = req -> sector ;
221223 if (!mmc_card_blockaddr (card ))
222224 brq .cmd .arg <<= 9 ;
223- brq .cmd .flags = MMC_RSP_R1 | MMC_CMD_ADTC ;
225+ brq .cmd .flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC ;
224226 brq .data .blksz = 1 << md -> block_bits ;
225227 brq .stop .opcode = MMC_STOP_TRANSMISSION ;
226228 brq .stop .arg = 0 ;
227- brq .stop .flags = MMC_RSP_R1B | MMC_CMD_AC ;
229+ brq .stop .flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC ;
228230 brq .data .blocks = req -> nr_sectors >> (md -> block_bits - 9 );
229231 if (brq .data .blocks > card -> host -> max_blk_count )
230232 brq .data .blocks = card -> host -> max_blk_count ;
@@ -241,7 +243,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
241243 brq .data .blocks = 1 ;
242244
243245 if (brq .data .blocks > 1 ) {
244- brq .mrq .stop = & brq .stop ;
246+ /* SPI multiblock writes terminate using a special
247+ * token, not a STOP_TRANSMISSION request.
248+ */
249+ if (!mmc_host_is_spi (card -> host )
250+ || rq_data_dir (req ) == READ )
251+ brq .mrq .stop = & brq .stop ;
245252 readcmd = MMC_READ_MULTIPLE_BLOCK ;
246253 writecmd = MMC_WRITE_MULTIPLE_BLOCK ;
247254 } else {
@@ -301,7 +308,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
301308 goto cmd_err ;
302309 }
303310
304- if (rq_data_dir (req ) != READ ) {
311+ if (! mmc_host_is_spi ( card -> host ) && rq_data_dir (req ) != READ ) {
305312 do {
306313 int err ;
307314
@@ -509,7 +516,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
509516 mmc_claim_host (card -> host );
510517 cmd .opcode = MMC_SET_BLOCKLEN ;
511518 cmd .arg = 1 << md -> block_bits ;
512- cmd .flags = MMC_RSP_R1 | MMC_CMD_AC ;
519+ cmd .flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC ;
513520 err = mmc_wait_for_cmd (card -> host , & cmd , 5 );
514521 mmc_release_host (card -> host );
515522
0 commit comments