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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 89DF8CA9ECF for ; Mon, 4 Nov 2019 03:35:22 +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 5B99C21D71 for ; Mon, 4 Nov 2019 03:35:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LvQG5HMd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="EG4h5Lmh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B99C21D71 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.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:References: 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: List-Owner; bh=Ls4n9JQ5yjtvaWO85sn6uhWdMaLPxn/jP+7Kb11pqQs=; b=LvQG5HMd8G8Btj 3kKPrBnmgAV841RvV5/Dq5BbkRsFjTjXhcbQuVQsPdTy+UdX67VAx+7V6u3loHL3I3PBrwlV9aLol pZQ/WaD6WKb79LKNDvpadFTA2G5P837byakq3zWkzXz2RReosQUWn5tVjk/SrfJO8Qi/WFhO2dRSI WY0klaFte+KddhN228/EV6B2Hy4BcPSPjSx4wcaeDa6Ofl1aUDZZqeizHCtM3h+xsi81JHXktabTj HxOABeewsbTYfZF69y3zOwYjgtr7ZEkZjji7QEVPjVSHy7Y9A6kmh3ycQgM7Qe9ResLVGwxl9XgIE WgclVJDRWDs2f85Dm6Fg==; 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 1iRT9F-0000Wu-Or; Mon, 04 Nov 2019 03:35:21 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRT9C-0000WO-1p for linux-arm-kernel@lists.infradead.org; Mon, 04 Nov 2019 03:35:19 +0000 Received: from dragon (li1038-30.members.linode.com [45.33.96.30]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC63421D71; Mon, 4 Nov 2019 03:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572838516; bh=iroKnUAok1Sq+8IyTw9Vhovpm9pbCGUI2JQm6NnkhUc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EG4h5Lmhdnmbiok+eCDZCOhYwY3Ani6UWoGnCu5vTTH8bwZ7VrcLAvy2D4aliWTK3 N6AzpCev/yPfYXgYN4ZKkPhX82PgO/KgkT6bd7wPhpKR/+v8dZ1drlhpnhLwsHQHZw D0kcV/hZFdY8YmkA45qpIOLhGG8hJFjQptpuk+2U= Date: Mon, 4 Nov 2019 11:34:52 +0800 From: Shawn Guo To: Leonard Crestez Subject: Re: [PATCH v2] soc: imx8mq: Read SOC revision from TF-A Message-ID: <20191104033451.GN24620@dragon> References: <681dff4de9d3d0cb045b0a5883b02c04bbd2486f.1572391028.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <681dff4de9d3d0cb045b0a5883b02c04bbd2486f.1572391028.git.leonard.crestez@nxp.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191103_193518_142007_C751863C X-CRM114-Status: GOOD ( 22.24 ) 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 , Abel Vesa , Guido =?iso-8859-1?Q?G=FCnther?= , linux-imx@nxp.com, kernel@pengutronix.de, Fabio Estevam , linux-arm-kernel@lists.infradead.org, Lucas Stach Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 30, 2019 at 01:17:39AM +0200, Leonard Crestez wrote: > 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 > > --- > Changes since v1: > * Add ifdef to fix build on ARM older than v7 (kbuild robot) > Link to v1: https://patchwork.kernel.org/patch/11183813/ > > Alternatively a CONFIG_IMX8M_SOC config option could be created which > depends on HAVE_ARM_SMCCC but that also requires defconfig changes. > > drivers/soc/imx/soc-imx8.c | 32 +++++++++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c > index fcbf745a9971..6a2916664438 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 > @@ -27,10 +30,26 @@ struct imx8_soc_data { > u32 (*soc_revision)(void); > }; > > static u64 soc_uid; > > +#ifdef CONFIG_HAVE_ARM_SMCCC > +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; > +} > +#else > +static u32 imx8mq_soc_revision_from_atf(void) { return 0; }; We may want to have an inline for it. I added it and applied the patch. Shawn > +#endif > + > static u32 __init imx8mq_soc_revision(void) > { > struct device_node *np; > void __iomem *ocotp_base; > u32 magic; > @@ -41,13 +60,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); > > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel