public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: linux-mtd@lists.infradead.org
Cc: "Marek Vasut" <marek.vasut@gmail.com>,
	"Boris Brezillon" <boris.brezillon@free-electrons.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Brian Norris" <computersforpeace@gmail.com>,
	"Richard Weinberger" <richard@nod.at>,
	linux-aspeed@lists.ozlabs.org, "Joel Stanley" <joel@jms.id.au>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PATCH 3/4] mtd: spi-nor: aspeed: retrieve the ABH clock frequency
Date: Fri, 22 Jun 2018 14:14:16 +0200	[thread overview]
Message-ID: <20180622121417.6762-4-clg@kaod.org> (raw)
In-Reply-To: <20180622121417.6762-1-clg@kaod.org>

We will need the AHB frequency to set the SPI clock frequency to
perform the SPI calibration sequence and optimize the controller
settings for the fast reads.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/spi-nor/aspeed-smc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index 054614f34698..0251724eeecb 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/bug.h>
+#include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -113,6 +114,8 @@ struct aspeed_smc_controller {
 	void __iomem *ahb_base;			/* per-chip windows resource */
 	u32 ahb_window_size;			/* full mapping window size */
 
+	unsigned long	clk_frequency;
+
 	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
 };
 
@@ -911,6 +914,7 @@ static int aspeed_smc_probe(struct platform_device *pdev)
 	struct aspeed_smc_controller *controller;
 	const struct of_device_id *match;
 	const struct aspeed_smc_info *info;
+	struct clk *clk;
 	struct resource *res;
 	int ret;
 
@@ -942,6 +946,12 @@ static int aspeed_smc_probe(struct platform_device *pdev)
 
 	controller->ahb_window_size = resource_size(res);
 
+	clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	controller->clk_frequency = clk_get_rate(clk);
+	devm_clk_put(&pdev->dev, clk);
+
 	ret = aspeed_smc_setup_flash(controller, np, res);
 	if (ret)
 		dev_err(dev, "Aspeed SMC probe failed %d\n", ret);
-- 
2.13.6

  parent reply	other threads:[~2018-06-22 12:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 12:14 [PATCH 0/4] mtd: spi-nor: aspeed: introduce optimized settings for fast reads Cédric Le Goater
2018-06-22 12:14 ` [PATCH 1/4] mtd: spi-nor: aspeed: use command mode for reads Cédric Le Goater
2018-07-23 12:12   ` Joel Stanley
2018-09-21  2:39     ` Joel Stanley
2018-09-21  6:09       ` Cédric Le Goater
2018-06-22 12:14 ` [PATCH 2/4] mtd: spi-nor: aspeed: add support for SPI dual IO read mode Cédric Le Goater
2018-07-23 12:12   ` Joel Stanley
2018-06-22 12:14 ` Cédric Le Goater [this message]
2018-07-23 12:13   ` [PATCH 3/4] mtd: spi-nor: aspeed: retrieve the ABH clock frequency Joel Stanley
2018-06-22 12:14 ` [PATCH 4/4] mtd: spi-nor: aspeed: introduce optimized settings for fast reads Cédric Le Goater
2018-07-23 12:16   ` Joel Stanley
2018-08-01  7:43     ` Cédric Le Goater

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=20180622121417.6762-4-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=andrew@aj.id.au \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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