Skip to content

Commit cc78d1e

Browse files
Nicolas Frattarolibroonie
authored andcommitted
ASoC: rockchip: add Serial Audio Interface (SAI) driver
The Rockchip RK3576 SoC features a new audio controller, the Serial Audio Interface, or SAI for short. It is capable of both sending and receiving audio over up to 4 lanes for each direction using the I2S, PCM or TDM formats. This driver is derived from the downstream vendor driver. That is why its original author, Sugar Zhang, is listed as a Co-developer, with their signoff. Since adjustments to make the driver suitable for upstream were quite extensive, I've added myself to the authors and put myself as the commit author; all added bugs are my fault alone, and not that of the original author at Rockchip. The hardware is somewhat similar to the Rockchip I2S-TDM hardware when judged based on their register map, except it uses the same mclk for tx and rx. It appears to be much more flexible with regards to TDM. The loopback stuff and mono mode are new as well. In line with the changes that were made to the Rockchip I2S-TDM driver after upstreaming, the mclk-calibrate functionality was dropped, and setting the mclk rate properly is now left up to the Common Clock Framework, similar to how it is in the upstream I2S-TDM driver now. A spinlock has been introduced to protect register write accesses that depend on the bclk/fs to be stopped, i.e. XFER[1:0] being 0. I couldn't find whether the asoc core held a per-instance lock so only one callback can run at a time, and so it seemed prudent to add this. I couldn't successfully test whether TDM was working, though I've tried with a TAS6424 codec board. I'm not sure yet whether to blame the codec driver, this version of the SAI driver, or the vendor implementation of the SAI driver. The TDM mask registers remain untouched in both this version and the downstream vendor version, which is suspicious, though the Linux ASoC core wouldn't be able to support the 128 (!!!) slots of TDM the hardware supports anyway. Regular old 2-channel stereo I2S thrown at an I2S stereo codec works well though. I tested with the CPU-side SAI controller in provider mode and an Everest ES8388 codec as the consumer. Some vendor driver features (no-dmaengine, fifo rockchip performance monitoring, many kcontrols) were dropped for this initial upstream version. They can always be added later if they make sense for upstream. Co-developed-by: Sugar Zhang <sugar.zhang@rock-chips.com> Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Link: https://patch.msgid.link/20250410-rk3576-sai-v2-6-c64608346be3@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fd55908 commit cc78d1e

5 files changed

Lines changed: 1819 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20918,6 +20918,7 @@ M: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
2091820918
L: linux-rockchip@lists.infradead.org
2091920919
S: Maintained
2092020920
F: Documentation/devicetree/bindings/sound/rockchip,rk3576-sai.yaml
20921+
F: sound/soc/rockchip/rockchip_sai.*
2092120922

2092220923
ROCKCHIP VIDEO DECODER DRIVER
2092320924
M: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

sound/soc/rockchip/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ config SND_SOC_ROCKCHIP_PDM
3737
Rockchip PDM Controller. The Controller supports up to maximum of
3838
8 channels record.
3939

40+
config SND_SOC_ROCKCHIP_SAI
41+
tristate "Rockchip SAI Controller Driver"
42+
depends on HAVE_CLK && SND_SOC_ROCKCHIP
43+
select SND_SOC_GENERIC_DMAENGINE_PCM
44+
help
45+
Say Y or M if you want to add support for the Rockchip Serial Audio
46+
Interface controller found on Rockchip SoCs such as the RK3576. The
47+
controller may support both playback and recording, with up to 4 lanes
48+
for each and up to 128 channels per lane in TDM mode.
49+
4050
config SND_SOC_ROCKCHIP_SPDIF
4151
tristate "Rockchip SPDIF Device Driver"
4252
depends on HAVE_CLK && SND_SOC_ROCKCHIP

sound/soc/rockchip/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
snd-soc-rockchip-i2s-y := rockchip_i2s.o
44
snd-soc-rockchip-i2s-tdm-y := rockchip_i2s_tdm.o
55
snd-soc-rockchip-pdm-y := rockchip_pdm.o
6+
snd-soc-rockchip-sai-y := rockchip_sai.o
67
snd-soc-rockchip-spdif-y := rockchip_spdif.o
78

89
obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-rockchip-i2s.o
910
obj-$(CONFIG_SND_SOC_ROCKCHIP_PDM) += snd-soc-rockchip-pdm.o
11+
obj-$(CONFIG_SND_SOC_ROCKCHIP_SAI) += snd-soc-rockchip-sai.o
1012
obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o
1113
obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S_TDM) += snd-soc-rockchip-i2s-tdm.o
1214

0 commit comments

Comments
 (0)