static void davinci_hw_common_param(struct davinci_audio_dev *dev, int stream) { int i; u8 tx_ser = 0; u8 rx_ser = 0; /* Default configuration */ mcasp_set_bits(dev->base + DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); /* All PINS as McASP */ mcasp_set_reg(dev->base + DAVINCI_MCASP_PFUNC_REG, 0x00000000); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); } else { mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); mcasp_clr_bits(dev->base + DAVINCI_MCASP_REVTCTL_REG, RXDATADMADIS); } for (i = 0; i < dev->num_serializer; i++) { mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i), dev->serial_dir[i]); if (dev->serial_dir[i] == TX_MODE) { mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AXR(i)); tx_ser++; } else if (dev->serial_dir[i] == RX_MODE) { mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AXR(i)); rx_ser++; } } if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { if (dev->txnumevt * tx_ser > 64) dev->txnumevt = 1; mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, tx_ser, NUMDMA_MASK); mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); mcasp_set_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); } if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { if (dev->rxnumevt * rx_ser > 64) dev->rxnumevt = 1; mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, rx_ser, NUMDMA_MASK); mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); mcasp_set_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); } }
static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) { int i, active_slots; u32 mask = 0; active_slots = (dev->tdm_slots > 31) ? 32 : dev->tdm_slots; for (i = 0; i < active_slots; i++) mask |= (1 << i); mcasp_clr_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { /* bit stream is MSB first with no delay */ /* DSP_B mode */ mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32)) mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); else printk(KERN_ERR "playback tdm slot %d not supported\n", dev->tdm_slots); mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); } else { /* bit stream is MSB first with no delay */ /* DSP_B mode */ mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD); mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32)) mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); else printk(KERN_ERR "capture tdm slot %d not supported\n", dev->tdm_slots); mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); } }
static int davinci_config_channel_size(struct davinci_audio_dev *dev, int channel_size) { u32 fmt = 0; u32 mask, rotate; switch (channel_size) { case DAVINCI_AUDIO_WORD_8: fmt = 0x03; rotate = 6; mask = 0x000000ff; break; case DAVINCI_AUDIO_WORD_12: fmt = 0x05; rotate = 5; mask = 0x00000fff; break; case DAVINCI_AUDIO_WORD_16: fmt = 0x07; rotate = 4; mask = 0x0000ffff; break; case DAVINCI_AUDIO_WORD_20: fmt = 0x09; rotate = 3; mask = 0x000fffff; break; case DAVINCI_AUDIO_WORD_24: fmt = 0x0B; rotate = 2; mask = 0x00ffffff; break; case DAVINCI_AUDIO_WORD_28: fmt = 0x0D; rotate = 1; mask = 0x0fffffff; break; case DAVINCI_AUDIO_WORD_32: fmt = 0x0F; rotate = 0; mask = 0xffffffff; break; default: return -EINVAL; } mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXSSZ(fmt), RXSSZ(0x0F)); mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXSSZ(fmt), TXSSZ(0x0F)); mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXROT(rotate), TXROT(7)); mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXROT(rotate), RXROT(7)); mcasp_set_reg(dev->base + DAVINCI_MCASP_TXMASK_REG, mask); mcasp_set_reg(dev->base + DAVINCI_MCASP_RXMASK_REG, mask); return 0; }
static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) { int i, active_slots; u32 mask = 0, val; active_slots = (dev->tdm_slots > 31) ? 32 : dev->tdm_slots; for (i = 0; i < active_slots; i++) mask |= (1 << i); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { /* bit stream is MSB first with no delay */ /* DSP_B mode or I2S mode */ /* AHCLK from internal clk */ mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); /* in which tdm slots is the transmitter active */ mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); /* MSB first (and 1 bit delay for I2S) */ val = TXORD; if ((dev->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) val |= FSXDLY(1); mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, val); if (((dev->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) && (dev->tdm_slots != 2)) dev_err(dev->dev, "I2S should have 2 tdm_slots\n"); if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); else printk(KERN_ERR "playback tdm slot %d not supported\n", dev->tdm_slots); /* frame sync width */ if ((dev->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); else mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); } else { /* bit stream is MSB first (and 1 bit delay for I2S) */ /* DSP_B mode or I2S mode */ val = TXORD; if ((dev->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) val |= FSXDLY(1); mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, val); mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) { mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSRMOD(dev->tdm_slots), FSXMOD(0x1FF)); } else printk(KERN_ERR "capture tdm slot %d not supported\n", dev->tdm_slots); /* frame sync width */ if ((dev->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) { mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); } else { mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); } } }