• Richard Fitzgerald's avatar
    ASoC: cs35l56: Remove buggy checks from cs35l56_is_fw_reload_needed() · 3739cc07
    Richard Fitzgerald authored
    Remove the check of fw_patched from cs35l56_is_fw_reload_needed().
    Also remove the redundant check for control of the reset GPIO.
    
    The fw_patched flag is set when cs35l56_dsp_work() has completed its
    steps to download firmware and power-up wm_adsp. There was a check in
    cs35l56_is_fw_reload_needed() to make a quick exit of 'false' if
    !fw_patched. The original idea was that the system might be suspended
    before the driver has ever made any attempt to download firmware, and
    in that case the driver doesn't need to return to a patched state
    because it was never in a patched state.
    
    This check of fw_patched is buggy because it prevented ever recovering
    from a failed patch. If a previous attempt to patch and reboot the
    silicon had failed it would leave fw_patched==false. This would mean
    the driver never attempted another download even though the fault may
    have been cleared (by a hard reset, for example).
    
    It is also a redundant check because the calling code already makes
    a quick exit if cs35l56_component_probe() has not been called, which
    deals with the original intent of this check but in a safer way.
    
    The check for reset GPIO is redundant: if the silicon was hard-reset
    the FIRMWARE_MISSING flag will be 1. But this check created an
    expectation that the suspend/resume code toggles reset. This can't
    easily be protected against accidental code breakage. The only reason
    for the check was to skip runtime-resuming the driver to read the
    PROTECTION_STATUS register when it already knows it reset the silicon.
    But in that case the driver will have to be runtime-resumed to do
    the firmware download. So it created an assumption for no benefit.
    Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 8a731fd3 ("ASoC: cs35l56: Move utility functions to shared file")
    Link: https://msgid.link/r/20240129162737.497-7-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    3739cc07
cs35l56-shared.c 23.9 KB