From patchwork Fri Jul 18 07:22:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4581061 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 7B0109F37C for ; Fri, 18 Jul 2014 07:22:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 860ED2017D for ; Fri, 18 Jul 2014 07:22:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A9C5200FF for ; Fri, 18 Jul 2014 07:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbaGRHWQ (ORCPT ); Fri, 18 Jul 2014 03:22:16 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:51238 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752104AbaGRHWP (ORCPT ); Fri, 18 Jul 2014 03:22:15 -0400 Received: by mail-we0-f180.google.com with SMTP id w61so4149443wes.39 for ; Fri, 18 Jul 2014 00:22:13 -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=FlA/Rx3FcW1ZRDr73FvZHAlbDInwvh5bJcJwAZMb8k1sNohUvdUlibQqazto3z96GA dWx+z8NBz1vT/MVrZXnFAn1vTK7BXWuMFN2SasIRe3/yzQzLHACqTCtkPpGyqmeMkUpt hJlJKeaOfa2Nt4jzTfj+h0Qan3FHxe6wK49p4R3kwFSFN0mveM+/J2MoBafFHBpM80HK VJZZo/i0+Wiz9nlJdaSLwe/Dvwg0Bk93ozACHqg3DcBc/Nb1uH2DJcCm+xEbxSwcWYJa 1WYlut5AdNhNGTR4brqyDZ2xadDnwtvmG76/QF3bkyjz76BbYzlBJJypcSgBOWQFH1GL qceA== X-Received: by 10.194.61.47 with SMTP id m15mr3620774wjr.63.1405668133867; Fri, 18 Jul 2014 00:22:13 -0700 (PDT) Received: from localhost (ip-89-176-190-177.net.upcbroadband.cz. [89.176.190.177]) by mx.google.com with ESMTPSA id m3sm3543643wik.7.2014.07.18.00.22.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 00:22:13 -0700 (PDT) From: Andreas Fenkart To: Balaji T K Cc: linux-omap@vger.kernel.org, linux-mmc@vger.kernel.org, Tony Lindgren , ulf.hansson@linaro.org, daniel@zonque.org, Andreas Fenkart Subject: [PATCH 1/3] omap_hsmmc: reuse mmc/slot-gpio for write protect detection Date: Fri, 18 Jul 2014 09:22:01 +0200 Message-Id: <1405668123-17073-2-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1405668123-17073-1-git-send-email-afenkart@gmail.com> References: <1405668123-17073-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=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,