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

Commit 88025775 authored by Chris Lew's avatar Chris Lew
Browse files

soc: qcom: smp2p_sleepstate: Update smp2p APIs



Update the smp2p_sleepstate driver to use the new smp2p APIs which
expose an outgoing smp2p entry using qcom_smem_state. Update the
devicetree documentation and compatible for the new interface instead
of the gpio interface.

In addition, remove the ws calls to ipc_router since ipc router is
replaced with qrtr.

Change-Id: I45a186ed881c72a1cb994ae149e44eba017580d0
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 84932aaa
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -2,12 +2,11 @@ Qualcomm Technologies, Inc. SMSM Point-to-Point (SMP2P) Sleepstate driver

Required properties:
-compatible : should be one of the following:
- "qcom,smp2pgpio_sleepstate_3_out" - for sensor processor on remote pid 3
- "qcom,smp2pgpio-sleepstate-out" - for other cases
-gpios : the relevant gpio pins of the entry.
- "qcom,smp2p-sleepstate"
-qcom,smem-states : the relevant outgoing smp2p entry

Example:
	qcom,smp2pgpio-sleepstate-3-out {
		compatible = "qcom,smp2pgpio_sleepstate_3_out";
		gpios = <&smp2pgpio_sleepstate_3_out 0 0>;
qcom,smp2p_sleepstate {
	compatible = "qcom,smp2p-sleepstate";
	qcom,smem-states = <&sleepstate_smp2p_out 0>;
};
+17 −33
Original line number Diff line number Diff line
@@ -9,18 +9,14 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/suspend.h>
#include <linux/delay.h>
#include <linux/ipc_router.h>
#include "smp2p_private.h"
#include <linux/platform_device.h>
#include <linux/soc/qcom/smem_state.h>

#define SET_DELAY (2 * HZ)
#define PROC_AWAKE_ID 12 /* 12th bit */
static int slst_gpio_base_id;
#define AWAKE_BIT BIT(PROC_AWAKE_ID)
static struct qcom_smem_state *state;

/**
 * sleepstate_pm_notifier() - PM notifier callback function.
@@ -36,16 +32,14 @@ static int sleepstate_pm_notifier(struct notifier_block *nb,
{
	switch (event) {
	case PM_SUSPEND_PREPARE:
		gpio_set_value(slst_gpio_base_id + PROC_AWAKE_ID, 0);
		usleep_range(10000, 10500); /* Tuned based on SMP2P latencies */
		msm_ipc_router_set_ws_allowed(true);
		qcom_smem_state_update_bits(state, AWAKE_BIT, 0);
		break;

	case PM_POST_SUSPEND:
		gpio_set_value(slst_gpio_base_id + PROC_AWAKE_ID, 1);
		msm_ipc_router_set_ws_allowed(false);
		qcom_smem_state_update_bits(state, AWAKE_BIT, AWAKE_BIT);
		break;
	}

	return NOTIFY_DONE;
}

@@ -57,30 +51,21 @@ static struct notifier_block sleepstate_pm_nb = {
static int smp2p_sleepstate_probe(struct platform_device *pdev)
{
	int ret;
	struct device_node *node = pdev->dev.of_node;

	slst_gpio_base_id = of_get_gpio(node, 0);
	if (slst_gpio_base_id == -EPROBE_DEFER) {
		return slst_gpio_base_id;
	} else if (slst_gpio_base_id < 0) {
		SMP2P_ERR("%s: Error to get gpio %d\n",
				__func__, slst_gpio_base_id);
		return slst_gpio_base_id;
	}


	gpio_set_value(slst_gpio_base_id + PROC_AWAKE_ID, 1);
	state = qcom_smem_state_get(&pdev->dev, 0, &ret);
	if (IS_ERR(state))
		return PTR_ERR(state);
	qcom_smem_state_update_bits(state, AWAKE_BIT, AWAKE_BIT);

	ret = register_pm_notifier(&sleepstate_pm_nb);
	if (ret)
		SMP2P_ERR("%s: power state notif error %d\n", __func__, ret);
		pr_err("%s: power state notif error %d\n", __func__, ret);

	return 0;
}

static const struct of_device_id msm_smp2p_slst_match_table[] = {
	{.compatible = "qcom,smp2pgpio_sleepstate_3_out"},
	{.compatible = "qcom,smp2pgpio-sleepstate-out"},
static const struct of_device_id smp2p_slst_match_table[] = {
	{.compatible = "qcom,smp2p-sleepstate"},
	{},
};

@@ -89,7 +74,7 @@ static struct platform_driver smp2p_sleepstate_driver = {
	.driver = {
		.name = "smp2p_sleepstate",
		.owner = THIS_MODULE,
		.of_match_table = msm_smp2p_slst_match_table,
		.of_match_table = smp2p_slst_match_table,
	},
};

@@ -99,8 +84,7 @@ static int __init smp2p_sleepstate_init(void)

	ret = platform_driver_register(&smp2p_sleepstate_driver);
	if (ret) {
		SMP2P_ERR("%s: smp2p_sleepstate_driver register failed %d\n",
			 __func__, ret);
		pr_err("%s: register failed %d\n", __func__, ret);
		return ret;
	}