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

Commit c888bbe4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "sdm429w: Register ADSP UP/DOWN events callback"

parents eac58634 30f1c28e
Loading
Loading
Loading
Loading
+47 −2
Original line number Diff line number Diff line
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -44,11 +44,13 @@
#define BGDAEMON_LDO03_NPM_VTG 10000

#define MPPS_DOWN_EVENT_TO_BG_TIMEOUT 3000
#define ADSP_DOWN_EVENT_TO_BG_TIMEOUT 3000
#define SLEEP_FOR_SPI_BUS 2000

enum {
	SSR_DOMAIN_BG,
	SSR_DOMAIN_MODEM,
	SSR_DOMAIN_ADSP,
	SSR_DOMAIN_MAX,
};

@@ -83,6 +85,7 @@ struct service_info {
static char *ssr_domains[] = {
	"bg-wear",
	"modem",
	"adsp",
};

static struct bgdaemon_priv *dev;
@@ -98,6 +101,7 @@ static bool twm_exit;
static	bool                     bg_app_running;
static  struct   bgcom_open_config_type   config_type;
static DECLARE_COMPLETION(bg_modem_down_wait);
static DECLARE_COMPLETION(bg_adsp_down_wait);

/**
 * send_uevent(): send events to user space
@@ -334,6 +338,12 @@ static int modem_down2_bg(void)
	return 0;
}

static int adsp_down2_bg(void)
{
	complete(&bg_adsp_down_wait);
	return 0;
}

static long bg_com_ioctl(struct file *filp,
		unsigned int ui_bgcom_cmd, unsigned long arg)
{
@@ -378,6 +388,8 @@ static long bg_com_ioctl(struct file *filp,
	case BG_MODEM_DOWN2_BG_DONE:
		ret = modem_down2_bg();
		break;
	case BG_ADSP_DOWN2_BG_DONE:
		ret = adsp_down2_bg();
	case BG_TWM_EXIT:
		twm_exit = true;
		ret = 0;
@@ -584,7 +596,29 @@ static int ssr_modem_cb(struct notifier_block *this,
	}
	return NOTIFY_DONE;
}
static int ssr_adsp_cb(struct notifier_block *this,
		unsigned long opcode, void *data)
{
	struct bg_event adspe;
	int ret;

	switch (opcode) {
	case SUBSYS_BEFORE_SHUTDOWN:
		adspe.e_type = ADSP_BEFORE_POWER_DOWN;
		reinit_completion(&bg_adsp_down_wait);
		send_uevent(&adspe);
		ret = wait_for_completion_timeout(&bg_adsp_down_wait,
			msecs_to_jiffies(ADSP_DOWN_EVENT_TO_BG_TIMEOUT));
		if (!ret)
			pr_err("Time out on adsp down event\n");
		break;
	case SUBSYS_AFTER_POWERUP:
		adspe.e_type = ADSP_AFTER_POWER_UP;
		send_uevent(&adspe);
		break;
	}
	return NOTIFY_DONE;
}
bool is_twm_exit(void)
{
	if (twm_exit) {
@@ -610,12 +644,17 @@ static struct notifier_block ssr_modem_nb = {
	.priority = 0,
};

static struct notifier_block ssr_adsp_nb = {
	.notifier_call = ssr_adsp_cb,
	.priority = 0,
};

static struct notifier_block ssr_bg_nb = {
	.notifier_call = ssr_bg_cb,
	.priority = 0,
};

static struct service_info service_data[2] = {
static struct service_info service_data[3] = {
	{
		.name = "SSR_BG",
		.domain_id = SSR_DOMAIN_BG,
@@ -628,6 +667,12 @@ static struct service_info service_data[2] = {
		.nb = &ssr_modem_nb,
		.handle = NULL,
	},
	{
		.name = "SSR_ADSP",
		.domain_id = SSR_DOMAIN_ADSP,
		.nb = &ssr_adsp_nb,
		.handle = NULL,
	},
};

/**
+7 −1
Original line number Diff line number Diff line
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -21,6 +21,7 @@
#define BGCOM_MODEM_DOWN2_BG  7
#define BGCOM_TWM_EXIT  8
#define BGCOM_BG_APP_RUNNING 9
#define BGCOM_ADSP_DOWN2_BG  10
#define EXCHANGE_CODE  'V'

struct bg_ui_data {
@@ -36,6 +37,8 @@ enum bg_event_type {
	BG_AFTER_POWER_UP,
	MODEM_BEFORE_POWER_DOWN,
	MODEM_AFTER_POWER_UP,
	ADSP_BEFORE_POWER_DOWN,
	ADSP_AFTER_POWER_UP,
};

#define REG_READ \
@@ -68,4 +71,7 @@ enum bg_event_type {
#define BG_MODEM_DOWN2_BG_DONE \
	_IOWR(EXCHANGE_CODE, BGCOM_MODEM_DOWN2_BG, \
	struct bg_ui_data)
#define BG_ADSP_DOWN2_BG_DONE \
	_IOWR(EXCHANGE_CODE, BGCOM_ADSP_DOWN2_BG, \
	struct bg_ui_data)
#endif