From patchwork Mon Jan 2 11:15:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 133814 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 88605B6FA7 for ; Mon, 2 Jan 2012 22:16:20 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EBB65282AB; Mon, 2 Jan 2012 12:16:05 +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 yjKU43UdVSDd; Mon, 2 Jan 2012 12:16:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B1BF1282B3; Mon, 2 Jan 2012 12:15:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8DB472827B 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 SSSSombHz7b9 for ; Mon, 2 Jan 2012 12:15:49 +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 D08D028292 for ; Mon, 2 Jan 2012 12:15:48 +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 0M6ym1-1Sdc0q2BVt-00wKF6; 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 625372C4119; 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 EF4362A2810C; 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 DZMq-alea+Ak; Mon, 2 Jan 2012 12:15:44 +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 DF6252A281C7; 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:39 +0100 Message-Id: <1325502939-6556-5-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:dp5LcDLn8CvcrjIb6LBlJDrP1C5yzSyR0bnosmdHxq6 8YizQ7E8kjCWxhkCDT7YxjlfyJMWzQ21YTl5EEdBh44f0fM0ji LSd5S69+a5fvrVQ20g5QP1cfZRHINOJGWnW7Cva0boSrz5RhHL ap5gqGKqTI9VCPHUMYa68cqpRFXnGlphqabPuHmpL1mupystVU lqizAAAyMFULDy0xI9D87rYy0mTCValsjayMYWWWEW/NZPweXf xEVTqOunMLXZJQg+QkhuMp97PpUryR5xlrWYpH4EDS8OOmQuRZ Nm3FzZx0pwT4JAfSLQCjsT2vZCK3T613s6uTZlReR6Kq3QZ9B3 BNMAx+I+yzMCIYwXmDKkkQwQPNwWQG503ZjH3dfHYTtWzd97hz 3wdre2H88LYmNRnU0ryo25iByrFYOYOTrXFcrk6rKoIAT4erEE 3M3lm Cc: Fabio Estevam , Tom Warren , Reinhard Meyer , Andy Fleming Subject: [U-Boot] [PATCH v4 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 | 32 +++++++++++++------------------- 1 files changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c index 035a868..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,22 +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"); - - *cd = 1; /* Assume card is inserted, or eMMC */ - - if (IS_SD(mmc)) { - if (host->cd_gpio >= 0) { - if (gpio_get_value(host->cd_gpio)) - *cd = 0; - } - } - - return 0; -}