Commit 6a9ebad8 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: sh: fsi: add fsi_is_clk_master function

If FSI port is clock master, it use set_rate function
which is callback from platform,
and it is not necessary to call it if FSI port is clock slave.
Current FSI driver called this callback if platform provide it.
This patch modify it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarSimon Horman <simon@horms.net>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 5debd6c1
...@@ -146,10 +146,12 @@ struct fsi_priv { ...@@ -146,10 +146,12 @@ struct fsi_priv {
void __iomem *base; void __iomem *base;
struct fsi_master *master; struct fsi_master *master;
int chan_num;
struct fsi_stream playback; struct fsi_stream playback;
struct fsi_stream capture; struct fsi_stream capture;
int chan_num:16;
int clk_master:1;
long rate; long rate;
}; };
...@@ -244,6 +246,11 @@ static struct fsi_master *fsi_get_master(struct fsi_priv *fsi) ...@@ -244,6 +246,11 @@ static struct fsi_master *fsi_get_master(struct fsi_priv *fsi)
return fsi->master; return fsi->master;
} }
static int fsi_is_clk_master(struct fsi_priv *fsi)
{
return fsi->clk_master;
}
static int fsi_is_port_a(struct fsi_priv *fsi) static int fsi_is_port_a(struct fsi_priv *fsi)
{ {
return fsi->master->base == fsi->base; return fsi->master->base == fsi->base;
...@@ -793,14 +800,15 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream, ...@@ -793,14 +800,15 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream,
struct fsi_priv *fsi = fsi_get_priv(substream); struct fsi_priv *fsi = fsi_get_priv(substream);
int is_play = fsi_is_play(substream); int is_play = fsi_is_play(substream);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
set_rate_func set_rate; set_rate_func set_rate = fsi_get_info_set_rate(master);
fsi_irq_disable(fsi, is_play); fsi_irq_disable(fsi, is_play);
fsi_clk_ctrl(fsi, 0);
set_rate = fsi_get_info_set_rate(master); if (fsi_is_clk_master(fsi)) {
if (set_rate && fsi->rate) fsi_clk_ctrl(fsi, 0);
set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0); set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0);
}
fsi->rate = 0; fsi->rate = 0;
pm_runtime_put_sync(dai->dev); pm_runtime_put_sync(dai->dev);
...@@ -876,6 +884,8 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi) ...@@ -876,6 +884,8 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi)
static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai);
struct fsi_master *master = fsi_get_master(fsi);
set_rate_func set_rate = fsi_get_info_set_rate(master);
u32 flags = fsi_get_info_flags(fsi); u32 flags = fsi_get_info_flags(fsi);
u32 data = 0; u32 data = 0;
int ret; int ret;
...@@ -886,6 +896,7 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -886,6 +896,7 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
data = DIMD | DOMD; data = DIMD | DOMD;
fsi->clk_master = 1;
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
break; break;
...@@ -893,6 +904,13 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -893,6 +904,13 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
ret = -EINVAL; ret = -EINVAL;
goto set_fmt_exit; goto set_fmt_exit;
} }
if (fsi_is_clk_master(fsi) && !set_rate) {
dev_err(dai->dev, "platform doesn't have set_rate\n");
ret = -EINVAL;
goto set_fmt_exit;
}
fsi_reg_mask_set(fsi, CKG1, (DIMD | DOMD), data); fsi_reg_mask_set(fsi, CKG1, (DIMD | DOMD), data);
/* set format */ /* set format */
...@@ -919,13 +937,12 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -919,13 +937,12 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream,
{ {
struct fsi_priv *fsi = fsi_get_priv(substream); struct fsi_priv *fsi = fsi_get_priv(substream);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
set_rate_func set_rate; set_rate_func set_rate = fsi_get_info_set_rate(master);
int fsi_ver = master->core->ver; int fsi_ver = master->core->ver;
long rate = params_rate(params); long rate = params_rate(params);
int ret; int ret;
set_rate = fsi_get_info_set_rate(master); if (!fsi_is_clk_master(fsi))
if (!set_rate)
return 0; return 0;
ret = set_rate(dai->dev, fsi_is_port_a(fsi), rate, 1); ret = set_rate(dai->dev, fsi_is_port_a(fsi), rate, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment