From patchwork Thu Dec 4 10:21:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 41917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC43025E8C for ; Thu, 4 Dec 2014 10:22:23 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf10821812eek.0 for ; Thu, 04 Dec 2014 02:22:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Ma/kkQsY49HTvfjoAp2JFeKrOsf3NTNttXMdIAiTq3U=; b=NNcc65fFc5OXdR0zLvzlMbu8+Dls0k6gT5xlElPWpxLrZcA9AKQbyhzaziyQSQ5axg 7dIpeFrtJu+3SH0RciOatrZOV847Xe1g0/jc8NS5O8Vsk16iR1ZLn5u5hM7a6wgdqZ0w k+uqWfucbRLHiNg+34vSnoQPvm1cZbJBFP8BSWxSYQAciPtmvdp/qylI8NQ9ye8yU4zL JW5M1pWDN2hmjquwCLNbly6gp++MGsZzXtBAr/vQYbigbY9jfyEnBuwehr8eNpvMJB4r xw9HhVuBmekh3aMesJofp/bD5XGVF0GoIutZ1Ge42Qb+u8LoS9vaV3s6dGR92z61ccBq +LtQ== X-Gm-Message-State: ALoCoQkJN+SJoDsWRNRhC/wCnljNl+iaRYORthmMq+I51SywnXpHhdimO7FxCgxK4v5DPJeusoWn X-Received: by 10.112.188.199 with SMTP id gc7mr2082120lbc.6.1417688542937; Thu, 04 Dec 2014 02:22:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.194 with SMTP id g2ls275801lam.3.gmail; Thu, 04 Dec 2014 02:22:22 -0800 (PST) X-Received: by 10.112.199.233 with SMTP id jn9mr8659253lbc.18.1417688542643; Thu, 04 Dec 2014 02:22:22 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id j9si22720457lam.35.2014.12.04.02.22.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 02:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so13168551lab.23 for ; Thu, 04 Dec 2014 02:22:22 -0800 (PST) X-Received: by 10.112.138.137 with SMTP id qq9mr8582715lbb.80.1417688542515; Thu, 04 Dec 2014 02:22:22 -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.184.201 with SMTP id ew9csp10148lbc; Thu, 4 Dec 2014 02:22:21 -0800 (PST) X-Received: by 10.70.87.173 with SMTP id az13mr17294305pdb.134.1417688539736; Thu, 04 Dec 2014 02:22:19 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sb4si42505606pac.52.2014.12.04.02.22.18 for ; Thu, 04 Dec 2014 02:22:19 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754257AbaLDKWM (ORCPT + 26 others); Thu, 4 Dec 2014 05:22:12 -0500 Received: from mail-yk0-f175.google.com ([209.85.160.175]:56440 "EHLO mail-yk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753729AbaLDKWH (ORCPT ); Thu, 4 Dec 2014 05:22:07 -0500 Received: by mail-yk0-f175.google.com with SMTP id 200so7784455ykr.20 for ; Thu, 04 Dec 2014 02:22:06 -0800 (PST) X-Received: by 10.236.38.234 with SMTP id a70mr11694666yhb.63.1417688526823; Thu, 04 Dec 2014 02:22:06 -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 y67sm16089929yhc.11.2014.12.04.02.22.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Dec 2014 02:22:06 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v2 RESEND 02/11] mtd: st_spi_fsm: Obtain and use EMI clock if provided Date: Thu, 4 Dec 2014 10:21:43 +0000 Message-Id: <1417688512-7644-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417688512-7644-1-git-send-email-lee.jones@linaro.org> References: <1417688512-7644-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.50 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 provided. If system fails to provide the EMI clock FSM uses its original default rate. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 6e4d3bfe..ddb659f 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,13 @@ 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; + if (!fsm->clk) { + dev_warn(fsm->dev, + "No EMI clock available. Using default 100MHz.\n"); + + emi_freq = STFSM_DEFAULT_EMI_FREQ; + } else + emi_freq = clk_get_rate(fsm->clk); /* * Calculate clk_div - values between 2 and 128 @@ -2057,6 +2064,15 @@ static int stfsm_probe(struct platform_device *pdev) return PTR_ERR(fsm->base); } + fsm->clk = devm_clk_get(&pdev->dev, "emi_clk"); + if (IS_ERR(fsm->clk)) { + dev_warn(fsm->dev, "Couldn't find EMI clock.\n"); + fsm->clk = NULL; + } else if (clk_prepare_enable(fsm->clk)) { + dev_warn(fsm->dev, "Failed to enable EMI clock.\n"); + fsm->clk = NULL; + } + mutex_init(&fsm->lock); ret = stfsm_init(fsm); @@ -2121,6 +2137,30 @@ 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); + + if (fsm->clk) + clk_disable_unprepare(fsm->clk); + + return 0; +} + +static int stfsmfsm_resume(struct device *dev) +{ + struct stfsm *fsm = dev_get_drvdata(dev); + + if (fsm->clk) + 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 +2174,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);