| 346 | |
| 347 | |
| 348 | rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, |
| 349 | struct rt_mmcsd_card *card, |
| 350 | struct rt_mmcsd_cmd *cmd, |
| 351 | int retry) |
| 352 | { |
| 353 | struct rt_mmcsd_req req; |
| 354 | int i; |
| 355 | rt_err_t err; |
| 356 | |
| 357 | err = -RT_ERROR; |
| 358 | |
| 359 | /* |
| 360 | * We have to resend MMC_APP_CMD for each attempt so |
| 361 | * we cannot use the retries field in mmc_command. |
| 362 | */ |
| 363 | for (i = 0; i <= retry; i++) |
| 364 | { |
| 365 | rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); |
| 366 | |
| 367 | err = mmcsd_app_cmd(host, card); |
| 368 | if (err) |
| 369 | { |
| 370 | /* no point in retrying; no APP commands allowed */ |
| 371 | if (controller_is_spi(host)) |
| 372 | { |
| 373 | if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) |
| 374 | break; |
| 375 | } |
| 376 | continue; |
| 377 | } |
| 378 | |
| 379 | rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); |
| 380 | |
| 381 | rt_memset(cmd->resp, 0, sizeof(cmd->resp)); |
| 382 | |
| 383 | req.cmd = cmd; |
| 384 | //cmd->data = NULL; |
| 385 | |
| 386 | mmcsd_send_request(host, &req); |
| 387 | |
| 388 | err = cmd->err; |
| 389 | if (!cmd->err) |
| 390 | break; |
| 391 | |
| 392 | /* no point in retrying illegal APP commands */ |
| 393 | if (controller_is_spi(host)) |
| 394 | { |
| 395 | if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) |
| 396 | break; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | return err; |
| 401 | } |
| 402 | |
| 403 | rt_err_t mmcsd_app_set_bus_width(struct rt_mmcsd_card *card, rt_int32_t width) |
| 404 | { |
no test coverage detected