• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __DRIVERS_I2C_CS42L42_CHIP_H__
4 #define __DRIVERS_I2C_CS42L42_CHIP_H__
5 
6 #include <acpi/acpi_device.h>
7 
8 enum cs42l42_ts_dbnc_rise {
9 	RISE_DEB_0_MS = 0,
10 	RISE_DEB_125_MS = 1,
11 	RISE_DEB_250_MS = 2,
12 	RISE_DEB_500_MS = 3,
13 	RISE_DEB_750_MS = 4,
14 	RISE_DEB_1000_MS = 5,
15 	RISE_DEB_1250_MS = 6,
16 	RISE_DEB_1500_MS = 7,
17 };
18 
19 enum cs42l42_ts_dbnc_fall {
20 	FALL_DEB_0_MS = 0,
21 	FALL_DEB_125_MS = 1,
22 	FALL_DEB_250_MS = 2,
23 	FALL_DEB_500_MS = 3,
24 	FALL_DEB_750_MS = 4,
25 	FALL_DEB_1000_MS = 5,
26 	FALL_DEB_1250_MS = 6,
27 	FALL_DEB_1500_MS = 7,
28 };
29 
30 enum cs42l42_hs_bias_ramp_rate {
31 	HSBIAS_RAMP_FAST_RISE_SLOW_FALL = 0,
32 	HSBIAS_RAMP_FAST = 1,
33 	HSBIAS_RAMP_SLOW = 2,
34 	HSBIAS_RAMP_SLOWEST = 3,
35 };
36 
37 /*
38  * Cirrus Logic  CS42L42 Audio Codec devicetree bindings
39  * linux/Documentation/devicetree/bindings/sound/cs42l42.txt
40  */
41 struct drivers_i2c_cs42l42_config {
42 	/* Interrupt configuration */
43 	struct acpi_irq irq;
44 
45 	/* Use GPIO based interrupt instead of PIRQ */
46 	struct acpi_gpio irq_gpio;
47 
48 	/* Use GPIO based reset gpio */
49 	struct acpi_gpio reset_gpio;
50 
51 	/* I2C Bus Frequency in Hertz (default 400kHz) */
52 	unsigned int bus_speed;
53 
54 	/* Define cs42L42 parameters */
55 	/*
56 	 * cirrus,ts-inv : Boolean property. For jacks that invert the tip sense
57 	 * polarity. Normal jacks will short tip sense pin to HS1 when headphones are
58 	 * plugged in and leave tip sense floating when not plugged in. Inverting jacks
59 	 * short tip sense when unplugged and float when plugged in.
60 	 * false = Non-inverted
61 	 * true  = Inverted
62 	 * Default = Non-inverted
63 	 */
64 	bool ts_inv;
65 	/*
66 	 * cirrus,ts-dbnc-rise : Debounce the rising edge of TIP_SENSE_PLUG. With no
67 	 * debounce, the tip sense pin might be noisy on a plug event.
68 	 * Default = RISE_DEB_1000_MS
69 	 */
70 	enum cs42l42_ts_dbnc_rise ts_dbnc_rise;
71 	/*
72 	 * cirrus,ts-dbnc-fall : Debounce the falling edge of TIP_SENSE_UNPLUG.
73 	 * With no debounce, the tip sense pin might be noisy on an unplug event.
74 	 * Default = FALL_DEB_1000_MS
75 	 */
76 	enum cs42l42_ts_dbnc_fall ts_dbnc_fall;
77 	/*
78 	 * cirrus,btn-det-init-dbnce : This sets how long the driver sleeps after
79 	 * enabling button detection interrupts. After auto-detection and before
80 	 * servicing button interrupts, the HS bias needs time to settle. If you
81 	 * don't wait, there is possibility for erroneous button interrupt.
82 	 * Value in ms, 0 - 200.
83 	 * Default = 100ms
84 	 */
85 	unsigned int btn_det_init_dbnce;
86 	/*
87 	 * cirrus,btn-det-event-dbnce : This sets how long the driver delays after
88 	 * receiving a button press interrupt. With level detect interrupts, you want
89 	 * to wait a small amount of time to make sure the button press is making a
90 	 * clean connection with the bias resistors.
91 	 * Value in ms, 0 - 20.
92 	 * Default = 10ms
93 	 */
94 	unsigned int btn_det_event_dbnce;
95 	/*
96 	 * cirrus,bias-lvls : For a level-detect headset button scheme, each button
97 	 * will bias the mic pin to a certain voltage. To determine which button was
98 	 * pressed, the driver will compare this biased voltage to sequential,
99 	 * decreasing voltages and will stop when a comparator is tripped,
100 	 * indicating a comparator voltage < bias voltage. This value represents a
101 	 * percentage of the internally generated HS bias voltage. For different
102 	 * hardware setups, a designer might want to tweak this. This is an array of
103 	 * descending values for the comparator voltage.
104 	 * Array of 4 values
105 	 * Each 0-63
106 	 * < x1 x2 x3 x4 >
107 	 * Default = < 15 8 4 1>
108 	 */
109 	uint64_t bias_lvls[4];
110 	/* headset bias ramp rate */
111 	enum cs42l42_hs_bias_ramp_rate hs_bias_ramp_rate;
112 	/*
113 	 * cirrus,hs-bias-sense-disable: This is boolean property. If present the
114 	 * HSBIAS sense is disabled. Configures HSBIAS output current sense through
115 	 * the external 2.21-k resistor. HSBIAS_SENSE is hardware feature to reduce
116 	 * the potential pop noise during the headset plug out slowly. But on some
117 	 * platforms ESD voltage will affect it causing test to fail, especially
118 	 * with CTIA headset type. For different hardware setups, a designer might
119 	 * want to tweak default behavior.
120 	 */
121 	bool hs_bias_sense_disable;
122 };
123 
124 #endif /* __DRIVERS_I2C_CS42L42_CHIP_H__ */
125