From patchwork Thu Sep 27 18:38:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 10618493 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 633FC112B for ; Thu, 27 Sep 2018 19:18:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 118C72B984 for ; Thu, 27 Sep 2018 19:18:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0386B2B9D9; Thu, 27 Sep 2018 19:18:36 +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_SIGNED, DKIM_VALID,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 370232B0D5 for ; Thu, 27 Sep 2018 19:18:32 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=Ofn0RM8C6nqWszCJ5/mQmxHSLTrRTLY2nocPpaFm8Zs=; b=ZB8f6ThD7PhFkK sg1+TZTpsvOI54L+xI01SfWoe0lgaiNdA9Sv7lFExuh1cWn2GXrwU9oqj7XFdQtIoHe4nBDzz3w3c /T4A6YC10Ga2MUHGwwiyKSLB8wO6GOvhInqP8Rd5kszY+A2QMIvdWywalb+ZEb8rVn+NW4gNCTAz2 DoirmQhKwjjplb3TU1Y8ozyWuAYQ4DcmuhFqcwhqMJ6WOR0qk43V5micDlYApV6km5CVgPpviZtfV ysh3Q3wmwT/hC9bCi5l746+myFuE1Wwgv1k0v4zUb6S7MyaKCsfAdbweFGgBoncT4Lany9jncHO4M GN+e/HpTnUkT4/MaCasw==; 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 1g5bnw-0003pF-Rz; Thu, 27 Sep 2018 19:18:28 +0000 Received: from cpc82359-stkp12-2-0-cust135.10-2.cable.virginm.net ([86.17.48.136] helo=freya) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5baJ-00077x-JC for linux-arm-kernel@lists.infradead.org; Thu, 27 Sep 2018 19:04:25 +0000 Received: from ben by freya with local (Exim 4.91) (envelope-from ) id 1g5bAx-00060X-Lu; Thu, 27 Sep 2018 19:38:11 +0100 From: Ben Dooks To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: zImage: atags_to_fdt: add serial-number for ATAG_SERIAL Date: Thu, 27 Sep 2018 19:38:09 +0100 Message-Id: <20180927183809.23051-1-ben-linux@fluff.org> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180927_120423_629030_F88DBE47 X-CRM114-Status: GOOD ( 10.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Dooks Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the system passes an ATAG_SERIAL, convert that into a /serial-number node so that the system serial number will be present under the kernel. Signed-off-by: Ben Dooks --- arch/arm/boot/compressed/atags_to_fdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c index 41fa7316c52b..330cd3c2eae5 100644 --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -98,6 +98,24 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) setprop_string(fdt, "/chosen", "bootargs", cmdline); } +static void hex_str(char *out, uint32_t value) +{ + uint32_t digit; + int idx; + + for (idx = 7; idx >= 0; idx--) { + digit = value >> 28; + value <<= 4; + digit &= 0xf; + if (digit < 10) + digit += '0'; + else + digit += 'A'-10; + *out++ = digit; + } + *out = '\0'; +} + /* * Convert and fold provided ATAGs into the provided FDT. * @@ -180,6 +198,11 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) initrd_start); setprop_cell(fdt, "/chosen", "linux,initrd-end", initrd_start + initrd_size); + } else if (atag->hdr.tag == ATAG_SERIAL) { + char serno[16+2]; + hex_str(serno, atag->u.serialnr.high); + hex_str(serno+8, atag->u.serialnr.low); + setprop_string(fdt, "/", "serial-number", serno); } }