From patchwork Wed Mar 26 16:39:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 27144 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0103620369 for ; Wed, 26 Mar 2014 16:40:42 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf7974034iec.2 for ; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) 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=zKYrPcbD0q9nsDLTAB2tBzeCVtYagqPLDaUgyIK+JQQ=; b=abU3F8RHN7k682wttusaYh9VB1HHdHUYUQhZ2HlUqdhCFkD5fa2eCTr2JxP+3ewK4z vblUzwajjNCZA5MhdfDmm1rLBiUizRS8V8cICmPnI4LjtEAUhlnwjGY9d5MMI8NH8Ozi 1feD87bpbZQ/2rCzOsEjhmwx4SZ7LrEIPM1h50osXrlH+i+lYUagVSfujn7ph6ZGzDw3 ZTCT+KpOQzTw3ugIvJjtNsxvQL0lsVySM7qtEuwAJ6tjsSbr5LjjFSoMT76t3qMEKmte xdc0FcsP7RNh/OIFfcvrB7n4FTKFdV8WQbbCaZ2eMdmUMf6xxatL+KSi2Wsv2U5tzPQ3 Pjdg== X-Gm-Message-State: ALoCoQmtlz+gCh03WMH7hvU8icbu/yHvpkkL8S9sswqNjTFIM3SH/tcHeQVAy5YohWZC/ipp270L X-Received: by 10.51.18.97 with SMTP id gl1mr10872731igd.7.1395852042501; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.167 with SMTP id 36ls690511qgn.55.gmail; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) X-Received: by 10.58.110.74 with SMTP id hy10mr260510veb.52.1395852042294; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id dm2si4660079vec.3.2014.03.26.09.40.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 09:40:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lc6so2663882vcb.21 for ; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) X-Received: by 10.221.39.196 with SMTP id tn4mr262050vcb.51.1395852042217; Wed, 26 Mar 2014 09:40:42 -0700 (PDT) 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.220.78.9 with SMTP id i9csp61153vck; Wed, 26 Mar 2014 09:40:41 -0700 (PDT) X-Received: by 10.68.43.2 with SMTP id s2mr87712298pbl.60.1395852041281; Wed, 26 Mar 2014 09:40:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gr2si14174759pac.78.2014.03.26.09.40.40; Wed, 26 Mar 2014 09:40:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932127AbaCZQkO (ORCPT + 26 others); Wed, 26 Mar 2014 12:40:14 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:44367 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932069AbaCZQkG (ORCPT ); Wed, 26 Mar 2014 12:40:06 -0400 Received: by mail-wg0-f41.google.com with SMTP id n12so1494353wgh.12 for ; Wed, 26 Mar 2014 09:40:05 -0700 (PDT) X-Received: by 10.180.96.66 with SMTP id dq2mr30775204wib.54.1395852005107; Wed, 26 Mar 2014 09:40:05 -0700 (PDT) Received: from lee--X1.home (host109-148-113-193.range109-148.btcentralplus.com. [109.148.113.193]) by mx.google.com with ESMTPSA id gp10sm3913806wib.13.2014.03.26.09.40.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 09:40:04 -0700 (PDT) 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, angus.clark@st.com Subject: [PATCH 08/15] mtd: st_spi_fsm: Obtain and use EMI clock if provided Date: Wed, 26 Mar 2014 16:39:22 +0000 Message-Id: <1395851969-13520-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395851969-13520-1-git-send-email-lee.jones@linaro.org> References: <1395851969-13520-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=neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 9df59e7..2443757 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "serial_flash_cmds.h" @@ -297,6 +298,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; @@ -1941,8 +1943,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 @@ -2092,6 +2099,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); @@ -2156,6 +2172,30 @@ static int stfsm_remove(struct platform_device *pdev) return mtd_device_unregister(&fsm->mtd); } +#ifdef CONFIG_PM +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 struct of_device_id stfsm_match[] = { { .compatible = "st,spi-fsm", }, {}, @@ -2169,6 +2209,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);