1 /* SPDX-License-Identifier: GPL-2.0 */
3 // ALSA SoC Texas Instruments TAS2781 Audio Smart Amplifier
5 // Copyright (C) 2022 - 2023 Texas Instruments Incorporated
8 // The TAS2781 driver implements a flexible and configurable
9 // algo coefficient setting for one, two, or even multiple
12 // Author: Shenghao Ding <shenghao-ding@ti.com>
13 // Author: Kevin Lu <kevin-lu@ti.com>
16 #ifndef __TASDEVICE_DSP_H__
17 #define __TASDEVICE_DSP_H__
19 #define MAIN_ALL_DEVICES 0x0d
20 #define MAIN_DEVICE_A 0x01
21 #define MAIN_DEVICE_B 0x08
22 #define MAIN_DEVICE_C 0x10
23 #define MAIN_DEVICE_D 0x14
24 #define COEFF_DEVICE_A 0x03
25 #define COEFF_DEVICE_B 0x0a
26 #define COEFF_DEVICE_C 0x11
27 #define COEFF_DEVICE_D 0x15
28 #define PRE_DEVICE_A 0x04
29 #define PRE_DEVICE_B 0x0b
30 #define PRE_DEVICE_C 0x12
31 #define PRE_DEVICE_D 0x16
33 #define PPC3_VERSION 0x4100
34 #define PPC3_VERSION_TAS2781 0x14600
35 #define TASDEVICE_DEVICE_SUM 8
36 #define TASDEVICE_CONFIG_SUM 64
38 #define TASDEVICE_MAX_CHANNELS 8
40 enum tasdevice_dsp_dev_idx {
41 TASDEVICE_DSP_TAS_2555 = 0,
42 TASDEVICE_DSP_TAS_2555_STEREO,
43 TASDEVICE_DSP_TAS_2557_MONO,
44 TASDEVICE_DSP_TAS_2557_DUAL_MONO,
45 TASDEVICE_DSP_TAS_2559,
46 TASDEVICE_DSP_TAS_2563,
47 TASDEVICE_DSP_TAS_2563_DUAL_MONO = 7,
48 TASDEVICE_DSP_TAS_2563_QUAD,
49 TASDEVICE_DSP_TAS_2563_21,
50 TASDEVICE_DSP_TAS_2781,
51 TASDEVICE_DSP_TAS_2781_DUAL_MONO,
52 TASDEVICE_DSP_TAS_2781_21,
53 TASDEVICE_DSP_TAS_2781_QUAD,
54 TASDEVICE_DSP_TAS_MAX_DEVICE
57 struct tasdevice_fw_fixed_hdr {
63 struct tasdevice_dspfw_hdr {
64 struct tasdevice_fw_fixed_hdr fixed_hdr;
65 unsigned short device_family;
66 unsigned short device;
73 unsigned char is_pchksum_present;
74 unsigned char pchksum;
75 unsigned char is_ychksum_present;
76 unsigned char ychksum;
78 unsigned int blk_size;
79 unsigned int nr_subblocks;
83 struct tasdevice_data {
86 struct tasdev_blk *dev_blks;
89 struct tasdevice_prog {
90 unsigned int prog_size;
91 struct tasdevice_data dev_data;
94 struct tasdevice_config {
95 unsigned int cfg_size;
97 struct tasdevice_data dev_data;
100 struct tasdevice_calibration {
101 struct tasdevice_data dev_data;
104 struct tasdevice_fw {
105 struct tasdevice_dspfw_hdr fw_hdr;
106 unsigned short nr_programs;
107 struct tasdevice_prog *programs;
108 unsigned short nr_configurations;
109 struct tasdevice_config *configs;
110 unsigned short nr_calibrations;
111 struct tasdevice_calibration *calibrations;
115 enum tasdevice_dsp_fw_state {
116 TASDEVICE_DSP_FW_NONE = 0,
117 TASDEVICE_DSP_FW_PENDING,
118 TASDEVICE_DSP_FW_FAIL,
119 TASDEVICE_DSP_FW_ALL_OK,
122 enum tasdevice_bin_blk_type {
123 TASDEVICE_BIN_BLK_COEFF = 1,
124 TASDEVICE_BIN_BLK_POST_POWER_UP,
125 TASDEVICE_BIN_BLK_PRE_SHUTDOWN,
126 TASDEVICE_BIN_BLK_PRE_POWER_UP,
127 TASDEVICE_BIN_BLK_POST_SHUTDOWN
130 struct tasdevice_rca_hdr {
132 unsigned int checksum;
133 unsigned int binary_version_num;
134 unsigned int drv_fw_version;
135 unsigned char plat_type;
136 unsigned char dev_family;
137 unsigned char reserve;
139 unsigned char devs[TASDEVICE_DEVICE_SUM];
140 unsigned int nconfig;
141 unsigned int config_size[TASDEVICE_CONFIG_SUM];
144 struct tasdev_blk_data {
145 unsigned char dev_idx;
146 unsigned char block_type;
147 unsigned short yram_checksum;
148 unsigned int block_size;
149 unsigned int n_subblks;
150 unsigned char *regdata;
153 struct tasdevice_config_info {
154 unsigned int nblocks;
155 unsigned int real_nblocks;
156 unsigned char active_dev;
157 struct tasdev_blk_data **blk_data;
160 struct tasdevice_rca {
161 struct tasdevice_rca_hdr fw_hdr;
163 struct tasdevice_config_info **cfg_info;
167 void tasdevice_select_cfg_blk(void *context, int conf_no,
168 unsigned char block_type);
169 void tasdevice_config_info_remove(void *context);
170 void tasdevice_dsp_remove(void *context);
171 int tasdevice_dsp_parser(void *context);
172 int tasdevice_rca_parser(void *context, const struct firmware *fmw);
173 void tasdevice_dsp_remove(void *context);
174 void tasdevice_calbin_remove(void *context);
175 int tasdevice_select_tuningprm_cfg(void *context, int prm,
176 int cfg_no, int rca_conf_no);
177 int tasdevice_prmg_load(void *context, int prm_no);
178 int tasdevice_prmg_calibdata_load(void *context, int prm_no);
179 void tasdevice_tuning_switch(void *context, int state);
180 int tas2781_load_calibration(void *context, char *file_name,