mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 08:46:46 +00:00
23d89aa0c2
In order to save power, we only need to request a channel when the communication with the DSP active. For this we export the following functions: - imx_dsp_request_channel, gets a channel with a given index - imx_dsp_free_channel, frees a channel with a given index Notice that we still request channels at probe to support devices that do not have PM callbacks implemented. More explanations about why requesting a channel has an effect on power savings: - requesting an mailbox channel will call mailbox's startup function. - startup function calls pm_runtime_get_sync which increments device usage count and will keep the device active. Specifically, mailbox clock will be always ON when a mailbox channel is requested. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Paul Olaru <paul.olaru@nxp.com> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
77 lines
1.5 KiB
C
77 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Copyright 2019 NXP
|
|
*
|
|
* Header file for the DSP IPC implementation
|
|
*/
|
|
|
|
#ifndef _IMX_DSP_IPC_H
|
|
#define _IMX_DSP_IPC_H
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/types.h>
|
|
#include <linux/mailbox_client.h>
|
|
|
|
#define DSP_MU_CHAN_NUM 4
|
|
|
|
struct imx_dsp_chan {
|
|
struct imx_dsp_ipc *ipc;
|
|
struct mbox_client cl;
|
|
struct mbox_chan *ch;
|
|
char *name;
|
|
int idx;
|
|
};
|
|
|
|
struct imx_dsp_ops {
|
|
void (*handle_reply)(struct imx_dsp_ipc *ipc);
|
|
void (*handle_request)(struct imx_dsp_ipc *ipc);
|
|
};
|
|
|
|
struct imx_dsp_ipc {
|
|
/* Host <-> DSP communication uses 2 txdb and 2 rxdb channels */
|
|
struct imx_dsp_chan chans[DSP_MU_CHAN_NUM];
|
|
struct device *dev;
|
|
struct imx_dsp_ops *ops;
|
|
void *private_data;
|
|
};
|
|
|
|
static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data)
|
|
{
|
|
if (!ipc)
|
|
return;
|
|
|
|
ipc->private_data = data;
|
|
}
|
|
|
|
static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
|
|
{
|
|
if (!ipc)
|
|
return NULL;
|
|
|
|
return ipc->private_data;
|
|
}
|
|
|
|
#if IS_ENABLED(CONFIG_IMX_DSP)
|
|
|
|
int imx_dsp_ring_doorbell(struct imx_dsp_ipc *dsp, unsigned int chan_idx);
|
|
|
|
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx);
|
|
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx);
|
|
|
|
#else
|
|
|
|
static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
|
|
unsigned int chan_idx)
|
|
{
|
|
return -ENOTSUPP;
|
|
}
|
|
|
|
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx)
|
|
{
|
|
return ERR_PTR(-EOPNOTSUPP);
|
|
}
|
|
|
|
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx) { }
|
|
|
|
#endif
|
|
#endif /* _IMX_DSP_IPC_H */
|