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=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 17420C4741F for ; Thu, 5 Nov 2020 09:07:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 863492080D for ; Thu, 5 Nov 2020 09:07:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jmswOsFT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 863492080D 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+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=merlin.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=o4gGKBrD3kqSn5xHywOH/RDG2uOWLlE+dAC/AsqonN0=; b=jmswOsFT2BejbR5gLnP72slZT TPq8cRZFvSvHU1R9jTaETwXaLnabFOTjSl+a99XYj2Bo4oGfoGO0PMzDBlaAvdGgJow7hBEy/LIch yOitfR5lhZ2jadHUkuvGcnQU7v88Phx3abKAw3pAxGajkSJ6yW6LUAlbgAhomhVN1sLF6i7jIGeps pNIfYOXlGXZyQ6jX+jBSxQJSGVZ1X4u37CVc4/t/qUw3xEPtcg4uNQEy90/aX0rb6KvBcJhldYlyf HVLABjDRVU1YWWAXkk3KfiHrBMpB9jzBnNNtLIWLlzfgdJQLhq8SCOQtsCUH9svKaJq3aRySMrxhi YekNlP+3g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kabE4-0007Jl-Cu; Thu, 05 Nov 2020 09:06:36 +0000 Received: from mail-ej1-f65.google.com ([209.85.218.65]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kabE0-0007IO-P1 for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2020 09:06:33 +0000 Received: by mail-ej1-f65.google.com with SMTP id o21so1542862ejb.3 for ; Thu, 05 Nov 2020 01:06:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lCX5AAyN3xhJT1Mr0weeEfFOOHXZuEKis1CZnrJO9rI=; b=cg7PePJj37fg5GinjqJFLcbWHyHABPDTHHSYeqkosV44RplcagjZRGEiPGhCcC5JvR +/nobzsF6UhG5aC+fHPQoElHmtC4ue9XtM67sxkHCR6OA1lEEIHgCQEvLgAWsN/Xy7nR 5KQxcDrX3ppNLAEZQJSLt2/zfvkpQ+BKxdheCwij8gX1R8GFovrLF+oMa/9U08efpVhD 4VPNYXg5K0UEF3d5gw0VNE0H3GvExQpmN2ha7I5ZQPtwoblesJ3UF104t+TLyzmW3KhJ XWnnvCNynrQauj6xN1EWJAFmHWSCg232LDFQeZXeIEK+cxHHfDoYraufpQEzAmQ/r+l1 XSpA== X-Gm-Message-State: AOAM531lJGJB9GVbM0EbQRydKctb1fU6CYEur73y4scP5sVIuakakV6K Du7BPuORKwTTYO2aBFFCIB8= X-Google-Smtp-Source: ABdhPJyS7GhTRIIR+ep4Z1RpRHO87lQULzwSQcQOBkejlGZQzAIlIBeJvP9ELE21n1RyT7cZnU4fow== X-Received: by 2002:a17:906:7016:: with SMTP id n22mr1408325ejj.402.1604567190736; Thu, 05 Nov 2020 01:06:30 -0800 (PST) Received: from kozik-lap (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.googlemail.com with ESMTPSA id h8sm498072eds.51.2020.11.05.01.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 01:06:29 -0800 (PST) Date: Thu, 5 Nov 2020 10:06:28 +0100 From: Krzysztof Kozlowski To: Alice Guo Subject: Re: [PATCH v2 4/4] soc: imx8m: change to use platform driver Message-ID: <20201105090628.GA75895@kozik-lap> References: <20201105072629.24175-1-alice.guo@nxp.com> <20201105072629.24175-4-alice.guo@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201105072629.24175-4-alice.guo@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201105_040632_847433_6163B41F X-CRM114-Status: GOOD ( 28.98 ) 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: devicetree@vger.kernel.org, peng.fan@nxp.com, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-imx@nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 05, 2020 at 03:26:29PM +0800, Alice Guo wrote: > Directly reading ocotp register depends on that bootloader enables ocotp > clk, which is not always effective, so change to use nvmem API. Using > nvmem API requires to support driver defer probe and thus change > soc-imx8m.c to use platform driver. > > The other reason is that directly reading ocotp register causes kexec > kernel hang because the 1st kernel running will disable unused clks > after kernel boots up, and then ocotp clk will be disabled even if > bootloader enables it. When kexec kernel, ocotp clk needs to be enabled > before reading ocotp registers, and nvmem API with platform driver > supported can accomplish this. > > Signed-off-by: Alice Guo > --- > drivers/soc/imx/soc-imx8m.c | 75 +++++++++++++++++++++---------------- > 1 file changed, 42 insertions(+), 33 deletions(-) > > diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c > index cc57a384d74d..83f3297509be 100644 > --- a/drivers/soc/imx/soc-imx8m.c > +++ b/drivers/soc/imx/soc-imx8m.c > @@ -5,6 +5,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -29,7 +31,7 @@ > > struct imx8_soc_data { > char *name; > - u32 (*soc_revision)(void); > + u32 (*soc_revision)(struct device *dev); > }; > > static u64 soc_uid; > @@ -50,12 +52,15 @@ static u32 imx8mq_soc_revision_from_atf(void) > static inline u32 imx8mq_soc_revision_from_atf(void) { return 0; }; > #endif > > -static u32 __init imx8mq_soc_revision(void) > +static u32 __init imx8mm_soc_uid(struct device *dev); > + > +static u32 __init imx8mq_soc_revision(struct device *dev) > { > struct device_node *np; > void __iomem *ocotp_base; > u32 magic; > u32 rev; > + int ret = 0; > > np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp"); > if (!np) > @@ -75,9 +80,9 @@ static u32 __init imx8mq_soc_revision(void) > rev = REV_B1; > } > > - soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH); > - soc_uid <<= 32; > - soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW); > + ret = imx8mm_soc_uid(dev); > + if (ret) > + return ret; > > iounmap(ocotp_base); > of_node_put(np); > @@ -85,33 +90,20 @@ static u32 __init imx8mq_soc_revision(void) > return rev; > } > > -static void __init imx8mm_soc_uid(void) > +static u32 __init imx8mm_soc_uid(struct device *dev) > { > - void __iomem *ocotp_base; > - struct device_node *np; > - u32 offset = of_machine_is_compatible("fsl,imx8mp") ? > - IMX8MP_OCOTP_UID_OFFSET : 0; > - > - np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp"); > - if (!np) > - return; > - > - ocotp_base = of_iomap(np, 0); > - WARN_ON(!ocotp_base); > - > - soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset); > - soc_uid <<= 32; > - soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset); > + int ret = 0; > > - iounmap(ocotp_base); > - of_node_put(np); > + ret = nvmem_cell_read_u64(dev, "soc_unique_id", &soc_uid); > + return ret; > } > > -static u32 __init imx8mm_soc_revision(void) > +static u32 __init imx8mm_soc_revision(struct device *dev) > { > struct device_node *np; > void __iomem *anatop_base; > u32 rev; > + int ret; > > np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-anatop"); > if (!np) > @@ -125,7 +117,9 @@ static u32 __init imx8mm_soc_revision(void) > iounmap(anatop_base); > of_node_put(np); > > - imx8mm_soc_uid(); > + ret = imx8mm_soc_uid(dev); > + if (ret) > + return ret; I think this breaks old existing DTBs. If applied on separate branch than DTS patches, it will cause bisect regressions. Regardless of it, all out-of-tree (customer DTBs) will start failing here as well. Best regards, Krzysztof > > return rev; > } > @@ -151,19 +145,20 @@ static const struct imx8_soc_data imx8mp_soc_data = { > }; > > static __maybe_unused const struct of_device_id imx8_soc_match[] = { > - { .compatible = "fsl,imx8mq", .data = &imx8mq_soc_data, }, > - { .compatible = "fsl,imx8mm", .data = &imx8mm_soc_data, }, > - { .compatible = "fsl,imx8mn", .data = &imx8mn_soc_data, }, > - { .compatible = "fsl,imx8mp", .data = &imx8mp_soc_data, }, > + { .compatible = "fsl,imx8mq-soc", .data = &imx8mq_soc_data, }, > + { .compatible = "fsl,imx8mm-soc", .data = &imx8mm_soc_data, }, > + { .compatible = "fsl,imx8mn-soc", .data = &imx8mn_soc_data, }, > + { .compatible = "fsl,imx8mp-soc", .data = &imx8mp_soc_data, }, > { } > }; > +MODULE_DEVICE_TABLE(of, imx8_soc_match); > > #define imx8_revision(soc_rev) \ > soc_rev ? \ > kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \ > "unknown" > > -static int __init imx8_soc_init(void) > +static int imx8_soc_init_probe(struct platform_device *pdev) > { > struct soc_device_attribute *soc_dev_attr; > struct soc_device *soc_dev; > @@ -182,7 +177,7 @@ static int __init imx8_soc_init(void) > if (ret) > goto free_soc; > > - id = of_match_node(imx8_soc_match, of_root); > + id = of_match_node(imx8_soc_match, pdev->dev.of_node); > if (!id) { > ret = -ENODEV; > goto free_soc; > @@ -192,7 +187,11 @@ static int __init imx8_soc_init(void) > if (data) { > soc_dev_attr->soc_id = data->name; > if (data->soc_revision) > - soc_rev = data->soc_revision(); > + soc_rev = data->soc_revision(&pdev->dev); > + > + ret = soc_rev; > + if (ret < 0) > + goto free_soc; > } > > soc_dev_attr->revision = imx8_revision(soc_rev); > @@ -230,4 +229,14 @@ static int __init imx8_soc_init(void) > kfree(soc_dev_attr); > return ret; > } > -device_initcall(imx8_soc_init); > + > +static struct platform_driver imx8_soc_init_driver = { > + .probe = imx8_soc_init_probe, > + .driver = { > + .name = "imx8_soc_init", > + .of_match_table = of_match_ptr(imx8_soc_match), > + }, > +}; > + > +module_platform_driver(imx8_soc_init_driver); > +MODULE_LICENSE("GPL v2"); > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel