From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
Sebastian Reichel <sre@kernel.org>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH v2 2/8] memory: atmel-sdramc: allow probing from pdata
Date: Tue, 28 Oct 2014 00:09:31 +0100 [thread overview]
Message-ID: <1414451377-11053-3-git-send-email-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <1414451377-11053-1-git-send-email-alexandre.belloni@free-electrons.com>
Allow probing the atmel-sdramc from platform_data.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/memory/atmel-sdramc.c | 45 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
index d89ed0af44d9..c4a7ba0f291f 100644
--- a/drivers/memory/atmel-sdramc.c
+++ b/drivers/memory/atmel-sdramc.c
@@ -19,6 +19,7 @@
#include <linux/clk.h>
#include <linux/err.h>
+#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_address.h>
@@ -140,7 +141,7 @@ static const struct of_device_id atmel_ramc_of_match[] = {
};
MODULE_DEVICE_TABLE(of, atmel_ramc_of_match);
-static int atmel_ramc_probe(struct platform_device *pdev)
+static int atmel_ramc_of_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
const struct at91_ramc_caps *caps;
@@ -181,6 +182,47 @@ static int atmel_ramc_probe(struct platform_device *pdev)
return 0;
}
+static int atmel_ramc_platform_probe(struct platform_device *pdev)
+{
+ struct resource *res;
+ const struct platform_device_id *match;
+ int idx = 0;
+
+ for (idx = 0; idx < 2; idx++) {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1);
+ at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+ if (IS_ERR(at91_ramc_base[idx])) {
+ dev_err(&pdev->dev, "Could not map ram controller address\n");
+ return PTR_ERR(at91_ramc_base[idx]);
+ }
+ }
+
+ match = platform_get_device_id(pdev);
+ at91_ramc_shutdown =
+ (void (*)(void __iomem *rstc_cr, u32 value))match->driver_data;
+
+ return 0;
+};
+
+static int atmel_ramc_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ if (pdev->dev.of_node)
+ ret = atmel_ramc_of_probe(pdev);
+ else
+ ret = atmel_ramc_platform_probe(pdev);
+
+ return ret;
+}
+
+static struct platform_device_id atmel_ramc_plat_match[] = {
+ { "at91sam9260-sdramc", (unsigned long)at91sam9260_shutdown, },
+ { "at91sam9g45-ddramc", (unsigned long)at91sam9g45_shutdown, },
+ { /* sentinel */ }
+};
+
static struct platform_driver atmel_ramc_driver = {
.probe = atmel_ramc_probe,
.driver = {
@@ -188,6 +230,7 @@ static struct platform_driver atmel_ramc_driver = {
.owner = THIS_MODULE,
.of_match_table = atmel_ramc_of_match,
},
+ .id_table = atmel_ramc_plat_match,
};
static int __init atmel_ramc_init(void)
--
1.9.1
next prev parent reply other threads:[~2014-10-27 23:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 23:09 [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 1/8] memory: atmel-sdramc: export a shutdown function Alexandre Belloni
2014-10-27 23:09 ` Alexandre Belloni [this message]
2014-10-27 23:09 ` [PATCH v2 3/8] ARM: at91: sam9: probe the RAMC driver from pdata Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 4/8] ARM: at91: sam9g45/sam9rl: probe the ramc driver Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 5/8] power: reset: at91-reset: use at91_ramc_shutdown Alexandre Belloni
2014-10-28 2:18 ` Sebastian Reichel
2014-10-27 23:09 ` [PATCH v2 6/8] ARM: at91: sam9: remove useless resource for rstc Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 7/8] ARM: at91: sam9g45/sam9rl: remove useless resources " Alexandre Belloni
2014-10-27 23:09 ` [PATCH v2 8/8] MAINTAINERS: add at91 power and memory entries Alexandre Belloni
2014-10-27 23:17 ` Joe Perches
2014-11-21 20:17 ` Pavel Machek
2014-10-28 7:50 ` [PATCH v2 0/8] ARM: at91: Remove mach/ includes from the reset driver Boris Brezillon
2014-10-28 8:52 ` Alexandre Belloni
2014-10-28 8:59 ` Maxime Ripard
2014-10-28 9:04 ` Alexandre Belloni
2014-10-28 9:11 ` Maxime Ripard
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=1414451377-11053-3-git-send-email-alexandre.belloni@free-electrons.com \
--to=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=dbaryshkov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=nicolas.ferre@atmel.com \
--cc=plagnioj@jcrosoft.com \
--cc=sre@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®