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: 35304 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A51D220540 for ; Tue, 12 Aug 2014 17:26:43 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf25643608igi.0 for ; Tue, 12 Aug 2014 10:26:43 -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=PZOd9KQrsTFclbigKH5gR6HMboyiVF+4d4aJnRDcszI=; b=A5H+JcmpVCqpjK6QLapvfjlXKLmm/uzqY7SbsPR6yAoW9d8NjSE1u9wJTKmwmwj2aP TKSTBsbdo5eRlzx512lj23Mf6MyWpu6PZPK6KyCA9zHOSBBx2qk3TO9OSAk/3E0G0/0g 9wa0dARHQrv2wSkRCK0B8UBs4JPNF/eRlG7Iae6JwuYCG/wvSAbPcuy8RlfMgZp9eCdO h+4JNKDP2ifYk02tENXUrY7Eqhjj+5bjwP9rfCuunfm4L5w127B52loHLcXwYxKT++tc FpVwlwEXH8lpRQXiiJ8n2VU0flG1jOV0XYg7AWhslttxHtoWLpL8FVHy9d5udDTHW5QR F8jw== X-Gm-Message-State: ALoCoQkazoX+hSca0kB2a32mN/fXDWTMifsc78TLhQR562D7utzkPxre7GZwcsdWpkrAXyixno/o X-Received: by 10.182.107.135 with SMTP id hc7mr697242obb.48.1407864403094; Tue, 12 Aug 2014 10:26:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.231 with SMTP id v94ls224482qgd.14.gmail; Tue, 12 Aug 2014 10:26:42 -0700 (PDT) X-Received: by 10.220.181.196 with SMTP id bz4mr5401991vcb.36.1407864402924; Tue, 12 Aug 2014 10:26:42 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id 5si2500547vde.53.2014.08.12.10.26.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 10:26:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so13667401vcb.19 for ; Tue, 12 Aug 2014 10:26:42 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr5084961vdb.27.1407864402816; Tue, 12 Aug 2014 10:26:42 -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.37.5 with SMTP id tc5csp266513vcb; Tue, 12 Aug 2014 10:26:42 -0700 (PDT) X-Received: by 10.68.229.193 with SMTP id ss1mr2466197pbc.158.1407864401831; Tue, 12 Aug 2014 10:26:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si12944921pdm.29.2014.08.12.10.26.41 for ; Tue, 12 Aug 2014 10:26:41 -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 S1753216AbaHLR0l (ORCPT ); Tue, 12 Aug 2014 13:26:41 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:49174 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754059AbaHLR0k (ORCPT ); Tue, 12 Aug 2014 13:26:40 -0400 Received: by mail-wg0-f50.google.com with SMTP id n12so10359009wgh.9 for ; Tue, 12 Aug 2014 10:26:39 -0700 (PDT) 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-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.220.174 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 --- 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,