From: Andreas Fenkart <afenkart@gmail.com>
To: linux-mmc@vger.kernel.org
Cc: linux-omap@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
Balaji T K <balajitk@ti.com>,
daniel@zonque.org, Andreas Fenkart <afenkart@gmail.com>
Subject: [PATCH 2/3 resend] omap_hsmmc: separate card_detect/cover detect logic
Date: Sat, 26 Jul 2014 20:34:09 +0200 [thread overview]
Message-ID: <1406399650-671-3-git-send-email-afenkart@gmail.com> (raw)
In-Reply-To: <1406399650-671-1-git-send-email-afenkart@gmail.com>
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 <afenkart@gmail.com>
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;
--
2.0.0
next prev parent reply other threads:[~2014-07-26 18:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 18:34 [PATCH 0/3 resend] omap_hsmmc: reuse mmc/slot-gpio functions Andreas Fenkart
2014-07-26 18:34 ` [PATCH 1/3 resend] omap_hsmmc: reuse mmc/slot-gpio for write protect detection Andreas Fenkart
2014-07-26 18:34 ` Andreas Fenkart [this message]
2014-07-26 18:34 ` [PATCH 3/3 resend] omap_hsmmc: reuse mmc/slot-gpio for card detect instead of open-coded version Andreas Fenkart
-- strict thread matches above, loose matches on Subject: below --
2014-08-08 10:16 [PATCH 0/3 resend] omap_hsmmc: reuse mmc/slot-gpio functions Andreas Fenkart
2014-08-08 10:16 ` [PATCH 2/3 resend] omap_hsmmc: separate card_detect/cover detect logic Andreas Fenkart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406399650-671-3-git-send-email-afenkart@gmail.com \
--to=afenkart@gmail.com \
--cc=balajitk@ti.com \
--cc=daniel@zonque.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).