Skip to content

Conversation

@plbossart
Copy link
Member

SDCA devices are based on independent 'Functions', which are exposed in platform firmware using the DisCo 2.1 specification.

This patch adds a mechanism to parse the functions and extract basic information (adr and function type).

Example log on a MeteorLake device (which already shows problems with ACPI information...)

[ 13.069728] soundwire sdw:0:0:025d:0713:01: found invalid SDCA function type 4 ADR 1, skipped
[ 13.069743] soundwire sdw:0:0:025d:0713:01: found SDCA function type 6 ADR 3
[ 13.070166] soundwire sdw:0:1:025d:1316:01: found SDCA function type 1 ADR 4
[ 13.070750] soundwire sdw:0:2:025d:1316:01: found SDCA function type 1 ADR 4

@plbossart
Copy link
Member Author

v2: all the SDCA information is moved to a sound/soc/sdca library, and the information is parsed before the driver probe (if present).

@bardliao
Copy link
Collaborator

Thanks @plbossart Looks like a good start for SDCA driver.

@plbossart
Copy link
Member Author

@shumingfan would you happen to know what this Function 4 might be. I wonder if the function topology uses an older version of the SDCA/DisCo spec?

@plbossart plbossart force-pushed the sdw/parse-functions branch 2 times, most recently from 8e08c60 to 999b877 Compare April 17, 2024 20:32
@plbossart
Copy link
Member Author

plbossart commented Apr 17, 2024

logs with the last version

[   51.528012] rt1316-sdca sdw:0:1:025d:1316:01: found SDCA function AF04 type 1 ADR 4
[   51.528023] rt1316-sdca sdw:0:1:025d:1316:01: AF04: SDCA function has topology-features mask 0xb00
[   51.528033] acpi device:28: find_sdca_entities: AF04: found entity 0x1 type 0x2 label IT 21
[   51.528038] acpi device:28: find_sdca_entities: AF04: found entity 0x2 type 0x21 label UDMPU 21
[   51.528043] acpi device:28: find_sdca_entities: AF04: found entity 0x3 type 0x7 label FU 21
[   51.528047] acpi device:28: find_sdca_entities: AF04: found entity 0x33 type 0x11 label PDE 22
[   51.528052] acpi device:28: find_sdca_entities: AF04: found entity 0x22 type 0xa label XU 22
[   51.528056] acpi device:28: find_sdca_entities: AF04: found entity 0x29 type 0x24 label SAPU 29
[   51.528061] acpi device:28: find_sdca_entities: AF04: found entity 0x54 type 0x21 label UDMPU 23
[   51.528065] acpi device:28: find_sdca_entities: AF04: found entity 0x55 type 0x7 label FU 23
[   51.528070] acpi device:28: find_sdca_entities: AF04: found entity 0x31 type 0x11 label PDE 23
[   51.528074] acpi device:28: find_sdca_entities: AF04: found entity 0x56 type 0x3 label OT 23
[   51.528078] acpi device:28: find_sdca_entities: AF04: found entity 0x51 type 0x2 label IT 29
[   51.528082] acpi device:28: find_sdca_entities: AF04: found entity 0x34 type 0x11 label PDE 24
[   51.528086] acpi device:28: find_sdca_entities: AF04: found entity 0x24 type 0xa label XU 24
[   51.528091] acpi device:28: find_sdca_entities: AF04: found entity 0x52 type 0x3 label OT 24
[   51.528095] acpi device:28: find_sdca_entities: AF04: found entity 0x53 type 0xb label CS 24
[   51.528100] acpi device:28: find_sdca_entities: AF04: found entity 0x21 type 0xb label CS 21
[   51.528104] acpi device:28: find_sdca_entities: AF04: found entity 0x40 type 0x30 label TG 23
[   51.528638] rt1316-sdca sdw:0:2:025d:1316:01: found SDCA function AF04 type 1 ADR 4
[   51.528643] rt1316-sdca sdw:0:2:025d:1316:01: AF04: SDCA function has topology-features mask 0xb00
[   51.528651] acpi device:2a: find_sdca_entities: AF04: found entity 0x1 type 0x2 label IT 21
[   51.528655] acpi device:2a: find_sdca_entities: AF04: found entity 0x2 type 0x21 label UDMPU 21
[   51.528659] acpi device:2a: find_sdca_entities: AF04: found entity 0x3 type 0x7 label FU 21
[   51.528665] acpi device:2a: find_sdca_entities: AF04: found entity 0x33 type 0x11 label PDE 22
[   51.528668] acpi device:2a: find_sdca_entities: AF04: found entity 0x22 type 0xa label XU 22
[   51.528673] acpi device:2a: find_sdca_entities: AF04: found entity 0x29 type 0x24 label SAPU 29
[   51.528677] acpi device:2a: find_sdca_entities: AF04: found entity 0x54 type 0x21 label UDMPU 23
[   51.528681] acpi device:2a: find_sdca_entities: AF04: found entity 0x55 type 0x7 label FU 23
[   51.528685] acpi device:2a: find_sdca_entities: AF04: found entity 0x31 type 0x11 label PDE 23
[   51.528689] acpi device:2a: find_sdca_entities: AF04: found entity 0x56 type 0x3 label OT 23
[   51.528693] acpi device:2a: find_sdca_entities: AF04: found entity 0x51 type 0x2 label IT 29
[   51.528698] acpi device:2a: find_sdca_entities: AF04: found entity 0x34 type 0x11 label PDE 24
[   51.528712] acpi device:2a: find_sdca_entities: AF04: found entity 0x24 type 0xa label XU 24
[   51.528718] acpi device:2a: find_sdca_entities: AF04: found entity 0x52 type 0x3 label OT 24
[   51.528722] acpi device:2a: find_sdca_entities: AF04: found entity 0x53 type 0xb label CS 24
[   51.528726] acpi device:2a: find_sdca_entities: AF04: found entity 0x21 type 0xb label CS 21
[   51.528730] acpi device:2a: find_sdca_entities: AF04: found entity 0x40 type 0x30 label TG 23
[   51.529357] rt712-sdca sdw:0:0:025d:0713:01: found invalid SDCA function AF01 type 4 ADR 1, skipped
[   51.529374] rt712-sdca sdw:0:0:025d:0713:01: found SDCA function AF03 type 6 ADR 3
[   51.529383] acpi device:26: find_sdca_entities: AF03: found entity 0x1 type 0x31 label (null)

Now we need to figure out something useful with all this.

@shumingfan
Copy link

@shumingfan would you happen to know what this Function 4 might be. I wonder if the function topology uses an older version of the SDCA/DisCo spec?

I will try to ask the hardware team about this. If there are any results, I will give feedback.

@plbossart plbossart force-pushed the sdw/parse-functions branch from 999b877 to d43f80c Compare April 19, 2024 20:46
@vijendarmukunda
Copy link

vijendarmukunda commented Apr 22, 2024

Thanks @plbossart for pushing the SDCA driver patches. We will also try to validate sdca tables parsing on AMD platform.

@shumingfan
Copy link

I will try to ask the hardware team about this. If there are any results, I will give feedback.

The hardware engineer thinks reporting the function type 4 is a mistake.
The rt713 only needs the function type 6 actually. The rt1713 should report the mic function.

@plbossart
Copy link
Member Author

The hardware engineer thinks reporting the function type 4 is a mistake. The rt713 only needs the function type 6 actually. The rt1713 should report the mic function.

Right, that's what I thought @shumingfan. In this device there's no RT1713 (local mic disabled), so I can't check further.

Choose a reason for hiding this comment

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

Should probably acpi_get_local_address

Copy link
Member Author

@plbossart plbossart May 16, 2024

Choose a reason for hiding this comment

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

Erm, no. that function is wrong. _ADR is a 64-bit value, but the code assumes it's 32-bits.

I vaguely remember we had to fix some of the ACPI subsystem to make _ADR a true 64 bit value, this function has not been updated apparently.

Actually now I do remember, and it's even in git:

commit ca6f998cf9a259fe6019d44768064e0cfe8a925b
Author: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date:   Wed May 1 07:53:22 2019 -0500

    ACPI: bus: change _ADR representation to 64 bits

So this code would need to be updated to u64.

int acpi_get_local_address(acpi_handle handle, u32 *addr)
{
	unsigned long long adr;
	acpi_status status;

	status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
	if (ACPI_FAILURE(status))
		return -ENODATA;

	*addr = (u32)adr;
	return 0;
}

Gah.

Choose a reason for hiding this comment

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

Well you say there is no hardware that uses this feature, but cs42l43 and likely its successors make heavy use of it if they are used in SDCA mode. Not that support needs to be added right now, but just making you aware.

Copy link

@charleskeepax charleskeepax Apr 26, 2024

Choose a reason for hiding this comment

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

Probably slightly nice to use BITS_PER_TYPE(input_pin_list)

Choose a reason for hiding this comment

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

I would be tempted to add some sort of define for this max length, lot of max 40 byte strings used in the code.

Add new module for SDCA (SoundWire Device Class for Audio) support.
For now just add a mechanism to allocate a context.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
SDCA devices are based on independent 'Functions', which are exposed
in platform firmware using the DisCo 2.1 specification.

This patch adds a mechanism to parse the functions and extract basic
information (adr and function type).

Example log on a MeteorLake device (which already shows problems with
ACPI information...)

[   13.069728] soundwire sdw:0:0:025d:0713:01: found invalid SDCA function type 4 ADR 1, skipped
[   13.069743] soundwire sdw:0:0:025d:0713:01: found SDCA function type 6 ADR 3
[   13.070166] soundwire sdw:0:1:025d:1316:01: found SDCA function type 1 ADR 4
[   13.070750] soundwire sdw:0:2:025d:1316:01: found SDCA function type 1 ADR 4

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Before the driver probe, we can parse the SDCA information in platform
firmware to discover function-related information.

The SDCA information is abstracted away since:
a) not all implementations require SDCA support.
b) SDCA support will require tight integration with ASoC, specifically
the DAPM/DAI parts.

The SDCA integration follows the USB model, where the Audio Class is
handled by the sound/ subsystem. The ASoC codec drivers are the
intended users of the SDCA information reported by ACPI.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
For now only extract the ID, label and entity_type.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
In contrast to the USB spec, the SDCA only allows for well-defined
connections between entities. The intent was to limit errors/support
with a limited set of configurations. In other words, connections that
are not described in the SDCA spec are not permitted.

In order to allow for product variations, optional paths can be
supported. These options are described with a topology_features mask.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
…if non-zero

In their infinite wisdom, the MIPI SDCA subgroup allowed the semantics
of the "Command Ignored" to be overloaded.

In the MIPI SoundWire 1.x spec, the 'Command Ignored' can only happen
in three cases:
a) as a result of an access to an invalid register
b) as a result of an access to a device that is not attached to the bus
c) when enumeration is complete.

For SDCA devices, the 'Command Ignored' might be a valid response if
the device is currently 'busy' dealing with the previous
transaction. In that case, software has to poll the 'Function_Busy'
bit and re-issue the read/write command when that bit is no longer
asserted.

This behavior is currently NOT supported in the regmap and default
read/write functions, and there is currently no hardware which
implements this feature. For now the only thing we can do is to log an
error and ask end-users to report this problematic scenario.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The DisCo specification describes the connections between entities
with a 'pin-input-list' mask, and subproperties to point to the
connected entity. Unfortunately there's no direct access to the
connected entity id, so we have to search the entity list using the
'label' string, which is the only piece of information useable for a
match.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The MIPI DisCo 2.1 spec defines an "initialization table", which
contains a list of 4-byte addresses and 1 byte value. The registers
need to be updated during the initial boot and if context is lost.

Note that the data in the table is represented as an ACPI "buffer",
but the buffer is accessible with a DSD property:

ToUUID ("edb12dd0-363d-4085-a3d2-49522ca160c4")
Package (0x01)
{
  Package (0x02)
  {
    "mipi-sdca-function-initialization-table",
    "BUF0"
  }
}

Name (BUF0, Buffer (0x01BD)
{
  0x20, 0xC7, 0x00, 0x00, 0x17, 0x21, 0xC7, 0x00,
  0x00, 0x00, 0x22, 0xC7, 0x00, 0x00, 0x3E, 0x23,
  0xC7, 0x00, 0x00, 0x06, 0x24, 0xC7, 0x00, 0x00,
...
}

The connection between _DSD and ACPI is defined in the 'Data Buffer'
extension [1] already supported in the Linux kernel.

[1] https://github.com/UEFI/DSD-Guide/blob/main/src/dsd-guide.adoc#buffer-data-extension-uuid

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@plbossart plbossart force-pushed the sdw/parse-functions branch from 3795d70 to d9fc544 Compare April 30, 2024 00:24
@plbossart
Copy link
Member Author

closing for now, will re-add the functionality when basic parsing is implemented with PR #4995

@plbossart plbossart closed this May 17, 2024
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.

5 participants