2023-03-23 05:31:59

by Bard Liao

[permalink] [raw]
Subject: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x

This series uses the abstraction added in past kernel cycles to provide
support for the ACE2.x integration. The existing SHIM and Cadence
registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
parts also moved to the HDaudio Extended Multi link structures. Nothing
fundamentally different except for the register map.

This series only provides the basic mechanisms to expose SoundWire-based
DAIs. The PCI parts and DSP management will be contributed later, and the
DAI ops are now empty as well.

The change is mainly on SoundWire. It would be better to go through
SoundWire tree.

Pierre-Louis Bossart (20):
ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
soundwire: intel: add ACE2.x SHIM definitions
soundwire: intel_ace2x: add empty new ops for LunarLake
soundwire/ASOC: Intel: update offsets for LunarLake
soundwire: intel/cadence: set ip_offset at run-time
ASoC/soundwire: intel: pass hdac_bus pointer for link management
soundwire: intel: add eml_lock in the interface for new platforms
ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
soundwire: intel_init: use eml_lock parameter
soundwire: intel_ace2x: add debugfs support
soundwire: intel_ace2x: add link power-up/down helpers
soundwire: intel_ace2x: set SYNCPRD before powering-up
soundwire: intel_ace2x: configure link PHY
soundwire: intel_ace2x: add DAI registration
soundwire: intel_ace2x: add sync_arm/sync_go helpers
soundwire: intel_ace2x: use common helpers for bus start/stop
soundwire: intel_ace2x: enable wake support
soundwire: intel_ace2x: add check_cmdsync_unlocked helper
soundwire: bus: add new manager callback to deal with peripheral
enumeration
soundwire: intel_ace2x: add new_peripheral_assigned callback

drivers/soundwire/Makefile | 3 +-
drivers/soundwire/bus.c | 3 +
drivers/soundwire/cadence_master.h | 2 +
drivers/soundwire/intel.h | 16 +
drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
drivers/soundwire/intel_auxdevice.c | 17 ++
drivers/soundwire/intel_init.c | 21 +-
include/linux/soundwire/sdw.h | 3 +-
include/linux/soundwire/sdw_intel.h | 88 ++++++
sound/soc/sof/intel/hda.c | 31 +-
sound/soc/sof/intel/shim.h | 1 +
12 files changed, 711 insertions(+), 11 deletions(-)
create mode 100644 drivers/soundwire/intel_ace2x.c
create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c

--
2.25.1


2023-03-23 05:31:59

by Bard Liao

[permalink] [raw]
Subject: [PATCH 03/20] soundwire: intel_ace2x: add empty new ops for LunarLake

From: Pierre-Louis Bossart <[email protected]>

The register map and programming sequences for the ACE2.x IP are
completely different and need to be abstracted with a different set of
callbacks.

This initial patch adds a new file, follow-up patches will add each
required callback.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/Makefile | 2 +-
drivers/soundwire/intel_ace2x.c | 19 +++++++++++++++++++
include/linux/soundwire/sdw_intel.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 drivers/soundwire/intel_ace2x.c

diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
index 8038e840ac5b..d7212777a927 100644
--- a/drivers/soundwire/Makefile
+++ b/drivers/soundwire/Makefile
@@ -20,7 +20,7 @@ soundwire-cadence-y := cadence_master.o
obj-$(CONFIG_SOUNDWIRE_CADENCE) += soundwire-cadence.o

#Intel driver
-soundwire-intel-y := intel.o intel_auxdevice.o intel_init.o dmi-quirks.o \
+soundwire-intel-y := intel.o intel_ace2x.o intel_auxdevice.o intel_init.o dmi-quirks.o \
intel_bus_common.o
obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel.o

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
new file mode 100644
index 000000000000..623e4fd7db91
--- /dev/null
+++ b/drivers/soundwire/intel_ace2x.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+// Copyright(c) 2023 Intel Corporation. All rights reserved.
+
+/*
+ * Soundwire Intel ops for LunarLake
+ */
+
+#include <linux/acpi.h>
+#include <linux/device.h>
+#include <linux/soundwire/sdw_registers.h>
+#include <linux/soundwire/sdw.h>
+#include <linux/soundwire/sdw_intel.h>
+#include "cadence_master.h"
+#include "bus.h"
+#include "intel.h"
+
+const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
+};
+EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index 8e6183e029fa..66687e83a94f 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -419,5 +419,6 @@ struct sdw_intel_hw_ops {
};

extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;
+extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops;

#endif
--
2.25.1

2023-03-23 05:32:08

by Bard Liao

[permalink] [raw]
Subject: [PATCH 05/20] soundwire: intel/cadence: set ip_offset at run-time

From: Pierre-Louis Bossart <[email protected]>

Select relevant ip-offset depending on hardware version. This offset
is used to access MCP_ or IP_MCP_ registers with a fixed offset.

For existing platforms, the offset is exactly zero. Starting with
LunarLake, the offset is 0x4000.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/cadence_master.h | 2 ++
drivers/soundwire/intel.h | 2 ++
drivers/soundwire/intel_auxdevice.c | 1 +
drivers/soundwire/intel_init.c | 2 ++
4 files changed, 7 insertions(+)

diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index b653734085d9..b0f0bf90640b 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -14,6 +14,8 @@
*/
#define CDNS_MCP_IP_MAX_CMD_LEN 32

+#define SDW_CADENCE_MCP_IP_OFFSET 0x4000
+
/**
* struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
*
diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h
index 51aa42a5a824..1b23292bb8be 100644
--- a/drivers/soundwire/intel.h
+++ b/drivers/soundwire/intel.h
@@ -10,6 +10,7 @@
* @hw_ops: platform-specific ops
* @mmio_base: mmio base of SoundWire registers
* @registers: Link IO registers base
+ * @ip_offset: offset for MCP_IP registers
* @shim: Audio shim pointer
* @shim_vs: Audio vendor-specific shim pointer
* @alh: ALH (Audio Link Hub) pointer
@@ -28,6 +29,7 @@ struct sdw_intel_link_res {

void __iomem *mmio_base; /* not strictly needed, useful for debug */
void __iomem *registers;
+ u32 ip_offset;
void __iomem *shim;
void __iomem *shim_vs;
void __iomem *alh;
diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
index 5021be0f4158..b02cef4f4b66 100644
--- a/drivers/soundwire/intel_auxdevice.c
+++ b/drivers/soundwire/intel_auxdevice.c
@@ -144,6 +144,7 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
sdw->link_res = &ldev->link_res;
cdns->dev = dev;
cdns->registers = sdw->link_res->registers;
+ cdns->ip_offset = sdw->link_res->ip_offset;
cdns->instance = sdw->instance;
cdns->msg_count = 0;

diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index e0023af9e0e1..43d339c6bcee 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -66,10 +66,12 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
if (!res->ext) {
link->registers = res->mmio_base + SDW_LINK_BASE
+ (SDW_LINK_SIZE * link_id);
+ link->ip_offset = 0;
link->shim = res->mmio_base + res->shim_base;
link->alh = res->mmio_base + res->alh_base;
} else {
link->registers = res->mmio_base + SDW_IP_BASE(link_id);
+ link->ip_offset = SDW_CADENCE_MCP_IP_OFFSET;
link->shim = res->mmio_base + SDW_SHIM2_GENERIC_BASE(link_id);
link->shim_vs = res->mmio_base + SDW_SHIM2_VS_BASE(link_id);
}
--
2.25.1

2023-03-23 05:32:13

by Bard Liao

[permalink] [raw]
Subject: [PATCH 06/20] ASoC/soundwire: intel: pass hdac_bus pointer for link management

From: Pierre-Louis Bossart <[email protected]>

The hdac_bus pointer is used to access the extended link information
and handle power management. Pass it from the SOF driver down to the
auxiliary devices.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel.h | 4 ++++
drivers/soundwire/intel_init.c | 2 ++
include/linux/soundwire/sdw_intel.h | 4 ++++
sound/soc/sof/intel/hda.c | 1 +
4 files changed, 11 insertions(+)

diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h
index 1b23292bb8be..cf9db4906de4 100644
--- a/drivers/soundwire/intel.h
+++ b/drivers/soundwire/intel.h
@@ -4,6 +4,8 @@
#ifndef __SDW_INTEL_LOCAL_H
#define __SDW_INTEL_LOCAL_H

+struct hdac_bus;
+
/**
* struct sdw_intel_link_res - Soundwire Intel link resource structure,
* typically populated by the controller driver.
@@ -23,6 +25,7 @@
* @link_mask: global mask needed for power-up/down sequences
* @cdns: Cadence master descriptor
* @list: used to walk-through all masters exposed by the same controller
+ * @hbus: hdac_bus pointer, needed for power management
*/
struct sdw_intel_link_res {
const struct sdw_intel_hw_ops *hw_ops;
@@ -42,6 +45,7 @@ struct sdw_intel_link_res {
u32 link_mask;
struct sdw_cdns *cdns;
struct list_head list;
+ struct hdac_bus *hbus;
};

struct sdw_intel {
diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index 43d339c6bcee..c918d2b81cc3 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -84,6 +84,8 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
link->shim_mask = &ctx->shim_mask;
link->link_mask = ctx->link_mask;

+ link->hbus = res->hbus;
+
/* now follow the two-step init/add sequence */
ret = auxiliary_device_init(auxdev);
if (ret < 0) {
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index 88eb5bf98140..c4281aa06e2e 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -269,6 +269,8 @@ struct sdw_intel_slave_id {
struct sdw_slave_id id;
};

+struct hdac_bus;
+
/**
* struct sdw_intel_ctx - context allocated by the controller
* driver probe
@@ -324,6 +326,7 @@ struct sdw_intel_ctx {
* @shim_base: sdw shim base.
* @alh_base: sdw alh base.
* @ext: extended HDaudio link support
+ * @hbus: hdac_bus pointer, needed for power management
*/
struct sdw_intel_res {
const struct sdw_intel_hw_ops *hw_ops;
@@ -339,6 +342,7 @@ struct sdw_intel_res {
u32 shim_base;
u32 alh_base;
bool ext;
+ struct hdac_bus *hbus;
};

/*
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index db103524be4f..22eba57bb3e6 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -229,6 +229,7 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
res.ops = &sdw_callback;
res.dev = sdev->dev;
res.clock_stop_quirks = sdw_clock_stop_quirks;
+ res.hbus = sof_to_bus(sdev);

/*
* ops and arg fields are not populated for now,
--
2.25.1

2023-03-23 05:32:16

by Bard Liao

[permalink] [raw]
Subject: [PATCH 07/20] soundwire: intel: add eml_lock in the interface for new platforms

From: Pierre-Louis Bossart <[email protected]>

In existing Intel/SoundWire systems, all the SoundWire configuration
is 'self-contained', with the 'shim_lock' mutex used to protect access
to shared registers in multi-link configurations.

With the move of part of the SoundWire registers to the HDaudio
multi-link structure, we need a unified lock. The hda-mlink
implementation provides an 'eml_lock' that is used to protect shared
registers such as LCTL and LSYNC, we can pass it to the SoundWire
side. There is no issue with possible dangling pointers since the
SoundWire auxiliary devices are children of the PCI device, so the
'eml_lock' cannot be removed while the SoundWire side is in use.

This patch only adds the interface for now.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
include/linux/soundwire/sdw_intel.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index c4281aa06e2e..bafc6f2554b0 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -327,6 +327,8 @@ struct sdw_intel_ctx {
* @alh_base: sdw alh base.
* @ext: extended HDaudio link support
* @hbus: hdac_bus pointer, needed for power management
+ * @eml_lock: mutex protecting shared registers in the HDaudio multi-link
+ * space
*/
struct sdw_intel_res {
const struct sdw_intel_hw_ops *hw_ops;
@@ -343,6 +345,7 @@ struct sdw_intel_res {
u32 alh_base;
bool ext;
struct hdac_bus *hbus;
+ struct mutex *eml_lock;
};

/*
--
2.25.1

2023-03-23 05:32:17

by Bard Liao

[permalink] [raw]
Subject: [PATCH 08/20] ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer

From: Pierre-Louis Bossart <[email protected]>

Use new helper and interface to make sure the HDaudio and SoundWire
parts use the same mutex when accessing shared registers.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
sound/soc/sof/intel/hda.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 22eba57bb3e6..f8cd5a9ebad1 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -215,6 +215,15 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
res.alh_base = hdev->desc->sdw_alh_base;
res.ext = false;
} else {
+ /*
+ * retrieve eml_lock needed to protect shared registers
+ * in the HDaudio multi-link areas
+ */
+ res.eml_lock = hdac_bus_eml_get_mutex(sof_to_bus(sdev), true,
+ AZX_REG_ML_LEPTR_ID_SDW);
+ if (!res.eml_lock)
+ return -ENODEV;
+
res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR];
/*
* the SHIM and SoundWire register offsets are link-specific
--
2.25.1

2023-03-23 05:32:20

by Bard Liao

[permalink] [raw]
Subject: [PATCH 09/20] soundwire: intel_init: use eml_lock parameter

From: Pierre-Louis Bossart <[email protected]>

Now that the ASoC/SOF/HDAudio parts has retrieved the mutex and set
the parameter, we can use it to share the same synchronization across
the two domains.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index c918d2b81cc3..534c8795e7e8 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -69,18 +69,19 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
link->ip_offset = 0;
link->shim = res->mmio_base + res->shim_base;
link->alh = res->mmio_base + res->alh_base;
+ link->shim_lock = &ctx->shim_lock;
} else {
link->registers = res->mmio_base + SDW_IP_BASE(link_id);
link->ip_offset = SDW_CADENCE_MCP_IP_OFFSET;
link->shim = res->mmio_base + SDW_SHIM2_GENERIC_BASE(link_id);
link->shim_vs = res->mmio_base + SDW_SHIM2_VS_BASE(link_id);
+ link->shim_lock = res->eml_lock;
}

link->ops = res->ops;
link->dev = res->dev;

link->clock_stop_quirks = res->clock_stop_quirks;
- link->shim_lock = &ctx->shim_lock;
link->shim_mask = &ctx->shim_mask;
link->link_mask = ctx->link_mask;

--
2.25.1

2023-03-23 05:32:23

by Bard Liao

[permalink] [raw]
Subject: [PATCH 01/20] ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake

From: Pierre-Louis Bossart <[email protected]>

Add the new enum needed for SoundWire IP selection. The LunarLake PCI
descriptors and DSP parts will be added at a later time.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
sound/soc/sof/intel/shim.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/sound/soc/sof/intel/shim.h b/sound/soc/sof/intel/shim.h
index 48428ccbcfe0..207df48e27cf 100644
--- a/sound/soc/sof/intel/shim.h
+++ b/sound/soc/sof/intel/shim.h
@@ -21,6 +21,7 @@ enum sof_intel_hw_ip_version {
SOF_INTEL_CAVS_2_0, /* IceLake, JasperLake */
SOF_INTEL_CAVS_2_5, /* TigerLake, AlderLake */
SOF_INTEL_ACE_1_0, /* MeteorLake */
+ SOF_INTEL_ACE_2_0, /* LunarLake */
};

/*
--
2.25.1

2023-03-23 05:32:34

by Bard Liao

[permalink] [raw]
Subject: [PATCH 11/20] soundwire: intel_ace2x: add link power-up/down helpers

From: Pierre-Louis Bossart <[email protected]>

only power-up/down for now, the frequency is not set.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 50 +++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 1c47bb2adb93..5b6a608e63ba 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -10,12 +10,62 @@
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_intel.h>
+#include <sound/hda-mlink.h>
#include "cadence_master.h"
#include "bus.h"
#include "intel.h"

+static int intel_link_power_up(struct sdw_intel *sdw)
+{
+ int ret;
+
+ mutex_lock(sdw->link_res->shim_lock);
+
+ ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, sdw->instance);
+ if (ret < 0) {
+ dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_up failed: %d\n",
+ __func__, ret);
+ goto out;
+ }
+
+ sdw->cdns.link_up = true;
+out:
+ mutex_unlock(sdw->link_res->shim_lock);
+
+ return ret;
+}
+
+static int intel_link_power_down(struct sdw_intel *sdw)
+{
+ int ret;
+
+ mutex_lock(sdw->link_res->shim_lock);
+
+ sdw->cdns.link_up = false;
+
+ ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, sdw->instance);
+ if (ret < 0) {
+ dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_down failed: %d\n",
+ __func__, ret);
+
+ /*
+ * we leave the sdw->cdns.link_up flag as false since we've disabled
+ * the link at this point and cannot handle interrupts any longer.
+ */
+ }
+
+ mutex_unlock(sdw->link_res->shim_lock);
+
+ return ret;
+}
+
const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.debugfs_init = intel_ace2x_debugfs_init,
.debugfs_exit = intel_ace2x_debugfs_exit,
+
+ .link_power_up = intel_link_power_up,
+ .link_power_down = intel_link_power_down,
};
EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);
+
+MODULE_IMPORT_NS(SND_SOC_SOF_HDA_MLINK);
--
2.25.1

2023-03-23 05:32:38

by Bard Liao

[permalink] [raw]
Subject: [PATCH 12/20] soundwire: intel_ace2x: set SYNCPRD before powering-up

From: Pierre-Louis Bossart <[email protected]>

The registers used for multi-link synchronization are no longer in the
SHIM but in the HDaudio multi-link capability space. Use helpers to
configure the SYNCPRD value, and wait for SYNCPU to change after
powering-up.

Note that the SYNCPRD value is shared between all sublinks, for
obvious reasons if those links are supposed to be synchronized. The
value of SYNCPRD is programmed only once for all sublinks.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 42 +++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 5b6a608e63ba..01668246b7ba 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -17,17 +17,51 @@

static int intel_link_power_up(struct sdw_intel *sdw)
{
+ struct sdw_bus *bus = &sdw->cdns.bus;
+ struct sdw_master_prop *prop = &bus->prop;
+ u32 *shim_mask = sdw->link_res->shim_mask;
+ unsigned int link_id = sdw->instance;
+ u32 syncprd;
int ret;

mutex_lock(sdw->link_res->shim_lock);

- ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, sdw->instance);
+ if (!*shim_mask) {
+ /* we first need to program the SyncPRD/CPU registers */
+ dev_dbg(sdw->cdns.dev, "first link up, programming SYNCPRD\n");
+
+ if (prop->mclk_freq % 6000000)
+ syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_38_4;
+ else
+ syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_24;
+
+ ret = hdac_bus_eml_sdw_set_syncprd_unlocked(sdw->link_res->hbus, syncprd);
+ if (ret < 0) {
+ dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_set_syncprd failed: %d\n",
+ __func__, ret);
+ goto out;
+ }
+ }
+
+ ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, link_id);
if (ret < 0) {
dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_up failed: %d\n",
__func__, ret);
goto out;
}

+ if (!*shim_mask) {
+ /* SYNCPU will change once link is active */
+ ret = hdac_bus_eml_sdw_wait_syncpu_unlocked(sdw->link_res->hbus);
+ if (ret < 0) {
+ dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_wait_syncpu failed: %d\n",
+ __func__, ret);
+ goto out;
+ }
+ }
+
+ *shim_mask |= BIT(link_id);
+
sdw->cdns.link_up = true;
out:
mutex_unlock(sdw->link_res->shim_lock);
@@ -37,13 +71,17 @@ static int intel_link_power_up(struct sdw_intel *sdw)

static int intel_link_power_down(struct sdw_intel *sdw)
{
+ u32 *shim_mask = sdw->link_res->shim_mask;
+ unsigned int link_id = sdw->instance;
int ret;

mutex_lock(sdw->link_res->shim_lock);

sdw->cdns.link_up = false;

- ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, sdw->instance);
+ *shim_mask &= ~BIT(link_id);
+
+ ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, link_id);
if (ret < 0) {
dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_down failed: %d\n",
__func__, ret);
--
2.25.1

2023-03-23 05:32:43

by Bard Liao

[permalink] [raw]
Subject: [PATCH 13/20] soundwire: intel_ace2x: configure link PHY

From: Pierre-Louis Bossart <[email protected]>

Unlike previous hardware generations, the glue-to-master transition is
not managed by software, instead the transitions are managed as part
of the power-up/down sequences controlled by SPA/CPA bits.

The only thing that's required is to configure the link PHY for
'normal' operation instead of the PHY test mode.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 01668246b7ba..5deff32976f1 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -15,6 +15,22 @@
#include "bus.h"
#include "intel.h"

+/*
+ * shim vendor-specific (vs) ops
+ */
+
+static void intel_shim_vs_init(struct sdw_intel *sdw)
+{
+ void __iomem *shim_vs = sdw->link_res->shim_vs;
+ u16 act = 0;
+
+ u16p_replace_bits(&act, 0x1, SDW_SHIM2_INTEL_VS_ACTMCTL_DOAIS);
+ act |= SDW_SHIM2_INTEL_VS_ACTMCTL_DACTQE;
+ act |= SDW_SHIM2_INTEL_VS_ACTMCTL_DODS;
+ intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_ACTMCTL, act);
+ usleep_range(10, 15);
+}
+
static int intel_link_power_up(struct sdw_intel *sdw)
{
struct sdw_bus *bus = &sdw->cdns.bus;
@@ -63,6 +79,9 @@ static int intel_link_power_up(struct sdw_intel *sdw)
*shim_mask |= BIT(link_id);

sdw->cdns.link_up = true;
+
+ intel_shim_vs_init(sdw);
+
out:
mutex_unlock(sdw->link_res->shim_lock);

--
2.25.1

2023-03-23 05:32:46

by Bard Liao

[permalink] [raw]
Subject: [PATCH 04/20] soundwire/ASOC: Intel: update offsets for LunarLake

From: Pierre-Louis Bossart <[email protected]>

The previous settings are not applicable, use a flag to determine what
the register layout is.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel.h | 2 ++
drivers/soundwire/intel_init.c | 14 ++++++++++----
include/linux/soundwire/sdw_intel.h | 2 ++
sound/soc/sof/intel/hda.c | 21 +++++++++++++++++----
4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h
index 09d479f2c77b..51aa42a5a824 100644
--- a/drivers/soundwire/intel.h
+++ b/drivers/soundwire/intel.h
@@ -11,6 +11,7 @@
* @mmio_base: mmio base of SoundWire registers
* @registers: Link IO registers base
* @shim: Audio shim pointer
+ * @shim_vs: Audio vendor-specific shim pointer
* @alh: ALH (Audio Link Hub) pointer
* @irq: Interrupt line
* @ops: Shim callback ops
@@ -28,6 +29,7 @@ struct sdw_intel_link_res {
void __iomem *mmio_base; /* not strictly needed, useful for debug */
void __iomem *registers;
void __iomem *shim;
+ void __iomem *shim_vs;
void __iomem *alh;
int irq;
const struct sdw_intel_ops *ops;
diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index cbe56b993c6c..e0023af9e0e1 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -63,10 +63,16 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
link = &ldev->link_res;
link->hw_ops = res->hw_ops;
link->mmio_base = res->mmio_base;
- link->registers = res->mmio_base + SDW_LINK_BASE
- + (SDW_LINK_SIZE * link_id);
- link->shim = res->mmio_base + res->shim_base;
- link->alh = res->mmio_base + res->alh_base;
+ if (!res->ext) {
+ link->registers = res->mmio_base + SDW_LINK_BASE
+ + (SDW_LINK_SIZE * link_id);
+ link->shim = res->mmio_base + res->shim_base;
+ link->alh = res->mmio_base + res->alh_base;
+ } else {
+ link->registers = res->mmio_base + SDW_IP_BASE(link_id);
+ link->shim = res->mmio_base + SDW_SHIM2_GENERIC_BASE(link_id);
+ link->shim_vs = res->mmio_base + SDW_SHIM2_VS_BASE(link_id);
+ }

link->ops = res->ops;
link->dev = res->dev;
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index 66687e83a94f..88eb5bf98140 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -323,6 +323,7 @@ struct sdw_intel_ctx {
* DSP driver. The quirks are common for all links for now.
* @shim_base: sdw shim base.
* @alh_base: sdw alh base.
+ * @ext: extended HDaudio link support
*/
struct sdw_intel_res {
const struct sdw_intel_hw_ops *hw_ops;
@@ -337,6 +338,7 @@ struct sdw_intel_res {
u32 clock_stop_quirks;
u32 shim_base;
u32 alh_base;
+ bool ext;
};

/*
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 81c697e20108..db103524be4f 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -198,6 +198,7 @@ static int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)

static int hda_sdw_probe(struct snd_sof_dev *sdev)
{
+ const struct sof_intel_dsp_desc *chip;
struct sof_intel_hda_dev *hdev;
struct sdw_intel_res res;
void *sdw;
@@ -206,10 +207,22 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)

memset(&res, 0, sizeof(res));

- res.hw_ops = &sdw_intel_cnl_hw_ops;
- res.mmio_base = sdev->bar[HDA_DSP_BAR];
- res.shim_base = hdev->desc->sdw_shim_base;
- res.alh_base = hdev->desc->sdw_alh_base;
+ chip = get_chip_info(sdev->pdata);
+ if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) {
+ res.mmio_base = sdev->bar[HDA_DSP_BAR];
+ res.hw_ops = &sdw_intel_cnl_hw_ops;
+ res.shim_base = hdev->desc->sdw_shim_base;
+ res.alh_base = hdev->desc->sdw_alh_base;
+ res.ext = false;
+ } else {
+ res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR];
+ /*
+ * the SHIM and SoundWire register offsets are link-specific
+ * and will be determined when adding auxiliary devices
+ */
+ res.hw_ops = &sdw_intel_lnl_hw_ops;
+ res.ext = true;
+ }
res.irq = sdev->ipc_irq;
res.handle = hdev->info.handle;
res.parent = sdev->dev;
--
2.25.1

2023-03-23 05:32:49

by Bard Liao

[permalink] [raw]
Subject: [PATCH 14/20] soundwire: intel_ace2x: add DAI registration

From: Pierre-Louis Bossart <[email protected]>

The code is similar to the previous implementation, the only
difference is that the PDI descriptors are now in different areas.

Using common helpers proves tricky with multiple changed registers,
workarounds that are no longer necessary. It's simpler to duplicate
the intel_register_dai() function rather than try to add multiple
levels of abstraction and indirections.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 161 ++++++++++++++++++++++++++++++++
1 file changed, 161 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 5deff32976f1..d6d5e6e070f4 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -116,10 +116,171 @@ static int intel_link_power_down(struct sdw_intel *sdw)
return ret;
}

+/*
+ * DAI operations
+ */
+static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
+};
+
+static const struct snd_soc_component_driver dai_component = {
+ .name = "soundwire",
+};
+
+/*
+ * PDI routines
+ */
+static void intel_pdi_init(struct sdw_intel *sdw,
+ struct sdw_cdns_stream_config *config)
+{
+ void __iomem *shim = sdw->link_res->shim;
+ int pcm_cap;
+
+ /* PCM Stream Capability */
+ pcm_cap = intel_readw(shim, SDW_SHIM2_PCMSCAP);
+
+ config->pcm_bd = FIELD_GET(SDW_SHIM2_PCMSCAP_BSS, pcm_cap);
+ config->pcm_in = FIELD_GET(SDW_SHIM2_PCMSCAP_ISS, pcm_cap);
+ config->pcm_out = FIELD_GET(SDW_SHIM2_PCMSCAP_ISS, pcm_cap);
+
+ dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n",
+ config->pcm_bd, config->pcm_in, config->pcm_out);
+}
+
+static int
+intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num)
+{
+ void __iomem *shim = sdw->link_res->shim;
+
+ /* zero based values for channel count in register */
+ return intel_readw(shim, SDW_SHIM2_PCMSYCHC(pdi_num)) + 1;
+}
+
+static void intel_pdi_get_ch_update(struct sdw_intel *sdw,
+ struct sdw_cdns_pdi *pdi,
+ unsigned int num_pdi,
+ unsigned int *num_ch)
+{
+ int ch_count = 0;
+ int i;
+
+ for (i = 0; i < num_pdi; i++) {
+ pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num);
+ ch_count += pdi->ch_count;
+ pdi++;
+ }
+
+ *num_ch = ch_count;
+}
+
+static void intel_pdi_stream_ch_update(struct sdw_intel *sdw,
+ struct sdw_cdns_streams *stream)
+{
+ intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd,
+ &stream->num_ch_bd);
+
+ intel_pdi_get_ch_update(sdw, stream->in, stream->num_in,
+ &stream->num_ch_in);
+
+ intel_pdi_get_ch_update(sdw, stream->out, stream->num_out,
+ &stream->num_ch_out);
+}
+
+static int intel_create_dai(struct sdw_cdns *cdns,
+ struct snd_soc_dai_driver *dais,
+ enum intel_pdi_type type,
+ u32 num, u32 off, u32 max_ch)
+{
+ int i;
+
+ if (!num)
+ return 0;
+
+ for (i = off; i < (off + num); i++) {
+ dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL,
+ "SDW%d Pin%d",
+ cdns->instance, i);
+ if (!dais[i].name)
+ return -ENOMEM;
+
+ if (type == INTEL_PDI_BD || type == INTEL_PDI_OUT) {
+ dais[i].playback.channels_min = 1;
+ dais[i].playback.channels_max = max_ch;
+ }
+
+ if (type == INTEL_PDI_BD || type == INTEL_PDI_IN) {
+ dais[i].capture.channels_min = 1;
+ dais[i].capture.channels_max = max_ch;
+ }
+
+ dais[i].ops = &intel_pcm_dai_ops;
+ }
+
+ return 0;
+}
+
+static int intel_register_dai(struct sdw_intel *sdw)
+{
+ struct sdw_cdns_dai_runtime **dai_runtime_array;
+ struct sdw_cdns_stream_config config;
+ struct sdw_cdns *cdns = &sdw->cdns;
+ struct sdw_cdns_streams *stream;
+ struct snd_soc_dai_driver *dais;
+ int num_dai;
+ int ret;
+ int off = 0;
+
+ /* Read the PDI config and initialize cadence PDI */
+ intel_pdi_init(sdw, &config);
+ ret = sdw_cdns_pdi_init(cdns, config);
+ if (ret)
+ return ret;
+
+ intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm);
+
+ /* DAIs are created based on total number of PDIs supported */
+ num_dai = cdns->pcm.num_pdi;
+
+ dai_runtime_array = devm_kcalloc(cdns->dev, num_dai,
+ sizeof(struct sdw_cdns_dai_runtime *),
+ GFP_KERNEL);
+ if (!dai_runtime_array)
+ return -ENOMEM;
+ cdns->dai_runtime_array = dai_runtime_array;
+
+ dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL);
+ if (!dais)
+ return -ENOMEM;
+
+ /* Create PCM DAIs */
+ stream = &cdns->pcm;
+
+ ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in,
+ off, stream->num_ch_in);
+ if (ret)
+ return ret;
+
+ off += cdns->pcm.num_in;
+ ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out,
+ off, stream->num_ch_out);
+ if (ret)
+ return ret;
+
+ off += cdns->pcm.num_out;
+ ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd,
+ off, stream->num_ch_bd);
+ if (ret)
+ return ret;
+
+ return devm_snd_soc_register_component(cdns->dev, &dai_component,
+ dais, num_dai);
+}
+
const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.debugfs_init = intel_ace2x_debugfs_init,
.debugfs_exit = intel_ace2x_debugfs_exit,

+ .register_dai = intel_register_dai,
+
.link_power_up = intel_link_power_up,
.link_power_down = intel_link_power_down,
};
--
2.25.1

2023-03-23 05:32:56

by Bard Liao

[permalink] [raw]
Subject: [PATCH 15/20] soundwire: intel_ace2x: add sync_arm/sync_go helpers

From: Pierre-Louis Bossart <[email protected]>

Same functionality as before, but with the registers moved to the
HDaudio multi-link area.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 39 +++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index d6d5e6e070f4..20b8806f7de6 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -116,6 +116,41 @@ static int intel_link_power_down(struct sdw_intel *sdw)
return ret;
}

+static void intel_sync_arm(struct sdw_intel *sdw)
+{
+ unsigned int link_id = sdw->instance;
+
+ mutex_lock(sdw->link_res->shim_lock);
+
+ hdac_bus_eml_sdw_sync_arm_unlocked(sdw->link_res->hbus, link_id);
+
+ mutex_unlock(sdw->link_res->shim_lock);
+}
+
+static int intel_sync_go_unlocked(struct sdw_intel *sdw)
+{
+ int ret;
+
+ ret = hdac_bus_eml_sdw_sync_go_unlocked(sdw->link_res->hbus);
+ if (ret < 0)
+ dev_err(sdw->cdns.dev, "%s: SyncGO clear failed: %d\n", __func__, ret);
+
+ return ret;
+}
+
+static int intel_sync_go(struct sdw_intel *sdw)
+{
+ int ret;
+
+ mutex_lock(sdw->link_res->shim_lock);
+
+ ret = intel_sync_go_unlocked(sdw);
+
+ mutex_unlock(sdw->link_res->shim_lock);
+
+ return ret;
+}
+
/*
* DAI operations
*/
@@ -283,6 +318,10 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {

.link_power_up = intel_link_power_up,
.link_power_down = intel_link_power_down,
+
+ .sync_arm = intel_sync_arm,
+ .sync_go_unlocked = intel_sync_go_unlocked,
+ .sync_go = intel_sync_go,
};
EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);

--
2.25.1

2023-03-23 05:33:02

by Bard Liao

[permalink] [raw]
Subject: [PATCH 10/20] soundwire: intel_ace2x: add debugfs support

From: Pierre-Louis Bossart <[email protected]>

Add access to registers in SHIM and SHIM_VS (vendor-specific) areas.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/Makefile | 3 +-
drivers/soundwire/intel.h | 8 ++
drivers/soundwire/intel_ace2x.c | 2 +
drivers/soundwire/intel_ace2x_debugfs.c | 147 ++++++++++++++++++++++++
4 files changed, 159 insertions(+), 1 deletion(-)
create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c

diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
index d7212777a927..c57571c82e04 100644
--- a/drivers/soundwire/Makefile
+++ b/drivers/soundwire/Makefile
@@ -20,7 +20,8 @@ soundwire-cadence-y := cadence_master.o
obj-$(CONFIG_SOUNDWIRE_CADENCE) += soundwire-cadence.o

#Intel driver
-soundwire-intel-y := intel.o intel_ace2x.o intel_auxdevice.o intel_init.o dmi-quirks.o \
+soundwire-intel-y := intel.o intel_ace2x.o intel_ace2x_debugfs.o \
+ intel_auxdevice.o intel_init.o dmi-quirks.o \
intel_bus_common.o
obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel.o

diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h
index cf9db4906de4..511932c55216 100644
--- a/drivers/soundwire/intel.h
+++ b/drivers/soundwire/intel.h
@@ -95,6 +95,14 @@ static inline void intel_writew(void __iomem *base, int offset, u16 value)
(sdw)->link_res->hw_ops->cb)
#define SDW_INTEL_OPS(sdw, cb) ((sdw)->link_res->hw_ops->cb)

+#ifdef CONFIG_DEBUG_FS
+void intel_ace2x_debugfs_init(struct sdw_intel *sdw);
+void intel_ace2x_debugfs_exit(struct sdw_intel *sdw);
+#else
+static inline void intel_ace2x_debugfs_init(struct sdw_intel *sdw) {}
+static inline void intel_ace2x_debugfs_exit(struct sdw_intel *sdw) {}
+#endif
+
static inline void sdw_intel_debugfs_init(struct sdw_intel *sdw)
{
if (SDW_INTEL_CHECK_OPS(sdw, debugfs_init))
diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 623e4fd7db91..1c47bb2adb93 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -15,5 +15,7 @@
#include "intel.h"

const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
+ .debugfs_init = intel_ace2x_debugfs_init,
+ .debugfs_exit = intel_ace2x_debugfs_exit,
};
EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);
diff --git a/drivers/soundwire/intel_ace2x_debugfs.c b/drivers/soundwire/intel_ace2x_debugfs.c
new file mode 100644
index 000000000000..3d24661ffd37
--- /dev/null
+++ b/drivers/soundwire/intel_ace2x_debugfs.c
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright(c) 2023 Intel Corporation. All rights reserved.
+
+#include <linux/acpi.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>
+#include <linux/soundwire/sdw.h>
+#include <linux/soundwire/sdw_intel.h>
+#include <linux/soundwire/sdw_registers.h>
+#include "bus.h"
+#include "cadence_master.h"
+#include "intel.h"
+
+/*
+ * debugfs
+ */
+#ifdef CONFIG_DEBUG_FS
+
+#define RD_BUF (2 * PAGE_SIZE)
+
+static ssize_t intel_sprintf(void __iomem *mem, bool l,
+ char *buf, size_t pos, unsigned int reg)
+{
+ int value;
+
+ if (l)
+ value = intel_readl(mem, reg);
+ else
+ value = intel_readw(mem, reg);
+
+ return scnprintf(buf + pos, RD_BUF - pos, "%4x\t%4x\n", reg, value);
+}
+
+static int intel_reg_show(struct seq_file *s_file, void *data)
+{
+ struct sdw_intel *sdw = s_file->private;
+ void __iomem *s = sdw->link_res->shim;
+ void __iomem *vs_s = sdw->link_res->shim_vs;
+ ssize_t ret;
+ u32 pcm_cap;
+ int pcm_bd;
+ char *buf;
+ int j;
+
+ buf = kzalloc(RD_BUF, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ ret = scnprintf(buf, RD_BUF, "Register Value\n");
+ ret += scnprintf(buf + ret, RD_BUF - ret, "\nShim\n");
+
+ ret += intel_sprintf(s, true, buf, ret, SDW_SHIM2_LECAP);
+ ret += intel_sprintf(s, false, buf, ret, SDW_SHIM2_PCMSCAP);
+
+ pcm_cap = intel_readw(s, SDW_SHIM2_PCMSCAP);
+ pcm_bd = FIELD_GET(SDW_SHIM2_PCMSCAP_BSS, pcm_cap);
+
+ for (j = 0; j < pcm_bd; j++) {
+ ret += intel_sprintf(s, false, buf, ret,
+ SDW_SHIM2_PCMSYCHM(j));
+ ret += intel_sprintf(s, false, buf, ret,
+ SDW_SHIM2_PCMSYCHC(j));
+ }
+
+ ret += scnprintf(buf + ret, RD_BUF - ret, "\nVS CLK controls\n");
+ ret += intel_sprintf(vs_s, true, buf, ret, SDW_SHIM2_INTEL_VS_LVSCTL);
+
+ ret += scnprintf(buf + ret, RD_BUF - ret, "\nVS Wake registers\n");
+ ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_WAKEEN);
+ ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_WAKESTS);
+
+ ret += scnprintf(buf + ret, RD_BUF - ret, "\nVS IOCTL, ACTMCTL\n");
+ ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_IOCTL);
+ ret += intel_sprintf(vs_s, false, buf, ret, SDW_SHIM2_INTEL_VS_ACTMCTL);
+
+ seq_printf(s_file, "%s", buf);
+ kfree(buf);
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(intel_reg);
+
+static int intel_set_m_datamode(void *data, u64 value)
+{
+ struct sdw_intel *sdw = data;
+ struct sdw_bus *bus = &sdw->cdns.bus;
+
+ if (value > SDW_PORT_DATA_MODE_STATIC_1)
+ return -EINVAL;
+
+ /* Userspace changed the hardware state behind the kernel's back */
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+
+ bus->params.m_data_mode = value;
+
+ return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(intel_set_m_datamode_fops, NULL,
+ intel_set_m_datamode, "%llu\n");
+
+static int intel_set_s_datamode(void *data, u64 value)
+{
+ struct sdw_intel *sdw = data;
+ struct sdw_bus *bus = &sdw->cdns.bus;
+
+ if (value > SDW_PORT_DATA_MODE_STATIC_1)
+ return -EINVAL;
+
+ /* Userspace changed the hardware state behind the kernel's back */
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+
+ bus->params.s_data_mode = value;
+
+ return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(intel_set_s_datamode_fops, NULL,
+ intel_set_s_datamode, "%llu\n");
+
+void intel_ace2x_debugfs_init(struct sdw_intel *sdw)
+{
+ struct dentry *root = sdw->cdns.bus.debugfs;
+
+ if (!root)
+ return;
+
+ sdw->debugfs = debugfs_create_dir("intel-sdw", root);
+
+ debugfs_create_file("intel-registers", 0400, sdw->debugfs, sdw,
+ &intel_reg_fops);
+
+ debugfs_create_file("intel-m-datamode", 0200, sdw->debugfs, sdw,
+ &intel_set_m_datamode_fops);
+
+ debugfs_create_file("intel-s-datamode", 0200, sdw->debugfs, sdw,
+ &intel_set_s_datamode_fops);
+
+ sdw_cdns_debugfs_init(&sdw->cdns, sdw->debugfs);
+}
+
+void intel_ace2x_debugfs_exit(struct sdw_intel *sdw)
+{
+ debugfs_remove_recursive(sdw->debugfs);
+}
+#endif /* CONFIG_DEBUG_FS */
--
2.25.1

2023-03-23 05:33:20

by Bard Liao

[permalink] [raw]
Subject: [PATCH 17/20] soundwire: intel_ace2x: enable wake support

From: Pierre-Louis Bossart <[email protected]>

The WAKEEN and WAKESTS registers were moved to the per-link SHIM_VS
area.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 38 +++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 2e33e8a00b55..fe950b3ea3bc 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -31,6 +31,41 @@ static void intel_shim_vs_init(struct sdw_intel *sdw)
usleep_range(10, 15);
}

+static int intel_shim_check_wake(struct sdw_intel *sdw)
+{
+ void __iomem *shim_vs;
+ u16 wake_sts;
+
+ shim_vs = sdw->link_res->shim_vs;
+ wake_sts = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS);
+
+ return wake_sts & SDW_SHIM2_INTEL_VS_WAKEEN_PWS;
+}
+
+static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
+{
+ void __iomem *shim_vs = sdw->link_res->shim_vs;
+ u16 wake_en;
+ u16 wake_sts;
+
+ wake_en = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN);
+
+ if (wake_enable) {
+ /* Enable the wakeup */
+ wake_en |= SDW_SHIM2_INTEL_VS_WAKEEN_PWE;
+ intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN, wake_en);
+ } else {
+ /* Disable the wake up interrupt */
+ wake_en &= ~SDW_SHIM2_INTEL_VS_WAKEEN_PWE;
+ intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKEEN, wake_en);
+
+ /* Clear wake status (W1C) */
+ wake_sts = intel_readw(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS);
+ wake_sts |= SDW_SHIM2_INTEL_VS_WAKEEN_PWS;
+ intel_writew(shim_vs, SDW_SHIM2_INTEL_VS_WAKESTS, wake_sts);
+ }
+}
+
static int intel_link_power_up(struct sdw_intel *sdw)
{
struct sdw_bus *bus = &sdw->cdns.bus;
@@ -325,6 +360,9 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.link_power_up = intel_link_power_up,
.link_power_down = intel_link_power_down,

+ .shim_check_wake = intel_shim_check_wake,
+ .shim_wake = intel_shim_wake,
+
.sync_arm = intel_sync_arm,
.sync_go_unlocked = intel_sync_go_unlocked,
.sync_go = intel_sync_go,
--
2.25.1

2023-03-23 05:33:34

by Bard Liao

[permalink] [raw]
Subject: [PATCH 18/20] soundwire: intel_ace2x: add check_cmdsync_unlocked helper

From: Pierre-Louis Bossart <[email protected]>

This is the last callback needed for all bus management routines on
new hardware. Same concept as before, just different register.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index fe950b3ea3bc..a12fee8a5bfa 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -186,6 +186,11 @@ static int intel_sync_go(struct sdw_intel *sdw)
return ret;
}

+static bool intel_check_cmdsync_unlocked(struct sdw_intel *sdw)
+{
+ return hdac_bus_eml_sdw_check_cmdsync_unlocked(sdw->link_res->hbus);
+}
+
/*
* DAI operations
*/
@@ -366,6 +371,7 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.sync_arm = intel_sync_arm,
.sync_go_unlocked = intel_sync_go_unlocked,
.sync_go = intel_sync_go,
+ .sync_check_cmdsync_unlocked = intel_check_cmdsync_unlocked,
};
EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);

--
2.25.1

2023-03-23 05:33:36

by Bard Liao

[permalink] [raw]
Subject: [PATCH 19/20] soundwire: bus: add new manager callback to deal with peripheral enumeration

From: Pierre-Louis Bossart <[email protected]>

When a peripheral reports as ATTACHED, the manager may need to follow
a programming sequence, e.g. to assign DMA resources and/or assign a
command queue for that peripheral.

This patch adds an optional callback, which will be invoked every time
the peripheral attaches. This might be overkill in some scenarios, and
one could argue that this should be invoked only on the first
attachment. The bus does not however track this first attachment with
any existing state-mirroring variable, and using dev_num_sticky would
not work across suspend-resume cycles.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/bus.c | 3 +++
include/linux/soundwire/sdw.h | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index b6aca59c3130..35f49bcc53e5 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -716,6 +716,9 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
/* After xfer of msg, restore dev_num */
slave->dev_num = slave->dev_num_sticky;

+ if (bus->ops && bus->ops->new_peripheral_assigned)
+ bus->ops->new_peripheral_assigned(bus, dev_num);
+
return 0;
}

diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index ef645de13ae9..c076a3f879b3 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -846,6 +846,7 @@ struct sdw_defer {
* @post_bank_switch: Callback for post bank switch
* @read_ping_status: Read status from PING frames, reported with two bits per Device.
* Bits 31:24 are reserved.
+ * @new_peripheral_assigned: Callback to handle enumeration of new peripheral.
*/
struct sdw_master_ops {
int (*read_prop)(struct sdw_bus *bus);
@@ -860,7 +861,7 @@ struct sdw_master_ops {
int (*pre_bank_switch)(struct sdw_bus *bus);
int (*post_bank_switch)(struct sdw_bus *bus);
u32 (*read_ping_status)(struct sdw_bus *bus);
-
+ void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num);
};

/**
--
2.25.1

2023-03-23 05:33:51

by Bard Liao

[permalink] [raw]
Subject: [PATCH 16/20] soundwire: intel_ace2x: use common helpers for bus start/stop

From: Pierre-Louis Bossart <[email protected]>

The sequences are so far identical, so the abstraction is a bit
over-engineered. In time we will simplify if there is no need to
special case or work-around programming sequences.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 20b8806f7de6..2e33e8a00b55 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -316,6 +316,12 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {

.register_dai = intel_register_dai,

+ .check_clock_stop = intel_check_clock_stop,
+ .start_bus = intel_start_bus,
+ .start_bus_after_reset = intel_start_bus_after_reset,
+ .start_bus_after_clock_stop = intel_start_bus_after_clock_stop,
+ .stop_bus = intel_stop_bus,
+
.link_power_up = intel_link_power_up,
.link_power_down = intel_link_power_down,

--
2.25.1

2023-03-23 05:34:17

by Bard Liao

[permalink] [raw]
Subject: [PATCH 20/20] soundwire: intel_ace2x: add new_peripheral_assigned callback

From: Pierre-Louis Bossart <[email protected]>

Add the abstraction needed to only program the LSDIID registers for
the HDaudio extended links. It's perfectly fine to program this
register multiple times in case devices lose sync and reattach.

Signed-off-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
---
drivers/soundwire/intel_ace2x.c | 12 ++++++++++++
drivers/soundwire/intel_auxdevice.c | 16 ++++++++++++++++
include/linux/soundwire/sdw_intel.h | 3 +++
3 files changed, 31 insertions(+)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index a12fee8a5bfa..65deb4345354 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -350,6 +350,16 @@ static int intel_register_dai(struct sdw_intel *sdw)
dais, num_dai);
}

+static void intel_program_sdi(struct sdw_intel *sdw, int dev_num)
+{
+ int ret;
+
+ ret = hdac_bus_eml_sdw_set_lsdiid(sdw->link_res->hbus, sdw->instance, dev_num);
+ if (ret < 0)
+ dev_err(sdw->cdns.dev, "%s: could not set lsdiid for link %d %d\n",
+ __func__, sdw->instance, dev_num);
+}
+
const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.debugfs_init = intel_ace2x_debugfs_init,
.debugfs_exit = intel_ace2x_debugfs_exit,
@@ -372,6 +382,8 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
.sync_go_unlocked = intel_sync_go_unlocked,
.sync_go = intel_sync_go,
.sync_check_cmdsync_unlocked = intel_check_cmdsync_unlocked,
+
+ .program_sdi = intel_program_sdi,
};
EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);

diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
index b02cef4f4b66..6e02782ef211 100644
--- a/drivers/soundwire/intel_auxdevice.c
+++ b/drivers/soundwire/intel_auxdevice.c
@@ -60,6 +60,21 @@ static int generic_post_bank_switch(struct sdw_bus *bus)
return sdw->link_res->hw_ops->post_bank_switch(sdw);
}

+static void generic_new_peripheral_assigned(struct sdw_bus *bus, int dev_num)
+{
+ struct sdw_cdns *cdns = bus_to_cdns(bus);
+ struct sdw_intel *sdw = cdns_to_intel(cdns);
+
+ /* paranoia check, this should never happen */
+ if (dev_num < INTEL_DEV_NUM_IDA_MIN || dev_num > SDW_MAX_DEVICES) {
+ dev_err(bus->dev, "%s: invalid dev_num %d\n", __func__, dev_num);
+ return;
+ }
+
+ if (sdw->link_res->hw_ops->program_sdi)
+ sdw->link_res->hw_ops->program_sdi(sdw, dev_num);
+}
+
static int sdw_master_read_intel_prop(struct sdw_bus *bus)
{
struct sdw_master_prop *prop = &bus->prop;
@@ -117,6 +132,7 @@ static struct sdw_master_ops sdw_intel_ops = {
.pre_bank_switch = generic_pre_bank_switch,
.post_bank_switch = generic_post_bank_switch,
.read_ping_status = cdns_read_ping_status,
+ .new_peripheral_assigned = generic_new_peripheral_assigned,
};

/*
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index bafc6f2554b0..1a8f32059cd8 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -399,6 +399,7 @@ struct sdw_intel;
* @sync_go: helper for multi-link synchronization
* @sync_check_cmdsync_unlocked: helper for multi-link synchronization
* and bank switch - shim_lock is assumed to be locked at higher level
+ * @program_sdi: helper for codec command/control based on dev_num
*/
struct sdw_intel_hw_ops {
void (*debugfs_init)(struct sdw_intel *sdw);
@@ -425,6 +426,8 @@ struct sdw_intel_hw_ops {
int (*sync_go_unlocked)(struct sdw_intel *sdw);
int (*sync_go)(struct sdw_intel *sdw);
bool (*sync_check_cmdsync_unlocked)(struct sdw_intel *sdw);
+
+ void (*program_sdi)(struct sdw_intel *sdw, int dev_num);
};

extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;
--
2.25.1

2023-03-23 14:20:25

by Liao, Bard

[permalink] [raw]
Subject: RE: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x

The patches will not compile due to missed dependency but welcome review
on the code changes.

> -----Original Message-----
> From: Bard Liao <[email protected]>
> Sent: Thursday, March 23, 2023 1:45 PM
> To: [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; pierre-
> [email protected]; Liao, Bard <[email protected]>;
> [email protected]
> Subject: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x
>
> This series uses the abstraction added in past kernel cycles to provide
> support for the ACE2.x integration. The existing SHIM and Cadence
> registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
> parts also moved to the HDaudio Extended Multi link structures. Nothing
> fundamentally different except for the register map.
>
> This series only provides the basic mechanisms to expose SoundWire-based
> DAIs. The PCI parts and DSP management will be contributed later, and the
> DAI ops are now empty as well.
>
> The change is mainly on SoundWire. It would be better to go through
> SoundWire tree.
>
> Pierre-Louis Bossart (20):
> ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
> soundwire: intel: add ACE2.x SHIM definitions
> soundwire: intel_ace2x: add empty new ops for LunarLake
> soundwire/ASOC: Intel: update offsets for LunarLake
> soundwire: intel/cadence: set ip_offset at run-time
> ASoC/soundwire: intel: pass hdac_bus pointer for link management
> soundwire: intel: add eml_lock in the interface for new platforms
> ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
> soundwire: intel_init: use eml_lock parameter
> soundwire: intel_ace2x: add debugfs support
> soundwire: intel_ace2x: add link power-up/down helpers
> soundwire: intel_ace2x: set SYNCPRD before powering-up
> soundwire: intel_ace2x: configure link PHY
> soundwire: intel_ace2x: add DAI registration
> soundwire: intel_ace2x: add sync_arm/sync_go helpers
> soundwire: intel_ace2x: use common helpers for bus start/stop
> soundwire: intel_ace2x: enable wake support
> soundwire: intel_ace2x: add check_cmdsync_unlocked helper
> soundwire: bus: add new manager callback to deal with peripheral
> enumeration
> soundwire: intel_ace2x: add new_peripheral_assigned callback
>
> drivers/soundwire/Makefile | 3 +-
> drivers/soundwire/bus.c | 3 +
> drivers/soundwire/cadence_master.h | 2 +
> drivers/soundwire/intel.h | 16 +
> drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
> drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
> drivers/soundwire/intel_auxdevice.c | 17 ++
> drivers/soundwire/intel_init.c | 21 +-
> include/linux/soundwire/sdw.h | 3 +-
> include/linux/soundwire/sdw_intel.h | 88 ++++++
> sound/soc/sof/intel/hda.c | 31 +-
> sound/soc/sof/intel/shim.h | 1 +
> 12 files changed, 711 insertions(+), 11 deletions(-)
> create mode 100644 drivers/soundwire/intel_ace2x.c
> create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c
>
> --
> 2.25.1

2023-03-23 14:21:48

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 01/20] ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake

On Thu, Mar 23, 2023 at 01:44:33PM +0800, Bard Liao wrote:
> From: Pierre-Louis Bossart <[email protected]>
>
> Add the new enum needed for SoundWire IP selection. The LunarLake PCI
> descriptors and DSP parts will be added at a later time.

Acked-by: Mark Brown <[email protected]>


Attachments:
(No filename) (311.00 B)
signature.asc (499.00 B)
Download all attachments

2023-03-23 14:22:01

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 04/20] soundwire/ASOC: Intel: update offsets for LunarLake

On Thu, Mar 23, 2023 at 01:44:36PM +0800, Bard Liao wrote:
> From: Pierre-Louis Bossart <[email protected]>
>
> The previous settings are not applicable, use a flag to determine what
> the register layout is.

Acked-by: Mark Brown <[email protected]>


Attachments:
(No filename) (279.00 B)
signature.asc (499.00 B)
Download all attachments

2023-03-23 14:23:09

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 08/20] ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer

On Thu, Mar 23, 2023 at 01:44:40PM +0800, Bard Liao wrote:
> From: Pierre-Louis Bossart <[email protected]>
>
> Use new helper and interface to make sure the HDaudio and SoundWire
> parts use the same mutex when accessing shared registers.

Acked-by: Mark Brown <[email protected]>


Attachments:
(No filename) (310.00 B)
signature.asc (499.00 B)
Download all attachments

2023-03-23 14:23:24

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 06/20] ASoC/soundwire: intel: pass hdac_bus pointer for link management

On Thu, Mar 23, 2023 at 01:44:38PM +0800, Bard Liao wrote:
> From: Pierre-Louis Bossart <[email protected]>
>
> The hdac_bus pointer is used to access the extended link information
> and handle power management. Pass it from the SOF driver down to the
> auxiliary devices.

Acked-by: Mark Brown <[email protected]>


Attachments:
(No filename) (344.00 B)
signature.asc (499.00 B)
Download all attachments

2023-04-12 10:10:36

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x

On 23-03-23, 13:44, Bard Liao wrote:
> This series uses the abstraction added in past kernel cycles to provide
> support for the ACE2.x integration. The existing SHIM and Cadence

ACE2..?

> registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
> parts also moved to the HDaudio Extended Multi link structures. Nothing
> fundamentally different except for the register map.
>
> This series only provides the basic mechanisms to expose SoundWire-based
> DAIs. The PCI parts and DSP management will be contributed later, and the
> DAI ops are now empty as well.
>
> The change is mainly on SoundWire. It would be better to go through
> SoundWire tree.
>
> Pierre-Louis Bossart (20):
> ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
> soundwire: intel: add ACE2.x SHIM definitions
> soundwire: intel_ace2x: add empty new ops for LunarLake
> soundwire/ASOC: Intel: update offsets for LunarLake
> soundwire: intel/cadence: set ip_offset at run-time
> ASoC/soundwire: intel: pass hdac_bus pointer for link management
> soundwire: intel: add eml_lock in the interface for new platforms
> ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
> soundwire: intel_init: use eml_lock parameter
> soundwire: intel_ace2x: add debugfs support
> soundwire: intel_ace2x: add link power-up/down helpers
> soundwire: intel_ace2x: set SYNCPRD before powering-up
> soundwire: intel_ace2x: configure link PHY
> soundwire: intel_ace2x: add DAI registration
> soundwire: intel_ace2x: add sync_arm/sync_go helpers
> soundwire: intel_ace2x: use common helpers for bus start/stop
> soundwire: intel_ace2x: enable wake support
> soundwire: intel_ace2x: add check_cmdsync_unlocked helper
> soundwire: bus: add new manager callback to deal with peripheral
> enumeration
> soundwire: intel_ace2x: add new_peripheral_assigned callback
>
> drivers/soundwire/Makefile | 3 +-
> drivers/soundwire/bus.c | 3 +
> drivers/soundwire/cadence_master.h | 2 +
> drivers/soundwire/intel.h | 16 +
> drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
> drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
> drivers/soundwire/intel_auxdevice.c | 17 ++
> drivers/soundwire/intel_init.c | 21 +-
> include/linux/soundwire/sdw.h | 3 +-
> include/linux/soundwire/sdw_intel.h | 88 ++++++
> sound/soc/sof/intel/hda.c | 31 +-
> sound/soc/sof/intel/shim.h | 1 +
> 12 files changed, 711 insertions(+), 11 deletions(-)
> create mode 100644 drivers/soundwire/intel_ace2x.c
> create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c
>
> --
> 2.25.1

--
~Vinod

2023-04-12 14:15:28

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x



On 4/12/23 05:07, Vinod Koul wrote:
> On 23-03-23, 13:44, Bard Liao wrote:
>> This series uses the abstraction added in past kernel cycles to provide
>> support for the ACE2.x integration. The existing SHIM and Cadence
>
> ACE2..?

Not sure I get the comment, this refers to the IP version.

ACE 2.0 IP used in LunarLake, x refers to future TDB versions.

BTW this depends on the series "[PATCH v2 00/18] ASoC: SOF: Intel:
hda-mlink: HDaudio multi-link extension update" applied yesterday by
Mark. It'd be really nice if we can have this in 6.4-rc1 to continue
adding the rest of the Lunar Lake patches.

We tried to limit the number of changes impacting both ASoC and
SoundWire subsystems but there's mechanically 2 merges needed (ASoC ->
SoundWire for the hda-mlink dependency and SoundWire->ASoC for the
interface changes below).

>
>> registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
>> parts also moved to the HDaudio Extended Multi link structures. Nothing
>> fundamentally different except for the register map.
>>
>> This series only provides the basic mechanisms to expose SoundWire-based
>> DAIs. The PCI parts and DSP management will be contributed later, and the
>> DAI ops are now empty as well.
>>
>> The change is mainly on SoundWire. It would be better to go through
>> SoundWire tree.
>>
>> Pierre-Louis Bossart (20):
>> ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
>> soundwire: intel: add ACE2.x SHIM definitions
>> soundwire: intel_ace2x: add empty new ops for LunarLake
>> soundwire/ASOC: Intel: update offsets for LunarLake
>> soundwire: intel/cadence: set ip_offset at run-time
>> ASoC/soundwire: intel: pass hdac_bus pointer for link management
>> soundwire: intel: add eml_lock in the interface for new platforms
>> ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
>> soundwire: intel_init: use eml_lock parameter
>> soundwire: intel_ace2x: add debugfs support
>> soundwire: intel_ace2x: add link power-up/down helpers
>> soundwire: intel_ace2x: set SYNCPRD before powering-up
>> soundwire: intel_ace2x: configure link PHY
>> soundwire: intel_ace2x: add DAI registration
>> soundwire: intel_ace2x: add sync_arm/sync_go helpers
>> soundwire: intel_ace2x: use common helpers for bus start/stop
>> soundwire: intel_ace2x: enable wake support
>> soundwire: intel_ace2x: add check_cmdsync_unlocked helper
>> soundwire: bus: add new manager callback to deal with peripheral
>> enumeration
>> soundwire: intel_ace2x: add new_peripheral_assigned callback
>>
>> drivers/soundwire/Makefile | 3 +-
>> drivers/soundwire/bus.c | 3 +
>> drivers/soundwire/cadence_master.h | 2 +
>> drivers/soundwire/intel.h | 16 +
>> drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
>> drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
>> drivers/soundwire/intel_auxdevice.c | 17 ++
>> drivers/soundwire/intel_init.c | 21 +-
>> include/linux/soundwire/sdw.h | 3 +-
>> include/linux/soundwire/sdw_intel.h | 88 ++++++
>> sound/soc/sof/intel/hda.c | 31 +-
>> sound/soc/sof/intel/shim.h | 1 +
>> 12 files changed, 711 insertions(+), 11 deletions(-)
>> create mode 100644 drivers/soundwire/intel_ace2x.c
>> create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c
>>
>> --
>> 2.25.1
>

2023-04-12 15:30:40

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x

On 12-04-23, 09:11, Pierre-Louis Bossart wrote:
>
>
> On 4/12/23 05:07, Vinod Koul wrote:
> > On 23-03-23, 13:44, Bard Liao wrote:
> >> This series uses the abstraction added in past kernel cycles to provide
> >> support for the ACE2.x integration. The existing SHIM and Cadence
> >
> > ACE2..?
>
> Not sure I get the comment, this refers to the IP version.

What does ACE mean, it should be expanded so that people know what it
might refer to..?

>
> ACE 2.0 IP used in LunarLake, x refers to future TDB versions.
>
> BTW this depends on the series "[PATCH v2 00/18] ASoC: SOF: Intel:
> hda-mlink: HDaudio multi-link extension update" applied yesterday by
> Mark. It'd be really nice if we can have this in 6.4-rc1 to continue
> adding the rest of the Lunar Lake patches.

That should be mentioned in cover, I can ack this if okay and Mark might
apply..? or u folks have something else in mind?

>
> We tried to limit the number of changes impacting both ASoC and
> SoundWire subsystems but there's mechanically 2 merges needed (ASoC ->
> SoundWire for the hda-mlink dependency and SoundWire->ASoC for the
> interface changes below).
>
> >
> >> registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
> >> parts also moved to the HDaudio Extended Multi link structures. Nothing
> >> fundamentally different except for the register map.
> >>
> >> This series only provides the basic mechanisms to expose SoundWire-based
> >> DAIs. The PCI parts and DSP management will be contributed later, and the
> >> DAI ops are now empty as well.
> >>
> >> The change is mainly on SoundWire. It would be better to go through
> >> SoundWire tree.
> >>
> >> Pierre-Louis Bossart (20):
> >> ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
> >> soundwire: intel: add ACE2.x SHIM definitions
> >> soundwire: intel_ace2x: add empty new ops for LunarLake
> >> soundwire/ASOC: Intel: update offsets for LunarLake
> >> soundwire: intel/cadence: set ip_offset at run-time
> >> ASoC/soundwire: intel: pass hdac_bus pointer for link management
> >> soundwire: intel: add eml_lock in the interface for new platforms
> >> ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
> >> soundwire: intel_init: use eml_lock parameter
> >> soundwire: intel_ace2x: add debugfs support
> >> soundwire: intel_ace2x: add link power-up/down helpers
> >> soundwire: intel_ace2x: set SYNCPRD before powering-up
> >> soundwire: intel_ace2x: configure link PHY
> >> soundwire: intel_ace2x: add DAI registration
> >> soundwire: intel_ace2x: add sync_arm/sync_go helpers
> >> soundwire: intel_ace2x: use common helpers for bus start/stop
> >> soundwire: intel_ace2x: enable wake support
> >> soundwire: intel_ace2x: add check_cmdsync_unlocked helper
> >> soundwire: bus: add new manager callback to deal with peripheral
> >> enumeration
> >> soundwire: intel_ace2x: add new_peripheral_assigned callback
> >>
> >> drivers/soundwire/Makefile | 3 +-
> >> drivers/soundwire/bus.c | 3 +
> >> drivers/soundwire/cadence_master.h | 2 +
> >> drivers/soundwire/intel.h | 16 +
> >> drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
> >> drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
> >> drivers/soundwire/intel_auxdevice.c | 17 ++
> >> drivers/soundwire/intel_init.c | 21 +-
> >> include/linux/soundwire/sdw.h | 3 +-
> >> include/linux/soundwire/sdw_intel.h | 88 ++++++
> >> sound/soc/sof/intel/hda.c | 31 +-
> >> sound/soc/sof/intel/shim.h | 1 +
> >> 12 files changed, 711 insertions(+), 11 deletions(-)
> >> create mode 100644 drivers/soundwire/intel_ace2x.c
> >> create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c
> >>
> >> --
> >> 2.25.1
> >

--
~Vinod

2023-04-12 16:16:14

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 00/20] ASoC/soundwire: add support for ACE2.x



On 4/12/23 10:22, Vinod Koul wrote:
> On 12-04-23, 09:11, Pierre-Louis Bossart wrote:
>>
>>
>> On 4/12/23 05:07, Vinod Koul wrote:
>>> On 23-03-23, 13:44, Bard Liao wrote:
>>>> This series uses the abstraction added in past kernel cycles to provide
>>>> support for the ACE2.x integration. The existing SHIM and Cadence
>>>
>>> ACE2..?
>>
>> Not sure I get the comment, this refers to the IP version.
>
> What does ACE mean, it should be expanded so that people know what it
> might refer to..?

I think at one point it stood for "Audio Converged Engine", which
doesn't really clarify anything, does it? It's easier for most people to
just refer to cAVS or ACE as a type of IP followed by a version number,
and use the mapping between the IP version and end-user device in the
PCI descriptors.

>> ACE 2.0 IP used in LunarLake, x refers to future TDB versions.
>>
>> BTW this depends on the series "[PATCH v2 00/18] ASoC: SOF: Intel:
>> hda-mlink: HDaudio multi-link extension update" applied yesterday by
>> Mark. It'd be really nice if we can have this in 6.4-rc1 to continue
>> adding the rest of the Lunar Lake patches.
>
> That should be mentioned in cover,

Yes the cover and some patches miss details, it's hard when you have
such a long series to be clear and avoid repetition at the same time...

> I can ack this if okay and Mark might apply..? or u folks have
something else in mind?

that would be ideal, but unfortunately this series will not apply as is
on Mark's for-next branch. I just checked, there are multiple conflicts
with the intel_bus_common stuff which is missing in Mark's tree.

Mark also provided his Acked-by tag already for patches 1/4/6/8, so I
was under the impression that these patches would be merged through the
soundwire tree.

I think what's missing is a tag from Mark to make sure the hda-mlink
dependencies are in the soundwire tree?

>>
>> We tried to limit the number of changes impacting both ASoC and
>> SoundWire subsystems but there's mechanically 2 merges needed (ASoC ->
>> SoundWire for the hda-mlink dependency and SoundWire->ASoC for the
>> interface changes below).
>>
>>>
>>>> registers are now split in 3 (SHIM, IP, SHIM vendor-specific), with some
>>>> parts also moved to the HDaudio Extended Multi link structures. Nothing
>>>> fundamentally different except for the register map.
>>>>
>>>> This series only provides the basic mechanisms to expose SoundWire-based
>>>> DAIs. The PCI parts and DSP management will be contributed later, and the
>>>> DAI ops are now empty as well.
>>>>
>>>> The change is mainly on SoundWire. It would be better to go through
>>>> SoundWire tree.
>>>>
>>>> Pierre-Louis Bossart (20):
>>>> ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake
>>>> soundwire: intel: add ACE2.x SHIM definitions
>>>> soundwire: intel_ace2x: add empty new ops for LunarLake
>>>> soundwire/ASOC: Intel: update offsets for LunarLake
>>>> soundwire: intel/cadence: set ip_offset at run-time
>>>> ASoC/soundwire: intel: pass hdac_bus pointer for link management
>>>> soundwire: intel: add eml_lock in the interface for new platforms
>>>> ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer
>>>> soundwire: intel_init: use eml_lock parameter
>>>> soundwire: intel_ace2x: add debugfs support
>>>> soundwire: intel_ace2x: add link power-up/down helpers
>>>> soundwire: intel_ace2x: set SYNCPRD before powering-up
>>>> soundwire: intel_ace2x: configure link PHY
>>>> soundwire: intel_ace2x: add DAI registration
>>>> soundwire: intel_ace2x: add sync_arm/sync_go helpers
>>>> soundwire: intel_ace2x: use common helpers for bus start/stop
>>>> soundwire: intel_ace2x: enable wake support
>>>> soundwire: intel_ace2x: add check_cmdsync_unlocked helper
>>>> soundwire: bus: add new manager callback to deal with peripheral
>>>> enumeration
>>>> soundwire: intel_ace2x: add new_peripheral_assigned callback
>>>>
>>>> drivers/soundwire/Makefile | 3 +-
>>>> drivers/soundwire/bus.c | 3 +
>>>> drivers/soundwire/cadence_master.h | 2 +
>>>> drivers/soundwire/intel.h | 16 +
>>>> drivers/soundwire/intel_ace2x.c | 390 ++++++++++++++++++++++++
>>>> drivers/soundwire/intel_ace2x_debugfs.c | 147 +++++++++
>>>> drivers/soundwire/intel_auxdevice.c | 17 ++
>>>> drivers/soundwire/intel_init.c | 21 +-
>>>> include/linux/soundwire/sdw.h | 3 +-
>>>> include/linux/soundwire/sdw_intel.h | 88 ++++++
>>>> sound/soc/sof/intel/hda.c | 31 +-
>>>> sound/soc/sof/intel/shim.h | 1 +
>>>> 12 files changed, 711 insertions(+), 11 deletions(-)
>>>> create mode 100644 drivers/soundwire/intel_ace2x.c
>>>> create mode 100644 drivers/soundwire/intel_ace2x_debugfs.c
>>>>
>>>> --
>>>> 2.25.1
>>>
>