Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3701184imu; Mon, 28 Jan 2019 09:16:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KSb1V4ieHbb5Ahrb3kQJHQMexxiIl1pz3OHU60rAOawyQilJ+5F2WIZomrrmd3cHudngj X-Received: by 2002:a62:3141:: with SMTP id x62mr22422122pfx.12.1548695791028; Mon, 28 Jan 2019 09:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695790; cv=none; d=google.com; s=arc-20160816; b=kaClC/dWx4Oq2m5hdUFc75MaQYeaRdYtc6dnU7rEu5yfknEt5BVMjmFVmRu2abqaKQ uWB7Ql/g8F2k0fb57Xomnw+KBJn5O/FJGyZU9mYyFq/DVZd3xPNxnTKNPpqTW1np7ReS dwhijQsouUbchstz3F0vyga2YJnuexa5dbbawqomu5iCbF5QajlPHEZotLDRhwhczBdM LcLrg/WNiOnVd6vkNNYL+FvoJ39/3Izcn87EdEA9fvo1X3sr5gtTwMcULAbioJmMBgsM NVvievj6/dPtrFQr7tNCeGseruBX3bN9wNmCQpRfTtt/8wwiwU8GsWi3Jppw5222OKdi VZzQ== 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=Jn/t4WVModk3pbueICUgFSCWvVO9IBWlL3b+Hs+9pcI=; b=gPK2tPaiEy9JuKxqakX1kIpk3waNZEgln+JT+KFNHrBK15RWE4+2b16nBxY/UMi/zs t/rwkdo9q+OxvX9fpVYwi4zhHADBwUSXT8mw37TYlmFJsYaVJH/l84/8IUPJY0mZQabo J6VsMPAz3aZLkkbdgxlGmqvZHJ5/8y17UZFJrVTeMO3/T0l33zpEg0kbBGAUL0nIWGwf quvUOvrVAVLIjqRh2OlakGnuqqDBLbJrY/ZrsxU2qOYEd+Ht6D3/4CbeBCooV+5aUb/V ziuvkpT3E0fJOs1VaCDPJkzKxQ49npfKD6LoT0LweoZduKNMU8kLBfiPyOJnYCPtLGwP kYZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ga4ylq47; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w190si33282030pgd.338.2019.01.28.09.16.15; Mon, 28 Jan 2019 09:16:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=ga4ylq47; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732234AbfA1RP5 (ORCPT + 99 others); Mon, 28 Jan 2019 12:15:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:56508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731634AbfA1QGw (ORCPT ); Mon, 28 Jan 2019 11:06:52 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4838320989; Mon, 28 Jan 2019 16:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691611; bh=yzklis1qP1ua7rltG5gDUCmqKN/vZQ7FGUFiHg/pBV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ga4ylq47lICVz+niQWAA7pX0yv5SVbvihRpcgFUT9gXYxydARMTIPHCZ+WQDDZoiN DBd1YThqLAuj0RED71Bdf+m0/LWletYZQkj3hESnYjki70u0IvSFTHyFevMGpBIs0b MOt5dsmAyFrZwQhhs/zhT3evjWoBqgEf2aLL2igE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Paul Cercueil , linux-mips@linux-mips.org, Ulf Hansson , Sasha Levin , linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 158/258] mmc: jz4740: Get CD/WP GPIOs from descriptors Date: Mon, 28 Jan 2019 10:57:44 -0500 Message-Id: <20190128155924.51521-158-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit 0c901c0566fb4edc2631c3786e5085a037be91f8 ] Modifty the JZ4740 driver to retrieve card detect and write protect GPIO pins from GPIO descriptors instead of hard-coded global numbers. Augment the only board file using this in the process and cut down on passed in platform data. Preserve the code setting the caps2 flags for CD and WP as active low or high since the slot GPIO code currently ignores the gpiolib polarity inversion semantice and uses the raw accessors to read the GPIO lines, but set the right polarity flags in the descriptor table for jz4740. Cc: Paul Cercueil Cc: linux-mips@linux-mips.org Signed-off-by: Linus Walleij Acked-by: Paul Burton Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- .../mips/include/asm/mach-jz4740/jz4740_mmc.h | 2 -- arch/mips/jz4740/board-qi_lb60.c | 12 ++++++++--- drivers/mmc/host/jz4740_mmc.c | 20 +++++++++---------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h index e9cc62cfac99..ff50aeb1a933 100644 --- a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h +++ b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h @@ -4,8 +4,6 @@ struct jz4740_mmc_platform_data { int gpio_power; - int gpio_card_detect; - int gpio_read_only; unsigned card_detect_active_low:1; unsigned read_only_active_low:1; unsigned power_active_low:1; diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c index af0c8ace0141..705593d40d12 100644 --- a/arch/mips/jz4740/board-qi_lb60.c +++ b/arch/mips/jz4740/board-qi_lb60.c @@ -43,7 +43,6 @@ #include "clock.h" /* GPIOs */ -#define QI_LB60_GPIO_SD_CD JZ_GPIO_PORTD(0) #define QI_LB60_GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2) #define QI_LB60_GPIO_KEYOUT(x) (JZ_GPIO_PORTC(10) + (x)) @@ -386,12 +385,18 @@ static struct platform_device qi_lb60_gpio_keys = { }; static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = { - .gpio_card_detect = QI_LB60_GPIO_SD_CD, - .gpio_read_only = -1, .gpio_power = QI_LB60_GPIO_SD_VCC_EN_N, .power_active_low = 1, }; +static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = { + .dev_id = "jz4740-mmc.0", + .table = { + GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* beeper */ static struct pwm_lookup qi_lb60_pwm_lookup[] = { PWM_LOOKUP("jz4740-pwm", 4, "pwm-beeper", NULL, 0, @@ -500,6 +505,7 @@ static int __init qi_lb60_init_platform_devices(void) gpiod_add_lookup_table(&qi_lb60_audio_gpio_table); gpiod_add_lookup_table(&qi_lb60_nand_gpio_table); gpiod_add_lookup_table(&qi_lb60_spigpio_gpio_table); + gpiod_add_lookup_table(&qi_lb60_mmc_gpio_table); spi_register_board_info(qi_lb60_spi_board_info, ARRAY_SIZE(qi_lb60_spi_board_info)); diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index 993386c9ea50..864338e308e2 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -983,17 +983,17 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc, if (!pdata->read_only_active_low) mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - if (gpio_is_valid(pdata->gpio_card_detect)) { - ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0); - if (ret) - return ret; - } + /* + * Get optional card detect and write protect GPIOs, + * only back out on probe deferral. + */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; - if (gpio_is_valid(pdata->gpio_read_only)) { - ret = mmc_gpio_request_ro(mmc, pdata->gpio_read_only); - if (ret) - return ret; - } + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); + if (ret == -EPROBE_DEFER) + return ret; return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power, "MMC read only", true, pdata->power_active_low); -- 2.19.1