| 1 |
|
| 2 | |
| 3 | * Copyright (C) 2024 Cirrus Logic, Inc. and
|
| 4 | * Cirrus Logic International Semiconductor Ltd.
|
| 5 |
|
| 6 |
|
| 7 | #ifndef CS_AMP_LIB_H
|
| 8 | #define CS_AMP_LIB_H
|
| 9 |
|
| 10 | #include <linux/efi.h>
|
| 11 | #include <linux/types.h>
|
| 12 |
|
| 13 | struct cs_dsp;
|
| 14 |
|
| 15 | struct cirrus_amp_cal_data {
|
| 16 | u32 calTarget[2];
|
| 17 | u32 calTime[2];
|
| 18 | s8 calAmbient;
|
| 19 | u8 calStatus;
|
| 20 | u16 calR;
|
| 21 | } __packed;
|
| 22 |
|
| 23 | struct cirrus_amp_efi_data {
|
| 24 | u32 size;
|
| 25 | u32 count;
|
| 26 | struct cirrus_amp_cal_data data[] __counted_by(count);
|
| 27 | } __packed;
|
| 28 |
|
| 29 | |
| 30 | * struct cirrus_amp_cal_controls - definition of firmware calibration controls
|
| 31 | * @alg_id: ID of algorithm containing the controls.
|
| 32 | * @mem_region: DSP memory region containing the controls.
|
| 33 | * @ambient: Name of control for calAmbient value.
|
| 34 | * @calr: Name of control for calR value.
|
| 35 | * @status: Name of control for calStatus value.
|
| 36 | * @checksum: Name of control for checksum value.
|
| 37 |
|
| 38 | struct cirrus_amp_cal_controls {
|
| 39 | unsigned int alg_id;
|
| 40 | int mem_region;
|
| 41 | const char *ambient;
|
| 42 | const char *calr;
|
| 43 | const char *status;
|
| 44 | const char *checksum;
|
| 45 | };
|
| 46 |
|
| 47 | int cs_amp_write_cal_coeffs(struct cs_dsp *dsp,
|
| 48 | const struct cirrus_amp_cal_controls *controls,
|
| 49 | const struct cirrus_amp_cal_data *data);
|
| 50 | int cs_amp_read_cal_coeffs(struct cs_dsp *dsp,
|
| 51 | const struct cirrus_amp_cal_controls *controls,
|
| 52 | struct cirrus_amp_cal_data *data);
|
| 53 | int cs_amp_write_ambient_temp(struct cs_dsp *dsp,
|
| 54 | const struct cirrus_amp_cal_controls *controls,
|
| 55 | u32 temp);
|
| 56 | int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
|
| 57 | struct cirrus_amp_cal_data *out_data);
|
| 58 | int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps,
|
| 59 | const struct cirrus_amp_cal_data *in_data);
|
| 60 | int cs_amp_get_vendor_spkid(struct device *dev);
|
| 61 | const char *cs_amp_devm_get_vendor_specific_variant_id(struct device *dev,
|
| 62 | int ssid_vendor,
|
| 63 | int ssid_device);
|
| 64 | struct dentry *cs_amp_create_debugfs(struct device *dev);
|
| 65 |
|
| 66 | static inline u64 cs_amp_cal_target_u64(const struct cirrus_amp_cal_data *data)
|
| 67 | {
|
| 68 | return ((u64)data->calTarget[1] << 32) | data->calTarget[0];
|
| 69 | }
|
| 70 |
|
| 71 | struct cs_amp_test_hooks {
|
| 72 | efi_status_t (*get_efi_variable)(efi_char16_t *name,
|
| 73 | efi_guid_t *guid,
|
| 74 | u32 *returned_attr,
|
| 75 | unsigned long *size,
|
| 76 | void *buf);
|
| 77 | efi_status_t (*set_efi_variable)(efi_char16_t *name,
|
| 78 | efi_guid_t *guid,
|
| 79 | u32 attr,
|
| 80 | unsigned long size,
|
| 81 | void *buf);
|
| 82 |
|
| 83 | int (*write_cal_coeff)(struct cs_dsp *dsp,
|
| 84 | const struct cirrus_amp_cal_controls *controls,
|
| 85 | const char *ctl_name, u32 val);
|
| 86 |
|
| 87 | int (*read_cal_coeff)(struct cs_dsp *dsp,
|
| 88 | const struct cirrus_amp_cal_controls *controls,
|
| 89 | const char *ctl_name, u32 *val);
|
| 90 | };
|
| 91 | extern const struct cs_amp_test_hooks * const cs_amp_test_hooks;
|
| 92 |
|
| 93 | #endif
|