Lines Matching full:wsa884x

1460 static void wsa884x_set_gain_parameters(struct wsa884x_priv *wsa884x)  in wsa884x_set_gain_parameters()  argument
1462 struct regmap *regmap = wsa884x->regmap; 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()
1512 static void wsa884x_init(struct wsa884x_priv *wsa884x) in wsa884x_init() argument
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()
1535 wsa884x_set_gain_parameters(wsa884x); 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() local
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()
1563 wsa884x_init(wsa884x); in wsa884x_update_status()
1572 struct wsa884x_priv *wsa884x = dev_get_drvdata(&slave->dev); in wsa884x_port_prep() local
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()
1591 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); in wsa884x_dev_mode_get() local
1593 ucontrol->value.enumerated.item[0] = wsa884x->dev_mode; in wsa884x_dev_mode_get()
1602 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); in wsa884x_dev_mode_put() local
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()
1616 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(comp); in wsa884x_get_swr_port() local
1620 ucontrol->value.integer.value[0] = wsa884x->port_enable[portidx]; in wsa884x_get_swr_port()
1629 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(comp); in wsa884x_set_swr_port() local
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()
1650 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(comp); in wsa884x_codec_probe() local
1652 snd_soc_component_init_regmap(comp, wsa884x->regmap); in wsa884x_codec_probe()
1658 struct wsa884x_priv *wsa884x) in wsa884x_spkr_post_pmu() argument
1662 wsa884x_set_gain_parameters(wsa884x); in wsa884x_spkr_post_pmu()
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()
1700 struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); in wsa884x_spkr_event() local
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()
1708 wsa884x_spkr_post_pmu(component, wsa884x); 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()
1761 .name = "WSA884x",
1775 struct wsa884x_priv *wsa884x = dev_get_drvdata(dai->dev); in wsa884x_hw_params() local
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() local
1799 sdw_stream_remove_slave(wsa884x->slave, wsa884x->sruntime); in wsa884x_hw_free()
1831 struct wsa884x_priv *wsa884x = dev_get_drvdata(dai->dev); in wsa884x_set_stream() local
1833 wsa884x->sruntime = stream; in wsa884x_set_stream()
1862 static int wsa884x_get_temp(struct wsa884x_priv *wsa884x, long *temp) in wsa884x_get_temp() argument
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()
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()
1944 pm_runtime_mark_last_busy(wsa884x->dev); in wsa884x_get_temp()
1945 pm_runtime_put_autosuspend(wsa884x->dev); in wsa884x_get_temp()
2002 struct wsa884x_priv *wsa884x = data; in wsa884x_reset_powerdown() local
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()
2010 static void wsa884x_reset_deassert(struct wsa884x_priv *wsa884x) in wsa884x_reset_deassert() argument
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()
2023 static int wsa884x_get_reset(struct device *dev, struct wsa884x_priv *wsa884x) in wsa884x_get_reset() argument
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()
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()
2048 struct wsa884x_priv *wsa884x; in wsa884x_probe() local
2052 wsa884x = devm_kzalloc(dev, sizeof(*wsa884x), GFP_KERNEL); in wsa884x_probe()
2053 if (!wsa884x) 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()
2075 ret = wsa884x_get_reset(dev, wsa884x); in wsa884x_probe()
2079 dev_set_drvdata(dev, wsa884x); 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()
2101 wsa884x_reset_deassert(wsa884x); in wsa884x_probe()
2102 ret = devm_add_action_or_reset(dev, wsa884x_reset_powerdown, wsa884x); 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()
2112 regcache_cache_only(wsa884x->regmap, true); in wsa884x_probe()
2113 wsa884x->hw_init = true; in wsa884x_probe()
2118 hwmon = devm_hwmon_device_register_with_info(dev, "wsa884x", in wsa884x_probe()
2119 wsa884x, in wsa884x_probe()
2171 .name = "wsa884x-codec",
2181 MODULE_DESCRIPTION("WSA884x codec driver");