From patchwork Mon Nov 21 16:15:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 9439749 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 800E2600BA for ; Mon, 21 Nov 2016 16:18:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 519D928B34 for ; Mon, 21 Nov 2016 16:18:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44D9028B55; Mon, 21 Nov 2016 16:18:50 +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=ham 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 C9AFF28B34 for ; Mon, 21 Nov 2016 16:18:49 +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 1c8rHX-00073I-LH; Mon, 21 Nov 2016 16:17:23 +0000 Received: from mail-wj0-x22d.google.com ([2a00:1450:400c:c01::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c8rGM-0006Wo-84 for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2016 16:16:11 +0000 Received: by mail-wj0-x22d.google.com with SMTP id mp19so28353835wjc.1 for ; Mon, 21 Nov 2016 08:15:49 -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=BmFF28lS8i1TwjOlkInNwhIMbQJpgB4CwnT75bpwmJE=; b=X45wDbZ18IZEv4RTm/mnGTIkhqZB6PrekQSsFXH4QRYMFWVrcv08heweasKf3dSvPd DEodgKKqh5GsSkGg5jW3lOdZqlIKDcT+dk7mEINyHRjI02qrbHNF1a+55EyKjPUxSPEj xr9bXNB2duPZnrSEMh1sUu+EC1qXJGnlmhSHdwu2DdHD4QbQF1DmuCrXtlyBvrKIbfUJ WFBtWWlXoJbmT1+vVW760l/SUHOmRgA+tnAvG0H+trcsuKdj7XX5Bt1bCiRjdL4aexLC XslaAX0BFH5WZFFvjHxClULShIGdDwHWR4OYwcZ4sNi0765Xj2JcaLhGjIH8xKFgXjIL mVAg== 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=BmFF28lS8i1TwjOlkInNwhIMbQJpgB4CwnT75bpwmJE=; b=e2W96MfF9yR+K4aemtlNxGg7NgSdMh9WK+9+RPTkgdMF24oMJXsUfEldA+BOpH/TvI AJiXKtOGXVHHnkcGGSIxN3TmpyvXkhpD7d15kzrlf/8DDDL2HB4+vQ+sThVYeF4RYEh3 HV/SKSOFqx1UpDDh8YOr0UvtzDrbeDLGYWr3a/YMCDHe8zCPpQ5WCabSrbvmnru/YnZy BvMccAkqbt2g2jZ/2pTMRb+hethQFe2EbKGaz3gq1fDjTUhQoONwOoR6sH2sCAF+7O3p XQUk0PoZ51GR+vaWMEnILs/qAcrGhZ9i56TPL6cvMz1j1V9IQTppIbWGuMKBQkVqHpTP /tiA== X-Gm-Message-State: AKaTC03+naOvuTs6OKk4uuqas87Sn47BkYqg+twHF2lITxkBN6EXYWDGgSmf6AjeHM8y2OAe X-Received: by 10.194.122.101 with SMTP id lr5mr9845764wjb.210.1479744948554; Mon, 21 Nov 2016 08:15:48 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l187sm20365294wml.6.2016.11.21.08.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Nov 2016 08:15:48 -0800 (PST) From: Axel Haslam To: nsekhar@ti.com, khilman@kernel.org Subject: [PATCH 3/3] ARM: davinci: hawk: use gpio descriptor for card detect Date: Mon, 21 Nov 2016 17:15:41 +0100 Message-Id: <20161121161541.27048-4-ahaslam@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161121161541.27048-1-ahaslam@baylibre.com> References: <20161121161541.27048-1-ahaslam@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161121_081610_534319_B0C8A1E7 X-CRM114-Status: GOOD ( 15.06 ) 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 with the mmc core with API's designed for this purpose. This has the advantage that an irq will be registered, and polling is no longer needed. Also, platform callbacks can be removed. Signed-off-by: Axel Haslam --- arch/arm/mach-davinci/board-omapl138-hawk.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index ddc312d..8e4f2102 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -25,7 +26,6 @@ #include #define HAWKBOARD_PHY_ID "davinci_mdio-0:07" -#define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(4, 0) #define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4) #define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13) @@ -122,13 +122,16 @@ static const short hawk_mmcsd0_pins[] = { -1 }; -static int da850_hawk_mmc_get_cd(int index) -{ - return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN); -} +static struct gpiod_lookup_table mmc_gpios_table = { + .dev_id = "da830-mmc.0", + .table = { + /* gpio4_0: chip 2 contains gpio range 64-95 */ + GPIO_LOOKUP("davinci_gpio.2", 0, "cd", + GPIO_ACTIVE_LOW), + }, +}; static struct davinci_mmc_config da850_mmc_config = { - .get_cd = da850_hawk_mmc_get_cd, .wires = 4, .max_freq = 50000000, .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, @@ -144,13 +147,7 @@ static __init void omapl138_hawk_mmc_init(void) return; } - ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN, - GPIOF_DIR_IN, "MMC CD"); - if (ret < 0) { - pr_warn("%s: can not open GPIO %d\n", - __func__, DA850_HAWK_MMCSD_CD_PIN); - return; - } + gpiod_add_lookup_table(&mmc_gpios_table); ret = da8xx_register_mmcsd0(&da850_mmc_config); if (ret) { @@ -161,7 +158,7 @@ static __init void omapl138_hawk_mmc_init(void) return; mmc_setup_mmcsd_fail: - gpio_free(DA850_HAWK_MMCSD_CD_PIN); + gpiod_remove_lookup_table(&mmc_gpios_table); } static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);