From patchwork Fri Sep 13 00:30:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Emilio_L=C3=B3pez?= X-Patchwork-Id: 2881141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3D084BFF05 for ; Fri, 13 Sep 2013 00:35:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 468792038C for ; Fri, 13 Sep 2013 00:35:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 185D82038B for ; Fri, 13 Sep 2013 00:35:35 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKHM7-0005T4-C4; Fri, 13 Sep 2013 00:35:27 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKHM5-0005N1-57; Fri, 13 Sep 2013 00:35:25 +0000 Received: from zetta.elopez.com.ar ([199.30.59.35]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKHM2-0005M8-7B for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2013 00:35:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=elopez.com.ar; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=dIJfsCJPD5EGpcJD7J/XS1NJzsZ6bp9o446gkdqZH1Y=; b=KrXya1grK+VyxVdXm0UGoz2qN73rvfyAYlzoMNa/YpxRLqALmAZfWewSz9S/vfLGioAPtoa8Ky81p0/2Eqs+HyaNJj0qYqfKjmxQ5EBQQiYrQcnGCjMaxmZZKgJx6IWFw79znRMEu0/yBc6x4A2BYUUBsATcAKYh7Mj/mg3qy4620JAd/dqEjXLAZezGkqaejjYR3R3aLLQ3PFBnv3BA8PhSnSdwmgIOZapmSBfc/o8yHZGBAcvUexjEMR0hKg0R3Oj2jloNpIZjrxa42q4hws2q3OL1z4N5slRMOq5LIBBNuIOh9ZoP7qZntujkQNMU2QlBlXjLw5YKD6yxcaQKTQ==; Received: from 201-212-126-35.prima.net.ar ([201.212.126.35] helo=desktop.lan) by zetta.elopez.com.ar with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) id 1VKHLa-0003Aw-VZ; Thu, 12 Sep 2013 21:34:55 -0300 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= To: Mike Turquette , Maxime Ripard , grant.likely@linaro.org, rob.herring@calxeda.com, gregkh@linuxfoundation.org Subject: [PATCH] memory: add a basic OF-based memory driver Date: Thu, 12 Sep 2013 21:30:25 -0300 Message-Id: <1379032225-6425-1-git-send-email-emilio@elopez.com.ar> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1378863781-4235-1-git-send-email-emilio@elopez.com.ar> References: <1378863781-4235-1-git-send-email-emilio@elopez.com.ar> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130912_203522_416016_3AF79366 X-CRM114-Status: GOOD ( 20.12 ) X-Spam-Score: -2.9 (--) Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , devicetree@vger.kernel.org, david.lanzendoerfer@o2s.ch, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 + * + * 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 +#include +#include +#include + +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 "); +MODULE_DESCRIPTION("Simple memory controller driver"); +MODULE_LICENSE("GPL");