From patchwork Wed Aug 27 13:13:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 383453 X-Patchwork-Delegate: linus.walleij@linaro.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1925514009C for ; Wed, 27 Aug 2014 23:14:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933721AbaH0NOB (ORCPT ); Wed, 27 Aug 2014 09:14:01 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:53267 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933270AbaH0NOA (ORCPT ); Wed, 27 Aug 2014 09:14:00 -0400 Received: by mail-wi0-f181.google.com with SMTP id bs8so402016wib.14 for ; Wed, 27 Aug 2014 06:13:58 -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; bh=H8tHHziHLGIwCH7DXqmdo8BjhHypdgu/Nd/BQpK1ngo=; b=G9QB5LbPuj3PM3JkRxZ9Lt7yqPWROlJUiWb7uhLe2cy8jEYgQajy0mXXOqedIEZpWq 8o9mNZ+yYKCLRKFmwdHUYNvvbSk6FxRVnQNmBnIUnXaLUuooN4hNgVGhWZgfbjvgVgrr IFTnPh5UjMZpHvCjRle4DQvoHvcp14DNR3L0uLvyFDsRs1TOCZT62mtRdh6NNB00hIu7 xWTI/H8a1TSOIsUOZGITJ/lywKlUPWEiKIG1HVc1Chmk5fNyBaPd5xdODxQWeoIuhMLN Fv7/NI3ROb8JxWXqFf4+JtN0OSYvqu2sCPwhuXr0sGtVjMtkAOsDH83o/tiA7L+tmCla PSKg== X-Gm-Message-State: ALoCoQklBiBOjI387eTm29nh3NYhMFuNYu+h2EPcH2tn7QoC71Mbz5i3ot/Ih9Mc8onX3hrYDdGr X-Received: by 10.180.96.33 with SMTP id dp1mr28234547wib.20.1409145238660; Wed, 27 Aug 2014 06:13:58 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id dc9sm23783511wib.5.2014.08.27.06.13.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 06:13:57 -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 v2] mmc: mmci: augment driver to handle gpio descriptors Date: Wed, 27 Aug 2014 15:13:54 +0200 Message-Id: <1409145234-18761-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 --- ChangeLog v1->v2: - Skip excess error/info/debug report prints. --- drivers/mmc/host/mmci.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index e4d470704150..4aec22439d0e 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1658,16 +1658,35 @@ 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 < 0) { + 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; + } + } + + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0); + if (ret < 0) { + 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; + } + } } ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED,