162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * tegra210_mvc.h - Definitions for Tegra210 MVC driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2021 NVIDIA CORPORATION. All rights reserved. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __TEGRA210_MVC_H__ 1062306a36Sopenharmony_ci#define __TEGRA210_MVC_H__ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* 1362306a36Sopenharmony_ci * MVC_RX registers are with respect to XBAR. 1462306a36Sopenharmony_ci * The data comes from XBAR to MVC. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci#define TEGRA210_MVC_RX_STATUS 0x0c 1762306a36Sopenharmony_ci#define TEGRA210_MVC_RX_INT_STATUS 0x10 1862306a36Sopenharmony_ci#define TEGRA210_MVC_RX_INT_MASK 0x14 1962306a36Sopenharmony_ci#define TEGRA210_MVC_RX_INT_SET 0x18 2062306a36Sopenharmony_ci#define TEGRA210_MVC_RX_INT_CLEAR 0x1c 2162306a36Sopenharmony_ci#define TEGRA210_MVC_RX_CIF_CTRL 0x20 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/* 2462306a36Sopenharmony_ci * MVC_TX registers are with respect to XBAR. 2562306a36Sopenharmony_ci * The data goes out of MVC. 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_ci#define TEGRA210_MVC_TX_STATUS 0x4c 2862306a36Sopenharmony_ci#define TEGRA210_MVC_TX_INT_STATUS 0x50 2962306a36Sopenharmony_ci#define TEGRA210_MVC_TX_INT_MASK 0x54 3062306a36Sopenharmony_ci#define TEGRA210_MVC_TX_INT_SET 0x58 3162306a36Sopenharmony_ci#define TEGRA210_MVC_TX_INT_CLEAR 0x5c 3262306a36Sopenharmony_ci#define TEGRA210_MVC_TX_CIF_CTRL 0x60 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* Register offsets from TEGRA210_MVC*_BASE */ 3562306a36Sopenharmony_ci#define TEGRA210_MVC_ENABLE 0x80 3662306a36Sopenharmony_ci#define TEGRA210_MVC_SOFT_RESET 0x84 3762306a36Sopenharmony_ci#define TEGRA210_MVC_CG 0x88 3862306a36Sopenharmony_ci#define TEGRA210_MVC_STATUS 0x90 3962306a36Sopenharmony_ci#define TEGRA210_MVC_INT_STATUS 0x94 4062306a36Sopenharmony_ci#define TEGRA210_MVC_CTRL 0xa8 4162306a36Sopenharmony_ci#define TEGRA210_MVC_SWITCH 0xac 4262306a36Sopenharmony_ci#define TEGRA210_MVC_INIT_VOL 0xb0 4362306a36Sopenharmony_ci#define TEGRA210_MVC_TARGET_VOL 0xd0 4462306a36Sopenharmony_ci#define TEGRA210_MVC_DURATION 0xf0 4562306a36Sopenharmony_ci#define TEGRA210_MVC_DURATION_INV 0xf4 4662306a36Sopenharmony_ci#define TEGRA210_MVC_POLY_N1 0xf8 4762306a36Sopenharmony_ci#define TEGRA210_MVC_POLY_N2 0xfc 4862306a36Sopenharmony_ci#define TEGRA210_MVC_PEAK_CTRL 0x100 4962306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL 0x104 5062306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_DATA 0x108 5162306a36Sopenharmony_ci#define TEGRA210_MVC_PEAK_VALUE 0x10c 5262306a36Sopenharmony_ci#define TEGRA210_MVC_CONFIG_ERR_TYPE 0x12c 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* Fields in TEGRA210_MVC_ENABLE */ 5562306a36Sopenharmony_ci#define TEGRA210_MVC_EN_SHIFT 0 5662306a36Sopenharmony_ci#define TEGRA210_MVC_EN (1 << TEGRA210_MVC_EN_SHIFT) 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define TEGRA210_MVC_MUTE_SHIFT 8 5962306a36Sopenharmony_ci#define TEGRA210_MUTE_MASK_EN 0xff 6062306a36Sopenharmony_ci#define TEGRA210_MVC_MUTE_MASK (TEGRA210_MUTE_MASK_EN << TEGRA210_MVC_MUTE_SHIFT) 6162306a36Sopenharmony_ci#define TEGRA210_MVC_MUTE_EN (TEGRA210_MUTE_MASK_EN << TEGRA210_MVC_MUTE_SHIFT) 6262306a36Sopenharmony_ci#define TEGRA210_MVC_CH0_MUTE_EN 1 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define TEGRA210_MVC_PER_CHAN_CTRL_EN_SHIFT 30 6562306a36Sopenharmony_ci#define TEGRA210_MVC_PER_CHAN_CTRL_EN_MASK (1 << TEGRA210_MVC_PER_CHAN_CTRL_EN_SHIFT) 6662306a36Sopenharmony_ci#define TEGRA210_MVC_PER_CHAN_CTRL_EN (1 << TEGRA210_MVC_PER_CHAN_CTRL_EN_SHIFT) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define TEGRA210_MVC_CURVE_TYPE_SHIFT 1 6962306a36Sopenharmony_ci#define TEGRA210_MVC_CURVE_TYPE_MASK (1 << TEGRA210_MVC_CURVE_TYPE_SHIFT) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define TEGRA210_MVC_VOLUME_SWITCH_SHIFT 2 7262306a36Sopenharmony_ci#define TEGRA210_MVC_VOLUME_SWITCH_MASK (1 << TEGRA210_MVC_VOLUME_SWITCH_SHIFT) 7362306a36Sopenharmony_ci#define TEGRA210_MVC_VOLUME_SWITCH_TRIGGER (1 << TEGRA210_MVC_VOLUME_SWITCH_SHIFT) 7462306a36Sopenharmony_ci#define TEGRA210_MVC_CTRL_DEFAULT 0x40000003 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define TEGRA210_MVC_INIT_VOL_DEFAULT_POLY 0x01000000 7762306a36Sopenharmony_ci#define TEGRA210_MVC_INIT_VOL_DEFAULT_LINEAR 0x00000000 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* Fields in TEGRA210_MVC ram ctrl */ 8062306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_RW_SHIFT 14 8162306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_RW_WRITE (1 << TEGRA210_MVC_CFG_RAM_CTRL_RW_SHIFT) 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_ADDR_INIT_EN_SHIFT 13 8462306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_ADDR_INIT_EN (1 << TEGRA210_MVC_CFG_RAM_CTRL_ADDR_INIT_EN_SHIFT) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_SEQ_ACCESS_EN_SHIFT 12 8762306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_SEQ_ACCESS_EN (1 << TEGRA210_MVC_CFG_RAM_CTRL_SEQ_ACCESS_EN_SHIFT) 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_ADDR_SHIFT 0 9062306a36Sopenharmony_ci#define TEGRA210_MVC_CFG_RAM_CTRL_ADDR_MASK (0x1ff << TEGRA210_MVC_CFG_RAM_CTRL_ADDR_SHIFT) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define REG_SIZE 4 9362306a36Sopenharmony_ci#define TEGRA210_MVC_MAX_CHAN_COUNT 8 9462306a36Sopenharmony_ci#define TEGRA210_MVC_REG_OFFSET(reg, i) (reg + (REG_SIZE * i)) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define TEGRA210_MVC_GET_CHAN(reg, base) (((reg) - (base)) / REG_SIZE) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define TEGRA210_GET_MUTE_VAL(val) (((val) >> TEGRA210_MVC_MUTE_SHIFT) & TEGRA210_MUTE_MASK_EN) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define NUM_GAIN_POLY_COEFFS 9 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cienum { 10362306a36Sopenharmony_ci CURVE_POLY, 10462306a36Sopenharmony_ci CURVE_LINEAR, 10562306a36Sopenharmony_ci}; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_cistruct tegra210_mvc_gain_params { 10862306a36Sopenharmony_ci int poly_coeff[NUM_GAIN_POLY_COEFFS]; 10962306a36Sopenharmony_ci int poly_n1; 11062306a36Sopenharmony_ci int poly_n2; 11162306a36Sopenharmony_ci int duration; 11262306a36Sopenharmony_ci int duration_inv; 11362306a36Sopenharmony_ci}; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cistruct tegra210_mvc { 11662306a36Sopenharmony_ci int volume[TEGRA210_MVC_MAX_CHAN_COUNT]; 11762306a36Sopenharmony_ci unsigned int curve_type; 11862306a36Sopenharmony_ci unsigned int ctrl_value; 11962306a36Sopenharmony_ci struct regmap *regmap; 12062306a36Sopenharmony_ci}; 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#endif 123