From patchwork Wed Aug 27 11:00: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: 383422 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 355FC1400A3 for ; Wed, 27 Aug 2014 21:01:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756279AbaH0LBM (ORCPT ); Wed, 27 Aug 2014 07:01:12 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:57511 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756189AbaH0LBK (ORCPT ); Wed, 27 Aug 2014 07:01:10 -0400 Received: by mail-we0-f171.google.com with SMTP id p10so38522wes.30 for ; Wed, 27 Aug 2014 04:01:09 -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=1s77W64fbqfTB6CtrsILX7MVuQ6jIEYlPUMgya9k1Ek=; b=jtRE5/nI1y/ThSSIjOowFq02r7sgGVl2sP9jxuztmYxeAkymG6jNx+5U9YB8R5bhgq yWzQ+SFtjuSeHhKVP8uqCG3RQrJ9wRexy1/IcsOymLbrJsHiu1Ed5YGdZ2BvswVJZqil Q0NRowfi5EJ8r0VfyGRZCtgct0xm8LyCFWEXUkC+F8mco6lyc+AuiopRv4DzEM5zQ7xt SBNhOfFLvbLmhmG33ZX9K6GHEF2UiZqRaRCMZdG/vsiTxtRmZwW0nzSjGEYpzMPQW6CF VOKD2USsQLRMFiuj+IHPMhGhCS73ddfYaSVF/i3tOrPJ/c2TY9LJXhHGVVj6RfDcjGLi GoqQ== X-Gm-Message-State: ALoCoQmYYE1xJA9z9RhB8aMXKOcB+QGZQfh1MR6clCorV5EliNFFz76+d+mtlCOHDr3iPMeCX7l2 X-Received: by 10.194.78.243 with SMTP id e19mr1802090wjx.119.1409137269247; Wed, 27 Aug 2014 04:01:09 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id y5sm93002wje.32.2014.08.27.04.01.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 04:01:08 -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: Wed, 27 Aug 2014 13:00:53 +0200 Message-Id: <1409137253-25189-4-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: 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 --- 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 e4d470704150..37a6542f056c 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1658,16 +1658,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,