18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * tegra20_spdif.h - Definitions for Tegra20 SPDIF driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Stephen Warren <swarren@nvidia.com>
68c2ecf20Sopenharmony_ci * Copyright (C) 2011 - NVIDIA, Inc.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Based on code copyright/by:
98c2ecf20Sopenharmony_ci * Copyright (c) 2008-2009, NVIDIA Corporation
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __TEGRA20_SPDIF_H__
138c2ecf20Sopenharmony_ci#define __TEGRA20_SPDIF_H__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "tegra_pcm.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* Offsets from TEGRA20_SPDIF_BASE */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL					0x0
208c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS					0x4
218c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL				0x8
228c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR				0x0C
238c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT					0x40
248c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN					0x80
258c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_A				0x100
268c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_B				0x104
278c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_C				0x108
288c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_D				0x10C
298c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_E				0x110
308c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_RX_F				0x114
318c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_A				0x140
328c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_B				0x144
338c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_C				0x148
348c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_D				0x14C
358c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_E				0x150
368c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CH_STA_TX_F				0x154
378c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_USR_STA_RX_A				0x180
388c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_USR_DAT_TX_A				0x1C0
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CTRL */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* Start capturing from 0=right, 1=left channel */
438c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_CAP_LC				(1 << 30)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* SPDIF receiver(RX) enable */
468c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_RX_EN				(1 << 29)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* SPDIF Transmitter(TX) enable */
498c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_TX_EN				(1 << 28)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* Transmit Channel status */
528c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_TC_EN				(1 << 27)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* Transmit user Data */
558c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_TU_EN				(1 << 26)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* Interrupt on transmit error */
588c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_TXE				(1 << 25)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Interrupt on receive error */
618c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_RXE				(1 << 24)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* Interrupt on invalid preamble */
648c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_P					(1 << 23)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* Interrupt on "B" preamble */
678c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_B					(1 << 22)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* Interrupt when block of channel status received */
708c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_C					(1 << 21)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Interrupt when a valid information unit (IU) is received */
738c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_IE_U					(1 << 20)
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* Interrupt when RX user FIFO attention level is reached */
768c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_QE_RU				(1 << 19)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/* Interrupt when TX user FIFO attention level is reached */
798c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_QE_TU				(1 << 18)
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/* Interrupt when RX data FIFO attention level is reached */
828c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_QE_RX				(1 << 17)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* Interrupt when TX data FIFO attention level is reached */
858c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_QE_TX				(1 << 16)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/* Loopback test mode enable */
888c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_LBK_EN				(1 << 15)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/*
918c2ecf20Sopenharmony_ci * Pack data mode:
928c2ecf20Sopenharmony_ci * 0 = Single data (16 bit needs to be  padded to match the
938c2ecf20Sopenharmony_ci *     interface data bit size).
948c2ecf20Sopenharmony_ci * 1 = Packeted left/right channel data into a single word.
958c2ecf20Sopenharmony_ci */
968c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_PACK					(1 << 14)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/*
998c2ecf20Sopenharmony_ci * 00 = 16bit data
1008c2ecf20Sopenharmony_ci * 01 = 20bit data
1018c2ecf20Sopenharmony_ci * 10 = 24bit data
1028c2ecf20Sopenharmony_ci * 11 = raw data
1038c2ecf20Sopenharmony_ci */
1048c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_BIT_MODE_16BIT				0
1058c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_BIT_MODE_20BIT				1
1068c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_BIT_MODE_24BIT				2
1078c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_BIT_MODE_RAW				3
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT			12
1108c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_MASK			(3                            << TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT)
1118c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_16BIT			(TEGRA20_SPDIF_BIT_MODE_16BIT << TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT)
1128c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_20BIT			(TEGRA20_SPDIF_BIT_MODE_20BIT << TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT)
1138c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_24BIT			(TEGRA20_SPDIF_BIT_MODE_24BIT << TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT)
1148c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_CTRL_BIT_MODE_RAW				(TEGRA20_SPDIF_BIT_MODE_RAW   << TEGRA20_SPDIF_CTRL_BIT_MODE_SHIFT)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_STATUS */
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/*
1198c2ecf20Sopenharmony_ci * Note: IS_P, IS_B, IS_C, and IS_U are sticky bits. Software must
1208c2ecf20Sopenharmony_ci * write a 1 to the corresponding bit location to clear the status.
1218c2ecf20Sopenharmony_ci */
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/*
1248c2ecf20Sopenharmony_ci * Receiver(RX) shifter is busy receiving data.
1258c2ecf20Sopenharmony_ci * This bit is asserted when the receiver first locked onto the
1268c2ecf20Sopenharmony_ci * preamble of the data stream after RX_EN is asserted. This bit is
1278c2ecf20Sopenharmony_ci * deasserted when either,
1288c2ecf20Sopenharmony_ci * (a) the end of a frame is reached after RX_EN is deeasserted, or
1298c2ecf20Sopenharmony_ci * (b) the SPDIF data stream becomes inactive.
1308c2ecf20Sopenharmony_ci */
1318c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_RX_BSY				(1 << 29)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/*
1348c2ecf20Sopenharmony_ci * Transmitter(TX) shifter is busy transmitting data.
1358c2ecf20Sopenharmony_ci * This bit is asserted when TX_EN is asserted.
1368c2ecf20Sopenharmony_ci * This bit is deasserted when the end of a frame is reached after
1378c2ecf20Sopenharmony_ci * TX_EN is deasserted.
1388c2ecf20Sopenharmony_ci */
1398c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_TX_BSY				(1 << 28)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/*
1428c2ecf20Sopenharmony_ci * TX is busy shifting out channel status.
1438c2ecf20Sopenharmony_ci * This bit is asserted when both TX_EN and TC_EN are asserted and
1448c2ecf20Sopenharmony_ci * data from CH_STA_TX_A register is loaded into the internal shifter.
1458c2ecf20Sopenharmony_ci * This bit is deasserted when either,
1468c2ecf20Sopenharmony_ci * (a) the end of a frame is reached after TX_EN is deasserted, or
1478c2ecf20Sopenharmony_ci * (b) CH_STA_TX_F register is loaded into the internal shifter.
1488c2ecf20Sopenharmony_ci */
1498c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_TC_BSY				(1 << 27)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci/*
1528c2ecf20Sopenharmony_ci * TX User data FIFO busy.
1538c2ecf20Sopenharmony_ci * This bit is asserted when TX_EN and TXU_EN are asserted and
1548c2ecf20Sopenharmony_ci * there's data in the TX user FIFO.  This bit is deassert when either,
1558c2ecf20Sopenharmony_ci * (a) the end of a frame is reached after TX_EN is deasserted, or
1568c2ecf20Sopenharmony_ci * (b) there's no data left in the TX user FIFO.
1578c2ecf20Sopenharmony_ci */
1588c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_TU_BSY				(1 << 26)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/* TX FIFO Underrun error status */
1618c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_TX_ERR				(1 << 25)
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci/* RX FIFO Overrun error status */
1648c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_RX_ERR				(1 << 24)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/* Preamble status: 0=Preamble OK, 1=bad/missing preamble */
1678c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_IS_P				(1 << 23)
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* B-preamble detection status: 0=not detected, 1=B-preamble detected */
1708c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_IS_B				(1 << 22)
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci/*
1738c2ecf20Sopenharmony_ci * RX channel block data receive status:
1748c2ecf20Sopenharmony_ci * 0=entire block not recieved yet.
1758c2ecf20Sopenharmony_ci * 1=received entire block of channel status,
1768c2ecf20Sopenharmony_ci */
1778c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_IS_C				(1 << 21)
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* RX User Data Valid flag:  1=valid IU detected, 0 = no IU detected. */
1808c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_IS_U				(1 << 20)
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/*
1838c2ecf20Sopenharmony_ci * RX User FIFO Status:
1848c2ecf20Sopenharmony_ci * 1=attention level reached, 0=attention level not reached.
1858c2ecf20Sopenharmony_ci */
1868c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_QS_RU				(1 << 19)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/*
1898c2ecf20Sopenharmony_ci * TX User FIFO Status:
1908c2ecf20Sopenharmony_ci * 1=attention level reached, 0=attention level not reached.
1918c2ecf20Sopenharmony_ci */
1928c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_QS_TU				(1 << 18)
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/*
1958c2ecf20Sopenharmony_ci * RX Data FIFO Status:
1968c2ecf20Sopenharmony_ci * 1=attention level reached, 0=attention level not reached.
1978c2ecf20Sopenharmony_ci */
1988c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_QS_RX				(1 << 17)
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/*
2018c2ecf20Sopenharmony_ci * TX Data FIFO Status:
2028c2ecf20Sopenharmony_ci * 1=attention level reached, 0=attention level not reached.
2038c2ecf20Sopenharmony_ci */
2048c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STATUS_QS_TX				(1 << 16)
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_STROBE_CTRL */
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/*
2098c2ecf20Sopenharmony_ci * Indicates the approximate number of detected SPDIFIN clocks within a
2108c2ecf20Sopenharmony_ci * bi-phase period.
2118c2ecf20Sopenharmony_ci */
2128c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_PERIOD_SHIFT			16
2138c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_PERIOD_MASK			(0xff << TEGRA20_SPDIF_STROBE_CTRL_PERIOD_SHIFT)
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci/* Data strobe mode: 0=Auto-locked 1=Manual locked */
2168c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_STROBE			(1 << 15)
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci/*
2198c2ecf20Sopenharmony_ci * Manual data strobe time within the bi-phase clock period (in terms of
2208c2ecf20Sopenharmony_ci * the number of over-sampling clocks).
2218c2ecf20Sopenharmony_ci */
2228c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_DATA_STROBES_SHIFT		8
2238c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_DATA_STROBES_MASK		(0x1f << TEGRA20_SPDIF_STROBE_CTRL_DATA_STROBES_SHIFT)
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/*
2268c2ecf20Sopenharmony_ci * Manual SPDIFIN bi-phase clock period (in terms of the number of
2278c2ecf20Sopenharmony_ci * over-sampling clocks).
2288c2ecf20Sopenharmony_ci */
2298c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_CLOCK_PERIOD_SHIFT		0
2308c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_STROBE_CTRL_CLOCK_PERIOD_MASK		(0x3f << TEGRA20_SPDIF_STROBE_CTRL_CLOCK_PERIOD_SHIFT)
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci/* Fields in SPDIF_DATA_FIFO_CSR */
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci/* Clear Receiver User FIFO (RX USR.FIFO) */
2358c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_CLR			(1 << 31)
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_U_ONE_SLOT			0
2388c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_U_TWO_SLOTS			1
2398c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_U_THREE_SLOTS		2
2408c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_U_FOUR_SLOTS			3
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci/* RU FIFO attention level */
2438c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT		29
2448c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_MASK		\
2458c2ecf20Sopenharmony_ci		(0x3                                      << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT)
2468c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_RU1_WORD_FULL	\
2478c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_ONE_SLOT    << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT)
2488c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_RU2_WORD_FULL	\
2498c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_TWO_SLOTS   << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT)
2508c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_RU3_WORD_FULL	\
2518c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_THREE_SLOTS << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT)
2528c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_RU4_WORD_FULL	\
2538c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_FOUR_SLOTS  << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_ATN_LVL_SHIFT)
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci/* Number of RX USR.FIFO levels with valid data. */
2568c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_FULL_COUNT_SHIFT		24
2578c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RU_FULL_COUNT_MASK		(0x1f << TEGRA20_SPDIF_DATA_FIFO_CSR_RU_FULL_COUNT_SHIFT)
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/* Clear Transmitter User FIFO (TX USR.FIFO) */
2608c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_CLR			(1 << 23)
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci/* TU FIFO attention level */
2638c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT		21
2648c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_MASK		\
2658c2ecf20Sopenharmony_ci		(0x3                                      << TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT)
2668c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_TU1_WORD_FULL	\
2678c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_ONE_SLOT    << TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT)
2688c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_TU2_WORD_FULL	\
2698c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_TWO_SLOTS   << TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT)
2708c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_TU3_WORD_FULL	\
2718c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_THREE_SLOTS << TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT)
2728c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_TU4_WORD_FULL	\
2738c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_U_FOUR_SLOTS  << TEGRA20_SPDIF_DATA_FIFO_CSR_TU_ATN_LVL_SHIFT)
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci/* Number of TX USR.FIFO levels that could be filled. */
2768c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_EMPTY_COUNT_SHIFT	16
2778c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TU_EMPTY_COUNT_MASK		(0x1f << SPDIF_DATA_FIFO_CSR_TU_EMPTY_COUNT_SHIFT)
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci/* Clear Receiver Data FIFO (RX DATA.FIFO) */
2808c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_CLR			(1 << 15)
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_D_ONE_SLOT			0
2838c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_D_FOUR_SLOTS			1
2848c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_D_EIGHT_SLOTS		2
2858c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_FIFO_ATN_LVL_D_TWELVE_SLOTS		3
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci/* RU FIFO attention level */
2888c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT		13
2898c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_MASK		\
2908c2ecf20Sopenharmony_ci		(0x3                                       << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT)
2918c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_RU1_WORD_FULL	\
2928c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_ONE_SLOT     << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT)
2938c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_RU4_WORD_FULL	\
2948c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_FOUR_SLOTS   << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT)
2958c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_RU8_WORD_FULL	\
2968c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_EIGHT_SLOTS  << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT)
2978c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_RU12_WORD_FULL	\
2988c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_TWELVE_SLOTS << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_ATN_LVL_SHIFT)
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci/* Number of RX DATA.FIFO levels with valid data. */
3018c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_FULL_COUNT_SHIFT		8
3028c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_RX_FULL_COUNT_MASK		(0x1f << TEGRA20_SPDIF_DATA_FIFO_CSR_RX_FULL_COUNT_SHIFT)
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* Clear Transmitter Data FIFO (TX DATA.FIFO) */
3058c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_CLR			(1 << 7)
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/* TU FIFO attention level */
3088c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT		5
3098c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_MASK		\
3108c2ecf20Sopenharmony_ci		(0x3                                       << TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT)
3118c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_TU1_WORD_FULL	\
3128c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_ONE_SLOT     << TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT)
3138c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_TU4_WORD_FULL	\
3148c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_FOUR_SLOTS   << TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT)
3158c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_TU8_WORD_FULL	\
3168c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_EIGHT_SLOTS  << TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT)
3178c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_TU12_WORD_FULL	\
3188c2ecf20Sopenharmony_ci		(TEGRA20_SPDIF_FIFO_ATN_LVL_D_TWELVE_SLOTS << TEGRA20_SPDIF_DATA_FIFO_CSR_TX_ATN_LVL_SHIFT)
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci/* Number of TX DATA.FIFO levels that could be filled. */
3218c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_EMPTY_COUNT_SHIFT	0
3228c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_FIFO_CSR_TX_EMPTY_COUNT_MASK		(0x1f << SPDIF_DATA_FIFO_CSR_TX_EMPTY_COUNT_SHIFT)
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_DATA_OUT */
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci/*
3278c2ecf20Sopenharmony_ci * This register has 5 different formats:
3288c2ecf20Sopenharmony_ci * 16-bit        (BIT_MODE=00, PACK=0)
3298c2ecf20Sopenharmony_ci * 20-bit        (BIT_MODE=01, PACK=0)
3308c2ecf20Sopenharmony_ci * 24-bit        (BIT_MODE=10, PACK=0)
3318c2ecf20Sopenharmony_ci * raw           (BIT_MODE=11, PACK=0)
3328c2ecf20Sopenharmony_ci * 16-bit packed (BIT_MODE=00, PACK=1)
3338c2ecf20Sopenharmony_ci */
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_SHIFT			0
3368c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_MASK			(0xffff << TEGRA20_SPDIF_DATA_OUT_DATA_16_SHIFT)
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_20_SHIFT			0
3398c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_20_MASK			(0xfffff << TEGRA20_SPDIF_DATA_OUT_DATA_20_SHIFT)
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_24_SHIFT			0
3428c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_24_MASK			(0xffffff << TEGRA20_SPDIF_DATA_OUT_DATA_24_SHIFT)
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_P			(1 << 31)
3458c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_C			(1 << 30)
3468c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_U			(1 << 29)
3478c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_V			(1 << 28)
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_DATA_SHIFT		8
3508c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_DATA_MASK		(0xfffff << TEGRA20_SPDIF_DATA_OUT_DATA_RAW_DATA_SHIFT)
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_AUX_SHIFT		4
3538c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_AUX_MASK		(0xf << TEGRA20_SPDIF_DATA_OUT_DATA_RAW_AUX_SHIFT)
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_PREAMBLE_SHIFT		0
3568c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_RAW_PREAMBLE_MASK		(0xf << TEGRA20_SPDIF_DATA_OUT_DATA_RAW_PREAMBLE_SHIFT)
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_RIGHT_SHIFT	16
3598c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_RIGHT_MASK	(0xffff << TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_RIGHT_SHIFT)
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_LEFT_SHIFT	0
3628c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_LEFT_MASK		(0xffff << TEGRA20_SPDIF_DATA_OUT_DATA_16_PACKED_LEFT_SHIFT)
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_DATA_IN */
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci/*
3678c2ecf20Sopenharmony_ci * This register has 5 different formats:
3688c2ecf20Sopenharmony_ci * 16-bit        (BIT_MODE=00, PACK=0)
3698c2ecf20Sopenharmony_ci * 20-bit        (BIT_MODE=01, PACK=0)
3708c2ecf20Sopenharmony_ci * 24-bit        (BIT_MODE=10, PACK=0)
3718c2ecf20Sopenharmony_ci * raw           (BIT_MODE=11, PACK=0)
3728c2ecf20Sopenharmony_ci * 16-bit packed (BIT_MODE=00, PACK=1)
3738c2ecf20Sopenharmony_ci *
3748c2ecf20Sopenharmony_ci * Bits 31:24 are common to all modes except 16-bit packed
3758c2ecf20Sopenharmony_ci */
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_P				(1 << 31)
3788c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_C				(1 << 30)
3798c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_U				(1 << 29)
3808c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_V				(1 << 28)
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_PREAMBLE_SHIFT		24
3838c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_PREAMBLE_MASK		(0xf << TEGRA20_SPDIF_DATA_IN_DATA_PREAMBLE_SHIFT)
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_SHIFT			0
3868c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_MASK			(0xffff << TEGRA20_SPDIF_DATA_IN_DATA_16_SHIFT)
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_20_SHIFT			0
3898c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_20_MASK			(0xfffff << TEGRA20_SPDIF_DATA_IN_DATA_20_SHIFT)
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_24_SHIFT			0
3928c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_24_MASK			(0xffffff << TEGRA20_SPDIF_DATA_IN_DATA_24_SHIFT)
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_DATA_SHIFT		8
3958c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_DATA_MASK		(0xfffff << TEGRA20_SPDIF_DATA_IN_DATA_RAW_DATA_SHIFT)
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_AUX_SHIFT		4
3988c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_AUX_MASK			(0xf << TEGRA20_SPDIF_DATA_IN_DATA_RAW_AUX_SHIFT)
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_PREAMBLE_SHIFT		0
4018c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_RAW_PREAMBLE_MASK		(0xf << TEGRA20_SPDIF_DATA_IN_DATA_RAW_PREAMBLE_SHIFT)
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_RIGHT_SHIFT	16
4048c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_RIGHT_MASK		(0xffff << TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_RIGHT_SHIFT)
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_LEFT_SHIFT		0
4078c2ecf20Sopenharmony_ci#define TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_LEFT_MASK		(0xffff << TEGRA20_SPDIF_DATA_IN_DATA_16_PACKED_LEFT_SHIFT)
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_A */
4108c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_B */
4118c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_C */
4128c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_D */
4138c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_E */
4148c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_RX_F */
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci/*
4178c2ecf20Sopenharmony_ci * The 6-word receive channel data page buffer holds a block (192 frames) of
4188c2ecf20Sopenharmony_ci * channel status information. The order of receive is from LSB to MSB
4198c2ecf20Sopenharmony_ci * bit, and from CH_STA_RX_A to CH_STA_RX_F then back to CH_STA_RX_A.
4208c2ecf20Sopenharmony_ci */
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_A */
4238c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_B */
4248c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_C */
4258c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_D */
4268c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_E */
4278c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_CH_STA_TX_F */
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci/*
4308c2ecf20Sopenharmony_ci * The 6-word transmit channel data page buffer holds a block (192 frames) of
4318c2ecf20Sopenharmony_ci * channel status information. The order of transmission is from LSB to MSB
4328c2ecf20Sopenharmony_ci * bit, and from CH_STA_TX_A to CH_STA_TX_F then back to CH_STA_TX_A.
4338c2ecf20Sopenharmony_ci */
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_USR_STA_RX_A */
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci/*
4388c2ecf20Sopenharmony_ci * This 4-word deep FIFO receives user FIFO field information. The order of
4398c2ecf20Sopenharmony_ci * receive is from LSB to MSB bit.
4408c2ecf20Sopenharmony_ci */
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci/* Fields in TEGRA20_SPDIF_USR_DAT_TX_A */
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci/*
4458c2ecf20Sopenharmony_ci * This 4-word deep FIFO transmits user FIFO field information. The order of
4468c2ecf20Sopenharmony_ci * transmission is from LSB to MSB bit.
4478c2ecf20Sopenharmony_ci */
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_cistruct tegra20_spdif {
4508c2ecf20Sopenharmony_ci	struct clk *clk_spdif_out;
4518c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data capture_dma_data;
4528c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data playback_dma_data;
4538c2ecf20Sopenharmony_ci	struct regmap *regmap;
4548c2ecf20Sopenharmony_ci};
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci#endif
457