MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sdio_read_cccr

Function sdio_read_cccr

components/drivers/sdio/dev_sdio.c:419–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417}
418
419static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card)
420{
421 rt_int32_t ret;
422 rt_int32_t cccr_version;
423 rt_uint8_t data;
424
425 rt_memset(&card->cccr, 0, sizeof(struct rt_sdio_cccr));
426
427 data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_CCCR_REV, &ret);
428 if (ret)
429 goto out;
430
431 cccr_version = data & 0x0f;
432
433 if (cccr_version > SDIO_CCCR_REV_3_00)
434 {
435 LOG_E("unrecognised CCCR structure version %d", cccr_version);
436
437 return -RT_ERROR;
438 }
439
440 card->cccr.sdio_version = (data & 0xf0) >> 4;
441
442 data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_CARD_CAPS, &ret);
443 if (ret)
444 goto out;
445
446 if (data & SDIO_CCCR_CAP_SMB)
447 card->cccr.multi_block = 1;
448 if (data & SDIO_CCCR_CAP_LSC)
449 card->cccr.low_speed = 1;
450 if (data & SDIO_CCCR_CAP_4BLS)
451 card->cccr.low_speed_4 = 1;
452 if (data & SDIO_CCCR_CAP_4BLS)
453 card->cccr.bus_width = 1;
454
455 if (cccr_version >= SDIO_CCCR_REV_1_10)
456 {
457 data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_POWER_CTRL, &ret);
458 if (ret)
459 goto out;
460
461 if (data & SDIO_POWER_SMPC)
462 card->cccr.power_ctrl = 1;
463 }
464
465 if (cccr_version >= SDIO_CCCR_REV_1_20)
466 {
467 data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_SPEED, &ret);
468 if (ret)
469 goto out;
470
471 if (data & SDIO_SPEED_SHS)
472 card->cccr.high_speed = 1;
473 }
474
475out:
476 return ret;

Callers 1

sdio_init_cardFunction · 0.70

Calls 2

rt_memsetFunction · 0.85
sdio_io_readbFunction · 0.85

Tested by

no test coverage detected