Lines Matching +full:odd +full:- +full:numbered
22 * Copyright 2007-2010 Freescale Semiconductor, Inc.
138 unsigned int master = dev->fmt & SND_SOC_DAIFMT_MASTER_MASK; in bcm2835_i2s_start_clock()
140 if (dev->clk_prepared) in bcm2835_i2s_start_clock()
146 clk_prepare_enable(dev->clk); in bcm2835_i2s_start_clock()
147 dev->clk_prepared = true; in bcm2835_i2s_start_clock()
156 if (dev->clk_prepared) in bcm2835_i2s_stop_clock()
157 clk_disable_unprepare(dev->clk); in bcm2835_i2s_stop_clock()
158 dev->clk_prepared = false; in bcm2835_i2s_stop_clock()
179 regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); in bcm2835_i2s_clear_fifos()
183 clk_was_prepared = dev->clk_prepared; in bcm2835_i2s_clear_fifos()
188 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, off, 0); in bcm2835_i2s_clear_fifos()
194 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, clr, clr); in bcm2835_i2s_clear_fifos()
202 regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &syncval); in bcm2835_i2s_clear_fifos()
205 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_clear_fifos()
209 while (--timeout) { in bcm2835_i2s_clear_fifos()
210 regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); in bcm2835_i2s_clear_fifos()
216 dev_err(dev->dev, "I2S SYNC error!\n"); in bcm2835_i2s_clear_fifos()
223 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_clear_fifos()
231 dev->fmt = fmt; in bcm2835_i2s_set_dai_fmt()
241 dev->tdm_slots = 0; in bcm2835_i2s_set_dai_bclk_ratio()
246 return -EINVAL; in bcm2835_i2s_set_dai_bclk_ratio()
248 dev->tdm_slots = 2; in bcm2835_i2s_set_dai_bclk_ratio()
249 dev->rx_mask = 0x03; in bcm2835_i2s_set_dai_bclk_ratio()
250 dev->tx_mask = 0x03; in bcm2835_i2s_set_dai_bclk_ratio()
251 dev->slot_width = ratio / 2; in bcm2835_i2s_set_dai_bclk_ratio()
252 dev->frame_length = ratio; in bcm2835_i2s_set_dai_bclk_ratio()
265 return -EINVAL; in bcm2835_i2s_set_dai_tdm_slot()
268 rx_mask &= GENMASK(slots - 1, 0); in bcm2835_i2s_set_dai_tdm_slot()
269 tx_mask &= GENMASK(slots - 1, 0); in bcm2835_i2s_set_dai_tdm_slot()
272 * The driver is limited to 2-channel setups. in bcm2835_i2s_set_dai_tdm_slot()
277 return -EINVAL; in bcm2835_i2s_set_dai_tdm_slot()
280 return -EINVAL; in bcm2835_i2s_set_dai_tdm_slot()
283 dev->tdm_slots = slots; in bcm2835_i2s_set_dai_tdm_slot()
285 dev->rx_mask = rx_mask; in bcm2835_i2s_set_dai_tdm_slot()
286 dev->tx_mask = tx_mask; in bcm2835_i2s_set_dai_tdm_slot()
287 dev->slot_width = width; in bcm2835_i2s_set_dai_tdm_slot()
288 dev->frame_length = slots * width; in bcm2835_i2s_set_dai_tdm_slot()
299 * Otherwise odd_offset defines the physical offset for odd numbered
323 * I2S-style TDM slot numbering ( 0 2 ... 3 4 ...) with odd
331 *ch1_pos = bcm2835_i2s_convert_slot((ffs(mask) - 1), odd_offset) in bcm2835_i2s_calc_channel_pos()
333 *ch2_pos = bcm2835_i2s_convert_slot((fls(mask) - 1), odd_offset) in bcm2835_i2s_calc_channel_pos()
358 regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); in bcm2835_i2s_hw_params()
368 if (dev->tdm_slots) { in bcm2835_i2s_hw_params()
369 slots = dev->tdm_slots; in bcm2835_i2s_hw_params()
370 slot_width = dev->slot_width; in bcm2835_i2s_hw_params()
371 frame_length = dev->frame_length; in bcm2835_i2s_hw_params()
372 rx_mask = dev->rx_mask; in bcm2835_i2s_hw_params()
373 tx_mask = dev->tx_mask; in bcm2835_i2s_hw_params()
374 bclk_rate = dev->frame_length * params_rate(params); in bcm2835_i2s_hw_params()
392 return -EINVAL; in bcm2835_i2s_hw_params()
395 switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) { in bcm2835_i2s_hw_params()
405 return -EINVAL; in bcm2835_i2s_hw_params()
409 switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) { in bcm2835_i2s_hw_params()
419 return -EINVAL; in bcm2835_i2s_hw_params()
424 (!dev->clk_prepared || dev->clk_rate != bclk_rate)) { in bcm2835_i2s_hw_params()
425 if (dev->clk_prepared) in bcm2835_i2s_hw_params()
428 if (dev->clk_rate != bclk_rate) { in bcm2835_i2s_hw_params()
429 ret = clk_set_rate(dev->clk, bclk_rate); in bcm2835_i2s_hw_params()
432 dev->clk_rate = bclk_rate; in bcm2835_i2s_hw_params()
444 format |= BCM2835_I2S_CHWID((data_length-8)&0xf); in bcm2835_i2s_hw_params()
449 switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in bcm2835_i2s_hw_params()
453 return -EINVAL; in bcm2835_i2s_hw_params()
456 * Use I2S-style logical slot numbering: even slots in bcm2835_i2s_hw_params()
457 * are in first half of frame, odd slots in second half. in bcm2835_i2s_hw_params()
470 return -EINVAL; in bcm2835_i2s_hw_params()
479 return -EINVAL; in bcm2835_i2s_hw_params()
481 /* Odd frame lengths aren't supported */ in bcm2835_i2s_hw_params()
483 return -EINVAL; in bcm2835_i2s_hw_params()
486 data_delay = slot_width - data_length; in bcm2835_i2s_hw_params()
501 return -EINVAL; in bcm2835_i2s_hw_params()
511 * in left-justified or DSP mode A, only works stable in bcm2835_i2s_hw_params()
515 dev_warn(dev->dev, in bcm2835_i2s_hw_params()
524 regmap_write(dev->i2s_regmap, BCM2835_I2S_RXC_A_REG, in bcm2835_i2s_hw_params()
528 regmap_write(dev->i2s_regmap, BCM2835_I2S_TXC_A_REG, in bcm2835_i2s_hw_params()
545 mode |= BCM2835_I2S_FLEN(frame_length - 1); in bcm2835_i2s_hw_params()
557 switch (dev->fmt & SND_SOC_DAIFMT_INV_MASK) { in bcm2835_i2s_hw_params()
566 return -EINVAL; in bcm2835_i2s_hw_params()
570 switch (dev->fmt & SND_SOC_DAIFMT_INV_MASK) { in bcm2835_i2s_hw_params()
582 return -EINVAL; in bcm2835_i2s_hw_params()
585 regmap_write(dev->i2s_regmap, BCM2835_I2S_MODE_A_REG, mode); in bcm2835_i2s_hw_params()
588 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_hw_params()
593 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_DREQ_A_REG, in bcm2835_i2s_hw_params()
602 dev_dbg(dev->dev, in bcm2835_i2s_hw_params()
606 dev_dbg(dev->dev, "frame len: %d sync len: %d data len: %d\n", in bcm2835_i2s_hw_params()
609 dev_dbg(dev->dev, "rx pos: %d,%d tx pos: %d,%d\n", in bcm2835_i2s_hw_params()
612 dev_dbg(dev->dev, "sampling rate: %d bclk rate: %d\n", in bcm2835_i2s_hw_params()
615 dev_dbg(dev->dev, "CLKM: %d CLKI: %d FSM: %d FSI: %d frame start: %s edge\n", in bcm2835_i2s_hw_params()
637 regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &cs_reg); in bcm2835_i2s_prepare()
639 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK in bcm2835_i2s_prepare()
642 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE in bcm2835_i2s_prepare()
655 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in bcm2835_i2s_stop()
660 regmap_update_bits(dev->i2s_regmap, in bcm2835_i2s_stop()
664 if (!dai->active && !(dev->fmt & SND_SOC_DAIFMT_CONT)) in bcm2835_i2s_stop()
680 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in bcm2835_i2s_trigger()
685 regmap_update_bits(dev->i2s_regmap, in bcm2835_i2s_trigger()
695 return -EINVAL; in bcm2835_i2s_trigger()
706 if (dai->active) in bcm2835_i2s_startup()
713 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_startup()
720 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_startup()
734 if (dai->active) in bcm2835_i2s_shutdown()
738 regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, in bcm2835_i2s_shutdown()
764 &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK], in bcm2835_i2s_dai_probe()
765 &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE]); in bcm2835_i2s_dai_probe()
771 .name = "bcm2835-i2s",
832 .name = "bcm2835-i2s-comp",
844 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), in bcm2835_i2s_probe()
847 return -ENOMEM; in bcm2835_i2s_probe()
850 dev->clk_prepared = false; in bcm2835_i2s_probe()
851 dev->clk = devm_clk_get(&pdev->dev, NULL); in bcm2835_i2s_probe()
852 if (IS_ERR(dev->clk)) { in bcm2835_i2s_probe()
853 dev_err(&pdev->dev, "could not get clk: %ld\n", in bcm2835_i2s_probe()
854 PTR_ERR(dev->clk)); in bcm2835_i2s_probe()
855 return PTR_ERR(dev->clk); in bcm2835_i2s_probe()
860 base = devm_ioremap_resource(&pdev->dev, mem); in bcm2835_i2s_probe()
864 dev->i2s_regmap = devm_regmap_init_mmio(&pdev->dev, base, in bcm2835_i2s_probe()
866 if (IS_ERR(dev->i2s_regmap)) in bcm2835_i2s_probe()
867 return PTR_ERR(dev->i2s_regmap); in bcm2835_i2s_probe()
869 /* Set the DMA address - we have to parse DT ourselves */ in bcm2835_i2s_probe()
870 addr = of_get_address(pdev->dev.of_node, 0, NULL, NULL); in bcm2835_i2s_probe()
872 dev_err(&pdev->dev, "could not get DMA-register address\n"); in bcm2835_i2s_probe()
873 return -EINVAL; in bcm2835_i2s_probe()
877 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr = in bcm2835_i2s_probe()
880 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr = in bcm2835_i2s_probe()
884 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr_width = in bcm2835_i2s_probe()
886 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr_width = in bcm2835_i2s_probe()
890 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].maxburst = 2; in bcm2835_i2s_probe()
891 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].maxburst = 2; in bcm2835_i2s_probe()
895 * packed into 32-bit transfers). in bcm2835_i2s_probe()
897 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].flags = in bcm2835_i2s_probe()
899 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].flags = in bcm2835_i2s_probe()
903 dev->dev = &pdev->dev; in bcm2835_i2s_probe()
904 dev_set_drvdata(&pdev->dev, dev); in bcm2835_i2s_probe()
906 ret = devm_snd_soc_register_component(&pdev->dev, in bcm2835_i2s_probe()
909 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); in bcm2835_i2s_probe()
913 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in bcm2835_i2s_probe()
915 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); in bcm2835_i2s_probe()
923 { .compatible = "brcm,bcm2835-i2s", },
932 .name = "bcm2835-i2s",
939 MODULE_ALIAS("platform:bcm2835-i2s");