| 1002 | } |
| 1003 | |
| 1004 | static void sdio_irq_thread(void *param) |
| 1005 | { |
| 1006 | rt_int32_t i, ret; |
| 1007 | rt_uint8_t pending; |
| 1008 | struct rt_mmcsd_card *card; |
| 1009 | struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)param; |
| 1010 | RT_ASSERT(host != RT_NULL); |
| 1011 | card = host->card; |
| 1012 | RT_ASSERT(card != RT_NULL); |
| 1013 | |
| 1014 | while (1) |
| 1015 | { |
| 1016 | if (rt_sem_take(host->sdio_irq_sem, RT_WAITING_FOREVER) == RT_EOK) |
| 1017 | { |
| 1018 | mmcsd_host_lock(host); |
| 1019 | pending = sdio_io_readb(host->card->sdio_function[0], |
| 1020 | SDIO_REG_CCCR_INT_PEND, &ret); |
| 1021 | if (ret) |
| 1022 | { |
| 1023 | mmcsd_dbg("error %d reading SDIO_REG_CCCR_INT_PEND\n", ret); |
| 1024 | goto out; |
| 1025 | } |
| 1026 | |
| 1027 | for (i = 1; i <= 7; i++) |
| 1028 | { |
| 1029 | if (pending & (1 << i)) |
| 1030 | { |
| 1031 | struct rt_sdio_function *func = card->sdio_function[i]; |
| 1032 | if (!func) |
| 1033 | { |
| 1034 | mmcsd_dbg("pending IRQ for non-existant function\n"); |
| 1035 | goto out; |
| 1036 | } |
| 1037 | else if (func->irq_handler) |
| 1038 | { |
| 1039 | func->irq_handler(func); |
| 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | mmcsd_dbg("pending IRQ with no register handler\n"); |
| 1044 | goto out; |
| 1045 | } |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | out: |
| 1050 | mmcsd_host_unlock(host); |
| 1051 | if (host->flags & MMCSD_SUP_SDIO_IRQ) |
| 1052 | host->ops->enable_sdio_irq(host, 1); |
| 1053 | continue; |
| 1054 | } |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | static rt_int32_t sdio_irq_thread_create(struct rt_mmcsd_card *card) |
| 1059 | { |
nothing calls this directly
no test coverage detected