From patchwork Fri Dec 9 07:11:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 130310 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 E405B1007D6 for ; Fri, 9 Dec 2011 18:12:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5004C280FB; Fri, 9 Dec 2011 08:12:03 +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 iUuVM5buKPYc; Fri, 9 Dec 2011 08:12:03 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57456280E3; Fri, 9 Dec 2011 08:11:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 316AF280BF for ; Fri, 9 Dec 2011 08:11:32 +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 zdAPC3N4ELVC for ; Fri, 9 Dec 2011 08:11:31 +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.10]) by theia.denx.de (Postfix) with ESMTP id AA456280C1 for ; Fri, 9 Dec 2011 08:11:31 +0100 (CET) Received: from benhur.adnet.avionic-design.de (p548E10F3.dip0.t-ipconnect.de [84.142.16.243]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LsOqW-1QbQBA293Q-012Bf7; 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 03CE42C4125; Fri, 9 Dec 2011 08:11:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id CD43E2A28196; 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 cTxjMSMXM-pP; 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 E64842A28193; 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:18 +0100 Message-Id: <1323414678-4291-5-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:pV6x7UehD1pgftd6iDl/CBlSmLlBkjdYXQwzEbhY3fD /r39JpFquYH+/zEtd4OdByAs+j7frIqBUaC6OY6Mjl8pcEEpY1 nIK6HDacnGaz3oT1WNT+T/pIZChnKnJkjLkd7G+lG2dZxxJ+be xu9DULTXiQXWRp+AiuSbzsyGv/KqNSHAI+VOzf3jb5UYINIE5c UzOD8pS+GuKfNcgvMZtYJTb5bfolMKN2VOyfPLXgye0jjIBc6o fx5WLTFeT7xZH+jws52x7yAn9fxEQtOdU+Q4/3anuIlVEiU2WK mvKa4n9ZieYi79+me+TfTaseYFSuyW0J36dUKbzSvpXfQFs5h3 bJIySCceD+wATkBKFy8L8+oXmJuGBsvJsd14vDzvOSlRU2/2aN A3JPs218bxhEC9m+/ZM1eF6fKiNJmF6BIhqW6vR2M3KzK2TvWW rrNyd Cc: Fabio Estevam , Tom Warren , Reinhard Meyer , Andy Fleming Subject: [U-Boot] [PATCH v2 4/4] mmc: tegra2: 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 On Tegra2, card-detection is implemented by passing the card-detection GPIOs to the MMC driver at initialization time. Instead of implementing the board_mmc_getcd() function, use the card-detect hook and allow boards to override it by providing their own board_mmc_getcd() implementation. Signed-off-by: Thierry Reding --- drivers/mmc/tegra2_mmc.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c index fe562ed..5b4c9f6 100644 --- a/drivers/mmc/tegra2_mmc.c +++ b/drivers/mmc/tegra2_mmc.c @@ -474,6 +474,18 @@ static int mmc_core_init(struct mmc *mmc) return 0; } +int tegra2_mmc_getcd(struct mmc *mmc) +{ + struct mmc_host *host = (struct mmc_host *)mmc->priv; + + debug("tegra2_mmc_getcd called\n"); + + if (host->cd_gpio >= 0) + return !gpio_get_value(host->cd_gpio); + + return 1; +} + int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio) { struct mmc_host *host; @@ -512,6 +524,7 @@ int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio) mmc->send_cmd = mmc_send_cmd; mmc->set_ios = mmc_set_ios; mmc->init = mmc_core_init; + mmc->getcd = tegra2_mmc_getcd; mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; if (bus_width == 8) @@ -535,18 +548,3 @@ int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio) return 0; } - -/* this is a weak define that we are overriding */ -int board_mmc_getcd(u8 *cd, struct mmc *mmc) -{ - struct mmc_host *host = (struct mmc_host *)mmc->priv; - - debug("board_mmc_getcd called\n"); - - if (host->cd_gpio >= 0) - *cd = !gpio_get_value(host->cd_gpio); - else - *cd = 1; - - return 0; -}