18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * tegra_cif.h - TEGRA Audio CIF Programming 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __TEGRA_CIF_H__ 108c2ecf20Sopenharmony_ci#define __TEGRA_CIF_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/regmap.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_FIFO_TH_SHIFT 24 158c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_AUDIO_CH_SHIFT 20 168c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_CLIENT_CH_SHIFT 16 178c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_AUDIO_BITS_SHIFT 12 188c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_CLIENT_BITS_SHIFT 8 198c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_EXPAND_SHIFT 6 208c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_STEREO_CONV_SHIFT 4 218c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_REPLICATE_SHIFT 3 228c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_TRUNCATE_SHIFT 1 238c2ecf20Sopenharmony_ci#define TEGRA_ACIF_CTRL_MONO_CONV_SHIFT 0 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* AUDIO/CLIENT_BITS values */ 268c2ecf20Sopenharmony_ci#define TEGRA_ACIF_BITS_8 1 278c2ecf20Sopenharmony_ci#define TEGRA_ACIF_BITS_16 3 288c2ecf20Sopenharmony_ci#define TEGRA_ACIF_BITS_24 5 298c2ecf20Sopenharmony_ci#define TEGRA_ACIF_BITS_32 7 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define TEGRA_ACIF_UPDATE_MASK 0x3ffffffb 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct tegra_cif_conf { 348c2ecf20Sopenharmony_ci unsigned int threshold; 358c2ecf20Sopenharmony_ci unsigned int audio_ch; 368c2ecf20Sopenharmony_ci unsigned int client_ch; 378c2ecf20Sopenharmony_ci unsigned int audio_bits; 388c2ecf20Sopenharmony_ci unsigned int client_bits; 398c2ecf20Sopenharmony_ci unsigned int expand; 408c2ecf20Sopenharmony_ci unsigned int stereo_conv; 418c2ecf20Sopenharmony_ci unsigned int replicate; 428c2ecf20Sopenharmony_ci unsigned int truncate; 438c2ecf20Sopenharmony_ci unsigned int mono_conv; 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic inline void tegra_set_cif(struct regmap *regmap, unsigned int reg, 478c2ecf20Sopenharmony_ci struct tegra_cif_conf *conf) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci unsigned int value; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci value = (conf->threshold << TEGRA_ACIF_CTRL_FIFO_TH_SHIFT) | 528c2ecf20Sopenharmony_ci ((conf->audio_ch - 1) << TEGRA_ACIF_CTRL_AUDIO_CH_SHIFT) | 538c2ecf20Sopenharmony_ci ((conf->client_ch - 1) << TEGRA_ACIF_CTRL_CLIENT_CH_SHIFT) | 548c2ecf20Sopenharmony_ci (conf->audio_bits << TEGRA_ACIF_CTRL_AUDIO_BITS_SHIFT) | 558c2ecf20Sopenharmony_ci (conf->client_bits << TEGRA_ACIF_CTRL_CLIENT_BITS_SHIFT) | 568c2ecf20Sopenharmony_ci (conf->expand << TEGRA_ACIF_CTRL_EXPAND_SHIFT) | 578c2ecf20Sopenharmony_ci (conf->stereo_conv << TEGRA_ACIF_CTRL_STEREO_CONV_SHIFT) | 588c2ecf20Sopenharmony_ci (conf->replicate << TEGRA_ACIF_CTRL_REPLICATE_SHIFT) | 598c2ecf20Sopenharmony_ci (conf->truncate << TEGRA_ACIF_CTRL_TRUNCATE_SHIFT) | 608c2ecf20Sopenharmony_ci (conf->mono_conv << TEGRA_ACIF_CTRL_MONO_CONV_SHIFT); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci regmap_update_bits(regmap, reg, TEGRA_ACIF_UPDATE_MASK, value); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#endif 66