Commit 0a2e4923 authored by Simon Trimmer's avatar Simon Trimmer Committed by Mark Brown

ASoC: cs35l56: Convert utility functions to use common data structure

Use the new cs35l56_base struct for utility functions.
Signed-off-by: default avatarSimon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-4-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent cf6e7486
......@@ -802,14 +802,14 @@ static const struct reg_sequence cs35l56_system_reset_seq[] = {
REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_SYSTEM_RESET),
};
static void cs35l56_system_reset(struct cs35l56_private *cs35l56, bool is_soundwire)
static void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire)
{
/*
* Must enter cache-only first so there can't be any more register
* accesses other than the controlled system reset sequence below.
*/
regcache_cache_only(cs35l56->base.regmap, true);
regmap_multi_reg_write_bypassed(cs35l56->base.regmap,
regcache_cache_only(cs35l56_base->regmap, true);
regmap_multi_reg_write_bypassed(cs35l56_base->regmap,
cs35l56_system_reset_seq,
ARRAY_SIZE(cs35l56_system_reset_seq));
......@@ -818,7 +818,7 @@ static void cs35l56_system_reset(struct cs35l56_private *cs35l56, bool is_soundw
return;
usleep_range(CS35L56_CONTROL_PORT_READY_US, CS35L56_CONTROL_PORT_READY_US + 400);
regcache_cache_only(cs35l56->base.regmap, false);
regcache_cache_only(cs35l56_base->regmap, false);
}
static void cs35l56_secure_patch(struct cs35l56_private *cs35l56)
......@@ -882,7 +882,7 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)
init_completion(&cs35l56->init_completion);
cs35l56->soft_resetting = true;
cs35l56_system_reset(cs35l56, !!cs35l56->sdw_peripheral);
cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
if (cs35l56->sdw_peripheral) {
/*
......@@ -1137,20 +1137,20 @@ int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56)
}
EXPORT_SYMBOL_NS_GPL(cs35l56_runtime_resume_common, SND_SOC_CS35L56_CORE);
static int cs35l56_is_fw_reload_needed(struct cs35l56_private *cs35l56)
static int cs35l56_is_fw_reload_needed(struct cs35l56_base *cs35l56_base)
{
unsigned int val;
int ret;
/* Nothing to re-patch if we haven't done any patching yet. */
if (!cs35l56->base.fw_patched)
if (!cs35l56_base->fw_patched)
return false;
/*
* If we have control of RESET we will have asserted it so the firmware
* will need re-patching.
*/
if (cs35l56->base.reset_gpio)
if (cs35l56_base->reset_gpio)
return true;
/*
......@@ -1158,22 +1158,22 @@ static int cs35l56_is_fw_reload_needed(struct cs35l56_private *cs35l56)
* can't be used here to test for memory retention.
* Assume that tuning must be re-loaded.
*/
if (cs35l56->base.secured)
if (cs35l56_base->secured)
return true;
ret = pm_runtime_resume_and_get(cs35l56->base.dev);
ret = pm_runtime_resume_and_get(cs35l56_base->dev);
if (ret) {
dev_err(cs35l56->base.dev, "Failed to runtime_get: %d\n", ret);
dev_err(cs35l56_base->dev, "Failed to runtime_get: %d\n", ret);
return ret;
}
ret = regmap_read(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, &val);
ret = regmap_read(cs35l56_base->regmap, CS35L56_PROTECTION_STATUS, &val);
if (ret)
dev_err(cs35l56->base.dev, "Failed to read PROTECTION_STATUS: %d\n", ret);
dev_err(cs35l56_base->dev, "Failed to read PROTECTION_STATUS: %d\n", ret);
else
ret = !!(val & CS35L56_FIRMWARE_MISSING);
pm_runtime_put_autosuspend(cs35l56->base.dev);
pm_runtime_put_autosuspend(cs35l56_base->dev);
return ret;
}
......@@ -1302,7 +1302,7 @@ int cs35l56_system_resume(struct device *dev)
if (!cs35l56->component)
return 0;
ret = cs35l56_is_fw_reload_needed(cs35l56);
ret = cs35l56_is_fw_reload_needed(&cs35l56->base);
dev_dbg(cs35l56->base.dev, "fw_reload_needed: %d\n", ret);
if (ret < 1)
return ret;
......@@ -1547,7 +1547,7 @@ int cs35l56_init(struct cs35l56_private *cs35l56)
if (!cs35l56->base.reset_gpio) {
dev_dbg(cs35l56->base.dev, "No reset gpio: using soft reset\n");
cs35l56->soft_resetting = true;
cs35l56_system_reset(cs35l56, !!cs35l56->sdw_peripheral);
cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
if (cs35l56->sdw_peripheral) {
/* Keep alive while we wait for re-enumeration */
pm_runtime_get_noresume(cs35l56->base.dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment