以获取fw_version为例,也就是获取ext_CSD[261:254]的值:
kernel/include/linux/mmc/card.h
struct mmc_ext_csd{
+u8 raw_fw_version[8]; /*254 - 8bytes*/
}
kernel/include/linux/mmc/mmc.h
+#define EXT_CSD_FW_VER 254 /* RO 8bytes*/
kernel/drivers/mmc/core/mmc.c
mmc_read_ext_csd()
{
+for(int i=0;i<8;i++)
+card->ext_csd.raw_fw_version[i]=ext_csd[EXT_CSD_FW_VER + i];
}
+MMC_DEV_ATTR(ecsdrev,"%08x%08x%08x%08x%08x%08x%08x%08x",
card->ext_csd.raw_fw_version[0],card->ext_csd.raw_fw_version[1],card->ext_csd.raw_fw_version[2],card->ext_csd.raw_fw_version[3], card->ext_csd.raw_fw_version[4],card->ext_csd.raw_fw_version[5],card->ext_csd.raw_fw_version[6],card->ext_csd.raw_fw_version[7]);
static struct attribute *mmc_std_attrs[] ={
&dev_attr_ecsdrev.attr,
}
添加完成后,可以通过命令来查看:
cat /sys/class/mmc_host/mmc0/mmc0:0001/ecsdrev
cp link https://jingyan.baidu.com/article/86f4a73e98177137d652699a.html