Date: Sat, 19 Jun 2021 17:06:59 GMT From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 6506efea63f5 - main - mmccam: Read the common members of CSD v1.0 and v2.0 Message-ID: <202106191706.15JH6xJI013572@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=6506efea63f5a52d62ceea4bc18b8faf8a037ff3 commit 6506efea63f5a52d62ceea4bc18b8faf8a037ff3 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2021-06-17 16:11:04 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2021-06-19 17:06:54 +0000 mmccam: Read the common members of CSD v1.0 and v2.0 And only get the differents ones based on the version. No functional changes intented. Sponsored by: Diablotin Systems --- sys/cam/mmc/mmc_da.c | 63 +++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c index 8deba8ccfaff..e41792dcebc1 100644 --- a/sys/cam/mmc/mmc_da.c +++ b/sys/cam/mmc/mmc_da.c @@ -284,20 +284,30 @@ mmc_decode_csd_sd(uint32_t *raw_csd, struct mmc_csd *csd) memset(csd, 0, sizeof(*csd)); csd->csd_structure = v = mmc_get_bits(raw_csd, 128, 126, 2); + + /* Common members between 1.0 and 2.0 */ + m = mmc_get_bits(raw_csd, 128, 115, 4); + e = mmc_get_bits(raw_csd, 128, 112, 3); + csd->tacc = (exp[e] * mant[m] + 9) / 10; + csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 128, 99, 4); + e = mmc_get_bits(raw_csd, 128, 96, 3); + csd->tran_speed = exp[e] * 10000 * mant[m]; + csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12); + csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4); + csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1); + csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1); + csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1); + csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1); + csd->erase_blk_en = mmc_get_bits(raw_csd, 128, 46, 1); + csd->erase_sector = mmc_get_bits(raw_csd, 128, 39, 7) + 1; + csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 7); + csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1); + csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3); + csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4); + csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1); + if (v == 0) { - m = mmc_get_bits(raw_csd, 128, 115, 4); - e = mmc_get_bits(raw_csd, 128, 112, 3); - csd->tacc = (exp[e] * mant[m] + 9) / 10; - csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100; - m = mmc_get_bits(raw_csd, 128, 99, 4); - e = mmc_get_bits(raw_csd, 128, 96, 3); - csd->tran_speed = exp[e] * 10000 * mant[m]; - csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12); - csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4); - csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1); - csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1); - csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1); - csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1); csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 59, 3)]; csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 128, 56, 3)]; csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 53, 3)]; @@ -305,36 +315,9 @@ mmc_decode_csd_sd(uint32_t *raw_csd, struct mmc_csd *csd) m = mmc_get_bits(raw_csd, 128, 62, 12); e = mmc_get_bits(raw_csd, 128, 47, 3); csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len; - csd->erase_blk_en = mmc_get_bits(raw_csd, 128, 46, 1); - csd->erase_sector = mmc_get_bits(raw_csd, 128, 39, 7) + 1; - csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 7); - csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1); - csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3); - csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4); - csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1); } else if (v == 1) { - m = mmc_get_bits(raw_csd, 128, 115, 4); - e = mmc_get_bits(raw_csd, 128, 112, 3); - csd->tacc = (exp[e] * mant[m] + 9) / 10; - csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100; - m = mmc_get_bits(raw_csd, 128, 99, 4); - e = mmc_get_bits(raw_csd, 128, 96, 3); - csd->tran_speed = exp[e] * 10000 * mant[m]; - csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12); - csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4); - csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1); - csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1); - csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1); - csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1); csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 128, 48, 22) + 1) * 512 * 1024; - csd->erase_blk_en = mmc_get_bits(raw_csd, 128, 46, 1); - csd->erase_sector = mmc_get_bits(raw_csd, 128, 39, 7) + 1; - csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 7); - csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1); - csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3); - csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4); - csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1); } else panic("unknown SD CSD version"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106191706.15JH6xJI013572>