xref: /linux/sound/soc/codecs/cs42l42.h (revision ae9f5e607da47104bc3d02e5c0ed237749f5db51)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
22c394ca7SJames Schulman /*
32c394ca7SJames Schulman  * cs42l42.h -- CS42L42 ALSA SoC audio driver header
42c394ca7SJames Schulman  *
57b43e6d7SStefan Binding  * Copyright 2016-2022 Cirrus Logic, Inc.
62c394ca7SJames Schulman  *
72c394ca7SJames Schulman  * Author: James Schulman <james.schulman@cirrus.com>
82c394ca7SJames Schulman  * Author: Brian Austin <brian.austin@cirrus.com>
92c394ca7SJames Schulman  * Author: Michael White <michael.white@cirrus.com>
102c394ca7SJames Schulman  */
112c394ca7SJames Schulman 
122c394ca7SJames Schulman #ifndef __CS42L42_H__
132c394ca7SJames Schulman #define __CS42L42_H__
142c394ca7SJames Schulman 
15b48d1da0SRichard Fitzgerald #include <dt-bindings/sound/cs42l42.h>
16b48d1da0SRichard Fitzgerald #include <linux/device.h>
17b48d1da0SRichard Fitzgerald #include <linux/gpio.h>
18fdd53528SRichard Fitzgerald #include <linux/mutex.h>
19b48d1da0SRichard Fitzgerald #include <linux/regmap.h>
20b48d1da0SRichard Fitzgerald #include <linux/regulator/consumer.h>
21c5b8ee08SLucas Tanure #include <sound/jack.h>
227b43e6d7SStefan Binding #include <sound/cs42l42.h>
23*ae9f5e60SRichard Fitzgerald #include <sound/soc-component.h>
24*ae9f5e60SRichard Fitzgerald #include <sound/soc-dai.h>
252c394ca7SJames Schulman 
262c394ca7SJames Schulman struct  cs42l42_private {
272c394ca7SJames Schulman 	struct regmap *regmap;
282003c44eSRichard Fitzgerald 	struct device *dev;
292c394ca7SJames Schulman 	struct regulator_bulk_data supplies[CS42L42_NUM_SUPPLIES];
302c394ca7SJames Schulman 	struct gpio_desc *reset_gpio;
312c394ca7SJames Schulman 	struct completion pdn_done;
32c26a5289SLucas Tanure 	struct snd_soc_jack *jack;
335982b5a8SRichard Fitzgerald 	struct mutex irq_lock;
340285042fSRichard Fitzgerald 	int irq;
35f1040e86SRichard Fitzgerald 	int pll_config;
362c394ca7SJames Schulman 	u32 sclk;
372c394ca7SJames Schulman 	u32 srate;
382c394ca7SJames Schulman 	u8 plug_state;
392c394ca7SJames Schulman 	u8 hs_type;
402c394ca7SJames Schulman 	u8 ts_inv;
412c394ca7SJames Schulman 	u8 ts_dbnc_rise;
422c394ca7SJames Schulman 	u8 ts_dbnc_fall;
432c394ca7SJames Schulman 	u8 btn_det_init_dbnce;
442c394ca7SJames Schulman 	u8 btn_det_event_dbnce;
452c394ca7SJames Schulman 	u8 bias_thresholds[CS42L42_NUM_BIASES];
462c394ca7SJames Schulman 	u8 hs_bias_ramp_rate;
472c394ca7SJames Schulman 	u8 hs_bias_ramp_time;
48c9f2e3c3SVitaly Rodionov 	u8 hs_bias_sense_en;
4943fc3571SLucas Tanure 	u8 stream_use;
504ae1d8f9SRichard Fitzgerald 	bool hp_adc_up_pending;
51f8593e88SRichard Fitzgerald 	bool suspended;
520285042fSRichard Fitzgerald 	bool init_done;
532c394ca7SJames Schulman };
542c394ca7SJames Schulman 
55*ae9f5e60SRichard Fitzgerald extern const struct regmap_config cs42l42_regmap;
56*ae9f5e60SRichard Fitzgerald extern const struct snd_soc_component_driver cs42l42_soc_component;
57*ae9f5e60SRichard Fitzgerald extern struct snd_soc_dai_driver cs42l42_dai;
58*ae9f5e60SRichard Fitzgerald 
59*ae9f5e60SRichard Fitzgerald int cs42l42_suspend(struct device *dev);
60*ae9f5e60SRichard Fitzgerald int cs42l42_resume(struct device *dev);
61*ae9f5e60SRichard Fitzgerald void cs42l42_resume_restore(struct device *dev);
62*ae9f5e60SRichard Fitzgerald int cs42l42_common_probe(struct cs42l42_private *cs42l42,
63*ae9f5e60SRichard Fitzgerald 			 const struct snd_soc_component_driver *component_drv,
64*ae9f5e60SRichard Fitzgerald 			 struct snd_soc_dai_driver *dai);
65*ae9f5e60SRichard Fitzgerald int cs42l42_init(struct cs42l42_private *cs42l42);
66*ae9f5e60SRichard Fitzgerald void cs42l42_common_remove(struct cs42l42_private *cs42l42);
67*ae9f5e60SRichard Fitzgerald 
682c394ca7SJames Schulman #endif /* __CS42L42_H__ */
69