From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 069CEC433EF for ; Fri, 8 Apr 2022 14:31:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7ACC83DA2; Fri, 8 Apr 2022 16:31:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="gIJVCDt8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF8C983D0F; Fri, 8 Apr 2022 16:31:31 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7775583DA0 for ; Fri, 8 Apr 2022 16:31:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 49C6A61ADD; Fri, 8 Apr 2022 14:31:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FA13C385A3; Fri, 8 Apr 2022 14:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649428285; bh=q2ir68toIAieHjyC395kV0LEciqn01ZFRSWWnYJen9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gIJVCDt8GuIEcKGhrrERu90zRLFDUbtILuzQGStFL6eWUPqFtN8NPRNwbGdEBbXSV fW3e4HwI3Hv+leaSs9tkcX9tRUHA9hILC5flEt+O7XyttClVO0jbrwEpeLhNHTlLAd PWghECggwhBpV+vo+CyV27N6Ub4yVkmmokKhoEfljqROcP0c94pXXm/rR0gLo9GhPU 5hbSMrOzNxKIbV7UA0s+py6PddLy/Bd6nQ4AuLLog/w+QLuwH4ymPHjm/VbDF1MQuk o/l5o8zlW6qrlrTZVMaCp2puNNUNhBh60SOA/l6KeEqwxdAxDwqOa5qgICHOr1ZHkf 2Shyh+V5ZlM0A== Received: by pali.im (Postfix) id 367FDB20; Fri, 8 Apr 2022 16:31:23 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Marek Behun 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 Message-Id: <20220408143015.23163-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220408143015.23163-1-pali@kernel.org> References: <20220408143015.23163-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 --- 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