From patchwork Fri Aug 16 02:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13765377 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D00954F20E; Fri, 16 Aug 2024 02:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775630; cv=none; b=VxkC1snLvhaAmAvXG/ytOH8ptZd2VvxWymMhVqPyPBTGS1NYvWZULUWUnqQd39wt1F/In7nA2z4r1cbSrbGdeMHUiyh6Jk1FcIMozQauvJ4v8IFSFmVYbnzxfldltK/9E2JDHoVoMlDu2USb5AlNAL82wpDMpmuev6SxpBnGiS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775630; c=relaxed/simple; bh=HMRwzVYs/M9EtV34zw7AD/7vm/ahsPsaVILYWWzBuUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HzT3GhdBGgLKyR6/gFictodvPXxA99kknLbUd76KUZ73X3ZuD8CEQOUbkbWEbC64jJs6a0E6G3SSdLikHspcndwjf6vNfKnFcpzJnE5zDXSdQyVJ0UbEcNBE25LI0ovtKaZd++MjD55/TaYvHIC3pDdsadse3CcKAHoKuXRs/yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dYimUQAT; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dYimUQAT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723775629; x=1755311629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HMRwzVYs/M9EtV34zw7AD/7vm/ahsPsaVILYWWzBuUk=; b=dYimUQATV7iTvk35inLg0n+DIMg4AQ0dqgLwIsV7C8f+leD8Xmdhx2EW jGY/R+YbF8av2/FcQYHCr52LkQ1oFre74DSVeISuMPGf8IudI0tNjKblb ahSpsqC6kV/DkuncJPTonyUYY80P2RpRYRdeE7PVye4dBMZdYQpksGIPb cgNI4ooYhFH39+kDW325xcowkQc0W66QvkytHX/ysiilG3jLF971DLyxF S2ujl1gYkXAbhFnA2He24fvL0LJmr9cJRhYYARzHta1hmpiRrR9S+10AM yhMRhc2PSl1mu6gZeANlswfCdDWqq46xXEqLf8hkjNOCSmk1gmB8SV2v+ A==; X-CSE-ConnectionGUID: AFvgf0B4QtmuHYE7eS032w== X-CSE-MsgGUID: Augu0ShtSAiwx0gHzYa/oA== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="22203564" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="22203564" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:48 -0700 X-CSE-ConnectionGUID: lZuT+ivDR1uyq2a1ZhC3HQ== X-CSE-MsgGUID: XRv+Dm8VQCuCc5jYOQJt7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="63949193" Received: from unknown (HELO yungchua-desk.intel.com) ([10.247.119.176]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:45 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 1/3] ALSA/ASoC/SoundWire: Intel: use single definition for SDW_INTEL_MAX_LINKS Date: Fri, 16 Aug 2024 10:33:29 +0800 Message-ID: <20240816023331.6565-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> References: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pierre-Louis Bossart The definitions are currently duplicated in intel-sdw-acpi.c and sof_sdw.c. Move the definition to the sdw_intel.h header, and change the prefix to make it Intel-specific. No functionality change in this patch. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Signed-off-by: Bard Liao Acked-by: Mark Brown Reviewed-by: Takashi Iwai --- include/linux/soundwire/sdw_intel.h | 5 +++++ sound/hda/intel-sdw-acpi.c | 5 ++--- sound/soc/intel/boards/sof_sdw.c | 4 +++- sound/soc/intel/boards/sof_sdw_common.h | 4 +--- sound/soc/intel/boards/sof_sdw_hdmi.c | 2 ++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index d537587b4499..87d82ea9a13a 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -447,4 +447,9 @@ extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops; #define SDW_INTEL_DEV_NUM_IDA_MIN 6 +/* + * Max number of links supported in hardware + */ +#define SDW_INTEL_MAX_LINKS 4 + #endif diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c index f3b2a610df23..04d6b6beabca 100644 --- a/sound/hda/intel-sdw-acpi.c +++ b/sound/hda/intel-sdw-acpi.c @@ -17,7 +17,6 @@ #include #define SDW_LINK_TYPE 4 /* from Intel ACPI documentation */ -#define SDW_MAX_LINKS 4 static int ctrl_link_mask; module_param_named(sdw_link_mask, ctrl_link_mask, int, 0444); @@ -87,9 +86,9 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info) } /* Check count is within bounds */ - if (count > SDW_MAX_LINKS) { + if (count > SDW_INTEL_MAX_LINKS) { dev_err(&adev->dev, "Link count %d exceeds max %d\n", - count, SDW_MAX_LINKS); + count, SDW_INTEL_MAX_LINKS); return -EINVAL; } diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index d258728d64cf..b1fb6fabd3b7 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -5,12 +5,14 @@ * sof_sdw - ASOC Machine driver for Intel SoundWire platforms */ +#include #include #include #include #include #include #include +#include #include #include "sof_sdw_common.h" #include "../../codecs/rt711.h" @@ -883,7 +885,7 @@ static int create_sdw_dailinks(struct snd_soc_card *card, struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private; int ret, i; - for (i = 0; i < SDW_MAX_LINKS; i++) + for (i = 0; i < SDW_INTEL_MAX_LINKS; i++) intel_ctx->sdw_pin_index[i] = SOC_SDW_INTEL_BIDIR_PDI_BASE; /* generate DAI links by each sdw link */ diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 02f3eebd019d..c10d2711b730 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -19,8 +19,6 @@ #define SOC_SDW_MAX_CPU_DAIS 16 #define SOC_SDW_INTEL_BIDIR_PDI_BASE 2 -#define SDW_MAX_LINKS 4 - /* 8 combinations with 4 links + unused group 0 */ #define SDW_MAX_GROUPS 9 @@ -57,7 +55,7 @@ enum { struct intel_mc_ctx { struct sof_hdmi_private hdmi; /* To store SDW Pin index for each SoundWire link */ - unsigned int sdw_pin_index[SDW_MAX_LINKS]; + unsigned int sdw_pin_index[SDW_INTEL_MAX_LINKS]; }; extern unsigned long sof_sdw_quirk; diff --git a/sound/soc/intel/boards/sof_sdw_hdmi.c b/sound/soc/intel/boards/sof_sdw_hdmi.c index 4084119a9a5f..f92867deb029 100644 --- a/sound/soc/intel/boards/sof_sdw_hdmi.c +++ b/sound/soc/intel/boards/sof_sdw_hdmi.c @@ -5,10 +5,12 @@ * sof_sdw_hdmi - Helpers to handle HDMI from generic machine driver */ +#include #include #include #include #include +#include #include #include #include From patchwork Fri Aug 16 02:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13765378 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFE016F077; Fri, 16 Aug 2024 02:33:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775633; cv=none; b=jBhmWRBzuqbsRBQ/RVir+Ta/gZDWtSioif+LiOZrcCgEbUCvLjwPhcOll1D1llRhzJEAZfnVsYfVgQ2d9zqkFrbCeMnayWQVOjR+5eqARytLu1E4rb+S9Zvi6z+r/hLqslV2Ye7nsZbbY6Jh+S6/R/nQjfnQGZgXimSLyU9am3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775633; c=relaxed/simple; bh=or0XB+/dgJu4KGVOM0mhWGDl51cpwO3IM2pUWBpH75E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t56VxuMNQV7lghP9+yqdB2TH2jePmml5C9DL/s7ouZ9lDEJVmu4rNvrYH3+tnKQ5WbkbkdlX4q5tj4St4TXukfrqwwZQ+IT6mNW3NReoXDhQMQTsUlBS8G5tARoR3NWeIjgsbOf6KEJmg3RzZ/Rp4A7gX97kLySnKiTshHETKQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BnovtYyx; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BnovtYyx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723775632; x=1755311632; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=or0XB+/dgJu4KGVOM0mhWGDl51cpwO3IM2pUWBpH75E=; b=BnovtYyxDHVGzWO9MXTBpWWkgiOGZrnLgSDj0heILCOc0MmvpA4PhLYx wMqAHdY/OlO9NMxQVxvi2ayPF15JhfVmfowYtiCoi1ydl43te+PCUNB7K eXRjLKfGUD3wUISBT8Y/f/uvW0aoDm7SNakc7nNFzdthFjBzFrwJYpOaw sSJKBvA6CuegD34yQlMKNbuwViiZFpj/hvhB3zHxa8H9sHoqpqYH/J4yC f7Vprx8DosWJNY/mdYieUX4LCMhncB3pc20bsTTxwwD0LwW0AfaUtI8Va uD6AQ8A1koQcVPCcaOnqOUqQMF/nibYX8C1Ckvi6INpwjmxFheWfxky7Z Q==; X-CSE-ConnectionGUID: F8EXW4IoQYu4slVMSSkrgQ== X-CSE-MsgGUID: soJTht3XSSKIbNNH3pcqCQ== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="22203573" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="22203573" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:51 -0700 X-CSE-ConnectionGUID: k7RIgxYlQuSiUiJgj5BBcQ== X-CSE-MsgGUID: F4FC6WNzRLCQOjTyWNH8cA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="63949207" Received: from unknown (HELO yungchua-desk.intel.com) ([10.247.119.176]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:48 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 2/3] soundwire: intel: increase maximum number of links Date: Fri, 16 Aug 2024 10:33:30 +0800 Message-ID: <20240816023331.6565-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> References: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pierre-Louis Bossart Intel platforms have enabled 4 links since the beginning, newer platforms now have 5 links. Update the definition accordingly. This patch will have no effect on older platforms where the number of links was hard-coded. A follow-up patch will add a dynamic check that the ACPI-reported information is aligned with hardware capabilities on newer platforms. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Signed-off-by: Bard Liao Acked-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 87d82ea9a13a..edbe1d4af8f8 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -450,6 +450,6 @@ extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops; /* * Max number of links supported in hardware */ -#define SDW_INTEL_MAX_LINKS 4 +#define SDW_INTEL_MAX_LINKS 5 #endif From patchwork Fri Aug 16 02:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13765379 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCA1576056; Fri, 16 Aug 2024 02:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775636; cv=none; b=VPtr8JIt+OInbDnHwsVXdTgb36xlZXOF/nllw8reHfg3uex25fW8oJRKO34gXjyv5i2CBa4vi1E0TGdX+AMwLcKA8J9Ci+JNcyGQf47GOQnD4B0G0TPe7qYReVHBvIvR0XokH/Ul/fRBxsMwHqy3Ytv1N7q0klKXfEWHQxhm93Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723775636; c=relaxed/simple; bh=Jr4/OGLQnK9gpgUHkut0m6qsxTOqjervLSR11XEpo40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mtX5yavsBEBYPiK5LXip8QCwiWfPkm4u/QmY7tLRQZtsRhkDXhzZjXOGmHnwVaZlHUq+Pc/myr8D5UJMz+TwCYEtZX22qWp/3z/Jne4fnagPOme24yLAHpB4EtgNWSq5cE5sa/pD12/ervFuDowe/SXOp3jE2o5PY2NBNqtH3/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UqU120tC; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UqU120tC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723775635; x=1755311635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jr4/OGLQnK9gpgUHkut0m6qsxTOqjervLSR11XEpo40=; b=UqU120tCApfhHCeR/CNrSU4mBxAG/FyAez9E4MANXwsTWnrbGAyI35iz IEQOBskU0nNAfo2CHXJnGo9Ctbhmrj9BF7mNhE4oAz1Wq7gX8xWhKCzj1 kum3kD4oNCrUEP22pCySHszCZCW8tDcHWpRAsM6QRS2Z8lql+hi+pTeYs 7q2REIkgh5n6cuW4Gw1g7FZ/2qKO403dyWZuJcHFtHTIzOUO8QFeB3zQx y/tD+O0OAqJw/gXDeYtObd+wvVSlk3G/pgq8Vr2EgR6ND4lEc+t224fOT RF42uOI67aWacNHox7OK6mZSIGSaxU2sTA/I6CTAaTJz6ZFDLiS3FmNmM A==; X-CSE-ConnectionGUID: AOtKSm/vRHeB13cg8I1/yA== X-CSE-MsgGUID: tEMhfP/6TGKXKYwk9gh4Cg== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="22203581" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="22203581" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:54 -0700 X-CSE-ConnectionGUID: skpkR3DzRfiAirew3dejpg== X-CSE-MsgGUID: mKh35jl6R0G9O2rZFFPW2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="63949220" Received: from unknown (HELO yungchua-desk.intel.com) ([10.247.119.176]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 19:33:51 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 3/3] soundwire: intel: add probe-time check on link id Date: Fri, 16 Aug 2024 10:33:31 +0800 Message-ID: <20240816023331.6565-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> References: <20240816023331.6565-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pierre-Louis Bossart In older platforms, the number of links was constant and hard-coded to 4. Newer platforms can have varying number of links, so we need to add a probe-time check to make sure the ACPI-reported information with _DSD properties is aligned with hardware capabilities reported in the SoundWire LCAP register. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Signed-off-by: Bard Liao Acked-by: Vinod Koul --- drivers/soundwire/intel.h | 7 +++++++ drivers/soundwire/intel_ace2x.c | 20 ++++++++++++++++++++ drivers/soundwire/intel_auxdevice.c | 14 ++++++++++++++ include/linux/soundwire/sdw_intel.h | 3 +++ 4 files changed, 44 insertions(+) diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h index 68838e843b54..1db4d9d3a3ba 100644 --- a/drivers/soundwire/intel.h +++ b/drivers/soundwire/intel.h @@ -222,6 +222,13 @@ static inline bool sdw_intel_sync_check_cmdsync_unlocked(struct sdw_intel *sdw) return false; } +static inline int sdw_intel_get_link_count(struct sdw_intel *sdw) +{ + if (SDW_INTEL_CHECK_OPS(sdw, get_link_count)) + return SDW_INTEL_OPS(sdw, get_link_count)(sdw); + return 4; /* default on older generations */ +} + /* common bus management */ int intel_start_bus(struct sdw_intel *sdw); int intel_start_bus_after_reset(struct sdw_intel *sdw); diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 781fe0aefa68..fff312c6968d 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -706,10 +706,30 @@ static void intel_program_sdi(struct sdw_intel *sdw, int dev_num) __func__, sdw->instance, dev_num); } +static int intel_get_link_count(struct sdw_intel *sdw) +{ + int ret; + + ret = hdac_bus_eml_get_count(sdw->link_res->hbus, true, AZX_REG_ML_LEPTR_ID_SDW); + if (!ret) { + dev_err(sdw->cdns.dev, "%s: could not retrieve link count\n", __func__); + return -ENODEV; + } + + if (ret > SDW_INTEL_MAX_LINKS) { + dev_err(sdw->cdns.dev, "%s: link count %d exceed max %d\n", __func__, ret, SDW_INTEL_MAX_LINKS); + return -EINVAL; + } + + 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, + .get_link_count = intel_get_link_count, + .register_dai = intel_register_dai, .check_clock_stop = intel_check_clock_stop, diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 8807e01cbf7c..d110f2b587d5 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -317,6 +317,20 @@ static int intel_link_probe(struct auxiliary_device *auxdev, bus->link_id = auxdev->id; bus->clk_stop_timeout = 1; + /* + * paranoia check: make sure ACPI-reported number of links is aligned with + * hardware capabilities. + */ + ret = sdw_intel_get_link_count(sdw); + if (ret < 0) { + dev_err(dev, "%s: sdw_intel_get_link_count failed: %d\n", __func__, ret); + return ret; + } + if (ret <= sdw->instance) { + dev_err(dev, "%s: invalid link id %d, link count %d\n", __func__, auxdev->id, ret); + return -EINVAL; + } + sdw_cdns_probe(cdns); /* Set ops */ diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index edbe1d4af8f8..37ae69365fe2 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -388,6 +388,7 @@ struct sdw_intel; /* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. * @debugfs_init: initialize all debugfs capabilities * @debugfs_exit: close and cleanup debugfs capabilities + * @get_link_count: fetch link count from hardware registers * @register_dai: read all PDI information and register DAIs * @check_clock_stop: throw error message if clock is not stopped. * @start_bus: normal start @@ -412,6 +413,8 @@ struct sdw_intel_hw_ops { void (*debugfs_init)(struct sdw_intel *sdw); void (*debugfs_exit)(struct sdw_intel *sdw); + int (*get_link_count)(struct sdw_intel *sdw); + int (*register_dai)(struct sdw_intel *sdw); void (*check_clock_stop)(struct sdw_intel *sdw);