From patchwork Wed Nov 26 12:36:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 415110 X-Patchwork-Delegate: ijc@hellion.org.uk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 0C65814017D for ; Wed, 26 Nov 2014 23:36:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 755244B6B2; Wed, 26 Nov 2014 13:36:53 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZoJhjr+f4ivF; Wed, 26 Nov 2014 13:36:53 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA1154B6C7; Wed, 26 Nov 2014 13:36:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E01F4B690 for ; Wed, 26 Nov 2014 13:36:44 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5qzwgPL3+NNr for ; Wed, 26 Nov 2014 13:36:44 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 32C754B6A8 for ; Wed, 26 Nov 2014 13:36:40 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAQCaYqT007268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 26 Nov 2014 07:36:34 -0500 Received: from shalem.localdomain.com (vpn1-4-238.ams2.redhat.com [10.36.4.238]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAQCaVid025419; Wed, 26 Nov 2014 07:36:33 -0500 From: Hans de Goede To: Ian Campbell Date: Wed, 26 Nov 2014 13:36:30 +0100 Message-Id: <1417005390-15672-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1417005390-15672-1-git-send-email-hdegoede@redhat.com> References: <1417005390-15672-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/2] sunxi: Add sunxi_get_sid helper function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On sun6i the SID is stored in the pmic, rather then in the SoC itself, add a helper function to abstract this away. This makes our MAC address generation code also work on sun6i. Signed-off-by: Hans de Goede --- arch/arm/cpu/armv7/sunxi/cpu_info.c | 19 +++++++++++++++++++ arch/arm/include/asm/arch-sunxi/cpu.h | 1 + board/sunxi/board.c | 24 +++++++++++------------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c b/arch/arm/cpu/armv7/sunxi/cpu_info.c index 5146dc4..7a3a4ca 100644 --- a/arch/arm/cpu/armv7/sunxi/cpu_info.c +++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef CONFIG_MACH_SUN6I int sunxi_get_ss_bonding_id(void) @@ -72,3 +73,21 @@ int print_cpuinfo(void) return 0; } #endif + +int sunxi_get_sid(unsigned int *sid) +{ +#ifdef CONFIG_MACH_SUN6I +#ifdef CONFIG_AXP221_POWER + return axp221_get_sid(sid); +#else + return -ENODEV; +#endif +#else + int i; + + for (i = 0; i< 4; i++) + sid[i] = readl(SUNXI_SID_BASE + 4 * i); + + return 0; +#endif +} diff --git a/arch/arm/include/asm/arch-sunxi/cpu.h b/arch/arm/include/asm/arch-sunxi/cpu.h index 8aeed2f..9500262 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu.h +++ b/arch/arm/include/asm/arch-sunxi/cpu.h @@ -147,6 +147,7 @@ void sunxi_board_init(void); void sunxi_reset(void); int sunxi_get_ss_bonding_id(void); +int sunxi_get_sid(unsigned int *sid); #endif /* __ASSEMBLY__ */ #endif /* _CPU_H */ diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 4c1c69a..b5dfe95 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -217,22 +217,20 @@ void sunxi_board_init(void) #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { - if (!getenv("ethaddr")) { - uint32_t reg_val = readl(SUNXI_SID_BASE); + unsigned int sid[4]; - if (reg_val) { - uint8_t mac_addr[6]; + if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 && + sid[0] != 0 && sid[3] != 0) { + uint8_t mac_addr[6]; - mac_addr[0] = 0x02; /* Non OUI / registered MAC address */ - mac_addr[1] = (reg_val >> 0) & 0xff; - reg_val = readl(SUNXI_SID_BASE + 0x0c); - mac_addr[2] = (reg_val >> 24) & 0xff; - mac_addr[3] = (reg_val >> 16) & 0xff; - mac_addr[4] = (reg_val >> 8) & 0xff; - mac_addr[5] = (reg_val >> 0) & 0xff; + mac_addr[0] = 0x02; /* Non OUI / registered MAC address */ + mac_addr[1] = (sid[0] >> 0) & 0xff; + mac_addr[2] = (sid[3] >> 24) & 0xff; + mac_addr[3] = (sid[3] >> 16) & 0xff; + mac_addr[4] = (sid[3] >> 8) & 0xff; + mac_addr[5] = (sid[3] >> 0) & 0xff; - eth_setenv_enetaddr("ethaddr", mac_addr); - } + eth_setenv_enetaddr("ethaddr", mac_addr); } return 0;