aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2012-02-03 03:58:48 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-03 06:55:40 -0500
commitfec691e73bf20e1c8e6ecd8e3725e4745bec4e21 (patch)
tree041ec35c18cdfec12b91e938b533e62f078195c4
parent97df81873e9c1391319dd818bc4b6856517e4939 (diff)
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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c30
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c18
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c4
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c4
-rw-r--r--include/sound/sh_fsi.h10
-rw-r--r--sound/soc/sh/fsi.c32
6 files changed, 48 insertions, 50 deletions
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index aab0a349f759..2ac08b29e278 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -745,26 +745,18 @@ fsi_set_rate_end:
745 return ret; 745 return ret;
746} 746}
747 747
748static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
749{
750 int ret;
751
752 if (is_porta)
753 ret = fsi_ak4642_set_rate(dev, rate, enable);
754 else
755 ret = fsi_hdmi_set_rate(dev, rate, enable);
756
757 return ret;
758}
759
760static struct sh_fsi_platform_info fsi_info = { 748static struct sh_fsi_platform_info fsi_info = {
761 .porta_flags = SH_FSI_BRS_INV, 749 .port_a = {
762 750 .flags = SH_FSI_BRS_INV,
763 .portb_flags = SH_FSI_BRS_INV | 751 .set_rate = fsi_ak4642_set_rate,
764 SH_FSI_BRM_INV | 752 },
765 SH_FSI_LRS_INV | 753 .port_b = {
766 SH_FSI_FMT_SPDIF, 754 .flags = SH_FSI_BRS_INV |
767 .set_rate = fsi_set_rate, 755 SH_FSI_BRM_INV |
756 SH_FSI_LRS_INV |
757 SH_FSI_FMT_SPDIF,
758 .set_rate = fsi_hdmi_set_rate,
759 },
768}; 760};
769 761
770static struct resource fsi_resources[] = { 762static struct resource fsi_resources[] = {
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 9b42fbd10f8e..28d6d1f9dad4 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -901,7 +901,7 @@ static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
901 return clk_enable(clk); 901 return clk_enable(clk);
902} 902}
903 903
904static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) 904static int fsi_b_set_rate(struct device *dev, int rate, int enable)
905{ 905{
906 struct clk *fsib_clk; 906 struct clk *fsib_clk;
907 struct clk *fdiv_clk = &sh7372_fsidivb_clk; 907 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 int ackmd_bpfmd; 910 int ackmd_bpfmd;
911 int ret; 911 int ret;
912 912
913 /* FSIA is slave mode. nothing to do here */
914 if (is_porta)
915 return 0;
916
917 /* clock start */ 913 /* clock start */
918 switch (rate) { 914 switch (rate) {
919 case 44100: 915 case 44100:
@@ -957,14 +953,16 @@ fsi_set_rate_end:
957} 953}
958 954
959static struct sh_fsi_platform_info fsi_info = { 955static struct sh_fsi_platform_info fsi_info = {
960 .porta_flags = SH_FSI_BRS_INV, 956 .port_a = {
961 957 .flags = SH_FSI_BRS_INV,
962 .portb_flags = SH_FSI_BRS_INV | 958 },
959 .port_b = {
960 .flags = SH_FSI_BRS_INV |
963 SH_FSI_BRM_INV | 961 SH_FSI_BRM_INV |
964 SH_FSI_LRS_INV | 962 SH_FSI_LRS_INV |
965 SH_FSI_FMT_SPDIF, 963 SH_FSI_FMT_SPDIF,
966 964 .set_rate = fsi_b_set_rate,
967 .set_rate = fsi_set_rate, 965 }
968}; 966};
969 967
970static struct resource fsi_resources[] = { 968static struct resource fsi_resources[] = {
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 033ef2ba621f..1e146fcdb8a0 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -767,7 +767,9 @@ static struct platform_device camera_devices[] = {
767 767
768/* FSI */ 768/* FSI */
769static struct sh_fsi_platform_info fsi_info = { 769static struct sh_fsi_platform_info fsi_info = {
770 .portb_flags = SH_FSI_BRS_INV, 770 .port_b = {
771 .flags = SH_FSI_BRS_INV,
772 },
771}; 773};
772 774
773static struct resource fsi_resources[] = { 775static struct resource fsi_resources[] = {
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 036fe1adaef1..1fc5d47a5687 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -277,7 +277,9 @@ static struct platform_device ceu1_device = {
277/* FSI */ 277/* FSI */
278/* change J20, J21, J22 pin to 1-2 connection to use slave mode */ 278/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
279static struct sh_fsi_platform_info fsi_info = { 279static struct sh_fsi_platform_info fsi_info = {
280 .porta_flags = SH_FSI_BRS_INV, 280 .port_a = {
281 .flags = SH_FSI_BRS_INV,
282 },
281}; 283};
282 284
283static struct resource fsi_resources[] = { 285static struct resource fsi_resources[] = {
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h
index 9b1aacaa82fe..78cd77aff1f4 100644
--- a/include/sound/sh_fsi.h
+++ b/include/sound/sh_fsi.h
@@ -72,10 +72,14 @@
72#define SH_FSI_BPFMD_32 (5 << 4) 72#define SH_FSI_BPFMD_32 (5 << 4)
73#define SH_FSI_BPFMD_16 (6 << 4) 73#define SH_FSI_BPFMD_16 (6 << 4)
74 74
75struct sh_fsi_port_info {
76 unsigned long flags;
77 int (*set_rate)(struct device *dev, int rate, int enable);
78};
79
75struct sh_fsi_platform_info { 80struct sh_fsi_platform_info {
76 unsigned long porta_flags; 81 struct sh_fsi_port_info port_a;
77 unsigned long portb_flags; 82 struct sh_fsi_port_info port_b;
78 int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
79}; 83};
80 84
81/* 85/*
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 1e10184af89a..75d0cda4bad4 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -116,7 +116,7 @@
116 116
117#define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) 117#define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
118 118
119typedef int (*set_rate_func)(struct device *dev, int is_porta, int rate, int enable); 119typedef int (*set_rate_func)(struct device *dev, int rate, int enable);
120 120
121/* 121/*
122 * FSI driver use below type name for variable 122 * FSI driver use below type name for variable
@@ -185,6 +185,7 @@ struct fsi_stream {
185struct fsi_priv { 185struct fsi_priv {
186 void __iomem *base; 186 void __iomem *base;
187 struct fsi_master *master; 187 struct fsi_master *master;
188 struct sh_fsi_port_info *info;
188 189
189 struct fsi_stream playback; 190 struct fsi_stream playback;
190 struct fsi_stream capture; 191 struct fsi_stream capture;
@@ -227,7 +228,6 @@ struct fsi_master {
227 struct fsi_priv fsia; 228 struct fsi_priv fsia;
228 struct fsi_priv fsib; 229 struct fsi_priv fsib;
229 struct fsi_core *core; 230 struct fsi_core *core;
230 struct sh_fsi_platform_info *info;
231 spinlock_t lock; 231 spinlock_t lock;
232}; 232};
233 233
@@ -346,24 +346,20 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream)
346 return fsi_get_priv_frm_dai(fsi_get_dai(substream)); 346 return fsi_get_priv_frm_dai(fsi_get_dai(substream));
347} 347}
348 348
349static set_rate_func fsi_get_info_set_rate(struct fsi_master *master) 349static set_rate_func fsi_get_info_set_rate(struct fsi_priv *fsi)
350{ 350{
351 if (!master->info) 351 if (!fsi->info)
352 return NULL; 352 return NULL;
353 353
354 return master->info->set_rate; 354 return fsi->info->set_rate;
355} 355}
356 356
357static u32 fsi_get_info_flags(struct fsi_priv *fsi) 357static u32 fsi_get_info_flags(struct fsi_priv *fsi)
358{ 358{
359 int is_porta = fsi_is_port_a(fsi); 359 if (!fsi->info)
360 struct fsi_master *master = fsi_get_master(fsi);
361
362 if (!master->info)
363 return 0; 360 return 0;
364 361
365 return is_porta ? master->info->porta_flags : 362 return fsi->info->flags;
366 master->info->portb_flags;
367} 363}
368 364
369static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io) 365static 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 long rate, int enable) 624 long rate, int enable)
629{ 625{
630 struct fsi_master *master = fsi_get_master(fsi); 626 struct fsi_master *master = fsi_get_master(fsi);
631 set_rate_func set_rate = fsi_get_info_set_rate(master); 627 set_rate_func set_rate = fsi_get_info_set_rate(fsi);
632 int fsi_ver = master->core->ver; 628 int fsi_ver = master->core->ver;
633 int ret; 629 int ret;
634 630
635 ret = set_rate(dev, fsi_is_port_a(fsi), rate, enable); 631 if (!set_rate)
632 return 0;
633
634 ret = set_rate(dev, rate, enable);
636 if (ret < 0) /* error */ 635 if (ret < 0) /* error */
637 return ret; 636 return ret;
638 637
@@ -1093,8 +1092,7 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi)
1093static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 1092static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1094{ 1093{
1095 struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); 1094 struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai);
1096 struct fsi_master *master = fsi_get_master(fsi); 1095 set_rate_func set_rate = fsi_get_info_set_rate(fsi);
1097 set_rate_func set_rate = fsi_get_info_set_rate(master);
1098 u32 flags = fsi_get_info_flags(fsi); 1096 u32 flags = fsi_get_info_flags(fsi);
1099 int ret; 1097 int ret;
1100 1098
@@ -1312,6 +1310,7 @@ static int fsi_probe(struct platform_device *pdev)
1312{ 1310{
1313 struct fsi_master *master; 1311 struct fsi_master *master;
1314 const struct platform_device_id *id_entry; 1312 const struct platform_device_id *id_entry;
1313 struct sh_fsi_platform_info *info = pdev->dev.platform_data;
1315 struct resource *res; 1314 struct resource *res;
1316 unsigned int irq; 1315 unsigned int irq;
1317 int ret; 1316 int ret;
@@ -1346,13 +1345,13 @@ static int fsi_probe(struct platform_device *pdev)
1346 1345
1347 /* master setting */ 1346 /* master setting */
1348 master->irq = irq; 1347 master->irq = irq;
1349 master->info = pdev->dev.platform_data;
1350 master->core = (struct fsi_core *)id_entry->driver_data; 1348 master->core = (struct fsi_core *)id_entry->driver_data;
1351 spin_lock_init(&master->lock); 1349 spin_lock_init(&master->lock);
1352 1350
1353 /* FSI A setting */ 1351 /* FSI A setting */
1354 master->fsia.base = master->base; 1352 master->fsia.base = master->base;
1355 master->fsia.master = master; 1353 master->fsia.master = master;
1354 master->fsia.info = &info->port_a;
1356 fsi_handler_init(&master->fsia); 1355 fsi_handler_init(&master->fsia);
1357 ret = fsi_stream_probe(&master->fsia); 1356 ret = fsi_stream_probe(&master->fsia);
1358 if (ret < 0) { 1357 if (ret < 0) {
@@ -1363,6 +1362,7 @@ static int fsi_probe(struct platform_device *pdev)
1363 /* FSI B setting */ 1362 /* FSI B setting */
1364 master->fsib.base = master->base + 0x40; 1363 master->fsib.base = master->base + 0x40;
1365 master->fsib.master = master; 1364 master->fsib.master = master;
1365 master->fsib.info = &info->port_b;
1366 fsi_handler_init(&master->fsib); 1366 fsi_handler_init(&master->fsib);
1367 ret = fsi_stream_probe(&master->fsib); 1367 ret = fsi_stream_probe(&master->fsib);
1368 if (ret < 0) { 1368 if (ret < 0) {