From patchwork Sat Jul 26 18:34:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4627651 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 24447C0338 for ; Sat, 26 Jul 2014 18:34:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 554F92015E for ; Sat, 26 Jul 2014 18:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71D4C20115 for ; Sat, 26 Jul 2014 18:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751991AbaGZSeZ (ORCPT ); Sat, 26 Jul 2014 14:34:25 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:47542 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751819AbaGZSeY (ORCPT ); Sat, 26 Jul 2014 14:34:24 -0400 Received: by mail-wi0-f171.google.com with SMTP id hi2so2485561wib.10 for ; Sat, 26 Jul 2014 11:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LJ74MXFAcCnZCNEX7P7Ao7zJPJxz1SAA1YqIzrXKW/s=; b=eTVAn4I0uHcK4OE7nAOI4zveuBaqfO/h7m1erHJsI+1y+UVFrVyipXxG4wlOcZ5NyK uiZpVVSMJVkkJ9k0X9khIjCK/oeLwxccAt5nVSM32XboovATnRx1+RDysCw4mnB6Cqfk 26/MRC7FN3EcsKSDfeEq9xuLz0L6njwxgN+mdpGKtnI7NJPK4my5JyWjdJbyO9glc45p Plfaca597eCv6RkstsYcGU3jkB/M2PiZQWHVpxvzEEbp0vx5lKRhjtRQH0VJ42f7IDi6 6qKFhFSQ55UiHT2+rV7oZUYpz9nR/1YQ/6BRVfZSXKAtSiHUSJi/kNaVU80+CyNGYdda pxDA== X-Received: by 10.180.12.79 with SMTP id w15mr5329251wib.35.1406399663385; Sat, 26 Jul 2014 11:34:23 -0700 (PDT) Received: from localhost (ip-94-112-0-184.net.upcbroadband.cz. [94.112.0.184]) by mx.google.com with ESMTPSA id eh10sm10169945wic.0.2014.07.26.11.34.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jul 2014 11:34:22 -0700 (PDT) From: Andreas Fenkart To: linux-mmc@vger.kernel.org Cc: linux-omap@vger.kernel.org, Tony Lindgren , Balaji T K , daniel@zonque.org, Andreas Fenkart Subject: [PATCH 2/3 resend] omap_hsmmc: separate card_detect/cover detect logic Date: Sat, 26 Jul 2014 20:34:09 +0200 Message-Id: <1406399650-671-3-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406399650-671-1-git-send-email-afenkart@gmail.com> References: <1406399650-671-1-git-send-email-afenkart@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP assuming cover is the door like thing on cameras that needs to be closed after replacing sd cards. card detect is a gpio connected to sdio slot. in a follow up patch card_detect will be replaced by generic mmc/slot-gpio a git bisect patch Signed-off-by: Andreas Fenkart diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 1c10e6c..1b9f279 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -447,19 +447,32 @@ static int omap_hsmmc_gpio_init(struct mmc_host *mmc, int ret; if (gpio_is_valid(pdata->slots[0].switch_pin)) { - if (pdata->slots[0].cover) + if (pdata->slots[0].cover) { pdata->slots[0].get_cover_state = omap_hsmmc_get_cover_state; - else + pdata->slots[0].cover_detect_irq = + gpio_to_irq(pdata->slots[0].switch_pin); + + ret = gpio_request(pdata->slots[0].switch_pin, + "mmc_cd"); + if (ret) + return ret; + ret = gpio_direction_input(pdata->slots[0].switch_pin); + if (ret) + goto err_free_sp; + } else { pdata->slots[0].card_detect = omap_hsmmc_card_detect; - pdata->slots[0].card_detect_irq = + pdata->slots[0].card_detect_irq = gpio_to_irq(pdata->slots[0].switch_pin); - ret = gpio_request(pdata->slots[0].switch_pin, "mmc_cd"); - if (ret) - return ret; - ret = gpio_direction_input(pdata->slots[0].switch_pin); - if (ret) - goto err_free_sp; + + ret = gpio_request(pdata->slots[0].switch_pin, + "mmc_cd"); + if (ret) + return ret; + ret = gpio_direction_input(pdata->slots[0].switch_pin); + if (ret) + goto err_free_sp; + } } else pdata->slots[0].switch_pin = -EINVAL; @@ -1282,19 +1295,18 @@ static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id) struct omap_mmc_slot_data *slot = &mmc_slot(host); int carddetect; - sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); - - if (slot->card_detect) + if (slot->card_detect) { carddetect = slot->card_detect(host->dev, host->slot_id); - else { + if (carddetect) + mmc_detect_change(host->mmc, (HZ * 200) / 1000); + else + mmc_detect_change(host->mmc, (HZ * 50) / 1000); + } else { + sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); omap_hsmmc_protect_card(host); - carddetect = -ENOSYS; + mmc_detect_change(host->mmc, (HZ * 200) / 1000); } - if (carddetect) - mmc_detect_change(host->mmc, (HZ * 200) / 1000); - else - mmc_detect_change(host->mmc, (HZ * 50) / 1000); return IRQ_HANDLED; } diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h index 7fe0c14..d113005 100644 --- a/include/linux/platform_data/mmc-omap.h +++ b/include/linux/platform_data/mmc-omap.h @@ -136,6 +136,7 @@ struct omap_mmc_platform_data { * 0 - closed * 1 - open */ + int cover_detect_irq; int (*get_cover_state)(struct device *dev, int slot); const char *name;