Commit Graph

34 Commits

Author SHA1 Message Date
Simon Trimmer f2602fba47
ASoC: cs35l56: Avoid static analysis warning of uninitialised variable
Static checkers complain that the silicon_uid variable passed by
pointer to cs35l56_read_silicon_uid() could later be used
uninitialised when calling cs_amp_get_efi_calibration_data().

cs35l56_read_silicon_uid() must have succeeded to call
cs_amp_get_efi_calibration_data() and that would have populated the
variable.

However, initialise the value so we are not haunted by it forevermore.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Fixes: e1830f66f6 ("ASoC: cs35l56: Add helper functions for amp calibration")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240422103211.236063-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-23 10:34:08 +09:00
Richard Fitzgerald dfd2ffb373
ASoC: cs35l56: Prevent overwriting firmware ASP config
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 07f7d6e7a1
("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: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 07f7d6e7a1 ("ASoC: cs35l56: Fix for initializing ASP1 mixer registers")
Link: https://msgid.link/r/20240408101803.43183-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-08 14:10:01 +01:00
Richard Fitzgerald d4884fd48a
ASoC: cs35l56: Fix unintended bus access while resetting amp
Use the new regmap_read_bypassed() so that the regmap can be left
in cache-only mode while it is booting, but the driver can still
read boot-status and chip-id information during this time.

This fixes race conditions where some writes could be issued to the
silicon while it is still rebooting, before the driver has determined
that the boot is complete.

This is typically prevented by putting regmap into cache-only until the
hardware is ready. But this assumes that the driver does not need to
access device registers to determine when it is "ready". For cs35l56
this involves polling a register and the original implementation relied
on having special handlers to block racing callbacks until dsp_work()
is complete. However, some cases were missed, most notably the ASP DAI
functions.

The regmap_read_bypassed() function allows the fix for this to be
simplified to putting regmap into cache-only during the reset. The
initial boot stages (poll HALO_STATE and read the chip ID) are all done
bypassed. Only when the amp is seen to be booted is the cache-only
revoked.

Changes are:
- cs35l56_system_reset() now leaves the regmap in cache-only status.

- cs35l56_wait_for_firmware_boot() polls using regmap_read_bypassed().

- cs35l56_init() revokes cache-only either via cs35l56_hw_init() or
  when firmware has rebooted after a soft reset.

- cs35l56_hw_init() exits cache-only after it has determined that the
  amp has booted.

- cs35l56_sdw_init() doesn't disable cache-only, since this must be
  deferred to cs35l56_init().

- cs35l56_runtime_resume_common() waits for firmware boot before exiting
  cache-only.

These changes cover three situations where the registers are not
accessible:

1) SoundWire first-time enumeration. The regmap is kept in cache-only
   until the chip is fully booted. The original code had to exit
   cache-only to read chip status in cs35l56_init() and cs35l56_hw_init()
   but this is now deferred to after the firmware has rebooted.

   In this case cs35l56_sdw_probe() leaves regmap in cache-only
   (unchanged behaviour) and cs35l56_hw_init() exits cache-only after the
   firmware is booted and the chip identified.

2) Soft reset during first-time initialization. cs35l56_init() calls
   cs35l56_system_reset(), which puts regmap into cache-only.
   On I2C/SPI cs35l56_init() then flows through to call
   cs35l56_wait_for_firmware_boot() and exit cache-only. On SoundWire
   the re-enumeration will enter cs35l56_init() again, which then drops
   down to call cs35l56_wait_for_firmware_boot() and exit cache-only.

3) Soft reset after firmware download. dsp_work() calls
   cs35l56_system_reset(), which puts regmap into cache-only. After this
   the flow is the same as (2).

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 8a731fd37f ("ASoC: cs35l56: Move utility functions to shared file")
Link: https://msgid.link/r/20240408101803.43183-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-08 14:10:00 +01:00
Takashi Iwai f5d9ddf121 ASoC: Updates for v6.9
This has been quite a small release, there's a lot of driver specific
 cleanups and minor enhancements but hardly anything on the core and only
 one new driver.  Highlights include:
 
  - SoundWire support for AMD ACP 6.3 systems.
  - Support for reporting version information for AVS firmware.
  - Support DSPless mode for Intel Soundwire systems.
  - Support for configuring CS35L56 amplifiers using EFI calibration
    data.
  - Log which component is being operated on as part of power management
    trace events.
  - Support for Microchip SAM9x7, NXP i.MX95 and Qualcomm WCD939x
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmXvE1AACgkQJNaLcl1U
 h9B15Qf8CrS5zHsD54bvTcumkDgbJ8Dl9f5qz4UN/AX0mcZ1UJU6sQ0HxIGEtlPc
 26pneHV9ZA0wSPw432NBpwcfe7AsWASmKUf6S2hsj4LMvnoj75iiZum8TE71ior7
 QI9ARnNipB1tHk7Kmgs/pe+CqX3hhCVqYUI9w5fMIj05T5qwYbqCERws6JA2Uw97
 6fb5CgI2uRYTShVVmYsE/FlxXmZqNN4NnNxlVvUSM5TE3Tayf+BCEqhpwuh59Pt/
 G+mZfj3eof0HdjGPQbLRPOWQOa3bT8gmT89OlbmmMf17+975pgShBbARzkv41vk1
 ifr6muHweaDLD7gloS/HUr4JRo9Daw==
 =ZYC5
 -----END PGP SIGNATURE-----

Merge tag 'asoc-v6.9' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Updates for v6.9

This has been quite a small release, there's a lot of driver specific
cleanups and minor enhancements but hardly anything on the core and only
one new driver.  Highlights include:

 - SoundWire support for AMD ACP 6.3 systems.
 - Support for reporting version information for AVS firmware.
 - Support DSPless mode for Intel Soundwire systems.
 - Support for configuring CS35L56 amplifiers using EFI calibration
   data.
 - Log which component is being operated on as part of power management
   trace events.
 - Support for Microchip SAM9x7, NXP i.MX95 and Qualcomm WCD939x
2024-03-11 16:18:47 +01:00
Takashi Iwai 14b9e4ab71 Merge branch 'for-next' into for-linus
Prep for 6.9 merge.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-03-11 09:12:58 +01:00
Simon Trimmer afd17e6deb ASoC: cs35l56: Add support for CS35L54 and CS35L57
The CS35L54 and CS35L57 are Boosted Smart Amplifiers. The CS35L54 has
I2C/SPI control and I2S/TDM audio. The CS35L57 also has SoundWire
control and audio.

The hardware differences between L54, L56 and L57 do not affect the
driver control interface so they can all be handled by the same driver.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <20240308135900.603192-2-rf@opensource.cirrus.com>
2024-03-08 17:59:18 +01:00
Richard Fitzgerald cb9d8a2c6c
ASoC: cs35l56: Prevent bad sign extension in cs35l56_read_silicon_uid()
Cast u8 values to u32 when using them to build a 32-bit unsigned value
that is then stored in a u64. This avoids the possibility of a bad sign
extension where the u8 is implicitly extended to an int, thus changing it
from an unsigned to a signed value.

Whether this is a real problem is debatable, but it does no harm to
ensure that the u8 are cast to a suitable type for shifting.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e1830f66f6 ("ASoC: cs35l56: Add helper functions for amp calibration")
Link: https://msgid.link/r/20240227100042.99-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-27 12:57:29 +00:00
Richard Fitzgerald e1830f66f6
ASoC: cs35l56: Add helper functions for amp calibration
Adds some helper functions and data for applying amp calibration.

1. cs35l56_read_silicon_uid() to get the silicon ID that is used to
   search for the correct calibration data entry.

2. Add the registers for the silicon ID to the readable registers.

3. cs35l56_get_calibration() wrapper around
   cs_amp_get_efi_calibration_data()

4. cs35l56_calibration_controls() table of the firmware controls
   for calibration data.

5. Added members to struct cs35l56_base to store the calibration
   data.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240223153910.2063698-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-23 17:21:40 +00:00
Richard Fitzgerald e33625c84b
ASoC: cs35l56: Must clear HALO_STATE before issuing SYSTEM_RESET
The driver must write 0 to HALO_STATE before sending the SYSTEM_RESET
command to the firmware.

HALO_STATE is in DSP memory, which is preserved across a soft reset.
The SYSTEM_RESET command does not change the value of HALO_STATE.
There is period of time while the CS35L56 is resetting, before the
firmware has started to boot, where a read of HALO_STATE will return
the value it had before the SYSTEM_RESET. If the driver does not
clear HALO_STATE, this would return BOOT_DONE status even though the
firmware has not booted.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 8a731fd37f ("ASoC: cs35l56: Move utility functions to shared file")
Link: https://msgid.link/r/20240216140535.1434933-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-19 16:58:02 +00:00
Richard Fitzgerald 727b943263
ASoC: cs35l56: Remove default from IRQ1_CFG register
The driver never uses the IRQ1_CFG register so there's no need to provide
a default value. It's set as a readable register only for debugging
through the regmap registers file.

A system-specific firmware could overwrite this register with a non-default
value. Therefore the driver can't hardcode what the initial value actually
is. As the register is only for debugging the value can be left unknown
until someone wants to read it through debugfs.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240209145700.1555950-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-09 15:22:54 +00:00
Richard Fitzgerald 245eeff18d
ASoC: cs35l56: Load tunings for the correct speaker models
If the "spk-id-gpios" property is present it points to GPIOs whose
value must be used to select the correct bin file to match the
speakers.

Some manufacturers use multiple sources of speakers, which need
different tunings for best performance. On these models the type of
speaker fitted is indicated by the values of one or more GPIOs. The
number formed by the GPIOs identifies the tuning required.

The speaker ID must be used in combination with the subsystem ID
(either from PCI SSID or cirrus,firmware-uid property), because the
GPIOs can only indicate variants of a specific model.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 1a1c3d794e ("ASoC: cs35l56: Use PCI SSID as the firmware UID")
Link: https://msgid.link/r/20240129162737.497-14-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:25 +00:00
Richard Fitzgerald f4ef514995
ASoC: cs35l56: Firmware file must match the version of preloaded firmware
Check during initialization whether the firmware is already patched.
If so, include the firmware version in the wm_adsp fwf_name string.

If the firmware has already been patched by the BIOS the driver
can only replace it if it has control of hard RESET.

If the driver cannot replace the firmware, it can still load a wmfw
(for ALSA control definitions) and/or a bin (for additional tunings).
But these must match the version of firmware that is running on the
CS35L56.

The firmware is pre-patched if FIRMWARE_MISSING == 0.

Including the firmware version in the fwf_name string will
qualify the firmware file name:

Normal (unpatched or replaceable firmware):
  cs35l56-rev-dsp1-misc[-system_name].[wmfw|bin]

Preloaded firmware:
  cs35l56-rev[-s]-VVVVVV-dsp1-misc[-system_name].[wmfw|bin]

Where:
   [-s] is an optional -s added into the name for a secured CS35L56
   VVVVVV is the 24-bit firmware version in hexadecimal.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 608f1b0dbd ("ASoC: cs35l56: Move DSP part string generation so that it is done only once")
Link: https://msgid.link/r/20240129162737.497-13-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:24 +00:00
Richard Fitzgerald 07f7d6e7a1
ASoC: cs35l56: Fix for initializing ASP1 mixer registers
Defer initializing the state of the ASP1 mixer registers until
the firmware has been downloaded and rebooted.

On a SoundWire system the ASP is free for use as a chip-to-chip
interconnect. This can be either for the firmware on multiple
CS35L56 to share reference audio; or as a bridge to another
device. If it is a firmware interconnect it is owned by the
firmware and the Linux driver should avoid writing the registers.
However, if it is a bridge then Linux may take over and handle
it as a normal codec-to-codec link. Even if the ASP is used
as a firmware-firmware interconnect it is useful to have
ALSA controls for the ASP mixer. They are at least useful for
debugging.

CS35L56 is designed for SDCA and a generic SDCA driver would
know nothing about these chip-specific registers. So if the
ASP is being used on a SoundWire system the firmware sets up the
ASP mixer registers. This means that we can't assume the default
state of these registers. But we don't know the initial state
that the firmware set them to until after the firmware has been
downloaded and booted, which can take several seconds when
downloading multiple amps.

DAPM normally reads the initial state of mux registers during
probe() but this would mean blocking probe() for several seconds
until the firmware has initialized them. To avoid this, the
mixer muxes are set SND_SOC_NOPM to prevent DAPM trying to read
the register state. Custom get/set callbacks are implemented for
ALSA control access, and these can safely block waiting for the
firmware download.

After the firmware download has completed, the state of the
mux registers is known so a work job is queued to call
snd_soc_dapm_mux_update_power() on each of the mux widgets.

Backport note:
This won't apply cleanly to kernels older than v6.6.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e496112529 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
Link: https://msgid.link/r/20240129162737.497-11-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:23 +00:00
Richard Fitzgerald 782e6c538b
ASoC: cs35l56: Fix default SDW TX mixer registers
Patch the SDW TX mixer registers to silicon defaults.

CS35L56 is designed for SDCA and a generic SDCA driver would
know nothing about these chip-specific registers. So the
firmware sets up the SDW TX mixer registers to whatever audio
is relevant on a specific system.

This means that the driver cannot assume the initial values
of these registers. But Linux has ALSA controls to configure
routing, so the registers can be patched to silicon default and
the ALSA controls used to select what audio to feed back to the
host capture path.

Backport note:
This won't apply to kernels older than v6.6.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e496112529 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
Link: https://msgid.link/r/20240129162737.497-9-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:21 +00:00
Richard Fitzgerald 72a77d7631
ASoC: cs35l56: Fix to ensure ASP1 registers match cache
Add a dummy SUPPLY widget connected to the ASP that forces the
chip registers to match the regmap cache when the ASP is
powered-up.

On a SoundWire system the ASP is free for use as a chip-to-chip
interconnect. This can be either for the firmware on multiple
CS35L56 to share reference audio; or as a bridge to another
device. If it is a firmware interconnect it is owned by the
firmware and the Linux driver should avoid writing the registers.
However. If it is a bridge then Linux may take over and handle
it as a normal codec-to-codec link.

CS35L56 is designed for SDCA and a generic SDCA driver would
know nothing about these chip-specific registers. So if the
ASP is being used on a SoundWire system the firmware sets up the
ASP registers. This means that we can't assume the default
state of the ASP registers. But we don't know the initial state
that the firmware set them to until after the firmware has been
downloaded and booted, which can take several seconds when
downloading multiple amps.

To avoid blocking probe() for several seconds waiting for the
firmware, the silicon defaults are assumed. This allows the machine
driver to setup the ASP configuration during probe() without being
blocked. If the ASP is hooked up and used, the SUPPLY widget
ensures that the chip registers match what was configured in the
regmap cache.

If the machine driver does not hook up the ASP, it is assumed that
it won't call any functions to configure the ASP DAI. Therefore
the regmap cache will be clean for these registers so a
regcache_sync() will not overwrite the chip registers. If the
DAI is not hooked up, the dummy SUPPLY widget will not be
invoked so it will never force-overwrite the chip registers.

Backport note:
This won't apply cleanly to kernels older than v6.6.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e496112529 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
Link: https://msgid.link/r/20240129162737.497-8-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:20 +00:00
Richard Fitzgerald 3739cc0733
ASoC: cs35l56: Remove buggy checks from cs35l56_is_fw_reload_needed()
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: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 8a731fd37f ("ASoC: cs35l56: Move utility functions to shared file")
Link: https://msgid.link/r/20240129162737.497-7-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-01 12:57:19 +00:00
Simon Trimmer 3df761bdbc
ASoC: cs35l56: Wake transactions need to be issued twice
As the dummy wake is a toggling signal (either I2C or SPI activity) it
is not guaranteed to meet the minimum asserted hold time for a wake
signal. In this case the wake must guarantee rising edges separated by
at least the minimum hold time.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231006111039.101914-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-10-06 12:30:27 +01:00
Simon Trimmer a47cf4dac7
ASoC: cs35l56: Change hibernate sequence to use allow auto hibernate
If the hardware uses SPI_MOSI, I2C_SCL or I2C_SDA as the wake source
the bus activity of sending HIBERNATE_NOW will wake up the amps that
were already put into hibernate.

ALLOW_AUTO_HIBERNATE tells the firmware to hibernate itself after a
timeout of a few seconds, giving the driver instances time to send this
before any amps have gone into hibernate.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231006111039.101914-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-10-06 12:30:26 +01:00
Simon Trimmer c98a0a83dc
ASoC: cs35l56: Initialise a variable to silence possible static analysis error
read_poll_timeout() is a macro and val will be populated before use,
however some static analysis tools treat it as a function and warn of
uninitialised variable usage.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231004144203.151775-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-10-04 16:09:15 +01:00
Simon Trimmer 06afec5c98
ASoC: cs35l56: Waiting for firmware to boot must be tolerant of I/O errors
Ignore failure to read from the cs35l56 when polling as the device will
NAK i2c accesses until it has booted and this would terminate the poll
of regmap_read_poll_timeout().

Fixes: 8a731fd37f ("ASoC: cs35l56: Move utility functions to shared file")
Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com
Link: https://lore.kernel.org/r/20230829160433.2647889-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-08-29 20:12:38 +01:00
Simon Trimmer 444dfa0912
ASoC: cs35l56: Make a common function to shutdown the DSP
Move issuing of a CS35L56_MBOX_CMD_SHUTDOWN command and then waiting for
the DSP to reach CS35L56_HALO_STATE_SHUTDOWN in the register appropriate
for the hardware revision into a common function.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-10-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:22 +01:00
Simon Trimmer f32a2bcbc0
ASoC: cs35l56: Make common function for control port wait
Move the waits for CS35L56_CONTROL_PORT_READY_US into a common
function, and also allow a wider range of allowed wait times.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-9-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:21 +01:00
Richard Fitzgerald 84851aa055
ASoC: cs35l56: Move part of cs35l56_init() to shared library
Part of the initialization code in cs35l56_init() can be re-used
by the HDA driver so move it into a new function in the shared
library.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-8-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:20 +01:00
Richard Fitzgerald 22e51dbb25
ASoC: cs35l56: Move cs_dsp init into shared library
Move the code that initialized the struct cs_dsp members
into the shared library so that the HDA driver can use it.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-7-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:19 +01:00
Richard Fitzgerald 9974d5b576
ASoC: cs35l56: Move runtime suspend/resume to shared library
The majority of runtime_suspend and runtime_resume handling
doesn't have anything specific to the ASoC driver, so can be
shared by the HDA driver. Move this code into the shared
library.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-6-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:18 +01:00
Simon Trimmer 8a731fd37f
ASoC: cs35l56: Move utility functions to shared file
Move the cs35l56 utility functions into the shared file so they are
available for use in HDA.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:17 +01:00
Simon Trimmer 898673b905
ASoC: cs35l56: Move shared data into a common data structure
The ASoC and HDA drivers have structures that contain some of the same
information - instead of maintaining two locations for this data the
drivers should share a common data structure as this will enable common
utility functions to be created.

The first step is to move the location of these members in the ASoC
driver.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230721132120.5523-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-23 23:40:14 +01:00
Mark Brown b174f9cab5
ASoC: cirrus: Use the maple tree register cache
Merge series from Mark Brown <broonie@kernel.org>:

The maple tree register register cache is now able to generate multi
register writes which was the last big feature of the rbtree cache that
it didn't support so let's update drivers to use the cache with the more
modern data structure.
2023-07-19 00:25:38 +01:00
Richard Fitzgerald df4167d658
ASoC: cs35l56: Patch soft registers to defaults
The soft (firmware) registers for volume/mute/posture are not reset by
a chip soft-reset, so use a regmap patch to set them to defaults.

cs35l56_reread_firmware_registers() has been removed. Its intent was to
use whatever the firmware set as a default. But the driver now patches the
defaults to the registers.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230718144625.39634-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-18 19:46:55 +01:00
Mark Brown faa48c9bda
ASoC: cs35l56: Update to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache. In
v6.5 it has also acquired the ability to generate multi-register writes in
sync operations, bringing performance up to parity with the rbtree cache
there.

Update the cs35l56 driver to use the more modern data structure.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230713-asoc-cirrus-maple-v1-4-a62651831735@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-18 14:45:05 +01:00
Richard Fitzgerald d29a966b72
ASoC: cs35l56: Rename mixer source defines for SoundWire DP1
Rename the mixer source defines from CS35L56_INPUT_SRC_SWIRE_RXn
to CS35L56_INPUT_SRC_SWIRE_DP1_CHANNELn to match the latest
datasheet.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230418144309.1100721-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-18 17:09:16 +01:00
Richard Fitzgerald d3a4efb334
ASoC: cs35l56: Remove SDW2RX1 mixer source
The mixer source index value for SDW2RX1 is different between
A1 and B0 silicon. As the driver doesn't provide a DAI for SDW2
just remove it as a mixer source option.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230418144309.1100721-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-18 17:09:15 +01:00
Richard Fitzgerald 5ab28c78a1
ASoC: cs35l56: Remove SDW1 TX5 and TX6
Reduce SDW1 to 4 channels and remove the controls for SDW1
TX5 and TX6.

The TX5 and TX6 channels have been removed from B0 silicon.
There is no need to support them on A1 silicon.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230418144309.1100721-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-18 17:09:14 +01:00
Richard Fitzgerald e496112529
ASoC: cs35l56: Add driver for Cirrus Logic CS35L56
The CS35L56 combines a high-performance mono audio amplifier, Class-H
tracking inductive boost converter, Halo Core(TM) DSP and a DC-DC boost
converter supporting Class-H tracking.

Supported control interfaces are I2C, SPI or SoundWire.
Supported audio interfaces are I2S/TDM or SoundWire.

Most chip functionality is controlled by on-board ROM firmware that is
always running. The driver must apply patch/tune to the firmware
before using the CS35L56.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230320112245.115720-9-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-21 12:13:24 +00:00