18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Rockchip PDM ALSA SoC Digital Audio Interface(DAI)  driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ROCKCHIP_PDM_H
98c2ecf20Sopenharmony_ci#define _ROCKCHIP_PDM_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/* PDM REGS */
128c2ecf20Sopenharmony_ci#define PDM_SYSCONFIG	(0x0000)
138c2ecf20Sopenharmony_ci#define PDM_CTRL0	(0x0004)
148c2ecf20Sopenharmony_ci#define PDM_CTRL1	(0x0008)
158c2ecf20Sopenharmony_ci#define PDM_CLK_CTRL	(0x000c)
168c2ecf20Sopenharmony_ci#define PDM_HPF_CTRL	(0x0010)
178c2ecf20Sopenharmony_ci#define PDM_FIFO_CTRL	(0x0014)
188c2ecf20Sopenharmony_ci#define PDM_DMA_CTRL	(0x0018)
198c2ecf20Sopenharmony_ci#define PDM_INT_EN	(0x001c)
208c2ecf20Sopenharmony_ci#define PDM_INT_CLR	(0x0020)
218c2ecf20Sopenharmony_ci#define PDM_INT_ST	(0x0024)
228c2ecf20Sopenharmony_ci#define PDM_RXFIFO_DATA	(0x0030)
238c2ecf20Sopenharmony_ci#define PDM_DATA_VALID	(0x0054)
248c2ecf20Sopenharmony_ci#define PDM_VERSION	(0x0058)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* PDM_SYSCONFIG */
278c2ecf20Sopenharmony_ci#define PDM_RX_MASK		(0x1 << 2)
288c2ecf20Sopenharmony_ci#define PDM_RX_START		(0x1 << 2)
298c2ecf20Sopenharmony_ci#define PDM_RX_STOP		(0x0 << 2)
308c2ecf20Sopenharmony_ci#define PDM_RX_CLR_MASK		(0x1 << 0)
318c2ecf20Sopenharmony_ci#define PDM_RX_CLR_WR		(0x1 << 0)
328c2ecf20Sopenharmony_ci#define PDM_RX_CLR_DONE		(0x0 << 0)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* PDM CTRL0 */
358c2ecf20Sopenharmony_ci#define PDM_PATH_MSK		(0xf << 27)
368c2ecf20Sopenharmony_ci#define PDM_MODE_MSK		BIT(31)
378c2ecf20Sopenharmony_ci#define PDM_MODE_RJ		0
388c2ecf20Sopenharmony_ci#define PDM_MODE_LJ		BIT(31)
398c2ecf20Sopenharmony_ci#define PDM_PATH3_EN		BIT(30)
408c2ecf20Sopenharmony_ci#define PDM_PATH2_EN		BIT(29)
418c2ecf20Sopenharmony_ci#define PDM_PATH1_EN		BIT(28)
428c2ecf20Sopenharmony_ci#define PDM_PATH0_EN		BIT(27)
438c2ecf20Sopenharmony_ci#define PDM_HWT_EN		BIT(26)
448c2ecf20Sopenharmony_ci#define PDM_VDW_MSK		(0x1f << 0)
458c2ecf20Sopenharmony_ci#define PDM_VDW(X)		((X - 1) << 0)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci/* PDM CTRL1 */
488c2ecf20Sopenharmony_ci#define PDM_FD_NUMERATOR_SFT	16
498c2ecf20Sopenharmony_ci#define PDM_FD_NUMERATOR_MSK	GENMASK(31, 16)
508c2ecf20Sopenharmony_ci#define PDM_FD_DENOMINATOR_SFT	0
518c2ecf20Sopenharmony_ci#define PDM_FD_DENOMINATOR_MSK	GENMASK(15, 0)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* PDM CLK CTRL */
548c2ecf20Sopenharmony_ci#define PDM_CLK_FD_RATIO_MSK	BIT(6)
558c2ecf20Sopenharmony_ci#define PDM_CLK_FD_RATIO_40	(0X0 << 6)
568c2ecf20Sopenharmony_ci#define PDM_CLK_FD_RATIO_35	BIT(6)
578c2ecf20Sopenharmony_ci#define PDM_CLK_MSK		BIT(5)
588c2ecf20Sopenharmony_ci#define PDM_CLK_EN		BIT(5)
598c2ecf20Sopenharmony_ci#define PDM_CLK_DIS		(0x0 << 5)
608c2ecf20Sopenharmony_ci#define PDM_CKP_MSK		BIT(3)
618c2ecf20Sopenharmony_ci#define PDM_CKP_NORMAL		(0x0 << 3)
628c2ecf20Sopenharmony_ci#define PDM_CKP_INVERTED	BIT(3)
638c2ecf20Sopenharmony_ci#define PDM_DS_RATIO_MSK	(0x7 << 0)
648c2ecf20Sopenharmony_ci#define PDM_CLK_320FS		(0x0 << 0)
658c2ecf20Sopenharmony_ci#define PDM_CLK_640FS		(0x1 << 0)
668c2ecf20Sopenharmony_ci#define PDM_CLK_1280FS		(0x2 << 0)
678c2ecf20Sopenharmony_ci#define PDM_CLK_2560FS		(0x3 << 0)
688c2ecf20Sopenharmony_ci#define PDM_CLK_5120FS		(0x4 << 0)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* PDM HPF CTRL */
718c2ecf20Sopenharmony_ci#define PDM_HPF_LE		BIT(3)
728c2ecf20Sopenharmony_ci#define PDM_HPF_RE		BIT(2)
738c2ecf20Sopenharmony_ci#define PDM_HPF_CF_MSK		(0x3 << 0)
748c2ecf20Sopenharmony_ci#define PDM_HPF_3P79HZ		(0x0 << 0)
758c2ecf20Sopenharmony_ci#define PDM_HPF_60HZ		(0x1 << 0)
768c2ecf20Sopenharmony_ci#define PDM_HPF_243HZ		(0x2 << 0)
778c2ecf20Sopenharmony_ci#define PDM_HPF_493HZ		(0x3 << 0)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* PDM DMA CTRL */
808c2ecf20Sopenharmony_ci#define PDM_DMA_RD_MSK		BIT(8)
818c2ecf20Sopenharmony_ci#define PDM_DMA_RD_EN		BIT(8)
828c2ecf20Sopenharmony_ci#define PDM_DMA_RD_DIS		(0x0 << 8)
838c2ecf20Sopenharmony_ci#define PDM_DMA_RDL_MSK		(0x7f << 0)
848c2ecf20Sopenharmony_ci#define PDM_DMA_RDL(X)		((X - 1) << 0)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#endif /* _ROCKCHIP_PDM_H */
87