1 /*
2  * Platform data for Arizona devices
3  *
4  * Copyright 2012 Wolfson Microelectronics. PLC.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 
11 #ifndef _ARIZONA_PDATA_H
12 #define _ARIZONA_PDATA_H
13 
14 #include <dt-bindings/mfd/arizona.h>
15 #include <linux/regulator/arizona-ldo1.h>
16 #include <linux/regulator/arizona-micsupp.h>
17 
18 #define ARIZONA_GPN_DIR_MASK                     0x8000  /* GPN_DIR */
19 #define ARIZONA_GPN_DIR_SHIFT                        15  /* GPN_DIR */
20 #define ARIZONA_GPN_DIR_WIDTH                         1  /* GPN_DIR */
21 #define ARIZONA_GPN_PU_MASK                      0x4000  /* GPN_PU */
22 #define ARIZONA_GPN_PU_SHIFT                         14  /* GPN_PU */
23 #define ARIZONA_GPN_PU_WIDTH                          1  /* GPN_PU */
24 #define ARIZONA_GPN_PD_MASK                      0x2000  /* GPN_PD */
25 #define ARIZONA_GPN_PD_SHIFT                         13  /* GPN_PD */
26 #define ARIZONA_GPN_PD_WIDTH                          1  /* GPN_PD */
27 #define ARIZONA_GPN_LVL_MASK                     0x0800  /* GPN_LVL */
28 #define ARIZONA_GPN_LVL_SHIFT                        11  /* GPN_LVL */
29 #define ARIZONA_GPN_LVL_WIDTH                         1  /* GPN_LVL */
30 #define ARIZONA_GPN_POL_MASK                     0x0400  /* GPN_POL */
31 #define ARIZONA_GPN_POL_SHIFT                        10  /* GPN_POL */
32 #define ARIZONA_GPN_POL_WIDTH                         1  /* GPN_POL */
33 #define ARIZONA_GPN_OP_CFG_MASK                  0x0200  /* GPN_OP_CFG */
34 #define ARIZONA_GPN_OP_CFG_SHIFT                      9  /* GPN_OP_CFG */
35 #define ARIZONA_GPN_OP_CFG_WIDTH                      1  /* GPN_OP_CFG */
36 #define ARIZONA_GPN_DB_MASK                      0x0100  /* GPN_DB */
37 #define ARIZONA_GPN_DB_SHIFT                          8  /* GPN_DB */
38 #define ARIZONA_GPN_DB_WIDTH                          1  /* GPN_DB */
39 #define ARIZONA_GPN_FN_MASK                      0x007F  /* GPN_FN - [6:0] */
40 #define ARIZONA_GPN_FN_SHIFT                          0  /* GPN_FN - [6:0] */
41 #define ARIZONA_GPN_FN_WIDTH                          7  /* GPN_FN - [6:0] */
42 
43 #define ARIZONA_MAX_GPIO 5
44 
45 #define ARIZONA_MAX_INPUT 4
46 
47 #define ARIZONA_MAX_MICBIAS 3
48 
49 #define ARIZONA_MAX_OUTPUT 6
50 
51 #define ARIZONA_MAX_AIF 3
52 
53 #define ARIZONA_HAP_ACT_ERM 0
54 #define ARIZONA_HAP_ACT_LRA 2
55 
56 #define ARIZONA_MAX_PDM_SPK 2
57 
58 struct regulator_init_data;
59 struct gpio_desc;
60 
61 struct arizona_micbias {
62 	int mV;                    /** Regulated voltage */
63 	unsigned int ext_cap:1;    /** External capacitor fitted */
64 	unsigned int discharge:1;  /** Actively discharge */
65 	unsigned int soft_start:1; /** Disable aggressive startup ramp rate */
66 	unsigned int bypass:1;     /** Use bypass mode */
67 };
68 
69 struct arizona_micd_config {
70 	unsigned int src;
71 	unsigned int bias;
72 	bool gpio;
73 };
74 
75 struct arizona_micd_range {
76 	int max;  /** Ohms */
77 	int key;  /** Key to report to input layer */
78 };
79 
80 struct arizona_pdata {
81 	struct gpio_desc *reset;      /** GPIO controlling /RESET, if any */
82 
83 	/** Regulator configuration for MICVDD */
84 	struct arizona_micsupp_pdata micvdd;
85 
86 	/** Regulator configuration for LDO1 */
87 	struct arizona_ldo1_pdata ldo1;
88 
89 	/** If a direct 32kHz clock is provided on an MCLK specify it here */
90 	int clk32k_src;
91 
92 	/** Mode for primary IRQ (defaults to active low) */
93 	unsigned int irq_flags;
94 
95 	/* Base GPIO */
96 	int gpio_base;
97 
98 	/** Pin state for GPIO pins */
99 	unsigned int gpio_defaults[ARIZONA_MAX_GPIO];
100 
101 	/**
102 	 * Maximum number of channels clocks will be generated for,
103 	 * useful for systems where and I2S bus with multiple data
104 	 * lines is mastered.
105 	 */
106 	unsigned int max_channels_clocked[ARIZONA_MAX_AIF];
107 
108 	/** GPIO5 is used for jack detection */
109 	bool jd_gpio5;
110 
111 	/** Internal pull on GPIO5 is disabled when used for jack detection */
112 	bool jd_gpio5_nopull;
113 
114 	/** set to true if jackdet contact opens on insert */
115 	bool jd_invert;
116 
117 	/** Use the headphone detect circuit to identify the accessory */
118 	bool hpdet_acc_id;
119 
120 	/** Check for line output with HPDET method */
121 	bool hpdet_acc_id_line;
122 
123 	/** GPIO used for mic isolation with HPDET */
124 	int hpdet_id_gpio;
125 
126 	/** Channel to use for headphone detection */
127 	unsigned int hpdet_channel;
128 
129 	/** Use software comparison to determine mic presence */
130 	bool micd_software_compare;
131 
132 	/** Extra debounce timeout used during initial mic detection (ms) */
133 	unsigned int micd_detect_debounce;
134 
135 	/** GPIO for mic detection polarity */
136 	int micd_pol_gpio;
137 
138 	/** Mic detect ramp rate */
139 	unsigned int micd_bias_start_time;
140 
141 	/** Mic detect sample rate */
142 	unsigned int micd_rate;
143 
144 	/** Mic detect debounce level */
145 	unsigned int micd_dbtime;
146 
147 	/** Mic detect timeout (ms) */
148 	unsigned int micd_timeout;
149 
150 	/** Force MICBIAS on for mic detect */
151 	bool micd_force_micbias;
152 
153 	/** Mic detect level parameters */
154 	const struct arizona_micd_range *micd_ranges;
155 	int num_micd_ranges;
156 
157 	/** Headset polarity configurations */
158 	struct arizona_micd_config *micd_configs;
159 	int num_micd_configs;
160 
161 	/** Reference voltage for DMIC inputs */
162 	int dmic_ref[ARIZONA_MAX_INPUT];
163 
164 	/** MICBIAS configurations */
165 	struct arizona_micbias micbias[ARIZONA_MAX_MICBIAS];
166 
167 	/**
168 	 * Mode of input structures
169 	 * One of the ARIZONA_INMODE_xxx values
170 	 * wm5102/wm5110/wm8280/wm8997: [0]=IN1 [1]=IN2 [2]=IN3 [3]=IN4
171 	 * wm8998: [0]=IN1A [1]=IN2A [2]=IN1B [3]=IN2B
172 	 */
173 	int inmode[ARIZONA_MAX_INPUT];
174 
175 	/** Mode for outputs */
176 	int out_mono[ARIZONA_MAX_OUTPUT];
177 
178 	/** Limit output volumes */
179 	unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
180 
181 	/** PDM speaker mute setting */
182 	unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
183 
184 	/** PDM speaker format */
185 	unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK];
186 
187 	/** Haptic actuator type */
188 	unsigned int hap_act;
189 
190 	/** GPIO for primary IRQ (used for edge triggered emulation) */
191 	int irq_gpio;
192 
193 	/** General purpose switch control */
194 	unsigned int gpsw;
195 };
196 
197 #endif
198