mbox series

[0/7] Add RK3576 SAI Audio Controller Support

Message ID 20250305-rk3576-sai-v1-0-64e6cf863e9a@collabora.com (mailing list archive)
Headers show
Series Add RK3576 SAI Audio Controller Support | expand

Message

Nicolas Frattaroli March 5, 2025, 9:24 p.m. UTC
This series adds support for Rockchip's Serial Audio Interface (SAI)
controller, found on SoCs such as the RK3576. The SAI is a flexible
controller IP that allows both transmitting and receiving digital audio
in the I2S, TDM and PCM formats. Instances of this controller are used
both for externally exposed audio interfaces, as well as for audio on
video interfaces such as HDMI.

Patch 1 and 2 do some preparatory work in the clock bindings and clock
controller. The RK3576 has the SAI0 through SAI4 output mclks as well as
the FSPI0 and FSPI1 clocks gated behind some GRF register writes. The
RK3588 had this for its I2S audio clocks as well, but got away with not
caring about it in mainline because the clocks were ungated by default.
This is no longer the case with RK3576: the SAI mclk need to be ungated
before they can be used.

The gritty details are in patch 2, but to sum it up: we need to
introduce a new clock branch type, and also rework the rockchip clock
code to deal with multiple separate GRF regmaps.

NB: checkpatch.pl seems to trip over patch 2 in some way that seems like
a combination of the diff being too clever and at the same time too
stupid.

Patch 3 adds the devicetree schema for the SAI. Right now, we only have
a RK3576 compatible, but as I understand it, the RK3528 uses this audio
controller as well.

Patch 4 is the main course and adds the driver. It's based on the
downstream vendor driver, but substantial changes have been made in the
hopes to make it suitable for upstream inclusion.

Patch 5 and 6 are boring devicetree changes to add the nodes and use
them in the ArmSoM Sige5 board. Patch 6 goes into some schematic-derived
knowledge about where the audio signal can actually be tapped into in
order to test this.

Patch 7 enables the driver in the arm64 defconfig, as the RK3576 is
supported in mainline, so its drivers should be enabled in the
defconfig.

To test this on the Sige5, I both soldered to the output 2 testpads, as
well as fashioned a cable to plug into the headphone header. I should
have some stuff arriving by mid-March to make more such cables, so if
you have a Sige5 and want to test this but don't happen to sit on a pile
of 03SUR-32S cables, then you may contact me off-list to request I send
you such a cable from Switzerland, and I'll see what I can do.

HDMI audio isn't enabled in this series yet, but I'll look into it
either for a v2 or in a follow-up series. I really wanted to get this
out to be reviewed now, as there's a substantial amount of code to look
at that is ready for both review and testing.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
Nicolas Frattaroli (7):
      dt-bindings: clock: rk3576: add IOC gated clocks
      clk: rockchip: add support for GRF gated clocks
      ASoC: dt-bindings: add schema for rockchip SAI controllers
      ASoC: rockchip: add Serial Audio Interface (SAI) driver
      arm64: dts: rockchip: Add RK3576 SAI nodes
      arm64: dts: rockchip: Add analog audio on RK3576 Sige5
      arm64: defconfig: Enable Rockchip SAI

 .../devicetree/bindings/sound/rockchip,sai.yaml    |  151 ++
 MAINTAINERS                                        |    7 +
 .../boot/dts/rockchip/rk3576-armsom-sige5.dts      |   56 +
 arch/arm64/boot/dts/rockchip/rk3576.dtsi           |  194 +++
 arch/arm64/configs/defconfig                       |    1 +
 drivers/clk/rockchip/Makefile                      |    1 +
 drivers/clk/rockchip/clk-rk3328.c                  |    6 +-
 drivers/clk/rockchip/clk-rk3568.c                  |    2 +-
 drivers/clk/rockchip/clk-rk3576.c                  |   59 +-
 drivers/clk/rockchip/clk.c                         |   24 +-
 drivers/clk/rockchip/clk.h                         |   49 +-
 drivers/clk/rockchip/gate-grf.c                    |  105 ++
 include/dt-bindings/clock/rockchip,rk3576-cru.h    |   10 +
 sound/soc/rockchip/Kconfig                         |    8 +
 sound/soc/rockchip/Makefile                        |    2 +
 sound/soc/rockchip/rockchip_sai.c                  | 1623 ++++++++++++++++++++
 sound/soc/rockchip/rockchip_sai.h                  |  251 +++
 17 files changed, 2533 insertions(+), 16 deletions(-)
---
base-commit: a03be51d680391ba113e2e22b38743c276b6e2fa
change-id: 20250305-rk3576-sai-c78e0430898e

Best regards,