bc51bb09da5c0be455b91d7c5649f1faf64e1ae4
[platform/kernel/linux-starfive.git] / sound / soc / codecs / cs42l42.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * cs42l42.h -- CS42L42 ALSA SoC audio driver header
4  *
5  * Copyright 2016-2022 Cirrus Logic, Inc.
6  *
7  * Author: James Schulman <james.schulman@cirrus.com>
8  * Author: Brian Austin <brian.austin@cirrus.com>
9  * Author: Michael White <michael.white@cirrus.com>
10  */
11
12 #ifndef __CS42L42_H__
13 #define __CS42L42_H__
14
15 #include <dt-bindings/sound/cs42l42.h>
16 #include <linux/device.h>
17 #include <linux/gpio.h>
18 #include <linux/mutex.h>
19 #include <linux/regmap.h>
20 #include <linux/regulator/consumer.h>
21 #include <sound/jack.h>
22 #include <sound/cs42l42.h>
23 #include <sound/soc-component.h>
24 #include <sound/soc-dai.h>
25
26 struct  cs42l42_private {
27         struct regmap *regmap;
28         struct device *dev;
29         struct regulator_bulk_data supplies[CS42L42_NUM_SUPPLIES];
30         struct gpio_desc *reset_gpio;
31         struct completion pdn_done;
32         struct snd_soc_jack *jack;
33         struct mutex irq_lock;
34         int devid;
35         int irq;
36         int pll_config;
37         u32 sclk;
38         u32 srate;
39         u8 plug_state;
40         u8 hs_type;
41         u8 ts_inv;
42         u8 ts_dbnc_rise;
43         u8 ts_dbnc_fall;
44         u8 btn_det_init_dbnce;
45         u8 btn_det_event_dbnce;
46         u8 bias_thresholds[CS42L42_NUM_BIASES];
47         u8 hs_bias_ramp_rate;
48         u8 hs_bias_ramp_time;
49         u8 hs_bias_sense_en;
50         u8 stream_use;
51         bool hp_adc_up_pending;
52         bool suspended;
53         bool init_done;
54 };
55
56 extern const struct regmap_range_cfg cs42l42_page_range;
57 extern const struct regmap_config cs42l42_regmap;
58 extern const struct snd_soc_component_driver cs42l42_soc_component;
59 extern struct snd_soc_dai_driver cs42l42_dai;
60
61 bool cs42l42_readable_register(struct device *dev, unsigned int reg);
62 bool cs42l42_volatile_register(struct device *dev, unsigned int reg);
63
64 int cs42l42_suspend(struct device *dev);
65 int cs42l42_resume(struct device *dev);
66 void cs42l42_resume_restore(struct device *dev);
67 int cs42l42_common_probe(struct cs42l42_private *cs42l42,
68                          const struct snd_soc_component_driver *component_drv,
69                          struct snd_soc_dai_driver *dai);
70 int cs42l42_init(struct cs42l42_private *cs42l42);
71 void cs42l42_common_remove(struct cs42l42_private *cs42l42);
72
73 #endif /* __CS42L42_H__ */