From patchwork Tue Aug 12 17:25:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 4714321 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 B4EDB9F375 for ; Tue, 12 Aug 2014 17:26:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C894820172 for ; Tue, 12 Aug 2014 17:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E39B920166 for ; Tue, 12 Aug 2014 17:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbaHLR0l (ORCPT ); Tue, 12 Aug 2014 13:26:41 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:38884 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754012AbaHLR0k (ORCPT ); Tue, 12 Aug 2014 13:26:40 -0400 Received: by mail-wg0-f49.google.com with SMTP id k14so10250942wgh.20 for ; Tue, 12 Aug 2014 10:26:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YtZ57cKH74RDJYBXaTbIgjvMRkFXtyLQ6sowrVsHyU4=; b=FqVSkCi4BGVJyJHTU5CCtD0viCCOqcAmWXyh0Qzpzifpvb1ESQuDRBcA9gwuF/fwXM VlfbZB0lYOmEmDnwq+bjE6qpHL3sBB9B2tc8LCGsbOSiRC88bFyI1Q5dFKVA/SWgblwM yk1u4m9gWQFvgewqIeP9bUnisJcRYUbg2ZPt1UmOhFjidOIvNUUKDURGX2MJKoeklVJL kMVNIctd1vhguDANfVxdXTev9bzPUts8O+DIS1SV08PcIH3EYjU8qtzulOuwejWqkB1H FU2QLzukBXdPOVYCPoGVK4tQ3NgGrwdWh9rd38I5o8hXYqqjXGQbMuOZwmAsPrulsxif 1NXQ== X-Gm-Message-State: ALoCoQldc//qXw/rdbFfg9pAtfTjv9GuBpa8JNMPda/9ooFQg+4kAOshDVGeHExkgyY/eGXAx1P3 X-Received: by 10.194.206.67 with SMTP id lm3mr6617313wjc.70.1407864399371; Tue, 12 Aug 2014 10:26:39 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id cx5sm10649644wjb.8.2014.08.12.10.26.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Aug 2014 10:26:38 -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 , Russell King Subject: [PATCH 4/4] mmc: mmci: augment driver to handle gpio descriptors Date: Tue, 12 Aug 2014 19:25:55 +0200 Message-Id: <1407864355-21545-4-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: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Currently the MMCI driver will only handle GPIO descriptors implicitly through the device tree probe glue in mmc_of_init(), but devices instatiated other ways such as through board files and passing descriptors using the GPIO descriptor table will not be able to exploit descriptors. Augment the driver to look for a GPIO descriptor if device tree is not used for the device, and if that doesn't work, fall back to platform data GPIO assignment using the old API. The end goal is to get rid of the platform data integer GPIO assingments from the kernel. This enable the MMCI-embedding platforms to be converted to GPIO descritor tables. Cc: Alexandre Courbot Cc: Russell King Signed-off-by: Linus Walleij --- drivers/mmc/host/mmci.c | 53 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 7ad463e9741c..24a83af6d153 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1552,16 +1552,49 @@ static int mmci_probe(struct amba_device *dev, writel(0, host->base + MMCIMASK1); writel(0xfff, host->base + MMCICLEAR); - /* If DT, cd/wp gpios must be supplied through it. */ - if (!np && gpio_is_valid(plat->gpio_cd)) { - ret = mmc_gpio_request_cd(mmc, plat->gpio_cd, 0); - if (ret) - goto clk_disable; - } - if (!np && gpio_is_valid(plat->gpio_wp)) { - ret = mmc_gpio_request_ro(mmc, plat->gpio_wp); - if (ret) - goto clk_disable; + /* + * If: + * - not using DT but using a descriptor table, or + * - using a table of descriptors ALONGSIDE DT, or + * look up these descriptors named "cd" and "wp" right here, fail + * silently of these do not exist and proceed to try platform data + */ + if (!np) { + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0); + if (!ret) + dev_info(mmc_dev(mmc), "got CD GPIO (table)\n"); + else { + if (ret == -EPROBE_DEFER) + goto clk_disable; + else if (gpio_is_valid(plat->gpio_cd)) { + ret = mmc_gpio_request_cd(mmc, plat->gpio_cd, 0); + if (ret) + goto clk_disable; + else + dev_info(mmc_dev(mmc), "got CD GPIO (pdata)\n"); + } else { + dev_dbg(mmc_dev(mmc), + "no CD GPIO in DT, table or pdata\n"); + } + } + + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0); + if (!ret) + dev_info(mmc_dev(mmc), "got WP GPIO (table)\n"); + else { + if (ret == -EPROBE_DEFER) + goto clk_disable; + else if (gpio_is_valid(plat->gpio_wp)) { + ret = mmc_gpio_request_ro(mmc, plat->gpio_wp); + if (ret) + goto clk_disable; + else + dev_info(mmc_dev(mmc), "got WP GPIO (pdata)\n"); + } else { + dev_dbg(mmc_dev(mmc), + "no WP GPIO in DT, table or pdata\n"); + } + } } ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,