Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A32A3C4320E for ; Tue, 31 Aug 2021 17:10:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D0DDB610E6 for ; Tue, 31 Aug 2021 17:10:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D0DDB610E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1488483444; Tue, 31 Aug 2021 19:10:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com 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=foss.st.com header.i=@foss.st.com header.b="ZG9fUgqc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F18283441; Tue, 31 Aug 2021 19:10:26 +0200 (CEST) Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (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 43C2A8344D for ; Tue, 31 Aug 2021 19:10:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=3877e84d46=patrick.delaunay@foss.st.com Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17VEubws014217; Tue, 31 Aug 2021 19:10:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=mvLe9xuI5uFt1tlcNqzg/F41aSWvXix6wZud1WfxXXk=; b=ZG9fUgqccg5IvHERp0bBV9mKHf3PpwbwZTKXAg7gzeSDfUDcQmvSNdnEtvvpWOcSn3Cy M5ThRZzhb0kZPzOjUjLXba04l0R+cJacjnhTwEKttYyRtaUNJdWgUhGBLlPAPbyyi5DM kD0yWCiSRN+2YTL1n3+b/r1OjH/lJg5sHR+SE6fTpEnskrSEr86WxaeHstNoXnERAWeA gvU/ctSvT05kivP7tOqxNnMrd4oycXcywBvby6aXMgZNcO4LNly+HJUauQ1A54/VodNX 5AIP23tx1Hr8iU+iXMOYxiW6G60zS9IzyR9VbjeF2tllXfj7iOE2+HatLsI5xLGxe5m6 yA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3asheh2gcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Aug 2021 19:10:20 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7D64610002A; Tue, 31 Aug 2021 19:10:20 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6B5EE2532DB; Tue, 31 Aug 2021 19:10:20 +0200 (CEST) Received: from lmecxl0994.lme.st.com (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 19:10:19 +0200 Subject: Re: [PATCH 07/10] stm32mp1: spl: Configure MAC address when booting OP-TEE To: Alexandru Gagniuc , CC: , Patrice CHOTARD , Alexandre TORGUE , Christophe ROULLIER References: <20210826214209.254461-1-mr.nuke.me@gmail.com> <20210826214209.254461-8-mr.nuke.me@gmail.com> From: Patrick DELAUNAY Message-ID: Date: Tue, 31 Aug 2021 19:10:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210826214209.254461-8-mr.nuke.me@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-31_08,2021-08-31_01,2020-04-07_01 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Hi, On 8/26/21 11:42 PM, Alexandru Gagniuc wrote: > When OP-TEE is booted as the SPL payload, the stage after OP-TEE is > not guaranteed to be u-boot. Thus the FDT patching in u-boot is not > guaranteed to occur. Add this step to SPL. > > The patching by stm32_fdt_setup_mac_addr() is done in SPL, and patches > the target FDT directly. This differs is different from > setup_mac_address(), which sets the "ethaddr" env variable, and does > not work in SPL. > > Signed-off-by: Alexandru Gagniuc > --- > arch/arm/mach-stm32mp/cpu.c | 22 +++++++++++++++++++ > .../arm/mach-stm32mp/include/mach/sys_proto.h | 3 +++ > arch/arm/mach-stm32mp/spl.c | 1 + > 3 files changed, 26 insertions(+) > > diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c > index 8727de513c..2b8b67bb40 100644 > --- a/arch/arm/mach-stm32mp/cpu.c > +++ b/arch/arm/mach-stm32mp/cpu.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -646,6 +647,27 @@ __weak int setup_mac_address(void) > return 0; > } > > +int stm32_fdt_setup_mac_addr(void *fdt) > +{ > + int ret; > + uchar enetaddr[ARP_HLEN]; > + > + ret = stm32_read_otp_mac(enetaddr); > + if (ret < 0) > + return ret; > + > + if (!is_valid_ethaddr(enetaddr)) { > + printf("invalid MAC address in OTP\n"); > + return -EINVAL; > + } > + > + ret = fdt_ethernet_set_macaddr(fdt, 0, enetaddr); > + if (ret) > + debug("Failed to set mac address from OTP: %d\n", ret); > + > + return ret; > +} > + > static int setup_serial_number(void) > { > char serial_string[25]; > diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h > index 4149d3a133..2d24cfee3f 100644 > --- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h > +++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h > @@ -47,7 +47,10 @@ void get_soc_name(char name[SOC_NAME_SIZE]); > /* return boot mode */ > u32 get_bootmode(void); > > +/* Set 'ethaddr' env variable with MAC from OTP (useful for u-boot proper) */ > int setup_mac_address(void); > +/* Patch the first 'ethernet' node of FDT with MAC from OTP (useful for SPL) */ > +int stm32_fdt_setup_mac_addr(void *fdt); > > /* board power management : configure vddcore according OPP */ > void board_vddcore_init(u32 voltage_mv); > diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c > index 405eff68a3..d9fdc5926c 100644 > --- a/arch/arm/mach-stm32mp/spl.c > +++ b/arch/arm/mach-stm32mp/spl.c > @@ -181,6 +181,7 @@ void stm32_init_tzc_for_optee(void) > > void spl_board_prepare_for_optee(void *fdt) > { > + stm32_fdt_setup_mac_addr(fdt); > stm32_init_tzc_for_optee(); > } > I think that all this part is not required for falcon mode: let the Linux driver fallback to nvmem access to read the MAC address in OTP when the DT is not updated by boot loader remove also the patch 06/10 and 04/40 PS: it is already working in OpenSTLinux based on the device tree modification for your board &bsec{             ethernet_mac_address: mac@e4 {             reg = <0xe4 0x6>; }; ðernet0 {     nvmem-cells = <ðernet_mac_address>;     nvmem-cell-names = "mac-address"; }; PS: this part is not yet upstreamed in Linux Linux reference = Documentation/devicetree/bindings/net/ethernet-controller.yaml   nvmem-cells:     maxItems: 1     description:       Reference to an nvmem node for the MAC address   nvmem-cell-names:     const: mac-address Patrick