From patchwork Tue Aug 14 13:07:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 10565603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1ED81390 for ; Tue, 14 Aug 2018 13:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 922AD28CCD for ; Tue, 14 Aug 2018 13:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8669B28DCE; Tue, 14 Aug 2018 13:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 38FB228CCD for ; Tue, 14 Aug 2018 13:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Eiup2ythoKty5a2JfLZz9F1HtkLW7nnJl19kEOGluDE=; b=N3cntddCE+V6qmk3jYZwjtG227 HuEn13mFxUqq1sFWeLs+wpsw+Qse6PEZ8Yi+ZCOateLrVS+8yEiyoTarx2weZ9XyKkrByw9SMvrV5 TjHByJBaiOayqYZMhJqyrM/fOW4yooviaLk/J/02FW6Hc7lAgHURCxRXNJKqX7V+GXH3foaGttwrO ug4in3yCpAqBx9v7P4JSUNobEpGTcPWeU0ASUO50Q4+GLlROb7zO/x1i0723li8b/+/LUuiMKs0Pm pPsRboOQNVpIFAG98FguODIe6I5BmzBC3LCzA/QFWqv7c2gk2QQcr8toc2h/q8AQe+3wSQBETC3LX QzKSmYhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ3x-0000Kh-CQ; Tue, 14 Aug 2018 13:08:41 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ3u-0000Ge-Ga for linux-amlogic@lists.infradead.org; Tue, 14 Aug 2018 13:08:39 +0000 Received: by mail-wr1-x432.google.com with SMTP id e7-v6so17144623wrs.9 for ; Tue, 14 Aug 2018 06:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DG9s5QiWCcf0B9BGJ3dYqjJXSSydKyWY4RFtZ7qkQRE=; b=QsNT1NkzdSreS8WUShbaXH5dy6nX/BUIy54zMUsskq2wv4fS4LP1589nrbd7F5Z8fj 7IMrsx68OQnbMn3jUx8bslysDwd3Ay1fDaNTGzTgbY2bvQ0BfnH+HviKpWGkUDw3VV+0 xJpezbM4zpvKLHLzl7OnFuOaszOn+l3PYM2EvNSSo671aZZgNhGwbot8hEqzlCrA1Eio tCvFCC6BwexHItgOMRJEkevG3/zhcTdEl2KMUAn5UbJl6XJTTM6AAyLPUGXM9UUM4uwL QhSdwn6/88/Y+X2cmg66Oy6DRR8/2XLZnB2/hWsdK3JXkEaQOYI5VtvrjkZGqOMIZ2wr 6ixw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DG9s5QiWCcf0B9BGJ3dYqjJXSSydKyWY4RFtZ7qkQRE=; b=JQOjyLZ4dFGS266SlNetU/aUNpCXR+pey9SLb1KU0MaKcznMVSs4oHgfkv8yJWnTfa pPytu0Bd66IRtv5xqFWW5qNTmz3deukSaR45RUkeWBz5bHYGnHJ9OikvOiLfMkKVYcoQ iqxcZ6qh0xvbNlTM9RZvyvABVb91AcpqIaxBFRgV2nGuZ19GKUjunf7I9kR78bP9U0or oS0MH3rkr2wPmTKdYtuqf8TwDF1jKfJPH9WgzCbfQVwm0CcgzdnPW+OiaQ7gYbZtwQ0i knKmWgEVMnqUQ9alQJ5Ph4J40+aESOFDBmWKqaf0dpQxAD3mVtRJjt9g2/xxlKL3PiqN fDOA== X-Gm-Message-State: AOUpUlGFGlCQBrqw2rnM8nwgDZa5x72Jy6hVEiMYKPl0zEnutNc7iQrD J11/kHWa6gy1rSDTNJS+MYg0I5ju X-Google-Smtp-Source: AA+uWPxNu5QSEkIxQfFtAgORRj1GfUsaZiCA7wCJN+35qG/JyBHPcfzDOMQD1DTLbhINnNGo0Y2wfQ== X-Received: by 2002:adf:e841:: with SMTP id d1-v6mr7888365wrn.269.1534252105364; Tue, 14 Aug 2018 06:08:25 -0700 (PDT) Received: from sark.homenet.telecomitalia.it ([79.46.68.202]) by smtp.gmail.com with ESMTPSA id r16-v6sm29123997wru.59.2018.08.14.06.08.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 06:08:24 -0700 (PDT) From: Beniamino Galvani To: u-boot@lists.denx.de Subject: [PATCH u-boot 1/3] boards: amlogic: remove ethernet gpio reset code from boards Date: Tue, 14 Aug 2018 15:07:52 +0200 Message-Id: <20180814130754.19294-2-b.galvani@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814130754.19294-1-b.galvani@gmail.com> References: <20180814130754.19294-1-b.galvani@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_060838_556390_632896A6 X-CRM114-Status: UNSURE ( 7.98 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rini , Albert Aribaud , Neil Armstrong , Simon Glass , Beniamino Galvani , linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The reset is already handled by the designware driver using information from device tree. Signed-off-by: Beniamino Galvani Acked-by: Neil Armstrong --- board/amlogic/nanopi-k2/nanopi-k2.c | 6 ------ board/amlogic/odroid-c2/odroid-c2.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/board/amlogic/nanopi-k2/nanopi-k2.c b/board/amlogic/nanopi-k2/nanopi-k2.c index 339dbb81db..ae29dd6fa4 100644 --- a/board/amlogic/nanopi-k2/nanopi-k2.c +++ b/board/amlogic/nanopi-k2/nanopi-k2.c @@ -30,12 +30,6 @@ int misc_init_r(void) meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - /* Reset PHY on GPIOZ_14 */ - clrbits_le32(GX_GPIO_EN(3), BIT(14)); - clrbits_le32(GX_GPIO_OUT(3), BIT(14)); - mdelay(10); - setbits_le32(GX_GPIO_OUT(3), BIT(14)); - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, mac_addr, EFUSE_MAC_SIZE); diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c index c47b9ce9cb..2a2755c387 100644 --- a/board/amlogic/odroid-c2/odroid-c2.c +++ b/board/amlogic/odroid-c2/odroid-c2.c @@ -30,12 +30,6 @@ int misc_init_r(void) meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - /* Reset PHY on GPIOZ_14 */ - clrbits_le32(GX_GPIO_EN(3), BIT(14)); - clrbits_le32(GX_GPIO_OUT(3), BIT(14)); - mdelay(10); - setbits_le32(GX_GPIO_OUT(3), BIT(14)); - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, mac_addr, EFUSE_MAC_SIZE); From patchwork Tue Aug 14 13:07:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 10565607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 810D115A6 for ; Tue, 14 Aug 2018 13:08:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D6B928C08 for ; Tue, 14 Aug 2018 13:08:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6181D28CD1; Tue, 14 Aug 2018 13:08:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF6DB28C08 for ; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MWNtxLfX5S6eXYxWwKRmTsm7t3rwBENeU9klNbUrYOs=; b=A2AvvtjZ0KeKXOp8fmCOhDXR8n oZRB3tYqkw16AC7LHtHM0XeKeKvOZNLvAjLzWyqz/3g7M/K07k1ObnxeHCml4w4nSpQ/kn80ZQ1Ja deF9AdalpCBvLH7JFL/qmWkfgjqJbR+Wi7etkCTQB7ov/InAbw2Rqcn6vFjrshrF1SLaiMluj0L+l DQ2QT+Vy37iy/AFP2W9qb2zir408oZ74w9aaJuQmWOtiV2Puk3IWgAjHrXmZlHPwgOypRmCPcQZDH fn+xBCXFmtdIP8uaOaSRxJyWiBowCkTBwSNjUE8l3D0nquAFY9ZPEHBPzzqniMg4BSiKa7vdgZCTu GK81ta1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ41-0000Og-T8; Tue, 14 Aug 2018 13:08:45 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ3x-0000Gk-Al for linux-amlogic@lists.infradead.org; Tue, 14 Aug 2018 13:08:43 +0000 Received: by mail-wr1-x444.google.com with SMTP id h9-v6so17183075wro.3 for ; Tue, 14 Aug 2018 06:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/cPa9g1ttYsZYdUcPwzKBMX632ifU5joE78RzoUZoqk=; b=dlHTFCXHdDfBquu/0D6HJ9ppdQJqe1ZZjaWVK8TJbC2MtJ87bmHy9O9yVA8+Sqhe6w NR+4e7BW6WAAgLOSF0jztJOeHSUMAJDQaZxDJdAVmOSdtURuO1Ja4Y5zZV8pt9OIj4eQ pQSVgM7VzbIf2NfnYpO9WoR0S1wrlRZ3XkKOggM3gjAaNHYj6XhlJn/avW3Pt9CG46/S lgqSjS2Aga9u7lT9iqWueLcsBXXGpBesKWbYUUgVbMyHR5jvJXxZLJyV0ZIJJjO04nkn tCtCDnuP7y5cRP1sfJvgHtLlygXdmqnHDtf7jI8s59TN+i/OJu2qOlv9AtrlQhwtcK7w CwWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/cPa9g1ttYsZYdUcPwzKBMX632ifU5joE78RzoUZoqk=; b=hG4ts0gq6z1mj2t4d228CcYkXqYQms7cZOWU6YGaBLyOEjQ9xuVA7eCE/28Px2WpBv O0DvDbvOZDCHAScXlzA/5hmmrUPnm9Y7dRbUKjGig5epqh3ZmTA3jtkUq8k92mEwluor /5os623Hz8OPheutdseSlBav+KgbBYJn/ZxpxwgZlrzp9CSSx6xTm5pvooLGmXNtQ2w9 V4YioGNLw3p8lJGg0CrJD3ygYIbriOtidfJO1euOn28p6ose9DzG88lp3ktqrIyD2qs2 MynHAl21Y+OnGd4J/Ncf3rQ4RCryO57pMDfYTeAfcTkH1p5ksB7/F3c6XlJdLS43MmCY C6gw== X-Gm-Message-State: AOUpUlFMdy6p9+chxUYxO5vDIRwkE+uGqki4zb7m/6DHHcwN65zyP9RH ieRw77QlIE/SfN//5cU0tIg= X-Google-Smtp-Source: AA+uWPwPwmkfYPZZ/DEBUXC9DNKrjUOR51SjsBstYujCHf2OjgpKo0IWz7Ghejk5wqgpK2J3rcfm+g== X-Received: by 2002:adf:9486:: with SMTP id 6-v6mr10170403wrr.257.1534252107187; Tue, 14 Aug 2018 06:08:27 -0700 (PDT) Received: from sark.homenet.telecomitalia.it ([79.46.68.202]) by smtp.gmail.com with ESMTPSA id r16-v6sm29123997wru.59.2018.08.14.06.08.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 06:08:26 -0700 (PDT) From: Beniamino Galvani To: u-boot@lists.denx.de Subject: [PATCH u-boot 2/3] boards: amlogic: use common function for environment initialization Date: Tue, 14 Aug 2018 15:07:53 +0200 Message-Id: <20180814130754.19294-3-b.galvani@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814130754.19294-1-b.galvani@gmail.com> References: <20180814130754.19294-1-b.galvani@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_060841_440919_C18D9DF2 X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rini , Albert Aribaud , Neil Armstrong , Simon Glass , Beniamino Galvani , linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Clean up board files by moving the duplicate environment initialization to arch code. Signed-off-by: Beniamino Galvani --- arch/arm/include/asm/arch-meson/sm.h | 1 + arch/arm/mach-meson/sm.c | 27 +++++++++++++++++++++++ board/amlogic/khadas-vim/khadas-vim.c | 25 +-------------------- board/amlogic/libretech-cc/libretech-cc.c | 25 +-------------------- board/amlogic/nanopi-k2/nanopi-k2.c | 25 +-------------------- board/amlogic/odroid-c2/odroid-c2.c | 25 +-------------------- board/amlogic/p212/p212.c | 25 +-------------------- 7 files changed, 33 insertions(+), 120 deletions(-) diff --git a/arch/arm/include/asm/arch-meson/sm.h b/arch/arm/include/asm/arch-meson/sm.h index 83d6441803..db2be38fc5 100644 --- a/arch/arm/include/asm/arch-meson/sm.h +++ b/arch/arm/include/asm/arch-meson/sm.h @@ -7,5 +7,6 @@ #define __MESON_SM_H__ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size); +void meson_init_env_from_efuse(void); #endif /* __MESON_SM_H__ */ diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c index 0bba5e4a07..2628591fe6 100644 --- a/arch/arm/mach-meson/sm.c +++ b/arch/arm/mach-meson/sm.c @@ -6,6 +6,7 @@ */ #include +#include #include #include @@ -14,6 +15,11 @@ #define FN_EFUSE_READ 0x82000030 #define FN_EFUSE_WRITE 0x82000031 +#define EFUSE_SN_OFFSET 20 +#define EFUSE_SN_SIZE 16 +#define EFUSE_MAC_OFFSET 52 +#define EFUSE_MAC_SIZE 6 + static void *shmem_input; static void *shmem_output; @@ -54,3 +60,24 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size) return regs.regs[0]; } + +void meson_init_env_from_efuse(void) +{ + static u8 mac[EFUSE_MAC_SIZE]; + char serial[EFUSE_SN_SIZE]; + ssize_t len; + + if (!eth_env_get_enetaddr("ethaddr", mac)) { + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, + mac, EFUSE_MAC_SIZE); + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac)) + eth_env_set_enetaddr("ethaddr", mac); + } + + if (!env_get("serial#")) { + len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, + EFUSE_SN_SIZE); + if (len == EFUSE_SN_SIZE) + env_set("serial#", serial); + } +} diff --git a/board/amlogic/khadas-vim/khadas-vim.c b/board/amlogic/khadas-vim/khadas-vim.c index 692bf2add3..4483a96761 100644 --- a/board/amlogic/khadas-vim/khadas-vim.c +++ b/board/amlogic/khadas-vim/khadas-vim.c @@ -6,18 +6,12 @@ #include #include -#include #include #include #include #include #include -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 - int board_init(void) { return 0; @@ -25,26 +19,9 @@ int board_init(void) int misc_init_r(void) { - u8 mac_addr[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; - ssize_t len; - meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, MESON_GXL_USE_INTERNAL_RMII_PHY); - - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { - len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, - mac_addr, EFUSE_MAC_SIZE); - if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) - eth_env_set_enetaddr("ethaddr", mac_addr); - } - - if (!env_get("serial#")) { - len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, - EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) - env_set("serial#", serial); - } + meson_init_env_from_efuse(); return 0; } diff --git a/board/amlogic/libretech-cc/libretech-cc.c b/board/amlogic/libretech-cc/libretech-cc.c index ccab1272c5..86b1d213ff 100644 --- a/board/amlogic/libretech-cc/libretech-cc.c +++ b/board/amlogic/libretech-cc/libretech-cc.c @@ -6,18 +6,12 @@ #include #include -#include #include #include #include #include #include -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 - int board_init(void) { return 0; @@ -25,26 +19,9 @@ int board_init(void) int misc_init_r(void) { - u8 mac_addr[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; - ssize_t len; - meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, MESON_GXL_USE_INTERNAL_RMII_PHY); - - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { - len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, - mac_addr, EFUSE_MAC_SIZE); - if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) - eth_env_set_enetaddr("ethaddr", mac_addr); - } - - if (!env_get("serial#")) { - len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, - EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) - env_set("serial#", serial); - } + meson_init_env_from_efuse(); return 0; } diff --git a/board/amlogic/nanopi-k2/nanopi-k2.c b/board/amlogic/nanopi-k2/nanopi-k2.c index ae29dd6fa4..e61c23f8c6 100644 --- a/board/amlogic/nanopi-k2/nanopi-k2.c +++ b/board/amlogic/nanopi-k2/nanopi-k2.c @@ -5,18 +5,12 @@ #include #include -#include #include #include #include #include #include -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 - int board_init(void) { return 0; @@ -24,25 +18,8 @@ int board_init(void) int misc_init_r(void) { - u8 mac_addr[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; - ssize_t len; - meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { - len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, - mac_addr, EFUSE_MAC_SIZE); - if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) - eth_env_set_enetaddr("ethaddr", mac_addr); - } - - if (!env_get("serial#")) { - len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, - EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) - env_set("serial#", serial); - } + meson_init_env_from_efuse(); return 0; } diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c index 2a2755c387..fffd225485 100644 --- a/board/amlogic/odroid-c2/odroid-c2.c +++ b/board/amlogic/odroid-c2/odroid-c2.c @@ -5,18 +5,12 @@ #include #include -#include #include #include #include #include #include -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 - int board_init(void) { return 0; @@ -24,25 +18,8 @@ int board_init(void) int misc_init_r(void) { - u8 mac_addr[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; - ssize_t len; - meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { - len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, - mac_addr, EFUSE_MAC_SIZE); - if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) - eth_env_set_enetaddr("ethaddr", mac_addr); - } - - if (!env_get("serial#")) { - len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, - EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) - env_set("serial#", serial); - } + meson_init_env_from_efuse(); return 0; } diff --git a/board/amlogic/p212/p212.c b/board/amlogic/p212/p212.c index 06c2eaee47..57f776f404 100644 --- a/board/amlogic/p212/p212.c +++ b/board/amlogic/p212/p212.c @@ -6,18 +6,12 @@ #include #include -#include #include #include #include #include #include -#define EFUSE_SN_OFFSET 20 -#define EFUSE_SN_SIZE 16 -#define EFUSE_MAC_OFFSET 52 -#define EFUSE_MAC_SIZE 6 - int board_init(void) { return 0; @@ -25,25 +19,8 @@ int board_init(void) int misc_init_r(void) { - u8 mac_addr[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; - ssize_t len; - meson_gx_eth_init(PHY_INTERFACE_MODE_RMII, 0); - - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { - len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, - mac_addr, EFUSE_MAC_SIZE); - if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) - eth_env_set_enetaddr("ethaddr", mac_addr); - } - - if (!env_get("serial#")) { - len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, - EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) - env_set("serial#", serial); - } + meson_init_env_from_efuse(); return 0; } From patchwork Tue Aug 14 13:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 10565605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 570F615A6 for ; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480B428C08 for ; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BEA928D2E; Tue, 14 Aug 2018 13:08:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE9F828C08 for ; Tue, 14 Aug 2018 13:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gZrZCJCe7GAmpM4I3eLcTxQp0h36dcSvOLR00Y5P8jA=; b=uMSVftwmrWlpXyYtE6vUsmAHQn JmULC25Z6GWb8o+T5XTzmCU+Bc4L382vvNI5iGobK82oh1Qd+oG8xwZzDz0FUPZWNMB/E5UjYfUvh n47q7xTfTvC1umLjyOvRwbFIQR+4bOFvd0ele1MhX1/fGm7j2YCDSDWdvsiPZ2NM4K/IWa93nXP0u Vl1POlwTkgPrVsfA2FPMt0GT5KshwOQ82yqfmAAmw3P40H5UgHSb1h4zLz3FdSkUw6lJSgnLQeo64 ea8IjTZZMDT49ue+mF/U/yg/UoVa7nWC1n4jYtOWaMDO1MhoKS4TruJ22FueC65Ddd19ttalbxMmL pNcxTTag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ41-0000O3-52; Tue, 14 Aug 2018 13:08:45 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpZ3y-0000Ht-48 for linux-amlogic@lists.infradead.org; Tue, 14 Aug 2018 13:08:43 +0000 Received: by mail-wm0-x230.google.com with SMTP id f21-v6so12220129wmc.5 for ; Tue, 14 Aug 2018 06:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vbwcmEcIuXUb0QLlRaSWHDMULR+42njV+zBxN930Ol0=; b=rcHY3Puk9MSpXE508H8jTg1o/pvbEjeBd7DxgvabMtf4xD5WHMGRp/92D0oGF/Bgd8 PLdSHQJzNThktxduQhzEFRmxhOlRPFINPloNfsePoik3EfSAAiTSI3VEdvGxVHvHvPJc C6tl+NxV7x3LCxm1BayKuUtIaT/c9anvLQQWXwtQ0wIvw/Nl7gsxy6S+cLlCgSCB5pw+ Yy0QgnV3ewrFSsYHbPPq4vt4p8Wxh6cmbhLCoijRsLAyjbmGW4+QQYGvu5JMsx6V9IeS Zl1gzAFJkDfgoi1XORRbSnSDKNV5tsRKqHNNozoUtsD0ndui5x35BUaQfvle8sfOJGKn iTww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vbwcmEcIuXUb0QLlRaSWHDMULR+42njV+zBxN930Ol0=; b=ONJa6PPRYVjdS+bT6YFL24NiDTBjWywa5gLEY4SivvWG0OWtr5IdX9cj6P6AHpoHoN rQ4eDhOb4uGfvwrstYSYGE6ia9EQ/Ado33+Vk7NjDVMhgpi+VgLYPibKYfKO19cqNi7a fRGI3W0x2ZsjrMqANZUcxCJRnA76KUoDxK/SUeouk0vVVPUH6VN2Arf07botOvQR/STD 3v6XSV/kyWub9puEQsEOvgAaLs0aK91mFTegyOQIlUJ6J+fC143S8A3zK3Q/cUE3H+4C ABaoSk2SW1I9EGJqiLK+AsI6+T6Vzd8HZoGgPNhX29VWDGQEYpoLhfyEDKciweovsnh/ Hwmg== X-Gm-Message-State: AOUpUlHxtCrbUspQzueVE3W1g+VjeNaMeSQa1M4z7r+FYmb+j+YjVdAd 4lJixkkt6Ay+OJk5kydtBJW+Jd7T X-Google-Smtp-Source: AA+uWPxuEx73CO1T8icI3lFNHlz3jE1HlbSXLZc9ieq2BrzSxbTT3e0lQ2gZcWtLzUHJkaJE5p/0sw== X-Received: by 2002:a1c:ca0f:: with SMTP id a15-v6mr10409621wmg.102.1534252108700; Tue, 14 Aug 2018 06:08:28 -0700 (PDT) Received: from sark.homenet.telecomitalia.it ([79.46.68.202]) by smtp.gmail.com with ESMTPSA id r16-v6sm29123997wru.59.2018.08.14.06.08.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 06:08:27 -0700 (PDT) From: Beniamino Galvani To: u-boot@lists.denx.de Subject: [PATCH u-boot 3/3] arm: meson: null-terminate the serial number Date: Tue, 14 Aug 2018 15:07:54 +0200 Message-Id: <20180814130754.19294-4-b.galvani@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814130754.19294-1-b.galvani@gmail.com> References: <20180814130754.19294-1-b.galvani@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_060842_325836_510F8F5E X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rini , Albert Aribaud , Neil Armstrong , Simon Glass , Beniamino Galvani , linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Terminate the serial number variable with null to avoid printing trailing garbage. Signed-off-by: Beniamino Galvani --- arch/arm/mach-meson/sm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c index 2628591fe6..23eafe87b4 100644 --- a/arch/arm/mach-meson/sm.c +++ b/arch/arm/mach-meson/sm.c @@ -64,7 +64,7 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size) void meson_init_env_from_efuse(void) { static u8 mac[EFUSE_MAC_SIZE]; - char serial[EFUSE_SN_SIZE]; + char serial[EFUSE_SN_SIZE + 1]; ssize_t len; if (!eth_env_get_enetaddr("ethaddr", mac)) { @@ -77,7 +77,9 @@ void meson_init_env_from_efuse(void) if (!env_get("serial#")) { len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, EFUSE_SN_SIZE); - if (len == EFUSE_SN_SIZE) + if (len == EFUSE_SN_SIZE) { + serial[EFUSE_SN_SIZE] = '\0'; env_set("serial#", serial); + } } }