From patchwork Thu Nov 24 15:04:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 9445711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1104F6071C for ; Thu, 24 Nov 2016 15:07:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E8827FA9 for ; Thu, 24 Nov 2016 15:07:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEFB127FB3; Thu, 24 Nov 2016 15:07:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 912AF27FA9 for ; Thu, 24 Nov 2016 15:07:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c9vbI-0001lS-AY; Thu, 24 Nov 2016 15:06:12 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c9vaV-0008LA-PU for linux-arm-kernel@lists.infradead.org; Thu, 24 Nov 2016 15:05:26 +0000 Received: by mail-wm0-x233.google.com with SMTP id c184so21908048wmd.0 for ; Thu, 24 Nov 2016 07:05:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CobwZdguVoXhjLdOp2c0G+tnBD19n5mjbeprbWNvSq4=; b=u536oeGWFWL1mC2I4VK2bbwJc2vCrDhSoMfir5PYK5JdpoM1ChTSmzZpxrlZNa3b9g ODmDPxBFXNehD6WQJ+M1TFBPlyfyxVL+Gu0hVSYQE1swc+jbgKQbzXc9IlTZySppp5+i P3bE3b7UL1p/JyxyIc/F4ait81MU0o8i0+emCh63cbOO7XdlFPOA5TN3TFWaxsMvpLSP VuChpscQ7iwypghwRBk7QStYPt2oqRi0rXrLpS8pAc9LK/fhwG4U1o3kT/aCN7dqKuaT 7Bea5EavrwfUOJGy+rMtG20FMux8BZ13l+9JQNFaX1R+ei2QqtRE5F/csdBvIyb2v0NG BiTA== 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:in-reply-to :references; bh=CobwZdguVoXhjLdOp2c0G+tnBD19n5mjbeprbWNvSq4=; b=ZBb5GN37mjO6EzS3vlNLMpwhFLEkXw3SlX2Dan/eOnZWx81La16xXVuABp6g+28PP2 //0bVphQQoExSqCmogS4SduOPRAYmolXrdmHF8n1DhHeXyG5m/vGn8AvVWoxMnBJA5Sd TWcyp+PDN+Fkhg4LRr69SLbfmZuKEAockRI3YtFOPQJ0r84iYQSHlu6zpCqpFMwnX5Yg +Q2M+ORWDjFoNh/19Ju68mA0gYvHvwBaWllkdA+0rLpKEwJ+QCtuT1Phl/jWZY/SeflM wV1Id74pFyR2zQ/C1EYTxLC7RwoGr8b1c2K1yODUDtaZkCTbpoowI+04zWT4ScM7ucuZ VbzA== X-Gm-Message-State: AKaTC02+s/QyEbPc8CBiX20ug52U6YeKEK+TDaGso7CMox57ImZzA8c2jI5jkJmx5KVMpiUS X-Received: by 10.28.230.72 with SMTP id d69mr2856071wmh.119.1479999901810; Thu, 24 Nov 2016 07:05:01 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l67sm8539251wmf.0.2016.11.24.07.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 07:05:01 -0800 (PST) From: Axel Haslam To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com Subject: [PATCH v2 2/3] ARM: davinci: da850-evm: use gpio descriptor for mmc pins Date: Thu, 24 Nov 2016 16:04:53 +0100 Message-Id: <20161124150454.23899-3-ahaslam@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161124150454.23899-1-ahaslam@baylibre.com> References: <20161124150454.23899-1-ahaslam@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161124_070524_109351_A15700CC X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Axel Haslam , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the mmc driver is polling the gpio to know if the card was removed. By using a gpio descriptor instead of the platform callbacks, the driver will be able to register the gpio using the mmc core API's designed for this purpose. This has the advantage that an irq will be registered, and polling is no longer needed. Also, a dependency on platform callbacks is removed for this board. Signed-off-by: Axel Haslam --- arch/arm/mach-davinci/board-da850-evm.c | 35 ++++++++++----------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index ec5cb10..1a31ac3 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -56,9 +57,6 @@ #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8) #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15) -#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0) -#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1) - #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6) static struct mtd_partition da850evm_spiflash_part[] = { @@ -776,19 +774,16 @@ static const short da850_evm_mcasp_pins[] __initconst = { -1 }; -static int da850_evm_mmc_get_ro(int index) -{ - return gpio_get_value(DA850_MMCSD_WP_PIN); -} - -static int da850_evm_mmc_get_cd(int index) -{ - return !gpio_get_value(DA850_MMCSD_CD_PIN); -} +static struct gpiod_lookup_table mmc_gpios_table = { + .dev_id = "da830-mmc.0", + .table = { + /* gpio chip 2 contains gpio range 64-95 */ + GPIO_LOOKUP("davinci_gpio.2", 0, "cd", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("davinci_gpio.2", 1, "wp", GPIO_ACTIVE_LOW), + }, +}; static struct davinci_mmc_config da850_mmc_config = { - .get_ro = da850_evm_mmc_get_ro, - .get_cd = da850_evm_mmc_get_cd, .wires = 4, .max_freq = 50000000, .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, @@ -1383,17 +1378,7 @@ static __init void da850_evm_init(void) pr_warn("%s: MMCSD0 mux setup failed: %d\n", __func__, ret); - ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n"); - if (ret) - pr_warn("%s: can not open GPIO %d\n", - __func__, DA850_MMCSD_CD_PIN); - gpio_direction_input(DA850_MMCSD_CD_PIN); - - ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n"); - if (ret) - pr_warn("%s: can not open GPIO %d\n", - __func__, DA850_MMCSD_WP_PIN); - gpio_direction_input(DA850_MMCSD_WP_PIN); + gpiod_add_lookup_table(&mmc_gpios_table); ret = da8xx_register_mmcsd0(&da850_mmc_config); if (ret)