1 /* SPDX-License-Identifier: GPL-2.0 1 /* SPDX-License-Identifier: GPL-2.0 2 * 2 * 3 * CS35L41 ALSA HDA audio driver 3 * CS35L41 ALSA HDA audio driver 4 * 4 * 5 * Copyright 2021 Cirrus Logic, Inc. 5 * Copyright 2021 Cirrus Logic, Inc. 6 * 6 * 7 * Author: Lucas Tanure <tanureal@opensource.c 7 * Author: Lucas Tanure <tanureal@opensource.cirrus.com> 8 */ 8 */ 9 9 10 #ifndef __CS35L41_HDA_H__ 10 #ifndef __CS35L41_HDA_H__ 11 #define __CS35L41_HDA_H__ 11 #define __CS35L41_HDA_H__ 12 12 13 #include <linux/acpi.h> 13 #include <linux/acpi.h> 14 #include <linux/efi.h> 14 #include <linux/efi.h> 15 #include <linux/regulator/consumer.h> 15 #include <linux/regulator/consumer.h> 16 #include <linux/gpio/consumer.h> 16 #include <linux/gpio/consumer.h> 17 #include <linux/device.h> 17 #include <linux/device.h> 18 #include <sound/cs35l41.h> 18 #include <sound/cs35l41.h> 19 #include <sound/cs-amp-lib.h> << 20 19 21 #include <linux/firmware/cirrus/cs_dsp.h> 20 #include <linux/firmware/cirrus/cs_dsp.h> 22 #include <linux/firmware/cirrus/wmfw.h> 21 #include <linux/firmware/cirrus/wmfw.h> 23 22 24 #define CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ 23 #define CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ 1000000 25 #define DEFAULT_AMP_GAIN_PCM << 26 #define DEFAULT_AMP_GAIN_PDM << 27 24 28 struct cs35l41_amp_cal_data { 25 struct cs35l41_amp_cal_data { 29 u32 calTarget[2]; 26 u32 calTarget[2]; 30 u32 calTime[2]; 27 u32 calTime[2]; 31 s8 calAmbient; 28 s8 calAmbient; 32 u8 calStatus; 29 u8 calStatus; 33 u16 calR; 30 u16 calR; 34 } __packed; 31 } __packed; 35 32 36 struct cs35l41_amp_efi_data { 33 struct cs35l41_amp_efi_data { 37 u32 size; 34 u32 size; 38 u32 count; 35 u32 count; 39 struct cs35l41_amp_cal_data data[]; 36 struct cs35l41_amp_cal_data data[]; 40 } __packed; 37 } __packed; 41 38 42 enum cs35l41_hda_spk_pos { 39 enum cs35l41_hda_spk_pos { 43 CS35L41_LEFT, 40 CS35L41_LEFT, 44 CS35L41_RIGHT, 41 CS35L41_RIGHT, 45 }; 42 }; 46 43 47 enum cs35l41_hda_gpio_function { 44 enum cs35l41_hda_gpio_function { 48 CS35L41_NOT_USED, 45 CS35L41_NOT_USED, 49 CS35l41_VSPK_SWITCH, 46 CS35l41_VSPK_SWITCH, 50 CS35L41_INTERRUPT, 47 CS35L41_INTERRUPT, 51 CS35l41_SYNC, 48 CS35l41_SYNC, 52 }; 49 }; 53 50 54 enum control_bus { 51 enum control_bus { 55 I2C, 52 I2C, 56 SPI 53 SPI 57 }; 54 }; 58 55 59 struct cs35l41_hda { 56 struct cs35l41_hda { 60 struct device *dev; 57 struct device *dev; 61 struct regmap *regmap; 58 struct regmap *regmap; 62 struct gpio_desc *reset_gpio; 59 struct gpio_desc *reset_gpio; 63 struct gpio_desc *cs_gpio; 60 struct gpio_desc *cs_gpio; 64 struct cs35l41_hw_cfg hw_cfg; 61 struct cs35l41_hw_cfg hw_cfg; 65 struct hda_codec *codec; 62 struct hda_codec *codec; 66 63 67 int irq; 64 int irq; 68 int index; 65 int index; 69 int channel_index; 66 int channel_index; 70 unsigned volatile long irq_errors; 67 unsigned volatile long irq_errors; 71 const char *amp_name; 68 const char *amp_name; 72 const char *acpi_subsystem_id; 69 const char *acpi_subsystem_id; 73 int firmware_type; 70 int firmware_type; 74 int speaker_id; 71 int speaker_id; 75 struct mutex fw_mutex; 72 struct mutex fw_mutex; 76 struct work_struct fw_load_work; 73 struct work_struct fw_load_work; 77 74 78 struct regmap_irq_chip_data *irq_data; 75 struct regmap_irq_chip_data *irq_data; 79 bool firmware_running; 76 bool firmware_running; 80 bool request_fw_load; 77 bool request_fw_load; 81 bool fw_request_ongoing; 78 bool fw_request_ongoing; 82 bool halo_initialized; 79 bool halo_initialized; 83 bool playback_started; 80 bool playback_started; 84 struct cs_dsp cs_dsp; 81 struct cs_dsp cs_dsp; 85 struct acpi_device *dacpi; 82 struct acpi_device *dacpi; 86 bool mute_override; 83 bool mute_override; 87 enum control_bus control_bus; 84 enum control_bus control_bus; 88 bool bypass_fw; 85 bool bypass_fw; 89 unsigned int tuning_gain; << 90 struct cirrus_amp_cal_data cal_data; << 91 bool cal_data_valid; << 92 86 93 }; 87 }; 94 88 95 enum halo_state { 89 enum halo_state { 96 HALO_STATE_CODE_INIT_DOWNLOAD = 0, 90 HALO_STATE_CODE_INIT_DOWNLOAD = 0, 97 HALO_STATE_CODE_START, 91 HALO_STATE_CODE_START, 98 HALO_STATE_CODE_RUN 92 HALO_STATE_CODE_RUN 99 }; 93 }; 100 94 101 extern const struct dev_pm_ops cs35l41_hda_pm_ 95 extern const struct dev_pm_ops cs35l41_hda_pm_ops; 102 96 103 int cs35l41_hda_probe(struct device *dev, cons 97 int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, 104 struct regmap *regmap, e 98 struct regmap *regmap, enum control_bus control_bus); 105 void cs35l41_hda_remove(struct device *dev); 99 void cs35l41_hda_remove(struct device *dev); 106 int cs35l41_get_speaker_id(struct device *dev, 100 int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id); 107 int cs35l41_hda_parse_acpi(struct cs35l41_hda << 108 101 109 #endif /*__CS35L41_HDA_H__*/ 102 #endif /*__CS35L41_HDA_H__*/ 110 103
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.