refactor(stm32mp1): drop the "st,stm32-nvmem-layout" node

Simplify the DT parsing by removing the parsing of the nvmem layout node
with "st,stm32-nvmem-layout" compatible.

The expected OTP NAME can directly be found in a sub-node named
NAME@ADDRESS of the BSEC node, the NVMEM provider node.

This patch also removes this specific binding introduced for TF-A.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Change-Id: Ic703385fad1bec5bef1cee583fbe9fbbf6aea216
This commit is contained in:
Patrick Delaunay 2022-03-01 09:56:03 +01:00 committed by Yann Gautier
parent b9a6dbc1ba
commit c5bf1b0971
2 changed files with 6 additions and 23 deletions

View file

@ -326,48 +326,32 @@ const char *dt_get_board_model(void)
int dt_find_otp_name(const char *name, uint32_t *otp, uint32_t *otp_len) int dt_find_otp_name(const char *name, uint32_t *otp, uint32_t *otp_len)
{ {
int node; int node;
int index, len; int len;
const fdt32_t *cuint; const fdt32_t *cuint;
if ((name == NULL) || (otp == NULL)) { if ((name == NULL) || (otp == NULL)) {
return -FDT_ERR_BADVALUE; return -FDT_ERR_BADVALUE;
} }
node = fdt_node_offset_by_compatible(fdt, -1, DT_NVMEM_LAYOUT_COMPAT); node = fdt_node_offset_by_compatible(fdt, -1, DT_BSEC_COMPAT);
if (node < 0) { if (node < 0) {
return node; return node;
} }
index = fdt_stringlist_search(fdt, node, "nvmem-cell-names", name); node = fdt_subnode_offset(fdt, node, name);
if (index < 0) {
return index;
}
cuint = fdt_getprop(fdt, node, "nvmem-cells", &len);
if (cuint == NULL) {
return -FDT_ERR_NOTFOUND;
}
if ((index * (int)sizeof(uint32_t)) > len) {
return -FDT_ERR_BADVALUE;
}
cuint += index;
node = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*cuint));
if (node < 0) { if (node < 0) {
ERROR("Malformed nvmem_layout node: ignored\n"); ERROR("nvmem node %s not found\n", name);
return node; return node;
} }
cuint = fdt_getprop(fdt, node, "reg", &len); cuint = fdt_getprop(fdt, node, "reg", &len);
if ((cuint == NULL) || (len != (2 * (int)sizeof(uint32_t)))) { if ((cuint == NULL) || (len != (2 * (int)sizeof(uint32_t)))) {
ERROR("Malformed nvmem_layout node: ignored\n"); ERROR("Malformed nvmem node %s: ignored\n", name);
return -FDT_ERR_BADVALUE; return -FDT_ERR_BADVALUE;
} }
if (fdt32_to_cpu(*cuint) % sizeof(uint32_t)) { if (fdt32_to_cpu(*cuint) % sizeof(uint32_t)) {
ERROR("Misaligned nvmem_layout element: ignored\n"); ERROR("Misaligned nvmem %s element: ignored\n", name);
return -FDT_ERR_BADVALUE; return -FDT_ERR_BADVALUE;
} }

View file

@ -621,7 +621,6 @@ static inline uintptr_t tamp_bkpr(uint32_t idx)
#define DT_DDR_COMPAT "st,stm32mp1-ddr" #define DT_DDR_COMPAT "st,stm32mp1-ddr"
#endif #endif
#define DT_IWDG_COMPAT "st,stm32mp1-iwdg" #define DT_IWDG_COMPAT "st,stm32mp1-iwdg"
#define DT_NVMEM_LAYOUT_COMPAT "st,stm32-nvmem-layout"
#define DT_PWR_COMPAT "st,stm32mp1,pwr-reg" #define DT_PWR_COMPAT "st,stm32mp1,pwr-reg"
#if STM32MP13 #if STM32MP13
#define DT_RCC_CLK_COMPAT "st,stm32mp13-rcc" #define DT_RCC_CLK_COMPAT "st,stm32mp13-rcc"