Commit 9e970b80 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Tony Lindgren

ALSA: Fix OMAP24xx EAC codec port I2S master/slave support

- Add explicit I2S master and slave modes
- Do not configure bit-clock and frame sync direction according to polarity
  changed I2S mode as it was done in programming model but according to
  master/slave mode
- Activate codec port transparent DMA only when EAC is I2S slave
Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 8d38963c
...@@ -48,14 +48,14 @@ enum eac_mclk_src { ...@@ -48,14 +48,14 @@ enum eac_mclk_src {
enum eac_codec_mode { enum eac_codec_mode {
EAC_CODEC_PCM, EAC_CODEC_PCM,
EAC_CODEC_AC97, EAC_CODEC_AC97,
EAC_CODEC_I2S, EAC_CODEC_I2S_MASTER, /* codec port, I.e. EAC is the master */
EAC_CODEC_I2S_SLAVE,
}; };
/* configuration structure for I2S mode */ /* configuration structure for I2S mode */
struct eac_i2s_conf { struct eac_i2s_conf {
/* it seems according to TRM that the polarity-changed I2S mode is not /* if enabled, then first data slot (left channel) is signaled as
* only that frame sync polarity (EAC.AC_FS) is changed but also direction * positive level of frame sync EAC.AC_FS */
* of it and interface serial clock (EAC.AC_SCLK) */
unsigned polarity_changed_mode:1; unsigned polarity_changed_mode:1;
/* if enabled, then serial data starts one clock cycle after the /* if enabled, then serial data starts one clock cycle after the
* of EAC.AC_FS for first audio slot */ * of EAC.AC_FS for first audio slot */
......
...@@ -435,24 +435,29 @@ static int eac_configure_i2s(struct omap_eac *eac, struct eac_codec *conf) ...@@ -435,24 +435,29 @@ static int eac_configure_i2s(struct omap_eac *eac, struct eac_codec *conf)
/* configuration for normal I2S or polarity-changed I2S */ /* configuration for normal I2S or polarity-changed I2S */
if (!conf->codec_conf.i2s.polarity_changed_mode) { if (!conf->codec_conf.i2s.polarity_changed_mode) {
/* I2S */
cpcfr1 |= CPCFR1_MODE(4); /* I2S mode */ cpcfr1 |= CPCFR1_MODE(4); /* I2S mode */
MOD_REG_BIT(cpcfr3, CPCFR3_CSCLKD, 0); /* CP_SCLK output */
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCD, 0); /* CP_SYNC output */
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCP, 0); /* CP_SYNC active low */ MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCP, 0); /* CP_SYNC active low */
/* audio time slots configuration for I2S */ /* audio time slots configuration for I2S */
cpcfr4 |= CPCFR4_ATSL(0); cpcfr4 |= CPCFR4_ATSL(0);
} else { } else {
/* polarity changed I2S mode */ cpcfr1 |= CPCFR1_MODE(1); /* PCM mode/polarity-changed I2S */
cpcfr1 |= CPCFR1_MODE(1); /* polarity changed I2S mode */
MOD_REG_BIT(cpcfr3, CPCFR3_CSCLKD, 1); /* CP_SCLK input */
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCD, 1); /* CP_SYNC input */
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCP, 1); /* CP_SYNC active MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCP, 1); /* CP_SYNC active
high */ high */
/* audio time slots configuration for polarity-changed I2S */ /* audio time slots configuration for polarity-changed I2S */
cpcfr4 |= CPCFR4_ATSL(0xf); cpcfr4 |= CPCFR4_ATSL(0xf);
}; };
/* master/slave configuration */
if (conf->codec_mode == EAC_CODEC_I2S_MASTER) {
/* EAC is master. Set CP_SCLK and CP_SYNC as outputs */
MOD_REG_BIT(cpcfr3, CPCFR3_CSCLKD, 0);
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCD, 0);
} else {
/* EAC is slave. Set CP_SCLK and CP_SYNC as inputs */
MOD_REG_BIT(cpcfr3, CPCFR3_CSCLKD, 1);
MOD_REG_BIT(cpcfr3, CPCFR3_CSYNCD, 1);
}
eac_write_reg(eac, EAC_CPCFR1, cpcfr1); eac_write_reg(eac, EAC_CPCFR1, cpcfr1);
eac_write_reg(eac, EAC_CPCFR2, cpcfr2); eac_write_reg(eac, EAC_CPCFR2, cpcfr2);
eac_write_reg(eac, EAC_CPCFR3, cpcfr3); eac_write_reg(eac, EAC_CPCFR3, cpcfr3);
...@@ -528,11 +533,13 @@ static int eac_codec_port_init(struct omap_eac *eac, struct eac_codec *conf) ...@@ -528,11 +533,13 @@ static int eac_codec_port_init(struct omap_eac *eac, struct eac_codec *conf)
agcfr3 &= ~AGCFR3_FSINT_BITS; agcfr3 &= ~AGCFR3_FSINT_BITS;
agcfr3 |= AGCFR3_FSINT(eac_calc_agcfr3_fsint(conf->default_rate)); agcfr3 |= AGCFR3_FSINT(eac_calc_agcfr3_fsint(conf->default_rate));
/* transparent DMA enable/disable bits /* transparent DMA enable bits */
* TODO: Are these needed? */
MOD_REG_BIT(agcfr3, AGCFR3_MD_TR_DMA, 1); /* modem */ MOD_REG_BIT(agcfr3, AGCFR3_MD_TR_DMA, 1); /* modem */
MOD_REG_BIT(agcfr3, AGCFR3_BT_TR_DMA, 1); /* BT */ MOD_REG_BIT(agcfr3, AGCFR3_BT_TR_DMA, 1); /* BT */
MOD_REG_BIT(agcfr3, AGCFR3_CP_TR_DMA, 0); /* codec port */ if (conf->codec_mode != EAC_CODEC_I2S_SLAVE)
MOD_REG_BIT(agcfr3, AGCFR3_CP_TR_DMA, 0);
else
MOD_REG_BIT(agcfr3, AGCFR3_CP_TR_DMA, 1);
/* step 4 (see TRM) */ /* step 4 (see TRM) */
eac_write_reg(eac, EAC_AGCFR3, agcfr3); eac_write_reg(eac, EAC_AGCFR3, agcfr3);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment