From patchwork Fri Dec 9 07:11:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 130307 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 909231007D6 for ; Fri, 9 Dec 2011 18:11:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C6CF0280D5; Fri, 9 Dec 2011 08:11:34 +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 eShh2zxfByIM; Fri, 9 Dec 2011 08:11:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5AC34280C3; Fri, 9 Dec 2011 08:11:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21D86280C1 for ; Fri, 9 Dec 2011 08:11:29 +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 9DaJdtCio45H for ; Fri, 9 Dec 2011 08:11:27 +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.9]) by theia.denx.de (Postfix) with ESMTP id 4E8E5280BF for ; Fri, 9 Dec 2011 08:11:25 +0100 (CET) Received: from benhur.adnet.avionic-design.de (p548E10F3.dip0.t-ipconnect.de [84.142.16.243]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MSJlD-1RB2FL1OP5-00TV23; Fri, 09 Dec 2011 08:11:24 +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 CB4A22C4124; Fri, 9 Dec 2011 08:11:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id AEE5D2A2819B; Fri, 9 Dec 2011 08:11:23 +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 Gjte0MBlOONn; Fri, 9 Dec 2011 08:11:22 +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 432192A281B3; Fri, 9 Dec 2011 08:11:21 +0100 (CET) From: Thierry Reding To: u-boot@lists.denx.de Date: Fri, 9 Dec 2011 08:11:17 +0100 Message-Id: <1323414678-4291-4-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1323414678-4291-1-git-send-email-thierry.reding@avionic-design.de> References: <1323414678-4291-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:AdIilN3OO17RhLvcYsHQHkVqBHx+fO0wYVDteApYNR1 epH7cM1uczyxw97klR3A0yBF2kLh72obrzK2lUatOPGU8C+rvv ixiMFdFpdWNQ2+I1QwyN3/BrdRcIktc3alv11StCuewTdn7VBP vJ3K84JzbkI9RHWKpT+f18QSkvM3HIFCV0bB44mAolRHrPcMDS FpS6m/Ou5mpkbexpL79NP98DasuZ/UKSaV/CcCVc6SwsI07Yg7 j7sXFK9/F/48P0Xs2i0UtgZcI2KzJeBv2XwMmT4sozusczMQ9R /oM7OVjQs7GWcmupjMhzC3tQT7GRLvTIj43A6rxk3HSslzA+Bm yFBdTads5qc4AO1viMdenYyOBodPtAVdVRHY6O5yMj4Rw9qTP7 CrYAT5SFmmTkCZUR6ANh3kxUIf1FqN7AU25Hb98xcW62I09izW +NEhD Cc: Fabio Estevam , Tom Warren , Reinhard Meyer , Andy Fleming Subject: [U-Boot] [PATCH v2 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. In addition to implementing the hook, this patch also removes the call to the board_mmc_getcd() function which is now called from the MMC framework and is no longer required here. 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;