| 1184 | } |
| 1185 | |
| 1186 | rt_int32_t sdio_enable_func(struct rt_sdio_function *func) |
| 1187 | { |
| 1188 | rt_int32_t ret; |
| 1189 | rt_uint8_t reg; |
| 1190 | rt_uint32_t timeout; |
| 1191 | struct rt_sdio_function *func0; |
| 1192 | |
| 1193 | RT_ASSERT(func != RT_NULL); |
| 1194 | RT_ASSERT(func->card != RT_NULL); |
| 1195 | |
| 1196 | func0 = func->card->sdio_function[0]; |
| 1197 | |
| 1198 | mmcsd_dbg("SDIO: enabling function %d\n", func->num); |
| 1199 | |
| 1200 | reg = sdio_io_readb(func0, SDIO_REG_CCCR_IO_EN, &ret); |
| 1201 | if (ret) |
| 1202 | goto err; |
| 1203 | |
| 1204 | reg |= 1 << func->num; |
| 1205 | |
| 1206 | ret = sdio_io_writeb(func0, SDIO_REG_CCCR_IO_EN, reg); |
| 1207 | if (ret) |
| 1208 | goto err; |
| 1209 | |
| 1210 | timeout = rt_tick_get() + func->enable_timeout_val * RT_TICK_PER_SECOND / 1000; |
| 1211 | |
| 1212 | while (1) |
| 1213 | { |
| 1214 | reg = sdio_io_readb(func0, SDIO_REG_CCCR_IO_RDY, &ret); |
| 1215 | if (ret) |
| 1216 | goto err; |
| 1217 | if (reg & (1 << func->num)) |
| 1218 | break; |
| 1219 | ret = -RT_ETIMEOUT; |
| 1220 | if (rt_tick_get() > timeout) |
| 1221 | goto err; |
| 1222 | } |
| 1223 | |
| 1224 | mmcsd_dbg("SDIO: enabled function successfull\n"); |
| 1225 | |
| 1226 | return 0; |
| 1227 | |
| 1228 | err: |
| 1229 | mmcsd_dbg("SDIO: failed to enable function %d\n", func->num); |
| 1230 | return ret; |
| 1231 | } |
| 1232 | |
| 1233 | rt_int32_t sdio_disable_func(struct rt_sdio_function *func) |
| 1234 | { |
nothing calls this directly
no test coverage detected