From patchwork Sun Dec 2 08:43:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152649 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5558199ljp; Sun, 2 Dec 2018 00:46:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/VhQHDVcVVyQCV2oCIN1Ju8Xzgg18FCvjkC2U5QRmKYqLR0GGWoGO0wsXKec+auioho9CM2 X-Received: by 2002:a63:334a:: with SMTP id z71mr9879270pgz.400.1543740404520; Sun, 02 Dec 2018 00:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543740404; cv=none; d=google.com; s=arc-20160816; b=clQpTYmozRPX0f8tHRsB7U/d8jZlYx5mSu9ecK3SYOsqe5S8V3ZWWiEOkWR/0Wd9KH SkOL7thxvtXg/dLG+t4ii0ss7vHMYDATi9wQmNpR9P1IHM3x97fxs7TsGihbTNV0lWXW qcnLNtemISkBHLNhffHJgjHzfRDCGYZVwHWyomC2ytxJyDhKtW8VgoqPFPncr9KpFwCK 9AaoEnSEGDMt8TQbMSJLAJ6Tyj4eJeLcuD05ChFSoxjt4jzJJcjmf1yfTyY/v4GMw8r+ Mc57c+9bhIeJxERL6tuwgtPv1+HLpWthSL5OxD/YKzqI7c4IaUFi5bkWvnDWG+n8Qm6k 9q5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2bLty74+TcSze6J6LiBJ2UxV5DWXbb/dBWSHNDNVtVo=; b=ai4W/uvoSlkpjveGuCa4KYdx/FSh1aOkULEne3KwML6xA2L5CY/AXqXmgPK9Y+W8md gbbCMDANd/1jb34S7+7xT6bMJo2zzUUVZrF9l/OvI3LdIjS2sFUreOWbingFDiC7ufTX A4YmbeYzWX3w9gjD4BvoRM42GHOpVVysL8tLZifiwCsDlMxZ6tfwdZNxHW+xNtUIaYio 0a2ERu1ISgaC5Lm6YwPtD9UCWZ01i+wwgWnhDeYMdot9gCNQfQ12ys/Xj7j/Ed5BjdeM FiBuNRvu0b3XWOG1WtHFtjWQGZWBbV6a2YLzotXVXcVlioTwWqfP08thJ0evehTRy6k3 Qf7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+KyefPt; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si9351748pgz.593.2018.12.02.00.46.44; Sun, 02 Dec 2018 00:46:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+KyefPt; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725803AbeLBIqq (ORCPT + 5 others); Sun, 2 Dec 2018 03:46:46 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40645 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbeLBIqp (ORCPT ); Sun, 2 Dec 2018 03:46:45 -0500 Received: by mail-lj1-f194.google.com with SMTP id n18-v6so8601517lji.7 for ; Sun, 02 Dec 2018 00:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2bLty74+TcSze6J6LiBJ2UxV5DWXbb/dBWSHNDNVtVo=; b=I+KyefPtB6M52LX0jrSlnWQzG3+sPIJBu2B9NXv8wNDEQKseg4aP9aX1fcPg3CC+qd dYQA4EgDkITRNzjLV5+kgkPeq+0iRXHlG0kbZsx+zDaNPq/IUZr4JtkN/8myMPBny8vJ F9HcOJKI2JuZnd1yfKatp0Odk1mswyX7XNzLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2bLty74+TcSze6J6LiBJ2UxV5DWXbb/dBWSHNDNVtVo=; b=TTAVBKe5UGH99c8ffEEd4nD8BLCPkfO3zOEF/OhmeWIhH/LcqPPWz4hBTQP7BZcp01 /dJsZEKm8b+pYmABlN0dEMB5YCK1OBPvniYs5ralnEW8PBsb+AfqtZ7KZB6l65MmIcLj cqF0AaEf2AVJvQv39mezmPvdgvtric70KIMBE61WNH0+BC7npw3dORYvfouyyDB7plRg jpdntk4n6dQi7cRytCPodcJvKxHlh4gvZYyi5XSz0ERhPN/Hm5XhqawjpIM3Q8TPyo3Z B1mUd0I6NpXpHc/NR3uZb9c27xBdy9hn2AyvurP4BFgeBq9ncnrkZq/qRxto23AZZy8n 7l0g== X-Gm-Message-State: AA+aEWYbeaKfgfzR0bdocJQpFV/a6BZHKKM0RyQ4Scy3WWJpfuVfB0AU J65XqJNOOHiydfPrmxhSsAjH2IryFOujxQ== X-Received: by 2002:a2e:9dcb:: with SMTP id x11-v6mr8277804ljj.158.1543740394383; Sun, 02 Dec 2018 00:46:34 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id z7-v6sm1772719lji.42.2018.12.02.00.46.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Dec 2018 00:46:33 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH 02/11 v4] mmc: host: tmio: Use GPIO descriptors Date: Sun, 2 Dec 2018 09:43:19 +0100 Message-Id: <20181202084328.25546-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181202084328.25546-1-linus.walleij@linaro.org> References: <20181202084328.25546-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The TMIO MMC driver was passing global GPIO numbers around for card detect. It turns out only one single board in the kernel was actually making use of this feature so it is pretty easy to convert the driver to use only GPIO descriptors. The lines are flagged as GPIO_ACTIVE_[LOW|HIGH] as that is what they are, and since we can now rely on the descriptors to have the right polarity, we set the "override_active_level" to false in mmc_gpiod_request_cd() and mmc_gpiod_request_ro(). Reviewed-by: Laurent Pinchart Acked-by: Kuninori Morimoto Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Collect Kuninori's ACK. - Collect Laurent's review tag. - Fix commit message to say why we do not override the active level anymore. ChangeLog v1->v3: - Kuninori/Laurent: any tests/ACKs appreciated. --- arch/sh/boards/mach-ecovec24/setup.c | 26 ++++++++++++++++++++++---- drivers/mmc/host/tmio_mmc_core.c | 12 +++++++----- include/linux/mfd/tmio.h | 9 ++------- 3 files changed, 31 insertions(+), 16 deletions(-) -- 2.19.1 diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 3097307b7cb7..af2c28946319 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -696,13 +696,20 @@ static struct gpiod_lookup_table sdhi0_power_gpiod_table = { }, }; +static struct gpiod_lookup_table sdhi0_gpio_table = { + .dev_id = "sh_mobile_sdhi.0", + .table = { + /* Card detect */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct tmio_mmc_data sdhi0_info = { .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | MMC_CAP_NEEDS_POLL, - .flags = TMIO_MMC_USE_GPIO_CD, - .cd_gpio = GPIO_PTY7, }; static struct resource sdhi0_resources[] = { @@ -735,8 +742,15 @@ static struct tmio_mmc_data sdhi1_info = { .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX, .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | MMC_CAP_NEEDS_POLL, - .flags = TMIO_MMC_USE_GPIO_CD, - .cd_gpio = GPIO_PTW7, +}; + +static struct gpiod_lookup_table sdhi1_gpio_table = { + .dev_id = "sh_mobile_sdhi.1", + .table = { + /* Card detect */ + GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW), + { }, + }, }; static struct resource sdhi1_resources[] = { @@ -1445,6 +1459,10 @@ static int __init arch_setup(void) gpiod_add_lookup_table(&cn12_power_gpiod_table); #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) gpiod_add_lookup_table(&sdhi0_power_gpiod_table); + gpiod_add_lookup_table(&sdhi0_gpio_table); +#endif +#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) + gpiod_add_lookup_table(&sdhi1_gpio_table); #endif return platform_add_devices(ecovec_devices, diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 8d64f6196f33..487b88dceff4 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1167,11 +1167,13 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) if (ret < 0) return ret; - if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); - if (ret) - return ret; - } + /* + * Look for a card detect GPIO, if it fails with anything + * else than a probe deferral, just live without it. + */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2; diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h index 1e70060c92ce..e2687a30e5a1 100644 --- a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -54,12 +54,8 @@ * idle before writing to some registers. */ #define TMIO_MMC_HAS_IDLE_WAIT BIT(4) -/* - * A GPIO is used for card hotplug detection. We need an extra flag for this, - * because 0 is a valid GPIO number too, and requiring users to specify - * cd_gpio < 0 to disable GPIO hotplug would break backwards compatibility. - */ -#define TMIO_MMC_USE_GPIO_CD BIT(5) + +/* BIT(5) is unused */ /* * Some controllers have CMD12 automatically @@ -104,7 +100,6 @@ struct tmio_mmc_data { unsigned long capabilities2; unsigned long flags; u32 ocr_mask; /* available voltages */ - unsigned int cd_gpio; int alignment_shift; dma_addr_t dma_rx_offset; unsigned int max_blk_count;