From patchwork Fri Sep 3 23:21:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 177902 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Sat, 04 Sep 2010 00:21:49 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1OrfZt-0001AR-8r for chris@printf.net; Sat, 04 Sep 2010 00:21:49 +0100 Received: by mail.laptop.org (Postfix) id 0137A23CC4; Fri, 3 Sep 2010 19:21:30 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id EA39023CC2 for ; Fri, 3 Sep 2010 19:21:29 -0400 (EDT) X-ASG-Debug-ID: 1283556106-0b740ac40001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id 9XD2gCv3DqxAzeJ5 for ; Fri, 03 Sep 2010 19:21:46 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925Ab0ICXVq (ORCPT ); Fri, 3 Sep 2010 19:21:46 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:52361 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752752Ab0ICXVp (ORCPT ); Fri, 3 Sep 2010 19:21:45 -0400 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id o83NL4iF003795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Sep 2010 16:21:04 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id o83NL2eP018564; Fri, 3 Sep 2010 16:21:02 -0700 Message-Id: <201009032321.o83NL2eP018564@imap1.linux-foundation.org> X-ASG-Orig-Subj: + mmc-make-id-freq-configurable.patch added to -mm tree Subject: + mmc-make-id-freq-configurable.patch added to -mm tree To: mm-commits@vger.kernel.org Cc: hein_tibosch@yahoo.es, adrian.hunter@nokia.com, bn@niasdigital.com, cjb@laptop.org, linux-mmc@vger.kernel.org, matt@console-pimps.org, pierre@ossman.eu, s.hauer@pengutronix.de From: akpm@linux-foundation.org Date: Fri, 03 Sep 2010 16:21:02 -0700 X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1283556106 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests=NO_REAL_NAME X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.39844 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name diff -puN drivers/mmc/core/core.c~mmc-make-id-freq-configurable drivers/mmc/core/core.c --- a/drivers/mmc/core/core.c~mmc-make-id-freq-configurable +++ a/drivers/mmc/core/core.c @@ -907,12 +907,7 @@ static void mmc_power_up(struct mmc_host */ mmc_delay(10); - if (host->f_min > 400000) { - pr_warning("%s: Minimum clock frequency too high for " - "identification mode\n", mmc_hostname(host)); - host->ios.clock = host->f_min; - } else - host->ios.clock = 400000; + host->ios.clock = host->f_init; host->ios.power_mode = MMC_POWER_ON; mmc_set_ios(host); @@ -1404,6 +1399,8 @@ void mmc_rescan(struct work_struct *work u32 ocr; int err; unsigned long flags; + int i; + unsigned freqs[] = { 400000, 300000, 200000, 100000 }; spin_lock_irqsave(&host->lock, flags); @@ -1443,55 +1440,64 @@ void mmc_rescan(struct work_struct *work if (host->ops->get_cd && host->ops->get_cd(host) == 0) goto out; - mmc_claim_host(host); + for (i = 0; i < ARRAY_SIZE(freqs); i++) { + mmc_claim_host(host); - mmc_power_up(host); - sdio_reset(host); - mmc_go_idle(host); + if (freqs[i] >= host->f_min) + host->f_init = freqs[i]; + else if (i && freqs[i-1] <= host->f_min) + goto out; + else + host->f_init = host->f_min; - mmc_send_if_cond(host, host->ocr_avail); + printk ("mmc_rescan: trying %u Hz\n", host->f_init); + mmc_power_up(host); + sdio_reset(host); + mmc_go_idle(host); - /* - * First we search for SDIO... - */ - err = mmc_send_io_op_cond(host, 0, &ocr); - if (!err) { - if (mmc_attach_sdio(host, ocr)) { - mmc_claim_host(host); - /* try SDMEM (but not MMC) even if SDIO is broken */ - if (mmc_send_app_op_cond(host, 0, &ocr)) - goto out_fail; + mmc_send_if_cond(host, host->ocr_avail); + + /* + * First we search for SDIO... + */ + err = mmc_send_io_op_cond(host, 0, &ocr); + if (!err) { + if (mmc_attach_sdio(host, ocr)) { + mmc_claim_host(host); + /* try SDMEM (but not MMC) even if SDIO is broken */ + if (mmc_send_app_op_cond(host, 0, &ocr)) + goto out_fail; + + if (mmc_attach_sd(host, ocr)) + mmc_power_off(host); + } + goto out; + } + /* + * ...then normal SD... + */ + err = mmc_send_app_op_cond(host, 0, &ocr); + if (!err) { if (mmc_attach_sd(host, ocr)) mmc_power_off(host); + goto out; } - goto out; - } - /* - * ...then normal SD... - */ - err = mmc_send_app_op_cond(host, 0, &ocr); - if (!err) { - if (mmc_attach_sd(host, ocr)) - mmc_power_off(host); - goto out; - } - - /* - * ...and finally MMC. - */ - err = mmc_send_op_cond(host, 0, &ocr); - if (!err) { - if (mmc_attach_mmc(host, ocr)) - mmc_power_off(host); - goto out; - } + /* + * ...and finally MMC. + */ + err = mmc_send_op_cond(host, 0, &ocr); + if (!err) { + if (mmc_attach_mmc(host, ocr)) + mmc_power_off(host); + goto out; + } out_fail: - mmc_release_host(host); - mmc_power_off(host); - + mmc_release_host(host); + mmc_power_off(host); + } out: if (host->caps & MMC_CAP_NEEDS_POLL) mmc_schedule_delayed_work(&host->detect, HZ); diff -puN include/linux/mmc/host.h~mmc-make-id-freq-configurable include/linux/mmc/host.h --- a/include/linux/mmc/host.h~mmc-make-id-freq-configurable +++ a/include/linux/mmc/host.h @@ -123,6 +123,7 @@ struct mmc_host { const struct mmc_host_ops *ops; unsigned int f_min; unsigned int f_max; + unsigned int f_init; u32 ocr_avail; struct notifier_block pm_notify;