Skip to content
Snippets Groups Projects
Commit 5b99340d authored by Alexandre Bailon's avatar Alexandre Bailon
Browse files

tee: optee: otp: Add another way to setup the mac address


This provides a way to set the mac address using the DT.
This looks up for the network interface node and set the attribute
with the mac address.

Signed-off-by: default avatarAlexandre Bailon <abailon@baylibre.com>
parent 2aebce2a
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
#include <mmc.h>
#include <net.h>
#include <tee.h>
#include <fdt_support.h>
#include <tee/optee_ta_otp.h>
......@@ -176,3 +177,35 @@ int optee_otp_read_mac(const char *name)
return ret;
}
int optee_otp_read_mac_fdt(void *blob, const char *node,
const char *attribute,
const char *otp_name)
{
u8 ethaddr[MAC_ADDRESS_LEN];
size_t len;
int ret;
int nodeoffset;
ret = read_persistent_value(otp_name, MAC_ADDRESS_LEN, ethaddr, &len);
if (!ret && is_valid_ethaddr(ethaddr)) {
nodeoffset = fdt_path_offset(blob, node);
if (nodeoffset < 0)
return nodeoffset;
ret = fdt_setprop(blob, nodeoffset, attribute, ethaddr,
sizeof(ethaddr));
if (ret < 0) {
printf("WARNING: could not set %s %s.\n", attribute,
fdt_strerror(ret));
return ret;
}
} else {
printf("Failed to read mac address\n");
ret = 0;
}
optee_otp_ta_close_session();
return ret;
}
......@@ -57,6 +57,9 @@ int read_persistent_value(const char *name,
size_t *out_num_bytes_read);
int optee_otp_read_serial(void);
int optee_otp_read_mac(const char *name);
int optee_otp_read_mac_fdt(void *blob, const char *node,
const char *attribute,
const char *otp_name);
void optee_otp_ta_close_session(void);
#else /* CONFIG_OPTEE_TA_OTP */
static inline int read_persistent_value(const char *name, size_t buffer_size,
......@@ -74,6 +77,12 @@ static inline int optee_otp_read_mac(const char *name)
{
return -ENODEV;
}
static inline int optee_otp_read_mac_fdt(void *blob, const char *node,
const char *attribute,
const char *otp_name)
{
return -ENODEV;
}
static inline void optee_otp_ta_close_session(void) {}
#endif /* CONFIG_OPTEE_TA_OTP */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment