18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * tegra20_das.h - Definitions for Tegra20 DAS driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Stephen Warren <swarren@nvidia.com>
68c2ecf20Sopenharmony_ci * Copyright (C) 2010,2012 - NVIDIA, Inc.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __TEGRA20_DAS_H__
108c2ecf20Sopenharmony_ci#define __TEGRA20_DAS_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/* Register TEGRA20_DAS_DAP_CTRL_SEL */
138c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL			0x00
148c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_COUNT			5
158c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_STRIDE			4
168c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_MS_SEL_P		31
178c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_MS_SEL_S		1
188c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_SDATA1_TX_RX_P	30
198c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_SDATA1_TX_RX_S	1
208c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_SDATA2_TX_RX_P	29
218c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_SDATA2_TX_RX_S	1
228c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_CTRL_SEL_P		0
238c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_CTRL_SEL_DAP_CTRL_SEL_S		5
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* Values for field TEGRA20_DAS_DAP_CTRL_SEL_DAP_CTRL_SEL */
268c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAC1	0
278c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAC2	1
288c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAC3	2
298c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAP1	16
308c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAP2	17
318c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAP3	18
328c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAP4	19
338c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_SEL_DAP5	20
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* Register TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL */
368c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL			0x40
378c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_COUNT		3
388c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_STRIDE		4
398c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA2_SEL_P	28
408c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA2_SEL_S	4
418c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA1_SEL_P	24
428c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA1_SEL_S	4
438c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_CLK_SEL_P	0
448c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_CLK_SEL_S	4
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/*
478c2ecf20Sopenharmony_ci * Values for:
488c2ecf20Sopenharmony_ci * TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA2_SEL
498c2ecf20Sopenharmony_ci * TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_SDATA1_SEL
508c2ecf20Sopenharmony_ci * TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_DAC_CLK_SEL
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_SEL_DAP1	0
538c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_SEL_DAP2	1
548c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_SEL_DAP3	2
558c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_SEL_DAP4	3
568c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_SEL_DAP5	4
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/*
598c2ecf20Sopenharmony_ci * Names/IDs of the DACs/DAPs.
608c2ecf20Sopenharmony_ci */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_ID_1 0
638c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_ID_2 1
648c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_ID_3 2
658c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_ID_4 3
668c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAP_ID_5 4
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_ID_1 0
698c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_ID_2 1
708c2ecf20Sopenharmony_ci#define TEGRA20_DAS_DAC_ID_3 2
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistruct tegra20_das {
738c2ecf20Sopenharmony_ci	struct device *dev;
748c2ecf20Sopenharmony_ci	struct regmap *regmap;
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/*
788c2ecf20Sopenharmony_ci * Terminology:
798c2ecf20Sopenharmony_ci * DAS: Digital audio switch (HW module controlled by this driver)
808c2ecf20Sopenharmony_ci * DAP: Digital audio port (port/pins on Tegra device)
818c2ecf20Sopenharmony_ci * DAC: Digital audio controller (e.g. I2S or AC97 controller elsewhere)
828c2ecf20Sopenharmony_ci *
838c2ecf20Sopenharmony_ci * The Tegra DAS is a mux/cross-bar which can connect each DAP to a specific
848c2ecf20Sopenharmony_ci * DAC, or another DAP. When DAPs are connected, one must be the master and
858c2ecf20Sopenharmony_ci * one the slave. Each DAC allows selection of a specific DAP for input, to
868c2ecf20Sopenharmony_ci * cater for the case where N DAPs are connected to 1 DAC for broadcast
878c2ecf20Sopenharmony_ci * output.
888c2ecf20Sopenharmony_ci *
898c2ecf20Sopenharmony_ci * This driver is dumb; no attempt is made to ensure that a valid routing
908c2ecf20Sopenharmony_ci * configuration is programmed.
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/*
948c2ecf20Sopenharmony_ci * Connect a DAP to a DAC
958c2ecf20Sopenharmony_ci * dap_id: DAP to connect: TEGRA20_DAS_DAP_ID_*
968c2ecf20Sopenharmony_ci * dac_sel: DAC to connect to: TEGRA20_DAS_DAP_SEL_DAC*
978c2ecf20Sopenharmony_ci */
988c2ecf20Sopenharmony_ciextern int tegra20_das_connect_dap_to_dac(int dap_id, int dac_sel);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/*
1018c2ecf20Sopenharmony_ci * Connect a DAP to another DAP
1028c2ecf20Sopenharmony_ci * dap_id: DAP to connect: TEGRA20_DAS_DAP_ID_*
1038c2ecf20Sopenharmony_ci * other_dap_sel: DAP to connect to: TEGRA20_DAS_DAP_SEL_DAP*
1048c2ecf20Sopenharmony_ci * master: Is this DAP the master (1) or slave (0)
1058c2ecf20Sopenharmony_ci * sdata1rx: Is this DAP's SDATA1 pin RX (1) or TX (0)
1068c2ecf20Sopenharmony_ci * sdata2rx: Is this DAP's SDATA2 pin RX (1) or TX (0)
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ciextern int tegra20_das_connect_dap_to_dap(int dap_id, int other_dap_sel,
1098c2ecf20Sopenharmony_ci					  int master, int sdata1rx,
1108c2ecf20Sopenharmony_ci					  int sdata2rx);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/*
1138c2ecf20Sopenharmony_ci * Connect a DAC's input to a DAP
1148c2ecf20Sopenharmony_ci * (DAC outputs are selected by the DAP)
1158c2ecf20Sopenharmony_ci * dac_id: DAC ID to connect: TEGRA20_DAS_DAC_ID_*
1168c2ecf20Sopenharmony_ci * dap_sel: DAP to receive input from: TEGRA20_DAS_DAC_SEL_DAP*
1178c2ecf20Sopenharmony_ci */
1188c2ecf20Sopenharmony_ciextern int tegra20_das_connect_dac_to_dap(int dac_id, int dap_sel);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#endif
121