1
0
Fork 0

MLK-24263-3 firmware: imx-dsp: Export functions to request/free channels

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 yet.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Daniel Baluta 2020-06-10 20:02:31 +03:00
parent 02e7ef1deb
commit 798bd66a9c
2 changed files with 35 additions and 0 deletions

View File

@ -60,6 +60,31 @@ static void imx_dsp_handle_rx(struct mbox_client *c, void *msg)
}
}
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *dsp_ipc, int idx)
{
struct imx_dsp_chan *dsp_chan;
if (idx >= DSP_MU_CHAN_NUM)
return ERR_PTR(-EINVAL);
dsp_chan = &dsp_ipc->chans[idx];
dsp_chan->ch = mbox_request_channel_byname(&dsp_chan->cl, dsp_chan->name);
return dsp_chan->ch;
}
EXPORT_SYMBOL(imx_dsp_request_channel);
void imx_dsp_free_channel(struct imx_dsp_ipc *dsp_ipc, int idx)
{
struct imx_dsp_chan *dsp_chan;
if (idx >= DSP_MU_CHAN_NUM)
return;
dsp_chan = &dsp_ipc->chans[idx];
mbox_free_channel(dsp_chan->ch);
}
EXPORT_SYMBOL(imx_dsp_free_channel);
static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)
{
struct device *dev = dsp_ipc->dev;

View File

@ -55,6 +55,9 @@ static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
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,
@ -63,5 +66,12 @@ static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
return -ENOTSUPP;
}
struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx)
{
return ERR_PTR(-ENOTSUPP);
}
void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx) { }
#endif
#endif /* _IMX_DSP_IPC_H */