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: 36080 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 04F6A203C5 for ; Wed, 27 Aug 2014 11:01:41 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id eb12sf156631oac.1 for ; Wed, 27 Aug 2014 04:01:41 -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=q0dE1YxZMWgZo1VFgOfML8mM8qwzEvrf+CDYg41Vme0=; b=CKsIGuq6HuC1ZJUv+EZ2qt69BL3rTx/6yUwmBM+gH0ltggrmHa7ZfiMlge7qu2pJVD aSvXfhRpJ/ybR59XqauA2tvKNItJ7R4wQWettEFnSK3RtW8ItihRgatawRQl86sH/OH1 QT4fR0Nw1Im4B9GWimGPNV4nUKQPhMfMmfVjcCH8UPBsN78XpgCEuck1lDHsK05+rsMK gfSSNnPywTRMEmh2YL0N979QomI0Q9tsUhDwQXkT3GjeoFivbZibGiusckdyEpS3SRt2 gZ8pPmxYSDU3vOARAhBiVK6MjuzDpzJHF5kwlvcJgxByxIjZoJJ26qgOSVx+GIqJeLS5 eQTA== X-Gm-Message-State: ALoCoQnXBXAjGJ1IaRT/SqAY2lFWyQd+oLejwRUki9WHokNJ9DZMfqxoJOFjQOjSRpvOSewPgIv1 X-Received: by 10.42.62.73 with SMTP id x9mr25572029ich.15.1409137301401; Wed, 27 Aug 2014 04:01:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.69 with SMTP id 63ls82816qgo.59.gmail; Wed, 27 Aug 2014 04:01:41 -0700 (PDT) X-Received: by 10.236.2.34 with SMTP id 22mr33727yhe.161.1409137301291; Wed, 27 Aug 2014 04:01:41 -0700 (PDT) Received: from mail-yh0-f51.google.com (mail-yh0-f51.google.com [209.85.213.51]) by mx.google.com with ESMTPS id v24si4849316yhg.91.2014.08.27.04.01.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Aug 2014 04:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.213.51 as permitted sender) client-ip=209.85.213.51; Received: by mail-yh0-f51.google.com with SMTP id f73so31775yha.38 for ; Wed, 27 Aug 2014 04:01:41 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr578280vdb.8.1409137301183; Wed, 27 Aug 2014 04:01:41 -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 uj3csp62869vcb; Wed, 27 Aug 2014 04:01:40 -0700 (PDT) X-Received: by 10.66.242.47 with SMTP id wn15mr45446358pac.64.1409137300069; Wed, 27 Aug 2014 04:01:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tl8si8341026pac.234.2014.08.27.04.01.34 for ; Wed, 27 Aug 2014 04:01:34 -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 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-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: 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.213.51 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 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,