| 1098 | } |
| 1099 | |
| 1100 | rt_int32_t sdio_attach_irq(struct rt_sdio_function *func, |
| 1101 | rt_sdio_irq_handler_t *handler) |
| 1102 | { |
| 1103 | rt_int32_t ret; |
| 1104 | rt_uint8_t reg; |
| 1105 | struct rt_sdio_function *func0; |
| 1106 | |
| 1107 | RT_ASSERT(func != RT_NULL); |
| 1108 | RT_ASSERT(func->card != RT_NULL); |
| 1109 | |
| 1110 | func0 = func->card->sdio_function[0]; |
| 1111 | |
| 1112 | mmcsd_dbg("SDIO: enabling IRQ for function %d\n", func->num); |
| 1113 | |
| 1114 | if (func->irq_handler) |
| 1115 | { |
| 1116 | mmcsd_dbg("SDIO: IRQ for already in use.\n"); |
| 1117 | |
| 1118 | return -RT_EBUSY; |
| 1119 | } |
| 1120 | |
| 1121 | reg = sdio_io_readb(func0, SDIO_REG_CCCR_INT_EN, &ret); |
| 1122 | if (ret) |
| 1123 | return ret; |
| 1124 | |
| 1125 | reg |= 1 << func->num; |
| 1126 | |
| 1127 | reg |= 1; /* Master interrupt enable */ |
| 1128 | |
| 1129 | ret = sdio_io_writeb(func0, SDIO_REG_CCCR_INT_EN, reg); |
| 1130 | if (ret) |
| 1131 | return ret; |
| 1132 | |
| 1133 | func->irq_handler = handler; |
| 1134 | |
| 1135 | ret = sdio_irq_thread_create(func->card); |
| 1136 | if (ret) |
| 1137 | func->irq_handler = RT_NULL; |
| 1138 | |
| 1139 | return ret; |
| 1140 | } |
| 1141 | |
| 1142 | rt_int32_t sdio_detach_irq(struct rt_sdio_function *func) |
| 1143 | { |
nothing calls this directly
no test coverage detected