From patchwork Sun Nov 25 22:52:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151933 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4908778ljp; Sun, 25 Nov 2018 14:54:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEB0Z4jQlyS83doKVGEBPJ70Qm0V309OovXhF8yT6BKHC/aU7LSHvamRX/SYwkrDT9Ghi8 X-Received: by 2002:a63:cd4c:: with SMTP id a12mr22855637pgj.252.1543186480378; Sun, 25 Nov 2018 14:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543186480; cv=none; d=google.com; s=arc-20160816; b=v0FmzTWzSHypTX6ffrbqWC2FAngq+loEQF33XOj5xtIHhBHI4mup0tpZG17APAzV1L sBtjoQgsg//aec6NkB4IB1ss7jdpjcvE6agodY8YcNgjq+/0NNRd3q8UB0CQYzDITT1k b9cqmlgXA1AOGbRrjb1fxOyNx5VoqrW2oI9nx7Q8Kx84fYyBU8X7lxlzdJ+TsPdF/nKu jisuj8iLv2sI2WtiaaqbWWZQ/SVKfIa95ayKxWZavYaZHSV8uixI358F8mZxFm1D7NOY mLjjnH/h+swI9Bmp8w9QaKPG2NvGBwtvDRQ1xWtdG/cL5Pi0u6mAxLbMrNSaQdH6zegG 0zSA== 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=ozCgkmE9yfYBBzh//L18D1a/C/nd2BgGM4vm1+GAfQo=; b=FZpeMZ/PZfhj1GnuUqS69KJnykdSZeWV8PXM0fZsXkaCJwmFqPB7Tv1IEwcpokJV3Z 4xSop8OriGm9HPO3N0zXA97R0oYM4VFoPGUwQFqDwsPxzKgAc1CoLwOOF1uU0xKNkkyK 0PGfyLAQSL4JNTUj9nWJc1165nVoI/2cYqAFrFInsvk7iyL0zN+tzcL9ESFHVOCVFhGv IJowHcSlARw+uMxm3GptHyLePVA4duJgvnc24BXTU9XULoYE3IBpSLK60GYKlckGUijv NXu+nZeywPykaWxQLlAipUKPIRvj0DF64iWTYGKwahmAvoMOjbbeAPo2QjKorcOX1hNR mm7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hr8dVXBx; 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 m75si39838955pga.432.2018.11.25.14.54.40; Sun, 25 Nov 2018 14:54:40 -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=Hr8dVXBx; 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 S1726032AbeKZJqv (ORCPT + 5 others); Mon, 26 Nov 2018 04:46:51 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35236 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbeKZJqu (ORCPT ); Mon, 26 Nov 2018 04:46:50 -0500 Received: by mail-lf1-f68.google.com with SMTP id e26so12149951lfc.2 for ; Sun, 25 Nov 2018 14:54:37 -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=ozCgkmE9yfYBBzh//L18D1a/C/nd2BgGM4vm1+GAfQo=; b=Hr8dVXBxJmJex5s8fUKIwWmOoCphnCZFv756bqJ7S2Y+xY1ZjMu1pgLxLcGHdklkZ3 utbfTk0U37ol6xkmKEQWUoN/OIj5JhLVHtkdnMvRqWwLXmeQVpkx93PB86qnKOSM9a9L RWRn00IfZ8qEYKPkMDlTkV8RmjNBZzZ1EUJLA= 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=ozCgkmE9yfYBBzh//L18D1a/C/nd2BgGM4vm1+GAfQo=; b=gsPYGC/mwpWNRscobjRGdWlHSi8BgLb+c5fL5pc8qOq53fvUmK2gk4ex9WpFJaJpJT /+ybAs//z03WSz8FTvoGK7X6d02FUmm3GrypOJLdPS4YT0gNQX6IE3o2bdRDkTI0NrtG toaAotE92bfGKt1YsxTPt4aiEbyh4BQ8N/DoHdeyea8ZErtC4Gaw87PPhXbiJc+lk0HT tHhFkXNZlMxVmUZbGquLv5g+wlFPVWySChIF7XlIVnhZMfUc0qNmWsnLLU8bfJoEdjKS MJ7XlvDmZsCa6G7UToAcCq3PudmHLs865t30OZ2uV2CejPfBKtwhLpKcBxB21hpptXhz KCTQ== X-Gm-Message-State: AGRZ1gJvrLbawvUGpm8WI0meeAO9+REWzxQsk8HMVniIGunAPvSYh9J4 kxVvQHNeRPQ7eAS9SZMRXrUsNeRIU3tvig== X-Received: by 2002:a19:6e0b:: with SMTP id j11mr15121695lfc.124.1543186476455; Sun, 25 Nov 2018 14:54:36 -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 c19sm9047235lfg.86.2018.11.25.14.54.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 14:54:35 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Kuninori Morimoto , Laurent Pinchart Subject: [PATCH 02/11 v3] mmc: host: tmio: Use GPIO descriptors Date: Sun, 25 Nov 2018 23:52:08 +0100 Message-Id: <20181125225217.23201-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181125225217.23201-1-linus.walleij@linaro.org> References: <20181125225217.23201-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 as that is what they are, but this will be ignored by the MMC slot GPIO code that uses the *raw accessors and rely on the caps2 flag for any inversion semantics. Cc: Kuninori Morimoto Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- 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 Reviewed-by: Laurent Pinchart 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;