mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM
	BCM7XXX ARM ARCHITECTURE)
Subject: [PATCH 1/3] memory: brcmstb_memc: Cache configuration register value
Date: Fri, 24 Mar 2023 09:52:29 -0700	[thread overview]
Message-ID: <20230324165231.3468069-2-f.fainelli@gmail.com> (raw)
In-Reply-To: <20230324165231.3468069-1-f.fainelli@gmail.com>

The configuration register does not change once the DDR controller is
configured, in preparation for providing more information about the DDR
type/width in subsequent changes, store this value so we can retrieve
it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/memory/brcmstb_memc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/memory/brcmstb_memc.c b/drivers/memory/brcmstb_memc.c
index 233a53f5bce1..67c75e21c95e 100644
--- a/drivers/memory/brcmstb_memc.c
+++ b/drivers/memory/brcmstb_memc.c
@@ -29,18 +29,15 @@ struct brcmstb_memc {
 	struct device *dev;
 	void __iomem *ddr_ctrl;
 	unsigned int timeout_cycles;
+	u32 config_reg;
 	u32 frequency;
 	u32 srpd_offset;
 };
 
 static int brcmstb_memc_uses_lpddr4(struct brcmstb_memc *memc)
 {
-	void __iomem *config = memc->ddr_ctrl + REG_MEMC_CNTRLR_CONFIG;
-	u32 reg;
-
-	reg = readl_relaxed(config) & CNTRLR_CONFIG_MASK;
-
-	return reg == CNTRLR_CONFIG_LPDDR4_SHIFT;
+	return (memc->config_reg & CNTRLR_CONFIG_MASK) ==
+		CNTRLR_CONFIG_LPDDR4_SHIFT;
 }
 
 static int brcmstb_memc_srpd_config(struct brcmstb_memc *memc,
@@ -148,6 +145,9 @@ static int brcmstb_memc_probe(struct platform_device *pdev)
 	of_property_read_u32(pdev->dev.of_node, "clock-frequency",
 			     &memc->frequency);
 
+	memc->config_reg = readl_relaxed(memc->ddr_ctrl +
+					 REG_MEMC_CNTRLR_CONFIG);
+
 	ret = sysfs_create_group(&dev->kobj, &dev_attr_group);
 	if (ret)
 		return ret;
-- 
2.34.1


  reply	other threads:[~2023-03-24 16:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 16:52 [PATCH 0/3] memory: brcmstb_memc: Report more DDR information Florian Fainelli
2023-03-24 16:52 ` Florian Fainelli [this message]
2023-03-24 16:52 ` [PATCH 2/3] Documentation: sysfs: brcmstb-memc: Document new attributes Florian Fainelli
2023-03-27 16:01   ` Krzysztof Kozlowski
2023-03-24 16:52 ` [PATCH 3/3] memory: brcmstb_memc: Add new DDR attributes Florian Fainelli
2023-03-27 16:04   ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230324165231.3468069-2-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®