From patchwork Thu Oct 10 15:19:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 11183813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20CB4112B for ; Thu, 10 Oct 2019 15:19:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEE4520B7C for ; Thu, 10 Oct 2019 15:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u8Pk71ef" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEE4520B7C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=h4Z1l0T8ISY1arjej+pTZY3HDeR7k2Z2Zl6ByXJg7OI=; b=u8P k71ef4hx5/opCODQZ7htnEGZEzkJk+hXAhj0gly0KDELBkIGhUKY6lEkk7E+m7Hl5NLTXuC1ubPXe ceuYmJYXCk5WaM+/7qCYBkf3c3lbP7S9457ouAzzmC1l67vsuAmvhVX8I9QGp/1YBZgeNKJ+KLt5A E/yTbsTu86RiKJb0myBS0YZvGRAFxlYrtQdbAjcWGH3S/8Jvm+Glx9k6yfrE8Vayf0FYgOO6ORbE7 WqmltoJm8rp5EsmDObpXn/+S4kUJPKIcmjVeuExb9Pl7TluTUBrfflZ8gKOp3KlOxtS7wbHorfqmZ yjFvfjFE7i4IWsOVGSxmnu9yd1PjMVQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIaDi-0001Kp-GY; Thu, 10 Oct 2019 15:19:14 +0000 Received: from inva020.nxp.com ([92.121.34.13]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIaDf-0001KF-O6 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2019 15:19:13 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 89A941A0840; Thu, 10 Oct 2019 17:19:08 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 7D1FD1A04BD; Thu, 10 Oct 2019 17:19:08 +0200 (CEST) Received: from fsr-ub1864-112.ea.freescale.net (fsr-ub1864-112.ea.freescale.net [10.171.82.98]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 04A2A2060B; Thu, 10 Oct 2019 17:19:07 +0200 (CEST) From: Leonard Crestez To: =?utf-8?q?Guido_G=C3=BCnther?= , Shawn Guo Subject: [PATCH] soc: imx8mq: Read SOC revision from TF-A Date: Thu, 10 Oct 2019 18:19:03 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191010_081911_921832_B99AB877 X-CRM114-Status: GOOD ( 10.99 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [92.121.34.13 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Jacky Bai , Anson Huang , linux-imx@nxp.com, kernel@pengutronix.de, Fabio Estevam , Lucas Stach , linux-arm-kernel@lists.infradead.org, Abel Vesa MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org SOC revision on older imx8mq is not available in fuses so on anything other than B1 current code just reports "unknown". TF-A already handles this by parsing the ROM and exposes the value through a SMC call. Call this instead of reimplementing the workaround in the kernel itself. Signed-off-by: Leonard Crestez Reviewed-by: Abel Vesa --- This was discussed previously and but nothing was merged. I'm having trouble finding email archive links but here's one: https://patchwork.kernel.org/patch/10935599/ NXP vendor tree always used TF-A for this and from previous discussion it is reasonable to rely on firmware for workarounds. The SMC call has been in TF-A upstream for a while. drivers/soc/imx/soc-imx8.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c index b9831576dd25..20af442a247a 100644 --- a/drivers/soc/imx/soc-imx8.c +++ b/drivers/soc/imx/soc-imx8.c @@ -7,17 +7,20 @@ #include #include #include #include #include +#include #include #define REV_B1 0x21 #define IMX8MQ_SW_INFO_B1 0x40 #define IMX8MQ_SW_MAGIC_B1 0xff0055aa +#define IMX_SIP_GET_SOC_INFO 0xc2000006 + #define OCOTP_UID_LOW 0x410 #define OCOTP_UID_HIGH 0x420 /* Same as ANADIG_DIGPROG_IMX7D */ #define ANADIG_DIGPROG_IMX8MM 0x800 @@ -35,10 +38,22 @@ static ssize_t soc_uid_show(struct device *dev, return sprintf(buf, "%016llX\n", soc_uid); } static DEVICE_ATTR_RO(soc_uid); +static u32 imx8mq_soc_revision_from_atf(void) +{ + struct arm_smccc_res res; + + arm_smccc_smc(IMX_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res); + + if (res.a0 == SMCCC_RET_NOT_SUPPORTED) + return 0; + else + return res.a0 & 0xff; +} + static u32 __init imx8mq_soc_revision(void) { struct device_node *np; void __iomem *ocotp_base; u32 magic; @@ -49,13 +64,20 @@ static u32 __init imx8mq_soc_revision(void) 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; + /* + * SOC revision on older imx8mq is not available in fuses so query + * the value from ATF instead. + */ + rev = imx8mq_soc_revision_from_atf(); + if (!rev) { + magic = readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1); + if (magic == IMX8MQ_SW_MAGIC_B1) + rev = REV_B1; + } soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH); soc_uid <<= 32; soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);