mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Emilio López" <emilio@elopez.com.ar>
To: Mike Turquette <mturquette@linaro.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	grant.likely@linaro.org, rob.herring@calxeda.com,
	gregkh@linuxfoundation.org
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	david.lanzendoerfer@o2s.ch, linux-kernel@vger.kernel.org,
	"Emilio López" <emilio@elopez.com.ar>
Subject: [PATCH] memory: add a basic OF-based memory driver
Date: Thu, 12 Sep 2013 21:30:25 -0300	[thread overview]
Message-ID: <1379032225-6425-1-git-send-email-emilio@elopez.com.ar> (raw)
In-Reply-To: <1378863781-4235-1-git-send-email-emilio@elopez.com.ar>

This driver's only job is to claim and ensure the necessary clock
for memory operation on a DT-powered machine remains enabled.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---

I believe this new patch should resolve all the concerns raised; as
always, all feedback is welcome :)

Changes from RFC:
- Move from drivers/of to drivers/memory
- Make a proper driver instead of using an initcall
- Binding document for the new "simple-memory-controller"

 .../simple-memory-controller.txt                   | 19 ++++++++
 drivers/memory/Kconfig                             | 11 +++++
 drivers/memory/Makefile                            |  1 +
 drivers/memory/simple-mc.c                         | 57 ++++++++++++++++++++++
 4 files changed, 88 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/simple-memory-controller.txt
 create mode 100644 drivers/memory/simple-mc.c

diff --git a/Documentation/devicetree/bindings/memory-controllers/simple-memory-controller.txt b/Documentation/devicetree/bindings/memory-controllers/simple-memory-controller.txt
new file mode 100644
index 0000000..d37683b
--- /dev/null
+++ b/Documentation/devicetree/bindings/memory-controllers/simple-memory-controller.txt
@@ -0,0 +1,19 @@
+Device Tree Clock binding for a simple memory controller.
+
+Required properties:
+- compatible : shall be "simple-memory-controller"
+
+Optional properties:
+- reg        : may contain the register space for the controller. This
+               property is currently ignored by the driver
+- clocks     : may contain a phandle to the clock that is currently being
+               used on the controller. This clock shall remain enabled
+               during system operation.
+
+Example:
+
+mc: mc@0123000 {
+	compatible = "simple-memory-controller";
+	reg = <0x0123000 0x400>;
+	clocks = <&pll5 1>;
+};
diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig
index 29a11db..4a6df65 100644
--- a/drivers/memory/Kconfig
+++ b/drivers/memory/Kconfig
@@ -50,4 +50,15 @@ config TEGRA30_MC
 	  analysis, especially for IOMMU/SMMU(System Memory Management
 	  Unit) module.
 
+config SIMPLE_MC
+	bool "Simple memory controller"
+	default y
+	depends on OF && COMMON_CLK
+	help
+	  This driver is able to manage a simple memory controller whose
+	  only needs consist of keeping one clock enabled. The
+	  controller must be defined on the device tree as compatible
+	  with "simple-memory-controller"; see the corresponding binding
+	  document for more details.
+
 endif
diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile
index 969d923..e0953e5 100644
--- a/drivers/memory/Makefile
+++ b/drivers/memory/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_TI_EMIF)		+= emif.o
 obj-$(CONFIG_MVEBU_DEVBUS)	+= mvebu-devbus.o
 obj-$(CONFIG_TEGRA20_MC)	+= tegra20-mc.o
 obj-$(CONFIG_TEGRA30_MC)	+= tegra30-mc.o
+obj-$(CONFIG_SIMPLE_MC)		+= simple-mc.o
diff --git a/drivers/memory/simple-mc.c b/drivers/memory/simple-mc.c
new file mode 100644
index 0000000..e58371d
--- /dev/null
+++ b/drivers/memory/simple-mc.c
@@ -0,0 +1,57 @@
+/*
+ * Simple memory controller driver
+ *
+ * Copyright 2013 Emilio López <emilio@elopez.com.ar>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/of.h>
+#include <linux/clk.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+static int simple_mc_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct clk *clk;
+
+	if (!np)
+		return -ENODEV;
+
+	clk = of_clk_get(np, 0);
+	if (!IS_ERR(clk)) {
+		clk_prepare_enable(clk);
+		clk_put(clk);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id simple_mc_of_match[] = {
+	{ .compatible = "simple-memory-controller", },
+	{ /* sentinel */ },
+};
+
+static struct platform_driver simple_mc_driver = {
+	.probe = simple_mc_probe,
+	.driver = {
+		.name = "simple-mc",
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(simple_mc_of_match),
+	},
+};
+
+module_platform_driver(simple_mc_driver);
+
+MODULE_AUTHOR("Emilio López <emilio@elopez.com.ar>");
+MODULE_DESCRIPTION("Simple memory controller driver");
+MODULE_LICENSE("GPL");
-- 
1.8.4


       reply	other threads:[~2013-09-13  0:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1378863781-4235-1-git-send-email-emilio@elopez.com.ar>
2013-09-13  0:30 ` Emilio López [this message]
2013-09-13  0:57   ` Olof Johansson
2013-09-13  1:31     ` Emilio López
2013-09-13 14:00       ` Rob Herring
2013-09-13 15:49         ` Olof Johansson
     [not found]           ` <20130915124325.B1DF2C42C5C@trevor.secretlab.ca>
2013-09-16 12:55             ` Rob Herring

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=1379032225-6425-1-git-send-email-emilio@elopez.com.ar \
    --to=emilio@elopez.com.ar \
    --cc=david.lanzendoerfer@o2s.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mturquette@linaro.org \
    --cc=rob.herring@calxeda.com \
    /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®