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: 4788051 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15BF79F2A9 for ; Wed, 27 Aug 2014 13:14:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3424A2012D for ; Wed, 27 Aug 2014 13:14:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8AB220123 for ; Wed, 27 Aug 2014 13:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933467AbaH0NOA (ORCPT ); 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-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=EYabp4VJPLOaA/KQq0N7cqDHgvR5ZHoJeFGNqkCKzl6BnQLXijLAiFEBDdT7oLEC6Y N9TarmVyGN4e0dO5G9FF12c/V3GnyFQU390kGWDQpWl3mvGGUcxDhhdG3Vk02Q4pRbrx eXDPB9t7KUdQpmJWAZkMvuJ+Fdn3mO3L5bVnWxgU91HO3pKMi8Sz8040SGtgFXYf/Nza BYaUwP4K7RJtZvMYiqmxeouWH3uZUh9MPzBOnROnFJFsbyaGHMQVjORgUj8QC4/dCYgz SHcpxNzZNv3uBjRKBGznGSCbwPSpX1eOd/NG6Hp09hWsRPiPD5m43exhlEH5C001ppnx ZY+Q== X-Gm-Message-State: ALoCoQm1ngc3EYzX0qJ7GXyp60losbzHdEotCLyqRM6e1IZYaqEnhlSp6R19S6mKyldtFm65J7e7 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: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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,