xref: /openbmc/linux/sound/soc/codecs/cs35l56.h (revision 724ba675)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Driver for Cirrus Logic CS35L56 smart amp
4  *
5  * Copyright (C) 2023 Cirrus Logic, Inc. and
6  *                    Cirrus Logic International Semiconductor Ltd.
7  */
8 
9 #ifndef CS35L56_H
10 #define CS35L56_H
11 
12 #include <linux/completion.h>
13 #include <linux/regulator/consumer.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/workqueue.h>
16 #include <sound/cs35l56.h>
17 #include "wm_adsp.h"
18 
19 #define CS35L56_SDW_GEN_INT_STAT_1	0xc0
20 #define CS35L56_SDW_GEN_INT_MASK_1	0xc1
21 #define CS35L56_SDW_INT_MASK_CODEC_IRQ	BIT(0)
22 
23 #define CS35L56_SDW_INVALID_BUS_SCALE	0xf
24 
25 #define CS35L56_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
26 #define CS35L56_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE \
27 			    | SNDRV_PCM_FMTBIT_S32_LE)
28 
29 #define CS35L56_RATES (SNDRV_PCM_RATE_48000)
30 
31 struct sdw_slave;
32 
33 struct cs35l56_private {
34 	struct wm_adsp dsp; /* must be first member */
35 	struct work_struct dsp_work;
36 	struct workqueue_struct *dsp_wq;
37 	struct mutex irq_lock;
38 	struct snd_soc_component *component;
39 	struct device *dev;
40 	struct regmap *regmap;
41 	struct regulator_bulk_data supplies[CS35L56_NUM_BULK_SUPPLIES];
42 	int irq;
43 	struct sdw_slave *sdw_peripheral;
44 	u8 rev;
45 	struct work_struct sdw_irq_work;
46 	bool secured;
47 	bool sdw_irq_no_unmask;
48 	bool soft_resetting;
49 	bool init_done;
50 	bool sdw_attached;
51 	bool fw_patched;
52 	bool can_hibernate;
53 	struct completion init_completion;
54 	struct gpio_desc *reset_gpio;
55 
56 	u32 rx_mask;
57 	u32 tx_mask;
58 	u8 asp_slot_width;
59 	u8 asp_slot_count;
60 	bool tdm_mode;
61 	bool sysclk_set;
62 	u8 old_sdw_clock_scale;
63 };
64 
65 extern const struct dev_pm_ops cs35l56_pm_ops_i2c_spi;
66 
67 int cs35l56_runtime_suspend(struct device *dev);
68 int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56);
69 int cs35l56_system_suspend(struct device *dev);
70 int cs35l56_system_suspend_late(struct device *dev);
71 int cs35l56_system_suspend_no_irq(struct device *dev);
72 int cs35l56_system_resume_no_irq(struct device *dev);
73 int cs35l56_system_resume_early(struct device *dev);
74 int cs35l56_system_resume(struct device *dev);
75 irqreturn_t cs35l56_irq(int irq, void *data);
76 int cs35l56_irq_request(struct cs35l56_private *cs35l56, int irq);
77 int cs35l56_common_probe(struct cs35l56_private *cs35l56);
78 int cs35l56_init(struct cs35l56_private *cs35l56);
79 void cs35l56_remove(struct cs35l56_private *cs35l56);
80 
81 #endif /* ifndef CS35L56_H */
82