Lines Matching +full:adc +full:- +full:diff +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * da7218.c - DA7218 ALSA SoC Codec Driver
22 #include <sound/soc-dapm.h>
37 static const DECLARE_TLV_DB_SCALE(da7218_mic_gain_tlv, -600, 600, 0);
38 static const DECLARE_TLV_DB_SCALE(da7218_mixin_gain_tlv, -450, 150, 0);
39 static const DECLARE_TLV_DB_SCALE(da7218_in_dig_gain_tlv, -8325, 75, 0);
40 static const DECLARE_TLV_DB_SCALE(da7218_ags_trigger_tlv, -9000, 600, 0);
42 static const DECLARE_TLV_DB_SCALE(da7218_alc_threshold_tlv, -9450, 150, 0);
47 static const DECLARE_TLV_DB_SCALE(da7218_dmix_gain_tlv, -4200, 150, 0);
50 static const DECLARE_TLV_DB_SCALE(da7218_dgs_trigger_tlv, -9450, 150, 0);
51 static const DECLARE_TLV_DB_SCALE(da7218_dgs_anticlip_tlv, -4200, 600, 0);
52 static const DECLARE_TLV_DB_SCALE(da7218_dgs_signal_tlv, -9000, 600, 0);
53 static const DECLARE_TLV_DB_SCALE(da7218_out_eq_band_tlv, -1050, 150, 0);
54 static const DECLARE_TLV_DB_SCALE(da7218_out_dig_gain_tlv, -8325, 75, 0);
55 static const DECLARE_TLV_DB_SCALE(da7218_dac_ng_threshold_tlv, -10200, 600, 0);
56 static const DECLARE_TLV_DB_SCALE(da7218_mixout_gain_tlv, -100, 50, 0);
57 static const DECLARE_TLV_DB_SCALE(da7218_hp_gain_tlv, -5700, 150, 0);
201 "Sum", "SWG1", "SWG2", "SWG1_1-Cos"
360 * rates above 32KHz the ADC signals will be stopped and will cause in da7218_alc_calib()
385 dev_warn(component->dev, in da7218_alc_calib()
386 "ALC auto calibration failed - %s\n", in da7218_alc_calib()
438 if ((ret == 1) && (da7218->alc_en)) in da7218_mixin_gain_put()
448 (struct soc_mixer_control *) kcontrol->private_value; in da7218_alc_sw_put()
451 unsigned int lvalue = ucontrol->value.integer.value[0]; in da7218_alc_sw_put()
452 unsigned int rvalue = ucontrol->value.integer.value[1]; in da7218_alc_sw_put()
453 unsigned int lshift = mc->shift; in da7218_alc_sw_put()
454 unsigned int rshift = mc->rshift; in da7218_alc_sw_put()
455 unsigned int mask = (mc->max << lshift) | (mc->max << rshift); in da7218_alc_sw_put()
458 if ((lvalue || rvalue) && (!da7218->alc_en)) in da7218_alc_sw_put()
461 /* Update bits to detail which channels are enabled/disabled */ in da7218_alc_sw_put()
462 da7218->alc_en &= ~mask; in da7218_alc_sw_put()
463 da7218->alc_en |= (lvalue << lshift) | (rvalue << rshift); in da7218_alc_sw_put()
475 (struct soc_mixer_control *) kcontrol->private_value; in da7218_tonegen_freq_get()
476 unsigned int reg = mixer_ctrl->reg; in da7218_tonegen_freq_get()
481 * Frequency value spans two 8-bit registers, lower then upper byte. in da7218_tonegen_freq_get()
484 ret = regmap_raw_read(da7218->regmap, reg, &val, 2); in da7218_tonegen_freq_get()
488 ucontrol->value.integer.value[0] = le16_to_cpu(val); in da7218_tonegen_freq_get()
499 (struct soc_mixer_control *) kcontrol->private_value; in da7218_tonegen_freq_put()
500 unsigned int reg = mixer_ctrl->reg; in da7218_tonegen_freq_put()
504 * Frequency value spans two 8-bit registers, lower then upper byte. in da7218_tonegen_freq_put()
508 val = cpu_to_le16(ucontrol->value.integer.value[0]); in da7218_tonegen_freq_put()
510 return regmap_raw_write(da7218->regmap, reg, &val, 2); in da7218_tonegen_freq_put()
519 (struct soc_mixer_control *) kcontrol->private_value; in da7218_mic_lvl_det_sw_put()
520 unsigned int lvalue = ucontrol->value.integer.value[0]; in da7218_mic_lvl_det_sw_put()
521 unsigned int rvalue = ucontrol->value.integer.value[1]; in da7218_mic_lvl_det_sw_put()
522 unsigned int lshift = mixer_ctrl->shift; in da7218_mic_lvl_det_sw_put()
523 unsigned int rshift = mixer_ctrl->rshift; in da7218_mic_lvl_det_sw_put()
524 unsigned int mask = (mixer_ctrl->max << lshift) | in da7218_mic_lvl_det_sw_put()
525 (mixer_ctrl->max << rshift); in da7218_mic_lvl_det_sw_put()
526 da7218->mic_lvl_det_en &= ~mask; in da7218_mic_lvl_det_sw_put()
527 da7218->mic_lvl_det_en |= (lvalue << lshift) | (rvalue << rshift); in da7218_mic_lvl_det_sw_put()
536 return snd_soc_component_write(component, mixer_ctrl->reg, in da7218_mic_lvl_det_sw_put()
537 (da7218->in_filt_en & da7218->mic_lvl_det_en)); in da7218_mic_lvl_det_sw_put()
546 (struct soc_mixer_control *) kcontrol->private_value; in da7218_mic_lvl_det_sw_get()
547 unsigned int lshift = mixer_ctrl->shift; in da7218_mic_lvl_det_sw_get()
548 unsigned int rshift = mixer_ctrl->rshift; in da7218_mic_lvl_det_sw_get()
549 unsigned int lmask = (mixer_ctrl->max << lshift); in da7218_mic_lvl_det_sw_get()
550 unsigned int rmask = (mixer_ctrl->max << rshift); in da7218_mic_lvl_det_sw_get()
552 ucontrol->value.integer.value[0] = in da7218_mic_lvl_det_sw_get()
553 (da7218->mic_lvl_det_en & lmask) >> lshift; in da7218_mic_lvl_det_sw_get()
554 ucontrol->value.integer.value[1] = in da7218_mic_lvl_det_sw_get()
555 (da7218->mic_lvl_det_en & rmask) >> rshift; in da7218_mic_lvl_det_sw_get()
566 (struct soc_bytes_ext *) kcontrol->private_value; in da7218_biquad_coeff_get()
569 switch (bytes_ext->max) { in da7218_biquad_coeff_get()
571 memcpy(ucontrol->value.bytes.data, da7218->biq_5stage_coeff, in da7218_biquad_coeff_get()
572 bytes_ext->max); in da7218_biquad_coeff_get()
575 memcpy(ucontrol->value.bytes.data, da7218->stbiq_3stage_coeff, in da7218_biquad_coeff_get()
576 bytes_ext->max); in da7218_biquad_coeff_get()
579 return -EINVAL; in da7218_biquad_coeff_get()
591 (struct soc_bytes_ext *) kcontrol->private_value; in da7218_biquad_coeff_put()
600 switch (bytes_ext->max) { in da7218_biquad_coeff_put()
603 memcpy(da7218->biq_5stage_coeff, ucontrol->value.bytes.data, in da7218_biquad_coeff_put()
604 bytes_ext->max); in da7218_biquad_coeff_put()
608 memcpy(da7218->stbiq_3stage_coeff, ucontrol->value.bytes.data, in da7218_biquad_coeff_put()
609 bytes_ext->max); in da7218_biquad_coeff_put()
612 return -EINVAL; in da7218_biquad_coeff_put()
620 for (i = 0; i < bytes_ext->max; ++i) { in da7218_biquad_coeff_put()
621 cfg[DA7218_BIQ_CFG_DATA] = ucontrol->value.bytes.data[i]; in da7218_biquad_coeff_put()
623 regmap_raw_write(da7218->regmap, reg, cfg, DA7218_BIQ_CFG_SIZE); in da7218_biquad_coeff_put()
689 SOC_SINGLE("ADC LP Mode Switch", DA7218_ADC_MODE,
796 /* Input High-Pass Filters */
1113 /* Output High-Pass Filter */
1118 /* 5-Band Equaliser */
1348 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7218_in_filter_event()
1352 switch (w->reg) { in da7218_in_filter_event()
1366 return -EINVAL; in da7218_in_filter_event()
1371 da7218->in_filt_en |= mask; in da7218_in_filter_event()
1377 if (mask & da7218->mic_lvl_det_en) in da7218_in_filter_event()
1381 da7218->in_filt_en &= ~mask; in da7218_in_filter_event()
1384 return -EINVAL; in da7218_in_filter_event()
1389 (da7218->in_filt_en & da7218->mic_lvl_det_en)); in da7218_in_filter_event()
1397 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7218_dai_event()
1405 if (da7218->master) in da7218_dai_event()
1433 dev_warn(component->dev, in da7218_dai_event()
1459 dev_warn(component->dev, "SRM failed to lock\n"); in da7218_dai_event()
1463 /* PC free-running */ in da7218_dai_event()
1466 if (da7218->master) in da7218_dai_event()
1473 return -EINVAL; in da7218_dai_event()
1480 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7218_cp_event()
1487 if (da7218->hp_single_supply) in da7218_cp_event()
1500 return -EINVAL; in da7218_cp_event()
1507 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7218_hp_pga_event()
1512 snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, in da7218_hp_pga_event()
1517 snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, 0); in da7218_hp_pga_event()
1520 return -EINVAL; in da7218_hp_pga_event()
1812 struct snd_soc_component *component = codec_dai->component; in da7218_set_dai_sysclk()
1816 if (da7218->mclk_rate == freq) in da7218_set_dai_sysclk()
1820 dev_err(codec_dai->dev, "Unsupported MCLK value %d\n", in da7218_set_dai_sysclk()
1822 return -EINVAL; in da7218_set_dai_sysclk()
1836 dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id); in da7218_set_dai_sysclk()
1837 return -EINVAL; in da7218_set_dai_sysclk()
1840 if (da7218->mclk) { in da7218_set_dai_sysclk()
1841 freq = clk_round_rate(da7218->mclk, freq); in da7218_set_dai_sysclk()
1842 ret = clk_set_rate(da7218->mclk, freq); in da7218_set_dai_sysclk()
1844 dev_err(codec_dai->dev, "Failed to set clock rate %d\n", in da7218_set_dai_sysclk()
1850 da7218->mclk_rate = freq; in da7218_set_dai_sysclk()
1858 struct snd_soc_component *component = codec_dai->component; in da7218_set_dai_pll()
1866 /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ in da7218_set_dai_pll()
1867 if (da7218->mclk_rate < 2000000) { in da7218_set_dai_pll()
1868 dev_err(component->dev, "PLL input clock %d below valid range\n", in da7218_set_dai_pll()
1869 da7218->mclk_rate); in da7218_set_dai_pll()
1870 return -EINVAL; in da7218_set_dai_pll()
1871 } else if (da7218->mclk_rate <= 4500000) { in da7218_set_dai_pll()
1874 } else if (da7218->mclk_rate <= 9000000) { in da7218_set_dai_pll()
1877 } else if (da7218->mclk_rate <= 18000000) { in da7218_set_dai_pll()
1880 } else if (da7218->mclk_rate <= 36000000) { in da7218_set_dai_pll()
1883 } else if (da7218->mclk_rate <= 54000000) { in da7218_set_dai_pll()
1887 dev_err(component->dev, "PLL input clock %d above valid range\n", in da7218_set_dai_pll()
1888 da7218->mclk_rate); in da7218_set_dai_pll()
1889 return -EINVAL; in da7218_set_dai_pll()
1891 freq_ref = (da7218->mclk_rate / indiv); in da7218_set_dai_pll()
1909 dev_err(component->dev, "Invalid PLL config\n"); in da7218_set_dai_pll()
1910 return -EINVAL; in da7218_set_dai_pll()
1933 struct snd_soc_component *component = codec_dai->component; in da7218_set_dai_fmt()
1939 da7218->master = true; in da7218_set_dai_fmt()
1942 da7218->master = false; in da7218_set_dai_fmt()
1945 return -EINVAL; in da7218_set_dai_fmt()
1966 return -EINVAL; in da7218_set_dai_fmt()
1984 return -EINVAL; in da7218_set_dai_fmt()
1988 return -EINVAL; in da7218_set_dai_fmt()
2005 return -EINVAL; in da7218_set_dai_fmt()
2022 struct snd_soc_component *component = dai->component; in da7218_set_dai_tdm_slot()
2026 /* No channels enabled so disable TDM, revert to 64-bit frames */ in da7218_set_dai_tdm_slot()
2039 dev_err(component->dev, "Invalid number of slots, max = %d\n", in da7218_set_dai_tdm_slot()
2041 return -EINVAL; in da7218_set_dai_tdm_slot()
2046 dev_err(component->dev, "Invalid slot offset, max = %d\n", in da7218_set_dai_tdm_slot()
2048 return -EINVAL; in da7218_set_dai_tdm_slot()
2067 dev_err(component->dev, "Invalid frame size\n"); in da7218_set_dai_tdm_slot()
2068 return -EINVAL; in da7218_set_dai_tdm_slot()
2091 struct snd_soc_component *component = dai->component; in da7218_hw_params()
2093 unsigned int channels; in da7218_hw_params() local
2109 return -EINVAL; in da7218_hw_params()
2112 channels = params_channels(params); in da7218_hw_params()
2113 if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) { in da7218_hw_params()
2114 dev_err(component->dev, in da7218_hw_params()
2115 "Invalid number of channels, only 1 to %d supported\n", in da7218_hw_params()
2117 return -EINVAL; in da7218_hw_params()
2119 dai_ctrl |= channels << DA7218_DAI_CH_NUM_SHIFT; in da7218_hw_params()
2156 return -EINVAL; in da7218_hw_params()
2181 .name = "da7218-hifi",
2185 .channels_max = 4, /* Only 2 channels of data */
2211 if (da7218->dev_id == DA7217_DEV_ID) in da7218_hpldet()
2212 return -EINVAL; in da7218_hpldet()
2214 da7218->jack = jack; in da7218_hpldet()
2230 kobject_uevent_env(&component->dev->kobj, KOBJ_CHANGE, envp); in da7218_micldet_irq()
2246 snd_soc_jack_report(da7218->jack, report, SND_JACK_HEADPHONE); in da7218_hpldet_irq()
2293 return (uintptr_t)id->data; in da7218_of_get_id()
2295 return -EINVAL; in da7218_of_get_id()
2321 dev_warn(component->dev, "Invalid micbias level"); in da7218_of_micbias_lvl()
2329 if (!strcmp(str, "diff")) { in da7218_of_mic_amp_in_sel()
2336 dev_warn(component->dev, "Invalid mic input type selection"); in da7218_of_mic_amp_in_sel()
2349 dev_warn(component->dev, "Invalid DMIC data type selection"); in da7218_of_dmic_data_sel()
2362 dev_warn(component->dev, "Invalid DMIC sample phase"); in da7218_of_dmic_samplephase()
2376 dev_warn(component->dev, "Invalid DMIC clock rate"); in da7218_of_dmic_clkrate()
2402 dev_warn(component->dev, "Invalid jack detect rate"); in da7218_of_jack_rate()
2420 dev_warn(component->dev, "Invalid jack debounce"); in da7218_of_jack_debounce()
2438 dev_warn(component->dev, "Invalid jack threshold level"); in da7218_of_jack_thr()
2446 struct device_node *np = component->dev->of_node; in da7218_of_to_pdata()
2453 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); in da7218_of_to_pdata()
2457 if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0) in da7218_of_to_pdata()
2458 pdata->micbias1_lvl = da7218_of_micbias_lvl(component, of_val32); in da7218_of_to_pdata()
2460 pdata->micbias1_lvl = DA7218_MICBIAS_1_6V; in da7218_of_to_pdata()
2462 if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0) in da7218_of_to_pdata()
2463 pdata->micbias2_lvl = da7218_of_micbias_lvl(component, of_val32); in da7218_of_to_pdata()
2465 pdata->micbias2_lvl = DA7218_MICBIAS_1_6V; in da7218_of_to_pdata()
2467 if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str)) in da7218_of_to_pdata()
2468 pdata->mic1_amp_in_sel = in da7218_of_to_pdata()
2471 pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; in da7218_of_to_pdata()
2473 if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str)) in da7218_of_to_pdata()
2474 pdata->mic2_amp_in_sel = in da7218_of_to_pdata()
2477 pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; in da7218_of_to_pdata()
2479 if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str)) in da7218_of_to_pdata()
2480 pdata->dmic1_data_sel = da7218_of_dmic_data_sel(component, of_str); in da7218_of_to_pdata()
2482 pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; in da7218_of_to_pdata()
2484 if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str)) in da7218_of_to_pdata()
2485 pdata->dmic1_samplephase = in da7218_of_to_pdata()
2488 pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; in da7218_of_to_pdata()
2490 if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0) in da7218_of_to_pdata()
2491 pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(component, of_val32); in da7218_of_to_pdata()
2493 pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ; in da7218_of_to_pdata()
2495 if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str)) in da7218_of_to_pdata()
2496 pdata->dmic2_data_sel = da7218_of_dmic_data_sel(component, of_str); in da7218_of_to_pdata()
2498 pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; in da7218_of_to_pdata()
2500 if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str)) in da7218_of_to_pdata()
2501 pdata->dmic2_samplephase = in da7218_of_to_pdata()
2504 pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; in da7218_of_to_pdata()
2506 if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0) in da7218_of_to_pdata()
2507 pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(component, of_val32); in da7218_of_to_pdata()
2509 pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ; in da7218_of_to_pdata()
2511 if (da7218->dev_id == DA7217_DEV_ID) { in da7218_of_to_pdata()
2512 if (of_property_read_bool(np, "dlg,hp-diff-single-supply")) in da7218_of_to_pdata()
2513 pdata->hp_diff_single_supply = true; in da7218_of_to_pdata()
2516 if (da7218->dev_id == DA7218_DEV_ID) { in da7218_of_to_pdata()
2521 hpldet_pdata = devm_kzalloc(component->dev, sizeof(*hpldet_pdata), in da7218_of_to_pdata()
2527 pdata->hpldet_pdata = hpldet_pdata; in da7218_of_to_pdata()
2529 if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us", in da7218_of_to_pdata()
2531 hpldet_pdata->jack_rate = in da7218_of_to_pdata()
2534 hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US; in da7218_of_to_pdata()
2536 if (of_property_read_u32(hpldet_np, "dlg,jack-debounce", in da7218_of_to_pdata()
2538 hpldet_pdata->jack_debounce = in da7218_of_to_pdata()
2541 hpldet_pdata->jack_debounce = in da7218_of_to_pdata()
2544 if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct", in da7218_of_to_pdata()
2546 hpldet_pdata->jack_thr = in da7218_of_to_pdata()
2549 hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT; in da7218_of_to_pdata()
2551 if (of_property_read_bool(hpldet_np, "dlg,comp-inv")) in da7218_of_to_pdata()
2552 hpldet_pdata->comp_inv = true; in da7218_of_to_pdata()
2555 hpldet_pdata->hyst = true; in da7218_of_to_pdata()
2558 hpldet_pdata->discharge = true; in da7218_of_to_pdata()
2583 if (da7218->mclk) { in da7218_set_bias_level()
2584 ret = clk_prepare_enable(da7218->mclk); in da7218_set_bias_level()
2586 dev_err(component->dev, "Failed to enable mclk\n"); in da7218_set_bias_level()
2606 if (da7218->mclk) in da7218_set_bias_level()
2607 clk_disable_unprepare(da7218->mclk); in da7218_set_bias_level()
2612 if (!da7218->jack) { in da7218_set_bias_level()
2642 da7218->supplies[i].supply = da7218_supply_names[i]; in da7218_handle_supplies()
2644 ret = devm_regulator_bulk_get(component->dev, DA7218_NUM_SUPPLIES, in da7218_handle_supplies()
2645 da7218->supplies); in da7218_handle_supplies()
2647 dev_err(component->dev, "Failed to get supplies\n"); in da7218_handle_supplies()
2652 vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer; in da7218_handle_supplies()
2655 dev_warn(component->dev, "Invalid VDDIO voltage\n"); in da7218_handle_supplies()
2660 ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies); in da7218_handle_supplies()
2662 dev_err(component->dev, "Failed to enable supplies\n"); in da7218_handle_supplies()
2678 struct da7218_pdata *pdata = da7218->pdata; in da7218_handle_pdata()
2684 switch (pdata->micbias1_lvl) { in da7218_handle_pdata()
2696 micbias_lvl |= (pdata->micbias1_lvl << in da7218_handle_pdata()
2701 switch (pdata->micbias2_lvl) { in da7218_handle_pdata()
2713 micbias_lvl |= (pdata->micbias2_lvl << in da7218_handle_pdata()
2721 switch (pdata->mic1_amp_in_sel) { in da7218_handle_pdata()
2726 pdata->mic1_amp_in_sel); in da7218_handle_pdata()
2730 switch (pdata->mic2_amp_in_sel) { in da7218_handle_pdata()
2735 pdata->mic2_amp_in_sel); in da7218_handle_pdata()
2740 switch (pdata->dmic1_data_sel) { in da7218_handle_pdata()
2743 dmic_cfg |= (pdata->dmic1_data_sel << in da7218_handle_pdata()
2748 switch (pdata->dmic1_samplephase) { in da7218_handle_pdata()
2751 dmic_cfg |= (pdata->dmic1_samplephase << in da7218_handle_pdata()
2756 switch (pdata->dmic1_clk_rate) { in da7218_handle_pdata()
2759 dmic_cfg |= (pdata->dmic1_clk_rate << in da7218_handle_pdata()
2770 switch (pdata->dmic2_data_sel) { in da7218_handle_pdata()
2773 dmic_cfg |= (pdata->dmic2_data_sel << in da7218_handle_pdata()
2778 switch (pdata->dmic2_samplephase) { in da7218_handle_pdata()
2781 dmic_cfg |= (pdata->dmic2_samplephase << in da7218_handle_pdata()
2786 switch (pdata->dmic2_clk_rate) { in da7218_handle_pdata()
2789 dmic_cfg |= (pdata->dmic2_clk_rate << in da7218_handle_pdata()
2800 if (da7218->dev_id == DA7217_DEV_ID) { in da7218_handle_pdata()
2801 da7218->hp_single_supply = in da7218_handle_pdata()
2802 pdata->hp_diff_single_supply; in da7218_handle_pdata()
2804 if (da7218->hp_single_supply) { in da7218_handle_pdata()
2814 if ((da7218->dev_id == DA7218_DEV_ID) && in da7218_handle_pdata()
2815 (pdata->hpldet_pdata)) { in da7218_handle_pdata()
2817 pdata->hpldet_pdata; in da7218_handle_pdata()
2820 switch (hpldet_pdata->jack_rate) { in da7218_handle_pdata()
2830 (hpldet_pdata->jack_rate << in da7218_handle_pdata()
2835 switch (hpldet_pdata->jack_debounce) { in da7218_handle_pdata()
2841 (hpldet_pdata->jack_debounce << in da7218_handle_pdata()
2846 switch (hpldet_pdata->jack_thr) { in da7218_handle_pdata()
2852 (hpldet_pdata->jack_thr << in da7218_handle_pdata()
2863 if (hpldet_pdata->comp_inv) in da7218_handle_pdata()
2866 if (hpldet_pdata->hyst) in da7218_handle_pdata()
2869 if (hpldet_pdata->discharge) in da7218_handle_pdata()
2888 if (component->dev->of_node) in da7218_probe()
2889 da7218->pdata = da7218_of_to_pdata(component); in da7218_probe()
2891 da7218->pdata = dev_get_platdata(component->dev); in da7218_probe()
2896 da7218->mclk = devm_clk_get(component->dev, "mclk"); in da7218_probe()
2897 if (IS_ERR(da7218->mclk)) { in da7218_probe()
2898 if (PTR_ERR(da7218->mclk) != -ENOENT) { in da7218_probe()
2899 ret = PTR_ERR(da7218->mclk); in da7218_probe()
2902 da7218->mclk = NULL; in da7218_probe()
2906 /* Default PC to free-running */ in da7218_probe()
2958 if (da7218->dev_id == DA7217_DEV_ID) { in da7218_probe()
2968 if (da7218->irq) { in da7218_probe()
2969 ret = devm_request_threaded_irq(component->dev, da7218->irq, NULL, in da7218_probe()
2974 dev_err(component->dev, "Failed to request IRQ %d: %d\n", in da7218_probe()
2975 da7218->irq, ret); in da7218_probe()
2984 regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); in da7218_probe()
2993 regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); in da7218_remove()
3004 if (!da7218->jack) in da7218_suspend()
3015 if (!da7218->jack) in da7218_resume()
3267 da7218 = devm_kzalloc(&i2c->dev, sizeof(*da7218), GFP_KERNEL); in da7218_i2c_probe()
3269 return -ENOMEM; in da7218_i2c_probe()
3273 if (i2c->dev.of_node) in da7218_i2c_probe()
3274 da7218->dev_id = da7218_of_get_id(&i2c->dev); in da7218_i2c_probe()
3276 da7218->dev_id = id->driver_data; in da7218_i2c_probe()
3278 if ((da7218->dev_id != DA7217_DEV_ID) && in da7218_i2c_probe()
3279 (da7218->dev_id != DA7218_DEV_ID)) { in da7218_i2c_probe()
3280 dev_err(&i2c->dev, "Invalid device Id\n"); in da7218_i2c_probe()
3281 return -EINVAL; in da7218_i2c_probe()
3284 da7218->irq = i2c->irq; in da7218_i2c_probe()
3286 da7218->regmap = devm_regmap_init_i2c(i2c, &da7218_regmap_config); in da7218_i2c_probe()
3287 if (IS_ERR(da7218->regmap)) { in da7218_i2c_probe()
3288 ret = PTR_ERR(da7218->regmap); in da7218_i2c_probe()
3289 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in da7218_i2c_probe()
3293 ret = devm_snd_soc_register_component(&i2c->dev, in da7218_i2c_probe()
3296 dev_err(&i2c->dev, "Failed to register da7218 component: %d\n", in da7218_i2c_probe()