From patchwork Tue Aug 12 17:25:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 35301 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AC80120540 for ; Tue, 12 Aug 2014 17:26:29 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf72962097pad.6 for ; Tue, 12 Aug 2014 10:26:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=d6zyiukCFfmerPbNCFsHO499ufNAauYI6LCzIUBDev4=; b=ZaVPYEiq90U4ZHzx/REy03UbERrXv5FgPlknM+TtRJAcXAPDC3X9eXL/U9iY2kRbz9 ax9C3g9ExEaxdA8bQsrtk59/8w4pvzbiFisUF5coHZJ1wR9OZEO3XSTWFj6D/km7svi3 OIzvrHHdN00hGJnHsGqMSfENK1ZDvIEY3+wnVBxrmWAbHLY7Mkf6QMFm9BxqGM3oIPOp dQRHMcXwUGzJS/oO7JEapBdmRMYHG3ekhe/hytin1Q4tHyU1IIJd4chJsTRguSICE7ES ur43/a/Kh548UmUc+r9vdIA1SnRETBVYyQwVNjPDPKMwKe9uMl139x4dxWTu6V+gpbIA t4zw== X-Gm-Message-State: ALoCoQmXqyt/NFt1htEdtHA0iBHJ1SeyRq6xLLe50yxtgZqDBnP6wemG7SLOc95EVwJve2Z96h4g X-Received: by 10.68.112.193 with SMTP id is1mr3002130pbb.2.1407864389022; Tue, 12 Aug 2014 10:26:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.113 with SMTP id e104ls249375qgd.33.gmail; Tue, 12 Aug 2014 10:26:28 -0700 (PDT) X-Received: by 10.221.64.142 with SMTP id xi14mr5409387vcb.31.1407864388911; Tue, 12 Aug 2014 10:26:28 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id xb10si8620521vcb.45.2014.08.12.10.26.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 10:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so13837807vcb.1 for ; Tue, 12 Aug 2014 10:26:28 -0700 (PDT) X-Received: by 10.221.5.137 with SMTP id og9mr5419055vcb.18.1407864388833; Tue, 12 Aug 2014 10:26:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp266490vcb; Tue, 12 Aug 2014 10:26:28 -0700 (PDT) X-Received: by 10.66.243.6 with SMTP id wu6mr1905470pac.157.1407864387830; Tue, 12 Aug 2014 10:26:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si12944921pdm.29.2014.08.12.10.26.27 for ; Tue, 12 Aug 2014 10:26:27 -0700 (PDT) Received-SPF: none (google.com: linux-mmc-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752293AbaHLR0Z (ORCPT + 4 others); Tue, 12 Aug 2014 13:26:25 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:49243 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753916AbaHLR0Y (ORCPT ); Tue, 12 Aug 2014 13:26:24 -0400 Received: by mail-wi0-f178.google.com with SMTP id hi2so6145176wib.5 for ; Tue, 12 Aug 2014 10:26:23 -0700 (PDT) X-Received: by 10.194.93.7 with SMTP id cq7mr6600472wjb.58.1407864382933; Tue, 12 Aug 2014 10:26:22 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id cx5sm10649644wjb.8.2014.08.12.10.26.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Aug 2014 10:26:22 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Chris Ball , Ulf Hansson Cc: linux-gpio@vger.kernel.org, Linus Walleij , Alexandre Courbot Subject: [PATCH 2/4] mmc: slot-gpio: add gpiod variant to get wp GPIO Date: Tue, 12 Aug 2014 19:25:53 +0200 Message-Id: <1407864355-21545-2-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407864355-21545-1-git-send-email-linus.walleij@linaro.org> References: <1407864355-21545-1-git-send-email-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This makes it possible to get the write protect (read only) GPIO line from a GPIO descriptor. Written to exactly mirror the card detect function. Cc: Alexandre Courbot Signed-off-by: Linus Walleij Acked-by: Alexandre Courbot --- drivers/mmc/core/slot-gpio.c | 48 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/slot-gpio.h | 3 +++ 2 files changed, 51 insertions(+) diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 908c2b29e79f..e3fce4493fab 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -326,6 +326,54 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, EXPORT_SYMBOL(mmc_gpiod_request_cd); /** + * mmc_gpiod_request_ro - request a gpio descriptor for write protection + * @host: mmc host + * @con_id: function within the GPIO consumer + * @idx: index of the GPIO to obtain in the consumer + * @override_active_level: ignore %GPIO_ACTIVE_LOW flag + * @debounce: debounce time in microseconds + * + * Use this function in place of mmc_gpio_request_ro() to use the GPIO + * descriptor API. Note that it is paired with mmc_gpiod_free_ro() not + * mmc_gpio_free_ro(). + * + * Returns zero on success, else an error. + */ +int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, + unsigned int idx, bool override_active_level, + unsigned int debounce) +{ + struct mmc_gpio *ctx; + struct gpio_desc *desc; + int ret; + + ret = mmc_gpio_alloc(host); + if (ret < 0) + return ret; + + ctx = host->slot.handler_priv; + + if (!con_id) + con_id = ctx->ro_label; + + desc = devm_gpiod_get_index(host->parent, con_id, idx, GPIOD_IN); + if (IS_ERR(desc)) + return PTR_ERR(desc); + + if (debounce) { + ret = gpiod_set_debounce(desc, debounce); + if (ret < 0) + return ret; + } + + ctx->override_ro_active_level = override_active_level; + ctx->ro_gpio = desc; + + return 0; +} +EXPORT_SYMBOL(mmc_gpiod_request_ro); + +/** * mmc_gpiod_free_cd - free the card-detection gpio descriptor * @host: mmc host * diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h index d2433381e828..a0d0442c15bf 100644 --- a/include/linux/mmc/slot-gpio.h +++ b/include/linux/mmc/slot-gpio.h @@ -25,6 +25,9 @@ void mmc_gpio_free_cd(struct mmc_host *host); int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, unsigned int idx, bool override_active_level, unsigned int debounce); +int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, + unsigned int idx, bool override_active_level, + unsigned int debounce); void mmc_gpiod_free_cd(struct mmc_host *host); void mmc_gpiod_request_cd_irq(struct mmc_host *host);