mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
ASoC: rockchip: pdm: Fix signoff for rk3588 pdm
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Change-Id: I75efb9ea38d2a5fe86c3797896d44fb0dd179f2c
This commit is contained in:
@@ -19,12 +19,14 @@
|
||||
#include "rockchip_pdm.h"
|
||||
|
||||
#define PDM_DMA_BURST_SIZE (8) /* size * width: 8*4 = 32 bytes */
|
||||
#define PDM_SIGNOFF_CLK_RATE (100000000)
|
||||
#define PDM_SIGNOFF_CLK_100M (100000000)
|
||||
#define PDM_SIGNOFF_CLK_300M (300000000)
|
||||
#define PDM_PATH_MAX (4)
|
||||
|
||||
enum rk_pdm_version {
|
||||
RK_PDM_RK3229,
|
||||
RK_PDM_RK3308,
|
||||
RK_PDM_RK3588,
|
||||
RK_PDM_RV1126,
|
||||
};
|
||||
|
||||
@@ -76,7 +78,8 @@ static struct rk_pdm_ds_ratio ds_ratio[] = {
|
||||
};
|
||||
|
||||
static unsigned int get_pdm_clk(struct rk_pdm_dev *pdm, unsigned int sr,
|
||||
unsigned int *clk_src, unsigned int *clk_out)
|
||||
unsigned int *clk_src, unsigned int *clk_out,
|
||||
unsigned int signoff)
|
||||
{
|
||||
unsigned int i, count, clk, div, rate;
|
||||
|
||||
@@ -101,7 +104,7 @@ static unsigned int get_pdm_clk(struct rk_pdm_dev *pdm, unsigned int sr,
|
||||
}
|
||||
|
||||
if (!clk) {
|
||||
clk = clk_round_rate(pdm->clk, PDM_SIGNOFF_CLK_RATE);
|
||||
clk = clk_round_rate(pdm->clk, signoff);
|
||||
*clk_src = clk;
|
||||
}
|
||||
return clk;
|
||||
@@ -200,7 +203,7 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream,
|
||||
struct rk_pdm_dev *pdm = to_info(dai);
|
||||
unsigned int val = 0;
|
||||
unsigned int clk_rate, clk_div, samplerate;
|
||||
unsigned int clk_src, clk_out = 0;
|
||||
unsigned int clk_src = 0, clk_out = 0, signoff = PDM_SIGNOFF_CLK_100M;
|
||||
unsigned long m, n;
|
||||
bool change;
|
||||
int ret;
|
||||
@@ -209,7 +212,10 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream,
|
||||
return 0;
|
||||
|
||||
samplerate = params_rate(params);
|
||||
clk_rate = get_pdm_clk(pdm, samplerate, &clk_src, &clk_out);
|
||||
|
||||
if (pdm->version == RK_PDM_RK3588)
|
||||
signoff = PDM_SIGNOFF_CLK_300M;
|
||||
clk_rate = get_pdm_clk(pdm, samplerate, &clk_src, &clk_out, signoff);
|
||||
if (!clk_rate)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -218,6 +224,7 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream,
|
||||
return -EINVAL;
|
||||
|
||||
if (pdm->version == RK_PDM_RK3308 ||
|
||||
pdm->version == RK_PDM_RK3588 ||
|
||||
pdm->version == RK_PDM_RV1126) {
|
||||
rational_best_approximation(clk_out, clk_src,
|
||||
GENMASK(16 - 1, 0),
|
||||
@@ -247,7 +254,7 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream,
|
||||
val);
|
||||
}
|
||||
|
||||
if (pdm->version == RK_PDM_RV1126) {
|
||||
if (pdm->version == RK_PDM_RK3588 || pdm->version == RK_PDM_RV1126) {
|
||||
val = get_pdm_cic_ratio(clk_out);
|
||||
regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, PDM_CIC_RATIO_MSK, val);
|
||||
val = samplerate_to_bit(samplerate);
|
||||
@@ -535,7 +542,7 @@ static const struct of_device_id rockchip_pdm_match[] __maybe_unused = {
|
||||
{ .compatible = "rockchip,rk3568-pdm",
|
||||
.data = (void *)RK_PDM_RV1126 },
|
||||
{ .compatible = "rockchip,rk3588-pdm",
|
||||
.data = (void *)RK_PDM_RV1126 },
|
||||
.data = (void *)RK_PDM_RK3588 },
|
||||
{ .compatible = "rockchip,rv1126-pdm",
|
||||
.data = (void *)RK_PDM_RV1126 },
|
||||
{},
|
||||
|
||||
Reference in New Issue
Block a user