18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// tegra210_ahub.c - Tegra210 AHUB driver 48c2ecf20Sopenharmony_ci// 58c2ecf20Sopenharmony_ci// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/clk.h> 88c2ecf20Sopenharmony_ci#include <linux/device.h> 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 118c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 128c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 138c2ecf20Sopenharmony_ci#include <linux/regmap.h> 148c2ecf20Sopenharmony_ci#include <sound/soc.h> 158c2ecf20Sopenharmony_ci#include "tegra210_ahub.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistatic int tegra_ahub_get_value_enum(struct snd_kcontrol *kctl, 188c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *uctl) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_kcontrol_component(kctl); 218c2ecf20Sopenharmony_ci struct tegra_ahub *ahub = snd_soc_component_get_drvdata(cmpnt); 228c2ecf20Sopenharmony_ci struct soc_enum *e = (struct soc_enum *)kctl->private_value; 238c2ecf20Sopenharmony_ci unsigned int reg, i, bit_pos = 0; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci /* 268c2ecf20Sopenharmony_ci * Find the bit position of current MUX input. 278c2ecf20Sopenharmony_ci * If nothing is set, position would be 0 and it corresponds to 'None'. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci for (i = 0; i < ahub->soc_data->reg_count; i++) { 308c2ecf20Sopenharmony_ci unsigned int reg_val; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci reg = e->reg + (TEGRA210_XBAR_PART1_RX * i); 338c2ecf20Sopenharmony_ci reg_val = snd_soc_component_read(cmpnt, reg); 348c2ecf20Sopenharmony_ci reg_val &= ahub->soc_data->mask[i]; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci if (reg_val) { 378c2ecf20Sopenharmony_ci bit_pos = ffs(reg_val) + 388c2ecf20Sopenharmony_ci (8 * cmpnt->val_bytes * i); 398c2ecf20Sopenharmony_ci break; 408c2ecf20Sopenharmony_ci } 418c2ecf20Sopenharmony_ci } 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* Find index related to the item in array *_ahub_mux_texts[] */ 448c2ecf20Sopenharmony_ci for (i = 0; i < e->items; i++) { 458c2ecf20Sopenharmony_ci if (bit_pos == e->values[i]) { 468c2ecf20Sopenharmony_ci uctl->value.enumerated.item[0] = i; 478c2ecf20Sopenharmony_ci break; 488c2ecf20Sopenharmony_ci } 498c2ecf20Sopenharmony_ci } 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci return 0; 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic int tegra_ahub_put_value_enum(struct snd_kcontrol *kctl, 558c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *uctl) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci struct snd_soc_component *cmpnt = snd_soc_dapm_kcontrol_component(kctl); 588c2ecf20Sopenharmony_ci struct tegra_ahub *ahub = snd_soc_component_get_drvdata(cmpnt); 598c2ecf20Sopenharmony_ci struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kctl); 608c2ecf20Sopenharmony_ci struct soc_enum *e = (struct soc_enum *)kctl->private_value; 618c2ecf20Sopenharmony_ci struct snd_soc_dapm_update update[TEGRA_XBAR_UPDATE_MAX_REG] = { }; 628c2ecf20Sopenharmony_ci unsigned int *item = uctl->value.enumerated.item; 638c2ecf20Sopenharmony_ci unsigned int value = e->values[item[0]]; 648c2ecf20Sopenharmony_ci unsigned int i, bit_pos, reg_idx = 0, reg_val = 0; 658c2ecf20Sopenharmony_ci int change = 0; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci if (item[0] >= e->items) 688c2ecf20Sopenharmony_ci return -EINVAL; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci if (value) { 718c2ecf20Sopenharmony_ci /* Get the register index and value to set */ 728c2ecf20Sopenharmony_ci reg_idx = (value - 1) / (8 * cmpnt->val_bytes); 738c2ecf20Sopenharmony_ci bit_pos = (value - 1) % (8 * cmpnt->val_bytes); 748c2ecf20Sopenharmony_ci reg_val = BIT(bit_pos); 758c2ecf20Sopenharmony_ci } 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci /* 788c2ecf20Sopenharmony_ci * Run through all parts of a MUX register to find the state changes. 798c2ecf20Sopenharmony_ci * There will be an additional update if new MUX input value is from 808c2ecf20Sopenharmony_ci * different part of the MUX register. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci for (i = 0; i < ahub->soc_data->reg_count; i++) { 838c2ecf20Sopenharmony_ci update[i].reg = e->reg + (TEGRA210_XBAR_PART1_RX * i); 848c2ecf20Sopenharmony_ci update[i].val = (i == reg_idx) ? reg_val : 0; 858c2ecf20Sopenharmony_ci update[i].mask = ahub->soc_data->mask[i]; 868c2ecf20Sopenharmony_ci update[i].kcontrol = kctl; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci /* Update widget power if state has changed */ 898c2ecf20Sopenharmony_ci if (snd_soc_component_test_bits(cmpnt, update[i].reg, 908c2ecf20Sopenharmony_ci update[i].mask, 918c2ecf20Sopenharmony_ci update[i].val)) 928c2ecf20Sopenharmony_ci change |= snd_soc_dapm_mux_update_power(dapm, kctl, 938c2ecf20Sopenharmony_ci item[0], e, 948c2ecf20Sopenharmony_ci &update[i]); 958c2ecf20Sopenharmony_ci } 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci return change; 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver tegra210_ahub_dais[] = { 1018c2ecf20Sopenharmony_ci DAI(ADMAIF1), 1028c2ecf20Sopenharmony_ci DAI(ADMAIF2), 1038c2ecf20Sopenharmony_ci DAI(ADMAIF3), 1048c2ecf20Sopenharmony_ci DAI(ADMAIF4), 1058c2ecf20Sopenharmony_ci DAI(ADMAIF5), 1068c2ecf20Sopenharmony_ci DAI(ADMAIF6), 1078c2ecf20Sopenharmony_ci DAI(ADMAIF7), 1088c2ecf20Sopenharmony_ci DAI(ADMAIF8), 1098c2ecf20Sopenharmony_ci DAI(ADMAIF9), 1108c2ecf20Sopenharmony_ci DAI(ADMAIF10), 1118c2ecf20Sopenharmony_ci DAI(I2S1), 1128c2ecf20Sopenharmony_ci DAI(I2S2), 1138c2ecf20Sopenharmony_ci DAI(I2S3), 1148c2ecf20Sopenharmony_ci DAI(I2S4), 1158c2ecf20Sopenharmony_ci DAI(I2S5), 1168c2ecf20Sopenharmony_ci DAI(DMIC1), 1178c2ecf20Sopenharmony_ci DAI(DMIC2), 1188c2ecf20Sopenharmony_ci DAI(DMIC3), 1198c2ecf20Sopenharmony_ci}; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver tegra186_ahub_dais[] = { 1228c2ecf20Sopenharmony_ci DAI(ADMAIF1), 1238c2ecf20Sopenharmony_ci DAI(ADMAIF2), 1248c2ecf20Sopenharmony_ci DAI(ADMAIF3), 1258c2ecf20Sopenharmony_ci DAI(ADMAIF4), 1268c2ecf20Sopenharmony_ci DAI(ADMAIF5), 1278c2ecf20Sopenharmony_ci DAI(ADMAIF6), 1288c2ecf20Sopenharmony_ci DAI(ADMAIF7), 1298c2ecf20Sopenharmony_ci DAI(ADMAIF8), 1308c2ecf20Sopenharmony_ci DAI(ADMAIF9), 1318c2ecf20Sopenharmony_ci DAI(ADMAIF10), 1328c2ecf20Sopenharmony_ci DAI(ADMAIF11), 1338c2ecf20Sopenharmony_ci DAI(ADMAIF12), 1348c2ecf20Sopenharmony_ci DAI(ADMAIF13), 1358c2ecf20Sopenharmony_ci DAI(ADMAIF14), 1368c2ecf20Sopenharmony_ci DAI(ADMAIF15), 1378c2ecf20Sopenharmony_ci DAI(ADMAIF16), 1388c2ecf20Sopenharmony_ci DAI(ADMAIF17), 1398c2ecf20Sopenharmony_ci DAI(ADMAIF18), 1408c2ecf20Sopenharmony_ci DAI(ADMAIF19), 1418c2ecf20Sopenharmony_ci DAI(ADMAIF20), 1428c2ecf20Sopenharmony_ci DAI(I2S1), 1438c2ecf20Sopenharmony_ci DAI(I2S2), 1448c2ecf20Sopenharmony_ci DAI(I2S3), 1458c2ecf20Sopenharmony_ci DAI(I2S4), 1468c2ecf20Sopenharmony_ci DAI(I2S5), 1478c2ecf20Sopenharmony_ci DAI(I2S6), 1488c2ecf20Sopenharmony_ci DAI(DMIC1), 1498c2ecf20Sopenharmony_ci DAI(DMIC2), 1508c2ecf20Sopenharmony_ci DAI(DMIC3), 1518c2ecf20Sopenharmony_ci DAI(DMIC4), 1528c2ecf20Sopenharmony_ci DAI(DSPK1), 1538c2ecf20Sopenharmony_ci DAI(DSPK2), 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic const char * const tegra210_ahub_mux_texts[] = { 1578c2ecf20Sopenharmony_ci "None", 1588c2ecf20Sopenharmony_ci "ADMAIF1", 1598c2ecf20Sopenharmony_ci "ADMAIF2", 1608c2ecf20Sopenharmony_ci "ADMAIF3", 1618c2ecf20Sopenharmony_ci "ADMAIF4", 1628c2ecf20Sopenharmony_ci "ADMAIF5", 1638c2ecf20Sopenharmony_ci "ADMAIF6", 1648c2ecf20Sopenharmony_ci "ADMAIF7", 1658c2ecf20Sopenharmony_ci "ADMAIF8", 1668c2ecf20Sopenharmony_ci "ADMAIF9", 1678c2ecf20Sopenharmony_ci "ADMAIF10", 1688c2ecf20Sopenharmony_ci "I2S1", 1698c2ecf20Sopenharmony_ci "I2S2", 1708c2ecf20Sopenharmony_ci "I2S3", 1718c2ecf20Sopenharmony_ci "I2S4", 1728c2ecf20Sopenharmony_ci "I2S5", 1738c2ecf20Sopenharmony_ci "DMIC1", 1748c2ecf20Sopenharmony_ci "DMIC2", 1758c2ecf20Sopenharmony_ci "DMIC3", 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_cistatic const char * const tegra186_ahub_mux_texts[] = { 1798c2ecf20Sopenharmony_ci "None", 1808c2ecf20Sopenharmony_ci "ADMAIF1", 1818c2ecf20Sopenharmony_ci "ADMAIF2", 1828c2ecf20Sopenharmony_ci "ADMAIF3", 1838c2ecf20Sopenharmony_ci "ADMAIF4", 1848c2ecf20Sopenharmony_ci "ADMAIF5", 1858c2ecf20Sopenharmony_ci "ADMAIF6", 1868c2ecf20Sopenharmony_ci "ADMAIF7", 1878c2ecf20Sopenharmony_ci "ADMAIF8", 1888c2ecf20Sopenharmony_ci "ADMAIF9", 1898c2ecf20Sopenharmony_ci "ADMAIF10", 1908c2ecf20Sopenharmony_ci "ADMAIF11", 1918c2ecf20Sopenharmony_ci "ADMAIF12", 1928c2ecf20Sopenharmony_ci "ADMAIF13", 1938c2ecf20Sopenharmony_ci "ADMAIF14", 1948c2ecf20Sopenharmony_ci "ADMAIF15", 1958c2ecf20Sopenharmony_ci "ADMAIF16", 1968c2ecf20Sopenharmony_ci "I2S1", 1978c2ecf20Sopenharmony_ci "I2S2", 1988c2ecf20Sopenharmony_ci "I2S3", 1998c2ecf20Sopenharmony_ci "I2S4", 2008c2ecf20Sopenharmony_ci "I2S5", 2018c2ecf20Sopenharmony_ci "I2S6", 2028c2ecf20Sopenharmony_ci "ADMAIF17", 2038c2ecf20Sopenharmony_ci "ADMAIF18", 2048c2ecf20Sopenharmony_ci "ADMAIF19", 2058c2ecf20Sopenharmony_ci "ADMAIF20", 2068c2ecf20Sopenharmony_ci "DMIC1", 2078c2ecf20Sopenharmony_ci "DMIC2", 2088c2ecf20Sopenharmony_ci "DMIC3", 2098c2ecf20Sopenharmony_ci "DMIC4", 2108c2ecf20Sopenharmony_ci}; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_cistatic const unsigned int tegra210_ahub_mux_values[] = { 2138c2ecf20Sopenharmony_ci 0, 2148c2ecf20Sopenharmony_ci MUX_VALUE(0, 0), 2158c2ecf20Sopenharmony_ci MUX_VALUE(0, 1), 2168c2ecf20Sopenharmony_ci MUX_VALUE(0, 2), 2178c2ecf20Sopenharmony_ci MUX_VALUE(0, 3), 2188c2ecf20Sopenharmony_ci MUX_VALUE(0, 4), 2198c2ecf20Sopenharmony_ci MUX_VALUE(0, 5), 2208c2ecf20Sopenharmony_ci MUX_VALUE(0, 6), 2218c2ecf20Sopenharmony_ci MUX_VALUE(0, 7), 2228c2ecf20Sopenharmony_ci MUX_VALUE(0, 8), 2238c2ecf20Sopenharmony_ci MUX_VALUE(0, 9), 2248c2ecf20Sopenharmony_ci MUX_VALUE(0, 16), 2258c2ecf20Sopenharmony_ci MUX_VALUE(0, 17), 2268c2ecf20Sopenharmony_ci MUX_VALUE(0, 18), 2278c2ecf20Sopenharmony_ci MUX_VALUE(0, 19), 2288c2ecf20Sopenharmony_ci MUX_VALUE(0, 20), 2298c2ecf20Sopenharmony_ci MUX_VALUE(2, 18), 2308c2ecf20Sopenharmony_ci MUX_VALUE(2, 19), 2318c2ecf20Sopenharmony_ci MUX_VALUE(2, 20), 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic const unsigned int tegra186_ahub_mux_values[] = { 2358c2ecf20Sopenharmony_ci 0, 2368c2ecf20Sopenharmony_ci MUX_VALUE(0, 0), 2378c2ecf20Sopenharmony_ci MUX_VALUE(0, 1), 2388c2ecf20Sopenharmony_ci MUX_VALUE(0, 2), 2398c2ecf20Sopenharmony_ci MUX_VALUE(0, 3), 2408c2ecf20Sopenharmony_ci MUX_VALUE(0, 4), 2418c2ecf20Sopenharmony_ci MUX_VALUE(0, 5), 2428c2ecf20Sopenharmony_ci MUX_VALUE(0, 6), 2438c2ecf20Sopenharmony_ci MUX_VALUE(0, 7), 2448c2ecf20Sopenharmony_ci MUX_VALUE(0, 8), 2458c2ecf20Sopenharmony_ci MUX_VALUE(0, 9), 2468c2ecf20Sopenharmony_ci MUX_VALUE(0, 10), 2478c2ecf20Sopenharmony_ci MUX_VALUE(0, 11), 2488c2ecf20Sopenharmony_ci MUX_VALUE(0, 12), 2498c2ecf20Sopenharmony_ci MUX_VALUE(0, 13), 2508c2ecf20Sopenharmony_ci MUX_VALUE(0, 14), 2518c2ecf20Sopenharmony_ci MUX_VALUE(0, 15), 2528c2ecf20Sopenharmony_ci MUX_VALUE(0, 16), 2538c2ecf20Sopenharmony_ci MUX_VALUE(0, 17), 2548c2ecf20Sopenharmony_ci MUX_VALUE(0, 18), 2558c2ecf20Sopenharmony_ci MUX_VALUE(0, 19), 2568c2ecf20Sopenharmony_ci MUX_VALUE(0, 20), 2578c2ecf20Sopenharmony_ci MUX_VALUE(0, 21), 2588c2ecf20Sopenharmony_ci MUX_VALUE(3, 16), 2598c2ecf20Sopenharmony_ci MUX_VALUE(3, 17), 2608c2ecf20Sopenharmony_ci MUX_VALUE(3, 18), 2618c2ecf20Sopenharmony_ci MUX_VALUE(3, 19), 2628c2ecf20Sopenharmony_ci MUX_VALUE(2, 18), 2638c2ecf20Sopenharmony_ci MUX_VALUE(2, 19), 2648c2ecf20Sopenharmony_ci MUX_VALUE(2, 20), 2658c2ecf20Sopenharmony_ci MUX_VALUE(2, 21), 2668c2ecf20Sopenharmony_ci}; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci/* Controls for t210 */ 2698c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif1_tx, 0x00); 2708c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif2_tx, 0x01); 2718c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif3_tx, 0x02); 2728c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif4_tx, 0x03); 2738c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif5_tx, 0x04); 2748c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif6_tx, 0x05); 2758c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif7_tx, 0x06); 2768c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif8_tx, 0x07); 2778c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif9_tx, 0x08); 2788c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_admaif10_tx, 0x09); 2798c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_i2s1_tx, 0x10); 2808c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_i2s2_tx, 0x11); 2818c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_i2s3_tx, 0x12); 2828c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_i2s4_tx, 0x13); 2838c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL(t210_i2s5_tx, 0x14); 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* Controls for t186 */ 2868c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif1_tx, 0x00); 2878c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif2_tx, 0x01); 2888c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif3_tx, 0x02); 2898c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif4_tx, 0x03); 2908c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif5_tx, 0x04); 2918c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif6_tx, 0x05); 2928c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif7_tx, 0x06); 2938c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif8_tx, 0x07); 2948c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif9_tx, 0x08); 2958c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif10_tx, 0x09); 2968c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s1_tx, 0x10); 2978c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s2_tx, 0x11); 2988c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s3_tx, 0x12); 2998c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s4_tx, 0x13); 3008c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s5_tx, 0x14); 3018c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif11_tx, 0x0a); 3028c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif12_tx, 0x0b); 3038c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif13_tx, 0x0c); 3048c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif14_tx, 0x0d); 3058c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif15_tx, 0x0e); 3068c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif16_tx, 0x0f); 3078c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_i2s6_tx, 0x15); 3088c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_dspk1_tx, 0x30); 3098c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_dspk2_tx, 0x31); 3108c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif17_tx, 0x68); 3118c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif18_tx, 0x69); 3128c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif19_tx, 0x6a); 3138c2ecf20Sopenharmony_ciMUX_ENUM_CTRL_DECL_186(t186_admaif20_tx, 0x6b); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/* 3168c2ecf20Sopenharmony_ci * The number of entries in, and order of, this array is closely tied to the 3178c2ecf20Sopenharmony_ci * calculation of tegra210_ahub_codec.num_dapm_widgets near the end of 3188c2ecf20Sopenharmony_ci * tegra210_ahub_probe() 3198c2ecf20Sopenharmony_ci */ 3208c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget tegra210_ahub_widgets[] = { 3218c2ecf20Sopenharmony_ci WIDGETS("ADMAIF1", t210_admaif1_tx), 3228c2ecf20Sopenharmony_ci WIDGETS("ADMAIF2", t210_admaif2_tx), 3238c2ecf20Sopenharmony_ci WIDGETS("ADMAIF3", t210_admaif3_tx), 3248c2ecf20Sopenharmony_ci WIDGETS("ADMAIF4", t210_admaif4_tx), 3258c2ecf20Sopenharmony_ci WIDGETS("ADMAIF5", t210_admaif5_tx), 3268c2ecf20Sopenharmony_ci WIDGETS("ADMAIF6", t210_admaif6_tx), 3278c2ecf20Sopenharmony_ci WIDGETS("ADMAIF7", t210_admaif7_tx), 3288c2ecf20Sopenharmony_ci WIDGETS("ADMAIF8", t210_admaif8_tx), 3298c2ecf20Sopenharmony_ci WIDGETS("ADMAIF9", t210_admaif9_tx), 3308c2ecf20Sopenharmony_ci WIDGETS("ADMAIF10", t210_admaif10_tx), 3318c2ecf20Sopenharmony_ci WIDGETS("I2S1", t210_i2s1_tx), 3328c2ecf20Sopenharmony_ci WIDGETS("I2S2", t210_i2s2_tx), 3338c2ecf20Sopenharmony_ci WIDGETS("I2S3", t210_i2s3_tx), 3348c2ecf20Sopenharmony_ci WIDGETS("I2S4", t210_i2s4_tx), 3358c2ecf20Sopenharmony_ci WIDGETS("I2S5", t210_i2s5_tx), 3368c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC1"), 3378c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC2"), 3388c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC3"), 3398c2ecf20Sopenharmony_ci}; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget tegra186_ahub_widgets[] = { 3428c2ecf20Sopenharmony_ci WIDGETS("ADMAIF1", t186_admaif1_tx), 3438c2ecf20Sopenharmony_ci WIDGETS("ADMAIF2", t186_admaif2_tx), 3448c2ecf20Sopenharmony_ci WIDGETS("ADMAIF3", t186_admaif3_tx), 3458c2ecf20Sopenharmony_ci WIDGETS("ADMAIF4", t186_admaif4_tx), 3468c2ecf20Sopenharmony_ci WIDGETS("ADMAIF5", t186_admaif5_tx), 3478c2ecf20Sopenharmony_ci WIDGETS("ADMAIF6", t186_admaif6_tx), 3488c2ecf20Sopenharmony_ci WIDGETS("ADMAIF7", t186_admaif7_tx), 3498c2ecf20Sopenharmony_ci WIDGETS("ADMAIF8", t186_admaif8_tx), 3508c2ecf20Sopenharmony_ci WIDGETS("ADMAIF9", t186_admaif9_tx), 3518c2ecf20Sopenharmony_ci WIDGETS("ADMAIF10", t186_admaif10_tx), 3528c2ecf20Sopenharmony_ci WIDGETS("ADMAIF11", t186_admaif11_tx), 3538c2ecf20Sopenharmony_ci WIDGETS("ADMAIF12", t186_admaif12_tx), 3548c2ecf20Sopenharmony_ci WIDGETS("ADMAIF13", t186_admaif13_tx), 3558c2ecf20Sopenharmony_ci WIDGETS("ADMAIF14", t186_admaif14_tx), 3568c2ecf20Sopenharmony_ci WIDGETS("ADMAIF15", t186_admaif15_tx), 3578c2ecf20Sopenharmony_ci WIDGETS("ADMAIF16", t186_admaif16_tx), 3588c2ecf20Sopenharmony_ci WIDGETS("ADMAIF17", t186_admaif17_tx), 3598c2ecf20Sopenharmony_ci WIDGETS("ADMAIF18", t186_admaif18_tx), 3608c2ecf20Sopenharmony_ci WIDGETS("ADMAIF19", t186_admaif19_tx), 3618c2ecf20Sopenharmony_ci WIDGETS("ADMAIF20", t186_admaif20_tx), 3628c2ecf20Sopenharmony_ci WIDGETS("I2S1", t186_i2s1_tx), 3638c2ecf20Sopenharmony_ci WIDGETS("I2S2", t186_i2s2_tx), 3648c2ecf20Sopenharmony_ci WIDGETS("I2S3", t186_i2s3_tx), 3658c2ecf20Sopenharmony_ci WIDGETS("I2S4", t186_i2s4_tx), 3668c2ecf20Sopenharmony_ci WIDGETS("I2S5", t186_i2s5_tx), 3678c2ecf20Sopenharmony_ci WIDGETS("I2S6", t186_i2s6_tx), 3688c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC1"), 3698c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC2"), 3708c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC3"), 3718c2ecf20Sopenharmony_ci TX_WIDGETS("DMIC4"), 3728c2ecf20Sopenharmony_ci WIDGETS("DSPK1", t186_dspk1_tx), 3738c2ecf20Sopenharmony_ci WIDGETS("DSPK2", t186_dspk2_tx), 3748c2ecf20Sopenharmony_ci}; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci#define TEGRA_COMMON_MUX_ROUTES(name) \ 3778c2ecf20Sopenharmony_ci { name " XBAR-TX", NULL, name " Mux" }, \ 3788c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF1", "ADMAIF1 XBAR-RX" }, \ 3798c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF2", "ADMAIF2 XBAR-RX" }, \ 3808c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF3", "ADMAIF3 XBAR-RX" }, \ 3818c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF4", "ADMAIF4 XBAR-RX" }, \ 3828c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF5", "ADMAIF5 XBAR-RX" }, \ 3838c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF6", "ADMAIF6 XBAR-RX" }, \ 3848c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF7", "ADMAIF7 XBAR-RX" }, \ 3858c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF8", "ADMAIF8 XBAR-RX" }, \ 3868c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF9", "ADMAIF9 XBAR-RX" }, \ 3878c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF10", "ADMAIF10 XBAR-RX" }, \ 3888c2ecf20Sopenharmony_ci { name " Mux", "I2S1", "I2S1 XBAR-RX" }, \ 3898c2ecf20Sopenharmony_ci { name " Mux", "I2S2", "I2S2 XBAR-RX" }, \ 3908c2ecf20Sopenharmony_ci { name " Mux", "I2S3", "I2S3 XBAR-RX" }, \ 3918c2ecf20Sopenharmony_ci { name " Mux", "I2S4", "I2S4 XBAR-RX" }, \ 3928c2ecf20Sopenharmony_ci { name " Mux", "I2S5", "I2S5 XBAR-RX" }, \ 3938c2ecf20Sopenharmony_ci { name " Mux", "DMIC1", "DMIC1 XBAR-RX" }, \ 3948c2ecf20Sopenharmony_ci { name " Mux", "DMIC2", "DMIC2 XBAR-RX" }, \ 3958c2ecf20Sopenharmony_ci { name " Mux", "DMIC3", "DMIC3 XBAR-RX" }, 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define TEGRA186_ONLY_MUX_ROUTES(name) \ 3988c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF11", "ADMAIF11 XBAR-RX" }, \ 3998c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF12", "ADMAIF12 XBAR-RX" }, \ 4008c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF13", "ADMAIF13 XBAR-RX" }, \ 4018c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF14", "ADMAIF14 XBAR-RX" }, \ 4028c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF15", "ADMAIF15 XBAR-RX" }, \ 4038c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF16", "ADMAIF16 XBAR-RX" }, \ 4048c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF17", "ADMAIF17 XBAR-RX" }, \ 4058c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF18", "ADMAIF18 XBAR-RX" }, \ 4068c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF19", "ADMAIF19 XBAR-RX" }, \ 4078c2ecf20Sopenharmony_ci { name " Mux", "ADMAIF20", "ADMAIF20 XBAR-RX" }, \ 4088c2ecf20Sopenharmony_ci { name " Mux", "I2S6", "I2S6 XBAR-RX" }, \ 4098c2ecf20Sopenharmony_ci { name " Mux", "DMIC4", "DMIC4 XBAR-RX" }, 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci#define TEGRA210_MUX_ROUTES(name) \ 4128c2ecf20Sopenharmony_ci TEGRA_COMMON_MUX_ROUTES(name) 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci#define TEGRA186_MUX_ROUTES(name) \ 4158c2ecf20Sopenharmony_ci TEGRA_COMMON_MUX_ROUTES(name) \ 4168c2ecf20Sopenharmony_ci TEGRA186_ONLY_MUX_ROUTES(name) 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/* Connect FEs with XBAR */ 4198c2ecf20Sopenharmony_ci#define TEGRA_FE_ROUTES(name) \ 4208c2ecf20Sopenharmony_ci { name " XBAR-Playback", NULL, name " Playback" }, \ 4218c2ecf20Sopenharmony_ci { name " XBAR-RX", NULL, name " XBAR-Playback"}, \ 4228c2ecf20Sopenharmony_ci { name " XBAR-Capture", NULL, name " XBAR-TX" }, \ 4238c2ecf20Sopenharmony_ci { name " Capture", NULL, name " XBAR-Capture" }, 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci/* 4268c2ecf20Sopenharmony_ci * The number of entries in, and order of, this array is closely tied to the 4278c2ecf20Sopenharmony_ci * calculation of tegra210_ahub_codec.num_dapm_routes near the end of 4288c2ecf20Sopenharmony_ci * tegra210_ahub_probe() 4298c2ecf20Sopenharmony_ci */ 4308c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route tegra210_ahub_routes[] = { 4318c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF1") 4328c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF2") 4338c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF3") 4348c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF4") 4358c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF5") 4368c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF6") 4378c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF7") 4388c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF8") 4398c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF9") 4408c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF10") 4418c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF1") 4428c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF2") 4438c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF3") 4448c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF4") 4458c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF5") 4468c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF6") 4478c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF7") 4488c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF8") 4498c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF9") 4508c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("ADMAIF10") 4518c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("I2S1") 4528c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("I2S2") 4538c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("I2S3") 4548c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("I2S4") 4558c2ecf20Sopenharmony_ci TEGRA210_MUX_ROUTES("I2S5") 4568c2ecf20Sopenharmony_ci}; 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route tegra186_ahub_routes[] = { 4598c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF1") 4608c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF2") 4618c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF3") 4628c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF4") 4638c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF5") 4648c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF6") 4658c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF7") 4668c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF8") 4678c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF9") 4688c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF10") 4698c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF11") 4708c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF12") 4718c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF13") 4728c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF14") 4738c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF15") 4748c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF16") 4758c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF17") 4768c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF18") 4778c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF19") 4788c2ecf20Sopenharmony_ci TEGRA_FE_ROUTES("ADMAIF20") 4798c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF1") 4808c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF2") 4818c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF3") 4828c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF4") 4838c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF5") 4848c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF6") 4858c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF7") 4868c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF8") 4878c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF9") 4888c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF10") 4898c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF11") 4908c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF12") 4918c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF13") 4928c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF14") 4938c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF15") 4948c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF16") 4958c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF17") 4968c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF18") 4978c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF19") 4988c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("ADMAIF20") 4998c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S1") 5008c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S2") 5018c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S3") 5028c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S4") 5038c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S5") 5048c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("I2S6") 5058c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("DSPK1") 5068c2ecf20Sopenharmony_ci TEGRA186_MUX_ROUTES("DSPK2") 5078c2ecf20Sopenharmony_ci}; 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver tegra210_ahub_component = { 5108c2ecf20Sopenharmony_ci .dapm_widgets = tegra210_ahub_widgets, 5118c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(tegra210_ahub_widgets), 5128c2ecf20Sopenharmony_ci .dapm_routes = tegra210_ahub_routes, 5138c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(tegra210_ahub_routes), 5148c2ecf20Sopenharmony_ci}; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver tegra186_ahub_component = { 5178c2ecf20Sopenharmony_ci .dapm_widgets = tegra186_ahub_widgets, 5188c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(tegra186_ahub_widgets), 5198c2ecf20Sopenharmony_ci .dapm_routes = tegra186_ahub_routes, 5208c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(tegra186_ahub_routes), 5218c2ecf20Sopenharmony_ci}; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_cistatic const struct regmap_config tegra210_ahub_regmap_config = { 5248c2ecf20Sopenharmony_ci .reg_bits = 32, 5258c2ecf20Sopenharmony_ci .val_bits = 32, 5268c2ecf20Sopenharmony_ci .reg_stride = 4, 5278c2ecf20Sopenharmony_ci .max_register = TEGRA210_MAX_REGISTER_ADDR, 5288c2ecf20Sopenharmony_ci .cache_type = REGCACHE_FLAT, 5298c2ecf20Sopenharmony_ci}; 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_cistatic const struct regmap_config tegra186_ahub_regmap_config = { 5328c2ecf20Sopenharmony_ci .reg_bits = 32, 5338c2ecf20Sopenharmony_ci .val_bits = 32, 5348c2ecf20Sopenharmony_ci .reg_stride = 4, 5358c2ecf20Sopenharmony_ci .max_register = TEGRA186_MAX_REGISTER_ADDR, 5368c2ecf20Sopenharmony_ci .cache_type = REGCACHE_FLAT, 5378c2ecf20Sopenharmony_ci}; 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_cistatic const struct tegra_ahub_soc_data soc_data_tegra210 = { 5408c2ecf20Sopenharmony_ci .cmpnt_drv = &tegra210_ahub_component, 5418c2ecf20Sopenharmony_ci .dai_drv = tegra210_ahub_dais, 5428c2ecf20Sopenharmony_ci .num_dais = ARRAY_SIZE(tegra210_ahub_dais), 5438c2ecf20Sopenharmony_ci .regmap_config = &tegra210_ahub_regmap_config, 5448c2ecf20Sopenharmony_ci .mask[0] = TEGRA210_XBAR_REG_MASK_0, 5458c2ecf20Sopenharmony_ci .mask[1] = TEGRA210_XBAR_REG_MASK_1, 5468c2ecf20Sopenharmony_ci .mask[2] = TEGRA210_XBAR_REG_MASK_2, 5478c2ecf20Sopenharmony_ci .mask[3] = TEGRA210_XBAR_REG_MASK_3, 5488c2ecf20Sopenharmony_ci .reg_count = TEGRA210_XBAR_UPDATE_MAX_REG, 5498c2ecf20Sopenharmony_ci}; 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_cistatic const struct tegra_ahub_soc_data soc_data_tegra186 = { 5528c2ecf20Sopenharmony_ci .cmpnt_drv = &tegra186_ahub_component, 5538c2ecf20Sopenharmony_ci .dai_drv = tegra186_ahub_dais, 5548c2ecf20Sopenharmony_ci .num_dais = ARRAY_SIZE(tegra186_ahub_dais), 5558c2ecf20Sopenharmony_ci .regmap_config = &tegra186_ahub_regmap_config, 5568c2ecf20Sopenharmony_ci .mask[0] = TEGRA186_XBAR_REG_MASK_0, 5578c2ecf20Sopenharmony_ci .mask[1] = TEGRA186_XBAR_REG_MASK_1, 5588c2ecf20Sopenharmony_ci .mask[2] = TEGRA186_XBAR_REG_MASK_2, 5598c2ecf20Sopenharmony_ci .mask[3] = TEGRA186_XBAR_REG_MASK_3, 5608c2ecf20Sopenharmony_ci .reg_count = TEGRA186_XBAR_UPDATE_MAX_REG, 5618c2ecf20Sopenharmony_ci}; 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_cistatic const struct of_device_id tegra_ahub_of_match[] = { 5648c2ecf20Sopenharmony_ci { .compatible = "nvidia,tegra210-ahub", .data = &soc_data_tegra210 }, 5658c2ecf20Sopenharmony_ci { .compatible = "nvidia,tegra186-ahub", .data = &soc_data_tegra186 }, 5668c2ecf20Sopenharmony_ci {}, 5678c2ecf20Sopenharmony_ci}; 5688c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, tegra_ahub_of_match); 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_cistatic int __maybe_unused tegra_ahub_runtime_suspend(struct device *dev) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci struct tegra_ahub *ahub = dev_get_drvdata(dev); 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci regcache_cache_only(ahub->regmap, true); 5758c2ecf20Sopenharmony_ci regcache_mark_dirty(ahub->regmap); 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci clk_disable_unprepare(ahub->clk); 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci return 0; 5808c2ecf20Sopenharmony_ci} 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_cistatic int __maybe_unused tegra_ahub_runtime_resume(struct device *dev) 5838c2ecf20Sopenharmony_ci{ 5848c2ecf20Sopenharmony_ci struct tegra_ahub *ahub = dev_get_drvdata(dev); 5858c2ecf20Sopenharmony_ci int err; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci err = clk_prepare_enable(ahub->clk); 5888c2ecf20Sopenharmony_ci if (err) { 5898c2ecf20Sopenharmony_ci dev_err(dev, "failed to enable AHUB clock, err: %d\n", err); 5908c2ecf20Sopenharmony_ci return err; 5918c2ecf20Sopenharmony_ci } 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci regcache_cache_only(ahub->regmap, false); 5948c2ecf20Sopenharmony_ci regcache_sync(ahub->regmap); 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci return 0; 5978c2ecf20Sopenharmony_ci} 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_cistatic int tegra_ahub_probe(struct platform_device *pdev) 6008c2ecf20Sopenharmony_ci{ 6018c2ecf20Sopenharmony_ci struct tegra_ahub *ahub; 6028c2ecf20Sopenharmony_ci void __iomem *regs; 6038c2ecf20Sopenharmony_ci int err; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci ahub = devm_kzalloc(&pdev->dev, sizeof(*ahub), GFP_KERNEL); 6068c2ecf20Sopenharmony_ci if (!ahub) 6078c2ecf20Sopenharmony_ci return -ENOMEM; 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci ahub->soc_data = of_device_get_match_data(&pdev->dev); 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, ahub); 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci ahub->clk = devm_clk_get(&pdev->dev, "ahub"); 6148c2ecf20Sopenharmony_ci if (IS_ERR(ahub->clk)) { 6158c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "can't retrieve AHUB clock\n"); 6168c2ecf20Sopenharmony_ci return PTR_ERR(ahub->clk); 6178c2ecf20Sopenharmony_ci } 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci regs = devm_platform_ioremap_resource(pdev, 0); 6208c2ecf20Sopenharmony_ci if (IS_ERR(regs)) 6218c2ecf20Sopenharmony_ci return PTR_ERR(regs); 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci ahub->regmap = devm_regmap_init_mmio(&pdev->dev, regs, 6248c2ecf20Sopenharmony_ci ahub->soc_data->regmap_config); 6258c2ecf20Sopenharmony_ci if (IS_ERR(ahub->regmap)) { 6268c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "regmap init failed\n"); 6278c2ecf20Sopenharmony_ci return PTR_ERR(ahub->regmap); 6288c2ecf20Sopenharmony_ci } 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci regcache_cache_only(ahub->regmap, true); 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci err = devm_snd_soc_register_component(&pdev->dev, 6338c2ecf20Sopenharmony_ci ahub->soc_data->cmpnt_drv, 6348c2ecf20Sopenharmony_ci ahub->soc_data->dai_drv, 6358c2ecf20Sopenharmony_ci ahub->soc_data->num_dais); 6368c2ecf20Sopenharmony_ci if (err) { 6378c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "can't register AHUB component, err: %d\n", 6388c2ecf20Sopenharmony_ci err); 6398c2ecf20Sopenharmony_ci return err; 6408c2ecf20Sopenharmony_ci } 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci err = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); 6438c2ecf20Sopenharmony_ci if (err) 6448c2ecf20Sopenharmony_ci return err; 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci pm_runtime_enable(&pdev->dev); 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci return 0; 6498c2ecf20Sopenharmony_ci} 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_cistatic int tegra_ahub_remove(struct platform_device *pdev) 6528c2ecf20Sopenharmony_ci{ 6538c2ecf20Sopenharmony_ci pm_runtime_disable(&pdev->dev); 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci return 0; 6568c2ecf20Sopenharmony_ci} 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_cistatic const struct dev_pm_ops tegra_ahub_pm_ops = { 6598c2ecf20Sopenharmony_ci SET_RUNTIME_PM_OPS(tegra_ahub_runtime_suspend, 6608c2ecf20Sopenharmony_ci tegra_ahub_runtime_resume, NULL) 6618c2ecf20Sopenharmony_ci SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 6628c2ecf20Sopenharmony_ci pm_runtime_force_resume) 6638c2ecf20Sopenharmony_ci}; 6648c2ecf20Sopenharmony_ci 6658c2ecf20Sopenharmony_cistatic struct platform_driver tegra_ahub_driver = { 6668c2ecf20Sopenharmony_ci .probe = tegra_ahub_probe, 6678c2ecf20Sopenharmony_ci .remove = tegra_ahub_remove, 6688c2ecf20Sopenharmony_ci .driver = { 6698c2ecf20Sopenharmony_ci .name = "tegra210-ahub", 6708c2ecf20Sopenharmony_ci .of_match_table = tegra_ahub_of_match, 6718c2ecf20Sopenharmony_ci .pm = &tegra_ahub_pm_ops, 6728c2ecf20Sopenharmony_ci }, 6738c2ecf20Sopenharmony_ci}; 6748c2ecf20Sopenharmony_cimodule_platform_driver(tegra_ahub_driver); 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ciMODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 6778c2ecf20Sopenharmony_ciMODULE_AUTHOR("Mohan Kumar <mkumard@nvidia.com>"); 6788c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Tegra210 ASoC AHUB driver"); 6798c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 680