public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ramon Fried <ramon.fried@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 2/3] snapdragon: added MAC generation functions
Date: Fri,  3 Aug 2018 16:25:36 +0300	[thread overview]
Message-ID: <20180803132537.1747-3-ramon.fried@gmail.com> (raw)
In-Reply-To: <20180803132537.1747-1-ramon.fried@gmail.com>

Add support for generation of unique MAC address
that is derived from board serial.
Algorithm for generation of MAC taken from LK.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---

 arch/arm/mach-snapdragon/include/mach/misc.h |  1 +
 arch/arm/mach-snapdragon/misc.c              | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/arch/arm/mach-snapdragon/include/mach/misc.h
index 5af6ae8da4..c60e3e4724 100644
--- a/arch/arm/mach-snapdragon/include/mach/misc.h
+++ b/arch/arm/mach-snapdragon/include/mach/misc.h
@@ -8,5 +8,6 @@
 #define MISC_H
 
 u32 msm_board_serial(void);
+void msm_generate_mac_addr(u8 *mac);
 
 #endif
diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
index 678bd69f83..f6c87866c0 100644
--- a/arch/arm/mach-snapdragon/misc.c
+++ b/arch/arm/mach-snapdragon/misc.c
@@ -35,3 +35,19 @@ u32 msm_board_serial(void)
 
 	return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
 }
+
+void msm_generate_mac_addr(u8 *mac)
+{
+	int i;
+	char sn[9];
+
+	snprintf(sn, 8, "%08x", msm_board_serial());
+
+	/* fill in the mac with serialno, use locally adminstrated pool */
+	mac[0] = 0x02;
+	mac[1] = 00;
+	for (i = 3; i >= 0; i--) {
+		mac[i + 2] = simple_strtoul(&sn[2 * i], NULL, 16);
+		sn[2 * i] = 0;
+	}
+}
-- 
2.18.0

  parent reply	other threads:[~2018-08-03 13:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 13:25 [U-Boot] [PATCH v1 0/3] Let U-Boot generate MAC address for db410 Ramon Fried
2018-08-03 13:25 ` [U-Boot] [PATCH v1 1/3] snapdragon: added msm_board_serial() func Ramon Fried
2018-08-13 23:57   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-08-03 13:25 ` Ramon Fried [this message]
2018-08-13 23:57   ` [U-Boot] [U-Boot, v1, 2/3] snapdragon: added MAC generation functions Tom Rini
2018-08-03 13:25 ` [U-Boot] [PATCH v1 3/3] db410: alter WLAN/BT MAC address fixup Ramon Fried
2018-08-13 23:57   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-08-13 23:57   ` Tom Rini

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=20180803132537.1747-3-ramon.fried@gmail.com \
    --to=ramon.fried@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox