From patchwork Mon Jan 2 11:15:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 133813 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 6DE971007D2 for ; Mon, 2 Jan 2012 22:15:57 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2CFA9282C0; Mon, 2 Jan 2012 12:15:53 +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 pZRGqvpd89SI; Mon, 2 Jan 2012 12:15:52 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DF98428292; Mon, 2 Jan 2012 12:15:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B96728297 for ; Mon, 2 Jan 2012 12:15:49 +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 wA+UGplVoyKr for ; Mon, 2 Jan 2012 12:15:48 +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.126.171]) by theia.denx.de (Postfix) with ESMTP id 867BF2827C for ; Mon, 2 Jan 2012 12:15:47 +0100 (CET) Received: from benhur.adnet.avionic-design.de (p548E095C.dip0.t-ipconnect.de [84.142.9.92]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LpAm0-1SMDkj1Ose-00f4dW; Mon, 02 Jan 2012 12:15:45 +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 1FFE02C4129; Mon, 2 Jan 2012 12:15:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id A70F72A28199; Mon, 2 Jan 2012 12:15:44 +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 PL2DbBHNkmJO; Mon, 2 Jan 2012 12:15:43 +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 699A72A2815A; Mon, 2 Jan 2012 12:15:42 +0100 (CET) From: Thierry Reding To: u-boot@lists.denx.de Date: Mon, 2 Jan 2012 12:15:38 +0100 Message-Id: <1325502939-6556-4-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1325502939-6556-1-git-send-email-thierry.reding@avionic-design.de> References: <1325502939-6556-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:3MHD8vIP+LNUdYxz8fhIfqVxLwtQTqvtxTynule7uvA 6F+U5IFdovYYQT0ilIP6IhWaxeaUxkgWOzYrhWsYYUmH2oSE5y fw9dpc1EMkH9CQl4rFCcAuoArVnIz7pevxqAFwSwX91zxSOL70 OY47tBLzsZEcOHr+feR8ReYOTmDWB6MpQ25faZDhBW95fWMwiR SGok3E2qLnUUy4ItG2J0X9w4ZChS62+1ikfOK6sTOi+9nt3pOU UfSmbXXGCP4b8akIZmln+JkWeVG5xTCVo5njHZV/lqsqzD2iCG wGDMcTjnQHyrtIm8PyVajQAHxjJVrgyBNGKdjsqWYgrMeGg7yO YMk+F2X4uJSVJ6NreBt1AbN8UkNCPCKmFHCD8Ki1Y6GOcMRIS/ OHVySebPvasRXcyXKY8dQBIfLVzjsSY41L/LrnLvEpqo26F6CG odUN9 Cc: Fabio Estevam , Tom Warren , Reinhard Meyer , Andy Fleming Subject: [U-Boot] [PATCH v4 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 Tested-by: Jason Liu --- 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 f038acc..1ed5355 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -418,7 +418,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); @@ -445,24 +444,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) @@ -500,6 +494,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;