summaryrefstree
path: root/kernel/include/linux/extcon/extcon-madera-pdata.h
blob: 6af99e444ec23859ee5190b6a8c74ac40ae17345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * Platform data for Madera codecs
 *
 * Copyright 2017 Cirrus Logic
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef EXTCON_MADERA_PDATA_H
#define EXTCON_MADERA_PDATA_H

#include <linux/kernel.h>

#define MADERA_MAX_ACCESSORY		1

/* Treat INT_MAX impedance as open circuit */
#define MADERA_HP_Z_OPEN		INT_MAX

struct madera_jd_state;

/** Bias and sense configuration for probing MICDET */
struct madera_micd_config {
	/** cs47l35, cs47l85, WM1840: value of the ACCDET_SRC field
	 *  other codecs: value of MICDn_SENSE_SEL field
	 * See datasheet for field values
	 */
	u32 src;

	/** cs47l35, cs47l85, wm1840: unused
	 *  other codecs: value of MICDn_GND_SEL
	 *
	 * See datasheet for field values
	 */
	u32 gnd;

	/** MICBIAS number to enable */
	u32 bias;

	/** State of polarity gpio during probe (true == gpio asserted) */
	bool gpio;

	/** cs47l35, cs47l85, wm1840: unused
	 *  other codecs: value of HPn_GND_SEL
	 *
	 * See datasheet for field values
	 */
	u32 hp_gnd;
};

struct madera_micd_range {
	int max;  /** Ohms */
	int key;  /** Key to report to input layer */
};

/** pdata sub-structure for accessory detect configuration */
struct madera_accdet_pdata {
	/** set to true to enable this accessory detect */
	bool enabled;

	/** which output this accdet is for (1 = OUT1, ...) */
	u32 output;

	/** Set whether JD2 is used for jack detection */
	bool jd_use_jd2;

	/** set to true if jackdet contact opens on insert */
	bool jd_invert;

	/** If non-zero don't run headphone detection, just report this value
	 * Specified as hundredths-of-an-ohm, that is (ohms * 100)
	 */
	u32 fixed_hpdet_imp_x100;

	/** Impedance of external series resistor on hpdet.
	 * Specified as hundredths-of-an-ohm, that is (ohms * 100)
	 */
	u32 hpdet_ext_res_x100;

	/** If non-zero, specifies the maximum impedance in ohms
	 * that will be considered as a short circuit.
	 */
	u32 hpdet_short_circuit_imp;

	/**
	 * Channel to use for headphone detection, valid values are 0 for
	 * left and 1 for right
	 */
	u32 hpdet_channel;

	/** Extra debounce timeout during initial mic detect (milliseconds) */
	u32 micd_detect_debounce_ms;

	/** Extra software debounces during button detection */
	u32 micd_manual_debounce;

	/** GPIO for mic detection polarity */
	int micd_pol_gpio;

	/** Mic detect ramp rate */
	u32 micd_bias_start_time;

	/** Setting for the codec MICD_RATE field
	 * See the  datasheet for documentation of the field values
	 */
	u32 micd_rate;

	/** Mic detect debounce level */
	u32 micd_dbtime;

	/** Mic detect timeout (milliseconds) */
	u32 micd_timeout_ms;

	/** Mic detect clamp function */
	u32 micd_clamp_mode;

	/** Force MICBIAS on for mic detect */
	bool micd_force_micbias;

	/** Declare an open circuit as a 4 pole jack */
	bool micd_open_circuit_declare;

	/** Use software comparison to determine mic presence */
	bool micd_software_compare;

	/** Mic detect level parameters */
	const struct madera_micd_range *micd_ranges;
	int num_micd_ranges;

	/** Headset polarity configurations */
	const struct madera_micd_config *micd_configs;
	int num_micd_configs;

	/**
	 * 4 entries:
	 * [HPL_clamp_pin, HPL_impedance_measurement_pin,
	 * HPR_clamp_pin, HPR_impedance_measurement_pin]
	 *
	 * 0 = use default setting
	 * values 0x1..0xffff = set to this value
	 * >0xffff = set to 0
	 */
	u32 hpd_pins[4];

	/** Override the normal jack detection */
	const struct madera_jd_state *custom_jd;
};

#endif