da7219-aad.c (9c3a985f88fa4de82bf4bda906095ce6444e9039) da7219-aad.c (dc0ff0fa3a9bf9f7be3a9530f8f6079324f54fa5)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * da7219-aad.c - Dialog DA7219 ALSA SoC AAD Driver
4 *
5 * Copyright (c) 2015 Dialog Semiconductor Ltd.
6 *
7 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
8 */

--- 557 unchanged lines hidden (view full) ---

566 case 1000:
567 return DA7219_AAD_JACK_INS_DEB_1S;
568 default:
569 dev_warn(dev, "Invalid jack insert debounce");
570 return DA7219_AAD_JACK_INS_DEB_20MS;
571 }
572}
573
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * da7219-aad.c - Dialog DA7219 ALSA SoC AAD Driver
4 *
5 * Copyright (c) 2015 Dialog Semiconductor Ltd.
6 *
7 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
8 */

--- 557 unchanged lines hidden (view full) ---

566 case 1000:
567 return DA7219_AAD_JACK_INS_DEB_1S;
568 default:
569 dev_warn(dev, "Invalid jack insert debounce");
570 return DA7219_AAD_JACK_INS_DEB_20MS;
571 }
572}
573
574static enum da7219_aad_jack_ins_det_pty
575 da7219_aad_fw_jack_ins_det_pty(struct device *dev, const char *str)
576{
577 if (!strcmp(str, "low")) {
578 return DA7219_AAD_JACK_INS_DET_PTY_LOW;
579 } else if (!strcmp(str, "high")) {
580 return DA7219_AAD_JACK_INS_DET_PTY_HIGH;
581 } else {
582 dev_warn(dev, "Invalid jack insertion detection polarity");
583 return DA7219_AAD_JACK_INS_DET_PTY_LOW;
584 }
585}
586
574static enum da7219_aad_jack_det_rate
575 da7219_aad_fw_jack_det_rate(struct device *dev, const char *str)
576{
587static enum da7219_aad_jack_det_rate
588 da7219_aad_fw_jack_det_rate(struct device *dev, const char *str)
589{
577 if (!strcmp(str, "32ms_64ms")) {
590 if (!strcmp(str, "32_64")) {
578 return DA7219_AAD_JACK_DET_RATE_32_64MS;
591 return DA7219_AAD_JACK_DET_RATE_32_64MS;
579 } else if (!strcmp(str, "64ms_128ms")) {
592 } else if (!strcmp(str, "64_128")) {
580 return DA7219_AAD_JACK_DET_RATE_64_128MS;
593 return DA7219_AAD_JACK_DET_RATE_64_128MS;
581 } else if (!strcmp(str, "128ms_256ms")) {
594 } else if (!strcmp(str, "128_256")) {
582 return DA7219_AAD_JACK_DET_RATE_128_256MS;
595 return DA7219_AAD_JACK_DET_RATE_128_256MS;
583 } else if (!strcmp(str, "256ms_512ms")) {
596 } else if (!strcmp(str, "256_512")) {
584 return DA7219_AAD_JACK_DET_RATE_256_512MS;
585 } else {
586 dev_warn(dev, "Invalid jack detect rate");
587 return DA7219_AAD_JACK_DET_RATE_256_512MS;
588 }
589}
590
591static enum da7219_aad_jack_rem_deb

--- 91 unchanged lines hidden (view full) ---

683 aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS;
684
685 if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0)
686 aad_pdata->jack_ins_deb =
687 da7219_aad_fw_jack_ins_deb(dev, fw_val32);
688 else
689 aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
690
597 return DA7219_AAD_JACK_DET_RATE_256_512MS;
598 } else {
599 dev_warn(dev, "Invalid jack detect rate");
600 return DA7219_AAD_JACK_DET_RATE_256_512MS;
601 }
602}
603
604static enum da7219_aad_jack_rem_deb

--- 91 unchanged lines hidden (view full) ---

696 aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS;
697
698 if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0)
699 aad_pdata->jack_ins_deb =
700 da7219_aad_fw_jack_ins_deb(dev, fw_val32);
701 else
702 aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
703
704 if (!fwnode_property_read_string(aad_np, "dlg,jack-ins-det-pty", &fw_str))
705 aad_pdata->jack_ins_det_pty =
706 da7219_aad_fw_jack_ins_det_pty(dev, fw_str);
707 else
708 aad_pdata->jack_ins_det_pty = DA7219_AAD_JACK_INS_DET_PTY_LOW;
709
691 if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
692 aad_pdata->jack_det_rate =
693 da7219_aad_fw_jack_det_rate(dev, fw_str);
694 else
695 aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS;
696
697 if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0)
698 aad_pdata->jack_rem_deb =

--- 145 unchanged lines hidden (view full) ---

844 case DA7219_AAD_ADC_1BIT_RPT_2:
845 case DA7219_AAD_ADC_1BIT_RPT_4:
846 case DA7219_AAD_ADC_1BIT_RPT_8:
847 cfg |= (aad_pdata->adc_1bit_rpt <<
848 DA7219_ADC_1_BIT_REPEAT_SHIFT);
849 mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
850 }
851 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
710 if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
711 aad_pdata->jack_det_rate =
712 da7219_aad_fw_jack_det_rate(dev, fw_str);
713 else
714 aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS;
715
716 if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0)
717 aad_pdata->jack_rem_deb =

--- 145 unchanged lines hidden (view full) ---

863 case DA7219_AAD_ADC_1BIT_RPT_2:
864 case DA7219_AAD_ADC_1BIT_RPT_4:
865 case DA7219_AAD_ADC_1BIT_RPT_8:
866 cfg |= (aad_pdata->adc_1bit_rpt <<
867 DA7219_ADC_1_BIT_REPEAT_SHIFT);
868 mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
869 }
870 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
871
872 switch (aad_pdata->jack_ins_det_pty) {
873 case DA7219_AAD_JACK_INS_DET_PTY_LOW:
874 snd_soc_component_write(component, 0xF0, 0x8B);
875 snd_soc_component_write(component, 0x75, 0x80);
876 snd_soc_component_write(component, 0xF0, 0x00);
877 break;
878 case DA7219_AAD_JACK_INS_DET_PTY_HIGH:
879 snd_soc_component_write(component, 0xF0, 0x8B);
880 snd_soc_component_write(component, 0x75, 0x00);
881 snd_soc_component_write(component, 0xF0, 0x00);
882 break;
883 default:
884 break;
885 }
852 }
853}
854
855static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *component)
856{
857 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
858 struct da7219_aad_priv *da7219_aad = da7219->aad;
859 u8 jack_det;

--- 173 unchanged lines hidden ---
886 }
887}
888
889static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *component)
890{
891 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
892 struct da7219_aad_priv *da7219_aad = da7219->aad;
893 u8 jack_det;

--- 173 unchanged lines hidden ---