From patchwork Thu Mar 23 05:44:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 666150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FB71C6FD1C for ; Thu, 23 Mar 2023 05:35:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 257AEEE9; Thu, 23 Mar 2023 06:34:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 257AEEE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1679549745; bh=zfPDFAUHD0yEFTAl6FmNYsvKI40bPenFTeUs36GSzIY=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ciGNtA74+V2wc4qo7KcUma7cBqwkK26+aWoJrnRWBw/p509TcVWwQHF/hGqF5SWMb XZKsDraqQ0K8sRelgKGD1KQ0IczbSGGtuCtBq5VzlM/HXL3r71BKUznCUaq+4CGHiR uyJg+Xo4WCDx7iOKi944ecn59ZPI2W5Zsh0NwQNw= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D124AF8055C; Thu, 23 Mar 2023 06:32:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0F7C9F8052E; Thu, 23 Mar 2023 06:30:56 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9413DF80254 for ; Thu, 23 Mar 2023 06:30:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9413DF80254 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=XxALgGX7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679549426; x=1711085426; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zfPDFAUHD0yEFTAl6FmNYsvKI40bPenFTeUs36GSzIY=; b=XxALgGX7SEmjID1HGr2Ndus3d80YaqLybJfdTtkXg3VU7tYf8f5+5A9w F+0o71/ylESRpzN1Is8/7eejRoJ2qNOGsGR1zdA0Mnlyf41LsxuG1CIRT QVh87rffX5SfcjwRkc22UzFI7aPGX5XvHj916AbIK6Am8gy/2nsN1GMIN xfkjaHV5hV4llWKG6UpLk0w2Ltd4oDpVCMdJr8YEWZkOTvXyc7mOmBFQT WTLRZSwTk538A+SebSYIzsOK0aXuMQ+ZfszDzHLG7yOwjNh1JVkhzoCGM bEZ3IfAw6B/6Ju0v7wdWLyYuwAgb7AyEjWGAFmdHKNf3BpTDzs6nEdGEj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327779410" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="327779410" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 22:30:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="675567117" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="675567117" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 22:30:16 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org, broonie@kernel.org Subject: [PATCH 11/20] soundwire: intel_ace2x: add link power-up/down helpers Date: Thu, 23 Mar 2023 13:44:43 +0800 Message-Id: <20230323054452.1543233-12-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com> References: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: OY75RKOWOT4WG7CFJRGU577QOBGZCFAG X-Message-ID-Hash: OY75RKOWOT4WG7CFJRGU577QOBGZCFAG X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, tiwai@suse.de X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart only power-up/down for now, the frequency is not set. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Péter Ujfalusi Reviewed-by: Ranjani Sridharan Signed-off-by: Bard Liao --- 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 #include #include +#include #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);