Unverified Commit 478fc2f4 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC/soundwire: add initial support for SDCA

Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

We need to get rt712 version by reading SDCA version and functions.
This patch series adds initial support for SDCA and add a helper to tell
if the codec is RT712_VB.

This series may go via the ASoC tree with Vinod's Acked-by tag.

Bard Liao (1):
  soundwire: sdw_intel: include linux/acpi.h

Pierre-Louis Bossart (10):
  ASoC/soundwire: remove sdw_slave_extended_id
  ASoC: SDCA: add initial module
  soundwire: slave: lookup SDCA version and functions
  ASoC: SDCA: add quirk function for RT712_VB match
  ASoC: rt712-sdca: detect the SMART_MIC function during the probe stage
  ASoC: soc-acpi: introduce new 'machine check' callback
  ASoC: sdw_utils: add SmartMic DAI for RT712 VB
  ASoC: sdw_utils: add SmartMic DAI for RT713 VB
  ASoC: Intel: soc-acpi: add is_device_rt712_vb() helper
  ASoC: SOF: Intel: hda: use machine_check() for SoundWire

 drivers/soundwire/Kconfig                     |   1 +
 drivers/soundwire/amd_init.c                  |  12 +-
 drivers/soundwire/intel_init.c                |  13 +-
 drivers/soundwire/slave.c                     |  14 ++
 include/linux/soundwire/sdw.h                 |   9 +-
 include/linux/soundwire/sdw_amd.h             |   7 +-
 include/linux/soundwire/sdw_intel.h           |   8 +-
 include/sound/sdca.h                          |  62 +++++++
 include/sound/sdca_function.h                 |  55 ++++++
 include/sound/soc-acpi.h                      |   8 +-
 sound/soc/Kconfig                             |   1 +
 sound/soc/Makefile                            |   1 +
 sound/soc/amd/ps/pci-ps.c                     |   3 +-
 sound/soc/codecs/rt712-sdca-sdw.c             |   1 +
 sound/soc/codecs/rt712-sdca.c                 |  38 +++-
 sound/soc/codecs/rt712-sdca.h                 |   1 +
 sound/soc/intel/Kconfig                       |   5 +
 sound/soc/intel/common/Makefile               |   3 +
 .../intel/common/soc-acpi-intel-mtl-match.c   |  51 ++++++
 .../intel/common/soc-acpi-intel-sdca-quirks.c |  42 +++++
 .../intel/common/soc-acpi-intel-sdca-quirks.h |  14 ++
 sound/soc/sdca/Kconfig                        |  11 ++
 sound/soc/sdca/Makefile                       |   5 +
 sound/soc/sdca/sdca_device.c                  |  67 +++++++
 sound/soc/sdca/sdca_functions.c               | 173 ++++++++++++++++++
 sound/soc/sdw_utils/soc_sdw_utils.c           |  18 +-
 sound/soc/soc-acpi.c                          |  30 +--
 sound/soc/sof/amd/acp-common.c                |   3 +-
 sound/soc/sof/intel/hda.c                     |  19 +-
 29 files changed, 610 insertions(+), 65 deletions(-)
 create mode 100644 include/sound/sdca.h
 create mode 100644 include/sound/sdca_function.h
 create mode 100644 sound/soc/intel/common/soc-acpi-intel-sdca-quirks.c
 create mode 100644 sound/soc/intel/common/soc-acpi-intel-sdca-quirks.h
 create mode 100644 sound/soc/sdca/Kconfig
 create mode 100644 sound/soc/sdca/Makefile
 create mode 100644 sound/soc/sdca/sdca_device.c
 create mode 100644 sound/soc/sdca/sdca_functions.c

--
2.43.0
parents 42fb5161 e92edcf8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
menuconfig SOUNDWIRE
	tristate "SoundWire support"
	depends on ACPI || OF
	depends on SND_SOC_SDCA_OPTIONAL
	help
	  SoundWire is a 2-Pin interface with data and clock line ratified
	  by the MIPI Alliance. SoundWire is used for transporting data
+6 −6
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ EXPORT_SYMBOL_NS(sdw_amd_probe, SOUNDWIRE_AMD_INIT);
void sdw_amd_exit(struct sdw_amd_ctx *ctx)
{
	sdw_amd_cleanup(ctx);
	kfree(ctx->ids);
	kfree(ctx->peripherals);
	kfree(ctx);
}
EXPORT_SYMBOL_NS(sdw_amd_exit, SOUNDWIRE_AMD_INIT);
@@ -204,10 +204,11 @@ int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx)
			num_slaves++;
	}

	ctx->ids = kcalloc(num_slaves, sizeof(*ctx->ids), GFP_KERNEL);
	if (!ctx->ids)
	ctx->peripherals = kmalloc(struct_size(ctx->peripherals, array, num_slaves),
				   GFP_KERNEL);
	if (!ctx->peripherals)
		return -ENOMEM;
	ctx->num_slaves = num_slaves;
	ctx->peripherals->num_peripherals = num_slaves;
	for (index = 0; index < ctx->count; index++) {
		if (!(ctx->link_mask & BIT(index)))
			continue;
@@ -215,8 +216,7 @@ int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx)
		if (amd_manager) {
			bus = &amd_manager->bus;
			list_for_each_entry(slave, &bus->slaves, node) {
				ctx->ids[i].id = slave->id;
				ctx->ids[i].link_id = bus->link_id;
				ctx->peripherals->array[i] = slave;
				i++;
			}
		}
+6 −7
Original line number Diff line number Diff line
@@ -252,17 +252,16 @@ static struct sdw_intel_ctx
			num_slaves++;
	}

	ctx->ids = kcalloc(num_slaves, sizeof(*ctx->ids), GFP_KERNEL);
	if (!ctx->ids)
	ctx->peripherals = kmalloc(struct_size(ctx->peripherals, array, num_slaves),
				   GFP_KERNEL);
	if (!ctx->peripherals)
		goto err;

	ctx->num_slaves = num_slaves;
	ctx->peripherals->num_peripherals = num_slaves;
	i = 0;
	list_for_each_entry(link, &ctx->link_list, list) {
		bus = &link->cdns->bus;
		list_for_each_entry(slave, &bus->slaves, node) {
			ctx->ids[i].id = slave->id;
			ctx->ids[i].link_id = bus->link_id;
			ctx->peripherals->array[i] = slave;
			i++;
		}
	}
@@ -371,7 +370,7 @@ void sdw_intel_exit(struct sdw_intel_ctx *ctx)
	}

	sdw_intel_cleanup(ctx);
	kfree(ctx->ids);
	kfree(ctx->peripherals);
	kfree(ctx->ldev);
	kfree(ctx);
}
+14 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <linux/of.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include <sound/sdca.h>
#include "bus.h"
#include "sysfs_local.h"

@@ -70,6 +71,17 @@ int sdw_slave_add(struct sdw_bus *bus,
	list_add_tail(&slave->node, &bus->slaves);
	mutex_unlock(&bus->bus_lock);

	/*
	 * The Soundwire driver probe may optionally register SDCA
	 * sub-devices, one per Function. This means the information
	 * on the SDCA revision and the number/type of Functions need
	 * to be extracted from platform firmware before the SoundWire
	 * driver probe, and as a consequence before the SoundWire
	 * device_register() below.
	 */
	sdca_lookup_interface_revision(slave);
	sdca_lookup_functions(slave);

	ret = device_register(&slave->dev);
	if (ret) {
		dev_err(bus->dev, "Failed to add slave: ret %d\n", ret);
@@ -259,3 +271,5 @@ int sdw_of_find_slaves(struct sdw_bus *bus)

	return 0;
}

MODULE_IMPORT_NS(SND_SOC_SDCA);
+6 −3
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/irqdomain.h>
#include <linux/mod_devicetable.h>
#include <linux/bitfield.h>
#include <sound/sdca.h>

struct sdw_bus;
struct sdw_slave;
@@ -488,9 +489,9 @@ struct sdw_slave_id {
	__u8 sdw_version:4;
};

struct sdw_extended_slave_id {
	int link_id;
	struct sdw_slave_id id;
struct sdw_peripherals {
	int num_peripherals;
	struct sdw_slave *array[];
};

/*
@@ -663,6 +664,7 @@ struct sdw_slave_ops {
 * @is_mockup_device: status flag used to squelch errors in the command/control
 * protocol for SoundWire mockup devices
 * @sdw_dev_lock: mutex used to protect callbacks/remove races
 * @sdca_data: structure containing all device data for SDCA helpers
 */
struct sdw_slave {
	struct sdw_slave_id id;
@@ -686,6 +688,7 @@ struct sdw_slave {
	bool first_interrupt_done;
	bool is_mockup_device;
	struct mutex sdw_dev_lock; /* protect callbacks/remove races */
	struct sdca_device_data sdca_data;
};

#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)
Loading