How to Mount wm8960 on I2C3 and Transmit Audio Data by SAI1

OKMX8MM-C development board of Forlinx Embedded reserves I2C3 and SAI, which are located on P18 and P7 respectively. The onboard audio chip is mounted on I2C2 and SAI2.

This article describes how to mount audio chip wm8960 on I2C3 and transmit audio data by SAI1.

The paths of device tree and device tree header file are as follows:



1. Modify result

1.1 Open device tree to modify sound node. Driver obtains device information from here.

Modify sound cpu-dai=<&sai2> to cpu-dai= <&sai1>. Mount WM8960 to sai1 to send and receive audio data streams. Similarly, it can also be mounted to sai3 by modifying hardware connection.

Modify hp-det-gpios= <&gpio4 22 0 > to hp-det-gpios= <&gpio4 22 1 >. Default is headphone output, which disables plug detection.

Modify result

1.2 Comment out wm8960 node under I2C2. Because there cannot be an identical device node in device tree, it need to comment out original wm8960 node.

wm8960 node

Add wm8960 node under I2C3. Put device node under corresponding mounted I2C. Modify clocks= <&clk IMX8MM_CLK_SAI1_ROOT>. There is a device node under I2C3, but clock needs to be changed to sai1.

wm8960 node under I2C3

1.3 Modify pinctrl_sai1 and comment pinctrl_sai1_dsd. The default device tree of i.MX8MM has already written pinctrl of sai1.


1.4 Modify SAI1 node, as shown below. Copy SAI2 node to replace SAI1, and modify to parameters of SAI1.

Modify SAI1 node

2. Modify guideline

guideline when modifying audio chip mount path:

  • 1. Block default mount path;
  • 2. Add node of audio device to I2C and SAI to be mounted;
  • 3. Modify pinctrl pin multiplexing;
  • 4. Block default wm8960 pin configuration.

wm8960 mounting method is of the same model as onboard default audio chip. If need to mount other models of audio chips, it needs to specify drive path on sound node.

cpu-dai indicates SAI channel to be used. The default is SAI2. In this article, to use SAI1 , it is changed to SAI1; audio-codec attribute is wm8960 node under I2C3.

Device tree sound node:

Device tree sound node

.compatible attribute of imx-wm8960.c driver

imx-wm8960.c driver

3. Summarize

compatible attribute under sound node of device tree corresponds to .compatible in audio driver imx-wm8960.c. Thus device and the driver are connected, and driver can obtain keyword like model, cpu-dai in device node.

When changing to other audio chips, it becomes easy to modify configuration of audio device by modifying compatible attribute value of device tree, which is the reason why Linux separates device tree.

The method in this article is carried out on the premise of blocking default audio device. For dual audio output, it needs to configure it in other links. The above is process of mounting wm8960 audio chip on I2C3 of OKMX8MM-C development board and transmitting audio data by SAI1.