From patchwork Wed May 6 08:49:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 6347881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2884FBEEE1 for ; Wed, 6 May 2015 08:57:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A21A20268 for ; Wed, 6 May 2015 08:57:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FE7920265 for ; Wed, 6 May 2015 08:57:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ypv64-0003rg-1K; Wed, 06 May 2015 08:54:28 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ypv1X-0008KC-NI for linux-arm-kernel@lists.infradead.org; Wed, 06 May 2015 08:49:48 +0000 Received: by widdi4 with SMTP id di4so13787005wid.0 for ; Wed, 06 May 2015 01:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=gj4Ni1U9Cw0AKRrAfnEvEXONz/mYbp/lblE3sHivCa8=; b=yeLOGU0hk+BjEwmP6blqKzBnqSxdtfykwktbah/lxxfIHhxwL+R6m77k3WnbH5Naud bfavAB1R9b3aMZKJRdoyioeAiAA7Sb0diczAy50rfUVzKhgzBiEH3k71/hieWtRoAwdU k4LSzJpjLkrUqWkj1KScnOAYQVZTimQRfC+sJ4ouc6X2D+pcl9pDA1fW2CnREyaSvSSC kNzmR1vSEe6zGcpwwgVIpxy92k44OYe8tFfNEeGl0PTD6j76GMOToQk1VQnUsJyGel82 2mpZcy+wnQWAnKFtRownJVnBtWkwFsX57NfhHor+7BJYleTytjKjb+v8niohJ07xciNi BvKg== X-Received: by 10.194.121.135 with SMTP id lk7mr16500837wjb.26.1430902165053; Wed, 06 May 2015 01:49:25 -0700 (PDT) Received: from atrey.karlin.mff.cuni.cz (atrey.karlin.mff.cuni.cz. [195.113.26.193]) by mx.google.com with ESMTPSA id be3sm1087590wib.21.2015.05.06.01.49.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 May 2015 01:49:24 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Rob Herring , Russell King , Will Deacon , Ivaylo Dimitrov , Sebastian Reichel , Pavel Machek , Tony Lindgren , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [RESEND] [PATCH v2 2/2] arm: boot: convert ATAG_REVISION to DT revision field Date: Wed, 6 May 2015 10:49:02 +0200 Message-Id: <1430902142-17035-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1430902142-17035-1-git-send-email-pali.rohar@gmail.com> References: <1430902142-17035-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150506_014948_013572_3DBCE67B X-CRM114-Status: GOOD ( 16.40 ) X-Spam-Score: -0.8 (/) Cc: linux-omap@vger.kernel.org, "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , =?UTF-8?q?Pali=20Roh=C3=A1r?= X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ATAG_REVISION is unsigned number and revision in DT is stored as hexadecimal string value. It means that it will be correctly parsed by kernel. Signed-off-by: Pali Rohár Acked-by: Pavel Machek --- arch/arm/boot/compressed/atags_to_fdt.c | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c index 9448aa0..b23748e 100644 --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -97,6 +97,39 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) setprop_string(fdt, "/chosen", "bootargs", cmdline); } +static void tohexstr(char * str, int size, unsigned int num) +{ + int len = 0; + int i, tmp; + + if (size < 4) { + if (size > 0) + str[0] = 0; + return; + } + + str[len++] = '0'; + str[len++] = 'x'; + + while (len-1 < size && num) { + tmp = num % 16; + if (tmp >= 10) + tmp += 'A'; + else + tmp += '0'; + str[len++] = tmp; + num /= 16; + } + + str[len] = 0; + + for (i = 2; i < 2+(len-2)/2; ++i) { + tmp = str[i]; + str[i] = str[len-i+1]; + str[len-i+1] = tmp; + } +} + /* * Convert and fold provided ATAGs into the provided FDT. * @@ -171,6 +204,10 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) cpu_to_fdt32(atag->u.mem.size); } + } else if (atag->hdr.tag == ATAG_REVISION) { + char revision[11]; + tohexstr(revision, sizeof(revision), atag->u.revision.rev); + setprop_string(fdt, "/", "revision", revision); } else if (atag->hdr.tag == ATAG_INITRD2) { uint32_t initrd_start, initrd_size; initrd_start = atag->u.initrd.start;