Lines Matching refs:saif

63 	struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);  in mxs_saif_set_dai_sysclk()  local
67 saif->mclk = freq; in mxs_saif_set_dai_sysclk()
81 static inline struct mxs_saif *mxs_saif_get_master(struct mxs_saif * saif) in mxs_saif_get_master() argument
83 return mxs_saif[saif->master_id]; in mxs_saif_get_master()
89 static int mxs_saif_set_clk(struct mxs_saif *saif, in mxs_saif_set_clk() argument
97 dev_dbg(saif->dev, "mclk %d rate %d\n", mclk, rate); in mxs_saif_set_clk()
100 master_saif = mxs_saif_get_master(saif); in mxs_saif_set_clk()
104 dev_dbg(saif->dev, "master saif%d\n", master_saif->id); in mxs_saif_set_clk()
108 dev_err(saif->dev, in mxs_saif_set_clk()
219 struct mxs_saif *saif = mxs_saif[saif_id]; in mxs_saif_put_mclk() local
222 if (!saif) in mxs_saif_put_mclk()
225 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_put_mclk()
227 dev_err(saif->dev, "error: busy\n"); in mxs_saif_put_mclk()
231 clk_disable_unprepare(saif->clk); in mxs_saif_put_mclk()
235 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_put_mclk()
237 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_put_mclk()
239 saif->mclk_in_use = 0; in mxs_saif_put_mclk()
253 struct mxs_saif *saif = mxs_saif[saif_id]; in mxs_saif_get_mclk() local
258 if (!saif) in mxs_saif_get_mclk()
263 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_get_mclk()
267 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_get_mclk()
269 master_saif = mxs_saif_get_master(saif); in mxs_saif_get_mclk()
270 if (saif != master_saif) { in mxs_saif_get_mclk()
271 dev_err(saif->dev, "can not get mclk from a non-master saif\n"); in mxs_saif_get_mclk()
275 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_get_mclk()
277 dev_err(saif->dev, "error: busy\n"); in mxs_saif_get_mclk()
281 saif->mclk_in_use = 1; in mxs_saif_get_mclk()
282 ret = mxs_saif_set_clk(saif, mclk, rate); in mxs_saif_get_mclk()
286 ret = clk_prepare_enable(saif->clk); in mxs_saif_get_mclk()
292 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_get_mclk()
306 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_set_dai_fmt() local
308 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_set_dai_fmt()
317 if (saif->id != saif->master_id) { in mxs_saif_set_dai_fmt()
319 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_set_dai_fmt()
321 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_set_dai_fmt()
324 scr0 = __raw_readl(saif->base + SAIF_CTRL); in mxs_saif_set_dai_fmt()
375 if (saif->id == saif->master_id) in mxs_saif_set_dai_fmt()
380 __raw_writel(scr | scr0, saif->base + SAIF_CTRL); in mxs_saif_set_dai_fmt()
392 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_startup() local
396 saif->fifo_underrun = 0; in mxs_saif_startup()
397 saif->fifo_overrun = 0; in mxs_saif_startup()
401 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_startup()
405 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_startup()
407 ret = clk_prepare(saif->clk); in mxs_saif_startup()
417 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_shutdown() local
419 clk_unprepare(saif->clk); in mxs_saif_shutdown()
430 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_hw_params() local
435 master_saif = mxs_saif_get_master(saif); in mxs_saif_hw_params()
440 if (!saif->mclk && saif->mclk_in_use) { in mxs_saif_hw_params()
445 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_hw_params()
446 if (!saif->mclk_in_use && (stat & BM_SAIF_STAT_BUSY)) { in mxs_saif_hw_params()
456 ret = mxs_saif_set_clk(saif, saif->mclk, params_rate(params)); in mxs_saif_hw_params()
462 if (saif != master_saif) { in mxs_saif_hw_params()
470 clk_enable(saif->clk); in mxs_saif_hw_params()
471 ret = clk_set_rate(saif->clk, 24000000); in mxs_saif_hw_params()
472 clk_disable(saif->clk); in mxs_saif_hw_params()
481 scr = __raw_readl(saif->base + SAIF_CTRL); in mxs_saif_hw_params()
510 __raw_writel(scr, saif->base + SAIF_CTRL); in mxs_saif_hw_params()
517 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_prepare() local
521 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_prepare()
529 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); in mxs_saif_trigger() local
534 master_saif = mxs_saif_get_master(saif); in mxs_saif_trigger()
542 if (saif->state == MXS_SAIF_STATE_RUNNING) in mxs_saif_trigger()
549 dev_err(saif->dev, "Failed to enable master clock\n"); in mxs_saif_trigger()
557 if (saif != master_saif) { in mxs_saif_trigger()
558 ret = clk_enable(saif->clk); in mxs_saif_trigger()
560 dev_err(saif->dev, "Failed to enable master clock\n"); in mxs_saif_trigger()
566 saif->base + SAIF_CTRL + MXS_SET_ADDR); in mxs_saif_trigger()
581 __raw_writel(0, saif->base + SAIF_DATA); in mxs_saif_trigger()
582 __raw_writel(0, saif->base + SAIF_DATA); in mxs_saif_trigger()
591 __raw_readl(saif->base + SAIF_DATA); in mxs_saif_trigger()
592 __raw_readl(saif->base + SAIF_DATA); in mxs_saif_trigger()
596 saif->state = MXS_SAIF_STATE_RUNNING; in mxs_saif_trigger()
598 dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n", in mxs_saif_trigger()
599 __raw_readl(saif->base + SAIF_CTRL), in mxs_saif_trigger()
600 __raw_readl(saif->base + SAIF_STAT)); in mxs_saif_trigger()
609 if (saif->state == MXS_SAIF_STATE_STOPPED) in mxs_saif_trigger()
624 if (saif != master_saif) { in mxs_saif_trigger()
626 saif->base + SAIF_CTRL + MXS_CLR_ADDR); in mxs_saif_trigger()
628 clk_disable(saif->clk); in mxs_saif_trigger()
632 saif->state = MXS_SAIF_STATE_STOPPED; in mxs_saif_trigger()
659 struct mxs_saif *saif = dev_get_drvdata(dai->dev); in mxs_saif_dai_probe() local
661 snd_soc_dai_set_drvdata(dai, saif); in mxs_saif_dai_probe()
690 struct mxs_saif *saif = dev_id; in mxs_saif_irq() local
693 stat = __raw_readl(saif->base + SAIF_STAT); in mxs_saif_irq()
699 dev_dbg(saif->dev, "underrun!!! %d\n", ++saif->fifo_underrun); in mxs_saif_irq()
701 saif->base + SAIF_STAT + MXS_CLR_ADDR); in mxs_saif_irq()
705 dev_dbg(saif->dev, "overrun!!! %d\n", ++saif->fifo_overrun); in mxs_saif_irq()
707 saif->base + SAIF_STAT + MXS_CLR_ADDR); in mxs_saif_irq()
710 dev_dbg(saif->dev, "SAIF_CTRL %x SAIF_STAT %x\n", in mxs_saif_irq()
711 __raw_readl(saif->base + SAIF_CTRL), in mxs_saif_irq()
712 __raw_readl(saif->base + SAIF_STAT)); in mxs_saif_irq()
719 struct mxs_saif *saif = platform_get_drvdata(pdev); in mxs_saif_mclk_init() local
725 __clk_get_name(saif->clk), 0, in mxs_saif_mclk_init()
726 saif->base + SAIF_CTRL, in mxs_saif_mclk_init()
748 struct mxs_saif *saif; in mxs_saif_probe() local
755 saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL); in mxs_saif_probe()
756 if (!saif) in mxs_saif_probe()
763 saif->id = ret; in mxs_saif_probe()
765 if (saif->id >= ARRAY_SIZE(mxs_saif)) { in mxs_saif_probe()
777 saif->master_id = saif->id; in mxs_saif_probe()
783 saif->master_id = ret; in mxs_saif_probe()
785 if (saif->master_id >= ARRAY_SIZE(mxs_saif)) { in mxs_saif_probe()
791 mxs_saif[saif->id] = saif; in mxs_saif_probe()
793 saif->clk = devm_clk_get(&pdev->dev, NULL); in mxs_saif_probe()
794 if (IS_ERR(saif->clk)) { in mxs_saif_probe()
795 ret = PTR_ERR(saif->clk); in mxs_saif_probe()
803 saif->base = devm_ioremap_resource(&pdev->dev, iores); in mxs_saif_probe()
804 if (IS_ERR(saif->base)) in mxs_saif_probe()
805 return PTR_ERR(saif->base); in mxs_saif_probe()
815 saif->dev = &pdev->dev; in mxs_saif_probe()
817 dev_name(&pdev->dev), saif); in mxs_saif_probe()
823 platform_set_drvdata(pdev, saif); in mxs_saif_probe()
826 if (saif->id == 0) { in mxs_saif_probe()