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: 36101 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C3B05203C5 for ; Wed, 27 Aug 2014 13:14:03 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id j7sf465933qaq.9 for ; Wed, 27 Aug 2014 06:14:03 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=DAsBtZ1TdoqghyT2OHkSKk83F2zVrLglkg0ROWNVrXg=; b=ZmZ7nfhrG6IA4VbGrU9reMaFIe9W35UqSoJmw3dICD2MHvabY8Fc11Ik3L5Z/+3GdY uEH+Y2NWUiIm2LsaFH7U7CAmb2OoclXqW4enBso+eL6AeB8ZLAFpwCxMiINY4QJqpp70 jMEZrZCRL5XvvpMP/jJVEQRLaePuajxm/lpIVI9hscg6z0wEk5M/vt0/JZCX5mibc7Y+ /BLfTWIS8hlSCqW8OShaPN7zk5Jxz8LhRmI9Q339WmZMP/0s9LTpdTo3Jp4uhdB1iyTn Fxc7LfGYrwEjtaLMQd3hMlYF7wnIJXLqA8Y8FZox90+VxE+3rP2j1qAmFUi1+gVAvNbS FNZA== X-Gm-Message-State: ALoCoQnM51bqy+7jXqc+/C66XOdCwUZ13B/ygXk9BYvGm5pWPvmzQwA2N4ztA8s28C8NuS/re+Hm X-Received: by 10.52.29.72 with SMTP id i8mr18075522vdh.6.1409145243613; Wed, 27 Aug 2014 06:14:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.74 with SMTP id x68ls129654qge.28.gmail; Wed, 27 Aug 2014 06:14:03 -0700 (PDT) X-Received: by 10.220.200.195 with SMTP id ex3mr254663vcb.63.1409145243481; Wed, 27 Aug 2014 06:14:03 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id ac6si206680vdc.47.2014.08.27.06.14.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Aug 2014 06:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so61532vcb.10 for ; Wed, 27 Aug 2014 06:14:03 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr54671vdb.95.1409145243386; Wed, 27 Aug 2014 06:14:03 -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 uj3csp79898vcb; Wed, 27 Aug 2014 06:14:02 -0700 (PDT) X-Received: by 10.70.129.162 with SMTP id nx2mr835890pdb.73.1409145241542; Wed, 27 Aug 2014 06:14:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ff2si195715pad.236.2014.08.27.06.14.00 for ; Wed, 27 Aug 2014 06:14:01 -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 S933467AbaH0NOA (ORCPT + 4 others); Wed, 27 Aug 2014 09:14:00 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:46251 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933270AbaH0NN7 (ORCPT ); Wed, 27 Aug 2014 09:13:59 -0400 Received: by mail-wi0-f177.google.com with SMTP id ho1so416579wib.10 for ; Wed, 27 Aug 2014 06:13:58 -0700 (PDT) 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-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.179 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: , 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,