From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C1E0C04A6B for ; Wed, 8 May 2019 12:40:32 +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 3DFB420449 for ; Wed, 8 May 2019 12:40:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jm1TL/kp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DFB420449 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sigxcpu.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=ft3x7Urw1sOFjaiM5iKctKLSH77lfO1yknPH8kvoygU=; b=jm1TL/kpxHFbXl zvWoQHQfPPnHCVE05XsAzS+dVPBTrNac69l/DYwrqNFeOKqoYGQ70Ynihe1f8nH4Az53+78tyBrjZ l1CfJAyVvuF5lyAMEVMPfBuPs++dR5Tb9Hcc/IsFXmLl8zIoK1uL8mpL0/cQU2Fltk/gd6YNIB847 d1h150r51O7orFbWSSD5QSaQJGeYWgKt9AXL6oM96T/5s5gRuRUHpVlnIoJFzdf+W4+e5zIMrjnKz PlSi5R3eDVnN+kSRqJ9YwfAwKHZVtypofSfRooJxqTxdOHI4yJOclfb/qm4il+gPeA+skm+lJ0Xgg itJl1ar++SEVX5LrbPPg==; 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 1hOLs3-0000ju-8P; Wed, 08 May 2019 12:40:27 +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 1hOLrz-0000iz-62 for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2019 12:40:25 +0000 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id C0045FB03; Wed, 8 May 2019 14:40:20 +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 nZU3glKHYqCD; Wed, 8 May 2019 14:40:18 +0200 (CEST) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id 566BE47B7D; Wed, 8 May 2019 14:40:18 +0200 (CEST) Date: Wed, 8 May 2019 14:40:18 +0200 From: Guido =?iso-8859-1?Q?G=FCnther?= To: Leonard Crestez , Abel Vesa , Lucas Stach Subject: [RFC PATCH] soc: imx: Try harder to get imq8mq SoC revisions Message-ID: <20190508124018.GA16859@bogon.m.sigxcpu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190508_054023_535430_BE82FDA3 X-CRM114-Status: GOOD ( 15.29 ) 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: Jacky Bai , Anson Huang , Fabio Estevam , Sascha Hauer , "linux-kernel@vger.kernel.org" , dl-linux-imx , Pengutronix Kernel Team , Shawn Guo , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Leonard, Thanks for your comments. Let's try s.th. different then: identify by bootrom, ocotop and anatop and fall back to ATF afterwards (I'll split out the DT part and add binding docs if this makes sense). I'm also happy to drop the whole ATF logic until mailine ATF catched up: The mainline ATF doesn't currently support the FSL_SIP_GET_SOC_INFO call nor does it have the code to identify different imx8mq SOC revisions so mimic what NXPs ATF does here. As a fallback use ATF so we can identify new revisions once it gains support or when using NXPs ATF. Signed-off-by: Guido G=FCnther --- arch/arm64/boot/dts/freescale/imx8mq.dtsi | 12 ++++ drivers/soc/imx/soc-imx8.c | 68 ++++++++++++++++++----- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dt= s/freescale/imx8mq.dtsi index 6d635ba0904c..52aa1600b33b 100644 --- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi @@ -246,6 +246,18 @@ ranges =3D <0x0 0x0 0x0 0x3e000000>; dma-ranges =3D <0x40000000 0x0 0x40000000 0xc0000000>; = + bus@00000000 { /* ROM */ + compatible =3D "simple-bus"; + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x00000000 0x00000000 0x20000>; + + rom@00000000 { + compatible =3D "fsl,imx8mq-bootrom"; + reg =3D <0x00000000 0x1e800>; + }; + }; + bus@30000000 { /* AIPS1 */ compatible =3D "fsl,imx8mq-aips-bus", "simple-bus"; #address-cells =3D <1>; diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c index fc6429f9170a..0a1fe82efe86 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,39 +12,80 @@ #include #include = +#define REV_A0 0x10 +#define REV_B0 0x20 #define REV_B1 0x21 = +#define IMX8MQ_SW_INFO_A0 0x800 +#define IMX8MQ_SW_INFO_B0 0x83C #define IMX8MQ_SW_INFO_B1 0x40 #define IMX8MQ_SW_MAGIC_B1 0xff0055aa = +#define FSL_SIP_GET_SOC_INFO 0xc2000006 + struct imx8_soc_data { char *name; u32 (*soc_revision)(void); }; = -static u32 __init imx8mq_soc_revision(void) +static u32 __init imx8mq_soc_revision_atf(void) +{ + struct arm_smccc_res res =3D { 0 }; + + arm_smccc_smc(FSL_SIP_GET_SOC_INFO, 0, 0, 0, 0, 0, 0, 0, &res); + /* + * 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 res.a0 & 0xff; +} + +static u32 __init imx8mq_soc_magic_node(const char *node, u32 offset) { struct device_node *np; - void __iomem *ocotp_base; + void __iomem *base; u32 magic; - u32 rev =3D 0; = - np =3D of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp"); + np =3D of_find_compatible_node(NULL, NULL, node); if (!np) - goto out; + return 0; + base =3D of_iomap(np, 0); + WARN_ON(!base); + + magic =3D readl_relaxed(base + offset); + iounmap(base); + of_node_put(np); + + return magic; +} = - ocotp_base =3D of_iomap(np, 0); - WARN_ON(!ocotp_base); +static u32 __init imx8mq_soc_revision(void) +{ + u32 magic; = - magic =3D readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1); + /* B1 revision identified by ocotop */ + magic =3D imx8mq_soc_magic_node("fsl,imx8mq-ocotp", IMX8MQ_SW_INFO_B1); if (magic =3D=3D IMX8MQ_SW_MAGIC_B1) - rev =3D REV_B1; + return REV_B1; = - iounmap(ocotp_base); + /* B0 identified by bootrom */ + magic =3D imx8mq_soc_magic_node("fsl,imx8mq-bootrom", IMX8MQ_SW_INFO_B0); + if ((magic & 0xff) =3D=3D REV_B0) + return REV_B0; = -out: - of_node_put(np); - return rev; + /* A0 identified by anatop */ + magic =3D imx8mq_soc_magic_node("fsl,imx8mq-anatop", IMX8MQ_SW_INFO_A0); + if ((magic & 0xff) =3D=3D REV_A0) + return REV_A0; + + /* Read revision from ATF as fallback */ + magic =3D imx8mq_soc_revision_atf(); + if (magic !=3D 0xff) + return magic; + + return 0; } = static const struct imx8_soc_data imx8mq_soc_data =3D { -- = 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel