From patchwork Thu Oct 19 14:46:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 828145 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yHsJR0GxPz9t44 for ; Fri, 20 Oct 2017 01:49:10 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9ED22C21FAD; Thu, 19 Oct 2017 14:48:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0744FC21FA0; Thu, 19 Oct 2017 14:46:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 57637C21F8C; Thu, 19 Oct 2017 14:46:16 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id 16276C21F92 for ; Thu, 19 Oct 2017 14:46:13 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9JEiQxI028284; Thu, 19 Oct 2017 16:46:12 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2dpnj1bm4e-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 19 Oct 2017 16:46:12 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EF00631; Thu, 19 Oct 2017 14:46:11 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DD554285F; Thu, 19 Oct 2017 14:46:11 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 19 Oct 2017 16:46:11 +0200 From: To: , , Date: Thu, 19 Oct 2017 16:46:02 +0200 Message-ID: <1508424362-19649-6-git-send-email-patrice.chotard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508424362-19649-1-git-send-email-patrice.chotard@st.com> References: <1508424362-19649-1-git-send-email-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-19_05:, , signatures=0 Subject: [U-Boot] [PATCH 5/5] mmc: arm_pl180_mmci: add .getcd callback X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Patrice Chotard Add .getcd callback to check is MMC card is present Signed-off-by: Patrice Chotard --- drivers/mmc/arm_pl180_mmci.c | 24 ++++++++++++++++++++++-- drivers/mmc/arm_pl180_mmci.h | 4 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c index f060c64..a827a1e 100644 --- a/drivers/mmc/arm_pl180_mmci.c +++ b/drivers/mmc/arm_pl180_mmci.c @@ -18,9 +18,10 @@ #include #include -#include "arm_pl180_mmci.h" - #include +#include + +#include "arm_pl180_mmci.h" #ifdef CONFIG_DM_MMC #include @@ -431,6 +432,8 @@ static int arm_pl180_mmc_probe(struct udevice *dev) host->clock_max = dev_read_u32_default(dev, "max-frequency", 48000000); host->version2 = dev_get_driver_data(dev); + gpio_request_by_name(dev, "cd-gpios", 0, &host->cd_gpio, GPIOD_IS_IN); + bus_width = dev_read_u32_default(dev, "bus-width", 1); switch (bus_width) { case 8: @@ -474,9 +477,26 @@ static int dm_host_set_ios(struct udevice *dev) return host_set_ios(mmc); } +static int dm_mmc_getcd(struct udevice *dev) +{ + struct arm_pl180_mmc_plat *pdata = dev_get_platdata(dev); + struct mmc *mmc = &pdata->mmc; + struct pl180_mmc_host *host = mmc->priv; + int value = 1; + + if (dm_gpio_is_valid(&host->cd_gpio)) { + value = dm_gpio_get_value(&host->cd_gpio); + if (host->cd_inverted) + return !value; + } + + return value; +} + static const struct dm_mmc_ops arm_pl180_dm_mmc_ops = { .send_cmd = dm_host_request, .set_ios = dm_host_set_ios, + .get_cd = dm_mmc_getcd, }; static int arm_pl180_mmc_ofdata_to_platdata(struct udevice *dev) diff --git a/drivers/mmc/arm_pl180_mmci.h b/drivers/mmc/arm_pl180_mmci.h index b935288..9df4b75 100644 --- a/drivers/mmc/arm_pl180_mmci.h +++ b/drivers/mmc/arm_pl180_mmci.h @@ -191,6 +191,10 @@ struct pl180_mmc_host { unsigned int pwr_init; int version2; struct mmc_config cfg; +#ifdef CONFIG_DM_MMC + struct gpio_desc cd_gpio; + bool cd_inverted; +#endif }; int arm_pl180_mmci_init(struct pl180_mmc_host *host, struct mmc **mmc);