18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) ST-Ericsson SA 2012
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Ola Lilja <ola.o.lilja@stericsson.com>,
68c2ecf20Sopenharmony_ci *         for ST-Ericsson.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * License terms:
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef UX500_MSP_I2S_H
138c2ecf20Sopenharmony_ci#define UX500_MSP_I2S_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
168c2ecf20Sopenharmony_ci#include <linux/platform_data/asoc-ux500-msp.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define MSP_INPUT_FREQ_APB 48000000
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/*** Stereo mode. Used for APB data accesses as 16 bits accesses (mono),
218c2ecf20Sopenharmony_ci *   32 bits accesses (stereo).
228c2ecf20Sopenharmony_ci ***/
238c2ecf20Sopenharmony_cienum msp_stereo_mode {
248c2ecf20Sopenharmony_ci	MSP_MONO,
258c2ecf20Sopenharmony_ci	MSP_STEREO
268c2ecf20Sopenharmony_ci};
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Direction (Transmit/Receive mode) */
298c2ecf20Sopenharmony_cienum msp_direction {
308c2ecf20Sopenharmony_ci	MSP_TX = 1,
318c2ecf20Sopenharmony_ci	MSP_RX = 2
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* Transmit and receive configuration register */
358c2ecf20Sopenharmony_ci#define MSP_BIG_ENDIAN           0x00000000
368c2ecf20Sopenharmony_ci#define MSP_LITTLE_ENDIAN        0x00001000
378c2ecf20Sopenharmony_ci#define MSP_UNEXPECTED_FS_ABORT  0x00000000
388c2ecf20Sopenharmony_ci#define MSP_UNEXPECTED_FS_IGNORE 0x00008000
398c2ecf20Sopenharmony_ci#define MSP_NON_MODE_BIT_MASK    0x00009000
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* Global configuration register */
428c2ecf20Sopenharmony_ci#define RX_ENABLE             0x00000001
438c2ecf20Sopenharmony_ci#define RX_FIFO_ENABLE        0x00000002
448c2ecf20Sopenharmony_ci#define RX_SYNC_SRG           0x00000010
458c2ecf20Sopenharmony_ci#define RX_CLK_POL_RISING     0x00000020
468c2ecf20Sopenharmony_ci#define RX_CLK_SEL_SRG        0x00000040
478c2ecf20Sopenharmony_ci#define TX_ENABLE             0x00000100
488c2ecf20Sopenharmony_ci#define TX_FIFO_ENABLE        0x00000200
498c2ecf20Sopenharmony_ci#define TX_SYNC_SRG_PROG      0x00001800
508c2ecf20Sopenharmony_ci#define TX_SYNC_SRG_AUTO      0x00001000
518c2ecf20Sopenharmony_ci#define TX_CLK_POL_RISING     0x00002000
528c2ecf20Sopenharmony_ci#define TX_CLK_SEL_SRG        0x00004000
538c2ecf20Sopenharmony_ci#define TX_EXTRA_DELAY_ENABLE 0x00008000
548c2ecf20Sopenharmony_ci#define SRG_ENABLE            0x00010000
558c2ecf20Sopenharmony_ci#define FRAME_GEN_ENABLE      0x00100000
568c2ecf20Sopenharmony_ci#define SRG_CLK_SEL_APB       0x00000000
578c2ecf20Sopenharmony_ci#define RX_FIFO_SYNC_HI       0x00000000
588c2ecf20Sopenharmony_ci#define TX_FIFO_SYNC_HI       0x00000000
598c2ecf20Sopenharmony_ci#define SPI_CLK_MODE_NORMAL   0x00000000
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define MSP_FRAME_SIZE_AUTO -1
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define MSP_DR		0x00
648c2ecf20Sopenharmony_ci#define MSP_GCR		0x04
658c2ecf20Sopenharmony_ci#define MSP_TCF		0x08
668c2ecf20Sopenharmony_ci#define MSP_RCF		0x0c
678c2ecf20Sopenharmony_ci#define MSP_SRG		0x10
688c2ecf20Sopenharmony_ci#define MSP_FLR		0x14
698c2ecf20Sopenharmony_ci#define MSP_DMACR	0x18
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define MSP_IMSC	0x20
728c2ecf20Sopenharmony_ci#define MSP_RIS		0x24
738c2ecf20Sopenharmony_ci#define MSP_MIS		0x28
748c2ecf20Sopenharmony_ci#define MSP_ICR		0x2c
758c2ecf20Sopenharmony_ci#define MSP_MCR		0x30
768c2ecf20Sopenharmony_ci#define MSP_RCV		0x34
778c2ecf20Sopenharmony_ci#define MSP_RCM		0x38
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define MSP_TCE0	0x40
808c2ecf20Sopenharmony_ci#define MSP_TCE1	0x44
818c2ecf20Sopenharmony_ci#define MSP_TCE2	0x48
828c2ecf20Sopenharmony_ci#define MSP_TCE3	0x4c
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define MSP_RCE0	0x60
858c2ecf20Sopenharmony_ci#define MSP_RCE1	0x64
868c2ecf20Sopenharmony_ci#define MSP_RCE2	0x68
878c2ecf20Sopenharmony_ci#define MSP_RCE3	0x6c
888c2ecf20Sopenharmony_ci#define MSP_IODLY	0x70
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define MSP_ITCR	0x80
918c2ecf20Sopenharmony_ci#define MSP_ITIP	0x84
928c2ecf20Sopenharmony_ci#define MSP_ITOP	0x88
938c2ecf20Sopenharmony_ci#define MSP_TSTDR	0x8c
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define MSP_PID0	0xfe0
968c2ecf20Sopenharmony_ci#define MSP_PID1	0xfe4
978c2ecf20Sopenharmony_ci#define MSP_PID2	0xfe8
988c2ecf20Sopenharmony_ci#define MSP_PID3	0xfec
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define MSP_CID0	0xff0
1018c2ecf20Sopenharmony_ci#define MSP_CID1	0xff4
1028c2ecf20Sopenharmony_ci#define MSP_CID2	0xff8
1038c2ecf20Sopenharmony_ci#define MSP_CID3	0xffc
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/* Protocol dependant parameters list */
1068c2ecf20Sopenharmony_ci#define RX_ENABLE_MASK		BIT(0)
1078c2ecf20Sopenharmony_ci#define RX_FIFO_ENABLE_MASK	BIT(1)
1088c2ecf20Sopenharmony_ci#define RX_FSYNC_MASK		BIT(2)
1098c2ecf20Sopenharmony_ci#define DIRECT_COMPANDING_MASK	BIT(3)
1108c2ecf20Sopenharmony_ci#define RX_SYNC_SEL_MASK	BIT(4)
1118c2ecf20Sopenharmony_ci#define RX_CLK_POL_MASK		BIT(5)
1128c2ecf20Sopenharmony_ci#define RX_CLK_SEL_MASK		BIT(6)
1138c2ecf20Sopenharmony_ci#define LOOPBACK_MASK		BIT(7)
1148c2ecf20Sopenharmony_ci#define TX_ENABLE_MASK		BIT(8)
1158c2ecf20Sopenharmony_ci#define TX_FIFO_ENABLE_MASK	BIT(9)
1168c2ecf20Sopenharmony_ci#define TX_FSYNC_MASK		BIT(10)
1178c2ecf20Sopenharmony_ci#define TX_MSP_TDR_TSR		BIT(11)
1188c2ecf20Sopenharmony_ci#define TX_SYNC_SEL_MASK	(BIT(12) | BIT(11))
1198c2ecf20Sopenharmony_ci#define TX_CLK_POL_MASK		BIT(13)
1208c2ecf20Sopenharmony_ci#define TX_CLK_SEL_MASK		BIT(14)
1218c2ecf20Sopenharmony_ci#define TX_EXTRA_DELAY_MASK	BIT(15)
1228c2ecf20Sopenharmony_ci#define SRG_ENABLE_MASK		BIT(16)
1238c2ecf20Sopenharmony_ci#define SRG_CLK_POL_MASK	BIT(17)
1248c2ecf20Sopenharmony_ci#define SRG_CLK_SEL_MASK	(BIT(19) | BIT(18))
1258c2ecf20Sopenharmony_ci#define FRAME_GEN_EN_MASK	BIT(20)
1268c2ecf20Sopenharmony_ci#define SPI_CLK_MODE_MASK	(BIT(22) | BIT(21))
1278c2ecf20Sopenharmony_ci#define SPI_BURST_MODE_MASK	BIT(23)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define RXEN_SHIFT		0
1308c2ecf20Sopenharmony_ci#define RFFEN_SHIFT		1
1318c2ecf20Sopenharmony_ci#define RFSPOL_SHIFT		2
1328c2ecf20Sopenharmony_ci#define DCM_SHIFT		3
1338c2ecf20Sopenharmony_ci#define RFSSEL_SHIFT		4
1348c2ecf20Sopenharmony_ci#define RCKPOL_SHIFT		5
1358c2ecf20Sopenharmony_ci#define RCKSEL_SHIFT		6
1368c2ecf20Sopenharmony_ci#define LBM_SHIFT		7
1378c2ecf20Sopenharmony_ci#define TXEN_SHIFT		8
1388c2ecf20Sopenharmony_ci#define TFFEN_SHIFT		9
1398c2ecf20Sopenharmony_ci#define TFSPOL_SHIFT		10
1408c2ecf20Sopenharmony_ci#define TFSSEL_SHIFT		11
1418c2ecf20Sopenharmony_ci#define TCKPOL_SHIFT		13
1428c2ecf20Sopenharmony_ci#define TCKSEL_SHIFT		14
1438c2ecf20Sopenharmony_ci#define TXDDL_SHIFT		15
1448c2ecf20Sopenharmony_ci#define SGEN_SHIFT		16
1458c2ecf20Sopenharmony_ci#define SCKPOL_SHIFT		17
1468c2ecf20Sopenharmony_ci#define SCKSEL_SHIFT		18
1478c2ecf20Sopenharmony_ci#define FGEN_SHIFT		20
1488c2ecf20Sopenharmony_ci#define SPICKM_SHIFT		21
1498c2ecf20Sopenharmony_ci#define TBSWAP_SHIFT		28
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define RCKPOL_MASK		BIT(0)
1528c2ecf20Sopenharmony_ci#define TCKPOL_MASK		BIT(0)
1538c2ecf20Sopenharmony_ci#define SPICKM_MASK		(BIT(1) | BIT(0))
1548c2ecf20Sopenharmony_ci#define MSP_RX_CLKPOL_BIT(n)     ((n & RCKPOL_MASK) << RCKPOL_SHIFT)
1558c2ecf20Sopenharmony_ci#define MSP_TX_CLKPOL_BIT(n)     ((n & TCKPOL_MASK) << TCKPOL_SHIFT)
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#define P1ELEN_SHIFT		0
1588c2ecf20Sopenharmony_ci#define P1FLEN_SHIFT		3
1598c2ecf20Sopenharmony_ci#define DTYP_SHIFT		10
1608c2ecf20Sopenharmony_ci#define ENDN_SHIFT		12
1618c2ecf20Sopenharmony_ci#define DDLY_SHIFT		13
1628c2ecf20Sopenharmony_ci#define FSIG_SHIFT		15
1638c2ecf20Sopenharmony_ci#define P2ELEN_SHIFT		16
1648c2ecf20Sopenharmony_ci#define P2FLEN_SHIFT		19
1658c2ecf20Sopenharmony_ci#define P2SM_SHIFT		26
1668c2ecf20Sopenharmony_ci#define P2EN_SHIFT		27
1678c2ecf20Sopenharmony_ci#define FSYNC_SHIFT		15
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define P1ELEN_MASK		0x00000007
1708c2ecf20Sopenharmony_ci#define P2ELEN_MASK		0x00070000
1718c2ecf20Sopenharmony_ci#define P1FLEN_MASK		0x00000378
1728c2ecf20Sopenharmony_ci#define P2FLEN_MASK		0x03780000
1738c2ecf20Sopenharmony_ci#define DDLY_MASK		0x00003000
1748c2ecf20Sopenharmony_ci#define DTYP_MASK		0x00000600
1758c2ecf20Sopenharmony_ci#define P2SM_MASK		0x04000000
1768c2ecf20Sopenharmony_ci#define P2EN_MASK		0x08000000
1778c2ecf20Sopenharmony_ci#define ENDN_MASK		0x00001000
1788c2ecf20Sopenharmony_ci#define TFSPOL_MASK		0x00000400
1798c2ecf20Sopenharmony_ci#define TBSWAP_MASK		0x30000000
1808c2ecf20Sopenharmony_ci#define COMPANDING_MODE_MASK	0x00000c00
1818c2ecf20Sopenharmony_ci#define FSYNC_MASK		0x00008000
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#define MSP_P1_ELEM_LEN_BITS(n)		(n & P1ELEN_MASK)
1848c2ecf20Sopenharmony_ci#define MSP_P2_ELEM_LEN_BITS(n)		(((n) << P2ELEN_SHIFT) & P2ELEN_MASK)
1858c2ecf20Sopenharmony_ci#define MSP_P1_FRAME_LEN_BITS(n)	(((n) << P1FLEN_SHIFT) & P1FLEN_MASK)
1868c2ecf20Sopenharmony_ci#define MSP_P2_FRAME_LEN_BITS(n)	(((n) << P2FLEN_SHIFT) & P2FLEN_MASK)
1878c2ecf20Sopenharmony_ci#define MSP_DATA_DELAY_BITS(n)		(((n) << DDLY_SHIFT) & DDLY_MASK)
1888c2ecf20Sopenharmony_ci#define MSP_DATA_TYPE_BITS(n)		(((n) << DTYP_SHIFT) & DTYP_MASK)
1898c2ecf20Sopenharmony_ci#define MSP_P2_START_MODE_BIT(n)	((n << P2SM_SHIFT) & P2SM_MASK)
1908c2ecf20Sopenharmony_ci#define MSP_P2_ENABLE_BIT(n)		((n << P2EN_SHIFT) & P2EN_MASK)
1918c2ecf20Sopenharmony_ci#define MSP_SET_ENDIANNES_BIT(n)	((n << ENDN_SHIFT) & ENDN_MASK)
1928c2ecf20Sopenharmony_ci#define MSP_FSYNC_POL(n)		((n << TFSPOL_SHIFT) & TFSPOL_MASK)
1938c2ecf20Sopenharmony_ci#define MSP_DATA_WORD_SWAP(n)		((n << TBSWAP_SHIFT) & TBSWAP_MASK)
1948c2ecf20Sopenharmony_ci#define MSP_SET_COMPANDING_MODE(n)	((n << DTYP_SHIFT) & \
1958c2ecf20Sopenharmony_ci						COMPANDING_MODE_MASK)
1968c2ecf20Sopenharmony_ci#define MSP_SET_FSYNC_IGNORE(n)		((n << FSYNC_SHIFT) & FSYNC_MASK)
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/* Flag register */
1998c2ecf20Sopenharmony_ci#define RX_BUSY			BIT(0)
2008c2ecf20Sopenharmony_ci#define RX_FIFO_EMPTY		BIT(1)
2018c2ecf20Sopenharmony_ci#define RX_FIFO_FULL		BIT(2)
2028c2ecf20Sopenharmony_ci#define TX_BUSY			BIT(3)
2038c2ecf20Sopenharmony_ci#define TX_FIFO_EMPTY		BIT(4)
2048c2ecf20Sopenharmony_ci#define TX_FIFO_FULL		BIT(5)
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci#define RBUSY_SHIFT		0
2078c2ecf20Sopenharmony_ci#define RFE_SHIFT		1
2088c2ecf20Sopenharmony_ci#define RFU_SHIFT		2
2098c2ecf20Sopenharmony_ci#define TBUSY_SHIFT		3
2108c2ecf20Sopenharmony_ci#define TFE_SHIFT		4
2118c2ecf20Sopenharmony_ci#define TFU_SHIFT		5
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* Multichannel control register */
2148c2ecf20Sopenharmony_ci#define RMCEN_SHIFT		0
2158c2ecf20Sopenharmony_ci#define RMCSF_SHIFT		1
2168c2ecf20Sopenharmony_ci#define RCMPM_SHIFT		3
2178c2ecf20Sopenharmony_ci#define TMCEN_SHIFT		5
2188c2ecf20Sopenharmony_ci#define TNCSF_SHIFT		6
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci/* Sample rate generator register */
2218c2ecf20Sopenharmony_ci#define SCKDIV_SHIFT		0
2228c2ecf20Sopenharmony_ci#define FRWID_SHIFT		10
2238c2ecf20Sopenharmony_ci#define FRPER_SHIFT		16
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci#define SCK_DIV_MASK		0x0000003FF
2268c2ecf20Sopenharmony_ci#define FRAME_WIDTH_BITS(n)	(((n) << FRWID_SHIFT)  & 0x0000FC00)
2278c2ecf20Sopenharmony_ci#define FRAME_PERIOD_BITS(n)	(((n) << FRPER_SHIFT) & 0x1FFF0000)
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/* DMA controller register */
2308c2ecf20Sopenharmony_ci#define RX_DMA_ENABLE		BIT(0)
2318c2ecf20Sopenharmony_ci#define TX_DMA_ENABLE		BIT(1)
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define RDMAE_SHIFT		0
2348c2ecf20Sopenharmony_ci#define TDMAE_SHIFT		1
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci/* Interrupt Register */
2378c2ecf20Sopenharmony_ci#define RX_SERVICE_INT		BIT(0)
2388c2ecf20Sopenharmony_ci#define RX_OVERRUN_ERROR_INT	BIT(1)
2398c2ecf20Sopenharmony_ci#define RX_FSYNC_ERR_INT	BIT(2)
2408c2ecf20Sopenharmony_ci#define RX_FSYNC_INT		BIT(3)
2418c2ecf20Sopenharmony_ci#define TX_SERVICE_INT		BIT(4)
2428c2ecf20Sopenharmony_ci#define TX_UNDERRUN_ERR_INT	BIT(5)
2438c2ecf20Sopenharmony_ci#define TX_FSYNC_ERR_INT	BIT(6)
2448c2ecf20Sopenharmony_ci#define TX_FSYNC_INT		BIT(7)
2458c2ecf20Sopenharmony_ci#define ALL_INT			0x000000ff
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci/* MSP test control register */
2488c2ecf20Sopenharmony_ci#define MSP_ITCR_ITEN		BIT(0)
2498c2ecf20Sopenharmony_ci#define MSP_ITCR_TESTFIFO	BIT(1)
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci#define RMCEN_BIT   0
2528c2ecf20Sopenharmony_ci#define RMCSF_BIT   1
2538c2ecf20Sopenharmony_ci#define RCMPM_BIT   3
2548c2ecf20Sopenharmony_ci#define TMCEN_BIT   5
2558c2ecf20Sopenharmony_ci#define TNCSF_BIT   6
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/* Single or dual phase mode */
2588c2ecf20Sopenharmony_cienum msp_phase_mode {
2598c2ecf20Sopenharmony_ci	MSP_SINGLE_PHASE,
2608c2ecf20Sopenharmony_ci	MSP_DUAL_PHASE
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci/* Frame length */
2648c2ecf20Sopenharmony_cienum msp_frame_length {
2658c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_1 = 0,
2668c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_2 = 1,
2678c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_4 = 3,
2688c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_8 = 7,
2698c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_12 = 11,
2708c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_16 = 15,
2718c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_20 = 19,
2728c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_32 = 31,
2738c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_48 = 47,
2748c2ecf20Sopenharmony_ci	MSP_FRAME_LEN_64 = 63
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci/* Element length */
2788c2ecf20Sopenharmony_cienum msp_elem_length {
2798c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_8 = 0,
2808c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_10 = 1,
2818c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_12 = 2,
2828c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_14 = 3,
2838c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_16 = 4,
2848c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_20 = 5,
2858c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_24 = 6,
2868c2ecf20Sopenharmony_ci	MSP_ELEM_LEN_32 = 7
2878c2ecf20Sopenharmony_ci};
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cienum msp_data_xfer_width {
2908c2ecf20Sopenharmony_ci	MSP_DATA_TRANSFER_WIDTH_BYTE,
2918c2ecf20Sopenharmony_ci	MSP_DATA_TRANSFER_WIDTH_HALFWORD,
2928c2ecf20Sopenharmony_ci	MSP_DATA_TRANSFER_WIDTH_WORD
2938c2ecf20Sopenharmony_ci};
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cienum msp_frame_sync {
2968c2ecf20Sopenharmony_ci	MSP_FSYNC_UNIGNORE = 0,
2978c2ecf20Sopenharmony_ci	MSP_FSYNC_IGNORE = 1,
2988c2ecf20Sopenharmony_ci};
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_cienum msp_phase2_start_mode {
3018c2ecf20Sopenharmony_ci	MSP_PHASE2_START_MODE_IMEDIATE,
3028c2ecf20Sopenharmony_ci	MSP_PHASE2_START_MODE_FSYNC
3038c2ecf20Sopenharmony_ci};
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_cienum msp_btf {
3068c2ecf20Sopenharmony_ci	MSP_BTF_MS_BIT_FIRST = 0,
3078c2ecf20Sopenharmony_ci	MSP_BTF_LS_BIT_FIRST = 1
3088c2ecf20Sopenharmony_ci};
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cienum msp_fsync_pol {
3118c2ecf20Sopenharmony_ci	MSP_FSYNC_POL_ACT_HI = 0,
3128c2ecf20Sopenharmony_ci	MSP_FSYNC_POL_ACT_LO = 1
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci/* Data delay (in bit clock cycles) */
3168c2ecf20Sopenharmony_cienum msp_delay {
3178c2ecf20Sopenharmony_ci	MSP_DELAY_0 = 0,
3188c2ecf20Sopenharmony_ci	MSP_DELAY_1 = 1,
3198c2ecf20Sopenharmony_ci	MSP_DELAY_2 = 2,
3208c2ecf20Sopenharmony_ci	MSP_DELAY_3 = 3
3218c2ecf20Sopenharmony_ci};
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci/* Configurations of clocks (transmit, receive or sample rate generator) */
3248c2ecf20Sopenharmony_cienum msp_edge {
3258c2ecf20Sopenharmony_ci	MSP_FALLING_EDGE = 0,
3268c2ecf20Sopenharmony_ci	MSP_RISING_EDGE = 1,
3278c2ecf20Sopenharmony_ci};
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_cienum msp_hws {
3308c2ecf20Sopenharmony_ci	MSP_SWAP_NONE = 0,
3318c2ecf20Sopenharmony_ci	MSP_SWAP_BYTE_PER_WORD = 1,
3328c2ecf20Sopenharmony_ci	MSP_SWAP_BYTE_PER_HALF_WORD = 2,
3338c2ecf20Sopenharmony_ci	MSP_SWAP_HALF_WORD_PER_WORD = 3
3348c2ecf20Sopenharmony_ci};
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_cienum msp_compress_mode {
3378c2ecf20Sopenharmony_ci	MSP_COMPRESS_MODE_LINEAR = 0,
3388c2ecf20Sopenharmony_ci	MSP_COMPRESS_MODE_MU_LAW = 2,
3398c2ecf20Sopenharmony_ci	MSP_COMPRESS_MODE_A_LAW = 3
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_cienum msp_expand_mode {
3438c2ecf20Sopenharmony_ci	MSP_EXPAND_MODE_LINEAR = 0,
3448c2ecf20Sopenharmony_ci	MSP_EXPAND_MODE_LINEAR_SIGNED = 1,
3458c2ecf20Sopenharmony_ci	MSP_EXPAND_MODE_MU_LAW = 2,
3468c2ecf20Sopenharmony_ci	MSP_EXPAND_MODE_A_LAW = 3
3478c2ecf20Sopenharmony_ci};
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci#define MSP_FRAME_PERIOD_IN_MONO_MODE 256
3508c2ecf20Sopenharmony_ci#define MSP_FRAME_PERIOD_IN_STEREO_MODE 32
3518c2ecf20Sopenharmony_ci#define MSP_FRAME_WIDTH_IN_STEREO_MODE 16
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_cienum msp_protocol {
3548c2ecf20Sopenharmony_ci	MSP_I2S_PROTOCOL,
3558c2ecf20Sopenharmony_ci	MSP_PCM_PROTOCOL,
3568c2ecf20Sopenharmony_ci	MSP_PCM_COMPAND_PROTOCOL,
3578c2ecf20Sopenharmony_ci	MSP_INVALID_PROTOCOL
3588c2ecf20Sopenharmony_ci};
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci/*
3618c2ecf20Sopenharmony_ci * No of registers to backup during
3628c2ecf20Sopenharmony_ci * suspend resume
3638c2ecf20Sopenharmony_ci */
3648c2ecf20Sopenharmony_ci#define MAX_MSP_BACKUP_REGS 36
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cienum i2s_direction_t {
3678c2ecf20Sopenharmony_ci	MSP_DIR_TX = 0x01,
3688c2ecf20Sopenharmony_ci	MSP_DIR_RX = 0x02,
3698c2ecf20Sopenharmony_ci};
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cienum msp_data_size {
3728c2ecf20Sopenharmony_ci	MSP_DATA_BITS_DEFAULT = -1,
3738c2ecf20Sopenharmony_ci	MSP_DATA_BITS_8 = 0x00,
3748c2ecf20Sopenharmony_ci	MSP_DATA_BITS_10,
3758c2ecf20Sopenharmony_ci	MSP_DATA_BITS_12,
3768c2ecf20Sopenharmony_ci	MSP_DATA_BITS_14,
3778c2ecf20Sopenharmony_ci	MSP_DATA_BITS_16,
3788c2ecf20Sopenharmony_ci	MSP_DATA_BITS_20,
3798c2ecf20Sopenharmony_ci	MSP_DATA_BITS_24,
3808c2ecf20Sopenharmony_ci	MSP_DATA_BITS_32,
3818c2ecf20Sopenharmony_ci};
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_cienum msp_state {
3848c2ecf20Sopenharmony_ci	MSP_STATE_IDLE = 0,
3858c2ecf20Sopenharmony_ci	MSP_STATE_CONFIGURED = 1,
3868c2ecf20Sopenharmony_ci	MSP_STATE_RUNNING = 2,
3878c2ecf20Sopenharmony_ci};
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_cienum msp_rx_comparison_enable_mode {
3908c2ecf20Sopenharmony_ci	MSP_COMPARISON_DISABLED = 0,
3918c2ecf20Sopenharmony_ci	MSP_COMPARISON_NONEQUAL_ENABLED = 2,
3928c2ecf20Sopenharmony_ci	MSP_COMPARISON_EQUAL_ENABLED = 3
3938c2ecf20Sopenharmony_ci};
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_cistruct msp_multichannel_config {
3968c2ecf20Sopenharmony_ci	bool rx_multichannel_enable;
3978c2ecf20Sopenharmony_ci	bool tx_multichannel_enable;
3988c2ecf20Sopenharmony_ci	enum msp_rx_comparison_enable_mode rx_comparison_enable_mode;
3998c2ecf20Sopenharmony_ci	u8 padding;
4008c2ecf20Sopenharmony_ci	u32 comparison_value;
4018c2ecf20Sopenharmony_ci	u32 comparison_mask;
4028c2ecf20Sopenharmony_ci	u32 rx_channel_0_enable;
4038c2ecf20Sopenharmony_ci	u32 rx_channel_1_enable;
4048c2ecf20Sopenharmony_ci	u32 rx_channel_2_enable;
4058c2ecf20Sopenharmony_ci	u32 rx_channel_3_enable;
4068c2ecf20Sopenharmony_ci	u32 tx_channel_0_enable;
4078c2ecf20Sopenharmony_ci	u32 tx_channel_1_enable;
4088c2ecf20Sopenharmony_ci	u32 tx_channel_2_enable;
4098c2ecf20Sopenharmony_ci	u32 tx_channel_3_enable;
4108c2ecf20Sopenharmony_ci};
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistruct msp_protdesc {
4138c2ecf20Sopenharmony_ci	u32 rx_phase_mode;
4148c2ecf20Sopenharmony_ci	u32 tx_phase_mode;
4158c2ecf20Sopenharmony_ci	u32 rx_phase2_start_mode;
4168c2ecf20Sopenharmony_ci	u32 tx_phase2_start_mode;
4178c2ecf20Sopenharmony_ci	u32 rx_byte_order;
4188c2ecf20Sopenharmony_ci	u32 tx_byte_order;
4198c2ecf20Sopenharmony_ci	u32 rx_frame_len_1;
4208c2ecf20Sopenharmony_ci	u32 rx_frame_len_2;
4218c2ecf20Sopenharmony_ci	u32 tx_frame_len_1;
4228c2ecf20Sopenharmony_ci	u32 tx_frame_len_2;
4238c2ecf20Sopenharmony_ci	u32 rx_elem_len_1;
4248c2ecf20Sopenharmony_ci	u32 rx_elem_len_2;
4258c2ecf20Sopenharmony_ci	u32 tx_elem_len_1;
4268c2ecf20Sopenharmony_ci	u32 tx_elem_len_2;
4278c2ecf20Sopenharmony_ci	u32 rx_data_delay;
4288c2ecf20Sopenharmony_ci	u32 tx_data_delay;
4298c2ecf20Sopenharmony_ci	u32 rx_clk_pol;
4308c2ecf20Sopenharmony_ci	u32 tx_clk_pol;
4318c2ecf20Sopenharmony_ci	u32 rx_fsync_pol;
4328c2ecf20Sopenharmony_ci	u32 tx_fsync_pol;
4338c2ecf20Sopenharmony_ci	u32 rx_half_word_swap;
4348c2ecf20Sopenharmony_ci	u32 tx_half_word_swap;
4358c2ecf20Sopenharmony_ci	u32 compression_mode;
4368c2ecf20Sopenharmony_ci	u32 expansion_mode;
4378c2ecf20Sopenharmony_ci	u32 frame_sync_ignore;
4388c2ecf20Sopenharmony_ci	u32 frame_period;
4398c2ecf20Sopenharmony_ci	u32 frame_width;
4408c2ecf20Sopenharmony_ci	u32 clocks_per_frame;
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistruct ux500_msp_config {
4448c2ecf20Sopenharmony_ci	unsigned int f_inputclk;
4458c2ecf20Sopenharmony_ci	unsigned int rx_clk_sel;
4468c2ecf20Sopenharmony_ci	unsigned int tx_clk_sel;
4478c2ecf20Sopenharmony_ci	unsigned int srg_clk_sel;
4488c2ecf20Sopenharmony_ci	unsigned int rx_fsync_pol;
4498c2ecf20Sopenharmony_ci	unsigned int tx_fsync_pol;
4508c2ecf20Sopenharmony_ci	unsigned int rx_fsync_sel;
4518c2ecf20Sopenharmony_ci	unsigned int tx_fsync_sel;
4528c2ecf20Sopenharmony_ci	unsigned int rx_fifo_config;
4538c2ecf20Sopenharmony_ci	unsigned int tx_fifo_config;
4548c2ecf20Sopenharmony_ci	unsigned int loopback_enable;
4558c2ecf20Sopenharmony_ci	unsigned int tx_data_enable;
4568c2ecf20Sopenharmony_ci	unsigned int default_protdesc;
4578c2ecf20Sopenharmony_ci	struct msp_protdesc protdesc;
4588c2ecf20Sopenharmony_ci	int multichannel_configured;
4598c2ecf20Sopenharmony_ci	struct msp_multichannel_config multichannel_config;
4608c2ecf20Sopenharmony_ci	unsigned int direction;
4618c2ecf20Sopenharmony_ci	unsigned int protocol;
4628c2ecf20Sopenharmony_ci	unsigned int frame_freq;
4638c2ecf20Sopenharmony_ci	enum msp_data_size data_size;
4648c2ecf20Sopenharmony_ci	unsigned int def_elem_len;
4658c2ecf20Sopenharmony_ci	unsigned int iodelay;
4668c2ecf20Sopenharmony_ci};
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_cistruct ux500_msp_dma_params {
4698c2ecf20Sopenharmony_ci	unsigned int data_size;
4708c2ecf20Sopenharmony_ci	dma_addr_t tx_rx_addr;
4718c2ecf20Sopenharmony_ci	struct stedma40_chan_cfg *dma_cfg;
4728c2ecf20Sopenharmony_ci};
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_cistruct ux500_msp {
4758c2ecf20Sopenharmony_ci	int id;
4768c2ecf20Sopenharmony_ci	void __iomem *registers;
4778c2ecf20Sopenharmony_ci	struct device *dev;
4788c2ecf20Sopenharmony_ci	struct ux500_msp_dma_params playback_dma_data;
4798c2ecf20Sopenharmony_ci	struct ux500_msp_dma_params capture_dma_data;
4808c2ecf20Sopenharmony_ci	enum msp_state msp_state;
4818c2ecf20Sopenharmony_ci	int def_elem_len;
4828c2ecf20Sopenharmony_ci	unsigned int dir_busy;
4838c2ecf20Sopenharmony_ci	int loopback_enable;
4848c2ecf20Sopenharmony_ci	unsigned int f_bitclk;
4858c2ecf20Sopenharmony_ci};
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_cistruct msp_i2s_platform_data;
4888c2ecf20Sopenharmony_ciint ux500_msp_i2s_init_msp(struct platform_device *pdev,
4898c2ecf20Sopenharmony_ci			struct ux500_msp **msp_p,
4908c2ecf20Sopenharmony_ci			struct msp_i2s_platform_data *platform_data);
4918c2ecf20Sopenharmony_civoid ux500_msp_i2s_cleanup_msp(struct platform_device *pdev,
4928c2ecf20Sopenharmony_ci			struct ux500_msp *msp);
4938c2ecf20Sopenharmony_ciint ux500_msp_i2s_open(struct ux500_msp *msp, struct ux500_msp_config *config);
4948c2ecf20Sopenharmony_ciint ux500_msp_i2s_close(struct ux500_msp *msp,
4958c2ecf20Sopenharmony_ci			unsigned int dir);
4968c2ecf20Sopenharmony_ciint ux500_msp_i2s_trigger(struct ux500_msp *msp, int cmd,
4978c2ecf20Sopenharmony_ci			int direction);
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci#endif
500