From patchwork Fri Aug 8 10:16:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 4695131 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B31439F373 for ; Fri, 8 Aug 2014 10:17:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C900E200DF for ; Fri, 8 Aug 2014 10:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6691201BA for ; Fri, 8 Aug 2014 10:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756541AbaHHKRO (ORCPT ); Fri, 8 Aug 2014 06:17:14 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:43962 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756539AbaHHKRN (ORCPT ); Fri, 8 Aug 2014 06:17:13 -0400 Received: by mail-wi0-f170.google.com with SMTP id f8so2307920wiw.3 for ; Fri, 08 Aug 2014 03:17:11 -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=AFKXpVfI3q1PbYXbtgMVXHD0oC5ED0tJ3dVy9QIRYi33LjwjYAM3YixWEfj5bXN/NY ojHzLi1glwNRgd7WWNRxBvjf8hz2sl+cduZMVmSzLU+ShPnuNpdq9bKbTzGMQgQeQnqe e3FQxKKIiXCl6EIk6gd+hl7DUVyYMfI63EwGfB7L/OdkqWEE3ttDCJtjZzx7678Z+Ps7 UcGC+dr2SCqplTRfC5UThLL1hGeSDr9Vef071SK0TH/qJ7VuWFqfby1dQVkO/FreykGK SA3wBTy7QLswSwjgAGWg+LEBNTLO6CAa0nekTH2C6XG55oWPlLiYVktI2sd5M1+u4x9r bvAg== X-Received: by 10.194.237.194 with SMTP id ve2mr31095926wjc.89.1407493031848; Fri, 08 Aug 2014 03:17:11 -0700 (PDT) Received: from localhost (ip-94-112-2-16.net.upcbroadband.cz. [94.112.2.16]) by mx.google.com with ESMTPSA id h13sm16329299wjs.2.2014.08.08.03.17.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Aug 2014 03:17:11 -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: Fri, 8 Aug 2014 12:16:59 +0200 Message-Id: <1407493020-11566-3-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407493020-11566-1-git-send-email-afenkart@gmail.com> References: <1407493020-11566-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=-7.5 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;