From patchwork Fri Dec 7 13:32:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1850881 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7F52B3FCD5 for ; Fri, 7 Dec 2012 13:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030368Ab2LGNdR (ORCPT ); Fri, 7 Dec 2012 08:33:17 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:47856 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030354Ab2LGNdR (ORCPT ); Fri, 7 Dec 2012 08:33:17 -0500 Received: by mail-pb0-f46.google.com with SMTP id wy7so370202pbc.19 for ; Fri, 07 Dec 2012 05:33:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=00ZR83AZhJbK/6kq/fIJtUyvTkjAL/dLfX1/xXnh554=; b=eJ52ysWFdCeGJl/ibURaXgdF3cMx36R9lalEdMOAeaSmuozce4ws3m6D4KvLSufYFO SqBWgJmobz5LXg6RSKtt8OxvA+B12UZ1oNSDMtn90liQ94rNCtInP1n/tIwtZ8LTpQsj 8U5kxOCnmtth+ARbOXG04c6+bDXsJaYhskznsdLIQFDAeDOq8nzYPrCXYAVJ+8sHW0zT dAE+4lkAXQEMQmoCIQGT5v9VeExZ48RBN1T5+BiMa4ylP1d7+VllI/UZMCYB61Rm0VlL yu38B7y+crsUOpj0jSBYfiG4w+Kue6S6Zr0hmw6OF1FaIq5IRIo9//qf0q9eTFNegZlM lOLg== Received: by 10.68.225.70 with SMTP id ri6mr15965175pbc.41.1354887197001; Fri, 07 Dec 2012 05:33:17 -0800 (PST) Received: from S2101-09.domain ([117.60.178.142]) by mx.google.com with ESMTPS id gq10sm6702566pbc.54.2012.12.07.05.33.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Dec 2012 05:33:16 -0800 (PST) From: Shawn Guo To: linux-mmc@vger.kernel.org Cc: Guennadi Liakhovetski , Chris Ball , linux-arm-kernel@lists.infradead.org, Shawn Guo Subject: [PATCH 2/2] mmc: sdhci-esdhc-imx: use slot-gpio helpers for CD and WP Date: Fri, 7 Dec 2012 21:32:48 +0800 Message-Id: <1354887168-3073-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354887168-3073-1-git-send-email-shawn.guo@linaro.org> References: <1354887168-3073-1-git-send-email-shawn.guo@linaro.org> X-Gm-Message-State: ALoCoQndBN6MCLg46ZKllApN0YQtq1/28ktkajuxgalesFnO+vSFD8MSebRK4f30r5e/Pga+JFjQ Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Use slot-gpio helpers to save some code in the driver. Signed-off-by: Shawn Guo --- drivers/mmc/host/sdhci-esdhc-imx.c | 56 +++++++++++------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index e07df81..dd7fcc1 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -147,17 +148,16 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg) struct pltfm_imx_data *imx_data = pltfm_host->priv; struct esdhc_platform_data *boarddata = &imx_data->boarddata; - /* fake CARD_PRESENT flag */ u32 val = readl(host->ioaddr + reg); - if (unlikely((reg == SDHCI_PRESENT_STATE) - && gpio_is_valid(boarddata->cd_gpio))) { - if (gpio_get_value(boarddata->cd_gpio)) - /* no card, if a valid gpio says so... */ + if (unlikely(reg == SDHCI_PRESENT_STATE)) { + /* + * After SDHCI core gets improved to never query + * SDHCI_CARD_PRESENT state in GPIO case, we can + * remove this check. + */ + if (boarddata->cd_type == ESDHC_CD_GPIO) val &= ~SDHCI_CARD_PRESENT; - else - /* ... in all other cases assume card is present */ - val |= SDHCI_CARD_PRESENT; } if (unlikely(reg == SDHCI_CAPABILITIES)) { @@ -362,8 +362,7 @@ static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) switch (boarddata->wp_type) { case ESDHC_WP_GPIO: - if (gpio_is_valid(boarddata->wp_gpio)) - return gpio_get_value(boarddata->wp_gpio); + return mmc_gpio_get_ro(host->mmc); case ESDHC_WP_CONTROLLER: return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_WRITE_PROTECT); @@ -394,14 +393,6 @@ static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { .ops = &sdhci_esdhc_ops, }; -static irqreturn_t cd_irq(int irq, void *data) -{ - struct sdhci_host *sdhost = (struct sdhci_host *)data; - - tasklet_schedule(&sdhost->card_tasklet); - return IRQ_HANDLED; -}; - #ifdef CONFIG_OF static int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, @@ -527,37 +518,22 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) /* write_protect */ if (boarddata->wp_type == ESDHC_WP_GPIO) { - err = devm_gpio_request_one(&pdev->dev, boarddata->wp_gpio, - GPIOF_IN, "ESDHC_WP"); + err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); if (err) { - dev_warn(mmc_dev(host->mmc), - "no write-protect pin available!\n"); - boarddata->wp_gpio = -EINVAL; + dev_err(mmc_dev(host->mmc), + "failed to request write-protect gpio!\n"); + goto disable_clk; } - } else { - boarddata->wp_gpio = -EINVAL; + host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; } /* card_detect */ - if (boarddata->cd_type != ESDHC_CD_GPIO) - boarddata->cd_gpio = -EINVAL; - switch (boarddata->cd_type) { case ESDHC_CD_GPIO: - err = devm_gpio_request_one(&pdev->dev, boarddata->cd_gpio, - GPIOF_IN, "ESDHC_CD"); + err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio); if (err) { dev_err(mmc_dev(host->mmc), - "no card-detect pin available!\n"); - goto disable_clk; - } - - err = devm_request_irq(&pdev->dev, - gpio_to_irq(boarddata->cd_gpio), cd_irq, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, - mmc_hostname(host->mmc), host); - if (err) { - dev_err(mmc_dev(host->mmc), "request irq error\n"); + "failed to request card-detect gpio!\n"); goto disable_clk; } /* fall through */