public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>, Marek Behun <marek.behun@nic.cz>
Cc: u-boot@lists.denx.de
Subject: [PATCH 3/4] board: turris: Allow to specify first eth idx of first MAC address
Date: Fri,  8 Apr 2022 16:30:14 +0200	[thread overview]
Message-ID: <20220408143015.23163-3-pali@kernel.org> (raw)
In-Reply-To: <20220408143015.23163-1-pali@kernel.org>

Turris Omnia uses first MAC address from OTP for second ethernet interface.
Second MAC address for third interface and third MAC address for first
interface.

Other Turris routers do not have this rotate by one mapping. So add
function parameter for specifying id of the first ethernet interface.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 board/CZ.NIC/turris_atsha_otp.c          | 8 ++++----
 board/CZ.NIC/turris_atsha_otp.h          | 2 +-
 board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
index 840721a9b737..7a39b7f61d5d 100644
--- a/board/CZ.NIC/turris_atsha_otp.c
+++ b/board/CZ.NIC/turris_atsha_otp.c
@@ -49,7 +49,7 @@ static void set_mac_if_invalid(int i, u8 *mac)
 		eth_env_set_enetaddr_by_index("eth", i, mac);
 }
 
-int turris_atsha_otp_init_mac_addresses(void)
+int turris_atsha_otp_init_mac_addresses(int first_idx)
 {
 	struct udevice *dev = get_atsha204a_dev();
 	u8 mac0[4], mac1[4], mac[6];
@@ -81,11 +81,11 @@ int turris_atsha_otp_init_mac_addresses(void)
 	mac[4] = mac1[2];
 	mac[5] = mac1[3];
 
-	set_mac_if_invalid(1, mac);
+	set_mac_if_invalid((first_idx + 0) % 3, mac);
 	increment_mac(mac);
-	set_mac_if_invalid(2, mac);
+	set_mac_if_invalid((first_idx + 1) % 3, mac);
 	increment_mac(mac);
-	set_mac_if_invalid(0, mac);
+	set_mac_if_invalid((first_idx + 2) % 3, mac);
 
 	return 0;
 }
diff --git a/board/CZ.NIC/turris_atsha_otp.h b/board/CZ.NIC/turris_atsha_otp.h
index 667d01af7310..bd4308fdc3ef 100644
--- a/board/CZ.NIC/turris_atsha_otp.h
+++ b/board/CZ.NIC/turris_atsha_otp.h
@@ -3,7 +3,7 @@
 #ifndef TURRIS_ATSHA_OTP_H
 #define TURRIS_ATSHA_OTP_H
 
-int turris_atsha_otp_init_mac_addresses(void);
+int turris_atsha_otp_init_mac_addresses(int first_idx);
 int turris_atsha_otp_get_serial_number(u32 *version_num, u32 *serial_num);
 
 #endif
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 719e8750e60a..da2fee578c44 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -606,7 +606,7 @@ int show_board_info(void)
 
 int misc_init_r(void)
 {
-	turris_atsha_otp_init_mac_addresses();
+	turris_atsha_otp_init_mac_addresses(1);
 	return 0;
 }
 
-- 
2.20.1


  parent reply	other threads:[~2022-04-08 14:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 14:30 [PATCH 1/4] board: turris: Move Turris Atsha OTP code to separate file Pali Rohár
2022-04-08 14:30 ` [PATCH 2/4] board: turris: Do not cache Atsha device in BSS Pali Rohár
2022-04-08 17:45   ` Marek Behún
2022-04-21 14:14   ` Stefan Roese
2022-04-08 14:30 ` Pali Rohár [this message]
2022-04-08 17:45   ` [PATCH 3/4] board: turris: Allow to specify first eth idx of first MAC address Marek Behún
2022-04-21 14:15   ` Stefan Roese
2022-04-08 14:30 ` [PATCH 4/4] board: turris: Rename atsha204a@64 DT node to crypto@64 Pali Rohár
2022-04-08 17:46   ` Marek Behún
2022-04-21 14:15   ` Stefan Roese
2022-04-08 17:45 ` [PATCH 1/4] board: turris: Move Turris Atsha OTP code to separate file Marek Behún
2022-04-21 14:14 ` Stefan Roese

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=20220408143015.23163-3-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --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