18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * tegra210_admaif.h - Tegra ADMAIF registers
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __TEGRA_ADMAIF_H__
108c2ecf20Sopenharmony_ci#define __TEGRA_ADMAIF_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_CHANNEL_REG_STRIDE			0x40
138c2ecf20Sopenharmony_ci/* Tegra210 specific */
148c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_LAST_REG			0x75f
158c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_CHANNEL_COUNT			10
168c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX_BASE				0x0
178c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX_BASE				0x300
188c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_GLOBAL_BASE			0x700
198c2ecf20Sopenharmony_ci/* Tegra186 specific */
208c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_LAST_REG			0xd5f
218c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_CHANNEL_COUNT			20
228c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX_BASE				0x0
238c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX_BASE				0x500
248c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_GLOBAL_BASE			0xd00
258c2ecf20Sopenharmony_ci/* Global registers */
268c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_GLOBAL_ENABLE			0x0
278c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_GLOBAL_CG_0			0x8
288c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_GLOBAL_STATUS			0x10
298c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_GLOBAL_RX_ENABLE_STATUS		0x20
308c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_GLOBAL_TX_ENABLE_STATUS		0x24
318c2ecf20Sopenharmony_ci/* RX channel registers */
328c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_ENABLE				0x0
338c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_SOFT_RESET			0x4
348c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_STATUS				0xc
358c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_INT_STATUS			0x10
368c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_INT_MASK			0x14
378c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_INT_SET				0x18
388c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_INT_CLEAR			0x1c
398c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_CH_ACIF_RX_CTRL			0x20
408c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_FIFO_CTRL			0x28
418c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_RX_FIFO_READ			0x2c
428c2ecf20Sopenharmony_ci/* TX channel registers */
438c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_ENABLE				0x0
448c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_SOFT_RESET			0x4
458c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_STATUS				0xc
468c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_INT_STATUS			0x10
478c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_INT_MASK			0x14
488c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_INT_SET				0x18
498c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_INT_CLEAR			0x1c
508c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_CH_ACIF_TX_CTRL			0x20
518c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_FIFO_CTRL			0x28
528c2ecf20Sopenharmony_ci#define TEGRA_ADMAIF_TX_FIFO_WRITE			0x2c
538c2ecf20Sopenharmony_ci/* Bit fields */
548c2ecf20Sopenharmony_ci#define PACK8_EN_SHIFT					31
558c2ecf20Sopenharmony_ci#define PACK8_EN_MASK					BIT(PACK8_EN_SHIFT)
568c2ecf20Sopenharmony_ci#define PACK8_EN					BIT(PACK8_EN_SHIFT)
578c2ecf20Sopenharmony_ci#define PACK16_EN_SHIFT					30
588c2ecf20Sopenharmony_ci#define PACK16_EN_MASK					BIT(PACK16_EN_SHIFT)
598c2ecf20Sopenharmony_ci#define PACK16_EN					BIT(PACK16_EN_SHIFT)
608c2ecf20Sopenharmony_ci#define TX_ENABLE_SHIFT					0
618c2ecf20Sopenharmony_ci#define TX_ENABLE_MASK					BIT(TX_ENABLE_SHIFT)
628c2ecf20Sopenharmony_ci#define TX_ENABLE					BIT(TX_ENABLE_SHIFT)
638c2ecf20Sopenharmony_ci#define RX_ENABLE_SHIFT					0
648c2ecf20Sopenharmony_ci#define RX_ENABLE_MASK					BIT(RX_ENABLE_SHIFT)
658c2ecf20Sopenharmony_ci#define RX_ENABLE					BIT(RX_ENABLE_SHIFT)
668c2ecf20Sopenharmony_ci#define SW_RESET_MASK					1
678c2ecf20Sopenharmony_ci#define SW_RESET					1
688c2ecf20Sopenharmony_ci/* Default values - Tegra210 */
698c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX1_FIFO_CTRL_REG_DEFAULT	0x00000300
708c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX2_FIFO_CTRL_REG_DEFAULT	0x00000304
718c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX3_FIFO_CTRL_REG_DEFAULT	0x00000208
728c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX4_FIFO_CTRL_REG_DEFAULT	0x0000020b
738c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX5_FIFO_CTRL_REG_DEFAULT	0x0000020e
748c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX6_FIFO_CTRL_REG_DEFAULT	0x00000211
758c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX7_FIFO_CTRL_REG_DEFAULT	0x00000214
768c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX8_FIFO_CTRL_REG_DEFAULT	0x00000217
778c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX9_FIFO_CTRL_REG_DEFAULT	0x0000021a
788c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_RX10_FIFO_CTRL_REG_DEFAULT	0x0000021d
798c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX1_FIFO_CTRL_REG_DEFAULT	0x02000300
808c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX2_FIFO_CTRL_REG_DEFAULT	0x02000304
818c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX3_FIFO_CTRL_REG_DEFAULT	0x01800208
828c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX4_FIFO_CTRL_REG_DEFAULT	0x0180020b
838c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX5_FIFO_CTRL_REG_DEFAULT	0x0180020e
848c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX6_FIFO_CTRL_REG_DEFAULT	0x01800211
858c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX7_FIFO_CTRL_REG_DEFAULT	0x01800214
868c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX8_FIFO_CTRL_REG_DEFAULT	0x01800217
878c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX9_FIFO_CTRL_REG_DEFAULT	0x0180021a
888c2ecf20Sopenharmony_ci#define TEGRA210_ADMAIF_TX10_FIFO_CTRL_REG_DEFAULT	0x0180021d
898c2ecf20Sopenharmony_ci/* Default values - Tegra186 */
908c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX1_FIFO_CTRL_REG_DEFAULT	0x00000300
918c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX2_FIFO_CTRL_REG_DEFAULT	0x00000304
928c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX3_FIFO_CTRL_REG_DEFAULT	0x00000308
938c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX4_FIFO_CTRL_REG_DEFAULT	0x0000030c
948c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX5_FIFO_CTRL_REG_DEFAULT	0x00000210
958c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX6_FIFO_CTRL_REG_DEFAULT	0x00000213
968c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX7_FIFO_CTRL_REG_DEFAULT	0x00000216
978c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX8_FIFO_CTRL_REG_DEFAULT	0x00000219
988c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX9_FIFO_CTRL_REG_DEFAULT	0x0000021c
998c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX10_FIFO_CTRL_REG_DEFAULT	0x0000021f
1008c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX11_FIFO_CTRL_REG_DEFAULT	0x00000222
1018c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX12_FIFO_CTRL_REG_DEFAULT	0x00000225
1028c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX13_FIFO_CTRL_REG_DEFAULT	0x00000228
1038c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX14_FIFO_CTRL_REG_DEFAULT	0x0000022b
1048c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX15_FIFO_CTRL_REG_DEFAULT	0x0000022e
1058c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX16_FIFO_CTRL_REG_DEFAULT	0x00000231
1068c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX17_FIFO_CTRL_REG_DEFAULT	0x00000234
1078c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX18_FIFO_CTRL_REG_DEFAULT	0x00000237
1088c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX19_FIFO_CTRL_REG_DEFAULT	0x0000023a
1098c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_RX20_FIFO_CTRL_REG_DEFAULT	0x0000023d
1108c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX1_FIFO_CTRL_REG_DEFAULT	0x02000300
1118c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX2_FIFO_CTRL_REG_DEFAULT	0x02000304
1128c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX3_FIFO_CTRL_REG_DEFAULT	0x02000308
1138c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX4_FIFO_CTRL_REG_DEFAULT	0x0200030c
1148c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX5_FIFO_CTRL_REG_DEFAULT	0x01800210
1158c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX6_FIFO_CTRL_REG_DEFAULT	0x01800213
1168c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX7_FIFO_CTRL_REG_DEFAULT	0x01800216
1178c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX8_FIFO_CTRL_REG_DEFAULT	0x01800219
1188c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX9_FIFO_CTRL_REG_DEFAULT	0x0180021c
1198c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX10_FIFO_CTRL_REG_DEFAULT	0x0180021f
1208c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX11_FIFO_CTRL_REG_DEFAULT	0x01800222
1218c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX12_FIFO_CTRL_REG_DEFAULT	0x01800225
1228c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX13_FIFO_CTRL_REG_DEFAULT	0x01800228
1238c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX14_FIFO_CTRL_REG_DEFAULT	0x0180022b
1248c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX15_FIFO_CTRL_REG_DEFAULT	0x0180022e
1258c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX16_FIFO_CTRL_REG_DEFAULT	0x01800231
1268c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX17_FIFO_CTRL_REG_DEFAULT	0x01800234
1278c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX18_FIFO_CTRL_REG_DEFAULT	0x01800237
1288c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX19_FIFO_CTRL_REG_DEFAULT	0x0180023a
1298c2ecf20Sopenharmony_ci#define TEGRA186_ADMAIF_TX20_FIFO_CTRL_REG_DEFAULT	0x0180023d
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cienum {
1328c2ecf20Sopenharmony_ci	DATA_8BIT,
1338c2ecf20Sopenharmony_ci	DATA_16BIT,
1348c2ecf20Sopenharmony_ci	DATA_32BIT
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cienum {
1388c2ecf20Sopenharmony_ci	ADMAIF_RX_PATH,
1398c2ecf20Sopenharmony_ci	ADMAIF_TX_PATH,
1408c2ecf20Sopenharmony_ci	ADMAIF_PATHS,
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistruct tegra_admaif_soc_data {
1448c2ecf20Sopenharmony_ci	const struct snd_soc_component_driver *cmpnt;
1458c2ecf20Sopenharmony_ci	const struct regmap_config *regmap_conf;
1468c2ecf20Sopenharmony_ci	struct snd_soc_dai_driver *dais;
1478c2ecf20Sopenharmony_ci	unsigned int global_base;
1488c2ecf20Sopenharmony_ci	unsigned int tx_base;
1498c2ecf20Sopenharmony_ci	unsigned int rx_base;
1508c2ecf20Sopenharmony_ci	unsigned int num_ch;
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct tegra_admaif {
1548c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data *capture_dma_data;
1558c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data *playback_dma_data;
1568c2ecf20Sopenharmony_ci	const struct tegra_admaif_soc_data *soc_data;
1578c2ecf20Sopenharmony_ci	unsigned int *mono_to_stereo[ADMAIF_PATHS];
1588c2ecf20Sopenharmony_ci	unsigned int *stereo_to_mono[ADMAIF_PATHS];
1598c2ecf20Sopenharmony_ci	struct regmap *regmap;
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#endif
163