ASoC: rockchip: pdm: Add support for path map
This patch adds property 'rockchip,path-map' for path mapping. e.g. "rockchip,path-map = <3 2 1 0>" means the mapping as follows: path0 <-- sdi3 path1 <-- sdi2 path2 <-- sdi1 path3 <-- sdi0 Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Link: https://lore.kernel.org/r/1630675410-3354-5-git-send-email-sugar.zhang@rock-chips.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f80e5a14ac
commit
13e6e042a6
@ -20,6 +20,7 @@
|
||||
|
||||
#define PDM_DMA_BURST_SIZE (8) /* size * width: 8*4 = 32 bytes */
|
||||
#define PDM_SIGNOFF_CLK_RATE (100000000)
|
||||
#define PDM_PATH_MAX (4)
|
||||
|
||||
enum rk_pdm_version {
|
||||
RK_PDM_RK3229,
|
||||
@ -539,8 +540,36 @@ static const struct of_device_id rockchip_pdm_match[] __maybe_unused = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rockchip_pdm_match);
|
||||
|
||||
static int rockchip_pdm_path_parse(struct rk_pdm_dev *pdm, struct device_node *node)
|
||||
{
|
||||
unsigned int path[PDM_PATH_MAX];
|
||||
int cnt = 0, ret = 0, i = 0, val = 0, msk = 0;
|
||||
|
||||
cnt = of_count_phandle_with_args(node, "rockchip,path-map",
|
||||
NULL);
|
||||
if (cnt != PDM_PATH_MAX)
|
||||
return cnt;
|
||||
|
||||
ret = of_property_read_u32_array(node, "rockchip,path-map",
|
||||
path, cnt);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (path[i] >= PDM_PATH_MAX)
|
||||
return -EINVAL;
|
||||
msk |= PDM_PATH_MASK(i);
|
||||
val |= PDM_PATH(i, path[i]);
|
||||
}
|
||||
|
||||
regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, msk, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_pdm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
const struct of_device_id *match;
|
||||
struct rk_pdm_dev *pdm;
|
||||
struct resource *res;
|
||||
@ -606,6 +635,11 @@ static int rockchip_pdm_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
rockchip_pdm_rxctrl(pdm, 0);
|
||||
|
||||
ret = rockchip_pdm_path_parse(pdm, node);
|
||||
if (ret != 0 && ret != -ENOENT)
|
||||
goto err_suspend;
|
||||
|
||||
ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "could not register pcm: %d\n", ret);
|
||||
|
@ -53,6 +53,9 @@
|
||||
#define PDM_FD_DENOMINATOR_MSK GENMASK(15, 0)
|
||||
|
||||
/* PDM CLK CTRL */
|
||||
#define PDM_PATH_SHIFT(x) (8 + (x) * 2)
|
||||
#define PDM_PATH_MASK(x) (0x3 << PDM_PATH_SHIFT(x))
|
||||
#define PDM_PATH(x, v) ((v) << PDM_PATH_SHIFT(x))
|
||||
#define PDM_CLK_FD_RATIO_MSK BIT(6)
|
||||
#define PDM_CLK_FD_RATIO_40 (0X0 << 6)
|
||||
#define PDM_CLK_FD_RATIO_35 BIT(6)
|
||||
|
Loading…
Reference in New Issue
Block a user