| 623 | } |
| 624 | |
| 625 | void mmcsd_detect(void *param) |
| 626 | { |
| 627 | struct rt_mmcsd_host *host; |
| 628 | rt_uint32_t ocr; |
| 629 | rt_int32_t err; |
| 630 | |
| 631 | while (1) |
| 632 | { |
| 633 | if (rt_mb_recv(&mmcsd_detect_mb, (rt_ubase_t *)&host, RT_WAITING_FOREVER) == RT_EOK) |
| 634 | { |
| 635 | if (host->card == RT_NULL) |
| 636 | { |
| 637 | mmcsd_host_lock(host); |
| 638 | mmcsd_power_up(host); |
| 639 | mmcsd_go_idle(host); |
| 640 | |
| 641 | mmcsd_send_if_cond(host, host->valid_ocr); |
| 642 | |
| 643 | err = sdio_io_send_op_cond(host, 0, &ocr); |
| 644 | if (!err) |
| 645 | { |
| 646 | if (init_sdio(host, ocr)) |
| 647 | mmcsd_power_off(host); |
| 648 | mmcsd_host_unlock(host); |
| 649 | continue; |
| 650 | } |
| 651 | |
| 652 | /* |
| 653 | * detect SD card |
| 654 | */ |
| 655 | err = mmcsd_send_app_op_cond(host, 0, &ocr); |
| 656 | if (!err) |
| 657 | { |
| 658 | if (init_sd(host, ocr)) |
| 659 | mmcsd_power_off(host); |
| 660 | mmcsd_host_unlock(host); |
| 661 | rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host); |
| 662 | continue; |
| 663 | } |
| 664 | |
| 665 | /* |
| 666 | * detect mmc card |
| 667 | */ |
| 668 | err = mmc_send_op_cond(host, 0, &ocr); |
| 669 | if (!err) |
| 670 | { |
| 671 | if (init_mmc(host, ocr)) |
| 672 | mmcsd_power_off(host); |
| 673 | mmcsd_host_unlock(host); |
| 674 | rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host); |
| 675 | continue; |
| 676 | } |
| 677 | mmcsd_host_unlock(host); |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | /* card removed */ |
| 682 | mmcsd_host_lock(host); |
nothing calls this directly
no test coverage detected