From patchwork Fri Jul 18 07:22:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4581091 Return-Path: X-Original-To: patchwork-linux-omap@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 7667FC0514 for ; Fri, 18 Jul 2014 07:22:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5673200FF for ; Fri, 18 Jul 2014 07:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B93D920176 for ; Fri, 18 Jul 2014 07:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753116AbaGRHWT (ORCPT ); Fri, 18 Jul 2014 03:22:19 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:42167 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752750AbaGRHWS (ORCPT ); Fri, 18 Jul 2014 03:22:18 -0400 Received: by mail-wi0-f178.google.com with SMTP id hi2so332253wib.5 for ; Fri, 18 Jul 2014 00:22:17 -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=bHxeb8D7ZQ6nyB+MAGPy+pY3lMo4qS5Q6AqT24rnEBeP8Ad+JOfNCjKlfGykaM8lgC oyJ+AIgf/sDXZJHHNbN2j3yHqYtXx9dHHt5BVcF960aP2GfXObms7aG6Vly1hBhMJdUJ qDKtpNL9ZIfKB1zzznG8LTKqUhJ7JQhdm4B1AnterJk3EdhAxBNvkedK0oQqzL8XtgRG e1UtiV0VWhWZ3cPQ1WidlQtXM0E9DKWQdvuHcJdI9kwKop05N+Q4JSl0xYuKReQzVrgd 9AUXK5pSHWV1NtCEZRNY599ytSTdjkixM3MWKLOiS5NclP8totKQpBIWFYvmxucEefBJ eDmQ== X-Received: by 10.194.6.134 with SMTP id b6mr3867315wja.64.1405668137021; Fri, 18 Jul 2014 00:22:17 -0700 (PDT) Received: from localhost (ip-89-176-190-177.net.upcbroadband.cz. [89.176.190.177]) by mx.google.com with ESMTPSA id h3sm11988603wjz.48.2014.07.18.00.22.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 00:22:16 -0700 (PDT) From: Andreas Fenkart To: Balaji T K Cc: linux-omap@vger.kernel.org, linux-mmc@vger.kernel.org, Tony Lindgren , ulf.hansson@linaro.org, daniel@zonque.org, Andreas Fenkart Subject: [PATCH 2/3] omap_hsmmc: separate card_detect/cover detect logic Date: Fri, 18 Jul 2014 09:22:02 +0200 Message-Id: <1405668123-17073-3-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1405668123-17073-1-git-send-email-afenkart@gmail.com> References: <1405668123-17073-1-git-send-email-afenkart@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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=unavailable 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;