Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp563907yba; Fri, 3 May 2019 06:59:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIkQ9m2ZwMyOA8hIyXJPtQzuZb3LEn9D1S8k1ugfnYh7To7sGSmIsAH42PhvP+K4VcQnez X-Received: by 2002:a63:a449:: with SMTP id c9mr1804881pgp.149.1556891940341; Fri, 03 May 2019 06:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556891940; cv=none; d=google.com; s=arc-20160816; b=zf8bYSxFaMwnkCOL4LNx3VCKwMFwkZDUlXQwuzAIF8dQdfTVhm/UxE7ti4bm4vdOap 2R37bacnAVod2XUueM9oUp+tRbtf3KJ42FeLbCiF3sA+Wdid+5GKIh5wBqrQAl/Rz2S2 1SPrMYW/QIdU26pPEAV1OqkRF5B8rmP/JUr6DeDPqeXSBff5MI6848rujth3GjZ3FFlU 72slz1gEQdyUCD1fsY3xC7S8ir86zBVlzOv7JT+OBvIQ8p4gXUXb2bWFiLFjfihOJzkU YhgWkbIfLVDMyABJAfYqR1ePnDQYINnCT74C4XysC7aOfJvCuWpN6sCYRrVSu27ycNS2 Muxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=F6+u8MhnimqRGYDSQQLZomQVyGzvQmnL0iJBN8Ca97Y=; b=LT2PH9UqJlGpIhOii/vzJWT9PmQx2vJziDvzBxhSnJ8CTsM9mVBNiJIwTIIv/wZX98 9yYEze4D4gcfSHqxhTKVepZQ6SPJvNovkJ1m4Wl6utkBcmGkXt6x52IoiM72KHXjDwet 5xoRS33hLgqRRK4tRpzHz9tYAVEbXB1OhIJP+zD9jBrO4HY7szNgZGgYTQOXxnNlQKep AQ28GRXcCxSKjvoPCKJ6W/lWp91Gp+54aMH/2sqZtSlpVacw76sJZ66/+NgXZzXBXKHr uxAEE2zT9yQKSrPyoRj6KWdfKfXm9g++xhmztXUqcN438z0aHxRiZ9indSbEv5/r7AJ1 l5HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si2259168pgj.46.2019.05.03.06.58.44; Fri, 03 May 2019 06:59:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727524AbfECNxS (ORCPT + 99 others); Fri, 3 May 2019 09:53:18 -0400 Received: from honk.sigxcpu.org ([24.134.29.49]:43502 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbfECNxS (ORCPT ); Fri, 3 May 2019 09:53:18 -0400 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=20G=C3=BCnther?= To: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Leonard Crestez , Abel Vesa , =?UTF-8?q?Guido=20G=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.20.1