• Richard Fitzgerald's avatar
    ASoC: cs35l56: Prevent overwriting firmware ASP config · dfd2ffb3
    Richard Fitzgerald authored
    Only populate the ASP1 config registers in the regmap cache if the
    ASP DAI is used. This prevents regcache_sync() from overwriting
    these registers with their defaults when the firmware owns
    control of these registers.
    
    On a SoundWire system the ASP could be owned by the firmware to
    share reference audio with the firmware on other cs35l56. Or it
    can be used as a normal codec-codec interface owned by the driver.
    The driver must not overwrite the registers if the firmware has
    control of them.
    
    The original implementation for this in commit 07f7d6e7
    ("ASoC: cs35l56: Fix for initializing ASP1 mixer registers") was
    to still provide defaults for these registers, assuming that if
    they were never reconfigured from defaults then regcache_sync()
    would not write them out because they are not dirty. Unfortunately
    regcache_sync() is not that smart. If the chip has not reset (so
    the driver has not called regcache_mark_dirty()) a regcache_sync()
    could write out registers that are not dirty.
    
    To avoid accidental overwriting of the ASP registers, they are
    removed from the table of defaults and instead are populated with
    defaults only if one of the ASP DAI configuration functions is
    called. So if the DAI has never been configured, the firmware is
    assumed to have ownership of these registers, and the regmap cache
    will not contain any entries for them.
    Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 07f7d6e7 ("ASoC: cs35l56: Fix for initializing ASP1 mixer registers")
    Link: https://msgid.link/r/20240408101803.43183-5-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    dfd2ffb3
cs35l56.h 11 KB