Lines Matching refs:nau8821

45 static int nau8821_configure_sysclk(struct nau8821 *nau8821,
471 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in dmic_clock_control() local
479 regmap_read(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, in dmic_clock_control()
483 clk_adc = (nau8821->fs * 256) >> clk_adc_src; in dmic_clock_control()
487 nau8821->dmic_clk_threshold) { in dmic_clock_control()
494 dev_dbg(nau8821->dev, in dmic_clock_control()
496 clk_adc, nau8821->dmic_clk_threshold, in dmic_clock_control()
498 regmap_update_bits(nau8821->regmap, NAU8821_R13_DMIC_CTRL, in dmic_clock_control()
510 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_left_adc_event() local
515 regmap_update_bits(nau8821->regmap, NAU8821_R01_ENA_CTRL, in nau8821_left_adc_event()
519 regmap_update_bits(nau8821->regmap, in nau8821_left_adc_event()
534 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_right_adc_event() local
539 regmap_update_bits(nau8821->regmap, NAU8821_R01_ENA_CTRL, in nau8821_right_adc_event()
543 regmap_update_bits(nau8821->regmap, in nau8821_right_adc_event()
558 struct nau8821 *nau8821 = in nau8821_pump_event() local
565 regmap_update_bits(nau8821->regmap, NAU8821_R80_CHARGE_PUMP, in nau8821_pump_event()
569 regmap_update_bits(nau8821->regmap, NAU8821_R80_CHARGE_PUMP, in nau8821_pump_event()
584 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_output_dac_event() local
589 regmap_update_bits(nau8821->regmap, NAU8821_R66_BIAS_ADJ, in nau8821_output_dac_event()
593 regmap_update_bits(nau8821->regmap, NAU8821_R66_BIAS_ADJ, in nau8821_output_dac_event()
608 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in system_clock_control() local
611 dev_dbg(nau8821->dev, "system clock control : POWER OFF\n"); in system_clock_control()
617 if (nau8821_is_jack_inserted(nau8821->regmap)) { in system_clock_control()
618 nau8821_configure_sysclk(nau8821, in system_clock_control()
621 nau8821_configure_sysclk(nau8821, NAU8821_CLK_DIS, 0); in system_clock_control()
631 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_left_fepga_event() local
633 if (!nau8821->left_input_single_end) in nau8821_left_fepga_event()
638 regmap_update_bits(nau8821->regmap, NAU8821_R77_FEPGA, in nau8821_left_fepga_event()
641 regmap_update_bits(nau8821->regmap, NAU8821_R76_BOOST, in nau8821_left_fepga_event()
645 regmap_update_bits(nau8821->regmap, NAU8821_R77_FEPGA, in nau8821_left_fepga_event()
647 regmap_update_bits(nau8821->regmap, NAU8821_R76_BOOST, in nau8821_left_fepga_event()
810 nau8821_get_osr(struct nau8821 *nau8821, int stream) in nau8821_get_osr() argument
815 regmap_read(nau8821->regmap, NAU8821_R2C_DAC_CTRL1, &osr); in nau8821_get_osr()
821 regmap_read(nau8821->regmap, NAU8821_R2B_ADC_RATE, &osr); in nau8821_get_osr()
833 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_dai_startup() local
836 osr = nau8821_get_osr(nau8821, substream->stream); in nau8821_dai_startup()
849 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_hw_params() local
853 nau8821->fs = params_rate(params); in nau8821_hw_params()
860 osr = nau8821_get_osr(nau8821, substream->stream); in nau8821_hw_params()
863 if (nau8821->fs * osr->osr > CLK_DA_AD_MAX) in nau8821_hw_params()
866 regmap_update_bits(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, in nau8821_hw_params()
870 regmap_update_bits(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, in nau8821_hw_params()
875 regmap_read(nau8821->regmap, NAU8821_R1D_I2S_PCM_CTRL2, &ctrl_val); in nau8821_hw_params()
878 bclk_fs = snd_soc_params_to_bclk(params) / nau8821->fs; in nau8821_hw_params()
888 regmap_update_bits(nau8821->regmap, NAU8821_R1D_I2S_PCM_CTRL2, in nau8821_hw_params()
910 regmap_update_bits(nau8821->regmap, NAU8821_R1C_I2S_PCM_CTRL1, in nau8821_hw_params()
919 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_set_dai_fmt() local
963 regmap_update_bits(nau8821->regmap, NAU8821_R1C_I2S_PCM_CTRL1, in nau8821_set_dai_fmt()
966 regmap_update_bits(nau8821->regmap, NAU8821_R1D_I2S_PCM_CTRL2, in nau8821_set_dai_fmt()
976 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_digital_mute() local
982 return regmap_update_bits(nau8821->regmap, in nau8821_digital_mute()
1049 static void nau8821_eject_jack(struct nau8821 *nau8821) in nau8821_eject_jack() argument
1051 struct snd_soc_dapm_context *dapm = nau8821->dapm; in nau8821_eject_jack()
1052 struct regmap *regmap = nau8821->regmap; in nau8821_eject_jack()
1083 nau8821_configure_sysclk(nau8821, NAU8821_CLK_DIS, 0); in nau8821_eject_jack()
1088 if (nau8821->key_enable) { in nau8821_eject_jack()
1106 struct nau8821 *nau8821 = in nau8821_jdet_work() local
1107 container_of(work, struct nau8821, jdet_work); in nau8821_jdet_work()
1108 struct snd_soc_dapm_context *dapm = nau8821->dapm; in nau8821_jdet_work()
1110 struct regmap *regmap = nau8821->regmap; in nau8821_jdet_work()
1120 dev_dbg(nau8821->dev, "Headset connected\n"); in nau8821_jdet_work()
1131 if (nau8821->key_enable) { in nau8821_jdet_work()
1141 dev_dbg(nau8821->dev, "Headphone connected\n"); in nau8821_jdet_work()
1147 snd_soc_jack_report(nau8821->jack, event, event_mask); in nau8821_jdet_work()
1151 static void nau8821_setup_inserted_irq(struct nau8821 *nau8821) in nau8821_setup_inserted_irq() argument
1153 struct regmap *regmap = nau8821->regmap; in nau8821_setup_inserted_irq()
1156 if (nau8821->dapm->bias_level < SND_SOC_BIAS_PREPARE) in nau8821_setup_inserted_irq()
1157 nau8821_configure_sysclk(nau8821, NAU8821_CLK_INTERNAL, 0); in nau8821_setup_inserted_irq()
1181 struct nau8821 *nau8821 = (struct nau8821 *)data; in nau8821_interrupt() local
1182 struct regmap *regmap = nau8821->regmap; in nau8821_interrupt()
1186 dev_err(nau8821->dev, "failed to read irq status\n"); in nau8821_interrupt()
1190 dev_dbg(nau8821->dev, "IRQ %d\n", active_irq); in nau8821_interrupt()
1196 nau8821_eject_jack(nau8821); in nau8821_interrupt()
1212 cancel_work_sync(&nau8821->jdet_work); in nau8821_interrupt()
1213 schedule_work(&nau8821->jdet_work); in nau8821_interrupt()
1223 nau8821_setup_inserted_irq(nau8821); in nau8821_interrupt()
1225 dev_warn(nau8821->dev, in nau8821_interrupt()
1227 nau8821_eject_jack(nau8821); in nau8821_interrupt()
1237 snd_soc_jack_report(nau8821->jack, event, event_mask); in nau8821_interrupt()
1258 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_component_probe() local
1262 nau8821->dapm = dapm; in nau8821_component_probe()
1334 static void nau8821_fll_apply(struct nau8821 *nau8821, in nau8821_fll_apply() argument
1337 struct regmap *regmap = nau8821->regmap; in nau8821_fll_apply()
1400 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_set_fll() local
1407 dev_err(nau8821->dev, in nau8821_set_fll()
1412 dev_dbg(nau8821->dev, in nau8821_set_fll()
1417 nau8821_fll_apply(nau8821, fll_param); in nau8821_set_fll()
1419 regmap_update_bits(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, in nau8821_set_fll()
1436 static int nau8821_configure_sysclk(struct nau8821 *nau8821, in nau8821_configure_sysclk() argument
1439 struct regmap *regmap = nau8821->regmap; in nau8821_configure_sysclk()
1504 dev_err(nau8821->dev, "Invalid clock id (%d)\n", clk_id); in nau8821_configure_sysclk()
1507 nau8821->clk_id = clk_id; in nau8821_configure_sysclk()
1508 dev_dbg(nau8821->dev, "Sysclk is %dHz and clock id is %d\n", freq, in nau8821_configure_sysclk()
1509 nau8821->clk_id); in nau8821_configure_sysclk()
1517 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_set_sysclk() local
1519 return nau8821_configure_sysclk(nau8821, clk_id, freq); in nau8821_set_sysclk()
1522 static int nau8821_resume_setup(struct nau8821 *nau8821) in nau8821_resume_setup() argument
1524 struct regmap *regmap = nau8821->regmap; in nau8821_resume_setup()
1527 nau8821_configure_sysclk(nau8821, NAU8821_CLK_DIS, 0); in nau8821_resume_setup()
1528 if (nau8821->irq) { in nau8821_resume_setup()
1550 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_set_bias_level() local
1551 struct regmap *regmap = nau8821->regmap; in nau8821_set_bias_level()
1564 nau8821_resume_setup(nau8821); in nau8821_set_bias_level()
1571 if (nau8821->irq) { in nau8821_set_bias_level()
1597 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_suspend() local
1599 if (nau8821->irq) in nau8821_suspend()
1600 disable_irq(nau8821->irq); in nau8821_suspend()
1604 snd_soc_dapm_sync(nau8821->dapm); in nau8821_suspend()
1605 regcache_cache_only(nau8821->regmap, true); in nau8821_suspend()
1606 regcache_mark_dirty(nau8821->regmap); in nau8821_suspend()
1613 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_resume() local
1615 regcache_cache_only(nau8821->regmap, false); in nau8821_resume()
1616 regcache_sync(nau8821->regmap); in nau8821_resume()
1617 if (nau8821->irq) in nau8821_resume()
1618 enable_irq(nau8821->irq); in nau8821_resume()
1655 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); in nau8821_enable_jack_detect() local
1658 nau8821->jack = jack; in nau8821_enable_jack_detect()
1660 INIT_WORK(&nau8821->jdet_work, nau8821_jdet_work); in nau8821_enable_jack_detect()
1661 ret = devm_request_threaded_irq(nau8821->dev, nau8821->irq, NULL, in nau8821_enable_jack_detect()
1663 "nau8821", nau8821); in nau8821_enable_jack_detect()
1665 dev_err(nau8821->dev, "Cannot request irq %d (%d)\n", in nau8821_enable_jack_detect()
1666 nau8821->irq, ret); in nau8821_enable_jack_detect()
1680 static void nau8821_print_device_properties(struct nau8821 *nau8821) in nau8821_print_device_properties() argument
1682 struct device *dev = nau8821->dev; in nau8821_print_device_properties()
1684 dev_dbg(dev, "jkdet-enable: %d\n", nau8821->jkdet_enable); in nau8821_print_device_properties()
1685 dev_dbg(dev, "jkdet-pull-enable: %d\n", nau8821->jkdet_pull_enable); in nau8821_print_device_properties()
1686 dev_dbg(dev, "jkdet-pull-up: %d\n", nau8821->jkdet_pull_up); in nau8821_print_device_properties()
1687 dev_dbg(dev, "jkdet-polarity: %d\n", nau8821->jkdet_polarity); in nau8821_print_device_properties()
1688 dev_dbg(dev, "micbias-voltage: %d\n", nau8821->micbias_voltage); in nau8821_print_device_properties()
1689 dev_dbg(dev, "vref-impedance: %d\n", nau8821->vref_impedance); in nau8821_print_device_properties()
1691 nau8821->jack_insert_debounce); in nau8821_print_device_properties()
1693 nau8821->jack_eject_debounce); in nau8821_print_device_properties()
1695 nau8821->dmic_clk_threshold); in nau8821_print_device_properties()
1696 dev_dbg(dev, "key_enable: %d\n", nau8821->key_enable); in nau8821_print_device_properties()
1700 struct nau8821 *nau8821) in nau8821_read_device_properties() argument
1704 nau8821->jkdet_enable = device_property_read_bool(dev, in nau8821_read_device_properties()
1706 nau8821->jkdet_pull_enable = device_property_read_bool(dev, in nau8821_read_device_properties()
1708 nau8821->jkdet_pull_up = device_property_read_bool(dev, in nau8821_read_device_properties()
1710 nau8821->key_enable = device_property_read_bool(dev, in nau8821_read_device_properties()
1712 nau8821->left_input_single_end = device_property_read_bool(dev, in nau8821_read_device_properties()
1715 &nau8821->jkdet_polarity); in nau8821_read_device_properties()
1717 nau8821->jkdet_polarity = 1; in nau8821_read_device_properties()
1719 &nau8821->micbias_voltage); in nau8821_read_device_properties()
1721 nau8821->micbias_voltage = 6; in nau8821_read_device_properties()
1723 &nau8821->vref_impedance); in nau8821_read_device_properties()
1725 nau8821->vref_impedance = 2; in nau8821_read_device_properties()
1727 &nau8821->jack_insert_debounce); in nau8821_read_device_properties()
1729 nau8821->jack_insert_debounce = 7; in nau8821_read_device_properties()
1731 &nau8821->jack_eject_debounce); in nau8821_read_device_properties()
1733 nau8821->jack_eject_debounce = 0; in nau8821_read_device_properties()
1735 &nau8821->dmic_clk_threshold); in nau8821_read_device_properties()
1737 nau8821->dmic_clk_threshold = 3072000; in nau8821_read_device_properties()
1742 static void nau8821_init_regs(struct nau8821 *nau8821) in nau8821_init_regs() argument
1744 struct regmap *regmap = nau8821->regmap; in nau8821_init_regs()
1758 (nau8821->vref_impedance << NAU8821_BIAS_VMID_SEL_SFT) | in nau8821_init_regs()
1789 NAU8821_MICBIAS_VOLTAGE_MASK, nau8821->micbias_voltage); in nau8821_init_regs()
1797 if (nau8821->left_input_single_end) { in nau8821_init_regs()
1805 static int nau8821_setup_irq(struct nau8821 *nau8821) in nau8821_setup_irq() argument
1807 struct regmap *regmap = nau8821->regmap; in nau8821_setup_irq()
1812 nau8821->jkdet_enable ? 0 : NAU8821_JKDET_OUTPUT_EN); in nau8821_setup_irq()
1815 nau8821->jkdet_pull_enable ? 0 : NAU8821_JKDET_PULL_EN); in nau8821_setup_irq()
1818 nau8821->jkdet_pull_up ? NAU8821_JKDET_PULL_UP : 0); in nau8821_setup_irq()
1822 nau8821->jkdet_polarity ? 0 : NAU8821_JACK_POLARITY); in nau8821_setup_irq()
1825 nau8821->jack_insert_debounce << in nau8821_setup_irq()
1829 nau8821->jack_eject_debounce << in nau8821_setup_irq()
1873 struct nau8821 *nau8821 = dev_get_platdata(&i2c->dev); in nau8821_i2c_probe() local
1876 if (!nau8821) { in nau8821_i2c_probe()
1877 nau8821 = devm_kzalloc(dev, sizeof(*nau8821), GFP_KERNEL); in nau8821_i2c_probe()
1878 if (!nau8821) in nau8821_i2c_probe()
1880 nau8821_read_device_properties(dev, nau8821); in nau8821_i2c_probe()
1882 i2c_set_clientdata(i2c, nau8821); in nau8821_i2c_probe()
1884 nau8821->regmap = devm_regmap_init_i2c(i2c, &nau8821_regmap_config); in nau8821_i2c_probe()
1885 if (IS_ERR(nau8821->regmap)) in nau8821_i2c_probe()
1886 return PTR_ERR(nau8821->regmap); in nau8821_i2c_probe()
1888 nau8821->dev = dev; in nau8821_i2c_probe()
1889 nau8821->irq = i2c->irq; in nau8821_i2c_probe()
1894 nau8821->jkdet_polarity = 0; in nau8821_i2c_probe()
1896 nau8821_print_device_properties(nau8821); in nau8821_i2c_probe()
1898 nau8821_reset_chip(nau8821->regmap); in nau8821_i2c_probe()
1899 ret = regmap_read(nau8821->regmap, NAU8821_R58_I2C_DEVICE_ID, &value); in nau8821_i2c_probe()
1904 nau8821_init_regs(nau8821); in nau8821_i2c_probe()
1907 nau8821_setup_irq(nau8821); in nau8821_i2c_probe()