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

Commit 686f86b7 authored by Ananda Kishore's avatar Ananda Kishore Committed by Gerrit - the friendly Code Review server
Browse files

sensors: ssc: Add restart interface for SLPI



Sensor Low Power Island (SLPI) is a DSP core integrated
into SDM/MSM to run sensor drivers and algorithms. User
space sensor daemon requires to restart the SLPI during
some of the use cases.
Add sysfs interface to do SLPI sub system restart from
user space sensor daemon.

Change-Id: Id5c16986aae4ac8a1fc1474fb542d36c70173a95
Signed-off-by: default avatarAnanda Kishore <kananda@codeaurora.org>
parent fb7d0fd0
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

#define IMAGE_LOAD_CMD 1
#define IMAGE_UNLOAD_CMD 0
#define SSR_RESET_CMD 1
#define CLASS_NAME	"ssc"
#define DRV_NAME	"sensors"
#define DRV_VERSION	"2.00"
@@ -53,6 +54,10 @@ static ssize_t slpi_boot_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf, size_t count);

static ssize_t slpi_ssr_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf, size_t count);

struct slpi_loader_private {
	void *pil_h;
	struct kobject *boot_slpi_obj;
@@ -62,8 +67,12 @@ struct slpi_loader_private {
static struct kobj_attribute slpi_boot_attribute =
	__ATTR(boot, 0220, NULL, slpi_boot_store);

static struct kobj_attribute slpi_ssr_attribute =
	__ATTR(ssr, 0220, NULL, slpi_ssr_store);

static struct attribute *attrs[] = {
	&slpi_boot_attribute.attr,
	&slpi_ssr_attribute.attr,
	NULL,
};

@@ -138,6 +147,44 @@ static void slpi_loader_unload(struct platform_device *pdev)
	}
}

static ssize_t slpi_ssr_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf,
	size_t count)
{
	int ssr_cmd = 0;
	struct subsys_device *sns_dev = NULL;
	struct platform_device *pdev = slpi_private;
	struct slpi_loader_private *priv = NULL;

	pr_debug("%s: going to call slpi_ssr\n", __func__);

	if (kstrtoint(buf, 10, &ssr_cmd) < 0)
		return -EINVAL;

	if (ssr_cmd != SSR_RESET_CMD)
		return -EINVAL;

	priv = platform_get_drvdata(pdev);
	if (!priv)
		return -EINVAL;

	sns_dev = (struct subsys_device *)priv->pil_h;
	if (!sns_dev)
		return -EINVAL;

	dev_err(&pdev->dev, "Something went wrong with SLPI, restarting\n");

	/* subsystem_restart_dev has worker queue to handle */
	if (subsystem_restart_dev(sns_dev) != 0) {
		dev_err(&pdev->dev, "subsystem_restart_dev failed\n");
		return -EINVAL;
	}

	dev_dbg(&pdev->dev, "SLPI restarted\n");
	return count;
}

static ssize_t slpi_boot_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf,