Lines Matching refs:saif
50 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_set_dai_sysclk() local
54 saif->mclk = freq; in mxs_saif_set_dai_sysclk()
68 static inline struct mxs_saif *mxs_saif_get_master(struct mxs_saif * saif) in mxs_saif_get_master() argument
70 return mxs_saif[saif->master_id]; in mxs_saif_get_master()
76 static int mxs_saif_set_clk(struct mxs_saif *saif, in mxs_saif_set_clk() argument
84 dev_dbg(saif->dev, "mclk %d rate %d\n", mclk, rate); in mxs_saif_set_clk()
87 master_saif = mxs_saif_get_master(saif); in mxs_saif_set_clk()
91 dev_dbg(saif->dev, "master saif%d\n", master_saif->id); in mxs_saif_set_clk()
95 dev_err(saif->dev, in mxs_saif_set_clk()
206 struct mxs_saif *saif = mxs_saif[saif_id]; in mxs_saif_put_mclk() local
209 if (!saif) in mxs_saif_put_mclk()
212 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_put_mclk()
214 dev_err(saif->dev, "error: busy\n"); in mxs_saif_put_mclk()
218 clk_disable_unprepare(saif->clk); in mxs_saif_put_mclk()
222 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_put_mclk()
224 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_put_mclk()
226 saif->mclk_in_use = 0; in mxs_saif_put_mclk()
240 struct mxs_saif *saif = mxs_saif[saif_id]; in mxs_saif_get_mclk() local
245 if (!saif) in mxs_saif_get_mclk()
250 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_get_mclk()
254 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_get_mclk()
256 master_saif = mxs_saif_get_master(saif); in mxs_saif_get_mclk()
257 if (saif != master_saif) { in mxs_saif_get_mclk()
258 dev_err(saif->dev, "can not get mclk from a non-master saif\n"); in mxs_saif_get_mclk()
262 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_get_mclk()
264 dev_err(saif->dev, "error: busy\n"); in mxs_saif_get_mclk()
268 saif->mclk_in_use = 1; in mxs_saif_get_mclk()
269 ret = mxs_saif_set_clk(saif, mclk, rate); in mxs_saif_get_mclk()
273 ret = clk_prepare_enable(saif->clk); in mxs_saif_get_mclk()
279 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_get_mclk()
293 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_set_dai_fmt() local
295 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_set_dai_fmt()
304 if (saif->id != saif->master_id) { in mxs_saif_set_dai_fmt()
306 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_set_dai_fmt()
308 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_set_dai_fmt()
311 scr0 = __raw_readl(saif->base + SAIF_CTRL); in mxs_saif_set_dai_fmt()
362 if (saif->id == saif->master_id) in mxs_saif_set_dai_fmt()
367 __raw_writel(scr | scr0, saif->base + SAIF_CTRL); in mxs_saif_set_dai_fmt()
379 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_startup() local
383 saif->fifo_underrun = 0; in mxs_saif_startup()
384 saif->fifo_overrun = 0; in mxs_saif_startup()
388 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_startup()
392 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_startup()
394 ret = clk_prepare(saif->clk); in mxs_saif_startup()
404 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_shutdown() local
406 clk_unprepare(saif->clk); in mxs_saif_shutdown()
417 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_hw_params() local
422 master_saif = mxs_saif_get_master(saif); in mxs_saif_hw_params()
427 if (!saif->mclk && saif->mclk_in_use) { in mxs_saif_hw_params()
432 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_hw_params()
433 if (!saif->mclk_in_use && (stat & BM_SAIF_STAT_BUSY)) { in mxs_saif_hw_params()
443 ret = mxs_saif_set_clk(saif, saif->mclk, params_rate(params)); in mxs_saif_hw_params()
449 if (saif != master_saif) { in mxs_saif_hw_params()
457 ret = clk_enable(saif->clk); in mxs_saif_hw_params()
461 ret = clk_set_rate(saif->clk, 24000000); in mxs_saif_hw_params()
462 clk_disable(saif->clk); in mxs_saif_hw_params()
471 scr = __raw_readl(saif->base + SAIF_CTRL); in mxs_saif_hw_params()
500 __raw_writel(scr, saif->base + SAIF_CTRL); in mxs_saif_hw_params()
507 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_prepare() local
511 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_prepare()
519 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_trigger() local
524 master_saif = mxs_saif_get_master(saif); in mxs_saif_trigger()
532 if (saif->state == MXS_SAIF_STATE_RUNNING) in mxs_saif_trigger()
539 dev_err(saif->dev, "Failed to enable master clock\n"); in mxs_saif_trigger()
547 if (saif != master_saif) { in mxs_saif_trigger()
548 ret = clk_enable(saif->clk); in mxs_saif_trigger()
550 dev_err(saif->dev, "Failed to enable master clock\n"); in mxs_saif_trigger()
556 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_trigger()
571 __raw_writel(0, saif->base + SAIF_DATA); in mxs_saif_trigger()
572 __raw_writel(0, saif->base + SAIF_DATA); in mxs_saif_trigger()
581 __raw_readl(saif->base + SAIF_DATA); in mxs_saif_trigger()
582 __raw_readl(saif->base + SAIF_DATA); in mxs_saif_trigger()
586 saif->state = MXS_SAIF_STATE_RUNNING; in mxs_saif_trigger()
588 dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n", in mxs_saif_trigger()
589 __raw_readl(saif->base + SAIF_CTRL), in mxs_saif_trigger()
590 __raw_readl(saif->base + SAIF_STAT)); in mxs_saif_trigger()
599 if (saif->state == MXS_SAIF_STATE_STOPPED) in mxs_saif_trigger()
614 if (saif != master_saif) { in mxs_saif_trigger()
616 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_trigger()
618 clk_disable(saif->clk); in mxs_saif_trigger()
622 saif->state = MXS_SAIF_STATE_STOPPED; in mxs_saif_trigger()
671 struct mxs_saif *saif = dev_id; in mxs_saif_irq() local
674 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_irq()
680 dev_dbg(saif->dev, "underrun!!! %d\n", ++saif->fifo_underrun); in mxs_saif_irq()
682 saif->base + SAIF_STAT + MXS_CLR_ADDR); in mxs_saif_irq()
686 dev_dbg(saif->dev, "overrun!!! %d\n", ++saif->fifo_overrun); in mxs_saif_irq()
688 saif->base + SAIF_STAT + MXS_CLR_ADDR); in mxs_saif_irq()
691 dev_dbg(saif->dev, "SAIF_CTRL %x SAIF_STAT %x\n", in mxs_saif_irq()
692 __raw_readl(saif->base + SAIF_CTRL), in mxs_saif_irq()
693 __raw_readl(saif->base + SAIF_STAT)); in mxs_saif_irq()
700 struct mxs_saif *saif = platform_get_drvdata(pdev); in mxs_saif_mclk_init() local
706 __clk_get_name(saif->clk), 0, in mxs_saif_mclk_init()
707 saif->base + SAIF_CTRL, in mxs_saif_mclk_init()
728 struct mxs_saif *saif; in mxs_saif_probe() local
732 saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL); in mxs_saif_probe()
733 if (!saif) in mxs_saif_probe()
740 saif->id = ret; in mxs_saif_probe()
742 if (saif->id >= ARRAY_SIZE(mxs_saif)) { in mxs_saif_probe()
754 saif->master_id = saif->id; in mxs_saif_probe()
761 saif->master_id = ret; in mxs_saif_probe()
763 if (saif->master_id >= ARRAY_SIZE(mxs_saif)) { in mxs_saif_probe()
769 mxs_saif[saif->id] = saif; in mxs_saif_probe()
771 saif->clk = devm_clk_get(&pdev->dev, NULL); in mxs_saif_probe()
772 if (IS_ERR(saif->clk)) { in mxs_saif_probe()
773 ret = PTR_ERR(saif->clk); in mxs_saif_probe()
779 saif->base = devm_platform_ioremap_resource(pdev, 0); in mxs_saif_probe()
780 if (IS_ERR(saif->base)) in mxs_saif_probe()
781 return PTR_ERR(saif->base); in mxs_saif_probe()
787 saif->dev = &pdev->dev; in mxs_saif_probe()
789 dev_name(&pdev->dev), saif); in mxs_saif_probe()
795 platform_set_drvdata(pdev, saif); in mxs_saif_probe()
798 if (saif->id == 0) { in mxs_saif_probe()