Lines Matching +full:slave +full:- +full:dev
1 // SPDX-License-Identifier: GPL-2.0-only
28 static bool max98363_readable_register(struct device *dev, unsigned int reg) in max98363_readable_register() argument
49 static bool max98363_volatile_reg(struct device *dev, unsigned int reg) in max98363_volatile_reg() argument
77 static int max98363_suspend(struct device *dev) in max98363_suspend() argument
79 struct max98363_priv *max98363 = dev_get_drvdata(dev); in max98363_suspend()
81 regcache_cache_only(max98363->regmap, true); in max98363_suspend()
82 regcache_mark_dirty(max98363->regmap); in max98363_suspend()
89 static int max98363_resume(struct device *dev) in max98363_resume() argument
91 struct sdw_slave *slave = dev_to_sdw_dev(dev); in max98363_resume() local
92 struct max98363_priv *max98363 = dev_get_drvdata(dev); in max98363_resume()
95 if (!max98363->first_hw_init) in max98363_resume()
98 if (!slave->unattach_request) in max98363_resume()
101 time = wait_for_completion_timeout(&slave->initialization_complete, in max98363_resume()
104 dev_err(dev, "Initialization not complete, timed out\n"); in max98363_resume()
105 return -ETIMEDOUT; in max98363_resume()
110 slave->unattach_request = 0; in max98363_resume()
111 regcache_cache_only(max98363->regmap, false); in max98363_resume()
112 regcache_sync(max98363->regmap); in max98363_resume()
119 static int max98363_read_prop(struct sdw_slave *slave) in max98363_read_prop() argument
121 struct sdw_slave_prop *prop = &slave->prop; in max98363_read_prop()
127 prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; in max98363_read_prop()
130 prop->sink_ports = BIT(1); in max98363_read_prop()
131 prop->paging_support = true; in max98363_read_prop()
132 prop->clk_stop_timeout = 20; in max98363_read_prop()
133 prop->simple_clk_stop_capable = true; in max98363_read_prop()
134 prop->clock_reg_supported = true; in max98363_read_prop()
136 nval = hweight32(prop->sink_ports); in max98363_read_prop()
137 prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, in max98363_read_prop()
138 sizeof(*prop->sink_dpn_prop), in max98363_read_prop()
140 if (!prop->sink_dpn_prop) in max98363_read_prop()
141 return -ENOMEM; in max98363_read_prop()
144 dpn = prop->sink_dpn_prop; in max98363_read_prop()
145 addr = prop->sink_ports; in max98363_read_prop()
157 static int max98363_io_init(struct sdw_slave *slave) in max98363_io_init() argument
159 struct device *dev = &slave->dev; in max98363_io_init() local
160 struct max98363_priv *max98363 = dev_get_drvdata(dev); in max98363_io_init()
163 regcache_cache_only(max98363->regmap, false); in max98363_io_init()
164 if (max98363->first_hw_init) in max98363_io_init()
165 regcache_cache_bypass(max98363->regmap, true); in max98363_io_init()
168 * PM runtime status is marked as 'active' only when a Slave reports as Attached in max98363_io_init()
170 if (!max98363->first_hw_init) in max98363_io_init()
172 pm_runtime_set_active(dev); in max98363_io_init()
174 pm_runtime_get_noresume(dev); in max98363_io_init()
176 ret = regmap_read(max98363->regmap, MAX98363_R21FF_REV_ID, ®); in max98363_io_init()
178 dev_info(dev, "Revision ID: %X\n", reg); in max98363_io_init()
182 if (max98363->first_hw_init) { in max98363_io_init()
183 regcache_cache_bypass(max98363->regmap, false); in max98363_io_init()
184 regcache_mark_dirty(max98363->regmap); in max98363_io_init()
187 max98363->first_hw_init = true; in max98363_io_init()
188 max98363->hw_init = true; in max98363_io_init()
191 pm_runtime_put_autosuspend(dev); in max98363_io_init()
203 struct snd_soc_component *component = dai->component; in max98363_sdw_dai_hw_params()
211 struct snd_pcm_runtime *runtime = substream->runtime; in max98363_sdw_dai_hw_params()
218 return -EINVAL; in max98363_sdw_dai_hw_params()
220 if (!max98363->slave) in max98363_sdw_dai_hw_params()
221 return -EINVAL; in max98363_sdw_dai_hw_params()
223 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in max98363_sdw_dai_hw_params()
224 return -EINVAL; in max98363_sdw_dai_hw_params()
234 if (stream_config.ch_count > runtime->hw.channels_max) { in max98363_sdw_dai_hw_params()
235 stream_config.ch_count = runtime->hw.channels_max; in max98363_sdw_dai_hw_params()
236 dev_info(dai->dev, "Number of channels: %d (requested: %d)\n", in max98363_sdw_dai_hw_params()
239 port_config.ch_mask = GENMASK((int)stream_config.ch_count - 1, 0); in max98363_sdw_dai_hw_params()
241 ret = sdw_stream_add_slave(max98363->slave, &stream_config, in max98363_sdw_dai_hw_params()
244 dev_err(dai->dev, "Unable to configure port\n"); in max98363_sdw_dai_hw_params()
248 dev_dbg(component->dev, "Format supported %d", params_format(params)); in max98363_sdw_dai_hw_params()
256 struct snd_soc_component *component = dai->component; in max98363_pcm_hw_free()
262 if (!max98363->slave) in max98363_pcm_hw_free()
263 return -EINVAL; in max98363_pcm_hw_free()
265 sdw_stream_remove_slave(max98363->slave, stream); in max98363_pcm_hw_free()
286 .name = "max98363-aif1",
298 static int max98363_update_status(struct sdw_slave *slave, in max98363_update_status() argument
301 struct max98363_priv *max98363 = dev_get_drvdata(&slave->dev); in max98363_update_status()
304 max98363->hw_init = false; in max98363_update_status()
307 * Perform initialization only if slave status is SDW_SLAVE_ATTACHED in max98363_update_status()
309 if (max98363->hw_init || status != SDW_SLAVE_ATTACHED) in max98363_update_status()
312 /* perform I/O transfers required for Slave initialization */ in max98363_update_status()
313 return max98363_io_init(slave); in max98363_update_status()
321 static DECLARE_TLV_DB_SCALE(max98363_digital_tlv, -6350, 50, 1);
323 0, 5, TLV_DB_SCALE_ITEM(-300, 300, 0),
327 "Reserved", "0", "+FS/2", "-FS/2", "1KHz",
386 static int max98363_init(struct sdw_slave *slave, struct regmap *regmap) in max98363_init() argument
390 struct device *dev = &slave->dev; in max98363_init() local
393 max98363 = devm_kzalloc(dev, sizeof(*max98363), GFP_KERNEL); in max98363_init()
395 return -ENOMEM; in max98363_init()
397 dev_set_drvdata(dev, max98363); in max98363_init()
398 max98363->regmap = regmap; in max98363_init()
399 max98363->slave = slave; in max98363_init()
401 regcache_cache_only(max98363->regmap, true); in max98363_init()
403 max98363->hw_init = false; in max98363_init()
404 max98363->first_hw_init = false; in max98363_init()
407 ret = devm_snd_soc_register_component(dev, &soc_codec_dev_max98363, in max98363_init()
411 dev_err(dev, "Failed to register codec: %d\n", ret); in max98363_init()
416 pm_runtime_set_autosuspend_delay(dev, 3000); in max98363_init()
417 pm_runtime_use_autosuspend(dev); in max98363_init()
420 pm_runtime_mark_last_busy(dev); in max98363_init()
422 pm_runtime_enable(dev); in max98363_init()
427 * fail with -EACCESS because of race conditions between card creation and enumeration in max98363_init()
432 static int max98363_sdw_probe(struct sdw_slave *slave, in max98363_sdw_probe() argument
438 regmap = devm_regmap_init_sdw(slave, &max98363_sdw_regmap); in max98363_sdw_probe()
442 return max98363_init(slave, regmap); in max98363_sdw_probe()