18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * tegra210_ahub.h - TEGRA210 AHUB 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __TEGRA210_AHUB__H__ 108c2ecf20Sopenharmony_ci#define __TEGRA210_AHUB__H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* Tegra210 specific */ 138c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_PART1_RX 0x200 148c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_PART2_RX 0x400 158c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_RX_STRIDE 0x4 168c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_AUDIO_RX_COUNT 90 178c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_REG_MASK_0 0xf1f03ff 188c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_REG_MASK_1 0x3f30031f 198c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_REG_MASK_2 0xff1cf313 208c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_REG_MASK_3 0x0 218c2ecf20Sopenharmony_ci#define TEGRA210_XBAR_UPDATE_MAX_REG 3 228c2ecf20Sopenharmony_ci/* Tegra186 specific */ 238c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_PART3_RX 0x600 248c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_AUDIO_RX_COUNT 115 258c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_REG_MASK_0 0xf3fffff 268c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_REG_MASK_1 0x3f310f1f 278c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_REG_MASK_2 0xff3cf311 288c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_REG_MASK_3 0x3f0f00ff 298c2ecf20Sopenharmony_ci#define TEGRA186_XBAR_UPDATE_MAX_REG 4 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define TEGRA_XBAR_UPDATE_MAX_REG (TEGRA186_XBAR_UPDATE_MAX_REG) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define TEGRA186_MAX_REGISTER_ADDR (TEGRA186_XBAR_PART3_RX + \ 348c2ecf20Sopenharmony_ci (TEGRA210_XBAR_RX_STRIDE * (TEGRA186_XBAR_AUDIO_RX_COUNT - 1))) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define TEGRA210_MAX_REGISTER_ADDR (TEGRA210_XBAR_PART2_RX + \ 378c2ecf20Sopenharmony_ci (TEGRA210_XBAR_RX_STRIDE * (TEGRA210_XBAR_AUDIO_RX_COUNT - 1))) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define MUX_REG(id) (TEGRA210_XBAR_RX_STRIDE * (id)) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define MUX_VALUE(npart, nbit) (1 + (nbit) + (npart) * 32) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_WIDE(xreg, shift, xmax, xtexts, xvalues) \ 448c2ecf20Sopenharmony_ci { \ 458c2ecf20Sopenharmony_ci .reg = xreg, \ 468c2ecf20Sopenharmony_ci .shift_l = shift, \ 478c2ecf20Sopenharmony_ci .shift_r = shift, \ 488c2ecf20Sopenharmony_ci .items = xmax, \ 498c2ecf20Sopenharmony_ci .texts = xtexts, \ 508c2ecf20Sopenharmony_ci .values = xvalues, \ 518c2ecf20Sopenharmony_ci .mask = xmax ? roundup_pow_of_two(xmax) - 1 : 0 \ 528c2ecf20Sopenharmony_ci } 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define SOC_VALUE_ENUM_WIDE_DECL(name, xreg, shift, xtexts, xvalues) \ 558c2ecf20Sopenharmony_ci static struct soc_enum name = \ 568c2ecf20Sopenharmony_ci SOC_VALUE_ENUM_WIDE(xreg, shift, ARRAY_SIZE(xtexts), \ 578c2ecf20Sopenharmony_ci xtexts, xvalues) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define MUX_ENUM_CTRL_DECL(ename, id) \ 608c2ecf20Sopenharmony_ci SOC_VALUE_ENUM_WIDE_DECL(ename##_enum, MUX_REG(id), 0, \ 618c2ecf20Sopenharmony_ci tegra210_ahub_mux_texts, \ 628c2ecf20Sopenharmony_ci tegra210_ahub_mux_values); \ 638c2ecf20Sopenharmony_ci static const struct snd_kcontrol_new ename##_control = \ 648c2ecf20Sopenharmony_ci SOC_DAPM_ENUM_EXT("Route", ename##_enum, \ 658c2ecf20Sopenharmony_ci tegra_ahub_get_value_enum, \ 668c2ecf20Sopenharmony_ci tegra_ahub_put_value_enum) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define MUX_ENUM_CTRL_DECL_186(ename, id) \ 698c2ecf20Sopenharmony_ci SOC_VALUE_ENUM_WIDE_DECL(ename##_enum, MUX_REG(id), 0, \ 708c2ecf20Sopenharmony_ci tegra186_ahub_mux_texts, \ 718c2ecf20Sopenharmony_ci tegra186_ahub_mux_values); \ 728c2ecf20Sopenharmony_ci static const struct snd_kcontrol_new ename##_control = \ 738c2ecf20Sopenharmony_ci SOC_DAPM_ENUM_EXT("Route", ename##_enum, \ 748c2ecf20Sopenharmony_ci tegra_ahub_get_value_enum, \ 758c2ecf20Sopenharmony_ci tegra_ahub_put_value_enum) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define WIDGETS(sname, ename) \ 788c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_IN(sname " XBAR-RX", NULL, 0, SND_SOC_NOPM, 0, 0), \ 798c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_OUT(sname " XBAR-TX", NULL, 0, SND_SOC_NOPM, 0, 0), \ 808c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX(sname " Mux", SND_SOC_NOPM, 0, 0, \ 818c2ecf20Sopenharmony_ci &ename##_control) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define TX_WIDGETS(sname) \ 848c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_IN(sname " XBAR-RX", NULL, 0, SND_SOC_NOPM, 0, 0), \ 858c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_OUT(sname " XBAR-TX", NULL, 0, SND_SOC_NOPM, 0, 0) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define DAI(sname) \ 888c2ecf20Sopenharmony_ci { \ 898c2ecf20Sopenharmony_ci .name = "XBAR-" #sname, \ 908c2ecf20Sopenharmony_ci .playback = { \ 918c2ecf20Sopenharmony_ci .stream_name = #sname " XBAR-Playback", \ 928c2ecf20Sopenharmony_ci .channels_min = 1, \ 938c2ecf20Sopenharmony_ci .channels_max = 16, \ 948c2ecf20Sopenharmony_ci .rates = SNDRV_PCM_RATE_8000_192000, \ 958c2ecf20Sopenharmony_ci .formats = SNDRV_PCM_FMTBIT_S8 | \ 968c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S16_LE | \ 978c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | \ 988c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE, \ 998c2ecf20Sopenharmony_ci }, \ 1008c2ecf20Sopenharmony_ci .capture = { \ 1018c2ecf20Sopenharmony_ci .stream_name = #sname " XBAR-Capture", \ 1028c2ecf20Sopenharmony_ci .channels_min = 1, \ 1038c2ecf20Sopenharmony_ci .channels_max = 16, \ 1048c2ecf20Sopenharmony_ci .rates = SNDRV_PCM_RATE_8000_192000, \ 1058c2ecf20Sopenharmony_ci .formats = SNDRV_PCM_FMTBIT_S8 | \ 1068c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S16_LE | \ 1078c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | \ 1088c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE, \ 1098c2ecf20Sopenharmony_ci }, \ 1108c2ecf20Sopenharmony_ci } 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistruct tegra_ahub_soc_data { 1138c2ecf20Sopenharmony_ci const struct regmap_config *regmap_config; 1148c2ecf20Sopenharmony_ci const struct snd_soc_component_driver *cmpnt_drv; 1158c2ecf20Sopenharmony_ci struct snd_soc_dai_driver *dai_drv; 1168c2ecf20Sopenharmony_ci unsigned int mask[4]; 1178c2ecf20Sopenharmony_ci unsigned int reg_count; 1188c2ecf20Sopenharmony_ci unsigned int num_dais; 1198c2ecf20Sopenharmony_ci}; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistruct tegra_ahub { 1228c2ecf20Sopenharmony_ci const struct tegra_ahub_soc_data *soc_data; 1238c2ecf20Sopenharmony_ci struct regmap *regmap; 1248c2ecf20Sopenharmony_ci struct clk *clk; 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#endif 128