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

Commit 0d1d05ce authored by Shaikh Shadul's avatar Shaikh Shadul
Browse files

soc: qcom: smp2p_sleepstate: Add inbound notification



smp2p sleep state is extended to handle interrupts from
remote processor to decide whether to acquire wake lock
or not during wakeup sensor sample processing.

For wake up sensors, the driver is expected to a hold a
wake lock with a timeout of 200 ms while reporting this
event as per spec.

Change-Id: Icc342be71b22400b54fe5021c8cecdd0015640e7
Signed-off-by: default avatarShaikh Shadul <sshadu@codeaurora.org>
parent 1e465bc9
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -4,9 +4,16 @@ Required properties:
-compatible : should be one of the following:
-compatible : should be one of the following:
- "qcom,smp2p-sleepstate"
- "qcom,smp2p-sleepstate"
-qcom,smem-states : the relevant outgoing smp2p entry
-qcom,smem-states : the relevant outgoing smp2p entry
- interrupt-parent: specifies the phandle to the parent interrupt controller
  this one is cascaded from
- interrupts: specifies the interrupt number, the irq line to be used
- interrupt-names: Interrupt name string, must be "smp2p-sleepstate-in"


Example:
Example:
qcom,smp2p_sleepstate {
qcom,smp2p_sleepstate {
	compatible = "qcom,smp2p-sleepstate";
	compatible = "qcom,smp2p-sleepstate";
	qcom,smem-states = <&sleepstate_smp2p_out 0>;
	qcom,smem-states = <&sleepstate_smp2p_out 0>;
	interrupt-parent = <&sleepstate_smp2p_in>;
	interrupts = <0 0>;
	interrupt-names = "smp2p-sleepstate-in";
};
};
+6 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,12 @@
			qcom,entry-name = "sleepstate";
			qcom,entry-name = "sleepstate";
			#qcom,smem-state-cells = <1>;
			#qcom,smem-state-cells = <1>;
		};
		};

		sleepstate_smp2p_in: qcom,sleepstate-in {
			qcom,entry-name = "sleepstate_see";
			interrupt-controller;
			#interrupt-cells = <2>;
		};
	};
	};


	qcom,smp2p-cdsp@1799000c {
	qcom,smp2p-cdsp@1799000c {
+3 −0
Original line number Original line Diff line number Diff line
@@ -2896,6 +2896,9 @@
	qcom,smp2p_sleepstate {
	qcom,smp2p_sleepstate {
		compatible = "qcom,smp2p-sleepstate";
		compatible = "qcom,smp2p-sleepstate";
		qcom,smem-states = <&sleepstate_smp2p_out 0>;
		qcom,smem-states = <&sleepstate_smp2p_out 0>;
		interrupt-parent = <&sleepstate_smp2p_in>;
		interrupts = <0 0>;
		interrupt-names = "smp2p-sleepstate-in";
	};
	};


	system_pm {
	system_pm {
+32 −0
Original line number Original line Diff line number Diff line
@@ -13,10 +13,16 @@
#include <linux/suspend.h>
#include <linux/suspend.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/soc/qcom/smem_state.h>
#include <linux/soc/qcom/smem_state.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
#include <linux/of_irq.h>
#include <linux/of.h>
#include <linux/pm_wakeup.h>


#define PROC_AWAKE_ID 12 /* 12th bit */
#define PROC_AWAKE_ID 12 /* 12th bit */
#define AWAKE_BIT BIT(PROC_AWAKE_ID)
#define AWAKE_BIT BIT(PROC_AWAKE_ID)
static struct qcom_smem_state *state;
static struct qcom_smem_state *state;
struct wakeup_source notify_ws;


/**
/**
 * sleepstate_pm_notifier() - PM notifier callback function.
 * sleepstate_pm_notifier() - PM notifier callback function.
@@ -48,9 +54,18 @@ static struct notifier_block sleepstate_pm_nb = {
	.priority = INT_MAX,
	.priority = INT_MAX,
};
};


static irqreturn_t smp2p_sleepstate_handler(int irq, void *ctxt)
{
	__pm_wakeup_event(&notify_ws, 200);
	return IRQ_HANDLED;
}

static int smp2p_sleepstate_probe(struct platform_device *pdev)
static int smp2p_sleepstate_probe(struct platform_device *pdev)
{
{
	int ret;
	int ret;
	int irq = -1;
	struct device *dev = &pdev->dev;
	struct device_node *node = dev->of_node;


	state = qcom_smem_state_get(&pdev->dev, 0, &ret);
	state = qcom_smem_state_get(&pdev->dev, 0, &ret);
	if (IS_ERR(state))
	if (IS_ERR(state))
@@ -61,6 +76,23 @@ static int smp2p_sleepstate_probe(struct platform_device *pdev)
	if (ret)
	if (ret)
		pr_err("%s: power state notif error %d\n", __func__, ret);
		pr_err("%s: power state notif error %d\n", __func__, ret);


	wakeup_source_init(&notify_ws, "smp2p-sleepstate");

	irq = of_irq_get_byname(node, "smp2p-sleepstate-in");
	if (irq <= 0) {
		pr_err("failed for irq getbyname for smp2p_sleep_state\n");
		wakeup_source_trash(&notify_ws);
		return -EPROBE_DEFER;
	}
	pr_info("got smp2p-sleepstate-in irq %d\n", irq);
	ret = devm_request_threaded_irq(dev, irq, NULL,
		(irq_handler_t)smp2p_sleepstate_handler,
		IRQF_TRIGGER_RISING, "smp2p_sleepstate", dev);
	if (ret) {
		pr_err("fail to register smp2p threaded_irq=%d\n", irq);
		wakeup_source_trash(&notify_ws);
		return ret;
	}
	return 0;
	return 0;
}
}