1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs35l34.c -- CS35l34 ALSA SoC audio driver
5 * Copyright 2016 Cirrus Logic, Inc.
7 * Author: Paul Handrigan <Paul.Handrigan@cirrus.com>
10 #include <linux/module.h>
11 #include <linux/moduleparam.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/i2c.h>
16 #include <linux/slab.h>
17 #include <linux/workqueue.h>
18 #include <linux/platform_device.h>
19 #include <linux/regulator/consumer.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/pm_runtime.h>
22 #include <linux/of_device.h>
23 #include <linux/of_gpio.h>
24 #include <linux/of_irq.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h>
28 #include <sound/soc.h>
29 #include <sound/soc-dapm.h>
30 #include <linux/gpio.h>
31 #include <linux/gpio/consumer.h>
32 #include <sound/initval.h>
33 #include <sound/tlv.h>
34 #include <sound/cs35l34.h>
38 #define PDN_DONE_ATTEMPTS 10
39 #define CS35L34_START_DELAY 50
41 struct cs35l34_private
{
42 struct snd_soc_component
*component
;
43 struct cs35l34_platform_data pdata
;
44 struct regmap
*regmap
;
45 struct regulator_bulk_data core_supplies
[2];
46 int num_core_supplies
;
49 struct gpio_desc
*reset_gpio
; /* Active-low reset GPIO */
52 static const struct reg_default cs35l34_reg
[] = {
53 {CS35L34_PWRCTL1
, 0x01},
54 {CS35L34_PWRCTL2
, 0x19},
55 {CS35L34_PWRCTL3
, 0x01},
56 {CS35L34_ADSP_CLK_CTL
, 0x08},
57 {CS35L34_MCLK_CTL
, 0x11},
58 {CS35L34_AMP_INP_DRV_CTL
, 0x01},
59 {CS35L34_AMP_DIG_VOL_CTL
, 0x12},
60 {CS35L34_AMP_DIG_VOL
, 0x00},
61 {CS35L34_AMP_ANLG_GAIN_CTL
, 0x0F},
62 {CS35L34_PROTECT_CTL
, 0x06},
63 {CS35L34_AMP_KEEP_ALIVE_CTL
, 0x04},
64 {CS35L34_BST_CVTR_V_CTL
, 0x00},
65 {CS35L34_BST_PEAK_I
, 0x10},
66 {CS35L34_BST_RAMP_CTL
, 0x87},
67 {CS35L34_BST_CONV_COEF_1
, 0x24},
68 {CS35L34_BST_CONV_COEF_2
, 0x24},
69 {CS35L34_BST_CONV_SLOPE_COMP
, 0x4E},
70 {CS35L34_BST_CONV_SW_FREQ
, 0x08},
71 {CS35L34_CLASS_H_CTL
, 0x0D},
72 {CS35L34_CLASS_H_HEADRM_CTL
, 0x0D},
73 {CS35L34_CLASS_H_RELEASE_RATE
, 0x08},
74 {CS35L34_CLASS_H_FET_DRIVE_CTL
, 0x41},
75 {CS35L34_CLASS_H_STATUS
, 0x05},
76 {CS35L34_VPBR_CTL
, 0x0A},
77 {CS35L34_VPBR_VOL_CTL
, 0x90},
78 {CS35L34_VPBR_TIMING_CTL
, 0x6A},
79 {CS35L34_PRED_MAX_ATTEN_SPK_LOAD
, 0x95},
80 {CS35L34_PRED_BROWNOUT_THRESH
, 0x1C},
81 {CS35L34_PRED_BROWNOUT_VOL_CTL
, 0x00},
82 {CS35L34_PRED_BROWNOUT_RATE_CTL
, 0x10},
83 {CS35L34_PRED_WAIT_CTL
, 0x10},
84 {CS35L34_PRED_ZVP_INIT_IMP_CTL
, 0x08},
85 {CS35L34_PRED_MAN_SAFE_VPI_CTL
, 0x80},
86 {CS35L34_VPBR_ATTEN_STATUS
, 0x00},
87 {CS35L34_PRED_BRWNOUT_ATT_STATUS
, 0x00},
88 {CS35L34_SPKR_MON_CTL
, 0xC6},
89 {CS35L34_ADSP_I2S_CTL
, 0x00},
90 {CS35L34_ADSP_TDM_CTL
, 0x00},
91 {CS35L34_TDM_TX_CTL_1_VMON
, 0x00},
92 {CS35L34_TDM_TX_CTL_2_IMON
, 0x04},
93 {CS35L34_TDM_TX_CTL_3_VPMON
, 0x03},
94 {CS35L34_TDM_TX_CTL_4_VBSTMON
, 0x07},
95 {CS35L34_TDM_TX_CTL_5_FLAG1
, 0x08},
96 {CS35L34_TDM_TX_CTL_6_FLAG2
, 0x09},
97 {CS35L34_TDM_TX_SLOT_EN_1
, 0x00},
98 {CS35L34_TDM_TX_SLOT_EN_2
, 0x00},
99 {CS35L34_TDM_TX_SLOT_EN_3
, 0x00},
100 {CS35L34_TDM_TX_SLOT_EN_4
, 0x00},
101 {CS35L34_TDM_RX_CTL_1_AUDIN
, 0x40},
102 {CS35L34_TDM_RX_CTL_3_ALIVE
, 0x04},
103 {CS35L34_MULT_DEV_SYNCH1
, 0x00},
104 {CS35L34_MULT_DEV_SYNCH2
, 0x80},
105 {CS35L34_PROT_RELEASE_CTL
, 0x00},
106 {CS35L34_DIAG_MODE_REG_LOCK
, 0x00},
107 {CS35L34_DIAG_MODE_CTL_1
, 0x00},
108 {CS35L34_DIAG_MODE_CTL_2
, 0x00},
109 {CS35L34_INT_MASK_1
, 0xFF},
110 {CS35L34_INT_MASK_2
, 0xFF},
111 {CS35L34_INT_MASK_3
, 0xFF},
112 {CS35L34_INT_MASK_4
, 0xFF},
113 {CS35L34_INT_STATUS_1
, 0x30},
114 {CS35L34_INT_STATUS_2
, 0x05},
115 {CS35L34_INT_STATUS_3
, 0x00},
116 {CS35L34_INT_STATUS_4
, 0x00},
117 {CS35L34_OTP_TRIM_STATUS
, 0x00},
120 static bool cs35l34_volatile_register(struct device
*dev
, unsigned int reg
)
123 case CS35L34_DEVID_AB
:
124 case CS35L34_DEVID_CD
:
125 case CS35L34_DEVID_E
:
128 case CS35L34_INT_STATUS_1
:
129 case CS35L34_INT_STATUS_2
:
130 case CS35L34_INT_STATUS_3
:
131 case CS35L34_INT_STATUS_4
:
132 case CS35L34_CLASS_H_STATUS
:
133 case CS35L34_VPBR_ATTEN_STATUS
:
134 case CS35L34_OTP_TRIM_STATUS
:
141 static bool cs35l34_readable_register(struct device
*dev
, unsigned int reg
)
144 case CS35L34_DEVID_AB
:
145 case CS35L34_DEVID_CD
:
146 case CS35L34_DEVID_E
:
149 case CS35L34_PWRCTL1
:
150 case CS35L34_PWRCTL2
:
151 case CS35L34_PWRCTL3
:
152 case CS35L34_ADSP_CLK_CTL
:
153 case CS35L34_MCLK_CTL
:
154 case CS35L34_AMP_INP_DRV_CTL
:
155 case CS35L34_AMP_DIG_VOL_CTL
:
156 case CS35L34_AMP_DIG_VOL
:
157 case CS35L34_AMP_ANLG_GAIN_CTL
:
158 case CS35L34_PROTECT_CTL
:
159 case CS35L34_AMP_KEEP_ALIVE_CTL
:
160 case CS35L34_BST_CVTR_V_CTL
:
161 case CS35L34_BST_PEAK_I
:
162 case CS35L34_BST_RAMP_CTL
:
163 case CS35L34_BST_CONV_COEF_1
:
164 case CS35L34_BST_CONV_COEF_2
:
165 case CS35L34_BST_CONV_SLOPE_COMP
:
166 case CS35L34_BST_CONV_SW_FREQ
:
167 case CS35L34_CLASS_H_CTL
:
168 case CS35L34_CLASS_H_HEADRM_CTL
:
169 case CS35L34_CLASS_H_RELEASE_RATE
:
170 case CS35L34_CLASS_H_FET_DRIVE_CTL
:
171 case CS35L34_CLASS_H_STATUS
:
172 case CS35L34_VPBR_CTL
:
173 case CS35L34_VPBR_VOL_CTL
:
174 case CS35L34_VPBR_TIMING_CTL
:
175 case CS35L34_PRED_MAX_ATTEN_SPK_LOAD
:
176 case CS35L34_PRED_BROWNOUT_THRESH
:
177 case CS35L34_PRED_BROWNOUT_VOL_CTL
:
178 case CS35L34_PRED_BROWNOUT_RATE_CTL
:
179 case CS35L34_PRED_WAIT_CTL
:
180 case CS35L34_PRED_ZVP_INIT_IMP_CTL
:
181 case CS35L34_PRED_MAN_SAFE_VPI_CTL
:
182 case CS35L34_VPBR_ATTEN_STATUS
:
183 case CS35L34_PRED_BRWNOUT_ATT_STATUS
:
184 case CS35L34_SPKR_MON_CTL
:
185 case CS35L34_ADSP_I2S_CTL
:
186 case CS35L34_ADSP_TDM_CTL
:
187 case CS35L34_TDM_TX_CTL_1_VMON
:
188 case CS35L34_TDM_TX_CTL_2_IMON
:
189 case CS35L34_TDM_TX_CTL_3_VPMON
:
190 case CS35L34_TDM_TX_CTL_4_VBSTMON
:
191 case CS35L34_TDM_TX_CTL_5_FLAG1
:
192 case CS35L34_TDM_TX_CTL_6_FLAG2
:
193 case CS35L34_TDM_TX_SLOT_EN_1
:
194 case CS35L34_TDM_TX_SLOT_EN_2
:
195 case CS35L34_TDM_TX_SLOT_EN_3
:
196 case CS35L34_TDM_TX_SLOT_EN_4
:
197 case CS35L34_TDM_RX_CTL_1_AUDIN
:
198 case CS35L34_TDM_RX_CTL_3_ALIVE
:
199 case CS35L34_MULT_DEV_SYNCH1
:
200 case CS35L34_MULT_DEV_SYNCH2
:
201 case CS35L34_PROT_RELEASE_CTL
:
202 case CS35L34_DIAG_MODE_REG_LOCK
:
203 case CS35L34_DIAG_MODE_CTL_1
:
204 case CS35L34_DIAG_MODE_CTL_2
:
205 case CS35L34_INT_MASK_1
:
206 case CS35L34_INT_MASK_2
:
207 case CS35L34_INT_MASK_3
:
208 case CS35L34_INT_MASK_4
:
209 case CS35L34_INT_STATUS_1
:
210 case CS35L34_INT_STATUS_2
:
211 case CS35L34_INT_STATUS_3
:
212 case CS35L34_INT_STATUS_4
:
213 case CS35L34_OTP_TRIM_STATUS
:
220 static bool cs35l34_precious_register(struct device
*dev
, unsigned int reg
)
223 case CS35L34_INT_STATUS_1
:
224 case CS35L34_INT_STATUS_2
:
225 case CS35L34_INT_STATUS_3
:
226 case CS35L34_INT_STATUS_4
:
233 static int cs35l34_sdin_event(struct snd_soc_dapm_widget
*w
,
234 struct snd_kcontrol
*kcontrol
, int event
)
236 struct snd_soc_component
*component
= snd_soc_dapm_to_component(w
->dapm
);
237 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
241 case SND_SOC_DAPM_PRE_PMU
:
243 regmap_update_bits(priv
->regmap
, CS35L34_PWRCTL3
,
244 CS35L34_PDN_TDM
, 0x00);
246 ret
= regmap_update_bits(priv
->regmap
, CS35L34_PWRCTL1
,
249 dev_err(component
->dev
, "Cannot set Power bits %d\n", ret
);
252 usleep_range(5000, 5100);
254 case SND_SOC_DAPM_POST_PMD
:
255 if (priv
->tdm_mode
) {
256 regmap_update_bits(priv
->regmap
, CS35L34_PWRCTL3
,
257 CS35L34_PDN_TDM
, CS35L34_PDN_TDM
);
259 ret
= regmap_update_bits(priv
->regmap
, CS35L34_PWRCTL1
,
260 CS35L34_PDN_ALL
, CS35L34_PDN_ALL
);
263 pr_err("Invalid event = 0x%x\n", event
);
268 static int cs35l34_set_tdm_slot(struct snd_soc_dai
*dai
, unsigned int tx_mask
,
269 unsigned int rx_mask
, int slots
, int slot_width
)
271 struct snd_soc_component
*component
= dai
->component
;
272 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
273 unsigned int reg
, bit_pos
;
279 priv
->tdm_mode
= true;
280 /* scan rx_mask for aud slot */
281 slot
= ffs(rx_mask
) - 1;
283 snd_soc_component_update_bits(component
, CS35L34_TDM_RX_CTL_1_AUDIN
,
284 CS35L34_X_LOC
, slot
);
286 /* scan tx_mask: vmon(2 slots); imon (2 slots); vpmon (1 slot)
289 slot
= ffs(tx_mask
) - 1;
292 /* disable vpmon/vbstmon: enable later if set in tx_mask */
293 snd_soc_component_update_bits(component
, CS35L34_TDM_TX_CTL_3_VPMON
,
294 CS35L34_X_STATE
| CS35L34_X_LOC
,
295 CS35L34_X_STATE
| CS35L34_X_LOC
);
296 snd_soc_component_update_bits(component
, CS35L34_TDM_TX_CTL_4_VBSTMON
,
297 CS35L34_X_STATE
| CS35L34_X_LOC
,
298 CS35L34_X_STATE
| CS35L34_X_LOC
);
300 /* disconnect {vp,vbst}_mon routes: eanble later if set in tx_mask*/
302 /* configure VMON_TX_LOC */
304 snd_soc_component_update_bits(component
, CS35L34_TDM_TX_CTL_1_VMON
,
305 CS35L34_X_STATE
| CS35L34_X_LOC
, slot
);
307 /* configure IMON_TX_LOC */
309 snd_soc_component_update_bits(component
, CS35L34_TDM_TX_CTL_2_IMON
,
310 CS35L34_X_STATE
| CS35L34_X_LOC
, slot
);
312 /* configure VPMON_TX_LOC */
314 snd_soc_component_update_bits(component
, CS35L34_TDM_TX_CTL_3_VPMON
,
315 CS35L34_X_STATE
| CS35L34_X_LOC
, slot
);
317 /* configure VBSTMON_TX_LOC */
319 snd_soc_component_update_bits(component
,
320 CS35L34_TDM_TX_CTL_4_VBSTMON
,
321 CS35L34_X_STATE
| CS35L34_X_LOC
, slot
);
324 /* Enable the relevant tx slot */
325 reg
= CS35L34_TDM_TX_SLOT_EN_4
- (slot
/8);
326 bit_pos
= slot
- ((slot
/ 8) * (8));
327 snd_soc_component_update_bits(component
, reg
,
328 1 << bit_pos
, 1 << bit_pos
);
330 tx_mask
&= ~(1 << slot
);
331 slot
= ffs(tx_mask
) - 1;
338 static int cs35l34_main_amp_event(struct snd_soc_dapm_widget
*w
,
339 struct snd_kcontrol
*kcontrol
, int event
)
341 struct snd_soc_component
*component
= snd_soc_dapm_to_component(w
->dapm
);
342 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
345 case SND_SOC_DAPM_POST_PMU
:
346 regmap_update_bits(priv
->regmap
, CS35L34_BST_CVTR_V_CTL
,
347 CS35L34_BST_CVTL_MASK
, priv
->pdata
.boost_vtge
);
348 usleep_range(5000, 5100);
349 regmap_update_bits(priv
->regmap
, CS35L34_PROTECT_CTL
,
352 case SND_SOC_DAPM_POST_PMD
:
353 regmap_update_bits(priv
->regmap
, CS35L34_BST_CVTR_V_CTL
,
354 CS35L34_BST_CVTL_MASK
, 0);
355 regmap_update_bits(priv
->regmap
, CS35L34_PROTECT_CTL
,
356 CS35L34_MUTE
, CS35L34_MUTE
);
357 usleep_range(5000, 5100);
360 pr_err("Invalid event = 0x%x\n", event
);
365 static DECLARE_TLV_DB_SCALE(dig_vol_tlv
, -10200, 50, 0);
367 static DECLARE_TLV_DB_SCALE(amp_gain_tlv
, 300, 100, 0);
370 static const struct snd_kcontrol_new cs35l34_snd_controls
[] = {
371 SOC_SINGLE_SX_TLV("Digital Volume", CS35L34_AMP_DIG_VOL
,
372 0, 0x34, 0xE4, dig_vol_tlv
),
373 SOC_SINGLE_TLV("Amp Gain Volume", CS35L34_AMP_ANLG_GAIN_CTL
,
374 0, 0xF, 0, amp_gain_tlv
),
378 static int cs35l34_mclk_event(struct snd_soc_dapm_widget
*w
,
379 struct snd_kcontrol
*kcontrol
, int event
)
381 struct snd_soc_component
*component
= snd_soc_dapm_to_component(w
->dapm
);
382 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
387 case SND_SOC_DAPM_PRE_PMD
:
388 ret
= regmap_read(priv
->regmap
, CS35L34_AMP_DIG_VOL_CTL
,
391 pr_err("%s regmap read failure %d\n", __func__
, ret
);
394 if (reg
& CS35L34_AMP_DIGSFT
)
397 usleep_range(2000, 2100);
399 for (i
= 0; i
< PDN_DONE_ATTEMPTS
; i
++) {
400 ret
= regmap_read(priv
->regmap
, CS35L34_INT_STATUS_2
,
403 pr_err("%s regmap read failure %d\n",
407 if (reg
& CS35L34_PDN_DONE
)
410 usleep_range(5000, 5100);
412 if (i
== PDN_DONE_ATTEMPTS
)
413 pr_err("%s Device did not power down properly\n",
417 pr_err("Invalid event = 0x%x\n", event
);
423 static const struct snd_soc_dapm_widget cs35l34_dapm_widgets
[] = {
424 SND_SOC_DAPM_AIF_IN_E("SDIN", NULL
, 0, CS35L34_PWRCTL3
,
425 1, 1, cs35l34_sdin_event
,
426 SND_SOC_DAPM_PRE_PMU
|
427 SND_SOC_DAPM_POST_PMD
),
428 SND_SOC_DAPM_AIF_OUT("SDOUT", NULL
, 0, CS35L34_PWRCTL3
, 2, 1),
430 SND_SOC_DAPM_SUPPLY("EXTCLK", CS35L34_PWRCTL3
, 7, 1,
431 cs35l34_mclk_event
, SND_SOC_DAPM_PRE_PMD
),
433 SND_SOC_DAPM_OUTPUT("SPK"),
435 SND_SOC_DAPM_INPUT("VP"),
436 SND_SOC_DAPM_INPUT("VPST"),
437 SND_SOC_DAPM_INPUT("ISENSE"),
438 SND_SOC_DAPM_INPUT("VSENSE"),
440 SND_SOC_DAPM_ADC("VMON ADC", NULL
, CS35L34_PWRCTL2
, 7, 1),
441 SND_SOC_DAPM_ADC("IMON ADC", NULL
, CS35L34_PWRCTL2
, 6, 1),
442 SND_SOC_DAPM_ADC("VPMON ADC", NULL
, CS35L34_PWRCTL3
, 3, 1),
443 SND_SOC_DAPM_ADC("VBSTMON ADC", NULL
, CS35L34_PWRCTL3
, 4, 1),
444 SND_SOC_DAPM_ADC("CLASS H", NULL
, CS35L34_PWRCTL2
, 5, 1),
445 SND_SOC_DAPM_ADC("BOOST", NULL
, CS35L34_PWRCTL2
, 2, 1),
447 SND_SOC_DAPM_OUT_DRV_E("Main AMP", CS35L34_PWRCTL2
, 0, 1, NULL
, 0,
448 cs35l34_main_amp_event
, SND_SOC_DAPM_POST_PMU
|
449 SND_SOC_DAPM_POST_PMD
),
452 static const struct snd_soc_dapm_route cs35l34_audio_map
[] = {
453 {"SDIN", NULL
, "AMP Playback"},
454 {"BOOST", NULL
, "SDIN"},
455 {"CLASS H", NULL
, "BOOST"},
456 {"Main AMP", NULL
, "CLASS H"},
457 {"SPK", NULL
, "Main AMP"},
459 {"VPMON ADC", NULL
, "CLASS H"},
460 {"VBSTMON ADC", NULL
, "CLASS H"},
461 {"SPK", NULL
, "VPMON ADC"},
462 {"SPK", NULL
, "VBSTMON ADC"},
464 {"IMON ADC", NULL
, "ISENSE"},
465 {"VMON ADC", NULL
, "VSENSE"},
466 {"SDOUT", NULL
, "IMON ADC"},
467 {"SDOUT", NULL
, "VMON ADC"},
468 {"AMP Capture", NULL
, "SDOUT"},
470 {"SDIN", NULL
, "EXTCLK"},
471 {"SDOUT", NULL
, "EXTCLK"},
474 struct cs35l34_mclk_div
{
480 static struct cs35l34_mclk_div cs35l34_mclk_coeffs
[] = {
482 /* MCLK, Sample Rate, adsp_rate */
484 {5644800, 11025, 0x1},
485 {5644800, 22050, 0x4},
486 {5644800, 44100, 0x7},
488 {6000000, 8000, 0x0},
489 {6000000, 11025, 0x1},
490 {6000000, 12000, 0x2},
491 {6000000, 16000, 0x3},
492 {6000000, 22050, 0x4},
493 {6000000, 24000, 0x5},
494 {6000000, 32000, 0x6},
495 {6000000, 44100, 0x7},
496 {6000000, 48000, 0x8},
498 {6144000, 8000, 0x0},
499 {6144000, 11025, 0x1},
500 {6144000, 12000, 0x2},
501 {6144000, 16000, 0x3},
502 {6144000, 22050, 0x4},
503 {6144000, 24000, 0x5},
504 {6144000, 32000, 0x6},
505 {6144000, 44100, 0x7},
506 {6144000, 48000, 0x8},
509 static int cs35l34_get_mclk_coeff(int mclk
, int srate
)
513 for (i
= 0; i
< ARRAY_SIZE(cs35l34_mclk_coeffs
); i
++) {
514 if (cs35l34_mclk_coeffs
[i
].mclk
== mclk
&&
515 cs35l34_mclk_coeffs
[i
].srate
== srate
)
521 static int cs35l34_set_dai_fmt(struct snd_soc_dai
*codec_dai
, unsigned int fmt
)
523 struct snd_soc_component
*component
= codec_dai
->component
;
524 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
526 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
527 case SND_SOC_DAIFMT_CBM_CFM
:
528 regmap_update_bits(priv
->regmap
, CS35L34_ADSP_CLK_CTL
,
531 case SND_SOC_DAIFMT_CBS_CFS
:
532 regmap_update_bits(priv
->regmap
, CS35L34_ADSP_CLK_CTL
,
541 static int cs35l34_pcm_hw_params(struct snd_pcm_substream
*substream
,
542 struct snd_pcm_hw_params
*params
,
543 struct snd_soc_dai
*dai
)
545 struct snd_soc_component
*component
= dai
->component
;
546 struct cs35l34_private
*priv
= snd_soc_component_get_drvdata(component
);
547 int srate
= params_rate(params
);
550 int coeff
= cs35l34_get_mclk_coeff(priv
->mclk_int
, srate
);
553 dev_err(component
->dev
, "ERROR: Invalid mclk %d and/or srate %d\n",
554 priv
->mclk_int
, srate
);
558 ret
= regmap_update_bits(priv
->regmap
, CS35L34_ADSP_CLK_CTL
,
559 CS35L34_ADSP_RATE
, cs35l34_mclk_coeffs
[coeff
].adsp_rate
);
561 dev_err(component
->dev
, "Failed to set clock state %d\n", ret
);
566 static const unsigned int cs35l34_src_rates
[] = {
567 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
571 static const struct snd_pcm_hw_constraint_list cs35l34_constraints
= {
572 .count
= ARRAY_SIZE(cs35l34_src_rates
),
573 .list
= cs35l34_src_rates
,
576 static int cs35l34_pcm_startup(struct snd_pcm_substream
*substream
,
577 struct snd_soc_dai
*dai
)
580 snd_pcm_hw_constraint_list(substream
->runtime
, 0,
581 SNDRV_PCM_HW_PARAM_RATE
, &cs35l34_constraints
);
586 static int cs35l34_set_tristate(struct snd_soc_dai
*dai
, int tristate
)
589 struct snd_soc_component
*component
= dai
->component
;
592 snd_soc_component_update_bits(component
, CS35L34_PWRCTL3
,
593 CS35L34_PDN_SDOUT
, CS35L34_PDN_SDOUT
);
595 snd_soc_component_update_bits(component
, CS35L34_PWRCTL3
,
596 CS35L34_PDN_SDOUT
, 0);
600 static int cs35l34_dai_set_sysclk(struct snd_soc_dai
*dai
,
601 int clk_id
, unsigned int freq
, int dir
)
603 struct snd_soc_component
*component
= dai
->component
;
604 struct cs35l34_private
*cs35l34
= snd_soc_component_get_drvdata(component
);
608 case CS35L34_MCLK_5644
:
609 value
= CS35L34_MCLK_RATE_5P6448
;
610 cs35l34
->mclk_int
= freq
;
613 value
= CS35L34_MCLK_RATE_6P0000
;
614 cs35l34
->mclk_int
= freq
;
616 case CS35L34_MCLK_6144
:
617 value
= CS35L34_MCLK_RATE_6P1440
;
618 cs35l34
->mclk_int
= freq
;
620 case CS35L34_MCLK_11289
:
621 value
= CS35L34_MCLK_DIV
| CS35L34_MCLK_RATE_5P6448
;
622 cs35l34
->mclk_int
= freq
/ 2;
624 case CS35L34_MCLK_12
:
625 value
= CS35L34_MCLK_DIV
| CS35L34_MCLK_RATE_6P0000
;
626 cs35l34
->mclk_int
= freq
/ 2;
628 case CS35L34_MCLK_12288
:
629 value
= CS35L34_MCLK_DIV
| CS35L34_MCLK_RATE_6P1440
;
630 cs35l34
->mclk_int
= freq
/ 2;
633 dev_err(component
->dev
, "ERROR: Invalid Frequency %d\n", freq
);
634 cs35l34
->mclk_int
= 0;
637 regmap_update_bits(cs35l34
->regmap
, CS35L34_MCLK_CTL
,
638 CS35L34_MCLK_DIV
| CS35L34_MCLK_RATE_MASK
, value
);
642 static const struct snd_soc_dai_ops cs35l34_ops
= {
643 .startup
= cs35l34_pcm_startup
,
644 .set_tristate
= cs35l34_set_tristate
,
645 .set_fmt
= cs35l34_set_dai_fmt
,
646 .hw_params
= cs35l34_pcm_hw_params
,
647 .set_sysclk
= cs35l34_dai_set_sysclk
,
648 .set_tdm_slot
= cs35l34_set_tdm_slot
,
651 static struct snd_soc_dai_driver cs35l34_dai
= {
655 .stream_name
= "AMP Playback",
658 .rates
= CS35L34_RATES
,
659 .formats
= CS35L34_FORMATS
,
662 .stream_name
= "AMP Capture",
665 .rates
= CS35L34_RATES
,
666 .formats
= CS35L34_FORMATS
,
669 .symmetric_rates
= 1,
672 static int cs35l34_boost_inductor(struct cs35l34_private
*cs35l34
,
673 unsigned int inductor
)
675 struct snd_soc_component
*component
= cs35l34
->component
;
678 case 1000: /* 1 uH */
679 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_1
, 0x24);
680 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_2
, 0x24);
681 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SLOPE_COMP
,
683 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SW_FREQ
, 0);
685 case 1200: /* 1.2 uH */
686 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_1
, 0x20);
687 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_2
, 0x20);
688 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SLOPE_COMP
,
690 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SW_FREQ
, 1);
692 case 1500: /* 1.5uH */
693 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_1
, 0x20);
694 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_2
, 0x20);
695 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SLOPE_COMP
,
697 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SW_FREQ
, 2);
699 case 2200: /* 2.2uH */
700 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_1
, 0x19);
701 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_COEF_2
, 0x25);
702 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SLOPE_COMP
,
704 regmap_write(cs35l34
->regmap
, CS35L34_BST_CONV_SW_FREQ
, 3);
707 dev_err(component
->dev
, "%s Invalid Inductor Value %d uH\n",
714 static int cs35l34_probe(struct snd_soc_component
*component
)
717 struct cs35l34_private
*cs35l34
= snd_soc_component_get_drvdata(component
);
719 pm_runtime_get_sync(component
->dev
);
721 /* Set over temperature warning attenuation to 6 dB */
722 regmap_update_bits(cs35l34
->regmap
, CS35L34_PROTECT_CTL
,
723 CS35L34_OTW_ATTN_MASK
, 0x8);
725 /* Set Power control registers 2 and 3 to have everything
726 * powered down at initialization
728 regmap_write(cs35l34
->regmap
, CS35L34_PWRCTL2
, 0xFD);
729 regmap_write(cs35l34
->regmap
, CS35L34_PWRCTL3
, 0x1F);
731 /* Set mute bit at startup */
732 regmap_update_bits(cs35l34
->regmap
, CS35L34_PROTECT_CTL
,
733 CS35L34_MUTE
, CS35L34_MUTE
);
735 /* Set Platform Data */
736 if (cs35l34
->pdata
.boost_peak
)
737 regmap_update_bits(cs35l34
->regmap
, CS35L34_BST_PEAK_I
,
738 CS35L34_BST_PEAK_MASK
,
739 cs35l34
->pdata
.boost_peak
);
741 if (cs35l34
->pdata
.gain_zc_disable
)
742 regmap_update_bits(cs35l34
->regmap
, CS35L34_PROTECT_CTL
,
743 CS35L34_GAIN_ZC_MASK
, 0);
745 regmap_update_bits(cs35l34
->regmap
, CS35L34_PROTECT_CTL
,
746 CS35L34_GAIN_ZC_MASK
, CS35L34_GAIN_ZC_MASK
);
748 if (cs35l34
->pdata
.aif_half_drv
)
749 regmap_update_bits(cs35l34
->regmap
, CS35L34_ADSP_CLK_CTL
,
750 CS35L34_ADSP_DRIVE
, 0);
752 if (cs35l34
->pdata
.digsft_disable
)
753 regmap_update_bits(cs35l34
->regmap
, CS35L34_AMP_DIG_VOL_CTL
,
754 CS35L34_AMP_DIGSFT
, 0);
756 if (cs35l34
->pdata
.amp_inv
)
757 regmap_update_bits(cs35l34
->regmap
, CS35L34_AMP_DIG_VOL_CTL
,
758 CS35L34_INV
, CS35L34_INV
);
760 if (cs35l34
->pdata
.boost_ind
)
761 ret
= cs35l34_boost_inductor(cs35l34
, cs35l34
->pdata
.boost_ind
);
763 if (cs35l34
->pdata
.i2s_sdinloc
)
764 regmap_update_bits(cs35l34
->regmap
, CS35L34_ADSP_I2S_CTL
,
765 CS35L34_I2S_LOC_MASK
,
766 cs35l34
->pdata
.i2s_sdinloc
<< CS35L34_I2S_LOC_SHIFT
);
768 if (cs35l34
->pdata
.tdm_rising_edge
)
769 regmap_update_bits(cs35l34
->regmap
, CS35L34_ADSP_TDM_CTL
,
772 pm_runtime_put_sync(component
->dev
);
778 static const struct snd_soc_component_driver soc_component_dev_cs35l34
= {
779 .probe
= cs35l34_probe
,
780 .dapm_widgets
= cs35l34_dapm_widgets
,
781 .num_dapm_widgets
= ARRAY_SIZE(cs35l34_dapm_widgets
),
782 .dapm_routes
= cs35l34_audio_map
,
783 .num_dapm_routes
= ARRAY_SIZE(cs35l34_audio_map
),
784 .controls
= cs35l34_snd_controls
,
785 .num_controls
= ARRAY_SIZE(cs35l34_snd_controls
),
787 .use_pmdown_time
= 1,
789 .non_legacy_dai_naming
= 1,
792 static struct regmap_config cs35l34_regmap
= {
796 .max_register
= CS35L34_MAX_REGISTER
,
797 .reg_defaults
= cs35l34_reg
,
798 .num_reg_defaults
= ARRAY_SIZE(cs35l34_reg
),
799 .volatile_reg
= cs35l34_volatile_register
,
800 .readable_reg
= cs35l34_readable_register
,
801 .precious_reg
= cs35l34_precious_register
,
802 .cache_type
= REGCACHE_RBTREE
,
805 static int cs35l34_handle_of_data(struct i2c_client
*i2c_client
,
806 struct cs35l34_platform_data
*pdata
)
808 struct device_node
*np
= i2c_client
->dev
.of_node
;
811 if (of_property_read_u32(np
, "cirrus,boost-vtge-millivolt",
813 /* Boost Voltage has a maximum of 8V */
814 if (val
> 8000 || (val
< 3300 && val
> 0)) {
815 dev_err(&i2c_client
->dev
,
816 "Invalid Boost Voltage %d mV\n", val
);
820 pdata
->boost_vtge
= 0; /* Use VP */
822 pdata
->boost_vtge
= ((val
- 3300)/100) + 1;
824 dev_warn(&i2c_client
->dev
,
825 "Boost Voltage not specified. Using VP\n");
828 if (of_property_read_u32(np
, "cirrus,boost-ind-nanohenry", &val
) >= 0) {
829 pdata
->boost_ind
= val
;
831 dev_err(&i2c_client
->dev
, "Inductor not specified.\n");
835 if (of_property_read_u32(np
, "cirrus,boost-peak-milliamp", &val
) >= 0) {
836 if (val
> 3840 || val
< 1200) {
837 dev_err(&i2c_client
->dev
,
838 "Invalid Boost Peak Current %d mA\n", val
);
841 pdata
->boost_peak
= ((val
- 1200)/80) + 1;
844 pdata
->aif_half_drv
= of_property_read_bool(np
,
845 "cirrus,aif-half-drv");
846 pdata
->digsft_disable
= of_property_read_bool(np
,
847 "cirrus,digsft-disable");
849 pdata
->gain_zc_disable
= of_property_read_bool(np
,
850 "cirrus,gain-zc-disable");
851 pdata
->amp_inv
= of_property_read_bool(np
, "cirrus,amp-inv");
853 if (of_property_read_u32(np
, "cirrus,i2s-sdinloc", &val
) >= 0)
854 pdata
->i2s_sdinloc
= val
;
855 if (of_property_read_u32(np
, "cirrus,tdm-rising-edge", &val
) >= 0)
856 pdata
->tdm_rising_edge
= val
;
861 static irqreturn_t
cs35l34_irq_thread(int irq
, void *data
)
863 struct cs35l34_private
*cs35l34
= data
;
864 struct snd_soc_component
*component
= cs35l34
->component
;
865 unsigned int sticky1
, sticky2
, sticky3
, sticky4
;
866 unsigned int mask1
, mask2
, mask3
, mask4
, current1
;
869 /* ack the irq by reading all status registers */
870 regmap_read(cs35l34
->regmap
, CS35L34_INT_STATUS_4
, &sticky4
);
871 regmap_read(cs35l34
->regmap
, CS35L34_INT_STATUS_3
, &sticky3
);
872 regmap_read(cs35l34
->regmap
, CS35L34_INT_STATUS_2
, &sticky2
);
873 regmap_read(cs35l34
->regmap
, CS35L34_INT_STATUS_1
, &sticky1
);
875 regmap_read(cs35l34
->regmap
, CS35L34_INT_MASK_4
, &mask4
);
876 regmap_read(cs35l34
->regmap
, CS35L34_INT_MASK_3
, &mask3
);
877 regmap_read(cs35l34
->regmap
, CS35L34_INT_MASK_2
, &mask2
);
878 regmap_read(cs35l34
->regmap
, CS35L34_INT_MASK_1
, &mask1
);
880 if (!(sticky1
& ~mask1
) && !(sticky2
& ~mask2
) && !(sticky3
& ~mask3
)
881 && !(sticky4
& ~mask4
))
884 regmap_read(cs35l34
->regmap
, CS35L34_INT_STATUS_1
, ¤t1
);
886 if (sticky1
& CS35L34_CAL_ERR
) {
887 dev_err(component
->dev
, "Cal error\n");
889 /* error is no longer asserted; safe to reset */
890 if (!(current1
& CS35L34_CAL_ERR
)) {
891 dev_dbg(component
->dev
, "Cal error release\n");
892 regmap_update_bits(cs35l34
->regmap
,
893 CS35L34_PROT_RELEASE_CTL
,
894 CS35L34_CAL_ERR_RLS
, 0);
895 regmap_update_bits(cs35l34
->regmap
,
896 CS35L34_PROT_RELEASE_CTL
,
898 CS35L34_CAL_ERR_RLS
);
899 regmap_update_bits(cs35l34
->regmap
,
900 CS35L34_PROT_RELEASE_CTL
,
901 CS35L34_CAL_ERR_RLS
, 0);
902 /* note: amp will re-calibrate on next resume */
906 if (sticky1
& CS35L34_ALIVE_ERR
)
907 dev_err(component
->dev
, "Alive error\n");
909 if (sticky1
& CS35L34_AMP_SHORT
) {
910 dev_crit(component
->dev
, "Amp short error\n");
912 /* error is no longer asserted; safe to reset */
913 if (!(current1
& CS35L34_AMP_SHORT
)) {
914 dev_dbg(component
->dev
,
915 "Amp short error release\n");
916 regmap_update_bits(cs35l34
->regmap
,
917 CS35L34_PROT_RELEASE_CTL
,
918 CS35L34_SHORT_RLS
, 0);
919 regmap_update_bits(cs35l34
->regmap
,
920 CS35L34_PROT_RELEASE_CTL
,
923 regmap_update_bits(cs35l34
->regmap
,
924 CS35L34_PROT_RELEASE_CTL
,
925 CS35L34_SHORT_RLS
, 0);
929 if (sticky1
& CS35L34_OTW
) {
930 dev_crit(component
->dev
, "Over temperature warning\n");
932 /* error is no longer asserted; safe to reset */
933 if (!(current1
& CS35L34_OTW
)) {
934 dev_dbg(component
->dev
,
935 "Over temperature warning release\n");
936 regmap_update_bits(cs35l34
->regmap
,
937 CS35L34_PROT_RELEASE_CTL
,
939 regmap_update_bits(cs35l34
->regmap
,
940 CS35L34_PROT_RELEASE_CTL
,
943 regmap_update_bits(cs35l34
->regmap
,
944 CS35L34_PROT_RELEASE_CTL
,
949 if (sticky1
& CS35L34_OTE
) {
950 dev_crit(component
->dev
, "Over temperature error\n");
952 /* error is no longer asserted; safe to reset */
953 if (!(current1
& CS35L34_OTE
)) {
954 dev_dbg(component
->dev
,
955 "Over temperature error release\n");
956 regmap_update_bits(cs35l34
->regmap
,
957 CS35L34_PROT_RELEASE_CTL
,
959 regmap_update_bits(cs35l34
->regmap
,
960 CS35L34_PROT_RELEASE_CTL
,
963 regmap_update_bits(cs35l34
->regmap
,
964 CS35L34_PROT_RELEASE_CTL
,
969 if (sticky3
& CS35L34_BST_HIGH
) {
970 dev_crit(component
->dev
, "VBST too high error; powering off!\n");
971 regmap_update_bits(cs35l34
->regmap
, CS35L34_PWRCTL2
,
972 CS35L34_PDN_AMP
, CS35L34_PDN_AMP
);
973 regmap_update_bits(cs35l34
->regmap
, CS35L34_PWRCTL1
,
974 CS35L34_PDN_ALL
, CS35L34_PDN_ALL
);
977 if (sticky3
& CS35L34_LBST_SHORT
) {
978 dev_crit(component
->dev
, "LBST short error; powering off!\n");
979 regmap_update_bits(cs35l34
->regmap
, CS35L34_PWRCTL2
,
980 CS35L34_PDN_AMP
, CS35L34_PDN_AMP
);
981 regmap_update_bits(cs35l34
->regmap
, CS35L34_PWRCTL1
,
982 CS35L34_PDN_ALL
, CS35L34_PDN_ALL
);
988 static const char * const cs35l34_core_supplies
[] = {
993 static int cs35l34_i2c_probe(struct i2c_client
*i2c_client
,
994 const struct i2c_device_id
*id
)
996 struct cs35l34_private
*cs35l34
;
997 struct cs35l34_platform_data
*pdata
=
998 dev_get_platdata(&i2c_client
->dev
);
1001 unsigned int devid
= 0;
1004 cs35l34
= devm_kzalloc(&i2c_client
->dev
, sizeof(*cs35l34
), GFP_KERNEL
);
1008 i2c_set_clientdata(i2c_client
, cs35l34
);
1009 cs35l34
->regmap
= devm_regmap_init_i2c(i2c_client
, &cs35l34_regmap
);
1010 if (IS_ERR(cs35l34
->regmap
)) {
1011 ret
= PTR_ERR(cs35l34
->regmap
);
1012 dev_err(&i2c_client
->dev
, "regmap_init() failed: %d\n", ret
);
1016 cs35l34
->num_core_supplies
= ARRAY_SIZE(cs35l34_core_supplies
);
1017 for (i
= 0; i
< ARRAY_SIZE(cs35l34_core_supplies
); i
++)
1018 cs35l34
->core_supplies
[i
].supply
= cs35l34_core_supplies
[i
];
1020 ret
= devm_regulator_bulk_get(&i2c_client
->dev
,
1021 cs35l34
->num_core_supplies
,
1022 cs35l34
->core_supplies
);
1024 dev_err(&i2c_client
->dev
,
1025 "Failed to request core supplies %d\n", ret
);
1029 ret
= regulator_bulk_enable(cs35l34
->num_core_supplies
,
1030 cs35l34
->core_supplies
);
1032 dev_err(&i2c_client
->dev
,
1033 "Failed to enable core supplies: %d\n", ret
);
1038 cs35l34
->pdata
= *pdata
;
1040 pdata
= devm_kzalloc(&i2c_client
->dev
, sizeof(*pdata
),
1045 if (i2c_client
->dev
.of_node
) {
1046 ret
= cs35l34_handle_of_data(i2c_client
, pdata
);
1051 cs35l34
->pdata
= *pdata
;
1054 ret
= devm_request_threaded_irq(&i2c_client
->dev
, i2c_client
->irq
, NULL
,
1055 cs35l34_irq_thread
, IRQF_ONESHOT
| IRQF_TRIGGER_LOW
,
1056 "cs35l34", cs35l34
);
1058 dev_err(&i2c_client
->dev
, "Failed to request IRQ: %d\n", ret
);
1060 cs35l34
->reset_gpio
= devm_gpiod_get_optional(&i2c_client
->dev
,
1061 "reset-gpios", GPIOD_OUT_LOW
);
1062 if (IS_ERR(cs35l34
->reset_gpio
))
1063 return PTR_ERR(cs35l34
->reset_gpio
);
1065 gpiod_set_value_cansleep(cs35l34
->reset_gpio
, 1);
1067 msleep(CS35L34_START_DELAY
);
1069 ret
= regmap_read(cs35l34
->regmap
, CS35L34_DEVID_AB
, ®
);
1071 devid
= (reg
& 0xFF) << 12;
1072 ret
= regmap_read(cs35l34
->regmap
, CS35L34_DEVID_CD
, ®
);
1073 devid
|= (reg
& 0xFF) << 4;
1074 ret
= regmap_read(cs35l34
->regmap
, CS35L34_DEVID_E
, ®
);
1075 devid
|= (reg
& 0xF0) >> 4;
1077 if (devid
!= CS35L34_CHIP_ID
) {
1078 dev_err(&i2c_client
->dev
,
1079 "CS35l34 Device ID (%X). Expected ID %X\n",
1080 devid
, CS35L34_CHIP_ID
);
1085 ret
= regmap_read(cs35l34
->regmap
, CS35L34_REV_ID
, ®
);
1087 dev_err(&i2c_client
->dev
, "Get Revision ID failed\n");
1091 dev_info(&i2c_client
->dev
,
1092 "Cirrus Logic CS35l34 (%x), Revision: %02X\n", devid
,
1095 /* Unmask critical interrupts */
1096 regmap_update_bits(cs35l34
->regmap
, CS35L34_INT_MASK_1
,
1097 CS35L34_M_CAL_ERR
| CS35L34_M_ALIVE_ERR
|
1098 CS35L34_M_AMP_SHORT
| CS35L34_M_OTW
|
1100 regmap_update_bits(cs35l34
->regmap
, CS35L34_INT_MASK_3
,
1101 CS35L34_M_BST_HIGH
| CS35L34_M_LBST_SHORT
, 0);
1103 pm_runtime_set_autosuspend_delay(&i2c_client
->dev
, 100);
1104 pm_runtime_use_autosuspend(&i2c_client
->dev
);
1105 pm_runtime_set_active(&i2c_client
->dev
);
1106 pm_runtime_enable(&i2c_client
->dev
);
1108 ret
= devm_snd_soc_register_component(&i2c_client
->dev
,
1109 &soc_component_dev_cs35l34
, &cs35l34_dai
, 1);
1111 dev_err(&i2c_client
->dev
,
1112 "%s: Register component failed\n", __func__
);
1119 regulator_bulk_disable(cs35l34
->num_core_supplies
,
1120 cs35l34
->core_supplies
);
1125 static int cs35l34_i2c_remove(struct i2c_client
*client
)
1127 struct cs35l34_private
*cs35l34
= i2c_get_clientdata(client
);
1129 gpiod_set_value_cansleep(cs35l34
->reset_gpio
, 0);
1131 pm_runtime_disable(&client
->dev
);
1132 regulator_bulk_disable(cs35l34
->num_core_supplies
,
1133 cs35l34
->core_supplies
);
1138 static int __maybe_unused
cs35l34_runtime_resume(struct device
*dev
)
1140 struct cs35l34_private
*cs35l34
= dev_get_drvdata(dev
);
1143 ret
= regulator_bulk_enable(cs35l34
->num_core_supplies
,
1144 cs35l34
->core_supplies
);
1147 dev_err(dev
, "Failed to enable core supplies: %d\n",
1152 regcache_cache_only(cs35l34
->regmap
, false);
1154 gpiod_set_value_cansleep(cs35l34
->reset_gpio
, 1);
1155 msleep(CS35L34_START_DELAY
);
1157 ret
= regcache_sync(cs35l34
->regmap
);
1159 dev_err(dev
, "Failed to restore register cache\n");
1164 regcache_cache_only(cs35l34
->regmap
, true);
1165 regulator_bulk_disable(cs35l34
->num_core_supplies
,
1166 cs35l34
->core_supplies
);
1171 static int __maybe_unused
cs35l34_runtime_suspend(struct device
*dev
)
1173 struct cs35l34_private
*cs35l34
= dev_get_drvdata(dev
);
1175 regcache_cache_only(cs35l34
->regmap
, true);
1176 regcache_mark_dirty(cs35l34
->regmap
);
1178 gpiod_set_value_cansleep(cs35l34
->reset_gpio
, 0);
1180 regulator_bulk_disable(cs35l34
->num_core_supplies
,
1181 cs35l34
->core_supplies
);
1186 static const struct dev_pm_ops cs35l34_pm_ops
= {
1187 SET_RUNTIME_PM_OPS(cs35l34_runtime_suspend
,
1188 cs35l34_runtime_resume
,
1192 static const struct of_device_id cs35l34_of_match
[] = {
1193 {.compatible
= "cirrus,cs35l34"},
1196 MODULE_DEVICE_TABLE(of
, cs35l34_of_match
);
1198 static const struct i2c_device_id cs35l34_id
[] = {
1202 MODULE_DEVICE_TABLE(i2c
, cs35l34_id
);
1204 static struct i2c_driver cs35l34_i2c_driver
= {
1207 .pm
= &cs35l34_pm_ops
,
1208 .of_match_table
= cs35l34_of_match
,
1211 .id_table
= cs35l34_id
,
1212 .probe
= cs35l34_i2c_probe
,
1213 .remove
= cs35l34_i2c_remove
,
1217 static int __init
cs35l34_modinit(void)
1221 ret
= i2c_add_driver(&cs35l34_i2c_driver
);
1223 pr_err("Failed to register CS35l34 I2C driver: %d\n", ret
);
1228 module_init(cs35l34_modinit
);
1230 static void __exit
cs35l34_exit(void)
1232 i2c_del_driver(&cs35l34_i2c_driver
);
1234 module_exit(cs35l34_exit
);
1236 MODULE_DESCRIPTION("ASoC CS35l34 driver");
1237 MODULE_AUTHOR("Paul Handrigan, Cirrus Logic Inc, <Paul.Handrigan@cirrus.com>");
1238 MODULE_LICENSE("GPL");