Skip to content

Commit d9fc544

Browse files
committed
ASoC: sdca: extract function initialization table
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>
1 parent 19e7f55 commit d9fc544

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

include/sound/sdca_function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ struct sdca_entity {
106106
* @function_busy_max_delay_us: indicates if hardware can assert the Function_Busy
107107
* bit, which requires special-casing of the 'Command Ignored' response. If zero,
108108
* then the Host shall assume this bit is never asserted.
109+
* @initialization_table: set of 4-byte address/byte value to set-up the Function
110+
* during boot and resume if context is lost
111+
* @initialization_table_size: size of @initialization_table
109112
*/
110113
struct sdca_function {
111114
u8 adr; /* limited range since only 8 functions can be supported */
@@ -114,6 +117,8 @@ struct sdca_function {
114117
int num_entities;
115118
struct sdca_entity *entities;
116119
u32 function_busy_max_delay_us;
120+
u8 *initialization_table;
121+
int initialization_table_size;
117122
};
118123

119124
/**

sound/soc/sdca/sdca_functions.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,48 @@ static int find_sdca_entities_connections(struct device *dev,
253253
return 0;
254254
}
255255

256+
static int find_sdca_function_initialization_table(struct device *dev,
257+
struct fwnode_handle *function_node,
258+
struct sdca_function *function)
259+
{
260+
u8 *initialization_table;
261+
int nval;
262+
int ret;
263+
264+
nval = fwnode_property_count_u8(function_node,
265+
"mipi-sdca-function-initialization-table");
266+
if (nval <= 0)
267+
return nval;
268+
269+
/* make sure the table contains a set of 4-byte addresses and one-byte value */
270+
if (nval % 5) {
271+
dev_err(dev, "%s: %pfwP: invalid initialization table size %#x\n",
272+
__func__, function_node, nval);
273+
return -EINVAL;
274+
}
275+
276+
dev_info(dev, "%s: %pfwP: initialization table size %#x\n",
277+
__func__, function_node, nval);
278+
279+
initialization_table = devm_kcalloc(dev, nval,
280+
sizeof(*initialization_table),
281+
GFP_KERNEL);
282+
if (!initialization_table)
283+
return -ENOMEM;
284+
285+
ret = fwnode_property_read_u8_array(function_node,
286+
"mipi-sdca-function-initialization-table",
287+
initialization_table,
288+
nval);
289+
if (ret < 0)
290+
return ret;
291+
292+
function->initialization_table = initialization_table;
293+
function->initialization_table_size = nval;
294+
295+
return 0;
296+
}
297+
256298
static int find_sdca_function(struct acpi_device *adev, void *data)
257299
{
258300
struct fwnode_handle *function_node = acpi_fwnode_handle(adev);
@@ -348,6 +390,11 @@ static int find_sdca_function(struct acpi_device *adev, void *data)
348390
topology_features;
349391
}
350392

393+
ret = find_sdca_function_initialization_table(parent, function_node,
394+
&sdca->functions[sdca->function_count]);
395+
if (ret < 0)
396+
return ret;
397+
351398
ret = find_sdca_entities(&adev->dev,
352399
function_node,
353400
&sdca->functions[sdca->function_count]);

0 commit comments

Comments
 (0)