Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c0c2335 authored by Asutosh Das's avatar Asutosh Das Committed by Subhash Jadavani
Browse files

mmc: core: add wakeup functionality to sdio cards



This patch initializes wakeup source if the detected card
is a sdio card and enables the wakeup capability.

Platform drivers would have to invoke:
 * pm_wakeup_event on this card device to signal a wakeup
 * corresponding pm_relax have to be invoked

Change-Id: Ic8d5c98073e8ed3f676eb42fc0ce1f13a11cb40f
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
[merez@codeaurora.org: fix conflicts due to different PM in 3.14]
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent 358ac29e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -361,6 +361,12 @@ int mmc_add_card(struct mmc_card *card)

	card->dev.of_node = mmc_of_find_child_device(card->host, 0);

	if (mmc_card_sdio(card)) {
		ret = device_init_wakeup(&card->dev, true);
		if (ret)
			pr_err("%s: %s: failed to init wakeup: %d\n",
			       mmc_hostname(card->host), __func__, ret);
	}
	ret = device_add(&card->dev);
	if (ret)
		return ret;
+18 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ static int sdio_irq_thread(void *_host)
	struct sched_param param = { .sched_priority = 1 };
	unsigned long period, idle_period;
	int ret;
	bool ws;

	sched_setscheduler(current, SCHED_FIFO, &param);

@@ -137,6 +138,17 @@ static int sdio_irq_thread(void *_host)
		ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort);
		if (ret)
			break;
		ws = false;
		/*
		 * prevent suspend if it has started when scheduled;
		 * 100 msec (approx. value) should be enough for the system to
		 * resume and attend to the card's request
		 */
		if ((host->dev_status == DEV_SUSPENDING) ||
		    (host->dev_status == DEV_SUSPENDED)) {
			pm_wakeup_event(&host->card->dev, 100);
			ws = true;
		}
		ret = process_sdio_pending_irqs(host);
		host->sdio_irq_pending = false;
		mmc_release_host(host);
@@ -173,6 +185,12 @@ static int sdio_irq_thread(void *_host)
			host->ops->enable_sdio_irq(host, 1);
			mmc_host_clk_release(host);
		}
		/*
		 * function drivers would have processed the event from card
		 * unless suspended, hence release wake source
		 */
		if (ws && (host->dev_status == DEV_RESUMED))
			pm_relax(&host->card->dev);
		if (!kthread_should_stop())
			schedule_timeout(period);
		set_current_state(TASK_RUNNING);
+7 −0
Original line number Diff line number Diff line
@@ -218,6 +218,12 @@ struct mmc_supply {
	struct regulator *vqmmc;	/* Optional Vccq supply */
};

enum dev_state {
	DEV_SUSPENDING = 1,
	DEV_SUSPENDED,
	DEV_RESUMED,
};

struct mmc_host {
	struct device		*parent;
	struct device		class_dev;
@@ -447,6 +453,7 @@ struct mmc_host {
		struct delayed_work work;
		enum mmc_load	state;
	} clk_scaling;
	enum dev_state dev_status;
	unsigned long		private[0] ____cacheline_aligned;
};