From patchwork Mon Dec 5 08:23:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 129242 X-Patchwork-Delegate: afleming@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 719511007D4 for ; Mon, 5 Dec 2011 19:24:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2E717280FE; Mon, 5 Dec 2011 09:24:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j8mLWE+1dJ6n; Mon, 5 Dec 2011 09:24:15 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59929280EE; Mon, 5 Dec 2011 09:24:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92847280D9 for ; Mon, 5 Dec 2011 09:24:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OJCKd9L5+0EJ for ; Mon, 5 Dec 2011 09:24:00 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by theia.denx.de (Postfix) with ESMTP id B6199280E3 for ; Mon, 5 Dec 2011 09:23:57 +0100 (CET) Received: from benhur.adnet.avionic-design.de (p548E1185.dip0.t-ipconnect.de [84.142.17.133]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0Ld8Qn-1R7SUf3AIr-00i9Hj; Mon, 05 Dec 2011 09:23:49 +0100 Received: from mailbox.adnet.avionic-design.de (add-virt-zarafa.adnet.avionic-design.de [172.20.129.9]) by benhur.adnet.avionic-design.de (Postfix) with ESMTP id 2D36E2C4115; Mon, 5 Dec 2011 09:23:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 2627A2A28187; Mon, 5 Dec 2011 09:23:48 +0100 (CET) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kMAWOTVxh53k; Mon, 5 Dec 2011 09:23:46 +0100 (CET) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) (Authenticated sender: thierry.reding) by mailbox.adnet.avionic-design.de (Postfix) with ESMTPA id 5ADDE2A28193; Mon, 5 Dec 2011 09:23:46 +0100 (CET) From: Thierry Reding To: u-boot@lists.denx.de Date: Mon, 5 Dec 2011 09:23:43 +0100 Message-Id: <1323073424-16656-3-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1323073424-16656-1-git-send-email-thierry.reding@avionic-design.de> References: <1323073424-16656-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:ybLuZ2agB0sGMG6BfLKku4JO2VeGJGAnn/ZC5hJJu8h 04RXEzCi0YC9KUvfgi0MpfCQm1pzdVreSzSBpVrBXwAUOxAeGB Ob5uQ/xxRAUHBnsyhJZYWO96Hfwwwt2BL/OIRwTAP1df+LBZdk NBADRWtn+mexP7mP5xenp4L8TIrurUxfppcfcD6bsReUjkoMbS /DTiItI+ya/MvVI59R0d7zvF0O/ZrMj0umQvNv4sc/Yr5ihVZU /JTyt5d/1W+XX2o37QhwmzqRYw85P9VLClhKNXHg9hXgHhj9J5 qOyRifZnSnRW1K6nheYAX6WwdZtxYCfSumEuBsGf6VqG0l9I5k RiWB98v9uOvvwooupSAbcn3ymUm/9p2PK3vf5TTlYeqEJh9b20 dtbZY5c0B+JKuA+Ad1Fz73eqzI0ctySzgMI0ZxLwLxgTQEe5wz 1RGLS Cc: Fabio Estevam , Tom Warren , Reinhard Meyer , Andy Fleming Subject: [U-Boot] [PATCH 3/4] mmc: fsl_esdhc: Implement card-detect hook. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This card-detect hook probably doesn't work. Perhaps somebody with more knowledge about the hardware can comment on this. I think that perhaps even the complete code from esdhc_init() could go into the getcd() function instead or mmc_getcd() needs to be called at some later time after mmc_init(), which, however, would require many other drivers to change. Signed-off-by: Thierry Reding --- drivers/mmc/fsl_esdhc.c | 29 ++++++++++++----------------- 1 files changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index f719afd..b46bf9f 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -412,7 +412,6 @@ static int esdhc_init(struct mmc *mmc) struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg->esdhc_base; int timeout = 1000; - int ret = 0; /* Reset the entire host controller */ esdhc_write32(®s->sysctl, SYSCTL_RSTA); @@ -439,24 +438,19 @@ static int esdhc_init(struct mmc *mmc) /* Set timout to the maximum value */ esdhc_clrsetbits32(®s->sysctl, SYSCTL_TIMEOUT_MASK, 14 << 16); - /* Check if there is a callback for detecting the card */ - ret = board_mmc_getcd(mmc); - if (ret < 0) { - timeout = 1000; - while (!(esdhc_read32(®s->prsstat) & PRSSTAT_CINS) && - --timeout) - udelay(1000); + return 0; +} - if (timeout <= 0) - ret = NO_CARD_ERR; - } else { - if (ret == 0) - ret = NO_CARD_ERR; - else - ret = 0; - } +static int esdhc_getcd(struct mmc *mmc) +{ + struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; + struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg->esdhc_base; + int timeout = 1000; + + while (!(esdhc_read32(®s->prsstat) & PRSSTAT_CINS) && --timeout) + udelay(1000); - return ret; + return timeout > 0; } static void esdhc_reset(struct fsl_esdhc *regs) @@ -494,6 +488,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) mmc->send_cmd = esdhc_send_cmd; mmc->set_ios = esdhc_set_ios; mmc->init = esdhc_init; + mmc->getcd = esdhc_getcd; voltage_caps = 0; caps = regs->hostcapblt;