Lines Matching refs:max98396
351 struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); in max98396_dai_set_fmt() local
403 ret = regmap_read(max98396->regmap, MAX98396_R210F_GLOBAL_EN, &status); in max98396_dai_set_fmt()
408 ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, ®); in max98396_dai_set_fmt()
414 ret = regmap_read(max98396->regmap, in max98396_dai_set_fmt()
423 max98396_global_enable_onoff(max98396->regmap, false); in max98396_dai_set_fmt()
426 regmap_update_bits(max98396->regmap, in max98396_dai_set_fmt()
430 regmap_update_bits(max98396->regmap, in max98396_dai_set_fmt()
436 max98396_global_enable_onoff(max98396->regmap, true); in max98396_dai_set_fmt()
510 struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); in max98396_dai_hw_params() local
580 if (max98396->tdm_mode) { in max98396_dai_hw_params()
581 if (params_rate(params) > max98396->tdm_max_samplerate) { in max98396_dai_hw_params()
607 ret = regmap_read(max98396->regmap, MAX98396_R210F_GLOBAL_EN, &status); in max98396_dai_hw_params()
612 ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, ®); in max98396_dai_hw_params()
618 ret = regmap_read(max98396->regmap, MAX98396_R2043_PCM_SR_SETUP, ®); in max98396_dai_hw_params()
627 max98396_global_enable_onoff(max98396->regmap, false); in max98396_dai_hw_params()
631 regmap_update_bits(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, in max98396_dai_hw_params()
635 regmap_update_bits(max98396->regmap, MAX98396_R2043_PCM_SR_SETUP, in max98396_dai_hw_params()
639 if (max98396->interleave_mode && in max98396_dai_hw_params()
641 regmap_update_bits(max98396->regmap, in max98396_dai_hw_params()
647 regmap_update_bits(max98396->regmap, in max98396_dai_hw_params()
653 regmap_update_bits(max98396->regmap, in max98396_dai_hw_params()
659 max98396_global_enable_onoff(max98396->regmap, true); in max98396_dai_hw_params()
672 struct max98396_priv *max98396 = in max98396_dai_tdm_slot() local
681 max98396->tdm_mode = false; in max98396_dai_tdm_slot()
683 max98396->tdm_mode = true; in max98396_dai_tdm_slot()
694 max98396->tdm_max_samplerate = max98396_pcm_configs[ret].max_sr; in max98396_dai_tdm_slot()
713 ret = regmap_read(max98396->regmap, MAX98396_R210F_GLOBAL_EN, &status); in max98396_dai_tdm_slot()
718 ret = regmap_read(max98396->regmap, MAX98396_R2042_PCM_CLK_SETUP, ®); in max98396_dai_tdm_slot()
724 ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, ®); in max98396_dai_tdm_slot()
733 max98396_global_enable_onoff(max98396->regmap, false); in max98396_dai_tdm_slot()
736 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
741 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
746 if (max98396->device_id == CODEC_TYPE_MAX98396) { in max98396_dai_tdm_slot()
747 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
751 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
756 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
760 regmap_update_bits(max98396->regmap, in max98396_dai_tdm_slot()
767 if (max98396->device_id == CODEC_TYPE_MAX98396) { in max98396_dai_tdm_slot()
768 regmap_write(max98396->regmap, in max98396_dai_tdm_slot()
771 regmap_write(max98396->regmap, in max98396_dai_tdm_slot()
775 regmap_write(max98396->regmap, in max98396_dai_tdm_slot()
778 regmap_write(max98396->regmap, in max98396_dai_tdm_slot()
784 max98396_global_enable_onoff(max98396->regmap, true); in max98396_dai_tdm_slot()
805 struct max98396_priv *max98396 = in max98396_dac_event() local
810 max98396_global_enable_onoff(max98396->regmap, true); in max98396_dac_event()
813 max98396_global_enable_onoff(max98396->regmap, false); in max98396_dac_event()
815 max98396->tdm_mode = false; in max98396_dac_event()
959 struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); in max98396_mux_get() local
962 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_mux_get()
967 regmap_read(max98396->regmap, reg, &val); in max98396_mux_get()
980 struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); in max98396_mux_put() local
991 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_mux_put()
1000 regmap_update_bits(max98396->regmap, reg, in max98396_mux_put()
1113 struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); in max98396_adc_value_get() local
1122 if (max98396->device_id == CODEC_TYPE_MAX98397) { in max98396_adc_value_get()
1138 ret = regmap_raw_read(max98396->regmap, reg, &val, 2); in max98396_adc_value_get()
1352 static void max98396_reset(struct max98396_priv *max98396, struct device *dev) in max98396_reset() argument
1357 ret = regmap_write(max98396->regmap, in max98396_reset()
1366 ret = regmap_read(max98396->regmap, in max98396_reset()
1367 GET_REG_ADDR_REV_ID(max98396->device_id), ®); in max98396_reset()
1379 struct max98396_priv *max98396 = in max98396_probe() local
1383 max98396_reset(max98396, component->dev); in max98396_probe()
1386 if (max98396->device_id == CODEC_TYPE_MAX98396) { in max98396_probe()
1387 regmap_write(max98396->regmap, in max98396_probe()
1389 regmap_write(max98396->regmap, in max98396_probe()
1392 regmap_write(max98396->regmap, in max98396_probe()
1394 regmap_write(max98396->regmap, in max98396_probe()
1398 regmap_update_bits(max98396->regmap, in max98396_probe()
1401 (max98396->vbat == NULL) ? in max98396_probe()
1404 regmap_update_bits(max98396->regmap, in max98396_probe()
1407 regmap_update_bits(max98396->regmap, in max98396_probe()
1412 regmap_write(max98396->regmap, in max98396_probe()
1415 regmap_update_bits(max98396->regmap, in max98396_probe()
1418 regmap_update_bits(max98396->regmap, in max98396_probe()
1422 regmap_write(max98396->regmap, in max98396_probe()
1424 max98396->bypass_slot); in max98396_probe()
1426 regmap_write(max98396->regmap, in max98396_probe()
1428 max98396->v_slot); in max98396_probe()
1429 regmap_write(max98396->regmap, in max98396_probe()
1431 max98396->i_slot); in max98396_probe()
1432 regmap_write(max98396->regmap, in max98396_probe()
1434 max98396->spkfb_slot); in max98396_probe()
1436 if (max98396->v_slot < 8) in max98396_probe()
1437 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_probe()
1438 regmap_update_bits(max98396->regmap, in max98396_probe()
1440 1 << max98396->v_slot, 0); in max98396_probe()
1442 regmap_update_bits(max98396->regmap, in max98396_probe()
1444 1 << max98396->v_slot, 0); in max98396_probe()
1446 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_probe()
1447 regmap_update_bits(max98396->regmap, in max98396_probe()
1449 1 << (max98396->v_slot - 8), 0); in max98396_probe()
1451 regmap_update_bits(max98396->regmap, in max98396_probe()
1453 1 << (max98396->v_slot - 8), 0); in max98396_probe()
1455 if (max98396->i_slot < 8) in max98396_probe()
1456 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_probe()
1457 regmap_update_bits(max98396->regmap, in max98396_probe()
1459 1 << max98396->i_slot, 0); in max98396_probe()
1461 regmap_update_bits(max98396->regmap, in max98396_probe()
1463 1 << max98396->i_slot, 0); in max98396_probe()
1465 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_probe()
1466 regmap_update_bits(max98396->regmap, in max98396_probe()
1468 1 << (max98396->i_slot - 8), 0); in max98396_probe()
1470 regmap_update_bits(max98396->regmap, in max98396_probe()
1472 1 << (max98396->i_slot - 8), 0); in max98396_probe()
1475 if (max98396->interleave_mode) in max98396_probe()
1476 regmap_update_bits(max98396->regmap, in max98396_probe()
1481 regmap_update_bits(max98396->regmap, in max98396_probe()
1486 regmap_update_bits(max98396->regmap, in max98396_probe()
1489 max98396->dmon_stuck_enable ? in max98396_probe()
1492 regmap_update_bits(max98396->regmap, in max98396_probe()
1495 max98396->dmon_mag_enable ? in max98396_probe()
1498 switch (max98396->dmon_duration) { in max98396_probe()
1500 regmap_update_bits(max98396->regmap, in max98396_probe()
1505 regmap_update_bits(max98396->regmap, in max98396_probe()
1510 regmap_update_bits(max98396->regmap, in max98396_probe()
1515 regmap_update_bits(max98396->regmap, in max98396_probe()
1521 max98396->dmon_duration); in max98396_probe()
1524 switch (max98396->dmon_stuck_threshold) { in max98396_probe()
1526 regmap_update_bits(max98396->regmap, in max98396_probe()
1532 regmap_update_bits(max98396->regmap, in max98396_probe()
1538 regmap_update_bits(max98396->regmap, in max98396_probe()
1544 regmap_update_bits(max98396->regmap, in max98396_probe()
1551 max98396->dmon_stuck_threshold); in max98396_probe()
1554 switch (max98396->dmon_mag_threshold) { in max98396_probe()
1556 regmap_update_bits(max98396->regmap, in max98396_probe()
1559 (5 - max98396->dmon_mag_threshold) in max98396_probe()
1564 max98396->dmon_mag_threshold); in max98396_probe()
1568 regmap_update_bits(max98396->regmap, in max98396_probe()
1578 struct max98396_priv *max98396 = dev_get_drvdata(dev); in max98396_suspend() local
1580 regcache_cache_only(max98396->regmap, true); in max98396_suspend()
1581 regcache_mark_dirty(max98396->regmap); in max98396_suspend()
1583 max98396->core_supplies); in max98396_suspend()
1584 if (max98396->pvdd) in max98396_suspend()
1585 regulator_disable(max98396->pvdd); in max98396_suspend()
1587 if (max98396->vbat) in max98396_suspend()
1588 regulator_disable(max98396->vbat); in max98396_suspend()
1595 struct max98396_priv *max98396 = dev_get_drvdata(dev); in max98396_resume() local
1599 max98396->core_supplies); in max98396_resume()
1603 if (max98396->pvdd) { in max98396_resume()
1604 ret = regulator_enable(max98396->pvdd); in max98396_resume()
1609 if (max98396->vbat) { in max98396_resume()
1610 ret = regulator_enable(max98396->vbat); in max98396_resume()
1615 regcache_cache_only(max98396->regmap, false); in max98396_resume()
1616 max98396_reset(max98396, dev); in max98396_resume()
1617 regcache_sync(max98396->regmap); in max98396_resume()
1675 struct max98396_priv *max98396) in max98396_read_device_property() argument
1680 max98396->v_slot = value & 0xF; in max98396_read_device_property()
1682 max98396->v_slot = 0; in max98396_read_device_property()
1685 max98396->i_slot = value & 0xF; in max98396_read_device_property()
1687 max98396->i_slot = 1; in max98396_read_device_property()
1690 max98396->spkfb_slot = value & 0xF; in max98396_read_device_property()
1692 max98396->spkfb_slot = 2; in max98396_read_device_property()
1695 max98396->bypass_slot = value & 0xF; in max98396_read_device_property()
1697 max98396->bypass_slot = 0; in max98396_read_device_property()
1699 max98396->dmon_stuck_enable = in max98396_read_device_property()
1703 max98396->dmon_stuck_threshold = value; in max98396_read_device_property()
1705 max98396->dmon_stuck_threshold = 15; in max98396_read_device_property()
1707 max98396->dmon_mag_enable = in max98396_read_device_property()
1711 max98396->dmon_mag_threshold = value; in max98396_read_device_property()
1713 max98396->dmon_mag_threshold = 5; in max98396_read_device_property()
1716 max98396->dmon_duration = value; in max98396_read_device_property()
1718 max98396->dmon_duration = 64; in max98396_read_device_property()
1723 struct max98396_priv *max98396 = priv; in max98396_core_supplies_disable() local
1726 max98396->core_supplies); in max98396_core_supplies_disable()
1737 struct max98396_priv *max98396 = NULL; in max98396_i2c_probe() local
1740 max98396 = devm_kzalloc(&i2c->dev, sizeof(*max98396), GFP_KERNEL); in max98396_i2c_probe()
1742 if (!max98396) { in max98396_i2c_probe()
1746 i2c_set_clientdata(i2c, max98396); in max98396_i2c_probe()
1748 max98396->device_id = id->driver_data; in max98396_i2c_probe()
1751 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_i2c_probe()
1752 max98396->regmap = devm_regmap_init_i2c(i2c, &max98396_regmap); in max98396_i2c_probe()
1755 max98396->regmap = devm_regmap_init_i2c(i2c, &max98397_regmap); in max98396_i2c_probe()
1757 if (IS_ERR(max98396->regmap)) { in max98396_i2c_probe()
1758 ret = PTR_ERR(max98396->regmap); in max98396_i2c_probe()
1766 max98396->core_supplies[i].supply = max98396_core_supplies[i]; in max98396_i2c_probe()
1769 max98396->core_supplies); in max98396_i2c_probe()
1775 max98396->vbat = devm_regulator_get_optional(&i2c->dev, "vbat"); in max98396_i2c_probe()
1776 if (IS_ERR(max98396->vbat)) { in max98396_i2c_probe()
1777 if (PTR_ERR(max98396->vbat) == -EPROBE_DEFER) in max98396_i2c_probe()
1780 max98396->vbat = NULL; in max98396_i2c_probe()
1783 max98396->pvdd = devm_regulator_get_optional(&i2c->dev, "pvdd"); in max98396_i2c_probe()
1784 if (IS_ERR(max98396->pvdd)) { in max98396_i2c_probe()
1785 if (PTR_ERR(max98396->pvdd) == -EPROBE_DEFER) in max98396_i2c_probe()
1788 max98396->pvdd = NULL; in max98396_i2c_probe()
1792 max98396->core_supplies); in max98396_i2c_probe()
1799 max98396); in max98396_i2c_probe()
1803 if (max98396->pvdd) { in max98396_i2c_probe()
1804 ret = regulator_enable(max98396->pvdd); in max98396_i2c_probe()
1810 max98396->pvdd); in max98396_i2c_probe()
1815 if (max98396->vbat) { in max98396_i2c_probe()
1816 ret = regulator_enable(max98396->vbat); in max98396_i2c_probe()
1822 max98396->vbat); in max98396_i2c_probe()
1829 max98396->interleave_mode = true; in max98396_i2c_probe()
1831 max98396->interleave_mode = false; in max98396_i2c_probe()
1834 max98396_read_device_property(&i2c->dev, max98396); in max98396_i2c_probe()
1837 max98396->reset_gpio = devm_gpiod_get_optional(&i2c->dev, in max98396_i2c_probe()
1839 if (IS_ERR(max98396->reset_gpio)) { in max98396_i2c_probe()
1840 ret = PTR_ERR(max98396->reset_gpio); in max98396_i2c_probe()
1845 if (max98396->reset_gpio) { in max98396_i2c_probe()
1847 gpiod_set_value_cansleep(max98396->reset_gpio, 0); in max98396_i2c_probe()
1852 ret = regmap_read(max98396->regmap, in max98396_i2c_probe()
1853 GET_REG_ADDR_REV_ID(max98396->device_id), ®); in max98396_i2c_probe()
1861 if (max98396->device_id == CODEC_TYPE_MAX98396) in max98396_i2c_probe()