Lines Matching +full:class +full:- +full:rev
4 * SPDX-License-Identifier: Apache-2.0
45 #define MMC_REL_ADR_ARG (card->relative_addr << 16U)
110 if (card->host_props.is_spi) { in mmc_card_init()
111 return -EINVAL; in mmc_card_init()
122 card->type = CARD_MMC; in mmc_card_init()
125 if (card->host_props.host_caps.vol_180_support) { in mmc_card_init()
128 if (card->host_props.host_caps.vol_330_support || in mmc_card_init()
129 card->host_props.host_caps.vol_300_support) { in mmc_card_init()
219 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_send_op_cond()
233 return -ETIMEDOUT; in mmc_send_op_cond()
238 card->flags |= SD_1800MV_FLAG; in mmc_send_op_cond()
241 card->flags |= SD_3000MV_FLAG; in mmc_send_op_cond()
245 if (card->host_props.host_caps.vol_180_support && (card->flags & SD_1800MV_FLAG)) { in mmc_send_op_cond()
246 card->bus_io.signal_voltage = SD_VOL_1_8_V; in mmc_send_op_cond()
247 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_send_op_cond()
254 card->card_voltage = SD_VOL_1_8_V; in mmc_send_op_cond()
260 card->flags |= SD_HIGH_CAPACITY_FLAG; in mmc_send_op_cond()
276 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_rca()
285 card->relative_addr = CONFIG_MMC_RCA; in mmc_set_rca()
300 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_read_csd()
307 if (card_csd->csd_structure < 2) { in mmc_read_csd()
309 return -ENOTSUP; in mmc_read_csd()
317 csd->csd_structure = (uint8_t)((raw_csd[3U] & 0xC0000000U) >> 30U); in mmc_decode_csd()
318 csd->read_time1 = (uint8_t)((raw_csd[3U] & 0xFF0000U) >> 16U); in mmc_decode_csd()
319 csd->read_time2 = (uint8_t)((raw_csd[3U] & 0xFF00U) >> 8U); in mmc_decode_csd()
320 csd->xfer_rate = (uint8_t)(raw_csd[3U] & 0xFFU); in mmc_decode_csd()
321 csd->cmd_class = (uint16_t)((raw_csd[2U] & 0xFFF00000U) >> 20U); in mmc_decode_csd()
322 csd->read_blk_len = (uint8_t)((raw_csd[2U] & 0xF0000U) >> 16U); in mmc_decode_csd()
324 csd->flags |= SD_CSD_READ_BLK_PARTIAL_FLAG; in mmc_decode_csd()
327 csd->flags |= SD_CSD_READ_BLK_PARTIAL_FLAG; in mmc_decode_csd()
330 csd->flags |= SD_CSD_READ_BLK_MISALIGN_FLAG; in mmc_decode_csd()
333 csd->flags |= SD_CSD_DSR_IMPLEMENTED_FLAG; in mmc_decode_csd()
335 csd->device_size = in mmc_decode_csd()
337 csd->read_current_min = (uint8_t)((raw_csd[1U] & 0x38000000U) >> 27U); in mmc_decode_csd()
338 csd->read_current_max = (uint8_t)((raw_csd[1U] & 0x07000000U) >> 24U); in mmc_decode_csd()
339 csd->write_current_min = (uint8_t)((raw_csd[1U] & 0x00E00000U) >> 21U); in mmc_decode_csd()
340 csd->write_current_max = (uint8_t)((raw_csd[1U] & 0x001C0000U) >> 18U); in mmc_decode_csd()
341 csd->dev_size_mul = (uint8_t)((raw_csd[1U] & 0x00038000U) >> 15U); in mmc_decode_csd()
342 csd->erase_size = (uint8_t)((raw_csd[1U] & 0x00007C00U) >> 10U); in mmc_decode_csd()
343 csd->write_prtect_size = (uint8_t)(raw_csd[1U] & 0x0000001FU); in mmc_decode_csd()
344 csd->write_speed_factor = (uint8_t)((raw_csd[0U] & 0x1C000000U) >> 26U); in mmc_decode_csd()
345 csd->write_blk_len = (uint8_t)((raw_csd[0U] & 0x03C00000U) >> 22U); in mmc_decode_csd()
346 csd->file_fmt = (uint8_t)((raw_csd[0U] & 0x00000C00U) >> 10U); in mmc_decode_csd()
352 enum mmc_csd_freq frequency_code = (card_csd->xfer_rate & 0x7); in mmc_set_max_freq()
353 enum mmc_csd_freq multiplier_code = (card_csd->xfer_rate & 0x78); in mmc_set_max_freq()
355 /* 4.3 - 5.1 emmc spec says 26 MHz */ in mmc_set_max_freq()
357 card->bus_io.clock = 26000000U; in mmc_set_max_freq()
358 card->bus_io.timing = SDHC_TIMING_LEGACY; in mmc_set_max_freq()
360 /* 4.0 - 4.2 emmc spec says 20 MHz */ in mmc_set_max_freq()
362 card->bus_io.clock = 20000000U; in mmc_set_max_freq()
363 card->bus_io.timing = SDHC_TIMING_LEGACY; in mmc_set_max_freq()
369 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_set_max_freq()
383 if (card->host_props.host_caps.bus_8_bit_support && card->bus_width == 8) { in mmc_set_bus_width()
385 card->bus_io.bus_width = SDHC_BUS_WIDTH8BIT; in mmc_set_bus_width()
386 } else if (card->host_props.host_caps.bus_4_bit_support && card->bus_width >= 4) { in mmc_set_bus_width()
388 card->bus_io.bus_width = SDHC_BUS_WIDTH4BIT; in mmc_set_bus_width()
398 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_bus_width()
406 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_set_bus_width()
425 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_hs_timing()
433 card->bus_io.clock = MMC_CLOCK_52MHZ; in mmc_set_hs_timing()
434 card->bus_io.timing = SDHC_TIMING_HS; in mmc_set_hs_timing()
436 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_set_hs_timing()
450 cmd.arg = ((MMC_SWITCH_PWR_CLASS_ARG) | (ext->pwr_class_200MHZ_VCCQ195 << 8)); in mmc_set_power_class_HS200()
453 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_power_class_HS200()
464 if ((ext->device_type.MMC_HS200_SDR_1200MV || ext->device_type.MMC_HS200_SDR_1800MV) && in mmc_set_timing()
465 (card->host_props.host_caps.hs200_support) && in mmc_set_timing()
466 (card->bus_io.signal_voltage == SD_VOL_1_8_V) && in mmc_set_timing()
467 (card->bus_io.bus_width >= SDHC_BUS_WIDTH4BIT)) { in mmc_set_timing()
473 card->bus_io.clock = MMC_CLOCK_HS200; in mmc_set_timing()
474 card->bus_io.timing = SDHC_TIMING_HS200; in mmc_set_timing()
475 } else if (ext->device_type.MMC_HS_52_DV) { in mmc_set_timing()
477 } else if (ext->device_type.MMC_HS_26_DV) { in mmc_set_timing()
481 return -ENOTSUP; in mmc_set_timing()
488 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_timing()
497 card->card_speed = ((cmd.arg & 0xFF << 8) >> 8); in mmc_set_timing()
499 /* Set power class to match timing mode */ in mmc_set_timing()
500 if (card->card_speed == MMC_HS200_TIMING) { in mmc_set_timing()
508 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_set_timing()
514 if (card->card_speed == MMC_HS200_TIMING) { in mmc_set_timing()
515 ret = sdhc_execute_tuning(card->sdhc); in mmc_set_timing()
523 if ((ext->device_type.MMC_HS400_DDR_1200MV || ext->device_type.MMC_HS400_DDR_1800MV) && in mmc_set_timing()
524 (card->host_props.host_caps.hs400_support) && in mmc_set_timing()
525 (card->bus_io.bus_width == SDHC_BUS_WIDTH8BIT)) { in mmc_set_timing()
537 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_timing()
548 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_timing()
558 card->bus_io.clock = MMC_CLOCK_HS400; in mmc_set_timing()
559 card->bus_io.timing = SDHC_TIMING_HS400; in mmc_set_timing()
560 ret = sdhc_set_io(card->sdhc, &card->bus_io); in mmc_set_timing()
564 card->card_speed = ((cmd.arg & 0xFF << 8) >> 8); in mmc_set_timing()
582 data.data = card->card_buffer; in mmc_read_ext_csd()
585 ret = sdhc_request(card->sdhc, &cmd, &data); in mmc_read_ext_csd()
591 mmc_decode_ext_csd(card_ext_csd, card->card_buffer); in mmc_read_ext_csd()
592 card->block_count = card_ext_csd->sec_count; in mmc_read_ext_csd()
593 card->block_size = SDMMC_DEFAULT_BLOCK_SIZE; in mmc_read_ext_csd()
595 LOG_INF("Card block count is %d, block size is %d", card->block_count, card->block_size); in mmc_read_ext_csd()
602 ext->sec_count = in mmc_decode_ext_csd()
604 ext->bus_width = raw[183U]; in mmc_decode_ext_csd()
605 ext->hs_timing = raw[185U]; in mmc_decode_ext_csd()
606 ext->device_type.MMC_HS400_DDR_1200MV = ((1 << 7U) & raw[196U]); in mmc_decode_ext_csd()
607 ext->device_type.MMC_HS400_DDR_1800MV = ((1 << 6U) & raw[196U]); in mmc_decode_ext_csd()
608 ext->device_type.MMC_HS200_SDR_1200MV = ((1 << 5U) & raw[196U]); in mmc_decode_ext_csd()
609 ext->device_type.MMC_HS200_SDR_1800MV = ((1 << 4U) & raw[196U]); in mmc_decode_ext_csd()
610 ext->device_type.MMC_HS_DDR_1200MV = ((1 << 3U) & raw[196U]); in mmc_decode_ext_csd()
611 ext->device_type.MMC_HS_DDR_1800MV = ((1 << 2U) & raw[196U]); in mmc_decode_ext_csd()
612 ext->device_type.MMC_HS_52_DV = ((1 << 1U) & raw[196U]); in mmc_decode_ext_csd()
613 ext->device_type.MMC_HS_26_DV = ((1 << 0U) & raw[196U]); in mmc_decode_ext_csd()
614 ext->rev = raw[192U]; in mmc_decode_ext_csd()
615 ext->power_class = (raw[187] & 0x0F); in mmc_decode_ext_csd()
616 ext->mmc_driver_strengths = raw[197U]; in mmc_decode_ext_csd()
617 ext->pwr_class_200MHZ_VCCQ195 = raw[237U]; in mmc_decode_ext_csd()
618 ext->cache_size = in mmc_decode_ext_csd()
628 if (card_ext_csd->cache_size == 0) { in mmc_set_cache()
636 ret = sdhc_request(card->sdhc, &cmd, NULL); in mmc_set_cache()