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

Commit 131cada2 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: slatecom: uevent for slate dsp and bt state"

parents 118838bc 400073c2
Loading
Loading
Loading
Loading
+88 −1
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@
#define RESULT_SUCCESS 0
#define RESULT_FAILURE -1

#define SLATECOM_INTF_N_FILES 2
static char btss_state[10] = "offline";
static char dspss_state[10] = "offline";

/* tzapp command list.*/
enum slate_tz_commands {
	SLATEPIL_RAMDUMP,
@@ -119,10 +123,46 @@ static int device_open;
static  void                     *handle;
static	bool                     twm_exit;
static	bool                     slate_app_running;
static	bool                     slate_dsp_error;
static	bool                     slate_bt_error;
static  struct   slatecom_open_config_type   config_type;
static DECLARE_COMPLETION(slate_modem_down_wait);
static DECLARE_COMPLETION(slate_adsp_down_wait);

static ssize_t slate_bt_state_sysfs_read
			(struct class *class, struct class_attribute *attr, char *buf)
{
	pr_debug("In %s\n", __func__);
	return scnprintf(buf, "%s", btss_state);
}

static ssize_t slate_dsp_state_sysfs_read
			(struct class *class, struct class_attribute *attr, char *buf)
{
	pr_debug("In %s\n", __func__);
	return	scnprintf(buf, "%s", dspss_state);
}

struct class_attribute slatecom_attr[] = {
	{
		.attr = {
			.name = "slate_bt_state",
			.mode = 0644
		},
		.show	= slate_bt_state_sysfs_read,
	},
	{
		.attr = {
			.name = "slate_dsp_state",
			.mode = 0644
		},
		.show	= slate_dsp_state_sysfs_read,
	},
};
struct class slatecom_intf_class = {
	.name = "slatecom"
};

/**
 * send_uevent(): send events to user space
 * pce : ssr event handle value
@@ -506,6 +546,38 @@ bool is_slate_running(void)
}
EXPORT_SYMBOL(is_slate_running);

void set_slate_dsp_state(bool status)
{
	struct slate_event statee;

	slate_dsp_error = status;
	if (status) {
		statee.e_type = SLATE_DSP_ERROR;
		strlcpy(dspss_state, "error");
	} else {
		statee.e_type = SLATE_DSP_READY;
		strlcpy(dspss_state, "ready");
	}
	send_uevent(&statee);
}
EXPORT_SYMBOL(set_slate_dsp_state);

void set_slate_bt_state(bool status)
{
	struct slate_event statee;

	slate_bt_error = status;
	if (status) {
		statee.e_type = SLATE_BT_ERROR;
		strlcpy(btss_state, "error");
	} else {
		statee.e_type = SLATE_BT_READY;
		strlcpy(btss_state, "ready");
	}
	send_uevent(&statee);
}
EXPORT_SYMBOL(set_slate_bt_state);

static struct notifier_block ssr_modem_nb = {
	.notifier_call = ssr_modem_cb,
	.priority = 0,
@@ -572,7 +644,7 @@ static void ssr_register(void)

static int __init init_slate_com_dev(void)
{
	int ret;
	int ret, i;

	ret = alloc_chrdev_region(&slate_dev, 0, 1, SLATECOM);
	if (ret  < 0) {
@@ -604,6 +676,17 @@ static int __init init_slate_com_dev(void)
		return PTR_ERR(dev_ret);
	}

	ret = class_register(&slatecom_intf_class);
	if (ret < 0) {
		pr_err("Failed to register slatecom_intf_class rc=%d\n", ret);
		return ret;
	}

	for (i = 0; i < SLATECOM_INTF_N_FILES; i++) {
		if (class_create_file(&slatecom_intf_class, &slatecom_attr[i]))
			pr_err("%s: failed to create slate-bt/dsp entry\n", __func__);
	}

	if (platform_driver_register(&slate_daemon_driver))
		pr_err("%s: failed to register slate-daemon register\n", __func__);

@@ -614,8 +697,12 @@ static int __init init_slate_com_dev(void)

static void __exit exit_slate_com_dev(void)
{
	int i;
	device_destroy(slate_class, slate_dev);
	class_destroy(slate_class);
	for (i = 0; i < SLATECOM_INTF_N_FILES; i++)
		class_remove_file(&slatecom_intf_class, &slatecom_attr[i]);
	class_unregister(&slatecom_intf_class);
	cdev_del(&slate_cdev);
	unregister_chrdev_region(slate_dev, 1);
	platform_driver_unregister(&slate_daemon_driver);
+12 −0
Original line number Diff line number Diff line
@@ -25,5 +25,17 @@ bool is_twm_exit(void);
 */
bool is_slate_running(void);

/*
 * set_slate_dsp_state()
 * Set slate dsp state
 */
void set_slate_dsp_state(bool status);

/*
 * set_slate_bt_state()
 * Set slate bt state
 */
void set_slate_bt_state(bool status);

#endif /* SLATECOM_INTERFACE_H */
+17 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/dma-mapping.h>
#include <linux/pm_runtime.h>
#include "slatecom.h"
#include "slatecom_interface.h"

#define SLATE_SPI_WORD_SIZE (0x04)
#define SLATE_SPI_READ_LEN (0x04)
@@ -423,6 +424,22 @@ static void send_back_notification(uint32_t slav_status_reg,
			send_event(SLATECOM_EVENT_AHB_READY,
				&event_data);
		}

		if (slav_status_reg & BIT(26)) {
			pr_debug("Slate DSP DOWN\n", __func__);
			set_slate_dsp_state(false);
		} else if (slav_status_reg & BIT(30)) {
			pr_debug("Slate DSP UP\n", __func__);
			set_slate_dsp_state(true);
		}

		if (slav_status_reg & BIT(25)) {
			pr_debug("Slate BT DOWN\n", __func__);
			set_slate_bt_state(false);
		} else if (slav_status_reg & BIT(30)) {
			pr_debug("Slate BT UP\n", __func__);
			set_slate_bt_state(true);
		}
	}

	if (master_fifo_used > 0) {
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ enum slate_event_type {
	ADSP_BEFORE_POWER_DOWN,
	ADSP_AFTER_POWER_UP,
	TWM_SLATE_AFTER_POWER_UP,
	SLATE_DSP_ERROR,
	SLATE_DSP_READY,
	SLATE_BT_ERROR,
	SLATE_BT_READY,
};

#define REG_READ \