From patchwork Mon Dec 15 11:59:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 42253 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66A5121772 for ; Mon, 15 Dec 2014 12:01:49 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf7135079lbv.5 for ; Mon, 15 Dec 2014 04:01:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=0OeGZ+urPjiHtRlun6XpXr7dA/2qJAz4LMwzEp0ce6E=; b=XNlVZR+7bT4tEv/sDPCN0kQFsq44Mkx8xB5B1fiedo2XwflLrPjNPp8jkYPA9Y+/pV IpcTjbisozVt41N9jbvSI2EeiycJMUS693PdRuegIlj1IKEJlaFmaTlCHBMJUEFC1XEu Z847YBAHvS04jGuXY7ib6VRrtL9afNLhrbl/+Im53hhHkGgHzTyfeHOuleeZ8L/NzpSv RHG8Xmmqbm/enp/j691iB6aCWGlZFkf6/3fxq/7WEE0Cew6XKl0YTr4ons7BVS4FA/z2 K9j0kMMLIVCkMu6v0CFwrPaijfftsxuSMoRrikHGsot7vksheu7F90ZiQdEp1o6E1hFb hRGw== X-Gm-Message-State: ALoCoQleKSiw2lXvQTIXbVvBznSTgWGGg3nQlOtHtS9LLVfi+t4+lgeMOk90HKf9FpPMbQ8NrN4i X-Received: by 10.152.6.202 with SMTP id d10mr611laa.10.1418644908345; Mon, 15 Dec 2014 04:01:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.100 with SMTP id m4ls155693lae.49.gmail; Mon, 15 Dec 2014 04:01:48 -0800 (PST) X-Received: by 10.152.21.228 with SMTP id y4mr16160679lae.72.1418644908130; Mon, 15 Dec 2014 04:01:48 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id sy8si10167032lbb.131.2014.12.15.04.01.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 04:01:48 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so9276347lam.19 for ; Mon, 15 Dec 2014 04:01:48 -0800 (PST) X-Received: by 10.112.170.36 with SMTP id aj4mr29714833lbc.3.1418644908052; Mon, 15 Dec 2014 04:01:48 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp692385lbb; Mon, 15 Dec 2014 04:01:46 -0800 (PST) X-Received: by 10.68.221.162 with SMTP id qf2mr50811242pbc.148.1418644905717; Mon, 15 Dec 2014 04:01:45 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id la11si13627749pab.123.2014.12.15.04.01.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2014 04:01:45 -0800 (PST) Received-SPF: none (google.com: linux-mtd-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0UKx-0002Lj-2R; Mon, 15 Dec 2014 12:01:15 +0000 Received: from mail-yk0-f177.google.com ([209.85.160.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0UJe-0000VV-Do for linux-mtd@lists.infradead.org; Mon, 15 Dec 2014 11:59:56 +0000 Received: by mail-yk0-f177.google.com with SMTP id 9so4846421ykp.22 for ; Mon, 15 Dec 2014 03:59:33 -0800 (PST) X-Received: by 10.236.103.136 with SMTP id f8mr21791486yhg.48.1418644773270; Mon, 15 Dec 2014 03:59:33 -0800 (PST) Received: from localhost.localdomain (host109-148-232-11.range109-148.btcentralplus.com. [109.148.232.11]) by mx.google.com with ESMTPSA id d91sm5783468yhq.53.2014.12.15.03.59.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 03:59:32 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v3 02/13] mtd: st_spi_fsm: Obtain and use EMI clock Date: Mon, 15 Dec 2014 11:59:09 +0000 Message-Id: <1418644760-18773-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418644760-18773-1-git-send-email-lee.jones@linaro.org> References: <1418644760-18773-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141215_035954_577304_6A649F92 X-CRM114-Status: GOOD ( 14.99 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.160.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: lee.jones@linaro.org, kernel@stlinux.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 ST's Common Clk Framework is now available. This patch ensures the FSM makes use of it by obtaining and enabling the EMI clock. If system fails to provide the EMI clock, we bomb out. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 6e4d3bfe..fac0fe9 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "serial_flash_cmds.h" @@ -262,6 +263,7 @@ struct stfsm { struct mtd_info mtd; struct mutex lock; struct flash_info *info; + struct clk *clk; uint32_t configuration; uint32_t fifo_dir_delay; @@ -1906,8 +1908,7 @@ static void stfsm_set_freq(struct stfsm *fsm, uint32_t spi_freq) uint32_t emi_freq; uint32_t clk_div; - /* TODO: Make this dynamic */ - emi_freq = STFSM_DEFAULT_EMI_FREQ; + emi_freq = clk_get_rate(fsm->clk); /* * Calculate clk_div - values between 2 and 128 @@ -2057,6 +2058,18 @@ static int stfsm_probe(struct platform_device *pdev) return PTR_ERR(fsm->base); } + fsm->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(fsm->clk)) { + dev_err(fsm->dev, "Couldn't find EMI clock.\n"); + return PTR_ERR(fsm->clk); + } + + ret = clk_prepare_enable(fsm->clk); + if (ret) { + dev_err(fsm->dev, "Failed to enable EMI clock.\n"); + return ret; + } + mutex_init(&fsm->lock); ret = stfsm_init(fsm); @@ -2121,6 +2134,28 @@ static int stfsm_remove(struct platform_device *pdev) return mtd_device_unregister(&fsm->mtd); } +#ifdef CONFIG_PM_SLEEP +static int stfsmfsm_suspend(struct device *dev) +{ + struct stfsm *fsm = dev_get_drvdata(dev); + + clk_disable_unprepare(fsm->clk); + + return 0; +} + +static int stfsmfsm_resume(struct device *dev) +{ + struct stfsm *fsm = dev_get_drvdata(dev); + + clk_prepare_enable(fsm->clk); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(stfsm_pm_ops, stfsmfsm_suspend, stfsmfsm_resume); + static const struct of_device_id stfsm_match[] = { { .compatible = "st,spi-fsm", }, {}, @@ -2134,6 +2169,7 @@ static struct platform_driver stfsm_driver = { .name = "st-spi-fsm", .owner = THIS_MODULE, .of_match_table = stfsm_match, + .pm = &stfsm_pm_ops, }, }; module_platform_driver(stfsm_driver);