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: 6347841 Return-Path: X-Original-To: patchwork-linux-omap@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 5CDEABEEE1 for ; Wed, 6 May 2015 08:49:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 706012022A for ; Wed, 6 May 2015 08:49:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 811502026C for ; Wed, 6 May 2015 08:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753559AbbEFIte (ORCPT ); Wed, 6 May 2015 04:49:34 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:38650 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753509AbbEFIt0 (ORCPT ); Wed, 6 May 2015 04:49:26 -0400 Received: by wiun10 with SMTP id n10so13764835wiu.1; 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?= Cc: linux-omap@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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;