18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * OMAP Multi-Channel Buffered Serial Port
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
68c2ecf20Sopenharmony_ci *          Peter Ujfalusi <peter.ujfalusi@ti.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __OMAP_MCBSP_PRIV_H__
108c2ecf20Sopenharmony_ci#define __OMAP_MCBSP_PRIV_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/platform_data/asoc-ti-mcbsp.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP1
158c2ecf20Sopenharmony_ci#define mcbsp_omap1()	1
168c2ecf20Sopenharmony_ci#else
178c2ecf20Sopenharmony_ci#define mcbsp_omap1()	0
188c2ecf20Sopenharmony_ci#endif
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* McBSP register numbers. Register address offset = num * reg_step */
218c2ecf20Sopenharmony_cienum {
228c2ecf20Sopenharmony_ci	/* Common registers */
238c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SPCR2 = 4,
248c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SPCR1,
258c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCR2,
268c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCR1,
278c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCR2,
288c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCR1,
298c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SRGR2,
308c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SRGR1,
318c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_MCR2,
328c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_MCR1,
338c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERA,
348c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERB,
358c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERA,
368c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERB,
378c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_PCR0,
388c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERC,
398c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERD,
408c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERC,
418c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERD,
428c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERE,
438c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERF,
448c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERE,
458c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERF,
468c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERG,
478c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCERH,
488c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERG,
498c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCERH,
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	/* OMAP1-OMAP2420 registers */
528c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DRR2 = 0,
538c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DRR1,
548c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DXR2,
558c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DXR1,
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/* OMAP2430 and onwards */
588c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DRR = 0,
598c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_DXR = 2,
608c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SYSCON =	35,
618c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_THRSH2,
628c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_THRSH1,
638c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_IRQST = 40,
648c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_IRQEN,
658c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_WAKEUPEN,
668c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XCCR,
678c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RCCR,
688c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_XBUFFSTAT,
698c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_RBUFFSTAT,
708c2ecf20Sopenharmony_ci	OMAP_MCBSP_REG_SSELCR,
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/************************** McBSP SPCR1 bit definitions ***********************/
748c2ecf20Sopenharmony_ci#define RRST			BIT(0)
758c2ecf20Sopenharmony_ci#define RRDY			BIT(1)
768c2ecf20Sopenharmony_ci#define RFULL			BIT(2)
778c2ecf20Sopenharmony_ci#define RSYNC_ERR		BIT(3)
788c2ecf20Sopenharmony_ci#define RINTM(value)		(((value) & 0x3) << 4)	/* bits 4:5 */
798c2ecf20Sopenharmony_ci#define ABIS			BIT(6)
808c2ecf20Sopenharmony_ci#define DXENA			BIT(7)
818c2ecf20Sopenharmony_ci#define CLKSTP(value)		(((value) & 0x3) << 11)	/* bits 11:12 */
828c2ecf20Sopenharmony_ci#define RJUST(value)		(((value) & 0x3) << 13)	/* bits 13:14 */
838c2ecf20Sopenharmony_ci#define ALB			BIT(15)
848c2ecf20Sopenharmony_ci#define DLB			BIT(15)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/************************** McBSP SPCR2 bit definitions ***********************/
878c2ecf20Sopenharmony_ci#define XRST			BIT(0)
888c2ecf20Sopenharmony_ci#define XRDY			BIT(1)
898c2ecf20Sopenharmony_ci#define XEMPTY			BIT(2)
908c2ecf20Sopenharmony_ci#define XSYNC_ERR		BIT(3)
918c2ecf20Sopenharmony_ci#define XINTM(value)		(((value) & 0x3) << 4)	/* bits 4:5 */
928c2ecf20Sopenharmony_ci#define GRST			BIT(6)
938c2ecf20Sopenharmony_ci#define FRST			BIT(7)
948c2ecf20Sopenharmony_ci#define SOFT			BIT(8)
958c2ecf20Sopenharmony_ci#define FREE			BIT(9)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/************************** McBSP PCR bit definitions *************************/
988c2ecf20Sopenharmony_ci#define CLKRP			BIT(0)
998c2ecf20Sopenharmony_ci#define CLKXP			BIT(1)
1008c2ecf20Sopenharmony_ci#define FSRP			BIT(2)
1018c2ecf20Sopenharmony_ci#define FSXP			BIT(3)
1028c2ecf20Sopenharmony_ci#define DR_STAT			BIT(4)
1038c2ecf20Sopenharmony_ci#define DX_STAT			BIT(5)
1048c2ecf20Sopenharmony_ci#define CLKS_STAT		BIT(6)
1058c2ecf20Sopenharmony_ci#define SCLKME			BIT(7)
1068c2ecf20Sopenharmony_ci#define CLKRM			BIT(8)
1078c2ecf20Sopenharmony_ci#define CLKXM			BIT(9)
1088c2ecf20Sopenharmony_ci#define FSRM			BIT(10)
1098c2ecf20Sopenharmony_ci#define FSXM			BIT(11)
1108c2ecf20Sopenharmony_ci#define RIOEN			BIT(12)
1118c2ecf20Sopenharmony_ci#define XIOEN			BIT(13)
1128c2ecf20Sopenharmony_ci#define IDLE_EN			BIT(14)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/************************** McBSP RCR1 bit definitions ************************/
1158c2ecf20Sopenharmony_ci#define RWDLEN1(value)		(((value) & 0x7) << 5)	/* Bits 5:7 */
1168c2ecf20Sopenharmony_ci#define RFRLEN1(value)		(((value) & 0x7f) << 8)	/* Bits 8:14 */
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/************************** McBSP XCR1 bit definitions ************************/
1198c2ecf20Sopenharmony_ci#define XWDLEN1(value)		(((value) & 0x7) << 5)	/* Bits 5:7 */
1208c2ecf20Sopenharmony_ci#define XFRLEN1(value)		(((value) & 0x7f) << 8)	/* Bits 8:14 */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/*************************** McBSP RCR2 bit definitions ***********************/
1238c2ecf20Sopenharmony_ci#define RDATDLY(value)		((value) & 0x3)		/* Bits 0:1 */
1248c2ecf20Sopenharmony_ci#define RFIG			BIT(2)
1258c2ecf20Sopenharmony_ci#define RCOMPAND(value)		(((value) & 0x3) << 3)	/* Bits 3:4 */
1268c2ecf20Sopenharmony_ci#define RWDLEN2(value)		(((value) & 0x7) << 5)	/* Bits 5:7 */
1278c2ecf20Sopenharmony_ci#define RFRLEN2(value)		(((value) & 0x7f) << 8)	/* Bits 8:14 */
1288c2ecf20Sopenharmony_ci#define RPHASE			BIT(15)
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/*************************** McBSP XCR2 bit definitions ***********************/
1318c2ecf20Sopenharmony_ci#define XDATDLY(value)		((value) & 0x3)		/* Bits 0:1 */
1328c2ecf20Sopenharmony_ci#define XFIG			BIT(2)
1338c2ecf20Sopenharmony_ci#define XCOMPAND(value)		(((value) & 0x3) << 3)	/* Bits 3:4 */
1348c2ecf20Sopenharmony_ci#define XWDLEN2(value)		(((value) & 0x7) << 5)	/* Bits 5:7 */
1358c2ecf20Sopenharmony_ci#define XFRLEN2(value)		(((value) & 0x7f) << 8)	/* Bits 8:14 */
1368c2ecf20Sopenharmony_ci#define XPHASE			BIT(15)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/************************* McBSP SRGR1 bit definitions ************************/
1398c2ecf20Sopenharmony_ci#define CLKGDV(value)		((value) & 0x7f)		/* Bits 0:7 */
1408c2ecf20Sopenharmony_ci#define FWID(value)		(((value) & 0xff) << 8)	/* Bits 8:15 */
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/************************* McBSP SRGR2 bit definitions ************************/
1438c2ecf20Sopenharmony_ci#define FPER(value)		((value) & 0x0fff)	/* Bits 0:11 */
1448c2ecf20Sopenharmony_ci#define FSGM			BIT(12)
1458c2ecf20Sopenharmony_ci#define CLKSM			BIT(13)
1468c2ecf20Sopenharmony_ci#define CLKSP			BIT(14)
1478c2ecf20Sopenharmony_ci#define GSYNC			BIT(15)
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/************************* McBSP MCR1 bit definitions *************************/
1508c2ecf20Sopenharmony_ci#define RMCM			BIT(0)
1518c2ecf20Sopenharmony_ci#define RCBLK(value)		(((value) & 0x7) << 2)	/* Bits 2:4 */
1528c2ecf20Sopenharmony_ci#define RPABLK(value)		(((value) & 0x3) << 5)	/* Bits 5:6 */
1538c2ecf20Sopenharmony_ci#define RPBBLK(value)		(((value) & 0x3) << 7)	/* Bits 7:8 */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci/************************* McBSP MCR2 bit definitions *************************/
1568c2ecf20Sopenharmony_ci#define XMCM(value)		((value) & 0x3)		/* Bits 0:1 */
1578c2ecf20Sopenharmony_ci#define XCBLK(value)		(((value) & 0x7) << 2)	/* Bits 2:4 */
1588c2ecf20Sopenharmony_ci#define XPABLK(value)		(((value) & 0x3) << 5)	/* Bits 5:6 */
1598c2ecf20Sopenharmony_ci#define XPBBLK(value)		(((value) & 0x3) << 7)	/* Bits 7:8 */
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci/*********************** McBSP XCCR bit definitions *************************/
1628c2ecf20Sopenharmony_ci#define XDISABLE		BIT(0)
1638c2ecf20Sopenharmony_ci#define XDMAEN			BIT(3)
1648c2ecf20Sopenharmony_ci#define DILB			BIT(5)
1658c2ecf20Sopenharmony_ci#define XFULL_CYCLE		BIT(11)
1668c2ecf20Sopenharmony_ci#define DXENDLY(value)		(((value) & 0x3) << 12)	/* Bits 12:13 */
1678c2ecf20Sopenharmony_ci#define PPCONNECT		BIT(14)
1688c2ecf20Sopenharmony_ci#define EXTCLKGATE		BIT(15)
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/********************** McBSP RCCR bit definitions *************************/
1718c2ecf20Sopenharmony_ci#define RDISABLE		BIT(0)
1728c2ecf20Sopenharmony_ci#define RDMAEN			BIT(3)
1738c2ecf20Sopenharmony_ci#define RFULL_CYCLE		BIT(11)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/********************** McBSP SYSCONFIG bit definitions ********************/
1768c2ecf20Sopenharmony_ci#define SOFTRST			BIT(1)
1778c2ecf20Sopenharmony_ci#define ENAWAKEUP		BIT(2)
1788c2ecf20Sopenharmony_ci#define SIDLEMODE(value)	(((value) & 0x3) << 3)
1798c2ecf20Sopenharmony_ci#define CLOCKACTIVITY(value)	(((value) & 0x3) << 8)
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci/********************** McBSP DMA operating modes **************************/
1828c2ecf20Sopenharmony_ci#define MCBSP_DMA_MODE_ELEMENT		0
1838c2ecf20Sopenharmony_ci#define MCBSP_DMA_MODE_THRESHOLD	1
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/********************** McBSP WAKEUPEN/IRQST/IRQEN bit definitions *********/
1868c2ecf20Sopenharmony_ci#define RSYNCERREN		BIT(0)
1878c2ecf20Sopenharmony_ci#define RFSREN			BIT(1)
1888c2ecf20Sopenharmony_ci#define REOFEN			BIT(2)
1898c2ecf20Sopenharmony_ci#define RRDYEN			BIT(3)
1908c2ecf20Sopenharmony_ci#define RUNDFLEN		BIT(4)
1918c2ecf20Sopenharmony_ci#define ROVFLEN			BIT(5)
1928c2ecf20Sopenharmony_ci#define XSYNCERREN		BIT(7)
1938c2ecf20Sopenharmony_ci#define XFSXEN			BIT(8)
1948c2ecf20Sopenharmony_ci#define XEOFEN			BIT(9)
1958c2ecf20Sopenharmony_ci#define XRDYEN			BIT(10)
1968c2ecf20Sopenharmony_ci#define XUNDFLEN		BIT(11)
1978c2ecf20Sopenharmony_ci#define XOVFLEN			BIT(12)
1988c2ecf20Sopenharmony_ci#define XEMPTYEOFEN		BIT(14)
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* Clock signal muxing options */
2018c2ecf20Sopenharmony_ci#define CLKR_SRC_CLKR		0 /* CLKR signal is from the CLKR pin */
2028c2ecf20Sopenharmony_ci#define CLKR_SRC_CLKX		1 /* CLKR signal is from the CLKX pin */
2038c2ecf20Sopenharmony_ci#define FSR_SRC_FSR		2 /* FSR signal is from the FSR pin */
2048c2ecf20Sopenharmony_ci#define FSR_SRC_FSX		3 /* FSR signal is from the FSX pin */
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/* McBSP functional clock sources */
2078c2ecf20Sopenharmony_ci#define MCBSP_CLKS_PRCM_SRC	0
2088c2ecf20Sopenharmony_ci#define MCBSP_CLKS_PAD_SRC	1
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci/* we don't do multichannel for now */
2118c2ecf20Sopenharmony_cistruct omap_mcbsp_reg_cfg {
2128c2ecf20Sopenharmony_ci	u16 spcr2;
2138c2ecf20Sopenharmony_ci	u16 spcr1;
2148c2ecf20Sopenharmony_ci	u16 rcr2;
2158c2ecf20Sopenharmony_ci	u16 rcr1;
2168c2ecf20Sopenharmony_ci	u16 xcr2;
2178c2ecf20Sopenharmony_ci	u16 xcr1;
2188c2ecf20Sopenharmony_ci	u16 srgr2;
2198c2ecf20Sopenharmony_ci	u16 srgr1;
2208c2ecf20Sopenharmony_ci	u16 mcr2;
2218c2ecf20Sopenharmony_ci	u16 mcr1;
2228c2ecf20Sopenharmony_ci	u16 pcr0;
2238c2ecf20Sopenharmony_ci	u16 rcerc;
2248c2ecf20Sopenharmony_ci	u16 rcerd;
2258c2ecf20Sopenharmony_ci	u16 xcerc;
2268c2ecf20Sopenharmony_ci	u16 xcerd;
2278c2ecf20Sopenharmony_ci	u16 rcere;
2288c2ecf20Sopenharmony_ci	u16 rcerf;
2298c2ecf20Sopenharmony_ci	u16 xcere;
2308c2ecf20Sopenharmony_ci	u16 xcerf;
2318c2ecf20Sopenharmony_ci	u16 rcerg;
2328c2ecf20Sopenharmony_ci	u16 rcerh;
2338c2ecf20Sopenharmony_ci	u16 xcerg;
2348c2ecf20Sopenharmony_ci	u16 xcerh;
2358c2ecf20Sopenharmony_ci	u16 xccr;
2368c2ecf20Sopenharmony_ci	u16 rccr;
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistruct omap_mcbsp_st_data;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistruct omap_mcbsp {
2428c2ecf20Sopenharmony_ci	struct device *dev;
2438c2ecf20Sopenharmony_ci	struct clk *fclk;
2448c2ecf20Sopenharmony_ci	spinlock_t lock;
2458c2ecf20Sopenharmony_ci	unsigned long phys_base;
2468c2ecf20Sopenharmony_ci	unsigned long phys_dma_base;
2478c2ecf20Sopenharmony_ci	void __iomem *io_base;
2488c2ecf20Sopenharmony_ci	u8 id;
2498c2ecf20Sopenharmony_ci	/*
2508c2ecf20Sopenharmony_ci	 * Flags indicating is the bus already activated and configured by
2518c2ecf20Sopenharmony_ci	 * another substream
2528c2ecf20Sopenharmony_ci	 */
2538c2ecf20Sopenharmony_ci	int active;
2548c2ecf20Sopenharmony_ci	int configured;
2558c2ecf20Sopenharmony_ci	u8 free;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	int irq;
2588c2ecf20Sopenharmony_ci	int rx_irq;
2598c2ecf20Sopenharmony_ci	int tx_irq;
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	/* Protect the field .free, while checking if the mcbsp is in use */
2628c2ecf20Sopenharmony_ci	struct omap_mcbsp_platform_data *pdata;
2638c2ecf20Sopenharmony_ci	struct omap_mcbsp_st_data *st_data;
2648c2ecf20Sopenharmony_ci	struct omap_mcbsp_reg_cfg cfg_regs;
2658c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data dma_data[2];
2668c2ecf20Sopenharmony_ci	unsigned int dma_req[2];
2678c2ecf20Sopenharmony_ci	int dma_op_mode;
2688c2ecf20Sopenharmony_ci	u16 max_tx_thres;
2698c2ecf20Sopenharmony_ci	u16 max_rx_thres;
2708c2ecf20Sopenharmony_ci	void *reg_cache;
2718c2ecf20Sopenharmony_ci	int reg_cache_size;
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	unsigned int fmt;
2748c2ecf20Sopenharmony_ci	unsigned int in_freq;
2758c2ecf20Sopenharmony_ci	unsigned int latency[2];
2768c2ecf20Sopenharmony_ci	int clk_div;
2778c2ecf20Sopenharmony_ci	int wlen;
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	struct pm_qos_request pm_qos_req;
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistatic inline void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
2838c2ecf20Sopenharmony_ci{
2848c2ecf20Sopenharmony_ci	void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step;
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	if (mcbsp->pdata->reg_size == 2) {
2878c2ecf20Sopenharmony_ci		((u16 *)mcbsp->reg_cache)[reg] = (u16)val;
2888c2ecf20Sopenharmony_ci		writew_relaxed((u16)val, addr);
2898c2ecf20Sopenharmony_ci	} else {
2908c2ecf20Sopenharmony_ci		((u32 *)mcbsp->reg_cache)[reg] = val;
2918c2ecf20Sopenharmony_ci		writel_relaxed(val, addr);
2928c2ecf20Sopenharmony_ci	}
2938c2ecf20Sopenharmony_ci}
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cistatic inline int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg,
2968c2ecf20Sopenharmony_ci				  bool from_cache)
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	if (mcbsp->pdata->reg_size == 2) {
3018c2ecf20Sopenharmony_ci		return !from_cache ? readw_relaxed(addr) :
3028c2ecf20Sopenharmony_ci				     ((u16 *)mcbsp->reg_cache)[reg];
3038c2ecf20Sopenharmony_ci	} else {
3048c2ecf20Sopenharmony_ci		return !from_cache ? readl_relaxed(addr) :
3058c2ecf20Sopenharmony_ci				     ((u32 *)mcbsp->reg_cache)[reg];
3068c2ecf20Sopenharmony_ci	}
3078c2ecf20Sopenharmony_ci}
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci#define MCBSP_READ(mcbsp, reg) \
3108c2ecf20Sopenharmony_ci		omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 0)
3118c2ecf20Sopenharmony_ci#define MCBSP_WRITE(mcbsp, reg, val) \
3128c2ecf20Sopenharmony_ci		omap_mcbsp_write(mcbsp, OMAP_MCBSP_REG_##reg, val)
3138c2ecf20Sopenharmony_ci#define MCBSP_READ_CACHE(mcbsp, reg) \
3148c2ecf20Sopenharmony_ci		omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci/* Sidetone specific API */
3188c2ecf20Sopenharmony_ciint omap_mcbsp_st_init(struct platform_device *pdev);
3198c2ecf20Sopenharmony_civoid omap_mcbsp_st_cleanup(struct platform_device *pdev);
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ciint omap_mcbsp_st_start(struct omap_mcbsp *mcbsp);
3228c2ecf20Sopenharmony_ciint omap_mcbsp_st_stop(struct omap_mcbsp *mcbsp);
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci#endif /* __OMAP_MCBSP_PRIV_H__ */
325