From patchwork Thu May 22 11:24:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 30599 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0528720369 for ; Thu, 22 May 2014 11:24:25 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oz11sf11670419veb.6 for ; Thu, 22 May 2014 04:24:24 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=XJj8PZ6TVY6Y8nRE965Eau89QVkj8JmbgdYut74JD2M=; b=emofaZsg3Qr6/MbCJnLE5wjVE9VuRjXm6ayEFsnjPiNhEna4xHLuetB5KW+YL/MpbQ 1oHAdGEeqtm82u6Li24D2YIF9YQvPksIMxQk0oJdVJTREZ9PTke7erwXFZktXcap65VG 7WYsrdhvBMX0/DFi10Gt4wzZDnbySUG+Ulbwcd6b0MqHTswcnSbUaj+Gdz4cQuKzHj7o o65RlUYykb86YRROtjWH4xRIoGL6VogYAxvWmWJ/2B5FFtyty/8qx5sHi8sVed5+govC a7TJFSUfeYggBsnuNXIcGSQFwfhvRJIsv6E8GZuLUUuaX8t9UXUaF0dCuQvPaw7OO0h0 Fg7Q== X-Gm-Message-State: ALoCoQlaqZTqWfBB4TcKrrxD+sqd2OWFoVVelnKbVzmjiJ3rKBTjpwSxH4K+L8rkfQg8hlSMk3Fg X-Received: by 10.236.167.138 with SMTP id i10mr5302252yhl.57.1400757864842; Thu, 22 May 2014 04:24:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.139 with SMTP id c11ls616006qgd.66.gmail; Thu, 22 May 2014 04:24:24 -0700 (PDT) X-Received: by 10.52.122.47 with SMTP id lp15mr72773vdb.60.1400757864773; Thu, 22 May 2014 04:24:24 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id 3si4647989vcs.47.2014.05.22.04.24.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 04:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id la4so4183673vcb.41 for ; Thu, 22 May 2014 04:24:24 -0700 (PDT) X-Received: by 10.58.106.104 with SMTP id gt8mr502222veb.46.1400757864700; Thu, 22 May 2014 04:24:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp189955vcb; Thu, 22 May 2014 04:24:23 -0700 (PDT) X-Received: by 10.42.186.3 with SMTP id cq3mr209630icb.34.1400757862083; Thu, 22 May 2014 04:24:22 -0700 (PDT) Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) by mx.google.com with ESMTPS id mi3si8256738igb.3.2014.05.22.04.24.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 04:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.181 as permitted sender) client-ip=209.85.223.181; Received: by mail-ie0-f181.google.com with SMTP id rp18so1743366iec.26 for ; Thu, 22 May 2014 04:24:21 -0700 (PDT) X-Received: by 10.43.62.204 with SMTP id xb12mr53295790icb.51.1400757861750; Thu, 22 May 2014 04:24:21 -0700 (PDT) Received: from localhost.localdomain (host109-148-113-200.range109-148.btcentralplus.com. [109.148.113.200]) by mx.google.com with ESMTPSA id z4sm12643314igl.13.2014.05.22.04.24.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 04:24:21 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, linux-mtd@lists.infradead.org, Lee Jones Subject: [PATCH 02/10] mtd: st_spi_fsm: Obtain and use EMI clock if provided Date: Thu, 22 May 2014 12:24:00 +0100 Message-Id: <1400757848-18075-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400757848-18075-1-git-send-email-lee.jones@linaro.org> References: <1400757848-18075-1-git-send-email-lee.jones@linaro.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.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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 aca4d72..fe54533 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; @@ -1907,8 +1909,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 @@ -2058,6 +2065,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); @@ -2122,6 +2138,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", }, {}, @@ -2135,6 +2175,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);