diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-17 08:10:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-17 08:10:22 +0200 |
commit | c59d7ab7317014cc14a98c47e91c2b582d5d08a7 (patch) | |
tree | 1a2b48b1f1eede56502eea748b4467ec8ab2d586 /drivers | |
parent | cde6a62a9d994087ff2d42239c1f370f98122c1c (diff) | |
parent | fbf03e24b9111aea4a11fea1ac67fee446ad2c63 (diff) | |
download | barebox-c59d7ab7317014cc14a98c47e91c2b582d5d08a7.tar.gz barebox-c59d7ab7317014cc14a98c47e91c2b582d5d08a7.tar.xz |
Merge branch 'for-next/machine-id'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvmem/ocotp.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c index 3f9f162860..79693e22e0 100644 --- a/drivers/nvmem/ocotp.c +++ b/drivers/nvmem/ocotp.c @@ -29,6 +29,8 @@ #include <regmap.h> #include <linux/clk.h> #include <mach/ocotp.h> +#include <machine_id.h> +#include <mach/ocotp-fusemap.h> #include <linux/nvmem-provider.h> /* @@ -77,6 +79,7 @@ #define MAC_OFFSET_1 (0x24 * 4) #define MAX_MAC_OFFSETS 2 #define MAC_BYTES 8 +#define UNIQUE_ID_NUM 2 enum imx_ocotp_format_mac_direction { OCOTP_HW_TO_MAC, @@ -548,6 +551,19 @@ static int imx_ocotp_read(struct device_d *dev, const int offset, void *val, return regmap_bulk_read(priv->map, offset, val, bytes); } +static void imx_ocotp_set_unique_machine_id(void) +{ + uint32_t unique_id_parts[UNIQUE_ID_NUM]; + int i; + + for (i = 0; i < UNIQUE_ID_NUM; i++) + if (imx_ocotp_read_field(OCOTP_UNIQUE_ID(i), + &unique_id_parts[i])) + return; + + machine_id_set_hashable(unique_id_parts, sizeof(unique_id_parts)); +} + static const struct nvmem_bus imx_ocotp_nvmem_bus = { .write = imx_ocotp_write, .read = imx_ocotp_read, @@ -633,6 +649,9 @@ static int imx_ocotp_probe(struct device_d *dev) ethaddr->value, ethaddr); } + if (IS_ENABLED(CONFIG_MACHINE_ID)) + imx_ocotp_set_unique_machine_id(); + imx_ocotp_init_dt(priv); dev_add_param_bool(&(priv->dev), "sense_enable", NULL, NULL, &priv->sense_enable, priv); |