Commit fcde8762 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

fel: [Fixup] Use fel_get_sid_root_key() routine for SID retrieval



The patch also introduces a "sid-register" command for diagnostic
purposes. It allows to use/enforce the workaround method for other
SoCs, to check if there are any inconsistencies with the values
read from memory.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent a3ce5f9f
...@@ -276,58 +276,29 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val) ...@@ -276,58 +276,29 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val)
fel_writel_n(dev, addr, &val, 1); fel_writel_n(dev, addr, &val, 1);
} }
#define EFUSE_PRCTL 0x40 void aw_fel_print_sid(feldev_handle *dev, bool force_workaround)
#define EFUSE_RDKEY 0x60
#define EFUSE_OP_LOCK 0xAC
uint32_t aw_fel_efuse_read(feldev_handle *dev, uint32_t offset)
{ {
uint32_t key[4];
soc_info_t *soc_info = dev->soc_info; soc_info_t *soc_info = dev->soc_info;
uint32_t reg_val;
reg_val = fel_readl(dev, soc_info->sid_base + EFUSE_PRCTL);
reg_val &= ~(((0x1ff) << 16) | 0x3);
reg_val |= (offset << 16);
fel_writel(dev, soc_info->sid_base + EFUSE_PRCTL, reg_val);
reg_val &= ~(((0xff) << 8) | 0x3);
reg_val |= (EFUSE_OP_LOCK << 8) | 0x2;
fel_writel(dev, soc_info->sid_base + EFUSE_PRCTL, reg_val);
while (fel_readl(dev, soc_info->sid_base + EFUSE_PRCTL) & 0x2);
reg_val &= ~(((0x1ff) << 16) | ((0xff) << 8) | 0x3); if (!soc_info->sid_base) {
fel_writel(dev, soc_info->sid_base + EFUSE_PRCTL, reg_val); printf("SID registers for your SoC (%s) are unknown or inaccessible.\n",
dev->soc_name);
return fel_readl(dev, soc_info->sid_base + EFUSE_RDKEY); return;
}
void aw_fel_print_sid(feldev_handle *dev)
{
soc_info_t *soc_info = dev->soc_info;
if (soc_info->sid_base) {
uint32_t sid_addr = soc_info->sid_base + soc_info->sid_offset;
pr_info("SID key (e-fuses) at 0x%08X\n", sid_addr);
if (soc_info->sid_fix) {
pr_info("SID key needs fix due to silicon bug.\n");
for (uint32_t i = 0; i < 0x10; i+=4) {
aw_fel_efuse_read(dev, i);
}
} }
uint32_t key[4]; if (soc_info->sid_fix || force_workaround) {
fel_readl_n(dev, sid_addr, key, 4); pr_info("Read SID key via registers, base = 0x%08X\n",
soc_info->sid_base);
} else {
pr_info("SID key (e-fuses) at 0x%08X\n",
soc_info->sid_base + soc_info->sid_offset);
}
fel_get_sid_root_key(dev, key, force_workaround);
unsigned int i;
/* output SID in "xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx" format */ /* output SID in "xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx" format */
for (i = 0; i <= 3; i++) for (unsigned i = 0; i <= 3; i++)
printf("%08x%c", key[i], i < 3 ? ':' : '\n'); printf("%08x%c", key[i], i < 3 ? ':' : '\n');
} else {
printf("SID registers for your SoC (%s) are unknown or inaccessible.\n",
dev->soc_name);
}
} }
void aw_enable_l2_cache(feldev_handle *dev, soc_info_t *soc_info) void aw_enable_l2_cache(feldev_handle *dev, soc_info_t *soc_info)
...@@ -1136,7 +1107,9 @@ int main(int argc, char **argv) ...@@ -1136,7 +1107,9 @@ int main(int argc, char **argv)
} else if (strncmp(argv[1], "ver", 3) == 0) { } else if (strncmp(argv[1], "ver", 3) == 0) {
aw_fel_print_version(handle); aw_fel_print_version(handle);
} else if (strcmp(argv[1], "sid") == 0) { } else if (strcmp(argv[1], "sid") == 0) {
aw_fel_print_sid(handle); aw_fel_print_sid(handle, false);
} else if (strcmp(argv[1], "sid-registers") == 0) {
aw_fel_print_sid(handle, true); /* enforce register access */
} else if (strcmp(argv[1], "write") == 0 && argc > 3) { } else if (strcmp(argv[1], "write") == 0 && argc > 3) {
skip += 2 * file_upload(handle, 1, argc - 2, argv + 2, skip += 2 * file_upload(handle, 1, argc - 2, argv + 2,
pflag_active ? progress_bar : NULL); pflag_active ? progress_bar : NULL);
......
...@@ -668,7 +668,7 @@ feldev_list_entry *list_fel_devices(size_t *count) ...@@ -668,7 +668,7 @@ feldev_list_entry *list_fel_devices(size_t *count)
strncpy(entry->soc_name, dev->soc_name, sizeof(soc_name_t)); strncpy(entry->soc_name, dev->soc_name, sizeof(soc_name_t));
/* retrieve SID bits */ /* retrieve SID bits */
fel_get_root_key(dev, entry->SID, false); fel_get_sid_root_key(dev, entry->SID, false);
feldev_close(dev); feldev_close(dev);
free(dev); free(dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment