From patchwork Sat Jul 26 18:34:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4627641 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 57A6E9F36A for ; Sat, 26 Jul 2014 18:34:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 706C220115 for ; Sat, 26 Jul 2014 18:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F7712015E for ; Sat, 26 Jul 2014 18:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbaGZSeW (ORCPT ); Sat, 26 Jul 2014 14:34:22 -0400 Received: from mail-we0-f181.google.com ([74.125.82.181]:61993 "EHLO mail-we0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751819AbaGZSeV (ORCPT ); Sat, 26 Jul 2014 14:34:21 -0400 Received: by mail-we0-f181.google.com with SMTP id k48so5566030wev.26 for ; Sat, 26 Jul 2014 11:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FLQd8aLU6UE0hX1mRnFixmmDT8hBJR3gDWt5CEYd3+Q=; b=glknRqhF+M1U2eqNaId8HbWF1zw7ao+2uyQfcKY0lu7nU/sAIXbJ94D+zhuRzI16Lz /Kr31KUPm7j1b35b84BgEtCDu2viWO03IpemoypTJNgNF2zSwH13hW9QZSWVr7AqX8zS m9kQr/Xx1alCFLlsusNieViKx9QOH4RD/tI+lZ3Y8bC8vkjilytWo2ls8dzT9aIKQ54F +PBOpGV4cB5tZebK7NJ2Z7sVuQvTeMur14Y+Y7Bkz/6Am77dPdP+1M4RlAvy0kz+M14s OdjCBifQywgCnXUVnqNUyP+MMwVLaTM4AdXQZgqTPmBM+yiXt5DtSRaA4nvBk/Z9lb9v 0cJg== X-Received: by 10.180.187.197 with SMTP id fu5mr4166757wic.64.1406399659832; Sat, 26 Jul 2014 11:34:19 -0700 (PDT) Received: from localhost (ip-94-112-0-184.net.upcbroadband.cz. [94.112.0.184]) by mx.google.com with ESMTPSA id bx2sm35383035wjb.47.2014.07.26.11.34.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jul 2014 11:34:19 -0700 (PDT) From: Andreas Fenkart To: linux-mmc@vger.kernel.org Cc: linux-omap@vger.kernel.org, Tony Lindgren , Balaji T K , daniel@zonque.org, Andreas Fenkart Subject: [PATCH 1/3 resend] omap_hsmmc: reuse mmc/slot-gpio for write protect detection Date: Sat, 26 Jul 2014 20:34:08 +0200 Message-Id: <1406399650-671-2-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406399650-671-1-git-send-email-afenkart@gmail.com> References: <1406399650-671-1-git-send-email-afenkart@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Andreas Fenkart diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 2f944d7..1c10e6c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -239,15 +240,6 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot) return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); } -static int omap_hsmmc_get_wp(struct device *dev, int slot) -{ - struct omap_hsmmc_host *host = dev_get_drvdata(dev); - struct omap_mmc_platform_data *mmc = host->pdata; - - /* NOTE: assumes write protect signal is active-high */ - return gpio_get_value_cansleep(mmc->slots[0].gpio_wp); -} - static int omap_hsmmc_get_cover_state(struct device *dev, int slot) { struct omap_hsmmc_host *host = dev_get_drvdata(dev); @@ -449,7 +441,8 @@ static inline int omap_hsmmc_have_reg(void) #endif -static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata) +static int omap_hsmmc_gpio_init(struct mmc_host *mmc, + struct omap_mmc_platform_data *pdata) { int ret; @@ -471,31 +464,31 @@ static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata) pdata->slots[0].switch_pin = -EINVAL; if (gpio_is_valid(pdata->slots[0].gpio_wp)) { - pdata->slots[0].get_ro = omap_hsmmc_get_wp; - ret = gpio_request(pdata->slots[0].gpio_wp, "mmc_wp"); - if (ret) - goto err_free_cd; - ret = gpio_direction_input(pdata->slots[0].gpio_wp); - if (ret) - goto err_free_wp; - } else - pdata->slots[0].gpio_wp = -EINVAL; + /* copy & paste from from mmc_of_parse */ + ret = mmc_gpio_request_ro(mmc, pdata->slots[0].gpio_wp); + if (ret < 0) { + dev_err(pdata->dev, + "Failed to request WP GPIO: %d!\n", ret); + goto err; + } else { + dev_info(pdata->dev, "Got WP GPIO #%d.\n", + pdata->slots[0].gpio_wp); + } + } return 0; -err_free_wp: - gpio_free(pdata->slots[0].gpio_wp); -err_free_cd: +err: if (gpio_is_valid(pdata->slots[0].switch_pin)) err_free_sp: gpio_free(pdata->slots[0].switch_pin); return ret; } -static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata) +static void omap_hsmmc_gpio_free(struct mmc_host *mmc, + struct omap_mmc_platform_data *pdata) { - if (gpio_is_valid(pdata->slots[0].gpio_wp)) - gpio_free(pdata->slots[0].gpio_wp); + mmc_gpio_free_ro(mmc); if (gpio_is_valid(pdata->slots[0].switch_pin)) gpio_free(pdata->slots[0].switch_pin); } @@ -1673,15 +1666,6 @@ static int omap_hsmmc_get_cd(struct mmc_host *mmc) return mmc_slot(host).card_detect(host->dev, host->slot_id); } -static int omap_hsmmc_get_ro(struct mmc_host *mmc) -{ - struct omap_hsmmc_host *host = mmc_priv(mmc); - - if (!mmc_slot(host).get_ro) - return -ENOSYS; - return mmc_slot(host).get_ro(host->dev, 0); -} - static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card) { struct omap_hsmmc_host *host = mmc_priv(mmc); @@ -1837,7 +1821,7 @@ static const struct mmc_host_ops omap_hsmmc_ops = { .request = omap_hsmmc_request, .set_ios = omap_hsmmc_set_ios, .get_cd = omap_hsmmc_get_cd, - .get_ro = omap_hsmmc_get_ro, + .get_ro = mmc_gpio_get_ro, .init_card = omap_hsmmc_init_card, .enable_sdio_irq = omap_hsmmc_enable_sdio_irq, }; @@ -2063,16 +2047,15 @@ static int omap_hsmmc_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - ret = omap_hsmmc_gpio_init(pdata); - if (ret) - goto err; - mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev); if (!mmc) { - ret = -ENOMEM; - goto err_alloc; + return -ENOMEM; } + ret = omap_hsmmc_gpio_init(mmc, pdata); + if (ret) + goto err; + host = mmc_priv(mmc); host->mmc = mmc; host->pdata = pdata; @@ -2302,10 +2285,9 @@ err_irq: if (host->dbclk) clk_disable_unprepare(host->dbclk); err1: - mmc_free_host(mmc); -err_alloc: - omap_hsmmc_gpio_free(pdata); + omap_hsmmc_gpio_free(mmc, pdata); err: + mmc_free_host(mmc); return ret; } @@ -2330,7 +2312,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev) if (host->dbclk) clk_disable_unprepare(host->dbclk); - omap_hsmmc_gpio_free(host->pdata); + omap_hsmmc_gpio_free(host->mmc, host->pdata); mmc_free_host(host->mmc); return 0; diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h index 51e70cf..7fe0c14 100644 --- a/include/linux/platform_data/mmc-omap.h +++ b/include/linux/platform_data/mmc-omap.h @@ -120,7 +120,6 @@ struct omap_mmc_platform_data { int (*set_bus_mode)(struct device *dev, int slot, int bus_mode); int (*set_power)(struct device *dev, int slot, int power_on, int vdd); - int (*get_ro)(struct device *dev, int slot); void (*remux)(struct device *dev, int slot, int power_on); /* Call back before enabling / disabling regulators */ void (*before_set_reg)(struct device *dev, int slot,