提交 fec691e7 编写于 作者: K Kuninori Morimoto 提交者: Mark Brown

ASoC: fsi: PortA/B information was controlled by sh_fsi_port_info

Current FSI got each PortA/B parameter by porta_flags/portb_flags from platform.
And .set_rate function was shared for PortA/B.
This structure was not readable and not flexible.
This patch adds sh_fsi_port_info, and its own settings was added on each platform.
it is preparation for DMAEngine support
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 97df8187
...@@ -745,26 +745,18 @@ static int fsi_hdmi_set_rate(struct device *dev, int rate, int enable) ...@@ -745,26 +745,18 @@ static int fsi_hdmi_set_rate(struct device *dev, int rate, int enable)
return ret; return ret;
} }
static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
{
int ret;
if (is_porta)
ret = fsi_ak4642_set_rate(dev, rate, enable);
else
ret = fsi_hdmi_set_rate(dev, rate, enable);
return ret;
}
static struct sh_fsi_platform_info fsi_info = { static struct sh_fsi_platform_info fsi_info = {
.porta_flags = SH_FSI_BRS_INV, .port_a = {
.flags = SH_FSI_BRS_INV,
.portb_flags = SH_FSI_BRS_INV | .set_rate = fsi_ak4642_set_rate,
SH_FSI_BRM_INV | },
SH_FSI_LRS_INV | .port_b = {
SH_FSI_FMT_SPDIF, .flags = SH_FSI_BRS_INV |
.set_rate = fsi_set_rate, SH_FSI_BRM_INV |
SH_FSI_LRS_INV |
SH_FSI_FMT_SPDIF,
.set_rate = fsi_hdmi_set_rate,
},
}; };
static struct resource fsi_resources[] = { static struct resource fsi_resources[] = {
......
...@@ -901,7 +901,7 @@ static int __fsi_set_round_rate(struct clk *clk, long rate, int enable) ...@@ -901,7 +901,7 @@ static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
return clk_enable(clk); return clk_enable(clk);
} }
static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) static int fsi_b_set_rate(struct device *dev, int rate, int enable)
{ {
struct clk *fsib_clk; struct clk *fsib_clk;
struct clk *fdiv_clk = &sh7372_fsidivb_clk; struct clk *fdiv_clk = &sh7372_fsidivb_clk;
...@@ -910,10 +910,6 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) ...@@ -910,10 +910,6 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
int ackmd_bpfmd; int ackmd_bpfmd;
int ret; int ret;
/* FSIA is slave mode. nothing to do here */
if (is_porta)
return 0;
/* clock start */ /* clock start */
switch (rate) { switch (rate) {
case 44100: case 44100:
...@@ -957,14 +953,16 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) ...@@ -957,14 +953,16 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
} }
static struct sh_fsi_platform_info fsi_info = { static struct sh_fsi_platform_info fsi_info = {
.porta_flags = SH_FSI_BRS_INV, .port_a = {
.flags = SH_FSI_BRS_INV,
.portb_flags = SH_FSI_BRS_INV | },
.port_b = {
.flags = SH_FSI_BRS_INV |
SH_FSI_BRM_INV | SH_FSI_BRM_INV |
SH_FSI_LRS_INV | SH_FSI_LRS_INV |
SH_FSI_FMT_SPDIF, SH_FSI_FMT_SPDIF,
.set_rate = fsi_b_set_rate,
.set_rate = fsi_set_rate, }
}; };
static struct resource fsi_resources[] = { static struct resource fsi_resources[] = {
......
...@@ -767,7 +767,9 @@ static struct platform_device camera_devices[] = { ...@@ -767,7 +767,9 @@ static struct platform_device camera_devices[] = {
/* FSI */ /* FSI */
static struct sh_fsi_platform_info fsi_info = { static struct sh_fsi_platform_info fsi_info = {
.portb_flags = SH_FSI_BRS_INV, .port_b = {
.flags = SH_FSI_BRS_INV,
},
}; };
static struct resource fsi_resources[] = { static struct resource fsi_resources[] = {
......
...@@ -277,7 +277,9 @@ static struct platform_device ceu1_device = { ...@@ -277,7 +277,9 @@ static struct platform_device ceu1_device = {
/* FSI */ /* FSI */
/* change J20, J21, J22 pin to 1-2 connection to use slave mode */ /* change J20, J21, J22 pin to 1-2 connection to use slave mode */
static struct sh_fsi_platform_info fsi_info = { static struct sh_fsi_platform_info fsi_info = {
.porta_flags = SH_FSI_BRS_INV, .port_a = {
.flags = SH_FSI_BRS_INV,
},
}; };
static struct resource fsi_resources[] = { static struct resource fsi_resources[] = {
......
...@@ -72,10 +72,14 @@ ...@@ -72,10 +72,14 @@
#define SH_FSI_BPFMD_32 (5 << 4) #define SH_FSI_BPFMD_32 (5 << 4)
#define SH_FSI_BPFMD_16 (6 << 4) #define SH_FSI_BPFMD_16 (6 << 4)
struct sh_fsi_port_info {
unsigned long flags;
int (*set_rate)(struct device *dev, int rate, int enable);
};
struct sh_fsi_platform_info { struct sh_fsi_platform_info {
unsigned long porta_flags; struct sh_fsi_port_info port_a;
unsigned long portb_flags; struct sh_fsi_port_info port_b;
int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
}; };
/* /*
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
#define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) #define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
typedef int (*set_rate_func)(struct device *dev, int is_porta, int rate, int enable); typedef int (*set_rate_func)(struct device *dev, int rate, int enable);
/* /*
* FSI driver use below type name for variable * FSI driver use below type name for variable
...@@ -185,6 +185,7 @@ struct fsi_stream { ...@@ -185,6 +185,7 @@ struct fsi_stream {
struct fsi_priv { struct fsi_priv {
void __iomem *base; void __iomem *base;
struct fsi_master *master; struct fsi_master *master;
struct sh_fsi_port_info *info;
struct fsi_stream playback; struct fsi_stream playback;
struct fsi_stream capture; struct fsi_stream capture;
...@@ -227,7 +228,6 @@ struct fsi_master { ...@@ -227,7 +228,6 @@ struct fsi_master {
struct fsi_priv fsia; struct fsi_priv fsia;
struct fsi_priv fsib; struct fsi_priv fsib;
struct fsi_core *core; struct fsi_core *core;
struct sh_fsi_platform_info *info;
spinlock_t lock; spinlock_t lock;
}; };
...@@ -346,24 +346,20 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream) ...@@ -346,24 +346,20 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream)
return fsi_get_priv_frm_dai(fsi_get_dai(substream)); return fsi_get_priv_frm_dai(fsi_get_dai(substream));
} }
static set_rate_func fsi_get_info_set_rate(struct fsi_master *master) static set_rate_func fsi_get_info_set_rate(struct fsi_priv *fsi)
{ {
if (!master->info) if (!fsi->info)
return NULL; return NULL;
return master->info->set_rate; return fsi->info->set_rate;
} }
static u32 fsi_get_info_flags(struct fsi_priv *fsi) static u32 fsi_get_info_flags(struct fsi_priv *fsi)
{ {
int is_porta = fsi_is_port_a(fsi); if (!fsi->info)
struct fsi_master *master = fsi_get_master(fsi);
if (!master->info)
return 0; return 0;
return is_porta ? master->info->porta_flags : return fsi->info->flags;
master->info->portb_flags;
} }
static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io) static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io)
...@@ -628,11 +624,14 @@ static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi, ...@@ -628,11 +624,14 @@ static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi,
long rate, int enable) long rate, int enable)
{ {
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
set_rate_func set_rate = fsi_get_info_set_rate(master); set_rate_func set_rate = fsi_get_info_set_rate(fsi);
int fsi_ver = master->core->ver; int fsi_ver = master->core->ver;
int ret; int ret;
ret = set_rate(dev, fsi_is_port_a(fsi), rate, enable); if (!set_rate)
return 0;
ret = set_rate(dev, rate, enable);
if (ret < 0) /* error */ if (ret < 0) /* error */
return ret; return ret;
...@@ -1093,8 +1092,7 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi) ...@@ -1093,8 +1092,7 @@ 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(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);
int ret; int ret;
...@@ -1312,6 +1310,7 @@ static int fsi_probe(struct platform_device *pdev) ...@@ -1312,6 +1310,7 @@ static int fsi_probe(struct platform_device *pdev)
{ {
struct fsi_master *master; struct fsi_master *master;
const struct platform_device_id *id_entry; const struct platform_device_id *id_entry;
struct sh_fsi_platform_info *info = pdev->dev.platform_data;
struct resource *res; struct resource *res;
unsigned int irq; unsigned int irq;
int ret; int ret;
...@@ -1346,13 +1345,13 @@ static int fsi_probe(struct platform_device *pdev) ...@@ -1346,13 +1345,13 @@ static int fsi_probe(struct platform_device *pdev)
/* master setting */ /* master setting */
master->irq = irq; master->irq = irq;
master->info = pdev->dev.platform_data;
master->core = (struct fsi_core *)id_entry->driver_data; master->core = (struct fsi_core *)id_entry->driver_data;
spin_lock_init(&master->lock); spin_lock_init(&master->lock);
/* FSI A setting */ /* FSI A setting */
master->fsia.base = master->base; master->fsia.base = master->base;
master->fsia.master = master; master->fsia.master = master;
master->fsia.info = &info->port_a;
fsi_handler_init(&master->fsia); fsi_handler_init(&master->fsia);
ret = fsi_stream_probe(&master->fsia); ret = fsi_stream_probe(&master->fsia);
if (ret < 0) { if (ret < 0) {
...@@ -1363,6 +1362,7 @@ static int fsi_probe(struct platform_device *pdev) ...@@ -1363,6 +1362,7 @@ static int fsi_probe(struct platform_device *pdev)
/* FSI B setting */ /* FSI B setting */
master->fsib.base = master->base + 0x40; master->fsib.base = master->base + 0x40;
master->fsib.master = master; master->fsib.master = master;
master->fsib.info = &info->port_b;
fsi_handler_init(&master->fsib); fsi_handler_init(&master->fsib);
ret = fsi_stream_probe(&master->fsib); ret = fsi_stream_probe(&master->fsib);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册