From patchwork Wed Sep 11 01:43:01 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: 2868341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 614829F2D6 for ; Wed, 11 Sep 2013 01:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7CD1820322 for ; Wed, 11 Sep 2013 01:46:55 +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 C458E2030D for ; Wed, 11 Sep 2013 01:46:53 +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 1VJZVs-00069u-Fy; Wed, 11 Sep 2013 01:46:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJZVq-0007MO-9i; Wed, 11 Sep 2013 01:46:34 +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 1VJZVn-0007Lm-6m for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 01:46:32 +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:Message-Id:Date:Subject:Cc:To:From; bh=BtlQFHw4JXnJmtST8NWinmrLoTmCGqMQMUfpSpEjyC8=; b=Q96ZvMb94Gr0zkQ1K1qiHt/m1c3PLHQ7CpR854bo4Iub1Etbc4adKSR9Yeiza32P3+BIOzIIrgCm2lSZIRperrdThclxn/RbL1gZFBQBLojaPt7uR5U9KKKn4Pm7kcvskk44t2T8SvUCQ4FRviP8glNHy9KfUAlSyFdEZHvjnFeVKdSTTMdnZnQR92GNwKzm+Th57UHzvBfzCVxcCxFC6/50+37eRDQ6nXtRECUEMhdrkLZuYSwe2hf6+Bb1TyLBxJivBAqwDuxTDASTcqUlgcqzPTF/evYy11o+05KCrxYFjSaXM8hvKOCSzxM8o6okhGVEymBg/W8ISzisljjO+w==; 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 1VJZVN-00020z-BJ; Tue, 10 Sep 2013 22:46:05 -0300 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= To: Mike Turquette , Maxime Ripard , grant.likely@linaro.org, rob.herring@calxeda.com Subject: [PATCH RFC] of: add a basic memory driver Date: Tue, 10 Sep 2013 22:43:01 -0300 Message-Id: <1378863781-4235-1-git-send-email-emilio@elopez.com.ar> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130910_214631_366195_9A788E03 X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -2.7 (--) Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , devicetree@vger.kernel.org, david.lanzendoerfer@o2s.ch, 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=-4.7 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 that the necessary clock for memory operation on a DT-enabled machine remains enabled. Signed-off-by: Emilio López --- Hi, I am currently facing an issue with the clock setup: a critical but unclaimed clock gets disabled as a side effect of disabling one of its children. The clock setup looks something like this: PLL | ------------ | | DDR Others | periph The PLL clock is marked with the CLK_IGNORE_UNUSED flag, so on a normal boot it remains on, even after the unused clocks cleanup code runs. The problem occurs when someone enables "periph" and then, later on, disables it: the framework starts disabling clocks upwards on the tree, eventually switching the PLL off (and that kills the machine, as the memory clock is shut down). There's two possible solutions I can think of: 1) add some extra checks on the framework to not turn off clocks marked with such a flag on the non-explicit case (ie, when I'm disabling some other clock) 2) create an actual user of the DDR clock, that way it won't get disabled simply because it's being used. I considered 1) and implemented it, but the result was not pretty. This patch is my take on 2). Please let me know what you think; all feedback is welcome :) Cheers, Emilio drivers/of/Kconfig | 6 ++++++ drivers/of/Makefile | 1 + drivers/of/of_memory.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 drivers/of/of_memory.c diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 9d2009a..f6c5e20 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -80,4 +80,10 @@ config OF_RESERVED_MEM help Initialization code for DMA reserved memory +config OF_MEMORY + depends on COMMON_CLK + def_bool y + help + Simple memory initialization + endmenu # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index ed9660a..15f0167 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -10,3 +10,4 @@ obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o +obj-$(CONFIG_OF_MEMORY) += of_memory.o diff --git a/drivers/of/of_memory.c b/drivers/of/of_memory.c new file mode 100644 index 0000000..a833f7a --- /dev/null +++ b/drivers/of/of_memory.c @@ -0,0 +1,30 @@ +/* + * Simple memory driver + */ + +#include +#include + +static int __init of_memory_enable(void) +{ + struct device_node *np; + struct clk *clk; + + np = of_find_node_by_path("/memory"); + if (!np) { + pr_err("no /memory on DT!\n"); + return 0; + } + + clk = of_clk_get(np, 0); + if (!IS_ERR(clk)) { + clk_prepare_enable(clk); + clk_put(clk); + } + + of_node_put(np); + + return 0; +} + +device_initcall(of_memory_enable);