From patchwork Fri Feb 2 08:06:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 10196347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D31AC603D7 for ; Fri, 2 Feb 2018 08:05:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0BF128E14 for ; Fri, 2 Feb 2018 08:05:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B145628E18; Fri, 2 Feb 2018 08:05:31 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 B8FBB28E14 for ; Fri, 2 Feb 2018 08:05:30 +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=o3bFZxBXDp324srmQ2H4Jf0rSRuyIA+dI1qgtr/Rd/4=; b=RWFdPavyZJxK7m bc5Ue9bkLZ3Vo3/ausomOU+i24xpyHJQQqBHvjoOoAu86dUxi8OrOodnJ8joLdBQc6dAYqVcbg9Zg vea04rmDxYocGV+6T2sOKdegPKRY5VsXW1/9xK/fTr9hnE53G+q3i9asX5Ex8ncryf1xKlcfpBLDU DanF7nQM6f0AVFLtWrVxSXGxXTEhVe162OkKUSET2SIdM4kmfAdmbYbDa84UoLJZWveT0VMwlDhfn /2KuaimwUI6dS8UEW22Jvc9Q1iPyysRMWnO6bbGzlBFEZvwwWZTesAGNw5mKfvZ6FqkMgo6tWq02a HoKqHPkbQ5QpseUokXPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ehWLd-0007FI-NL; Fri, 02 Feb 2018 08:05:25 +0000 Received: from mail-am5eur03on0604.outbound.protection.outlook.com ([2a01:111:f400:fe08::604] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ehWLY-000796-I3 for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2018 08:05:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ovGPunJKEC5eRuNTL3DviBWttWgYm9pACkbrlXhXavU=; b=q4F2lxVu/7wC8yZ050EuEuRb/VVXxyAaZORRYxEkqyEXXc4Lq+Pzqz7lXnfBsEcNYniEdz/2wXPoE1AL59bd/FzWK4JDWjOAghpmQbjJNodCop4unyyIVWBpk6+2bVnBI0VLSr5oEOpXaZi4zDMzSGY4aI2l6DhRht5agE7PEk4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ping.bai@nxp.com; Received: from localhost.localdomain (92.121.68.129) by DB6PR04MB3109.eurprd04.prod.outlook.com (2603:10a6:6:c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Fri, 2 Feb 2018 08:05:02 +0000 From: Bai Ping To: shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com Subject: [PATCH v2] ARM: imx: Improve the soc revision calculation flow Date: Fri, 2 Feb 2018 16:06:27 +0800 Message-Id: <1517558787-12858-1-git-send-email-ping.bai@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK2P15301CA0012.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::22) To DB6PR04MB3109.eurprd04.prod.outlook.com (2603:10a6:6:c::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7fcb6fb2-d959-4e96-6e98-08d56a13ab7d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DB6PR04MB3109; X-Microsoft-Exchange-Diagnostics: 1; DB6PR04MB3109; 3:if6yaI1k+sreNLxGYeaFq3TEVrZWUiDTkKTYLN3y2MpGJgTec6nLSKsIEX7cxxAF6SHPaeWWtpYY+Gt5XNIpHV4s0r4xg27KkWG9q5LvBc/feKxZnsJFxfEfdX89z0tRtY6gZyGLBPADl9penJhabRG+Iwkurc1FOwOpnhom2IoFC8u8W3KaJp913TzyvqzgfhG8/yLcZk+x2FuO6/hIedDT+YDi+Z9amEgtzQrMrpzaW3/tuYtNqXpU/8sht0aG; 25:etxCusDE05fP5p+KQ2yEfNogk2magj3B5BCqyCCMgn3FEM8HSRfBQ9xmBhst4fV0jyjZ20I0qu9RVhBxDNJ9y4+o7gelHxR74CcwsF4TQOm2lsopNHeI8I1JuAy1j7CIj6fp1AWGV+teKP3Z+X3V8wx+Icpz8trmDjvYhUBR0k7dD7lYymQKjli0lHgXHL4G+reRouSf9WVp68Z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aJgEkykbSR6TfFd7/FaSENLNPa69M4q8QSJdKrNoWSJLH5VsuMXn0Xj3KdTNxZjPpR2AktW6WDWswHL0ELUjJd8RyA2DEQewVi7TfQm49THlfL3ylFJQleMOfRT6bt2TIfkyrl06od5wZCNJVFhLdwl0Wmyo038LpJkzAv6mEKpj/0/J2KX9HY8vqX0AbNuVygdJC93q X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DB6PR04MB3109; BCL:0; PCL:0; RULEID:; SRVR:DB6PR04MB3109; X-Forefront-PRVS: 05715BE7FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(39860400002)(376002)(346002)(366004)(39380400002)(43544003)(189003)(199004)(36756003)(386003)(8676002)(105586002)(8936002)(52116002)(316002)(81156014)(50226002)(51416003)(6116002)(106356001)(81166006)(2906002)(3846002)(6636002)(68736007)(6506007)(5660300001)(478600001)(97736004)(4326008)(6512007)(86362001)(6666003)(6486002)(50466002)(48376002)(66066001)(39060400002)(305945005)(16526019)(16586007)(53936002)(7736002)(186003)(25786009)(47776003)(26005)(25903002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR04MB3109; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR04MB3109; 23:NqBtQhC7nFzrvojFqMwV0r1zTazP365tFPce4toFo?= =?us-ascii?Q?Msh56RavXUJ1M8NZDGKZ2hEkF48N7WP7QhlgDktDF1hM12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ZoihViZytNB44VtJZvDnY05Tq7ZwkBCO0D99d3j/fiKGfq3yqjBnQr6NarzogplMDikZs+/1IAOY+LqYla18Z8BTyf4lVX1Tmot7kSd9797zK+hsSl+BR26AqafQarl+IcIxBL8xBKIH SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2018 08:05:02.4652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fcb6fb2-d959-4e96-6e98-08d56a13ab7d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3109 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: aisheng.dong@nxp.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, jacky.baip@gmail.com 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 On our i.MX6 SOC, the DIGPROG register is used for representing the SOC ID and silicon revision. The revision has two part: MAJOR and MINOR. each is represented in 8 bits in the register. bits [15:8]: reflect the MAJOR part of the revision; bits [7:0]: reflect the MINOR part of the revision; In our linux kernel, the soc revision is represented in 8 bits. MAJOR part and MINOR each occupy 4 bits. previous method does NOT take care about the MAJOR part in DIGPROG register. So reformat the revision read from the HW to be compatible with the revision format used in kernel. Signed-off-by: Bai Ping Tested-by: Christoph Fritz --- v2: - remove redundant line - use u8 instead of u16 for 'major_part'&'minor_part' variables --- arch/arm/mach-imx/anatop.c | 56 ++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/arch/arm/mach-imx/anatop.c b/arch/arm/mach-imx/anatop.c index 649a84c..61f3d94 100644 --- a/arch/arm/mach-imx/anatop.c +++ b/arch/arm/mach-imx/anatop.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2013-2015 Freescale Semiconductor, Inc. + * Copyright 2017-2018 NXP. * * The code contained herein is licensed under the GNU General Public * License. You may obtain a copy of the GNU General Public License @@ -116,6 +117,7 @@ void __init imx_init_revision_from_anatop(void) unsigned int revision; u32 digprog; u16 offset = ANADIG_DIGPROG; + u8 major_part, minor_part; np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); anatop_base = of_iomap(np, 0); @@ -127,45 +129,25 @@ void __init imx_init_revision_from_anatop(void) digprog = readl_relaxed(anatop_base + offset); iounmap(anatop_base); - switch (digprog & 0xff) { - case 0: - /* - * For i.MX6QP, most of the code for i.MX6Q can be resued, - * so internally, we identify it as i.MX6Q Rev 2.0 - */ - if (digprog >> 8 & 0x01) - revision = IMX_CHIP_REVISION_2_0; - else - revision = IMX_CHIP_REVISION_1_0; - break; - case 1: - revision = IMX_CHIP_REVISION_1_1; - break; - case 2: - revision = IMX_CHIP_REVISION_1_2; - break; - case 3: - revision = IMX_CHIP_REVISION_1_3; - break; - case 4: - revision = IMX_CHIP_REVISION_1_4; - break; - case 5: - /* - * i.MX6DQ TO1.5 is defined as Rev 1.3 in Data Sheet, marked - * as 'D' in Part Number last character. - */ - revision = IMX_CHIP_REVISION_1_5; - break; - default: + /* + * On i.MX7D digprog value match linux version format, so + * it needn't map again and we can use register value directly. + */ + if (of_device_is_compatible(np, "fsl,imx7d-anatop")) { + revision = digprog & 0xff; + } else { /* - * Fail back to return raw register value instead of 0xff. - * It will be easy to know version information in SOC if it - * can't be recognized by known version. And some chip's (i.MX7D) - * digprog value match linux version format, so it needn't map - * again and we can use register value directly. + * MAJOR: [15:8], the major silicon revison; + * MINOR: [7: 0], the minor silicon revison; + * + * please refer to the i.MX RM for the detailed + * silicon revison bit define. + * format the major part and minor part to match the + * linux kernel soc version format. */ - revision = digprog & 0xff; + major_part = (digprog >> 8) & 0xf; + minor_part = digprog & 0xf; + revision = ((major_part + 1) << 4) | minor_part; } mxc_set_cpu_type(digprog >> 16 & 0xff);