1 /* SPDX-License-Identifier: GPL-2.0 2 * 3 * CS35L41 ALSA HDA audio driver 4 * 5 * Copyright 2021 Cirrus Logic, Inc. 6 * 7 * Author: Lucas Tanure <tanureal@opensource.cirrus.com> 8 */ 9 10 #ifndef __CS35L41_HDA_H__ 11 #define __CS35L41_HDA_H__ 12 13 #include <linux/acpi.h> 14 #include <linux/efi.h> 15 #include <linux/regulator/consumer.h> 16 #include <linux/gpio/consumer.h> 17 #include <linux/device.h> 18 #include <sound/cs35l41.h> 19 20 #include <linux/firmware/cirrus/cs_dsp.h> 21 #include <linux/firmware/cirrus/wmfw.h> 22 23 struct cs35l41_amp_cal_data { 24 u32 calTarget[2]; 25 u32 calTime[2]; 26 s8 calAmbient; 27 u8 calStatus; 28 u16 calR; 29 } __packed; 30 31 struct cs35l41_amp_efi_data { 32 u32 size; 33 u32 count; 34 struct cs35l41_amp_cal_data data[]; 35 } __packed; 36 37 enum cs35l41_hda_spk_pos { 38 CS35l41_LEFT, 39 CS35l41_RIGHT, 40 }; 41 42 enum cs35l41_hda_gpio_function { 43 CS35L41_NOT_USED, 44 CS35l41_VSPK_SWITCH, 45 CS35L41_INTERRUPT, 46 CS35l41_SYNC, 47 }; 48 49 struct cs35l41_hda { 50 struct device *dev; 51 struct regmap *regmap; 52 struct gpio_desc *reset_gpio; 53 struct cs35l41_hw_cfg hw_cfg; 54 struct hda_codec *codec; 55 56 int irq; 57 int index; 58 int channel_index; 59 unsigned volatile long irq_errors; 60 const char *amp_name; 61 const char *acpi_subsystem_id; 62 int firmware_type; 63 int speaker_id; 64 struct mutex fw_mutex; 65 struct work_struct fw_load_work; 66 67 struct regmap_irq_chip_data *irq_data; 68 bool firmware_running; 69 bool request_fw_load; 70 bool fw_request_ongoing; 71 bool halo_initialized; 72 bool playback_started; 73 struct cs_dsp cs_dsp; 74 struct acpi_device *dacpi; 75 bool mute_override; 76 }; 77 78 enum halo_state { 79 HALO_STATE_CODE_INIT_DOWNLOAD = 0, 80 HALO_STATE_CODE_START, 81 HALO_STATE_CODE_RUN 82 }; 83 84 extern const struct dev_pm_ops cs35l41_hda_pm_ops; 85 86 int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, 87 struct regmap *regmap); 88 void cs35l41_hda_remove(struct device *dev); 89 int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id); 90 91 #endif /*__CS35L41_HDA_H__*/ 92