From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
To: u-boot@lists.denx.de
Cc: patrick.delaunay@foss.st.com, marex@denx.de,
Alexandru Gagniuc <mr.nuke.me@gmail.com>
Subject: [PATCH 06/10] arm: stm32mp: Factor out reading MAC address from OTP
Date: Thu, 26 Aug 2021 16:42:05 -0500 [thread overview]
Message-ID: <20210826214209.254461-7-mr.nuke.me@gmail.com> (raw)
In-Reply-To: <20210826214209.254461-1-mr.nuke.me@gmail.com>
Move the reading the OTP into a separate function. This is
required for a subsequent change which sets the MAC in SPL.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
arch/arm/mach-stm32mp/cpu.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index eb79f3ffd2..8727de513c 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -593,6 +593,28 @@ static void setup_boot_mode(void)
clrsetbits_le32(TAMP_BOOT_CONTEXT, TAMP_BOOT_FORCED_MASK, BOOT_NORMAL);
}
+static int stm32_read_otp_mac(uint8_t enetaddr[ARP_HLEN])
+{
+ struct udevice *dev;
+ int ret, i;
+ u32 otp[2];
+
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_DRIVER_GET(stm32mp_bsec),
+ &dev);
+ if (ret)
+ return ret;
+
+ ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, sizeof(otp));
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < ARP_HLEN; i++)
+ enetaddr[i] = ((uint8_t *)&otp)[i];
+
+ return 0;
+}
+
/*
* If there is no MAC address in the environment, then it will be initialized
* (silently) from the value in the OTP.
@@ -601,29 +623,16 @@ __weak int setup_mac_address(void)
{
#if defined(CONFIG_NET)
int ret;
- int i;
- u32 otp[2];
uchar enetaddr[6];
- struct udevice *dev;
/* MAC already in environment */
if (eth_env_get_enetaddr("ethaddr", enetaddr))
return 0;
- ret = uclass_get_device_by_driver(UCLASS_MISC,
- DM_DRIVER_GET(stm32mp_bsec),
- &dev);
- if (ret)
- return ret;
-
- ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC),
- otp, sizeof(otp));
+ ret = stm32_read_otp_mac(enetaddr);
if (ret < 0)
return ret;
- for (i = 0; i < 6; i++)
- enetaddr[i] = ((uint8_t *)&otp)[i];
-
if (!is_valid_ethaddr(enetaddr)) {
log_err("invalid MAC address in OTP %pM\n", enetaddr);
return -EINVAL;
--
2.31.1
next prev parent reply other threads:[~2021-08-26 21:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 21:41 [PATCH 00/10] stm32mp1: Support falcon mode with OP-TEE payloads Alexandru Gagniuc
2021-08-26 21:42 ` [PATCH 01/10] stm32mp1: Add support for baudrates higher than 115200 Alexandru Gagniuc
2021-08-31 16:05 ` Patrick DELAUNAY
2021-08-26 21:42 ` [PATCH 02/10] stm32mp1: Add support for falcon mode boot from SD card Alexandru Gagniuc
2021-08-31 16:30 ` Patrick DELAUNAY
2021-08-26 21:42 ` [PATCH 03/10] board: stm32mp1: Implement board_fit_config_name_match() for SPL Alexandru Gagniuc
2021-08-31 16:39 ` Patrick DELAUNAY
2021-08-26 21:42 ` [PATCH 04/10] fdt_support: Implement fdt_ethernet_set_macaddr() Alexandru Gagniuc
2021-08-26 23:35 ` Sean Anderson
2021-08-26 23:50 ` Alex G.
2021-08-26 21:42 ` [PATCH 05/10] arm: stm32mp: bsec: Do not skip .probe() for SPL Alexandru Gagniuc
2021-08-31 16:54 ` Patrick DELAUNAY
2021-08-26 21:42 ` Alexandru Gagniuc [this message]
2021-08-26 21:42 ` [PATCH 07/10] stm32mp1: spl: Configure MAC address when booting OP-TEE Alexandru Gagniuc
2021-08-31 17:10 ` Patrick DELAUNAY
2021-08-31 19:13 ` Alex G.
2021-08-26 21:42 ` [PATCH 08/10] lib: Makefile: Make optee library available in SPL Alexandru Gagniuc
2021-08-31 17:16 ` Patrick DELAUNAY
2021-08-26 21:42 ` [PATCH 09/10] ARM: dts: stm32mp: Add OP-TEE "/firmware" node to SPL dtb Alexandru Gagniuc
2021-08-31 17:27 ` Patrick DELAUNAY
2021-08-26 21:42 ` [PATCH 10/10] stm32mp1: spl: Copy optee nodes to target FDT for OP-TEE payloads Alexandru Gagniuc
2021-08-31 17:24 ` Patrick DELAUNAY
2021-09-01 15:10 ` Alex G.
2021-09-02 17:34 ` Alex G.
2021-09-03 9:51 ` Patrick DELAUNAY
2021-09-02 21:45 ` Etienne Carriere
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210826214209.254461-7-mr.nuke.me@gmail.com \
--to=mr.nuke.me@gmail.com \
--cc=marex@denx.de \
--cc=patrick.delaunay@foss.st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.