xref: /openbmc/linux/sound/pci/hda/cs35l41_hda.h (revision 8957261c)
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/efi.h>
14 #include <linux/regulator/consumer.h>
15 #include <linux/gpio/consumer.h>
16 #include <linux/device.h>
17 #include <sound/cs35l41.h>
18 
19 #include <linux/firmware/cirrus/cs_dsp.h>
20 #include <linux/firmware/cirrus/wmfw.h>
21 
22 struct cs35l41_amp_cal_data {
23 	u32 calTarget[2];
24 	u32 calTime[2];
25 	s8 calAmbient;
26 	u8 calStatus;
27 	u16 calR;
28 } __packed;
29 
30 struct cs35l41_amp_efi_data {
31 	u32 size;
32 	u32 count;
33 	struct cs35l41_amp_cal_data data[];
34 } __packed;
35 
36 enum cs35l41_hda_spk_pos {
37 	CS35l41_LEFT,
38 	CS35l41_RIGHT,
39 };
40 
41 enum cs35l41_hda_gpio_function {
42 	CS35L41_NOT_USED,
43 	CS35l41_VSPK_SWITCH,
44 	CS35L41_INTERRUPT,
45 	CS35l41_SYNC,
46 };
47 
48 struct cs35l41_hda {
49 	struct device *dev;
50 	struct regmap *regmap;
51 	struct gpio_desc *reset_gpio;
52 	struct cs35l41_hw_cfg hw_cfg;
53 	struct hda_codec *codec;
54 
55 	int irq;
56 	int index;
57 	int channel_index;
58 	unsigned volatile long irq_errors;
59 	const char *amp_name;
60 	const char *acpi_subsystem_id;
61 	int firmware_type;
62 	int speaker_id;
63 	struct mutex fw_mutex;
64 	struct work_struct fw_load_work;
65 
66 	struct regmap_irq_chip_data *irq_data;
67 	bool firmware_running;
68 	bool request_fw_load;
69 	bool fw_request_ongoing;
70 	bool halo_initialized;
71 	bool playback_started;
72 	struct cs_dsp cs_dsp;
73 };
74 
75 enum halo_state {
76 	HALO_STATE_CODE_INIT_DOWNLOAD = 0,
77 	HALO_STATE_CODE_START,
78 	HALO_STATE_CODE_RUN
79 };
80 
81 extern const struct dev_pm_ops cs35l41_hda_pm_ops;
82 
83 int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
84 		      struct regmap *regmap);
85 void cs35l41_hda_remove(struct device *dev);
86 int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id);
87 
88 #endif /*__CS35L41_HDA_H__*/
89