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

Commit 277cf3d5 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare
Browse files

ASoC: wcd_cpe_core: Add support for CPE restart



The CPE hardware block on the codec may become unresponsive due to
unknown reasons. In such situation, the codec hardware has functionality
to interrupt the driver so that driver can take necessary steps to
reinitialize the CPE hardware block. Add support for detecting CPE
hardware state and reinitialize the CPE block so that further use
cases are not affected.

Change-Id: I8a3447925216f0d6c3bd177162800e3e3c8df879
Signed-off-by: default avatarVenkat Sudhir <vsudhir@codeaurora.org>
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent d3af110c
Loading
Loading
Loading
Loading
+626 −92

File changed.

Preview size limit exceeded, changes collapsed.

+61 −1
Original line number Diff line number Diff line
@@ -14,6 +14,19 @@

#define WCD_CPE_LAB_MAX_LATENCY 250
#define WCD_CPE_MAD_SLIM_CHANNEL 140

/* Indicates CPE block is ready for image re-download */
#define WCD_CPE_BLK_READY  (1 << 0)
/* Indicates the underlying bus is ready */
#define WCD_CPE_BUS_READY (1 << 1)

/*
 * only when the underlying bus and CPE block both are ready,
 * the state will be ready to download
 */
#define WCD_CPE_READY_TO_DLOAD	\
	(WCD_CPE_BLK_READY | WCD_CPE_BUS_READY)

struct wcd_cpe_cdc_cb {
	/* codec provided callback to enable RCO */
	int (*cdc_clk_en) (struct snd_soc_codec *, bool);
@@ -24,6 +37,24 @@ struct wcd_cpe_cdc_cb {
	int (*slimtx_lab_en)(struct snd_soc_codec *codec, int event);
};

enum wcd_cpe_ssr_state_event {
	/* Indicates that CPE is currently active */
	WCD_CPE_ACTIVE = 0,
	/* Event from underlying bus notifying bus is down */
	WCD_CPE_BUS_DOWN_EVENT,
	/* Event from CPE block, notifying CPE is down */
	WCD_CPE_SSR_EVENT,
	/* Event from underlying bus notifying bus is up */
	WCD_CPE_BUS_UP_EVENT,
};

struct wcd_cpe_ssr_entry {
	int offline;
	u32 offline_change;
	wait_queue_head_t offline_poll_wait;
	struct snd_info_entry *entry;
};

struct wcd_cpe_core {
	/* handle to cpe services */
	void *cpe_handle;
@@ -54,6 +85,33 @@ struct wcd_cpe_core {

	/* callbacks for codec specific implementation */
	struct wcd_cpe_cdc_cb cpe_cdc_cb;

	/* work to handle CPE SSR*/
	struct work_struct ssr_work;

	/* PM handle for suspend mode during SSR */
	struct pm_qos_request pm_qos_req;

	/* completion event indicating CPE OFFLINE */
	struct completion offline_compl;

	/* entry into snd card procfs indicating cpe status */
	struct wcd_cpe_ssr_entry ssr_entry;

	/*
	 * completion event to signal CPE is
	 * ready for image re-download
	 */
	struct completion ready_compl;

	/* maintains the status for cpe ssr */
	u8 ready_status;

	/* Indicate SSR type */
	enum wcd_cpe_ssr_state_event ssr_type;

	/* mutex to protect cpe ssr status variables */
	struct mutex ssr_lock;
};

struct wcd_cpe_params {
@@ -67,5 +125,7 @@ struct wcd_cpe_params {
	u32 cdc_id;
};

int wcd_cpe_ssr_event(void *core_handle,
		      enum wcd_cpe_ssr_state_event event);
struct wcd_cpe_core *wcd_cpe_init_and_boot(const char *,
struct snd_soc_codec *, struct wcd_cpe_params *params);