Lines Matching +full:vdd +full:- +full:1 +full:p8 +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
26 #include <sound/soc-dapm.h>
123 #define WSA884X_PWM_CLK_CTL_PWM_CLK_DIV_RATIO_SHIFT 1
217 #define WSA884X_ZX_CTRL1_ZX_BYP_MASK_DEL_SHIFT 1
310 #define WSA884X_PA_FSM_BYP0_CLK_WD_EN_SHIFT 1
328 #define WSA884X_TADC_VALUE_CTL_VBAT_VALUE_RD_EN_SHIFT 1
341 #define WSA884X_VBAT_THRM_FLT_CTL_VBAT_COEF_SEL_SHIFT 1
355 #define WSA884X_BOP_DEGLITCH_CTL_BOP_DEGLITCH_SETTING_SHIFT 1
401 #define WSA884X_PDM_WD_CTL_TIME_OUT_SEL_SHIFT 1
415 #define WSA884X_DRE_CTL_1_CSR_GAIN_SHIFT 1
437 #define WSA884X_CLSH_CTL_0_INPUT_EN_SHIFT 1
451 ((vth) != 0 ? (((vth) - 150) * WSA884X_PBR_MAX_CODE / (WSA884X_PBR_MAX_VOLTAGE * 100) + 1) : 0)
628 #define WSA884X_OTP_REG_40_ATE_BOOST_RDSON_TEST_SHIFT 1
700 #define WSA884X_NUM_REGISTERS (WSA884X_EMEM_63 + 1)
701 #define WSA884X_MAX_REGISTER (WSA884X_NUM_REGISTERS - 1)
717 /* Two-point trimming for temperature calibration */
718 #define WSA884X_T1_TEMP -10L
808 "vdd-io",
809 "vdd-1p8",
826 .num = WSA884X_PORT_DAC + 1,
828 .min_ch = 1,
829 .max_ch = 1,
834 .num = WSA884X_PORT_COMP + 1,
836 .min_ch = 1,
837 .max_ch = 1,
842 .num = WSA884X_PORT_BOOST + 1,
844 .min_ch = 1,
845 .max_ch = 1,
850 .num = WSA884X_PORT_PBR + 1,
852 .min_ch = 1,
853 .max_ch = 1,
858 .num = WSA884X_PORT_VISENSE + 1,
860 .min_ch = 1,
861 .max_ch = 1,
866 .num = WSA884X_PORT_CPS + 1,
868 .min_ch = 1,
869 .max_ch = 1,
877 .num = WSA884X_PORT_DAC + 1,
881 .num = WSA884X_PORT_COMP + 1,
885 .num = WSA884X_PORT_BOOST + 1,
889 .num = WSA884X_PORT_PBR + 1,
893 .num = WSA884X_PORT_VISENSE + 1,
897 .num = WSA884X_PORT_CPS + 1,
1392 * Downstream suggests for batteries different than 1-Stacked (1S):
1438 * battery 1S and rload 8 Ohms.
1462 struct regmap *regmap = wsa884x->regmap; in wsa884x_set_gain_parameters()
1466 * Downstream sets gain parameters customized per boards per use-case. in wsa884x_set_gain_parameters()
1471 * For WSA884X_RECEIVER - G_7P5_DB system gain in wsa884x_set_gain_parameters()
1472 * For WSA884X_SPEAKER - G_21_DB system gain in wsa884x_set_gain_parameters()
1474 if (wsa884x->dev_mode == WSA884X_RECEIVER) { in wsa884x_set_gain_parameters()
1497 if (wsa884x->port_enable[WSA884X_PORT_COMP]) { in wsa884x_set_gain_parameters()
1517 if (!regmap_read(wsa884x->regmap, WSA884X_OTP_REG_0, &variant)) in wsa884x_init()
1520 regmap_multi_reg_write(wsa884x->regmap, wsa884x_reg_init, in wsa884x_init()
1533 regmap_write(wsa884x->regmap, WSA884X_ANA_WO_CTL_0, wo_ctl_0); in wsa884x_init()
1537 wsa884x->hw_init = false; in wsa884x_init()
1543 struct wsa884x_priv *wsa884x = dev_get_drvdata(&slave->dev); in wsa884x_update_status()
1547 wsa884x->hw_init = false; in wsa884x_update_status()
1548 regcache_cache_only(wsa884x->regmap, true); in wsa884x_update_status()
1549 regcache_mark_dirty(wsa884x->regmap); in wsa884x_update_status()
1553 if (wsa884x->hw_init || status != SDW_SLAVE_ATTACHED) in wsa884x_update_status()
1556 regcache_cache_only(wsa884x->regmap, false); in wsa884x_update_status()
1557 ret = regcache_sync(wsa884x->regmap); in wsa884x_update_status()
1559 dev_err(&slave->dev, "Cannot sync regmap cache\n"); in wsa884x_update_status()
1572 struct wsa884x_priv *wsa884x = dev_get_drvdata(&slave->dev); in wsa884x_port_prep()
1575 wsa884x->port_prepared[prepare_ch->num - 1] = true; in wsa884x_port_prep()
1577 wsa884x->port_prepared[prepare_ch->num - 1] = false; in wsa884x_port_prep()
1593 ucontrol->value.enumerated.item[0] = wsa884x->dev_mode; in wsa884x_dev_mode_get()
1604 if (wsa884x->dev_mode == ucontrol->value.enumerated.item[0]) in wsa884x_dev_mode_put()
1607 wsa884x->dev_mode = ucontrol->value.enumerated.item[0]; in wsa884x_dev_mode_put()
1609 return 1; in wsa884x_dev_mode_put()
1617 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa884x_get_swr_port()
1618 int portidx = mixer->reg; in wsa884x_get_swr_port()
1620 ucontrol->value.integer.value[0] = wsa884x->port_enable[portidx]; in wsa884x_get_swr_port()
1630 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa884x_set_swr_port()
1631 int portidx = mixer->reg; in wsa884x_set_swr_port()
1633 if (ucontrol->value.integer.value[0]) { in wsa884x_set_swr_port()
1634 if (wsa884x->port_enable[portidx]) in wsa884x_set_swr_port()
1637 wsa884x->port_enable[portidx] = true; in wsa884x_set_swr_port()
1639 if (!wsa884x->port_enable[portidx]) in wsa884x_set_swr_port()
1642 wsa884x->port_enable[portidx] = false; in wsa884x_set_swr_port()
1645 return 1; in wsa884x_set_swr_port()
1652 snd_soc_component_init_regmap(comp, wsa884x->regmap); in wsa884x_codec_probe()
1663 if (wsa884x->dev_mode == WSA884X_RECEIVER) { in wsa884x_spkr_post_pmu()
1678 if (wsa884x->port_enable[WSA884X_PORT_PBR]) { in wsa884x_spkr_post_pmu()
1683 if (wsa884x->dev_mode == WSA884X_RECEIVER) in wsa884x_spkr_post_pmu()
1699 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa884x_spkr_event()
1704 mutex_lock(&wsa884x->sp_lock); in wsa884x_spkr_event()
1705 wsa884x->pa_on = true; in wsa884x_spkr_event()
1706 mutex_unlock(&wsa884x->sp_lock); in wsa884x_spkr_event()
1720 mutex_lock(&wsa884x->sp_lock); in wsa884x_spkr_event()
1721 wsa884x->pa_on = false; in wsa884x_spkr_event()
1722 mutex_unlock(&wsa884x->sp_lock); in wsa884x_spkr_event()
1734 static const DECLARE_TLV_DB_SCALE(pa_gain, -900, 150, -900);
1739 0x0, 0x1f, 1, pa_gain),
1742 SOC_SINGLE_EXT("DAC Switch", WSA884X_PORT_DAC, 0, 1, 0,
1744 SOC_SINGLE_EXT("COMP Switch", WSA884X_PORT_COMP, 0, 1, 0,
1746 SOC_SINGLE_EXT("BOOST Switch", WSA884X_PORT_BOOST, 0, 1, 0,
1748 SOC_SINGLE_EXT("PBR Switch", WSA884X_PORT_PBR, 0, 1, 0,
1750 SOC_SINGLE_EXT("VISENSE Switch", WSA884X_PORT_VISENSE, 0, 1, 0,
1752 SOC_SINGLE_EXT("CPS Switch", WSA884X_PORT_CPS, 0, 1, 0,
1775 struct wsa884x_priv *wsa884x = dev_get_drvdata(dai->dev); in wsa884x_hw_params()
1778 wsa884x->active_ports = 0; in wsa884x_hw_params()
1780 if (!wsa884x->port_enable[i]) in wsa884x_hw_params()
1783 wsa884x->port_config[wsa884x->active_ports] = wsa884x_pconfig[i]; in wsa884x_hw_params()
1784 wsa884x->active_ports++; in wsa884x_hw_params()
1787 wsa884x->sconfig.frame_rate = params_rate(params); in wsa884x_hw_params()
1789 return sdw_stream_add_slave(wsa884x->slave, &wsa884x->sconfig, in wsa884x_hw_params()
1790 wsa884x->port_config, wsa884x->active_ports, in wsa884x_hw_params()
1791 wsa884x->sruntime); in wsa884x_hw_params()
1797 struct wsa884x_priv *wsa884x = dev_get_drvdata(dai->dev); in wsa884x_hw_free()
1799 sdw_stream_remove_slave(wsa884x->slave, wsa884x->sruntime); in wsa884x_hw_free()
1806 struct snd_soc_component *component = dai->component; in wsa884x_mute_stream()
1831 struct wsa884x_priv *wsa884x = dev_get_drvdata(dai->dev); in wsa884x_set_stream()
1833 wsa884x->sruntime = stream; in wsa884x_set_stream()
1855 .channels_min = 1,
1856 .channels_max = 1,
1871 guard(mutex)(&wsa884x->sp_lock); in wsa884x_get_temp()
1873 if (wsa884x->pa_on) { in wsa884x_get_temp()
1878 *temp = wsa884x->temperature; in wsa884x_get_temp()
1882 ret = pm_runtime_resume_and_get(wsa884x->dev); in wsa884x_get_temp()
1899 regmap_update_bits(wsa884x->regmap, WSA884X_PA_FSM_BYP0, mask, mask); in wsa884x_get_temp()
1901 regmap_update_bits(wsa884x->regmap, WSA884X_TADC_VALUE_CTL, in wsa884x_get_temp()
1905 regmap_read(wsa884x->regmap, WSA884X_TEMP_DIN_MSB, &dmeas_msb); in wsa884x_get_temp()
1906 regmap_read(wsa884x->regmap, WSA884X_TEMP_DIN_LSB, &dmeas_lsb); in wsa884x_get_temp()
1908 regmap_update_bits(wsa884x->regmap, WSA884X_TADC_VALUE_CTL, in wsa884x_get_temp()
1912 regmap_read(wsa884x->regmap, WSA884X_OTP_REG_1, &d1_msb); in wsa884x_get_temp()
1913 regmap_read(wsa884x->regmap, WSA884X_OTP_REG_2, &d1_lsb); in wsa884x_get_temp()
1914 regmap_read(wsa884x->regmap, WSA884X_OTP_REG_3, &d2_msb); in wsa884x_get_temp()
1915 regmap_read(wsa884x->regmap, WSA884X_OTP_REG_4, &d2_lsb); in wsa884x_get_temp()
1917 regmap_update_bits(wsa884x->regmap, WSA884X_PA_FSM_BYP0, mask, 0x0); in wsa884x_get_temp()
1925 ret = -EINVAL; in wsa884x_get_temp()
1929 val = WSA884X_T1_TEMP + (((dmeas - d1) * (WSA884X_T2_TEMP - WSA884X_T1_TEMP))/(d2 - d1)); in wsa884x_get_temp()
1931 dev_dbg(wsa884x->dev, "Measured temp %ld (dmeas=%d, d1=%d, d2=%d)\n", in wsa884x_get_temp()
1936 wsa884x->temperature = val; in wsa884x_get_temp()
1940 ret = -EAGAIN; in wsa884x_get_temp()
1944 pm_runtime_mark_last_busy(wsa884x->dev); in wsa884x_get_temp()
1945 pm_runtime_put_autosuspend(wsa884x->dev); in wsa884x_get_temp()
1978 ret = -EOPNOTSUPP; in wsa884x_hwmon_read()
2004 if (wsa884x->sd_reset) in wsa884x_reset_powerdown()
2005 reset_control_assert(wsa884x->sd_reset); in wsa884x_reset_powerdown()
2007 gpiod_direction_output(wsa884x->sd_n, 1); in wsa884x_reset_powerdown()
2012 if (wsa884x->sd_reset) in wsa884x_reset_deassert()
2013 reset_control_deassert(wsa884x->sd_reset); in wsa884x_reset_deassert()
2015 gpiod_direction_output(wsa884x->sd_n, 0); in wsa884x_reset_deassert()
2025 wsa884x->sd_reset = devm_reset_control_get_optional_shared(dev, NULL); in wsa884x_get_reset()
2026 if (IS_ERR(wsa884x->sd_reset)) in wsa884x_get_reset()
2027 return dev_err_probe(dev, PTR_ERR(wsa884x->sd_reset), in wsa884x_get_reset()
2029 else if (wsa884x->sd_reset) in wsa884x_get_reset()
2032 * else: NULL, so use the backwards compatible way for powerdown-gpios, in wsa884x_get_reset()
2035 wsa884x->sd_n = devm_gpiod_get_optional(dev, "powerdown", in wsa884x_get_reset()
2037 if (IS_ERR(wsa884x->sd_n)) in wsa884x_get_reset()
2038 return dev_err_probe(dev, PTR_ERR(wsa884x->sd_n), in wsa884x_get_reset()
2047 struct device *dev = &pdev->dev; in wsa884x_probe()
2054 return -ENOMEM; in wsa884x_probe()
2056 mutex_init(&wsa884x->sp_lock); in wsa884x_probe()
2059 wsa884x->supplies[i].supply = wsa884x_supply_name[i]; in wsa884x_probe()
2062 wsa884x->supplies); in wsa884x_probe()
2066 ret = regulator_bulk_enable(WSA884X_SUPPLIES_NUM, wsa884x->supplies); in wsa884x_probe()
2071 wsa884x->supplies); in wsa884x_probe()
2080 wsa884x->slave = pdev; in wsa884x_probe()
2081 wsa884x->dev = dev; in wsa884x_probe()
2082 wsa884x->dev_mode = WSA884X_SPEAKER; in wsa884x_probe()
2083 wsa884x->sconfig.ch_count = 1; in wsa884x_probe()
2084 wsa884x->sconfig.bps = 1; in wsa884x_probe()
2085 wsa884x->sconfig.direction = SDW_DATA_DIR_RX; in wsa884x_probe()
2086 wsa884x->sconfig.type = SDW_STREAM_PDM; in wsa884x_probe()
2090 * are from index 1 in wsa884x_probe()
2092 if (of_property_read_u32_array(dev->of_node, "qcom,port-mapping", &pdev->m_port_map[1], in wsa884x_probe()
2096 pdev->prop.sink_ports = GENMASK(WSA884X_MAX_SWR_PORTS - 1, 0); in wsa884x_probe()
2097 pdev->prop.simple_clk_stop_capable = true; in wsa884x_probe()
2098 pdev->prop.sink_dpn_prop = wsa884x_sink_dpn_prop; in wsa884x_probe()
2099 pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; in wsa884x_probe()
2106 wsa884x->regmap = devm_regmap_init_sdw(pdev, &wsa884x_regmap_config); in wsa884x_probe()
2107 if (IS_ERR(wsa884x->regmap)) in wsa884x_probe()
2108 return dev_err_probe(dev, PTR_ERR(wsa884x->regmap), in wsa884x_probe()
2111 /* Start in cache-only until device is enumerated */ in wsa884x_probe()
2112 regcache_cache_only(wsa884x->regmap, true); in wsa884x_probe()
2113 wsa884x->hw_init = true; in wsa884x_probe()
2171 .name = "wsa884x-codec",