From patchwork Fri May 3 13:53:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Guido_G=C3=BCnther?= X-Patchwork-Id: 10928809 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 5A1181390 for ; Fri, 3 May 2019 13:53:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A60728608 for ; Fri, 3 May 2019 13:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4892128627; Fri, 3 May 2019 13:53:30 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 8B88D2861C for ; Fri, 3 May 2019 13:53:29 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LZJogV6wMvIZUjH5I0jvW50yuqqYbaOPCut05ezV3dk=; b=G3GLNAyKoL4IZQ Cjmwov076H/BFScgXt548MTAln9vdqXaGISqMURQwvdIWjc57PsY0+1AArLkdSqJWorSZ5wZ+PQua 5KAjwhuytgsvAf7HExjUa2escUtWnfVcimn5FlwUdJ5jHozJIXT9mnkpDh/JjaBqdb8T7EMfraGA6 thY92CJ5CIKjvnYSgP9enzTrO0EEQ/tfgAkB5mU30h+9I7qfZ/68ZGKwvC3U13q3e6RIc/dLda/xF t8yD/hel13906p7vScOQMF4xbMP9xDmB6QbdlgcrAPDQeLQsWE2IAHOjVftJfhaTjj9ESO72QnSOR T5O8Sl6JFFEk47Mwv2WA==; 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 1hMYct-0003e9-Su; Fri, 03 May 2019 13:53:23 +0000 Received: from honk.sigxcpu.org ([24.134.29.49]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hMYcp-0003dE-3k for linux-arm-kernel@lists.infradead.org; Fri, 03 May 2019 13:53:21 +0000 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id 8FDABFB03; Fri, 3 May 2019 15:53:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at honk.sigxcpu.org Received: from honk.sigxcpu.org ([127.0.0.1]) by localhost (honk.sigxcpu.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ooGTtBqEb89p; Fri, 3 May 2019 15:53:13 +0200 (CEST) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id A480547CED; Fri, 3 May 2019 15:53:12 +0200 (CEST) From: =?utf-8?q?Guido_G=C3=BCnther?= To: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Leonard Crestez , Abel Vesa , =?utf-8?q?Guido_G=C3=BCnther?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: imx: Get iMX8MQ revision for B0 from ATF Date: Fri, 3 May 2019 15:53:12 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190503_065319_318078_9E8F7947 X-CRM114-Status: GOOD ( 13.67 ) 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: , 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 This is similar to what the BSP does and needed to e.g. determine necessary quirks for MIPI DSI. Signed-off-by: Guido Günther --- From the list discussion and changelog it's not clear to me why a different method was chosen for the B1 silicon so I left that in place as is and only trigger on the B0 silicon I have here. --- drivers/soc/imx/soc-imx8.c | 49 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c index fc6429f9170a..363acd1151ee 100644 --- a/drivers/soc/imx/soc-imx8.c +++ b/drivers/soc/imx/soc-imx8.c @@ -3,6 +3,7 @@ * Copyright 2019 NXP. */ +#include #include #include #include @@ -11,16 +12,37 @@ #include #include +#define REV_B0 0x20 #define REV_B1 0x21 +#define IMX8MQ_ATF_GET_SOC_INFO 0xc2000006 #define IMX8MQ_SW_INFO_B1 0x40 #define IMX8MQ_SW_MAGIC_B1 0xff0055aa + struct imx8_soc_data { char *name; u32 (*soc_revision)(void); }; + +static u32 __init imx8mq_soc_revision_from_atf(void) +{ + struct arm_smccc_res res; + u32 digprog; + + arm_smccc_smc(IMX8MQ_ATF_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res); + digprog = res.a0; + /* + * Bit [23:16] is the silicon ID + * Bit[7:4] is the base layer revision, + * Bit[3:0] is the metal layer revision + * e.g. 0x10 stands for Tapeout 1.0 + */ + return digprog & 0xff; +} + + static u32 __init imx8mq_soc_revision(void) { struct device_node *np; @@ -29,20 +51,23 @@ static u32 __init imx8mq_soc_revision(void) u32 rev = 0; np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp"); - if (!np) - goto out; - - ocotp_base = of_iomap(np, 0); - WARN_ON(!ocotp_base); - - magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1); - if (magic == IMX8MQ_SW_MAGIC_B1) - rev = REV_B1; - - iounmap(ocotp_base); + if (np) { + ocotp_base = of_iomap(np, 0); + WARN_ON(!ocotp_base); + + magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1); + iounmap(ocotp_base); + of_node_put(np); + if (magic == IMX8MQ_SW_MAGIC_B1) + rev = REV_B1; + } + if (!rev) { + magic = imx8mq_soc_revision_from_atf(); + if (magic == REV_B0) + rev = REV_B0; + } out: - of_node_put(np); return rev; }