This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: Setting up TAS5802 on the AM6254

Part Number: AM625

Tool/software:

Hi all,

I'm reaching out to the TI audio experts for some guidance on the integration of the TAS5802 on an AM6254 design.

Our system contains one single TAS5802, on bus I2C-0, with the I2C address set to 0x54. The codec is driven from MCASP2, which is configured as a master, with an external 24.576MHz clock fed throu EXT_AUDIO_REFCLK0 input of the AM6254.

So far I was able to configure the clocks, with some help from TI and I can see the MCASP2 driving 48kHz audio on LRCLK and BCLK with a scope. For more info see this thread

So I configured the device tree as follow to bring up the TAS5802:

/* NOTE: ball names, refer to AM6254ALW */
&main_pmx0 {
	board_pins_codec_control: pp1-pins-codec-control {
		pinctrl-single,pins = <
			AM62X_IOPAD(0xf40b4, PIN_OUTPUT, 7) /* [Speaker_Audio_PDN] (K24) GPMC0_CSn3.GPIO0_44 */
			AM62X_IOPAD(0xf40b0, PIN_INPUT, 7) /* [Speaker_Audio_FAULT] (K22) GPMC0_CSn2.GPIO0_43 */
		>;
	};
};

&main_i2c0 {
	/* On-board audio amp: TAS5802 */
	tas5802: tasdevice@54 {
		compatible = "ti,tas5802";
		status = "okay";

		pinctrl-names = "default";
		pinctrl-0 = <&board_pins_codec_control>;

		reg = <0x54>; // ADR had 4.7k to VDD
		#sound-dai-cells = <0>;
		interrupt-parent = <&main_gpio0>;
		interrupts = <43 IRQ_TYPE_EDGE_FALLING>;
		reset-gpios = <&main_gpio0 44 GPIO_ACTIVE_HIGH>;
	};
};

&mcasp2 {
	status = "okay";
	#sound-dai-cells = <0>;

	/* CLOCKS:
	 * BOARD_AUDIO_EXT_REFCLK0 <192 12> --> AHCLKR IN <192 9>
	 * BOARD_AUDIO_EXT_REFCLK0 <192 18> --> AHCLKX IN <192 15>
	 * from TI E2E:       ???? <192 30> -->      ???? <192 27>
	 * REFCLK runs at 24,576 MHz
	 */
    assigned-clocks        = <&k3_clks 192 9>, <&k3_clks 192 15>, <&k3_clks 192 27>;
    assigned-clock-parents = <&k3_clks 192 12>, <&k3_clks 192 18>, <&k3_clks 192 30>;
    assigned-clock-rates   = <24576000>, <24576000>, <0>;

	pinctrl-names = "default";
	pinctrl-0 = <&pp1_pins_mcasp2>;

	op-mode = <0>;          /* MCASP_IIS_MODE */
	tdm-slots = <2>;

	serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
	       1 0 0 0
	       0 0 0 0
	       0 0 0 0
	       0 0 0 0
	>;
	tx-num-evt = <0>;
	rx-num-evt = <0>;
};


/ {
	board_speakers: sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "Internal-Speaker";

		simple-audio-card,widgets = "Speaker", "Internal Speaker";
		simple-audio-card,routing = "Internal Speaker", "OUT";

		simple-audio-card,bitclock-master = <&mcasp2>;
		simple-audio-card,frame-master = <&mcasp2>;
		simple-audio-card,format = "i2s";
		simple-audio-card,bitclock-inversion;

		simple-audio-card,cpu {
			sound-dai = <&mcasp2>;
			system-clock-frequency = <24576000>;
		};

		simple-audio-card,codec {
			sound-dai = <&tas5802>;
		};
    };
};

In addition I used the tool shipped with the tasdevice out-of-tree driver, opened tas5802-1amp-reg.json, saved it as tas5802-1amp-reg.bin and placed it in /usr/lib/firmware on the target system.

With this setup I am running into some issues that I need help figuring out.

During boot the following messages are printed (only tasdevice entries shown):

[    5.102786] tasdevice-codec 3-0054: Primary-device = 0x54
[    5.112888] tasdevice-codec 3-0054: tasdevice_i2c_probe: GPIO 305 request error
[    5.627002] tasdevice-codec 3-0054: tasdev: regbin_ready start
[    5.633031] tasdevice-codec 3-0054: nconfig = 4
[    5.641577] tasdevice-codec 3-0054: img_sz = 884 total_config_sz = 592 offset = 292
[    5.649742] tasdevice-codec 3-0054: select_cfg_blk: profile_conf_id = 0
[    5.656463] tasdevice-codec 3-0054: select_cfg_blk: conf 0, block type:PRE_POWER_UP   device idx = 0x00
[    5.677230] tasdevice-codec 3-0054: init id = 0!
[    5.684789] tasdevice-codec 3-0054: Firmware init complete

When I run aplay or speaker-test I see the following output on the console:

[   45.300126] tasdevice-codec 3-0054: tasdevice_hw_params: Playback
[   45.306717] tasdevice-codec 3-0054: tasdevice_hw_params: BCLK rate = 1536000 Channel = 2Sample rate = 48000 slot width = 16
[   45.347272] tasdevice-codec 3-0054: powercontrol_routine:1310: enter
[   45.353665] tasdevice-codec 3-0054: select_cfg_blk: profile_conf_id = 0
[   45.360287] tasdevice-codec 3-0054: select_cfg_blk: conf 0, block type:PRE_POWER_UP   device idx = 0x00
[   45.378850] tasdevice-codec 3-0054: powercontrol_routine:1319: leave

Pin 12 (nPDN) is high, and LRCLK and BCLK have 48kHz and 1.536MHz frequencies, respectively. I have no sound through the speakers, but I am not convinced yet that this is a hardware problem.

I tried removing the interrupt specifier and the reset gpio (hogging the pin high). None of these produced effect.

What steps can I take to understand what is missing on this setup?

Thanks!

António

  • Hi Antonio,

    Can you just add "system-clock-direction-out;" in the dts file for the section:

    simple-audio-card,cpu {
    sound-dai = <&mcasp2>;
    system-clock-frequency = <24576000>;
    };

    Let me know if it helps

    Best Regards,

    Suren

  • Hi Suren,

    Thanks for the suggestion. I suspect this might not fix the issue as the scope already showed LRCLK at 48kHz and BCLK at 1.536MHz which seem the correct frequencies for this setup.

    In the meantime we found a PCB bug that is likely to cause the output stages to not switch at all and is consistent with the voltage levels that I measures. We will be reworking two boards soon and return to this.

    I'll let you know if that solves the issue.

    Best regards,

    António

  • Thanks Antonio. I will wait for you to update on how it goes after reworking on your boards.

    Best Regards,

    Suren

  • Hi Suren,

    Sorry for the delay. I have an update and, finally, some progress!

    The rework of the amplifier circuit (BOOST and OUT connections were swapped on one channel) fixed our hardware issue. We can now play through the TAS5802 (both channels).

    There are still some pending issues, though:

    1. I am unable to configure the interrupt for the devicetree node

    If I have this in the codec devicetree node:

    interrupt-parent = <&main_gpio0>;
    interrupts = <43 IRQ_TYPE_EDGE_FALLING>;

    The kernel module prints out the following error during probe:

    [    5.148278] tasdevice-codec 3-0054: tasdevice_i2c_probe: GPIO 304 request error

    This doesn't seem to affect audio output, though (see ahead for other issues).

    I am currently running the tasdevice SHA:810b651d7d349638f80e0a96e81889388e55dff2 with linux-6.12 (SDK 11.00.10) with trivial changes to handle the new location of asm/unaligned.h

    I traced this to the following code in the tasdriver code (tasdevice-core.c, from line 1466):

    dev_dbg(tas_dev->dev, "irq-gpio = %d", tas_dev->irqinfo.irq_gpio);
    INIT_DELAYED_WORK(&tas_dev->irqinfo.irq_work, irq_work_routine);
    
    ret = gpio_request(tas_dev->irqinfo.irq_gpio, "TASDEV-IRQ");
    //-----> NOTE: ret is assigned -517 which I believe is -EPROBE_DEFER
    if (!ret) {
    	gpio_direction_input(tas_dev->irqinfo.irq_gpio);
    
    	tas_dev->irqinfo.irq = gpio_to_irq(tas_dev->irqinfo.irq_gpio);
    	dev_info(tas_dev->dev, "irq = %d\n", tas_dev->irqinfo.irq);
    
    	ret = request_threaded_irq(tas_dev->irqinfo.irq,
    		tasdevice_irq_handler, NULL, IRQF_TRIGGER_FALLING |
    		IRQF_ONESHOT, tas_dev->client->name, tas_dev);
    	if (!ret)
    		disable_irq_nosync(tas_dev->irqinfo.irq);
    	else
    		dev_err(tas_dev->dev, "request_irq failed, %d\n", ret);
    } else {
    	dev_err(tas_dev->dev, "%s: GPIO %d request error\n", __func__,
    		tas_dev->irqinfo.irq_gpio);
    }

    As a kernel user (not developer), I can't fathom why this error is being reported (it also appeared on linux-6.6 from SDK10). Are there any hints about what this might be and any potential ill-effects it has on the amplifier operation?

    2. The amplifier doesn't enter PLAY mode when I play through it

    After being positive that the McASP was outputting the correct audio frames I focused on the TAS5802 and used the debugging instructions to fetch its regdump:

    # echo 0 0x00 0x00 > regdump
    # cat regdump
    i2c-addr: 0x54
    DeviceID: 0x0d
    Chn0B0x00P0x00R0x00:0x00
    Chn0B0x00P0x00R0x01:0x11
    Chn0B0x00P0x00R0x02:0x01
    Chn0B0x00P0x00R0x03:0x02 <<------- HiZ mode while playing??
    Chn0B0x00P0x00R0x04:0x00
    Chn0B0x00P0x00R0x05:0x00
    Chn0B0x00P0x00R0x06:0x00
    Chn0B0x00P0x00R0x07:0x00
    Chn0B0x00P0x00R0x08:0x00
    Chn0B0x00P0x00R0x09:0x00
    Chn0B0x00P0x00R0x0a:0x00
    Chn0B0x00P0x00R0x0b:0x00
    Chn0B0x00P0x00R0x0c:0x00
    Chn0B0x00P0x00R0x0d:0x00
    Chn0B0x00P0x00R0x0e:0x00
    Chn0B0x00P0x00R0x0f:0x00
    Chn0B0x00P0x00R0x10:0x01
    Chn0B0x00P0x00R0x11:0x00
    Chn0B0x00P0x00R0x12:0x00
    Chn0B0x00P0x00R0x13:0x00
    Chn0B0x00P0x00R0x14:0x11
    Chn0B0x00P0x00R0x15:0x00
    Chn0B0x00P0x00R0x16:0x00
    Chn0B0x00P0x00R0x17:0x00
    Chn0B0x00P0x00R0x18:0x00
    Chn0B0x00P0x00R0x19:0x00
    Chn0B0x00P0x00R0x1a:0x00
    Chn0B0x00P0x00R0x1b:0x00
    Chn0B0x00P0x00R0x1c:0x00
    Chn0B0x00P0x00R0x1d:0x00
    Chn0B0x00P0x00R0x1e:0x00
    Chn0B0x00P0x00R0x1f:0x00
    Chn0B0x00P0x00R0x20:0x01
    Chn0B0x00P0x00R0x21:0x07
    Chn0B0x00P0x00R0x22:0x09
    Chn0B0x00P0x00R0x23:0x01
    Chn0B0x00P0x00R0x24:0x00
    Chn0B0x00P0x00R0x25:0x40
    Chn0B0x00P0x00R0x26:0x02
    Chn0B0x00P0x00R0x27:0x00
    Chn0B0x00P0x00R0x28:0x00
    Chn0B0x00P0x00R0x29:0x00
    Chn0B0x00P0x00R0x2a:0x00
    Chn0B0x00P0x00R0x2b:0x00
    Chn0B0x00P0x00R0x2c:0x00
    Chn0B0x00P0x00R0x2d:0x00
    Chn0B0x00P0x00R0x2e:0x00
    Chn0B0x00P0x00R0x2f:0x00
    Chn0B0x00P0x00R0x30:0x00
    Chn0B0x00P0x00R0x31:0x00
    Chn0B0x00P0x00R0x32:0x00
    Chn0B0x00P0x00R0x33:0x02
    Chn0B0x00P0x00R0x34:0x00
    Chn0B0x00P0x00R0x35:0x11
    Chn0B0x00P0x00R0x36:0x00
    Chn0B0x00P0x00R0x37:0x00
    Chn0B0x00P0x00R0x38:0x40
    Chn0B0x00P0x00R0x39:0x00
    Chn0B0x00P0x00R0x3a:0xf9
    Chn0B0x00P0x00R0x3b:0x04
    Chn0B0x00P0x00R0x3c:0x60
    Chn0B0x00P0x00R0x3d:0x20
    Chn0B0x00P0x00R0x3e:0x80
    Chn0B0x00P0x00R0x3f:0x00
    Chn0B0x00P0x00R0x40:0x01
    Chn0B0x00P0x00R0x41:0x00
    Chn0B0x00P0x00R0x42:0x00
    Chn0B0x00P0x00R0x43:0x00
    Chn0B0x00P0x00R0x44:0x00
    Chn0B0x00P0x00R0x45:0x00
    Chn0B0x00P0x00R0x46:0x11
    Chn0B0x00P0x00R0x47:0x00
    Chn0B0x00P0x00R0x48:0x00
    Chn0B0x00P0x00R0x49:0x00
    Chn0B0x00P0x00R0x4a:0x00
    Chn0B0x00P0x00R0x4b:0x00
    Chn0B0x00P0x00R0x4c:0x30
    Chn0B0x00P0x00R0x4d:0x30
    Chn0B0x00P0x00R0x4e:0x33
    Chn0B0x00P0x00R0x4f:0x30
    Chn0B0x00P0x00R0x50:0x00
    Chn0B0x00P0x00R0x51:0x55
    Chn0B0x00P0x00R0x52:0x00
    Chn0B0x00P0x00R0x53:0x01
    Chn0B0x00P0x00R0x54:0x00
    Chn0B0x00P0x00R0x55:0x00
    Chn0B0x00P0x00R0x56:0x00
    Chn0B0x00P0x00R0x57:0x00
    Chn0B0x00P0x00R0x58:0x00
    Chn0B0x00P0x00R0x59:0x00
    Chn0B0x00P0x00R0x5a:0x00
    Chn0B0x00P0x00R0x5b:0x00
    Chn0B0x00P0x00R0x5c:0x00
    Chn0B0x00P0x00R0x5d:0xf8
    Chn0B0x00P0x00R0x5e:0x00
    Chn0B0x00P0x00R0x5f:0x00
    Chn0B0x00P0x00R0x60:0x01
    Chn0B0x00P0x00R0x61:0x0b
    Chn0B0x00P0x00R0x62:0x00
    Chn0B0x00P0x00R0x63:0x00
    Chn0B0x00P0x00R0x64:0x00
    Chn0B0x00P0x00R0x65:0x00
    Chn0B0x00P0x00R0x66:0x03
    Chn0B0x00P0x00R0x67:0xa8
    Chn0B0x00P0x00R0x68:0x00
    Chn0B0x00P0x00R0x69:0x00
    Chn0B0x00P0x00R0x6a:0x00
    Chn0B0x00P0x00R0x6b:0x00
    Chn0B0x00P0x00R0x6c:0x00
    Chn0B0x00P0x00R0x6d:0x50
    Chn0B0x00P0x00R0x6e:0x11
    Chn0B0x00P0x00R0x6f:0x24
    Chn0B0x00P0x00R0x70:0x00
    Chn0B0x00P0x00R0x71:0x00
    Chn0B0x00P0x00R0x72:0x00
    Chn0B0x00P0x00R0x73:0x00
    Chn0B0x00P0x00R0x74:0x00
    Chn0B0x00P0x00R0x75:0x38
    Chn0B0x00P0x00R0x76:0x00
    Chn0B0x00P0x00R0x77:0xff
    Chn0B0x00P0x00R0x78:0x80
    Chn0B0x00P0x00R0x79:0x00
    Chn0B0x00P0x00R0x7a:0x09
    Chn0B0x00P0x00R0x7b:0x03
    Chn0B0x00P0x00R0x7c:0x00
    Chn0B0x00P0x00R0x7d:0x00
    Chn0B0x00P0x00R0x7e:0xe0
    Chn0B0x00P0x00R0x7f:0x00
    ======caught smartpa reg end ======

    Inspecting the regdump with the TAS5802 datasheet I see that STATE_CTL from DEVICE_CTRL2 register (3h) is set to Hi-Z

    I tried manually setting it to PLAY with:
    echo 0 0x00 0x00 0x03 0x03 > reg

    And immediately the amplifier started to drive the speakers.

    This is the output from the driver, just in case it is relevant:

    [ 1174.561113] tasdevice-codec 3-0054: tasdevice_hw_params: Playback
    [ 1174.569234] tasdevice-codec 3-0054: tasdevice_hw_params: BCLK rate = 1536000 Channel = 2 Sample rate = 48000 slot width = 16
    [ 1174.608625] tasdevice-codec 3-0054: powercontrol_routine:1276: enter
    [ 1174.615036] tasdevice-codec 3-0054: select_cfg_blk: profile_conf_id = 0
    [ 1174.621664] tasdevice-codec 3-0054: select_cfg_blk: conf 0, block type:PRE_POWER_UP   device idx = 0x00
    [ 1174.640313] tasdevice-codec 3-0054: powercontrol_routine:1285: leave

    I'm not sure I can attach the .bin file, which was generated from tas5802-1amp-reg.json from the same repo as the driver using the instructions. Please let me know if there's a way to do it.

    My expectation was to have the amplifier playing without me poking its registers. Any thoughts on what may cause this?

    3. Mixer controls have no effect

    The mixer controls reported by alsa are:

    # amixer scontrols
    Simple mixer control 'TASDEVICE Profile id',0

    If I use the control during playback nothing changes. I can work around this with alsa plugins and softvol but, still, It'd be good to have the mixer control actually controlling the output level. Also, not doing so may be a sign of some software issue. Please advise on how to make the mixer control operational.

    Despite these quirks, I'm happy that I was able to finally play something from the AM62 because it means that the clocking is right (I had other questions about this topic) and the sound card and codec is (mostly) right. It also means the hardware does work!

    Hopefully we are very close to a fully operational solutions.

    Best regards,

    António

  • Antonio,

    I am glad it is working fine after the board modifications. Do you still need support on this? If not, I will go ahead and close the thread.

    Please feel free to open newer threads for any issues.

    Best Regards,

    Suren

  • Hi Suren, I still have the above issue that the amplifier does not play unless I manually write into register 0x03.

    Please see the second issue on my post above and let me know what we can do to fix it. Issues 1 and 3 don't seem to be blocking anything and we can live with those, but issue number 2 is a showstopper for us and I believe there must be something that can be done (and that I may be missing) to have the amplifier come alive without user intervention, other than calling aplay.

    Best regards,

    António

  • Hi Suren,

    Do you have any advise regarding the problem of the amplifier not waking up when we attempt to play audio through it?

    If this is a topic for a separate question, please let me know and I'll open it. As it is, the amplifier is not yet functional out of the box.

    Thanks,

    António

  • Hi Antonio,

    Apologies for the delay, was out of office for last few days.

    Please have a separate thread created as its Amplifier problem and I won't be able to help much here.

    Let me know once the thread is created to route to the right expert.

    Best Regards,

    Suren

  • Hi Suren, thanks for circling back to this.

    I picked the relevant portion from this topic and opened a new question here

    Many thanks for your assistance in this topic,

    António

  • Thanks Antonio. I see an expert has been assigned for the newer thread. I am going to close this thread.

    Best Regards,

    Suren