From patchwork Wed Jun 17 18:05:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6627521 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C39A59F358 for ; Wed, 17 Jun 2015 18:11:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAE1F20656 for ; Wed, 17 Jun 2015 18:11:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF68620858 for ; Wed, 17 Jun 2015 18:11:20 +0000 (UTC) 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 1Z5Hln-0007Da-Rd; Wed, 17 Jun 2015 18:09:03 +0000 Received: from mail-bn1on0113.outbound.protection.outlook.com ([157.56.110.113] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5HlK-0006s2-52 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2015 18:08:34 +0000 Received: from BLUPR0301CA0024.namprd03.prod.outlook.com (10.162.113.162) by BLUPR03MB246.namprd03.prod.outlook.com (10.255.213.18) with Microsoft SMTP Server (TLS) id 15.1.201.11; Wed, 17 Jun 2015 18:08:11 +0000 Received: from BN1AFFO11FD013.protection.gbl (2a01:111:f400:7c10::130) by BLUPR0301CA0024.outlook.office365.com (2a01:111:e400:5259::34) with Microsoft SMTP Server (TLS) id 15.1.195.15 via Frontend Transport; Wed, 17 Jun 2015 18:08:11 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; lists.infradead.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD013.mail.protection.outlook.com (10.58.52.73) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Wed, 17 Jun 2015 18:08:10 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t5HI7jAd003611; Wed, 17 Jun 2015 11:08:04 -0700 From: Dong Aisheng To: Subject: [PATCH 3/6] mmc: sdhci: make max-frequency property in device tree work Date: Thu, 18 Jun 2015 02:05:34 +0800 Message-ID: <1434564337-24720-4-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com> References: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD013; 1:MTLCl9CQI69xD0jxi6C30BvSJ/elUzY+1/8nAXdVPGwmLqsPrYU4wc8SZ0wg6zeKAXO20Z8Py5RaGhrr8Y+Ztk23zY1oGQcA/qN7f/Jy/ivggRrEoTQjJg+wh9MuZDzEUd1O1nRjnwarYHyl8CstjboZP8WJWxde1xKDV0YvEz3VoINltpy0jYvEDWH7XuG05KWLftcSTgkWrTRovs63Ln/mgb8CrU1VyZ5WW93E/fxrNKBvLfEuLyWeGnSiejlh5i8JC7J1lgL2BNCZtnt/0gdSwzN0NH6TUc4LwNEj+VIlQZHzG4qixv5y9BADRBfHeoIDZ6WVlx9b5rCnwBTL7sMeEvoKEWeUN8oRl0Sqo40= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(106466001)(48376002)(46102003)(50466002)(19580405001)(6806004)(50226001)(19580395003)(2950100001)(47776003)(77096005)(85426001)(77156002)(62966003)(76176999)(189998001)(50986999)(5001960100002)(110136002)(87936001)(92566002)(105606002)(86362001)(2351001)(81156007)(229853001)(104016003)(33646002)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB246; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB246; 2:AabsEX3vdCfeQWsjfxB8jPPYa4mNcKTXyTXmraESlSxuTj6X6d2ip+btDdzNXSnL; 3:n0oTzFzGJLzR1rUZowIPNLb3ArZqdWNeVUaniYYOM3usEPW1nHc+gD5EpnrdQMwOnmSSzfOmpSnGvrzzpfCmSvjUvYeea9IgsctVxTRgVkDIenNhYcAyfEJOZcuhKJIiQgJZ1XYVfjMWhLXFi7kOO/YgINfcqrtfEcFtk4gNI3BAtYKTv4RPx5ZzKBCKvq9i306LISGJqjxFs6Nrp93wkjJxq9wlzzMFGmZf3oX8uB8=; 20:hxcRZ/fI1Kkjuiivng8AF/Jbd0AlFy0y0b8TeWFkCLfQmzhRxBwiJwq7hn8VqkpC+Q/ncUElcPsJFXPbmtXEdCu5W4oVaI8s5Z0gujDXpVRYbo/1zGxa35l7GujaBy1ir5ZRTmTZShKRZMfH5AMRY5XnSFDBSEarEBFKzS6+DYJK5PTPilQ0OBXss9W9hYXE3UcVkGP5m5OHbIXEx1pta8gNdS+aUnIgRzQniM2UgSJqfOMulaMht6SmjX99u/1Qkv3EcJfNKf08WBDxxZvcsSUpo82nxWgyw2zsfHoOSr9CiuqLJF41gdlOdQSruACO3YLOvWPrNW3QRUGcKh/hL6jwtL8pHLLhlFagjEJNGds=; 4:bPLHMHU7npgtT+BYLoMZ3Wq/7RKxqIzo/AY5SBWY4CXNJe9xn+lJehGtX7UO7FVia20MWOQlozbls0VhwRmUj2taPR4KsYeHLeY9Tx3Smn7LMOuodi3ixVmW1aYTlGAMPI0Op+6TTZi+5ziG66gxuEqxIGN9RJuRqU3bQFT/BrSAzg+RmD81W2MTOXnLReqO/DezmZoQoWtjOAKBofxQdcJRYwhELJujDIm8qZ/bZM8YcbYqcFwfnsSPvT0euX7MNpA/fEmX/x3YRtMQ/WmY0MYYOKqV+5/IxknO6mzJsIo= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB246; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR03MB246; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB246; X-Forefront-PRVS: 0610D16BBE X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB246; 23:FK4318TLmMFlkq7Hc5gZMetyuOfjUGYhaIeRHVaQPbPQey9q8R7zEcIDH2sC5QCA7Jio/aXBi8ad5EYXhg5/6JKOJk8c3L7tHqw2QnY9tL3J7L+ub2GjhChNSQjLFGPMp99OSFwrNMY8YAaEVV+51POHadSiycoJpRTKx0uRwx7dE10HgOPdwGVpAtcJqiXDSZXz6jWcPSkJEy6QYSIkF21R/NsF/CWLS4/qfLVlSr0k5m7IqdGC1RR7UV2vb5GC7Bqs6shY6V4PhvBJqcfSjhllsoSmFKoynsNt2dUFWEw/H6iold3S4tiyJP19fNKNAEkbKO/6waSopZhC2p7iWq5wHV98OpWOb6L7ggjiGf5iuSmFKff9A+cBs/IwIEJV/V2XmAVT4F/xjpzBaCeMR37Fv8kflRx7Tm2qnLHTmo8y6zuW8dCow6WZMvpP1EYuYMsRPBfoLjwnD8K3S8eupyICKpq0Z6oXv7WfbraHuCgaw41Gf0rvc7TwC8nNhLj20cC3fcRu/xjM1vjxjqpEEe7u/UjYtPtGiflSjcjyb4L1vJUkfQgv7iyxvFCrckt/HAPg0LxyduW5QJ/KIf8T3bb3CrCZmk9ZPEaSug7Fgg/E7U4Sx9MsAYLjKUqAD2DRNsJpnMR1R9dZNvO/KGjnxDIPgBJptne8hhyY14L2OB3ULpVelaZyuLy6crT8aYE2i1s9zWQcTd+fmgscamJ08ET06Pw+Ob1GZq82yCOy9DCWhiuYeaQn3/Frwj4k9XfqWweSJEVD7uelcbyrPu8esxpm89EVnv/3c2rXsfU5Akw1rxnbRwr7Lqhz2WsT5tqcYgASgu5lWeniy2pRYesxAtr+Vux1Dsa/QyUKztDXgJMijYdXcfdIidnhmdJEd3s62KqpweGiroC7S//CjNdb4w== X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB246; 5:m1rjJTMC7Qdu0bGPGOB13LsrfWEGMXO+yZE1oXI09eEfsn/zc8K2UZNjtDU9VKJOynIQ0SndFnGeYrphZsZsETiZ/882WMeuoeCudQqMD4OWwRnaZvQzdANy0sikWmcytEncLN28hexxYCxBFJxVig==; 24:FcHab1ejNVyxhKV3NpRYKCC/txL7rnLO7qTi3uYUOEdyaI/LMTfG1NyhRxJ2HJKEGs0Zi8gvfHKJMjaVMGYc0bSuYRh9wITk/EHdxL6Ir+o=; 20:ixI20T4PfZvXxXOwMivjMx/Nwjo5e4iuq5jDRll+F8lMmqmxNYLrDugOyIHu16eDkSaiCn0IALojD4/pDwATJw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2015 18:08:10.3920 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB246 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150617_110834_386665_57174BC5 X-CRM114-Status: UNSURE ( 8.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) Cc: fabio.estevam@freescale.com, marex@denx.de, ulf.hansson@linaro.org, s.trumtrar@pengutronix.de, smoch@web.de, linux-arm-kernel@lists.infradead.org, robertcnelson@gmail.com, s.hauer@pengutronix.de, chris@printf.net, rabeeh@solid-run.com, troy.kisky@boundarydevices.com, lisovy@gmail.com, hs@denx.de, gwenhael.goavec-merou@armadeus.com, p.zabel@pengutronix.de, rmk+kernel@arm.linux.org.uk, shawn.guo@linaro.org, b29396@freescale.com, tharvey@gateworks.com, LW@KARO-electronics.de, ipaton0@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Device tree provides option to specify the max freqency with property "max-frequency" in dts and common parse function mmc_of_parse() will parse it and use this value to set host->f_max to tell the MMC core the maxinum frequency the host works. However, current sdhci driver will finally overwrite this value with host->max_clk regardless of the max-frequency property. This patch makes sure not overwrite the max-frequency set from device tree and do basic sanity check. Signed-off-by: Dong Aisheng --- drivers/mmc/host/sdhci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index bc14452..0781c92 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2866,6 +2866,7 @@ int sdhci_add_host(struct sdhci_host *host) u32 max_current_caps; unsigned int ocr_avail; unsigned int override_timeout_clk; + u32 max_clk; int ret; WARN_ON(host == NULL); @@ -3047,18 +3048,22 @@ int sdhci_add_host(struct sdhci_host *host) * Set host parameters. */ mmc->ops = &sdhci_ops; - mmc->f_max = host->max_clk; + max_clk = host->max_clk; + if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock(host); else if (host->version >= SDHCI_SPEC_300) { if (host->clk_mul) { mmc->f_min = (host->max_clk * host->clk_mul) / 1024; - mmc->f_max = host->max_clk * host->clk_mul; + max_clk = host->max_clk * host->clk_mul; } else mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; } else mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; + if (!mmc->f_max || (mmc->f_max && (mmc->f_max > max_clk))) + mmc->f_max = max_clk; + if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) { host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;