Commit Graph

708 Commits

Author SHA1 Message Date
Sameer Pujar
34386d7e14 ASoC: tegra: Add Tegra186 based DSPK driver
The Digital Speaker Controller (DSPK) converts the multi-bit Pulse Code
Modulation (PCM) audio input to oversampled 1-bit Pulse Density Modulation
(PDM) output. From the signal flow perpsective, the DSPK can be viewed as
a PDM transmitter that up-samples the input to the desired sampling rate
by interpolation then converts the oversampled PCM input to the desired
1-bit output via Delta Sigma Modulation (DSM).

This patch registers DSPK component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes DSPK interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The DSPK devices can be enabled in the DT via
"nvidia,tegra186-dspk" compatible binding. This driver can be used
on Tegra194 chip as well.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-7-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:44:08 +05:30
Sameer Pujar
28e5d4400a ASoC: tegra: Add Tegra210 based AHUB driver
The Audio Hub (AHUB) comprises a collection of hardware accelerators for
audio pre/post-processing and a programmable full crossbar (XBAR) for
routing audio data across these accelerators in time and in parallel.
AHUB supports multiple interfaces to I2S, DSPK, DMIC etc., XBAR is a
switch used to configure or modify audio routing between HW accelerators
present inside AHUB.

This patch registers AHUB component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes AHUB interfaces, which can be used to connect different
components in the ASoC layer. Currently the driver takes care of XBAR
programming to allow audio data flow through various clients of the AHUB.
Makefile and Kconfig support is added to allow to build the driver. The
AHUB component can be enabled in the DT via below compatible bindings.
  - "nvidia,tegra210-ahub" for Tegra210
  - "nvidia,tegra186-ahub" for Tegra186 and Tegra194

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-6-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:42:22 +05:30
Sameer Pujar
4c6034066a ASoC: tegra: Add Tegra210 based I2S driver
The Inter-IC Sound (I2S) controller implements full-duplex, bi-directional
and single direction point to point serial interface. It can interface
with I2S compatible devices. Tegra I2S controller can operate as both
master and slave.

This patch registers I2S controller with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes I2S interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The I2S devices can be enabled in the DT via
"nvidia,tegra210-i2s" compatible binding.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-5-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:40:40 +05:30
Sameer Pujar
dfc3d8db24 ASoC: tegra: Add Tegra210 based DMIC driver
The Digital MIC (DMIC) Controller is used to interface with Pulse Density
Modulation (PDM) input devices. The DMIC controller implements a converter
to convert PDM signals to Pulse Code Modulation (PCM) signals. From signal
flow perspective, the DMIC can be viewed as a PDM receiver.

This patch registers DMIC component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes DMIC interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The DMIC devices can be enabled in the DT via
"nvidia,tegra210-dmic" compatible string. This driver can be used for
Tegra186 and Tegra194 chips as well.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-4-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:38:45 +05:30
Bitan Biswas
8e36d59756 k5.9: Fix linux-5.8-rc3 merge build
Resolve linux-5.8-rc3 merge conflicts in k5.9 branch
(currently tracking mainline with linux-5.7.0)
Fix build errors in k5.9 branch after merge of linux-5.8-rc3

bug 200617764

Change-Id: I3a358fef6e8b7c5926fd0de05a03cee539547e8f
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
2022-09-29 15:37:14 +05:30
Bitan Biswas
ffea8c683b Merge tag 'v5.8-rc3' into dev-main-5.9
Linux 5.8-rc3

Change-Id: Ie053381bcc551ded4bbbeed07bc33e284f921771
2022-09-29 15:37:14 +05:30
Sameer Pujar
41ff9ddcfe ASoC: tegra: remove 'tegra-alt' directory
As part of upstream alignment all audio drivers have been moved to
'tegra' path and are upgraded to work with 5.9 kernel. References
to older versions can be removed now. Earlier these were moved to
retain the commit history.

Summary on files that are being removed:
 * Legacy FPGA code is dropped
 * PCM driver changes already integrated
 * ASoC Utils changes already integrated
 * Makefile/Kconfig changes are aligned as per upstream plan

Bug 2845498

Change-Id: I645f94852d7137915ff4045be31e5a943a3fa6b3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2364087
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
07de08349a ASoC: tegra: fix kernel warnings during suspend
Following kernel warning is seen during suspend entry.

[  100.031806] ------------[ cut here ]------------
[  100.031844] WARNING: CPU: 5 PID: 1829 at
.../kernel-5.9/kernel/workqueue.c:3036 __flush_work.isra.40+0x21c/0x238
...
[  100.031965] Hardware name: Jetson-AGX (DT)
[  100.031973] pstate: 60400009 (nZCv daif +PAN -UAO)
[  100.031986] pc : __flush_work.isra.40+0x21c/0x238
[  100.031997] lr : flush_delayed_work+0x48/0x58
[  100.032024] sp : ffff80001bf8faa0
[  100.032029] x29: ffff80001bf8faa0 x28: ffff800010d24230
[  100.032038] x27: ffff0003c11bf490 x26: 0000000000000000
[  100.032046] x25: ffff80001111c550 x24: ffff800011eb0000
[  100.032054] x23: ffff80000a470000 x22: ffff800011f67000
[  100.032061] x21: ffff800011cf5000 x20: ffff0003c98906b0
[  100.032069] x19: ffff800011f67a08 x18: ffffffffffffffff
[  100.032077] x17: 0000000000000018 x16: ffff800016240920
[  100.032084] x15: ffff800011d0e000 x14: 00000000000001e6
[  100.032115] x13: 00000000000001e6 x12: 0000000000000000
[  100.032124] x11: 0000000000000000 x10: 0000000000000a20
[  100.032132] x9 : ffff80001bf8fac0 x8 : ffff0003ffba6540
[  100.032140] x7 : 0000000000000400 x6 : ffff80000a520018
[  100.032148] x5 : ffff0003c9ece6b8 x4 : 0000000000000000
[  100.032156] x3 : 0000000000000000 x2 : 0000000000000000
[  100.032156] x3 : 0000000000000000 x2 : 0000000000000000
[  100.032168] x1 : ffff800011cf5948 x0 : 0000000000000000
[  100.032177] Call trace:
[  100.032192]  __flush_work.isra.40+0x21c/0x238
[  100.032202]  flush_delayed_work+0x48/0x58
[  100.032217]  snd_soc_suspend+0x148/0x2a8
[  100.032249]  dpm_prepare+0x110/0x2b0
[  100.032260]  dpm_suspend_start+0x20/0xa0
[  100.032296]  suspend_devices_and_enter+0x120/0x520
[  100.032304]  pm_suspend+0x250/0x2a0
[  100.032311]  state_store+0x8c/0x118
[  100.032320]  kobj_attr_store+0x18/0x30
[  100.032329]  sysfs_kf_write+0x40/0x58
[  100.032336]  kernfs_fop_write+0x148/0x240
[  100.032345]  __vfs_write+0x1c/0x40

It happens because of a warning check that is added in workqueue.c
which expects non-zero work function. Following are the references
to upstream commits.
 * https://lkml.org/lkml/2019/4/30/608
 * commit 4d43d395fed1 ("workqueue: Try to catch flush_work() without
                        INIT_WORK()")

Upstream commit exposes a bug in the machine driver where INIT_DELAYED_WORK()
is done with NULL work->func. This was originally added to resolve
a kernel crash during v3.10 time frame as part of following change.
 * commit 6d1c2577c068 ("ASoC: tegra-alt: Improvement of t210 drivers")

Above downstream commit is no more required on newer kernels and hence
issue is fixed by removing explicit INIT_DELAYED_WORK() from machine
driver. Core already takes care of this for 'rtd->delayed_work'.

Bug 200627501

Change-Id: I20ed108dd90a321323005e8c389f5c1116b937b6
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2362032
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Viswanath L
f79c4d54ef ASoC: tegra: remove channel hard coding in SFC
Hardcoding of CIF channels based on stereo/mono conversion settings is
removed and individual controls are provided for setting audio/client
channels. This is in line with the approach adopted for upstream.

Bug 200528522
Bug 2845498

Change-Id: If26b365d6f79f961ef3deeadbd61dbf0dd42f35e
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2263865
(manually cherry picked from commit 404f9fa1f37f5389fa8de685e6581db23b7dba10)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2361551
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Sameer Pujar <spujar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Asha Talambedu
24a60cd984 ASoC: tegra: Support for ReSpeaker 4-Mic
- Supports capture through Respeaker 4 Mic Array that
has ac108 codec when patched with appropriate codec driver.
- Codec driver that needs to be patched can be found here:
https://github.com/AshaTalambedu/seeed-voicecard/tree/jetson-respeaker-4mic-array-compatible
- Refer README-jetson from above github tree for more details
on patching the codec driver

Bug 200526593
Bug 2845498

Change-Id: Iaf2e6204d644ffab17ac4b9844440448fbf23d86
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2325124
(manually cherry picked from commit ac8b6d6fcd6b46bce27c694e46c93a1aa1fd151f)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2361550
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Sameer Pujar <spujar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
bcd452f7b1 ASoC: tegra: propagate slave_id info to DMA engine
ADMAIF default channel FIFO size is different depending on Tegra210 and
Tegra186 (and later). There is a guideline from HW that FIFO size of
ADMAIF channel should be same as the corrpsonding mapped DMA channel.
Commit 8c0d5ea47d21 ("dmaengine: tegra210-adma: override ADMA FIFO size")
updates FIFO size based on 'slave_id' info. Current patch passes the
'slave_id' information to DMA engine.

Following are the original commits from where the changes have been
manually cherry picked.
 - commit 34aa1f405069 ("ASoC: tegra-alt: T210 AHUB drivers")
 - commit 938afdfeea42 ("ASoC: tegra-alt: Alternative DAPM-based driver")

Also updated copyright info for Tegra PCM driver.

Bug 2845498

Change-Id: I6c748b94544bc22c21a43b731e43862592047c09
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2356716
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
fe40005d9b ASoC: tegra: cosmetic changes for Tegra210
Following changes are pushed as part of this commit:
 - Update copyright signature as per new format.
 - Remove references to "_ALT_" in header macros.
 - Fix copyright year for I2S, DMIC, DSPK, ADMAIF and XBAR drivers.
 - Fix file name in source header for Machine Utility driver.

Bug 2845498

Change-Id: I18b040a9d48a86a33f3ac6b6932d55e81d6414ac
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354014
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
435468ef49 ASoC: tegra: add register dump feature for ADMAIF
This is based on the following original commit for 'tegra-alt' version.
Commit fd0548f8eb8f ("ASoC: tegra-alt: Dump APE register for debugging")

Following minor changes are done:
 - The device reference is available in component structure and the same
   is used to get 'tegra_admaif' structure in *_dump() function. Hence no
   need to separately save device reference.
 - The pm_runtime_get_*() call on child device will first resume parent
   device and hence it would be sufficient to have RPM calls on ADMAIF
   device alone.
 - Since device reference is available in *_dump() function now, pr_info()
   calls are replaced by dev_info().

Bug 2845498

Change-Id: Ib8d8ff7af543a79c34bfa476ddbace1826167a8e
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354012
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
ee22e8b8ce ASoC: tegra: expose DAIs/routes for ADSP Audio
ADMAIF driver is currently rebased as per the patch sent for upstream
review and it does not include interfaces/routing required for ADSP
audio. Since ADSP audio is required in downstream, DAIs, DAPM widgets
and DAPM routes are added for ADSP audio to be part of APE sound card.

Bug 2845498
Bug 200593718

Change-Id: I900963cac25e7ac4fcc4be1e35d1c2f839e965cc
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354011
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
8799f04efd ASoC: tegra: Audio is broken on v5.7-rc7
Commit 209e5c7b4144 ("drivers: fix k5.9 build errors") fixes few build
errors, associated with audio, which are required for initial kernel-5.9
setup. However there are functional issues on TOT, where APE sound card
registration fails. The root cause of this problem is because of below
listed changes in ASoC core:

 - 'snd_soc_ops' member is removed from 'component_driver' structure.
   The PCM callbacks now have to be directly populated in the component
   driver structure. ADMAIF and ADSP drivers are updated and Tegra PCM
   driver is cleaned up accordingly.

 - 'of_node' and 'dev_name' members are removed from 'snd_soc_codec_conf'
   structure now and instead wrapper for these is provided under 'dlc'.

 - Signature of 'snd_soc_get_pcm_runtime()' has changed now and it no
   more accepts DAI link name as argument. But since we require specific
   'rtd' based on DAI link names, the older version is duplicated in
   machine driver.

 - There are changes in trigger() order for start and stop now.

   *_trigger_start()
       |
       |--> rtd trigger()
       |--> component trigger()
       |--> dai trigger()

   *_trigger_stop()
       |
       |--> dai trigger()
       |--> component trigger()
       |--> rtd trigger()

   Above is resulting in following:
       |-> start ADMA
       |-> start ADMAIF
       |-> ...
       |-> stop ADMAIF
       |-> stop ADMA (unable to stop DMA channel print is seen here)

   Current order in downstream for previous kernel versions is:
       |-> start ADMA
       |-> start ADMAIF
       |-> ...
       |-> stop ADMA
       |-> stop ADMAIF

   This issue is addressed by invoking DMA trigger() call from ADMAIF dai
   trigger() itself to avoid the error during stop.

Bug 2845498

Change-Id: I1011555f51f5e0b0a448125a46b47df50e366d6f
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2353304
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
a99eabde9e ASoC: tegra: update ADSP audio driver for 5.4
This patch registers ADSP device as a component with ASoC core. Necessary
changes are made to work with 5.4 kernel and driver need not register a
separate platform and codec device.

Along with this following cleanup is done:
 - Move driver to 'tegra' directory.
 - Wherever possible, fix ACV issues in the driver. Not all of them can be
   fixed at the moment.

Bug 200593718

Change-Id: Ic60c7f59095bbe9f84d25077e4d4469544ca7783
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2342897
(cherry picked from commit d927c5daa951a58924e25d32b8002eb682e43aa0)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2353303
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Bitan Biswas
539a7841f3 drivers: fix k5.9 build errors
Fix linux-5.7-rc5 build in below source files:
	- mmc.c __mmc_switch 7th argument removed for downstream patches.
	- pwm-fan.c - remove unmatched #if PM_SLEEP
	- i2c-tegra.c , arm-smmu-nvidia.c and tegra_machine_driver.c

Bug 200617764

Change-Id: I5a98693219e431f25a101a13f9fc2f6d29829e73
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
5cbf657e1a ASoC: tegra: move ISOBW_MGR source to tegra
For 5.4 kernel AHUB drivers are put under kernel specific folder and plan
is to discontinue 'tegra-alt' directory. This patch moves ISOBW_MGR code
to 'tegra' and updates ADMAIF driver for BW requests.

Bug 2845498

Change-Id: Ib36b00482319f8d266e85b0a80a44b489db3e291
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2328028
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
63a2f16499 ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init()
Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30
through Tegra210 and currently Tegra clock driver keeps the audio mclk
enabled.

With the move of PMC clocks from clock driver into pmc driver, audio
mclk enable from clock driver is removed and this should be taken care
of by the audio driver.

tegra_asoc_utils_init() calls tegra_asoc_utils_set_rate() and audio mclk
rate configuration is not needed during init and the rate is actually
set during the ->hw_params() callback.

So, this patch removes tegra_asoc_utils_set_rate() call and just leaves
the audio mclk enabled.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
ae713bc1c7 ASoC: tegra: Add audio mclk parent configuration
Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30
through Tegra210 and currently Tegra clock driver does the initial
parent configuration for audio mclk and keeps it enabled by default.

With the move of PMC clocks from clock driver into PMC driver, audio
clocks parent configuration can be specified through the device tree
using assigned-clock-parents property and audio mclk control should be
taken care of by the audio driver.

This patch has implementation for parent configuration when default
parent configuration through assigned-clock-parents property is not
specified in the device tree.

Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
5e8303330e ASoC: tegra: Use device managed resource APIs to get the clock
tegra_asoc_utils uses clk_get() to get the clock and clk_put() to free
them explicitly.

This patch updates it to use device managed resource API devm_clk_get()
so the clock will be automatically released and freed when the device is
unbound and removes tegra_asoc_utils_fini() as its no longer needed.

Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
d7c5b86e51 ASoC: tegra: use sample size of 32 for S24_LE
I2S bit clock is derived from PLLA_OUT0 and sample size of 24 bits
results in fractional value. Clock is not accurate because of this
and noisy playback is observed. To avoid this sample size of 32 bits
can be used to derive I2S bit clock. This means there are additional
bit clocks (8 cycles) per channel which are ignored. Codec picks up
data for the other channel when LRCK toggles. The same is true for
capture as well.

For I2S Tegra-Slave mode this problem is not seen because the clock
signals are driven from the codec and above fix is not necessary for
it.

Bug 200594265
Bug 2845498

Change-Id: Ifa17e65a814fab060ab4762d19edfe34420524ce
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2303591
(cherry picked from commit 1bc9e1904454b359361da6682517952fd0108b46)
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2312716
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
0978d6b988 Revert "ASoC: tegra-alt: remove S24_LE format"
This reverts commit 9ac3457ed88631ef035fe9aa6baa4ce0cf2d5d5d

There are some conficts mainly because the revert is being done
on 5.4 kernel drivers and these are resolved manually.

Tegra can support S24_LE and the way it works is as follows.
 * S24_LE is a 32-bit container with 24-bit data in LSBs and the
   DMA is configured for 32-bit.
 * When ADMAIF client channel is configured for 24-bits, it picks
   up 24-bit(starting from LSB) from the ADMAIF FIFO. Higher 8-bits
   are sign extended.

Earlier the confusion was primarily because of the way data gets
picked up from FIFO and the way data conversion happens at CIF.

Bug 200590182
Bug 2845498

Change-Id: Icd0d9fb8fdd0a08d39cb45d23b3f441eaba5a98c
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2308468
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
aede424970 ASoC: tegra-alt: remove XBAR utils source file
As part of upstream alignment all drivers are moved to "tegra" path and
"utils/tegra210_xbar_utils_alt.c" is no more used now. Hence this patch
removes this source file. The helper functions are already moved to AHUB
driver. Currently there are other files related to ISO BW manager, ADSP
audio and FPGA in "tegra-alt" path. These will be cleaned up in subsequent
patches.

Bug 2845498

Change-Id: Iee52eb71bbc3c1996ea75777d3806ef76652848c
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2307646
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
a7db2ff05e ASoC: tegra: disable jack detect (WAR)
There seems to be kernel panic happening when rt5659_set_jack_detect()
is called from the machine driver.

For now the jack detection is disabled to unblock 5.4 bringup and
can be separately tracked. A FIXME item is put. Once the issue is
resolved this patch can be reverted.

Bug 2845498

Change-Id: Ieb67e783a1dbcfb9ebbeb2bf301a818c94e38457
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
517398df1a ASoC: tegra: fix crash in machine driver.
DAI link structure has changed in 5.4 and memory needs to be allocated
for DAI link cpu/codec/platform components. The same is done with the
current patch to avoid the crash.

Bug 2845498

Change-Id: I2d69517120b6debbd0bb8d6a51ab9c5f6d47a401
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
267f390083 ASoC: tegra: enable Tegra machine driver
This patch enables Tegra machine driver used on Jetson platform.
Tegra210 and later Jetson platforms use the same machine driver.

Following is the summary from the patch:
 * Enable the driver build in defconfig
 * Remove "tegra-alt" ASoC utility file
 * Renmae "tegra-alt" parser source file "tegra_asoc_dt_parser.c"
   to "tegra_asoc_machine.c" and move it to "tegra" directory.
 * Similarly "tegra_asoc_machine_alt.h" is renamed to
   "tegra_asoc_machine.h" and moved to "tegra".
 * Updated "tegra" ASoC utility files for supporting Tegra210 and
   later.
 * Rename machine driver file.
 * The older parsing code is removed.

Bug 2845498

Change-Id: I42d9d2da59febb99ce00a29ce65d7a16f96b1327
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
ec0813dbd1 ASoC: tegra: move remaining AHUB devices to component
Following AHUB modules are considered as part of this series. This updates
all drivers to use component structure. Initially AHUB, I2S, DMIC, DSPK
and ADMAIF drivers were updated.

FPGA code is removed from the related drivers. This can be cherry-picked
if it is really required.

Bug 2845498

Change-Id: Ia3f60257c225d281d86ad83325fb517969259cb4
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
5fa4522d98 ASoC: tegra: expose DAIs of other AHUB modules
For upstream initially ADMAIF and I/O modules are considered. And the
these drivers are rebased in previous commit. This patch tracks the
addition of DAIs in AHUB driver which are needed for other AHUB modules.

Bug 2845498

Change-Id: I16e04a3bcf1118d66a57da2db07c3155ec9fe1a3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
6b98f0a740 ASoC: tegra: update AHUB drivers as per upstream
AHUB and few components have been pushed for upstream review. Though the
changes are still under review, we can leverage the work done on upstream
5.x and use the same here on 5.4 kernel. This helps to align the downstream
code. Any changes that happen because of upstream review can be cherry
picked here. If we plan for any downstream changes, upstream patch needs to
be pushed to keep the code in sync.

As of today current snapshot is pulled from v3 of AHUB series,
http://patchwork.ozlabs.org/project/linux-tegra/list/?series=159664

Above series was worked on later versions of linux-next and hence following
are the changes required for porting back on 5.4
 * tegra_pcm_new() and tegra_pcm_free() are exposed from tegra_pcm.c and
   component driver callbacks use these.
 * Callback functions required for snd_pcm_ops in component driver are
   implemented by tegra_pcm.c
 * With this ADMAIF driver need not register platform device with ASoC
   core.

For components (AHUB, ADMAIF, I2S, DMIC and DSPK) the downsream code
differs in few aspects from the code that was pushed for v3. Some of them
are listed below.
 * I2S driver in downstream implements startup()/shutdown() calls for DAI,
   which does some setup related to pinconfig and regulators. The same is
   true for DMIC and DSPK drivers as well.
 * Downstream ADMAIF drivers makes bandwidth requests in startup/shutdown()
   calls and has helper function for dumping registers. It also has
   additional DAI interfaces which are used for ADSP audio.
 * Downstream AHUB driver has DAI interfaces for connecting to all other
   modules.
These differences will be cherry-picked as and when it is necessary.

Bug 2845498

Change-Id: Id374967ecae26f6b7334a959fb23308d383c15f2
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
39e4507117 ASoC: tegra: merge 'tegra' and 'tegra-alt' directories
Tegra210 and later audio drivers have been using 'tegra-alt' directory
from the beginning. As per the upstream roadmap, we plan to use the
same 'tegra' directory and place all the drivers under it. This patch
thus moves all the drivers to 'tegra' and renames the files accordingly.
The '_alt' suffix is removed from header and source files.

For some files still the '_alt' suffix is retained because 'tegra'
already has the corresponding files. Manual merge of following files is
needed and will be done in separate commits.
 * tegra_asoc_utils_alt.c and tegra_asoc_utils.c
 * tegra_asoc_utils_alt.h and tegra_asoc_utils.h
 * tegra_pcm_alt.c and tegra_pcm.c
 * tegra_pcm_alt.h and tegra_pcm.h
 * Corresponding Makefile and Kconfig files.
 * Source files related to ADSP audio, FPGA, bandwidth manager are not
   considered at the moment and will be tracked separately.

Bug 2845498

Change-Id: I51dae3971c72b58d921dc19f0553a83422fd3f9e
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Mohan Kumar
da1da6911e ASoC: tegra-alt: Control AHUB rate from DT
AHUB clock currently uses pll_a_out0 derivative clock from plla source
but the max frequency for pll_a_out0 was limited to ~49MHz to derive
all possible clock rates for i2s sampling rates. This limits the AHUB
clock rate to be used at peak possible rate for ahub which can help in
some high bandwidth usecase. Considering this AHUB rate can be derived
from PLLP clock to support max possible rate for AHUB.

Making use of assigned-clock-rates and assigned-clock-parents to set the
desired settings as per dvfs table for a given platforms.

Bug 200537672

Change-Id: Ica556fc68456b52516c82b6601b54cae0b5d1b73
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2204283
(cherry picked from commit add574aa21b447b61391f51650fe52175190064b)

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Change-Id: I655337be86d37b05843a9a9b4238001779653eeb
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2280448
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:30:21 +05:30
Sameer Pujar
f44cfefe5d ASoC: tegra-alt: use regmap macros for timeout
Following print is seen while using regmap_read_poll_timeout() macro
in snd_soc_dai_ops trigger() callback in ADMAIF driver,
 *** BUG: scheduling while atomic ***
and kernel panic happens there after. This happens because above macro
is not atomic safe and trigger() is called in atomic context.

Earlier this addressed by using readx_poll_timeout_atomic() macro.
Though this works fine driver needs to keep a reference to base address.
To avoid this new macro was pushed and is accepted in upstream and
following is the commit - https://lkml.org/lkml/2020/1/9/985

This patch makes use of regmap macros where there is a need of timeout
functionality. Following is the guideline that can be followed.
 * use regmap_read_poll_timeout_atomic() where the caller is in atomic
   context.
   ex: trigger() etc.,
 * use regmap_read_poll_timeout() when the caller is known to be running
   in non-atomic context.
   ex: hw_param(), prepare() etc.,

Based on this audio drivers are updated. ASRC and ARAD drivers will be
taken up in a separate change.

Bug 200566596

Change-Id: Iea88adc60de5919e456a36a30152212652a8ecd3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2274874
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
27008c3e63 ASoC: tegra-alt: optimize XBAR MUX get/put() APIs
This patch optimizes following functions on the usage of local
variables and removal of redundant loops, thus making these
functions more readable.
 * tegra_xbar_get_value_enum()
 * tegra_xbar_put_value_enum()

Bug 200503387

Change-Id: I32989d0cf46ad50bf47a0127bac1eb7c1ed32ff2
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268611
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
49b09c95c7 ASoC: tegra-alt: remove S24_LE format
S24_LE is a 32-bit container with 24-bit data in LSBs, with zeroes in
most significant byte. S32_LE can act as 32-bit container for 24-bit
data where data is pushed to MSBs and zeroes are filled in least
significant byte. For example below is how the data is represented
for different containers, where 'abc' is 24-bit data.
  0abc (S24_LE)
  abc0 (S32_LE)

As per IAS, most significant bits are pushed first when data moves
in AHUB. For any down conversion LSBs are discarded, where as for any
up conversion, zeroes are filled in the LSBs. Hence extraction of
S24_LE results in data loss. Mentioned below are some of the examples
to illustrate this.

Consider for playback path, where data flow is from memory to AHUB and
its clients, where 'abc' is valid data and 'x' is to ignore.
  * S32_LE
    abc0 --> audio = 32, client = 32 --> abc0
    abc0 --> audio = 32, client = 24 --> abcx
    abc0 --> audio = 32, client = 16 --> abxx
  * S24_LE
    0abc --> audio = 32, client = 32 --> 0abc
    0abc --> audio = 32, client = 24 --> 0abx (data loss)
    0abc --> audio = 32, client = 16 --> 0axx (data loss)

Thus this patch removes S24_LE format from the drivers since Tegra audio
HW is not designed to support this. Also S24_LE is not a commonly used
format.

Bug 200568187

Change-Id: I778d2f70527c17f00728fce75fe152d902c5aaa0
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264822
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
df32a012ac ASoC: tegra-alt: re-organize XBAR code
XBAR related code is currently put under source files "tegra210_xbar_alt.c"
and "tegra210_xbar_utils_alt.c". For upstream we are planning to use a
single source file. Thus code in downstream is re-organized so that all
XBAR code is moved under a single file.

Following is the summary of changes,
 * All XBAR specific code is moved under,
   "tegra210_xbar_alt.c" and "tegra210_xbar_alt.h"
 * Only common code, which is required for other modules, remains in
   "tegra210_xbar_utils_alt.c"
 * unused macros or functions are removed

Bug 200503387

Change-Id: I11cb93d3cdc07e14ef2e0b3b23ba6a98020a0373
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265584
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
6f6b01c660 ASoC: tegra-alt: remove i2s DT properties for "fsync-width" and "enable-cya"
Currently in downstream,
 * we pass FSYNC width from DT for LRCK and FSYNC modes. We also have a
   mixer control to override the width. If the property is missing a
   default width of "31" is set.
 * DT property, "enable-cya", is used on Tegra210 to enable pad controls
   for I2S4. This is not required for other instances of I2S on Tegra210
   and not required for any instance on Tegra186/Tegra194.

With current patch,
 * DT property "fsync-width" is removed
   - LRCK mode does not require FSYNC width to be configured.
   - Reset value (one-bit-clock wide) is what we are using for DSP modes.
   - If specific width needs to be configured, mixer control is already
     available. Generally for FSYNC modes, the width depends on the codec
     and in such cases mixer control is helpful.
 * DT property "enable-cya" is removed
   - By default the corresponding bit is enabled.
   - For other instances of I2S on Tegra210 and for any instance on
     Tegra186/Tegra194, this bit is unused.
 * updated the channel that needs to be used for CIF and I2S control.
   For example, for CIF configuration audio channels is used and
   for BCLK rate or channel bit count calculation, client channel is
   used.
 * helper function tegra210_i2s_set_timing_params() is added to program
   I2S clock and timing related registers.
 * I2S global enable is moved to default list. The enable status on TX/RX
   channel is controlled via DAPM widget.

Bug 200503387

Change-Id: Iafe62e8816f6d8702a325c8466d6b6fda5514d66
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2244478
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
c3c5ac4e23 ASoC: tegra-alt: remove channel hard coding for I2S and ADMAIF
Currently CIF channels are overridden based on mono/stereo settings.
This can be problematic for multi-channel use cases or the cases where
user is intentionally overriding channels through mixer control. In such
cases hard coding based on CIF mono/stereo settings can result in wrong
behavior.

Following are the changes in current patch,
 * Decouple CIF mono/stereo and CIF channel settings. It means that, user
   can override audio channels and CIF settings independently. Also these
   controls are provided for both playback and capture paths.
 * For ADMAIF, channel overrides are provided for both audio and client
   channels in both playback and capture paths.
 * For I2S, separate channel overrides for client channels is not needed
   in playback and capture paths. Hence a common client channel override
   control is provided. However for audio channels it is similar to the
   controls provided for ADMAIF.
 * Similar to channels, for I2S, audio bit format control is updated and
   provided separate controls in playback and capture paths.
 * "None" option is removed for mono/stereo to match HW register spec.
   Earlier channel was hard coded based on this.
 * For I2S, audio channels are used for CIF configuration and for the slot
   control client channels are used (earlier audio channels were getting
   used for slot control)
 * For upstream, we are standardizing mixer control names. For now, only
   relevant controls are updated. Going forward we need to take similar
   approach for all controls/modules. This needs to be reflected in
   test scripts and documentation as well.

Bug 200503387

Change-Id: I04df9a3bda41e028edc46e86ecd1d80966bc83e1
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2244477
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Viswanath L
f48397b648 ASoC: tegra-alt: warning print at disable timeout
ADMAIF may hit timeout in closing sequence, if some bits remain
unconsumed in FIFO, which may happen if the sink gets closed/blocked
ahead of source. As such the status register of ADMAIF remaining
uncleared is not a catastrophic error and the channel will be
available after reset, hence timeout merits a warning print.

Above issue gets hit in two test scripts:
 - tegra-audio-amx-to-adx.sh, where closing aplay at any one input
    port of AMX causes the module to block other substreams. This
    is a HW bug, fixed in T194 upwards.
 - tegra-audio-admaif-testsuite.sh, where running aplay and arecord
    without any flow control does not ensure that aplay always drains
    its bits.

The warning print here, in playback path, is whitelisted for GVS runs.

Bug 200569324

Change-Id: I12984d08c6f43f41f3b85bb066d42b6883249060
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2258180
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
9c3c3fbc35 ASoC: tegra-alt: remove dev.id parsing from DT
For AHUB modules instance number is passed with a DT property. For example,
"nvidia,ahub-i2s-id" property is used in I2S nodes. Similarly other modules
use "nvidia,ahub-<module>-id" property, where <module> is "dmic" or "dspk"
or other corresponding module names. With DAI links in DT now, this is not
required any more. Hence the parsing code for such properties is removed.

Bug 200503387

Change-Id: Ia372044ebecfe090668953b8da81028c63812a4f
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2146859
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha Talambedu
14ccf06582 ASoC: tegra-alt: ASRC_INT_CLEAR_WAR config cleanup
- CONFIG_TEGRA186_ASRC_INT_CLEAR_WAR is removed.

- Int clear war is disabled for platforms >= t194 as the related
  h/w issue is resolved with the help of compatible string match

Bug 200540133

Change-Id: I48677f17278f0451c67fa2b9232b9e960bf8a34f
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233940
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
7a56385cb5 ASoC: tegra-alt: remove overrides for device names
Currently we maintain auxdata structure for Tegra210 and Tegra186. This
is nothing but a lookup table used for device names and platform data.
It is used to override device names when creating devices from DT. Since
we have moved all DAI links to DT and no more we rely on device names,
automatically generated device names should be good enough. Hence this
patch removes auxdata table and dev_set_name() calls from XBAR, AMX
drivers.

Some of the embedded platforms are using older machine utility code,
which are using these names. Hence the utility code is also updated to
use automatically generated device names.

Bug 200503387

Change-Id: I80c4fb3a5927001f58a54ca90437ec67ed14bf54
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2258385
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
001188d41c ASoC: tegra-alt: parse machine widgets from DT
Machine DAPM widgets are currently defined in the driver and are used
to connect to DAPM input/output widgets of external codecs. This routing
map is exposed from DT. Since the machine driver is common to multiple
platforms, all widgets defined in the driver are not always required.
Instead of statically defining the widgets in the driver, these can be
exposed from DT. Any platform DT can then add required number of widgets
and can define a corresponding routing map.

This patch removes the static array for DAPM widgets and instead helper
function, snd_soc_of_parse_audio_simple_widgets(), is used to populate
given DAPM widgets for the sound card.

Bug 200503387

Change-Id: I8ff9f0d52e3c1cc10b6ab1682d05a7b7ef7e2684
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2257383
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
1f403897f1 ASoC: tegra-alt: move to DT based DAI links
Currently we are using static DAI links in machine-utils code and there
are some drawbacks associated with it.
 * All DAI links are enabled, even though if a platform does not require.
   For ex: ALSA ring buffers are allocated for all the ADMAIF PCM links.
   Some platforms might want to enable a very few links, which is not
   currently possible with static array in the driver code.
 * No way to disable specific modules from DT. For example if any of the
   module instances are disabled, sound card registration fails.
 * CPU and CODEC names are hard coded in the DAI link arrays. With this
   we need to pass instance-id properties from DT to identify or match
   the correct instance names.
 * One of the other concerns is about latency, where some platform want
   to optimize this by only enabling required links.

Above issues can be addressed with DT based DAI links and going ahead
plan is to use upstream style of DT binding. This patch includes following
changes.
 * Add new helper functions to parse all DAI links from DT. All code
   related to this is added in a new file.
 * Remove older helper functions for parsing. Please note that, not all
   functions can be removed since few machine drivers rely on them.
 * Common params structure is used for all codec-to-codec links. In machine
   driver hw_params() callback all DAI link params are updated. Hence it
   is not necessary to maintain separate structures.
 * By default card->dapm.idle_bias_off is set to true. This means, codec
   suspend() won't be called during STANDBY. The flag is set to true for
   Tegra210 as well, where earlier it was set to false. This further helps
   to remove soc_data structure.
 * Module specific checks are not needed to manage DAI links now.

Bug 200538260

Change-Id: I210b70c23a8878f5b1733dfa9d2010834ae4a85a
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2229358
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha Talambedu
e8f6236ef5 ASoC: tegra-alt: Unify machine driver config
-Avoided double compilation of machine driver as mobile
 platforms >= t210 have common machine driver, through a
 common config
-Removed SND_SOC_ASOC_MACHINE_ALT, SND_SOC_TEGRA_ALT_FORCE_CARD_REG
 config as its not being used

Bug 200540133

Change-Id: I57271888581d6494e771be77a8fd2fe5b5adb015
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233907
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
5f8e73c6cf ASoC: tegra-alt: simplify timeout code for I2S and ADMAIF
For SW reset and register status polling timeout code is used in multiple
drivers. Since the logic is similar, the same code is duplicated at many
places. This can be avoided by relying on the kernel macro which provides
similar functionality, where sleep between polling and timeout can be
explicitly provided. For example, ADMA driver is using a similar kernel
macro and this can be used for Tegra ASoC drivers as well.

Currently this patch updates timeout code for ADMAIF and I2S to start with.
This helps for upstream as well. Other drivers will be taken care in a
separate patch. In doing so following changes are also needed,
 * Few functions are optimized to simplify the code during stream start or
   stop. This basically combines RX and TX handling in a single function
   and thus helps to avoid code duplication.
 * For ADMAIF, macros are used wherever register access for RX and TX paths
   are needed. Existing CH_REG() macro is updated to facilitate this. RX
   and TX paths can use CH_RX_REG() and CH_TX_REG() respectively to get
   proper register offset. Accordingly the access is updated in the driver.

Bug 200566596
Bug 200503387

Change-Id: I6d46518dba09a936ad84799943eba8976a261faa
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2241448
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
5e32b94e91 ASoC: tegra-alt: Remove unsupported modes from I2S control
The I2S interfaces only support configurations where both the bit clock
and frame sync are master or are both slave. Therefore, remove support
for modes where the bit clock is master and frame sync is slave and
vice-versa from the 'I2Sx codec master mode' mixer controls.

Bug 2046053
Bug 2746555

Change-Id: I288a1a372fe200b5faf2eb0f3d7c481a34c1f545
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2230060
(cherry picked from commit 79a002b42a9c25cd26832c967f95f82e08935ca9)
Reviewed-on: https://git-master.nvidia.com/r/2237275
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha Talambedu
3b9d9c345c ASoC: tegra-alt: Remove redundant configs
Removed redundant configs TEGRA210_AMX_MAP_READ
and TEGRA210_ADX_MAP_READ

Bug 200540133

Change-Id: I84404731dd277385d1432c5d235c36805f2da4f5
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233899
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
84cc33a1b6 ASoC: tegra-alt: Prevent I2S controls overwriting each other
Each I2S interface has a mixer control 'I2Sx codec master mode' to
set the master mode and 'I2Sx codec frame mode' to set the frame mode.
An issue with these mixer controls has been found where if the user
sets both of these, then whatever is set last will overwrite the other
resetting it back to its default value. For example, if 'I2Sx codec
master mode' configures the codec as the master, then set the 'I2Sx
codec frame mode' to say 'dsp-a', then setting the frame mode will
revert the master mode setting back to its default. Fix this by
ensuring the frame mode and master mode do not overwrite each other.

Bug 2046053
Bug 2746555

Change-Id: Ibd51a0462a4c02055075aee84808f7ddca0a9199
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2230059
(cherry picked from commit 70c45f196b76ce0d5e1e76153232cb3d35928262)
Reviewed-on: https://git-master.nvidia.com/r/2234917
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
0ac26664d6 ASoC: tegra-alt: move OPE2 to the end of dai array
This is a preparatory patch for moving all DAI links to DT. With DT based
DAI links, we need to index through the DAI array. There are differences
between Tegra210 and Tegra186, which are listed below.
 * OPE2 is removed in Tegra186
 * AMX and ADX instances are increased to 4
 * DSPK, ASRC and ARAD are added
 * DMIC instances are increased to 4
 * I2S instances are increased to 6
 * ADMAIF channels are increased to 20 each for Tx and Rx

Above makes us to have separate headers in DT, containing macro defines,
for Tegra210 and Tegra186. This can be avoided by re-ordering the DAI array
to list common DAIs in the beginning and push the differences at the end.
As we can see adding instances can be easily handled by just listing out
the new DAIs at the end. But problem is when we remove an instance and it
requires some intelligence encoded in header files for optimization. In the
current case, OPE2 is being removed from Tegra186 onwards and hence this is
pushed to the end of Tegra210 DAI array.

Bug 200538260

Change-Id: I8f976ce08d6526357ab4578fa462ab53113c674d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2220276
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30