diff --git a/sound/soc/amlogic/auge/pdm.c b/sound/soc/amlogic/auge/pdm.c index 16e776663cdc..5e3c2d0d17e3 100644 --- a/sound/soc/amlogic/auge/pdm.c +++ b/sound/soc/amlogic/auge/pdm.c @@ -539,9 +539,12 @@ static int aml_pdm_dai_trigger( case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + pdm_fifo_reset(); + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { dev_info(substream->pcm->card->dev, "pdm capture enable\n"); aml_toddr_enable(p_pdm->tddr, 1); + pdm_enable(1); } break; @@ -550,6 +553,7 @@ static int aml_pdm_dai_trigger( case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { dev_info(substream->pcm->card->dev, "pdm capture enable\n"); + pdm_enable(0); aml_toddr_enable(p_pdm->tddr, 0); } diff --git a/sound/soc/amlogic/auge/pdm_hw.c b/sound/soc/amlogic/auge/pdm_hw.c index 188f85b4660a..640b103130fa 100644 --- a/sound/soc/amlogic/auge/pdm_hw.c +++ b/sound/soc/amlogic/auge/pdm_hw.c @@ -19,6 +19,7 @@ #include #include #include +/*#include */ #include "pdm_hw.h" #include "regs.h" @@ -26,6 +27,39 @@ #include "pdm_hw_coeff.c" extern int pdm_hcic_shift_gain; +void pdm_enable(int is_enable) +{ + if (is_enable) { + aml_pdm_update_bits( + PDM_CTRL, + 0x1 << 31, + is_enable << 31); + } else { + aml_pdm_update_bits( + PDM_CTRL, + 0x1 << 31 | 0x1 << 16, + 0 << 31 | 0 << 16); + + /*udelay(1000);*/ + } +} + +void pdm_fifo_reset(void) +{ + /* PDM Asynchronous FIFO soft reset. + * write 1 to soft reset AFIFO + */ + + aml_pdm_update_bits( + PDM_CTRL, + 0x1 << 16, + 0 << 16); + + aml_pdm_update_bits( + PDM_CTRL, + 0x1 << 16, + 0x1 << 16); +} void aml_pdm_ctrl( struct aml_audio_controller *actrl, @@ -43,11 +77,12 @@ void aml_pdm_ctrl( pr_info("%s, channels mask:%x\n", __func__, ch_mask); - aml_pdm_write(PDM_CTRL, 0); + aml_pdm_write(PDM_CLKG_CTRL, 1); /* must be sure that clk and pdm is enable */ - aml_pdm_write(PDM_CTRL, - (1 << 31) | + aml_pdm_update_bits(PDM_CTRL, + (0x7 << 28 | 0xff << 8 | 0xff << 0), + /*(1 << 31) |*/ /* invert the PDM_DCLK or not */ (0 << 30) | /* output mode: 1: 24bits. 0: 32 bits */ @@ -56,10 +91,6 @@ void aml_pdm_ctrl( * 1: bypass all filter. 0: normal mode. */ (0 << 28) | - /* PDM Asynchronous FIFO soft reset. - * write 1 to soft reset AFIFO - */ - (1 << 16) | /* PDM channel reset. */ (ch_mask << 8) | /* PDM channel enable */ @@ -384,5 +415,4 @@ void aml_pdm_filter_ctrl(int osr, int mode) lpf3_len, lpf3_coeff ); - aml_pdm_update_bits(PDM_CTRL, 1 << 31, 1 << 31); } diff --git a/sound/soc/amlogic/auge/pdm_hw.h b/sound/soc/amlogic/auge/pdm_hw.h index 7fc7333c8537..d51c8d867669 100644 --- a/sound/soc/amlogic/auge/pdm_hw.h +++ b/sound/soc/amlogic/auge/pdm_hw.h @@ -29,4 +29,7 @@ extern int aml_pmd_set_HPF_filter_parameters(void *array); extern void aml_pdm_filter_ctrl(int osr, int set); +extern void pdm_enable(int is_enable); + +extern void pdm_fifo_reset(void); #endif /*__AML_PDM_HW_H__*/