platform/kernel/linux-starfive.git
18 months agoASoC: Intel: soc-acpi-byt: Fix "WM510205" match no longer working
Hans de Goede [Fri, 21 Apr 2023 18:37:14 +0000 (20:37 +0200)]
ASoC: Intel: soc-acpi-byt: Fix "WM510205" match no longer working

Commit 7e1d728a94ca ("ASoC: Intel: soc-acpi-byt: Add new WM5102 ACPI HID")
added an extra HID to wm5102_comp_ids.codecs, but it forgot to bump
wm5102_comp_ids.num_codecs, causing the last codec HID in the codecs list
to no longer work.

Bump wm5102_comp_ids.num_codecs to fix this.

Fixes: 7e1d728a94ca ("ASoC: Intel: soc-acpi-byt: Add new WM5102 ACPI HID")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230421183714.35186-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: max98090: make it selectable
Maxim Kochetkov [Fri, 21 Apr 2023 21:19:50 +0000 (00:19 +0300)]
ASoC: max98090: make it selectable

There is no way to select max98090 from menuconfig right now.
Add a Kconfig menu description to allow building the driver standalone.
It will allow this codec to be used by any other I2S master without
adding extra sound card entry in Kconfig.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Link: https://lore.kernel.org/r/20230421211950.20972-1-fido_max@inbox.ru
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: imx-audmix: remove dummy dai_link->platform
Kuninori Morimoto [Fri, 21 Apr 2023 00:11:31 +0000 (00:11 +0000)]
ASoC: fsl: imx-audmix: remove dummy dai_link->platform

Dummy dai_link->platform is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Tested-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/877cu6f619.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: imx-audmix: cleanup platform which is using Generic DMA
Kuninori Morimoto [Fri, 21 Apr 2023 00:11:21 +0000 (00:11 +0000)]
ASoC: fsl: imx-audmix: cleanup platform which is using Generic DMA

If CPU is using soc-generic-dmaengine-pcm, Platform Component will be
same as CPU Component. In this case, we can use CPU dlc for Platform dlc.
This patch shares CPU dlc with Platform, and add comment.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Tested-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/878remf61j.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: imx-spdif: cleanup platform which is using Generic DMA
Kuninori Morimoto [Fri, 21 Apr 2023 00:11:07 +0000 (00:11 +0000)]
ASoC: fsl: imx-spdif: cleanup platform which is using Generic DMA

If CPU is using soc-generic-dmaengine-pcm, Platform Component will be
same as CPU Component. In this case, we can use CPU dlc for Platform dlc.
This patch shares CPU dlc with Platform, and add comment.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Tested-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/87a5z2f61w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: imx-es8328: cleanup platform which is using Generic DMA
Kuninori Morimoto [Fri, 21 Apr 2023 00:10:56 +0000 (00:10 +0000)]
ASoC: fsl: imx-es8328: cleanup platform which is using Generic DMA

If CPU is using soc-generic-dmaengine-pcm, Platform Component will be
same as CPU Component. In this case, we can use CPU dlc for Platform dlc.
This patch shares CPU dlc with Platform, and add comment.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Tested-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/87bkjif628.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: pcm/Intel: Pause-resume improvements for
Mark Brown [Thu, 20 Apr 2023 13:49:35 +0000 (14:49 +0100)]
ASoC: SOF: pcm/Intel: Pause-resume improvements for

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

Last minute patch for correct the pasue/resume operation with IPC4.  The
issues are hardto reproduce and needs extended stress testing to be hit,
in which case the audio breaks due to DMA errors.

18 months agoASoC: SOF: add no_reply IPC calls
Mark Brown [Thu, 20 Apr 2023 13:49:29 +0000 (14:49 +0100)]
ASoC: SOF: add no_reply IPC calls

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

Simplify IPC messages to avoid passing a reply structure that is not
used later.

18 months agoASoC: Intel: boards: updates for 6.4
Mark Brown [Thu, 20 Apr 2023 13:49:22 +0000 (14:49 +0100)]
ASoC: Intel: boards: updates for 6.4

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

Preparation of ALC712 support with different types of SoundWire
devices per link, new RaptorLake SoundWire device, better error
handling for Cirrus devices and cosmetic changes for Max98373.

Bard Liao (3):
  ASoC: Intel: sof_sdw: set codec_num = 1 if the device is not
    aggregated
  ASoC: Intel: sof_sdw: support different devices on the same sdw link
  ASoC: Intel: sof_sdw: append codec type to dai link name

Curtis Malainey (1):
  ASoC: Intel: sof_cirrus_common: Guard against missing buses

Yong Zhi (2):
  ASoC: Intel: sof_sdw: remove late_probe flag in struct
    sof_sdw_codec_info
  ASoC: Intel: sof_sdw_max98373: change sof_sdw_mx8373_late_probe to
    static call

apoorv (1):
  ASoC: Intel: soc-acpi: Add entry for rt711-sdca-sdw at link 2 in RPL
    match table

 sound/soc/intel/boards/sof_cirrus_common.c    |   7 +-
 sound/soc/intel/boards/sof_sdw.c              | 181 ++++++++++++------
 sound/soc/intel/boards/sof_sdw_common.h       |   3 -
 sound/soc/intel/boards/sof_sdw_max98373.c     |  22 +--
 .../intel/common/soc-acpi-intel-rpl-match.c   |  17 +-
 5 files changed, 152 insertions(+), 78 deletions(-)

--
2.37.2

18 months agoASoC: cs35l56: Remove duplicate mbox log messages
Simon Trimmer [Thu, 20 Apr 2023 10:20:43 +0000 (11:20 +0100)]
ASoC: cs35l56: Remove duplicate mbox log messages

cs35l56_mbox_send() logs a warning when sending a mbox command fails so
the callers can be simplified.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230420102043.1151830-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: es8316: Don't use ranges based register lookup for a single register
Mark Brown [Wed, 19 Apr 2023 18:45:06 +0000 (19:45 +0100)]
ASoC: es8316: Don't use ranges based register lookup for a single register

The es8316 driver uses a register range to specify the single volatile
register it has. While the cost will be in the noise this is a bunch of
overhead compared to just having a volatile_reg() callback so switch to
the callback.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230419-asoc-es8316-volatile-v1-1-2074ec93d8f1@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: Intel: Split the set_power_op for IPC3 and IPC4
Ranjani Sridharan [Thu, 20 Apr 2023 10:47:14 +0000 (13:47 +0300)]
ASoC: SOF: Intel: Split the set_power_op for IPC3 and IPC4

Suspending to S0iX with IPC3 requires the PM_GATE IPC to be sent again
to stop the DMA trace. But with IPC4, this is not needed as the trace is
stopped with the LARGE_CONFIG_SET IPC. Also, sending the MOD_D0IX IPC to
set the D0I3 state again when the DSP is in D0I3 already results in an
imbalance in PM runtime states in the firmware. So split the
set_power_state ops for IPC3 and IPC4 to avoid sending the MOD_D0IX IPC
when the DSP is already in D0I3 with IPC4.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230420104714.29573-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: pcm: Add an option to skip platform trigger during stop
Ranjani Sridharan [Thu, 20 Apr 2023 11:41:37 +0000 (14:41 +0300)]
ASoC: SOF: pcm: Add an option to skip platform trigger during stop

In the case of IPC4, a pipeline is only paused during STOP/PAUSE/SUSPEND
triggers and the FW keeps the host DMA running when a pipeline is
paused. The start/stop tests iterate through STOP/START triggers without
involving a hw_free. This means that the pipeline state will only toggle
between PAUSED (during the STOP trigger) and RUNNING (during the START
trigger). So this test should be treated in the same way as a
PAUSE_PUSH/PAUSE_RELEASE test and the DMA should be kept running when
toggling the pipeline states between PAUSED and RUNNING.

Since there is no way to tell if a STOP trigger will be followed by hw_free
or not, this patch proposes to always skip DMA stop during the STOP trigger
and handle it later during hw_free. Introduce a new flag in struct
sof_ipc_pcm_ops, delayed_platform_trigger, that will be used to ensure that
the host DMA will not be stopped during the STOP/PAUSE/RELEASE triggers
and set it for IPC4. The platform_trigger call to stop the DMA will be
invoked during PCM hw_free instead when the pipeline is reset.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230420114137.27613-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: Intel: hda: Do not stop/start DMA during pause/release
Ranjani Sridharan [Thu, 20 Apr 2023 11:41:36 +0000 (14:41 +0300)]
ASoC: SOF: Intel: hda: Do not stop/start DMA during pause/release

The FW does not pause/stop the host DMA during pause and stopping the
host DMA from the driver could result in an unknown behaviour. So, skip
triggering the HD-Audio host DMA during pause/release.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230420114137.27613-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_sdw: append codec type to dai link name
Bard Liao [Wed, 19 Apr 2023 19:55:24 +0000 (14:55 -0500)]
ASoC: Intel: sof_sdw: append codec type to dai link name

The existing sdw_sof machine driver constructs two SoundWire interfaces
by direction and sdw link id. It means that we will have exactly the
same dai link name if two dai links are on the same sdw link with the
same direction.
The new Realtek codec has two SoundWire interfaces for jack and DMIC
functions and they are treated as different codecs. To create two dai
links for jack and DMIC, we need to have different dai link names.
This patch suggests to append codec type if there are two or more
different types of devices on the same sdw bus.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_sdw: support different devices on the same sdw link
Bard Liao [Wed, 19 Apr 2023 19:55:23 +0000 (14:55 -0500)]
ASoC: Intel: sof_sdw: support different devices on the same sdw link

The existing code assumes all devices on the same soundwire link
are the same devices. eg. all rt1316. This commit removes the
assumption and supports different devices on the same soundwire link.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_sdw: set codec_num = 1 if the device is not aggregated
Bard Liao [Wed, 19 Apr 2023 19:55:22 +0000 (14:55 -0500)]
ASoC: Intel: sof_sdw: set codec_num = 1 if the device is not aggregated

We assume adr_link->num_adr = 1 if a device is not aggregated. However,
the assumption is not valid if there are different type devices on the
same soundwire link.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_sdw_max98373: change sof_sdw_mx8373_late_probe to static call
Yong Zhi [Wed, 19 Apr 2023 19:55:21 +0000 (14:55 -0500)]
ASoC: Intel: sof_sdw_max98373: change sof_sdw_mx8373_late_probe to static call

sof_sdw_mx8373_late_probe is only used in sof_sdw_max98373,
so it should be static and rename it to 'mx8373_sdw_late_probe'.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_sdw: remove late_probe flag in struct sof_sdw_codec_info
Yong Zhi [Wed, 19 Apr 2023 19:55:20 +0000 (14:55 -0500)]
ASoC: Intel: sof_sdw: remove late_probe flag in struct sof_sdw_codec_info

Just use codec_card_late_probe ptr in struct sof_sdw_codec_info
for validation check and drop late_probe variable.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: soc-acpi: Add entry for rt711-sdca-sdw at link 2 in RPL match table
apoorv [Wed, 19 Apr 2023 19:55:19 +0000 (14:55 -0500)]
ASoC: Intel: soc-acpi: Add entry for rt711-sdca-sdw at link 2 in RPL match table

RT711 sdca sdw is added with SDW2 link for RPL-P CRB platform.

Signed-off-by: apoorv <apoorv@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: Intel: sof_cirrus_common: Guard against missing buses
Curtis Malainey [Wed, 19 Apr 2023 19:55:18 +0000 (14:55 -0500)]
ASoC: Intel: sof_cirrus_common: Guard against missing buses

Even if we find a acpi device we can still be missing the physical node.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230419195524.46995-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: Use no_reply calls for TX
Curtis Malainey [Wed, 19 Apr 2023 19:40:57 +0000 (14:40 -0500)]
ASoC: SOF: Use no_reply calls for TX

Convert all existing calls that pass "NULL, 0" for reply data to the new
no_reply calls. Also convert any calls that pass in data but don't
actually parse the result.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20230419194057.42205-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: SOF: ipc: Add no reply inline calls
Curtis Malainey [Wed, 19 Apr 2023 19:40:56 +0000 (14:40 -0500)]
ASoC: SOF: ipc: Add no reply inline calls

95% of the calls inside SOF to TX an IPC don't care about a reply. Yet
the previous commit cleaned up a bunch of replies that were being
populated and then thrown away. This adds some functions so users who do
not need replies don't feel obligated to provide the space to the API.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20230419194057.42205-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: Restore configuration of platform
Shengjiu Wang [Wed, 19 Apr 2023 10:29:18 +0000 (18:29 +0800)]
ASoC: fsl: Restore configuration of platform

This reverts commit 33683cbf49b54 ("ASoC: fsl: remove unnecessary
dai_link->platform").

dai_link->platform is needed. The platform component is
"snd_dmaengine_pcm", which is registered from cpu driver,

If dai_link->platform is not assigned, then platform
component will not be probed, then there will be issue:

aplay: main:831: audio open error: Invalid argument

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1681900158-17428-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: fsl: Simplify an error message
Christophe JAILLET [Sun, 16 Apr 2023 06:29:34 +0000 (08:29 +0200)]
ASoC: fsl: Simplify an error message

dev_err_probe() already display the error code. There is no need to
duplicate it explicitly in the error message.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/c167c16a535049d56f817bbede9c9f6f0a0f4c68.1681626553.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Updates for B0 silicon
Mark Brown [Tue, 18 Apr 2023 18:08:24 +0000 (19:08 +0100)]
ASoC: cs35l56: Updates for B0 silicon

Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:

These patches make some small changes to align with the B0
silicon revision.

18 months agoASoC: cs35l56: Rename mixer source defines for SoundWire DP1
Richard Fitzgerald [Tue, 18 Apr 2023 14:43:09 +0000 (15:43 +0100)]
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>
18 months agoASoC: cs35l56: Remove SDW2RX1 mixer source
Richard Fitzgerald [Tue, 18 Apr 2023 14:43:08 +0000 (15:43 +0100)]
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>
18 months agoASoC: cs35l56: Remove SDW1 TX5 and TX6
Richard Fitzgerald [Tue, 18 Apr 2023 14:43:07 +0000 (15:43 +0100)]
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>
18 months agoASoC: cs35l56: Update comment on masking of EINT20 interrupts
Richard Fitzgerald [Tue, 18 Apr 2023 14:43:06 +0000 (15:43 +0100)]
ASoC: cs35l56: Update comment on masking of EINT20 interrupts

EINT20 contains wake-source interrupts and also interface-blocked
interrupts, which all default to unmasked after reset or wake.

The comment in cs35l56_init() only mentioned the wake interrupts.
Update the comment so it's clear that it's intentional to also
mask the *_BLOCKED interrupts.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230418144309.1100721-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: codecs: wcd938x: Simplify with dev_err_probe
Krzysztof Kozlowski [Tue, 18 Apr 2023 07:46:30 +0000 (09:46 +0200)]
ASoC: codecs: wcd938x: Simplify with dev_err_probe

Replace dev_err() in probe() path with dev_err_probe() to:
1. Make code a bit simpler and easier to read,
2. Do not print messages on deferred probe.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230418074630.8681-4-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: codecs: wcd934x: Simplify &pdev->dev in probe
Krzysztof Kozlowski [Tue, 18 Apr 2023 07:46:29 +0000 (09:46 +0200)]
ASoC: codecs: wcd934x: Simplify &pdev->dev in probe

The probe already stores pointer to &pdev->dev, so use it to make the
code a bit easier to read.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230418074630.8681-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: codecs: wcd934x: Simplify with dev_err_probe
Krzysztof Kozlowski [Tue, 18 Apr 2023 07:46:28 +0000 (09:46 +0200)]
ASoC: codecs: wcd934x: Simplify with dev_err_probe

Replace dev_err() in probe() path with dev_err_probe() to:
1. Make code a bit simpler and easier to read,
2. Do not print messages on deferred probe.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230418074630.8681-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: dt-bindings: wm8728: Convert to dtschema
Saalim Quadri [Mon, 17 Apr 2023 20:43:23 +0000 (20:43 +0000)]
ASoC: dt-bindings: wm8728: Convert to dtschema

Convert the WM8728 audio CODEC bindings to DT schema

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230417204323.137681-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: nau8825: fix bounds check for adc_delay
Tom Rix [Tue, 18 Apr 2023 12:09:55 +0000 (08:09 -0400)]
ASoC: nau8825: fix bounds check for adc_delay

clang build reports
sound/soc/codecs/nau8825.c:2826:31: error: overlapping comparisons
  always evaluate to false [-Werror,-Wtautological-overlap-compare]
        if (nau8825->adc_delay < 125 && nau8825->adc_delay > 500)
            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a bug, a logical-or should have been used.

Fixes: fc0b096c9291 ("ASoC: nau8825: Add delay control for input path")
Signed-off-by: Tom Rix <trix@redhat.com>
Acked-by: David Lin <CTLIN0@nuvoton.com>
Link: https://lore.kernel.org/r/20230418120955.3230705-1-trix@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: codecs: wcd9335: Simplify with dev_err_probe
Krzysztof Kozlowski [Mon, 17 Apr 2023 14:14:50 +0000 (16:14 +0200)]
ASoC: codecs: wcd9335: Simplify with dev_err_probe

Code can be a bit simpler with dev_err_probe().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230417141453.919158-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: dt-bindings: wm8737: Convert to dtschema
Saalim Quadri [Mon, 17 Apr 2023 21:24:00 +0000 (21:24 +0000)]
ASoC: dt-bindings: wm8737: Convert to dtschema

Convert the WM8737 audio CODEC bindings to DT schema

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230417212400.161796-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Code improvements
Mark Brown [Mon, 17 Apr 2023 20:26:56 +0000 (21:26 +0100)]
ASoC: cs35l56: Code improvements

Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:

Various code improvements. These remove redundant code and
clean up less-than-optimal original implementations.

18 months agoASoC: fsl_mqs: move of_node_put() to the correct location
Liliang Ye [Mon, 3 Apr 2023 15:26:47 +0000 (23:26 +0800)]
ASoC: fsl_mqs: move of_node_put() to the correct location

of_node_put() should have been done directly after
mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
otherwise it creates a reference leak on the success path.

To fix this, of_node_put() is moved to the correct location, and change
all the gotos to direct returns.

Fixes: a9d273671440 ("ASoC: fsl_mqs: Fix error handling in probe")
Signed-off-by: Liliang Ye <yll@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/20230403152647.17638-1-yll@hust.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cleanup mutex lock
Mark Brown [Mon, 17 Apr 2023 19:12:43 +0000 (20:12 +0100)]
ASoC: cleanup mutex lock

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

ASoC is using many type of mutex lock, but
some of them has helper function, but some doesn't.
Or, it has helper function, but is static.

This patch-set adds helper function and use it.

18 months agoASoC: add snd_soc_card_mutex_lock/unlock()
Kuninori Morimoto [Thu, 6 Apr 2023 00:16:27 +0000 (00:16 +0000)]
ASoC: add snd_soc_card_mutex_lock/unlock()

ASoC need to use card->mutex with _INIT or _RUNTIME,
but there is no helper function for it.

This patch adds its helper function and use it.

Because people might misunderstand that _init() is mutex initialization,
this patch renames _INIT to _ROOT and adds new
snd_soc_card_mutex_lock_root() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a5zlx3tw.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: expand snd_soc_dpcm_mutex_lock/unlock()
Kuninori Morimoto [Thu, 6 Apr 2023 00:16:10 +0000 (00:16 +0000)]
ASoC: expand snd_soc_dpcm_mutex_lock/unlock()

soc-pcm.c has snd_soc_dpcm_mutex_lock/unlock(),
but other files can't use it because it is static function.

It requests snd_soc_pcm_runtime as parameter (A), but sometimes we
want to use it by snd_soc_card (B).

(A) static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd)
{
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
}    ^^^^^^^^^

(B) mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
   ^^^^

We want to use it with both "rtd" and "card" for dapm lock/unlock.
To enable it, this patch uses _Generic macro.

This patch makes snd_soc_dpcm_mutex_{un}lock() global function, and use it on
each files.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bkk1x3ud.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: expand snd_soc_dapm_mutex_lock/unlock()
Kuninori Morimoto [Thu, 6 Apr 2023 00:15:48 +0000 (00:15 +0000)]
ASoC: expand snd_soc_dapm_mutex_lock/unlock()

soc.h has snd_soc_dapm_mutex_lock/unlock() definition and
many drivers are using it, but soc-dapm.c is not.

1st reason is snd_soc_dapm_mutex_lock/unlock() requests
snd_soc_dapm_context pointer as parameter (A), but sometimes soc-dapm.c
needs to use snd_soc_card (B).

(A) static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
{
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
}    ^^^^^^^^^^

(B) mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
   ^^^^

2nd reason is it want to use SND_SOC_DAPM_CLASS_INIT for mutex_lock_nested(),
but helper is using _RUNTIME (A).

The conclusion is we want to use "dapm vs card" and "_RUNTIME vs _INIT"
for dapm lock/unlock. To enable this selfish request, this patch uses
_Generic macro. We can use snd_soc_dapm_mutex_lock/unlock() for both
dapm and card case.

snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_unlock(dapm);
snd_soc_dapm_mutex_lock(card); snd_soc_dapm_mutex_unlock(card);

Current soc-dapm.c is using both mutex_lock() and mutex_lock_nested().
This patch handles mutex_lock() as mutex_lock_nested(..., 0),
in other words, handles below as same.

mutex_lock(&card->dapm_mutex);
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);

Because people might misunderstand that _init() is mutex initialization,
this patch renames _INIT to _ROOT and adds new
snd_soc_dapm_mutex_lock_root() for it.

This patch also moves snd_soc_dapm_subclass definition from soc-dapm.h
to soc.h to keep related code together.

Because very complex soc.h vs soc-dapm.h relationship,
it is difficult/impossible to define these helper into soc-dapm.h.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87cz4hx3v0.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: dt-bindings: wm8753: Convert to dtschema
Saalim Quadri [Fri, 14 Apr 2023 22:38:01 +0000 (22:38 +0000)]
ASoC: dt-bindings: wm8753: Convert to dtschema

Convert the WM8753 audio codec bindings to DT schema.

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230414223801.1106550-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: ssm2602: Add support for CLKDIV2
Paweł Anikiel [Fri, 14 Apr 2023 14:02:00 +0000 (16:02 +0200)]
ASoC: ssm2602: Add support for CLKDIV2

The SSM260x chips have an internal MCLK /2 divider (bit D7 in register
R8). Add logic that allows for more MCLK values using this divider.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Link: https://lore.kernel.org/r/20230414140203.707729-7-pan@semihalf.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Don't return a value from cs35l56_remove()
Simon Trimmer [Fri, 14 Apr 2023 13:37:53 +0000 (14:37 +0100)]
ASoC: cs35l56: Don't return a value from cs35l56_remove()

cs35l56_remove() always returns 0. Two of the functions that call
it are void and the other one should only return 0. So there's no
point returning anything from cs35l56_remove().

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230414133753.653139-6-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Remove redundant dsp_ready_completion
Simon Trimmer [Fri, 14 Apr 2023 13:37:52 +0000 (14:37 +0100)]
ASoC: cs35l56: Remove redundant dsp_ready_completion

dsp_ready_completion is redundant and can be replaced by a call
flush_work() to wait for cs35l56_dsp_work() to complete.

As the dsp_work is queued by component_probe() it must run before other
ASoC component callbacks and therefore there is no risk of calling
flush_work() before the dsp_work() has been queued.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230414133753.653139-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Wait for init_complete in cs35l56_component_probe()
Simon Trimmer [Fri, 14 Apr 2023 13:37:51 +0000 (14:37 +0100)]
ASoC: cs35l56: Wait for init_complete in cs35l56_component_probe()

Moving the wait from the beginning of the cs35l56_dsp_work() into
cs35l56_component_probe() will prevent the limbo situation that is an
artifact of the two stage SoundWire driver probe and initialisation
where the card is all registered and shows in ALSA but doesn't actually
work because the hardware didn't enumerate.

The other bus drivers perform the probe and init sequentially and are
not susceptible to this issue.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230414133753.653139-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Allow a wider range for reset pulse width
Simon Trimmer [Fri, 14 Apr 2023 13:37:50 +0000 (14:37 +0100)]
ASoC: cs35l56: Allow a wider range for reset pulse width

There is no reason to have such a tight usleep range of 400us and it is
acceptable to allow MIN_US * 2.

Also wrap the usleep in an inline function.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/168147949455.26.3401634900657387799@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: cs35l56: Rework IRQ allocation
Simon Trimmer [Fri, 14 Apr 2023 13:37:49 +0000 (14:37 +0100)]
ASoC: cs35l56: Rework IRQ allocation

The irq member was being set before calling the init function and then
cs35l56_irq_request() was called only when the init was successful.
However cs35l56_release() calls devm_free_irq() when the irq member is
set and therefore if init() fails then this will cause an attempted free
of an unallocated IRQ.

Instead pass the desired IRQ number to the cs35l56_irq_request()
function and set cs35l56->irq only when it has been successfully
allocated.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/168147949598.26.711670799488943454@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: nau8825: Add delay control for input path
David Lin [Fri, 14 Apr 2023 10:39:44 +0000 (18:39 +0800)]
ASoC: nau8825: Add delay control for input path

Change the original fixed delay to the assignment from property. It will make
more flexible to different platforms for avoiding pop noise at the beginning
of recording.

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Link: https://lore.kernel.org/r/20230414103941.39566-2-CTLIN0@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>
18 months agoASoC: dt-bindings: nau8825: Add delay control for input path
David Lin [Fri, 14 Apr 2023 10:39:42 +0000 (18:39 +0800)]
ASoC: dt-bindings: nau8825: Add delay control for input path

Change the original fixed delay to the assignment from property. It will make
more flexible to different platforms for avoiding pop noise at the beginning
of recording.

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Link: https://lore.kernel.org/r/20230414103941.39566-1-CTLIN0@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: da7218: Use devm_clk_get_optional()
Christophe JAILLET [Thu, 13 Apr 2023 05:28:33 +0000 (07:28 +0200)]
ASoC: da7218: Use devm_clk_get_optional()

Use devm_clk_get_optional() instead of hand writing it.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/51976b2515d7007ba5c8aa7524892f147d7cdd51.1681363691.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: da7219: Improve the relability of AAD IRQ process
David Rau [Thu, 13 Apr 2023 02:41:34 +0000 (02:41 +0000)]
ASoC: da7219: Improve the relability of AAD IRQ process

- Configure the default gound switch delay time before enabling IRQ
  to avoid the unexpected delay time is set up
- Apply DA7219 AAD own work queue to handle AAD events
- Replace msleep with queue_delayed_work to have better relability

This commit improves the control of ground switches in AAD IRQ

Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
Link: https://lore.kernel.org/r/20230413024134.8612-1-David.Rau.opensource@dm.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Add system suspend handling
Mark Brown [Wed, 12 Apr 2023 18:59:27 +0000 (19:59 +0100)]
ASoC: cs35l56: Add system suspend handling

Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:

This set of patches adds handling for system suspend.
Patches 1..4 make some code changes that simplify the
suspend implementation, mainly to avoid race conditions.

There are two seperate aspects to suspend, and these have
been done as two patches:
- the main suspend-resume handling,
- re-loading the firmware if necessary after resume.

19 months agoASoC: cs35l56: Re-patch firmware after system suspend
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:28 +0000 (16:25 +0100)]
ASoC: cs35l56: Re-patch firmware after system suspend

Check during cs35l56_system_resume() whether the firmware patch must
be applied again.

The FIRMWARE_MISSING flag in the PROTECTION_STATUS register indicates
whether the firmware has been patched.

In non-secure mode the FIRMWARE_MISSING flag is cleared at the end of
dsp_work(). If it is set after system-resume we know that dsp_work()
must be run again.

In secure mode the pre-OS loader will have done the secure patching
and cleared the FIRMWARE_MISSING flag. So this flag does not tell us
whether firmware memory was lost. But the driver could only be
downloading non-secure tunings, which is always safe to do.

If the driver has control of RESET we will have asserted it during
suspend so the firmware patch will have been lost. The driver would only
have control of RESET in non-secure mode.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/168122674550.26.8545058503709956172@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Remove quick-cancelling of dsp_work()
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:23 +0000 (16:25 +0100)]
ASoC: cs35l56: Remove quick-cancelling of dsp_work()

Delete the 'removing' flag and don't kick init_completion to make a
quick cancel of dsp_work(). Just let it timeout on the wait for the
completion.

Simplify the code to standard cancelling or flushing of the work.
This avoids introducing corner cases from a layer of custom signalling.
It also avoids potential race conditions when system-suspend handling
is added.

Unless the hardware is broken, the dsp_work() will already have started
and passed the completion before the driver would want to cancel it.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/168122674746.26.16881587647873355224@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Add basic system suspend handling
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:27 +0000 (16:25 +0100)]
ASoC: cs35l56: Add basic system suspend handling

This adds the main handling for system suspend but does not handle
re-patching the firmware after system resume.

This is a multi-stage suspend and resume because if there is a
RESET line it is almost certain that it will be shared by all the
amps. So every amp must have done its suspend before we can
assert RESET. Likewise we must de-assert RESET before the amps
can resume.

It's preferable to assert RESET before we turning off regulators, and
while they power up.

The actual suspend and resume is done by using the pair
pm_runtime_force_suspend() and pm_runtime_force_resume() to
re-use our runtime suspend/resume sequences.

pm_runtime_force_suspend() will disable our pm_runtime. If we were
runtime-resumed it calls our runtime_suspend().

pm_runtime_force_resume() re-enables pm_runtime and if we were
originally runtime-resumed before the pm_runtime_force_suspend()
it calls our runtime_resume(). Otherwise it leaves us
runtime-suspended.

The general process is therefore:

 suspend() -> finish dsp_work and then run our runtime_suspend
 suspend_late() -> assert RESET and turn off supplies
 resume_early() -> enable supplies and de-assert RESET
 resume() -> pm_runtime_force_resume()

In addition, to prevent the IRQ handler running in the period
between pm_runtime_force_suspend() and pm_runtime_force_resume()
the parent IRQ is temporarily disabled:
 - from suspend until suspend_noirq
 - from resume_noirq until resume

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230411152528.329803-6-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Always wait for firmware boot in runtime-resume
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:26 +0000 (16:25 +0100)]
ASoC: cs35l56: Always wait for firmware boot in runtime-resume

When we are resuming from a system suspend the CS35L56 has probably
been hard reset (usually a power-on reset). So we must wait for the
firmware to boot. On SoundWire we also need it to re-initialize before
we can read the registers to check the CS35L56 state.

The simplest way to handle this is for runtime-resume to always wait
for firmware boot. If the firmware is already booted the overhead is
only one register read.

The system-resume will have to runtime-resume the driver anyway before
attempting any register access. So this will automatically include the
wait for initialization on SoundWire.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230411152528.329803-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Skip first init_completion wait in dsp_work if init_done
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:25 +0000 (16:25 +0100)]
ASoC: cs35l56: Skip first init_completion wait in dsp_work if init_done

At the start of dsp_work() only wait for init_completion if !init_done.
This allows system suspend to re-queue dsp_work() without having to
do a dummy complete() of init_completion.

A dummy completion in system suspend would have to be conditional on
init_done. But that would create a possible race condition between our
system resume and cs35l56_init() in the corner case that we suspend right
after the SoundWire core has enumerated and reported ATTACHED.

It is safer and simpler to have cs35l56_init() as the only place that
init_completion is completed, and dsp_work() as the only place that
it is consumed.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230411152528.329803-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs35l56: Use DAPM widget for firmware PLAY/PAUSE
Richard Fitzgerald [Tue, 11 Apr 2023 15:25:24 +0000 (16:25 +0100)]
ASoC: cs35l56: Use DAPM widget for firmware PLAY/PAUSE

If we use a DAPM widget instead of mute_stream() to send the
PLAY command we can issue the plays to multiple amps in parallel.
With mute_stream each codec driver instance is called one at a
time so we get N * PS0 delay time.

DAPM does each stage on every widget in a card before moving to
the next stage. So all amps will do the PRE_PMU then all will do
the POST_PMU. The PLAY is sent in the PRE_PMU so that they all
power-up in parallel. After the PS0 wait in the first POST_PMU
all the other amps will also be ready so there won't be any extra
delay, or it will be negligible.

There's also no point waiting for the MBOX ack in the PRE_PMU.
We won't see a PS0 state in POST_PMU if it didn't ack the PLAY
command. So we can save a little extra time.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230411152528.329803-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: ep93xx: Add OF support
Alexander Sverdlin [Tue, 11 Apr 2023 16:59:51 +0000 (18:59 +0200)]
ASoC: ep93xx: Add OF support

Add the new cirrus,ep9301-ac97 and cirrus,ep9301-i2s compatibles.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/20230411165951.2335899-2-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: ep93xx: Add I2S description
Alexander Sverdlin [Tue, 11 Apr 2023 16:59:50 +0000 (18:59 +0200)]
ASoC: ep93xx: Add I2S description

Add device tree bindings for Cirrus Logic EP93xx internal SoCs' I2S
controller.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230411165951.2335899-1-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: amd: Add check for acp config flags
Syed Saba Kareem [Wed, 12 Apr 2023 09:16:16 +0000 (14:46 +0530)]
ASoC: amd: Add check for acp config flags

We have SOF and generic ACP support enabled for Rembrandt and
pheonix platforms on some machines. Since we have same PCI id
used for probing, add check for machine configuration flag to
avoid conflict with newer pci drivers. Such machine flag has
been initialized via dmi match on few Chrome machines. If no
flag is specified probe and register older platform device.

Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com>
Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/20230412091638.1158901-1-Syed.SabaKareem@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: tas5720: add missing unwind goto in tas5720_codec_probe
Ying Liu [Tue, 11 Apr 2023 17:09:12 +0000 (01:09 +0800)]
ASoC: tas5720: add missing unwind goto in tas5720_codec_probe

Smatch complains that missing unwind goto in tas5720_codec_probe.

When tas5720 has an invalid devtype, it is expected to invoke
regulator_bulk_disable to handle the failure. But the default
option return an error code directly. Fix it by reusing the
probe_fail label.

Signed-off-by: Ying Liu <lyre@hust.edu.cn>
Link: https://lore.kernel.org/r/20230411170912.1939906-1-lyre@hust.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: mtl: fix page fault in dspless mode when DSP is disabled
Fred Oh [Wed, 12 Apr 2023 06:14:57 +0000 (09:14 +0300)]
ASoC: SOF: Intel: mtl: fix page fault in dspless mode when DSP is disabled

The patch to make DSPless mode work even if the DSP is
disabled in BIOS missed to touch the MTL code to add
the needed checks.
If the DSP is disabled this can lead to page fault due to not
accesible registers.

Fixes: 9fc6786f549c ("ASoC: SOF: Intel: hda: make DSPless mode work with DSP disabled in BIOS")
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230412061457.27937-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: amd: yc: Add ThinkBook 14 G5+ ARP to quirks list for acp6x
Baishan Jiang [Wed, 12 Apr 2023 08:40:43 +0000 (16:40 +0800)]
ASoC: amd: yc: Add ThinkBook 14 G5+ ARP to quirks list for acp6x

ThinkBook 14 G5+ ARP uses Ryzen 7735H processor, and has the same
microphone problem as ThinkBook 14 G4+ ARA.

Adding 21HY to acp6x quirks table enables microphone for ThinkBook
14 G5+ ARP.

Signed-off-by: Baishan Jiang <bjiang400@outlook.com>
Link: https://lore.kernel.org/r/OS3P286MB1711DD6556284B69C79C0C4FE19B9@OS3P286MB1711.JPNP286.PROD.OUTLOOK.COM
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: HDaudio multi-link
Mark Brown [Tue, 11 Apr 2023 18:47:17 +0000 (19:47 +0100)]
ASoC: SOF: Intel: hda-mlink: HDaudio multi-link

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

The following series adds the core support to handle the recently updated
HDaudio multi-link support to hanlde non HDA links, like SoundWire/DMIC/SSP on
Intel platform.

For details, please see the first patch which documents the current mlink
support (introduced at Skylake) and the new extensions, arriving with LNL.

There is no change in functionality for existing HDA support, the extension is
backwards compatible with existing implementations.

19 months agoASoC: dt-bindings: wm8523: Convert to dtschema
Saalim Quadri [Wed, 5 Apr 2023 20:34:19 +0000 (02:04 +0530)]
ASoC: dt-bindings: wm8523: Convert to dtschema

Convert the WM8523 audio CODEC bindings to DT schema

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Link: https://lore.kernel.org/r/20230405203419.5621-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: dt-bindings: wm8711: Convert to dtschema
Saalim Quadri [Wed, 5 Apr 2023 20:58:20 +0000 (02:28 +0530)]
ASoC: dt-bindings: wm8711: Convert to dtschema

Convert the WM8711 audio CODEC bindings to DT schema

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230405205820.6836-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: dt-bindings: wm8580: Convert to dtschema
Saalim Quadri [Wed, 5 Apr 2023 20:50:25 +0000 (02:20 +0530)]
ASoC: dt-bindings: wm8580: Convert to dtschema

Convert the WM8580 and WM8581 audio CODEC bindings to DT schema

Signed-off-by: Saalim Quadri <danascape@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230405205025.6448-1-danascape@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: ep93xx: Prepare for DT transition
Mark Brown [Tue, 11 Apr 2023 14:17:18 +0000 (15:17 +0100)]
ASoC: ep93xx: Prepare for DT transition

Merge series from Alexander Sverdlin <alexander.sverdlin@gmail.com>:

This is a preparatory series for EP93xx transition to DT. This patchset is
a pre-requisite and has been tested with the full DT patchset [1].

[1]. git://git.maquefel.me/linux.git branch ep93xx/6.2-rc4-v0

Alexander Sverdlin (3):
  ASoC: ep93xx: i2s: move enable call to startup callback
  ASoC: cs4271: flat regcache, trivial simplifications
  ASoC: ep93xx: i2s: Make it individually selectable

 sound/soc/cirrus/Kconfig      |  6 +++++-
 sound/soc/cirrus/ep93xx-i2s.c | 12 +++++++++++-
 sound/soc/codecs/cs4271-i2c.c |  1 -
 sound/soc/codecs/cs4271-spi.c |  1 -
 sound/soc/codecs/cs4271.c     |  4 ++--
 5 files changed, 18 insertions(+), 6 deletions(-)

--
2.40.0

19 months agoASoC: mediatek: common: Fix refcount leak in parse_dai_link_info
Aashish Sharma [Tue, 11 Apr 2023 00:34:31 +0000 (06:04 +0530)]
ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info

Add missing of_node_put()s before the returns to balance
of_node_get()s and of_node_put()s, which may get unbalanced
in case the for loop 'for_each_available_child_of_node' returns
early.

Fixes: 4302187d955f ("ASoC: mediatek: common: add soundcard driver common code")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/
Signed-off-by: Aashish Sharma <shraash@google.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20230411003431.4048700-1-shraash@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: amd: Add Dell G15 5525 to quirks list
Cem Kaya [Mon, 10 Apr 2023 18:38:15 +0000 (20:38 +0200)]
ASoC: amd: Add Dell G15 5525 to quirks list

Add Dell G15 5525 Ryzen Edition to quirks list for acp6x so that
internal mic works.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217155
Signed-off-by: Cem Kaya <cemkaya.boun@gmail.com>
Link: https://lore.kernel.org/r/20230410183814.260518-1-cemkaya.boun@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: ep93xx: i2s: Make it individually selectable
Alexander Sverdlin [Mon, 10 Apr 2023 22:39:02 +0000 (00:39 +0200)]
ASoC: ep93xx: i2s: Make it individually selectable

This is necessary to replace EDB93XX specific SoC audio driver with generic
"simple-audio-card".

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/20230410223902.2321834-4-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: cs4271: flat regcache, trivial simplifications
Alexander Sverdlin [Mon, 10 Apr 2023 22:39:01 +0000 (00:39 +0200)]
ASoC: cs4271: flat regcache, trivial simplifications

- Switch to REGCACHE_FLAT, the whole overhead of RBTREE is not worth it
  with non sparse register set in the address range 1..7.
- Move register width to central location

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/20230410223902.2321834-3-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: ep93xx: i2s: move enable call to startup callback
Alexander Sverdlin [Mon, 10 Apr 2023 22:39:00 +0000 (00:39 +0200)]
ASoC: ep93xx: i2s: move enable call to startup callback

Make startup/shutdown callbacks symmetric to avoid clock subsystem warnings
(reproduced with "aplay --dump-hw-params" + ctrl-c):

WARNING: CPU: 0 PID: 102 at drivers/clk/clk.c:1048 clk_core_disable
lrclk already disabled
CPU: 0 PID: 102 Comm: aplay Not tainted 6.2.0-rc4 #1
Hardware name: Generic DT based system
 ...
 clk_core_disable from clk_core_disable_lock
 clk_core_disable_lock from ep93xx_i2s_shutdown
 ep93xx_i2s_shutdown from snd_soc_dai_shutdown
 snd_soc_dai_shutdown from soc_pcm_clean
 soc_pcm_clean from soc_pcm_close
 soc_pcm_close from snd_pcm_release_substream.part.0
 snd_pcm_release_substream.part.0 from snd_pcm_release
 snd_pcm_release from __fput
 __fput from task_work_run
 ...

WARNING: CPU: 0 PID: 102 at drivers/clk/clk.c:907 clk_core_unprepare
lrclk already unprepared
CPU: 0 PID: 102 Comm: aplay Tainted: G        W          6.2.0-rc4 #1
Hardware name: Generic DT based system
 ...
 clk_core_unprepare from clk_unprepare
 clk_unprepare from ep93xx_i2s_shutdown
 ep93xx_i2s_shutdown from snd_soc_dai_shutdown
 snd_soc_dai_shutdown from soc_pcm_clean
 soc_pcm_clean from soc_pcm_close
 soc_pcm_close from snd_pcm_release_substream.part.0
 snd_pcm_release_substream.part.0 from snd_pcm_release
 snd_pcm_release from __fput
 __fput from task_work_run
 ...

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/20230410223902.2321834-2-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: dt-bindings: asahi-kasei,ak4458: fix missing quotes around hash
Krzysztof Kozlowski [Fri, 7 Apr 2023 17:00:32 +0000 (19:00 +0200)]
ASoC: dt-bindings: asahi-kasei,ak4458: fix missing quotes around hash

The yamllint expect comments to start with hash and space ('# '), so
quote the description to fix:

  asahi-kasei,ak4458.yaml:40:30: [error] missing starting space in comment (comments)

Reported-by: Rob Herring <robh@kernel.org>
Closes: https://lore.kernel.org/all/CAL_JsqJzxQb1g=yVgHduLnYOpk8-Q3jppA1qQT1Ce51_gNWjhg@mail.gmail.com/
Fixes: 009e83b591dd ("ASoC: dt-bindings: ak4458: Convert to dtschema")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230407170032.102412-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: mediatek: mt8186: set variable aud_pinctrl to static
Tom Rix [Fri, 7 Apr 2023 11:55:53 +0000 (07:55 -0400)]
ASoC: mediatek: mt8186: set variable aud_pinctrl to static

smatch reports
sound/soc/mediatek/mt8186/mt8186-afe-gpio.c:14:16: warning: symbol
  'aud_pinctrl' was not declared. Should it be static?

This variable is only used in one file so should be static.

Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20230407115553.1968111-1-trix@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-dai: Print the format_val as hexadecimal number
Peter Ujfalusi [Thu, 6 Apr 2023 15:52:19 +0000 (10:52 -0500)]
ASoC: SOF: Intel: hda-dai: Print the format_val as hexadecimal number

The format_val is a set of bitfileds, printing it as a decimal just makes
interpreting it complicated.

In other HDA core code the format_val is printed as hexadecimal also.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20230406155219.18997-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: MTL: conditionally wake WPIO1PG domain
Yong Zhi [Thu, 6 Apr 2023 15:44:54 +0000 (10:44 -0500)]
ASoC: SOF: Intel: MTL: conditionally wake WPIO1PG domain

Wake IO1 from power gating if there is SoundWire enabled link discovered
by ACPI scan.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230406154454.18163-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: Intel: Add rpl_mx98360_rt5682 driver
Curtis Malainey [Thu, 6 Apr 2023 15:37:02 +0000 (10:37 -0500)]
ASoC: Intel: Add rpl_mx98360_rt5682 driver

Boards were using this in older kernels before adl and rpl ids were
split. Add this back to maintain support.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230406153703.17194-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helper to retrieve eml_lock
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:27 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helper to retrieve eml_lock

For SoundWire usages, we need to use the global eml_lock to
serialize/protect all accesses to shared registers.  Due to the split
implementation across two subsystems, we need to pass a pointer
around.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-19-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helper to offload link ownership
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:26 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helper to offload link ownership

For DMIC and SSP, the DSP will be responsible for programming the
blobs and link registers.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-18-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helpers to retrieve DMIC/SSP hlink
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:25 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helpers to retrieve DMIC/SSP hlink

Small helpers to make DAI ops simpler.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-17-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: program SoundWire LSDIID registers
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:24 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: program SoundWire LSDIID registers

Each SoundWire peripheral can be programmed from the manager side
either with a regular command FIFO, or with the HDaudio CORB/RIRB
DMA-based mechanism. The mapping between SoundWire peripheral and SDI
address is handled with the LSDIID register.

This mapping only works of course if each peripheral has a unique
address across all links. This has already been enforced in previous
Intel contributions allowing for an IDA-based solution for the device
number allocation.

The checks on the dev_num are handled at the SoundWire level, but the
locking is handled at the hda-mlink level.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-16-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helper to check cmdsync
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:23 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helper to check cmdsync

This helper is an optimization where sync_go is only called when the
cmdsync field is actually set to a non-zero value.

Since this is also only used by SoundWire for now, only expose the
_unlocked version.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-15-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helpers for sync_arm/sync_go
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:22 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helpers for sync_arm/sync_go

The multi-link synchronization uses the same concept and registers,
but moved to the HDAudio extended links.

Add helpers for sync_arm and sync_go which are the basic for the bus
reset, bank switch and clock stop.

Since SoundWire is the only user of those helpers, only expose the
_unlocked versions for now.

Note that SYNCGO is a write-only bit, so no error can be reported. We
still return 0 for compatibility with the SoundWire stream management
headers.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-14-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helpers to set link SYNC frequency
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:21 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helpers to set link SYNC frequency

These helpers configure the ratio between the base clock and the
hardware signal used for link synchronization.

The SYNCPRD is written before the first sublink is powered-up. The
SYNCPU bit is set, but it will only be cleared after the link is
powered-up, hence the implementation with a set/wait pattern.

These helpers are currently only needed by SoundWire support, where
the lock is taken at a higher level, so only the _unlocked versions
are exposed for now.

Note that the _wait_bit() implementation is similar to previous
helpers in drivers/soundwire, but with sleep duration and timeout
aligned with hardware recommendations. If desired, this helper could
be modified in a second step with e.g. readl_poll_timeout().

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-13-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helpers to enable/check interrupts
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:20 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helpers to enable/check interrupts

When INTC is set, LCTL exposes INTEN and INTSTS fields.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-12-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add helper to return sublink count
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:19 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add helper to return sublink count

This is needed for SoundWire integration.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-11-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add convenience helpers for SoundWire PM
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:18 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add convenience helpers for SoundWire PM

The updated SoundWire Intel driver will need to rely on Extended
HDaudio links for power management, but it doesn't need to be aware of
all the HDaudio structures. Add convenience helpers to avoid polluting
SoundWire drivers too much with HDaudio information.

Since the SoundWire/Intel solution already takes the lock at a higher
level, the _unlocked PM helpers are used.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-10-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: introduce helpers for 'extended links' PM
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:17 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: introduce helpers for 'extended links' PM

Add helpers to program SPA/CPA bits, using a mutex to access the
shared LCTL register if required.

All links are managed with the same LCTLx.SPA bits. However there are
quite a few implementation details to be aware of:

Legacy HDaudio multi-links are powered-up when exiting reset, which
requires the ref_count to be manually set to one when initializing the
link.

Alternate links for SoundWire/DMIC/SSP need to be explicitly
powered-up before accessing the SHIM/IP/Vendor-Specific SHIM space for
each sublink. DMIC/SSP/SoundWire are all different cases with a
different device/dai/hlink relationship.

SoundWire will handle power management with the auxiliary device
resume/suspend routine. The ref_count is not necessary in this case.

The DMIC/SSP will by contrast handle the power management from DAI
.startup and .shutdown callbacks.

The SSP has a 1:1 mapping between sublink and DAI, but it's
bidirectional so the ref_count will help avoid turning off the sublink
when one of the two directions is still in use.

The DMIC has a single link but two DAIs for data generated at
different sampling frequencies, again the ref_count will make sure the
two DAIs can be used concurrently.

And last the SoundWire Intel require power-up/down and bank switch to
be handled with a lock already taken, so the 'eml_lock' is made
optional with the _unlocked versions of the helpers.

Note that the _check_power_active() implementation is similar to
previous helpers in sound/hda/ext, with sleep duration and timeout
aligned with hardware recommendations. If desired, this helper could
be modified in a second step with .e.g. readl_poll_timeout()

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-9-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: special-case HDaudio regular links
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:16 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: special-case HDaudio regular links

For backwards compatibility, HDaudio/iDISP links are powered-on when
exiting reset, and the existing driver forces them to be powered-off
when entering S0ix. In addition, the get/put helpers are invoked
directly by the ASoC codec drivers, which a historical layering
violation.

Extended links are powered-on by software only, during the probe and
DAI startup phases. This calls for a different handling of the
'regular' and 'extended' audio links.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-8-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add structures to parse ALT links
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:15 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add structures to parse ALT links

Extend hdac_ext_link to store information needed for ALT
links. Follow-up patches will include more functional patches for
power-up and down.

Note that this patch suggests the use of an 'eml_lock' to serialize
access to shared registers. SoundWire-specific sequence require the
lock to be taken at a higher level, as a result the helpers added in
follow-up patches will provide 'unlocked' versions when needed.

Also note that the low-level sequences with the 'hdaml_' prefix are
taken directly from the hardware specifications - naming conventions
included. The code will be split in two, with locking and linked-list
management handled separately to avoid mixing required hardware setup
and Linux-based resource management.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-7-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: move to a dedicated module
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:14 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: move to a dedicated module

Some of the functions will be used for SoundWire enumeration and power
management, to avoid cycles in module dependencies and simplify
integration all the HDaudio multi-link needs to move to a dedicated
module.

Drop no longer needed headers at the same time.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-6-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: add return value for hda_bus_ml_get_capabilities()
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:13 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: add return value for hda_bus_ml_get_capabilities()

Add return value - this will need additional work in the caller.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-5-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoASoC: SOF: Intel: hda-mlink: improve hda_bus_ml_free() helper
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:12 +0000 (13:41 +0300)]
ASoC: SOF: Intel: hda-mlink: improve hda_bus_ml_free() helper

Use list_for_each_entry_safe() instead of open-coding.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-4-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoALSA: hda: add HDaudio Extended link definitions
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:11 +0000 (13:41 +0300)]
ALSA: hda: add HDaudio Extended link definitions

Add new definitions for the HDaudio Extended link support,
specifically new registers for SoundWire, Intel DMIC and INTEL SSP
interfaces.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
19 months agoDocumentation: sound: add description of Intel HDaudio multi-links
Pierre-Louis Bossart [Tue, 4 Apr 2023 10:41:10 +0000 (13:41 +0300)]
Documentation: sound: add description of Intel HDaudio multi-links

Add description of 'Skylake' multi-link structure added in 2015 and
recent extensions to support SoundWire/DMIC/SSP interfaces.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230404104127.5629-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>