Commit graph

10 commits

Author SHA1 Message Date
Martin Povišer
fb1847cc46
ASoC: apple: mca: Improve handling of unavailable DMA channels
When we fail to obtain a DMA channel, don't return a blanket -EINVAL,
instead return the original error code if there's one. This makes
deferring work as it should. Also don't print an error message for
-EPROBE_DEFER.

Fixes: 4ec8179c21 ("ASoC: apple: mca: Postpone requesting of DMA channels")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20230224153302.45365-3-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-24 16:31:20 +00:00
Martin Povišer
d8b3e39608
ASoC: apple: mca: Fix SERDES reset sequence
Fix the reset sequence of reads and writes that we invoke from within
the early trigger. It looks like there never was a SERDES_CONF_SOME_RST
bit that should be involved in the reset sequence, and its presence in
the driver code is a mistake from earlier.

Instead, the reset sequence should go as follows: We should switch the
the SERDES unit's SYNC_SEL mux to the value of 7 (so outside the range
of 1...6 representing cluster's SYNCGEN units), then raise the RST bit
in SERDES_STATUS and wait for it to clear.

Properly resetting the SERDES unit fixes frame desynchronization hazard
in case of long frames (longer than 4 used slots). The desynchronization
manifests itself by rotating the PCM channels.

Fixes: 3df5d0d972 ("ASoC: apple: mca: Start new platform driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20230224153302.45365-2-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-24 16:31:19 +00:00
Martin Povišer
aaf5f0d76b
ASoC: apple: mca: Fix final status read on SERDES reset
From within the early trigger we are doing a reset of the SERDES unit,
but the final status read is on a bad address. Add the missing SERDES
unit offset in calculation of the address.

Fixes: 3df5d0d972 ("ASoC: apple: mca: Start new platform driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20230224153302.45365-1-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-24 16:31:18 +00:00
Martin Povišer
db6ae79a7e
ASoC: apple: mca: Adjust timing of component unregister
On removal of the driver, the ASoC component should be unregistered
first, before we start releasing any of the other resources.

Fixes: 3df5d0d972 ("ASoC: apple: mca: Start new platform driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220927113426.49724-3-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-27 13:59:59 +01:00
Martin Povišer
e92e50e426
ASoC: apple: mca: Remove stale release of DMA channels
The commit 4ec8179c21 ("ASoC: apple: mca: Postpone requesting of DMA
channels") shuffled around with the requesting and releasing of DMA
channels. It left behind stale release calls from within
apple_mca_release, remove those now.

Fixes: 4ec8179c21 ("ASoC: apple: mca: Postpone requesting of DMA channels")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220927113426.49724-2-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-27 13:59:58 +01:00
Martin Povišer
d584e73e73
ASoC: apple: mca: Trigger, not deassert, the peripheral reset
Replace the deassertion of the peripheral's shared reset with the
triggering of a pulse on it. This is what we should have been using all
along as the platform's custom is not leaving the reset asserted on
unused peripherals.

Fixes: 3df5d0d972 ("ASoC: apple: mca: Start new platform driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220927113426.49724-1-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-27 13:59:57 +01:00
Martin Povišer
4ec8179c21
ASoC: apple: mca: Postpone requesting of DMA channels
Move the requesting of DMA channels further down from 'probe' to
'pcm_new'. This is to spare the allocated DMA channel resources as we
typically only ever use one or two of the clusters for PCM streaming.
Before we would request DMA channels for all clusters.

(This is prompted by a change in the Audio DMA Controller driver, which
will now be allocating cache SRAM to channels.)

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220905074030.1293-1-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-05 13:09:41 +01:00
Martin Povišer
7d2497b7fd
ASoC: apple: mca: Unselect COMMON_CLK in Kconfig
The MCA driver selects COMMON_CLK, which leads to misconfiguration
on platforms with HAVE_LEGACY_CLK (under compile test). Kconfig catches
the conflict with the following warning:

  WARNING: unmet direct dependencies detected for COMMON_CLK
  Depends on [n]: !HAVE_LEGACY_CLK [=y]
  Selected by [m]:
  - SND_SOC_APPLE_MCA [=m] && SOUND [=m] && !UML && SND [=m] &&
    SND_SOC [=m] && (ARCH_APPLE || COMPILE_TEST [=y])

Eventually the build fails with errors like:

>> drivers/clk/clk.c:867:6: error: redefinition of 'clk_unprepare'
     867 | void clk_unprepare(struct clk *clk)
         |      ^~~~~~~~~~~~~
   In file included from drivers/clk/clk.c:9:
   include/linux/clk.h:303:20: note: previous definition of 'clk_unprepare' with type 'void(struct clk *)'
     303 | static inline void clk_unprepare(struct clk *clk)
         |                    ^~~~~~~~~~~~~

which appears to be because COMMON_CLK is selected but HAVE_CLK_PREPARE
is not. In the end it seems we had no business selecting COMMON_CLK from
an unrelated driver like that, so remove the selection. The linux/clk.h
API is there anyway.

Fixes: 3df5d0d972 ("ASoC: apple: mca: Start new platform driver")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220901113415.27449-1-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-01 12:49:21 +01:00
Martin Povišer
4065f0b25b
ASoC: apple: mca: Add locking
In DAI ops, accesses to the native cluster (of the DAI), and to data of
clusters related to it by a DPCM frontend-backend link, should have
been synchronized by the 'pcm_mutex' lock at ASoC level.

What is not covered are the 'port_driver' accesses on foreign clusters
to which the current cluster has no a priori relation, so fill in
locking for that. (This should only matter in bizarre configurations of
sharing one MCA peripheral between ASoC cards.)

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220824160715.95779-5-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-25 13:51:35 +01:00
Martin Povišer
3df5d0d972
ASoC: apple: mca: Start new platform driver
Add ASoC platform driver for the MCA peripheral found on Apple M1 and
other chips.

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220824160715.95779-4-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-25 13:51:34 +01:00