Skip to content

arm64: dts: qcom: msm8953-xiaomi-vince: add TAS2557 speaker amplifier - #252

Draft
M0Rf30 wants to merge 4 commits into
msm8953-mainline:7.0.9/mainfrom
M0Rf30:m0rf30/7.0.9/develop
Draft

arm64: dts: qcom: msm8953-xiaomi-vince: add TAS2557 speaker amplifier #252
M0Rf30 wants to merge 4 commits into
msm8953-mainline:7.0.9/mainfrom
M0Rf30:m0rf30/7.0.9/develop

Conversation

@M0Rf30

@M0Rf30 M0Rf30 commented Jun 17, 2026

Copy link
Copy Markdown

Adds TAS2557 loudspeaker support for the Xiaomi Redmi 5 Plus (vince).

  • dt-bindings for ti,tas2557
  • TAS2557 codec driver (regmap I2C, book/page regmap, DSP firmware loader)
  • enable it in the msm8953 config
  • vince DT: codec on i2c_2 @0x4c (reset GPIO86, IRQ GPIO87, always-on rail so no regulator) + a Quinary MI2S
    dai-link

The amp is on Quinary MI2S, not Primary — Primary is the internal codec. Matches the stock mixer_paths and
the existing ocean/FP3 setups, so no machine-driver change.

Needs tas2557_uCDSP.bin (device-specific, pull from stock vendor into /lib/firmware) to actually pass audio.
Tested on device, speaker works.

@z3ntu

z3ntu commented Jun 17, 2026

Copy link
Copy Markdown

Nice, need to try if the amp on FP3+ works with this :)

@M0Rf30
M0Rf30 force-pushed the m0rf30/7.0.9/develop branch 7 times, most recently from c28ebec to e205166 Compare June 21, 2026 17:01
@M0Rf30
M0Rf30 force-pushed the m0rf30/7.0.9/develop branch from e205166 to be97d7a Compare June 28, 2026 15:28
@M0Rf30

M0Rf30 commented Jun 28, 2026

Copy link
Copy Markdown
Author

rebased on latest sdm660-mainline reviews
sdm660-mainline#187

@barni2000
barni2000 requested a review from vldly July 3, 2026 20:26
@M0Rf30
M0Rf30 force-pushed the m0rf30/7.0.9/develop branch from be97d7a to 0c40162 Compare July 3, 2026 21:13
@barni2000

Copy link
Copy Markdown
Member

Please send it to upstream at least for review, we have too much downstream commit at the moment what were never sent too upstream.

@barni2000

Copy link
Copy Markdown
Member

Lets wait 7.1 rebase there will be little changes in pinctrls.

Comment thread arch/arm64/boot/dts/qcom/msm8953-xiaomi-vince.dts Outdated
Comment thread arch/arm64/boot/dts/qcom/msm8953-xiaomi-vince.dts Outdated
@M0Rf30
M0Rf30 force-pushed the m0rf30/7.0.9/develop branch from 0c40162 to 638e44a Compare July 11, 2026 10:05
@M0Rf30
M0Rf30 requested a review from barni2000 July 11, 2026 10:06
@vldly
vldly removed their request for review July 12, 2026 20:35
firmware-name = "qcom/msm8953/xiaomi/vince/a506_zap.mdt";
};

&i2c_2 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&i2c_2 {
&i2c_2 {
clock-frequency = <400000>;

Apparently by default i2c runs at 100KHz. Downstream overrides it to 400KHz which would help to speed up firmware upload.

CONFIG_SND_SOC_MSM8916_WCD_ANALOG=m
CONFIG_SND_SOC_MSM8916_WCD_DIGITAL=m
CONFIG_SND_SOC_QDSP6_Q6VOICE=m
CONFIG_SND_SOC_TAS2557=m

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not in xiaomi-vince.config? This isn't used on many msm8953 devices.

TAS2557_ASI2_BDIV_CLK_RATIO_REG, 0x81, /* power up BDIV */
TAS2557_ASI2_WDIV_CLK_RATIO_REG, 0x40,
TAS2557_ASI2_WDIV_CLK_RATIO_REG, 0xc0, /* power up WDIV */
TAS2557_GPIO7_PIN_REG, 0x15, /* GPIO7 = ASI2 DOUT */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like hard-coding pin configurations like this. Especially setting grounded pin to output mode (on vince all "default" asi2 pins are connected to ground according to schematic). Meanwhile actually connected GPIO3 is not configured (default config seems to be interrupt output).

I think pin connections should be explicitly described in DT, something like this:

ti,i2s-asi1-pins = "gpio1", "gpio2", "gpi1", "gpio3">;
ti,i2s-asi2-pins = "gpio5", "gpio6", "gpio8", "gpio7";

Comment thread sound/soc/codecs/tas2557.c Outdated
Comment thread sound/soc/codecs/tas2557.c Outdated
}

/* Apply DAC gain */
tas2557_dev_update_bits(tas2557, TAS2557_SPK_CTRL_REG,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this register here or during playback with control causes volume to keep oscillating with few second period.

//
// The TAS2557 requires DSP firmware (tas2557_uCDSP.bin for PG2.x,
// tas2557_pg1p0_uCDSP.bin for PG1.0) to route audio through its internal
// DSP and DAC. Without loaded firmware the device produces no audio.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only because that firmware hides necessary init settings. I could make it produce sound on vince with just 17 writes below instead (based on ROMMODE2 config). This might not configure some features and right tuning tho.

w 4 (82 19 38) d1 50 00 10
w 1 (00 00 2a) 04
w 1 (00 01 73) 0f
w 1 (00 01 74) 00
w 1 (64 00 1b) 01
w 1 (64 00 1c) 20
w 1 (64 00 1d) 00
w 1 (64 00 1e) 00
w 1 (64 00 20) 02
w 1 (64 00 22) 08
w 1 (64 00 02) 10
w 1 (64 00 21) 08
w 1 (64 00 01) 08
w 1 (64 00 2b) 00
w 1 (64 00 2c) 40
w 1 (64 00 1f) 20
w 1 (64 00 2a) 00

offset = (tas2557->channel == 0) ? 1 : 1 + width * 2;
tas2557->asi_offset = offset;

/* Playback runs over ASI2; ASI1 is programmed too (per TI driver) */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem like a hack to merge 2 DAIs (ASIs) into one for simplicity.

}

/* Hard + soft reset, then baseline register setup */
tas2557_hw_reset(tas2557);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need to reset and reload firmware so often? There is no program/config selection anymore. Also driver doesn't enter "hardware shutdown" mode with reset low so device state isn't lost. It takes half a second to enable the just ClassD widget with this (with I2C@400KHz). Also when audio daemon starts (pulse) it triggers 10 startups and shutdowns back-to-back which is even more noticeable.

M0Rf30 added 4 commits July 18, 2026 20:25
Document the TAS2557 mono Class-D smart amplifier with an integrated
DSP for speaker protection. The device is controlled over I2C and
receives audio over I2S/TDM (ASI). It can drive a single mono speaker
or, as two devices, a stereo pair; in that case the ti,channel
property selects the audio slot each device reproduces and the
per-device tuning it applies.

The on-chip DSP boots from a firmware image generated per speaker
design with the TI PurePath Console tuning tools; the optional
firmware-name property selects a board-specific image.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
The TAS2557 is a mono Class-D smart amplifier with an on-chip DSP for
speaker protection. Audio is received over I2S/TDM (ASI) and processed
by DSP firmware before reaching the Class-D output stage.

The register map is book/page indirected behind an 8-bit regmap; the
driver layers composite book/page/register addressing on top of it.
The TI "uCDSP" firmware format (PLL, program and configuration blocks)
is parsed with bounds checking, and program 0 with a sample-rate
matched configuration is applied whenever the amplifier powers up;
the device cannot pass audio without this firmware. Firmware images
are produced per speaker design with TI's PurePath Console tuning
tools, so they are board specific; the default image name is derived
from the detected silicon revision and can be overridden with the
firmware-name device tree property.

Amplifier power is managed through DAPM. A fault interrupt handler
recovers the device from clock loss, over-current, brownout and
over-temperature events by reloading the firmware configuration.
Speaker volume and I/V-sense switches are exposed as ALSA controls.
Stereo is supported as two cooperating instances using stereo
(device 3) firmware, with per-instance DEV_A/DEV_B tuning selected by
the ti,channel property.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
Build the TAS2557 mono smart amplifier driver as a module, used by the
Xiaomi Redmi 5 Plus (vince) for its loudspeaker.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
Wire up the TAS2557 mono speaker amplifier on the Redmi 5 Plus (vince):

 - it sits on i2c_2 at 0x4c with reset on GPIO86 and IRQ on GPIO87; its
   AVDD/DVDD/IOVDD pins are fed by the always-on 1.8 V rail pm8953_l6, and
   VBAT by the always-on battery rail;

 - it is the external PA on Quinary MI2S.  The Android mixer paths route
   the speaker through QUIN_MI2S_RX, and the register-compatible Motorola
   ocean (tfa9874) and Fairphone 3 (aw8898) use Quinary as well.  Add a
   dedicated Quinary MI2S dai-link for the amplifier and register the
   QUINARY_MI2S_RX AFE DAI (SD0, per the downstream).  The internal codec
   stays on Primary MI2S, so earpiece and headphones are unaffected;

 - the MI2S pins (gpio88/91/93 plus the gpio92 word-clock, which uses the
   dedicated pri_mi2s_ws pinmux function) are configured.  The LPASS
   routes Quinary onto these pins through the quin iomux that the
   apq8016_sbc machine driver already programs in its MI2S_QUINARY path,
   so no machine-driver change is required.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
@M0Rf30
M0Rf30 force-pushed the m0rf30/7.0.9/develop branch from 638e44a to 67526b7 Compare July 18, 2026 18:27
@M0Rf30
M0Rf30 marked this pull request as draft July 18, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants