From patchwork Fri Aug 8 10:16:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4695101 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 48C42C0338 for ; Fri, 8 Aug 2014 10:17:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EA6D200DF for ; Fri, 8 Aug 2014 10:17:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 36FFF201B4 for ; Fri, 8 Aug 2014 10:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756531AbaHHKRL (ORCPT ); Fri, 8 Aug 2014 06:17:11 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:58222 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756210AbaHHKRK (ORCPT ); Fri, 8 Aug 2014 06:17:10 -0400 Received: by mail-wg0-f48.google.com with SMTP id x13so5420414wgg.7 for ; Fri, 08 Aug 2014 03:17:08 -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=sZqv1sYat3viAm1gSnwWbcbT67wXY1Mr31z9QWCwiH0Kl4S7Jeoj7trDNpxMFFri9B ATHg7VbELkUjh5WzZgeZkg7q0znZYH+s8CmEv8EbYxS0dN420mJMwMv5fSxRPANTBMrT GKb8HTfdlseuJZtD0nRvoDYZB9tlc88bZsCrFgbTDOXg4GcdwbHWUD1C0fIzTUyvT4fv oOqghaecz0EwJfEZA/E9eNdg3CuP24IF3bYrkPBL/Pj2R9/ol+5PFfMx2c9dDxKQoWg3 wxD/ulTC0/Any0J4VJMKu4MTj652WxCdicglzaZLemXlAFszRbjKlGIBUaJhG0ld26Ud xKOw== X-Received: by 10.194.92.148 with SMTP id cm20mr31362875wjb.57.1407493028313; Fri, 08 Aug 2014 03:17:08 -0700 (PDT) Received: from localhost (ip-94-112-2-16.net.upcbroadband.cz. [94.112.2.16]) by mx.google.com with ESMTPSA id h13sm16328939wjs.2.2014.08.08.03.17.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Aug 2014 03:17:07 -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: Fri, 8 Aug 2014 12:16:58 +0200 Message-Id: <1407493020-11566-2-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407493020-11566-1-git-send-email-afenkart@gmail.com> References: <1407493020-11566-1-git-send-email-afenkart@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.5 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=ham 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,