Lines Matching defs:i2s

8 #include <dt-bindings/sound/samsung-i2s.h>
27 #include "i2s.h"
28 #include "i2s-regs.h"
131 static inline bool is_secondary(struct i2s_dai *i2s)
133 return i2s->drv->id == SAMSUNG_I2S_ID_SECONDARY;
137 static inline bool tx_active(struct i2s_dai *i2s)
141 if (!i2s)
144 active = readl(i2s->priv->addr + I2SCON);
146 if (is_secondary(i2s))
155 static inline struct i2s_dai *get_other_dai(struct i2s_dai *i2s)
157 return i2s->pri_dai ? : i2s->sec_dai;
161 static inline bool other_tx_active(struct i2s_dai *i2s)
163 struct i2s_dai *other = get_other_dai(i2s);
169 static inline bool any_tx_active(struct i2s_dai *i2s)
171 return tx_active(i2s) || other_tx_active(i2s);
175 static inline bool rx_active(struct i2s_dai *i2s)
179 if (!i2s)
182 active = readl(i2s->priv->addr + I2SCON) & CON_RXDMA_ACTIVE;
188 static inline bool other_rx_active(struct i2s_dai *i2s)
190 struct i2s_dai *other = get_other_dai(i2s);
196 static inline bool any_rx_active(struct i2s_dai *i2s)
198 return rx_active(i2s) || other_rx_active(i2s);
202 static inline bool other_active(struct i2s_dai *i2s)
204 return other_rx_active(i2s) || other_tx_active(i2s);
208 static inline bool this_active(struct i2s_dai *i2s)
210 return tx_active(i2s) || rx_active(i2s);
214 static inline bool any_active(struct i2s_dai *i2s)
216 return this_active(i2s) || other_active(i2s);
226 static inline bool is_opened(struct i2s_dai *i2s)
228 if (i2s && (i2s->mode & DAI_OPENED))
234 static inline bool is_manager(struct i2s_dai *i2s)
236 if (is_opened(i2s) && (i2s->mode & DAI_MANAGER))
243 static inline unsigned get_rfs(struct i2s_dai *i2s)
245 struct samsung_i2s_priv *priv = i2s->priv;
264 static inline void set_rfs(struct i2s_dai *i2s, unsigned rfs)
266 struct samsung_i2s_priv *priv = i2s->priv;
303 static inline unsigned get_bfs(struct i2s_dai *i2s)
305 struct samsung_i2s_priv *priv = i2s->priv;
325 static inline void set_bfs(struct i2s_dai *i2s, unsigned bfs)
327 struct samsung_i2s_priv *priv = i2s->priv;
334 dev_err(&i2s->pdev->dev, "Unsupported BCLK divider\n");
369 dev_err(&i2s->pdev->dev, "Wrong BCLK Divider!\n");
377 static inline int get_blc(struct i2s_dai *i2s)
379 int blc = readl(i2s->priv->addr + I2SMOD);
391 static void i2s_txctrl(struct i2s_dai *i2s, int on)
393 struct samsung_i2s_priv *priv = i2s->priv;
403 if (is_secondary(i2s)) {
411 if (any_rx_active(i2s))
416 if (is_secondary(i2s)) {
424 if (other_tx_active(i2s)) {
431 if (any_rx_active(i2s))
442 static void i2s_rxctrl(struct i2s_dai *i2s, int on)
444 struct samsung_i2s_priv *priv = i2s->priv;
454 if (any_tx_active(i2s))
462 if (any_tx_active(i2s))
473 static inline void i2s_fifo(struct i2s_dai *i2s, u32 flush)
478 if (!i2s)
481 if (is_secondary(i2s))
482 fic = i2s->priv->addr + I2SFICS;
484 fic = i2s->priv->addr + I2SFIC;
501 struct i2s_dai *i2s = to_info(dai);
502 struct i2s_dai *other = get_other_dai(i2s);
528 (any_active(i2s) &&
533 dev_err(&i2s->pdev->dev,
542 i2s->rfs = rfs;
555 if (!any_active(i2s)) {
569 priv->op_clk = clk_get(&i2s->pdev->dev,
572 priv->op_clk = clk_get(&i2s->pdev->dev,
591 dev_err(&i2s->pdev->dev,
604 dev_err(&i2s->pdev->dev, "We don't serve that!\n");
626 struct i2s_dai *i2s = to_info(dai);
652 dev_err(&i2s->pdev->dev, "Format not supported\n");
670 dev_err(&i2s->pdev->dev, "Polarity not supported\n");
689 dev_err(&i2s->pdev->dev, "master/slave format not supported\n");
700 if (any_active(i2s) &&
704 dev_err(&i2s->pdev->dev,
723 struct i2s_dai *i2s = to_info(dai);
730 if (!is_secondary(i2s))
742 i2s->dma_playback.addr_width = 4;
744 i2s->dma_capture.addr_width = 4;
748 i2s->dma_playback.addr_width = 2;
750 i2s->dma_capture.addr_width = 2;
754 dev_err(&i2s->pdev->dev, "%d channels not supported\n",
759 if (is_secondary(i2s))
764 if (is_manager(i2s))
769 if (is_secondary(i2s))
773 if (is_manager(i2s))
777 if (is_secondary(i2s))
781 if (is_manager(i2s))
785 if (is_secondary(i2s))
789 if (is_manager(i2s))
793 dev_err(&i2s->pdev->dev, "Format(%d) not supported\n",
804 snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
806 i2s->frmclk = params_rate(params);
820 struct i2s_dai *i2s = to_info(dai);
821 struct i2s_dai *other = get_other_dai(i2s);
828 i2s->mode |= DAI_OPENED;
831 i2s->mode &= ~DAI_MANAGER;
833 i2s->mode |= DAI_MANAGER;
835 if (!any_active(i2s) && (priv->quirks & QUIRK_NEED_RSTCLR))
836 writel(CON_RSTCLR, i2s->priv->addr + I2SCON);
847 struct i2s_dai *i2s = to_info(dai);
848 struct i2s_dai *other = get_other_dai(i2s);
853 i2s->mode &= ~DAI_OPENED;
854 i2s->mode &= ~DAI_MANAGER;
860 i2s->rfs = 0;
861 i2s->bfs = 0;
868 static int config_setup(struct i2s_dai *i2s)
870 struct samsung_i2s_priv *priv = i2s->priv;
871 struct i2s_dai *other = get_other_dai(i2s);
875 blc = get_blc(i2s);
877 bfs = i2s->bfs;
886 rfs = i2s->rfs;
892 dev_err(&i2s->pdev->dev,
905 if (any_active(i2s) && (get_rfs(i2s) != rfs || get_bfs(i2s) != bfs)) {
906 dev_err(&i2s->pdev->dev,
911 set_bfs(i2s, bfs);
912 set_rfs(i2s, rfs);
919 psr = priv->rclk_srcrate / i2s->frmclk / rfs;
921 dev_dbg(&i2s->pdev->dev,
935 struct i2s_dai *i2s = to_info(asoc_rtd_to_cpu(rtd, 0));
945 if (config_setup(i2s)) {
951 i2s_rxctrl(i2s, 1);
953 i2s_txctrl(i2s, 1);
963 i2s_rxctrl(i2s, 0);
964 i2s_fifo(i2s, FIC_RXFLUSH);
966 i2s_txctrl(i2s, 0);
967 i2s_fifo(i2s, FIC_TXFLUSH);
981 struct i2s_dai *i2s = to_info(dai);
982 struct i2s_dai *other = get_other_dai(i2s);
987 if ((any_active(i2s) && div && (get_bfs(i2s) != div))
990 dev_err(&i2s->pdev->dev,
994 i2s->bfs = div;
998 dev_err(&i2s->pdev->dev,
1010 struct i2s_dai *i2s = to_info(dai);
1018 else if (is_secondary(i2s))
1044 struct i2s_dai *i2s = to_info(dai);
1045 struct i2s_dai *other = get_other_dai(i2s);
1050 if (is_secondary(i2s)) {
1052 snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, NULL);
1054 snd_soc_dai_init_dma_data(dai, &i2s->dma_playback,
1055 &i2s->dma_capture);
1066 i2s->rfs = 0;
1067 i2s->bfs = 0;
1070 i2s_txctrl(i2s, 0);
1071 i2s_rxctrl(i2s, 0);
1072 i2s_fifo(i2s, FIC_TXFLUSH);
1074 i2s_fifo(i2s, FIC_RXFLUSH);
1089 struct i2s_dai *i2s = to_info(dai);
1094 if (!is_secondary(i2s)) {
1136 .name = "samsung-i2s",
1155 static const char *dai_names[] = { "samsung-i2s", "samsung-i2s-sec" };
1353 pdev_sec->driver_override = kstrdup("samsung-i2s", GFP_KERNEL);
1654 .name = "samsung-i2s",
1664 .compatible = "samsung,s3c6410-i2s",
1667 .compatible = "samsung,s5pv210-i2s",
1670 .compatible = "samsung,exynos5420-i2s",
1673 .compatible = "samsung,exynos7-i2s",
1696 .name = "samsung-i2s",
1707 MODULE_ALIAS("platform:samsung-i2s");