From patchwork Wed Aug 27 11:00:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 36079 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 1CC7C203C5 for ; Wed, 27 Aug 2014 11:01:35 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf215215pad.6 for ; Wed, 27 Aug 2014 04:01:31 -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=kBFaSgi8wXOe8+j341OI3+D2mzLNIzvC1fSLKnolR+w=; b=bZczhk1aw4DsTPkwP6eymkUp1bCE3ls6XJULlv95Jy3cfa4MXHZDe8KxSMgat8liDt /p9r+XrX/wMULWv8hPb7W90xerIy2kXMYWoQFT6r2QiojfGuIte6yZjq/QSP7aqUezGS IpYu4AYkplX6DbeTZ1nQ5fHsWhu5SDIp93OmL3NKP1x0KBZOIldICQHFFCMvv9JMpb8C DN0T49S7tKMJko+Uqlkh6MHxai8JNQocGZws5Rcj7r5azj7EU209Szz8YxnwFMlY3jfX AoY5fVhumgyHNDcMbPISlNKVAGRl1xPRyLlewPyqI6XBh3O2ymMoNRstGFt7bS2dR8Ig ZWOg== X-Gm-Message-State: ALoCoQmNXMvPU7/PKxAvDFtAZdk1TaiQXVogq9g34X02W2bwGId5LQl4di5A4XBUMLdYC4P0rWjp X-Received: by 10.66.137.68 with SMTP id qg4mr363789pab.26.1409137289661; Wed, 27 Aug 2014 04:01:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.177 with SMTP id y46ls56370qge.79.gmail; Wed, 27 Aug 2014 04:01:29 -0700 (PDT) X-Received: by 10.236.26.101 with SMTP id b65mr49660290yha.75.1409137289548; Wed, 27 Aug 2014 04:01:29 -0700 (PDT) Received: from mail-yk0-f171.google.com (mail-yk0-f171.google.com [209.85.160.171]) by mx.google.com with ESMTPS id j25si29923yhb.29.2014.08.27.04.01.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Aug 2014 04:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.160.171 as permitted sender) client-ip=209.85.160.171; Received: by mail-yk0-f171.google.com with SMTP id 19so35898ykq.2 for ; Wed, 27 Aug 2014 04:01:29 -0700 (PDT) X-Received: by 10.52.148.2 with SMTP id to2mr818651vdb.38.1409137289458; Wed, 27 Aug 2014 04:01:29 -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.45.67 with SMTP id uj3csp62841vcb; Wed, 27 Aug 2014 04:01:28 -0700 (PDT) X-Received: by 10.66.233.226 with SMTP id tz2mr44876642pac.94.1409137288538; Wed, 27 Aug 2014 04:01:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tl8si8341026pac.234.2014.08.27.04.01.22 for ; Wed, 27 Aug 2014 04:01:22 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-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 S1755905AbaH0LBI (ORCPT ); Wed, 27 Aug 2014 07:01:08 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:47213 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755202AbaH0LBH (ORCPT ); Wed, 27 Aug 2014 07:01:07 -0400 Received: by mail-wi0-f181.google.com with SMTP id bs8so232026wib.2 for ; Wed, 27 Aug 2014 04:01:04 -0700 (PDT) X-Received: by 10.194.179.197 with SMTP id di5mr1622338wjc.125.1409137264018; Wed, 27 Aug 2014 04:01:04 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id y5sm93002wje.32.2014.08.27.04.01.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 04:01:02 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Chris Ball , Ulf Hansson Cc: linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 2/4] mmc: slot-gpio: add gpiod variant to get wp GPIO Date: Wed, 27 Aug 2014 13:00:51 +0200 Message-Id: <1409137253-25189-2-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409137253-25189-1-git-send-email-linus.walleij@linaro.org> References: <1409137253-25189-1-git-send-email-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@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.160.171 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. Acked-by: Alexandre Courbot Signed-off-by: Linus Walleij --- 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);