mmc: cmd: add mmc mac command to generate mac from mmc (ethaddr, eth1addr)
This commit is contained in:
parent
c5b92986b5
commit
1fbf0261fc
2 changed files with 55 additions and 0 deletions
|
@ -1288,6 +1288,12 @@ config CMD_MMC_REG
|
||||||
Enable the commands for reading card registers. This is useful
|
Enable the commands for reading card registers. This is useful
|
||||||
mostly for debugging or extracting details from the card.
|
mostly for debugging or extracting details from the card.
|
||||||
|
|
||||||
|
config CMD_MMC_MAC
|
||||||
|
bool "Enable support for creating a mac from the mmc command"
|
||||||
|
depends on CMD_MMC
|
||||||
|
help
|
||||||
|
Enable the commands for creating a mac from the emmc card.
|
||||||
|
|
||||||
config CMD_MMC_RPMB
|
config CMD_MMC_RPMB
|
||||||
bool "Enable support for RPMB in the mmc command"
|
bool "Enable support for RPMB in the mmc command"
|
||||||
depends on SUPPORT_EMMC_RPMB
|
depends on SUPPORT_EMMC_RPMB
|
||||||
|
|
49
cmd/mmc.c
49
cmd/mmc.c
|
@ -1198,6 +1198,49 @@ static int do_mmc_reg(struct cmd_tbl *cmdtp, int flag,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(CMD_MMC_MAC)
|
||||||
|
static int do_mac_mmc(struct cmd_tbl *cmdtp, int flag,
|
||||||
|
int argc, char *const argv[])
|
||||||
|
{
|
||||||
|
struct mmc *mmc;
|
||||||
|
u8 mac[6], mac1[6];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
mmc = init_mmc_device(curr_device, false);
|
||||||
|
u64 cid = ((u64)mmc->cid[2] << 32) | mmc->cid[3];
|
||||||
|
|
||||||
|
mac[0] = (cid >> 40) & 0xfe;
|
||||||
|
mac[1] = (cid >> 32) & 0xff;
|
||||||
|
mac[2] = (cid >> 24) & 0xff;
|
||||||
|
mac[3] = (cid >> 16) & 0xff;
|
||||||
|
mac[4] = (cid >> 8) & 0xff;
|
||||||
|
mac[5] = cid & 0xff;
|
||||||
|
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
mac1[i] = mac[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 5; i >= 0; i--) {
|
||||||
|
if (mac1[i] == 0xFF) {
|
||||||
|
mac1[i] = 0x00;
|
||||||
|
} else {
|
||||||
|
mac1[i] += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("MAC Address for ethaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
printf("MAC Address for eth1addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
mac1[0], mac1[1], mac1[2], mac1[3], mac1[4], mac1[5]);
|
||||||
|
|
||||||
|
eth_env_set_enetaddr("ethaddr", mac);
|
||||||
|
eth_env_set_enetaddr("eth1addr", mac1);
|
||||||
|
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct cmd_tbl cmd_mmc[] = {
|
static struct cmd_tbl cmd_mmc[] = {
|
||||||
U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
|
U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
|
||||||
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
|
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
|
||||||
|
@ -1233,6 +1276,9 @@ static struct cmd_tbl cmd_mmc[] = {
|
||||||
#if CONFIG_IS_ENABLED(CMD_MMC_REG)
|
#if CONFIG_IS_ENABLED(CMD_MMC_REG)
|
||||||
U_BOOT_CMD_MKENT(reg, 5, 0, do_mmc_reg, "", ""),
|
U_BOOT_CMD_MKENT(reg, 5, 0, do_mmc_reg, "", ""),
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_IS_ENABLED(CMD_MMC_MAC)
|
||||||
|
U_BOOT_CMD_MKENT(mac, 1, 0, do_mac_mmc, "", ""),
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
@ -1326,6 +1372,9 @@ U_BOOT_CMD(
|
||||||
" (optionally into [env] variable)\n"
|
" (optionally into [env] variable)\n"
|
||||||
" - reg: cid/csd/dsr/ocr/rca/extcsd\n"
|
" - reg: cid/csd/dsr/ocr/rca/extcsd\n"
|
||||||
" - offset: for cid/csd [0..3], for extcsd [0..511,all]\n"
|
" - offset: for cid/csd [0..3], for extcsd [0..511,all]\n"
|
||||||
|
#endif
|
||||||
|
#if CONFIG_IS_ENABLED(CMD_MMC_MAC)
|
||||||
|
"mmc mac - get the MAC address of the eMMC device\n"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue