From patchwork Wed Aug 21 20:17:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 11108153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B641112C for ; Wed, 21 Aug 2019 20:21:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3220222CF7 for ; Wed, 21 Aug 2019 20:21:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="SHfJdDau" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3220222CF7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 75EB91668; Wed, 21 Aug 2019 22:20:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 75EB91668 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1566418861; bh=4PTHQeiy2pe4mLnclY1aFNhVAq2sVjUTNVS202i4s0Q=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SHfJdDau5166Dnro0/GCJpbbtOHGfMfoe/LMgXwztLHYHxR3JWbFzZ0XNzh/KQ2KH 3oJrTmXJ+bN3LZ+PH/zgS3xjb4sVQHVc1kv1CFdhUfGxGHsBqh1MMipXprOqGR7ek5 Vkw4dB8uMW9y3sp1fsx+M1rKfNs1rAZr66KfDgoQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8B2BBF805F7; Wed, 21 Aug 2019 22:18:08 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7781F805F9; Wed, 21 Aug 2019 22:18:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 DDFA4F805F7 for ; Wed, 21 Aug 2019 22:18:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DDFA4F805F7 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2019 13:18:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,412,1559545200"; d="scan'208";a="186344192" Received: from smasango-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.252.139.100]) by FMSMGA003.fm.intel.com with ESMTP; 21 Aug 2019 13:17:57 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Wed, 21 Aug 2019 15:17:18 -0500 Message-Id: <20190821201720.17768-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821201720.17768-1-pierre-louis.bossart@linux.intel.com> References: <20190821201720.17768-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Guennadi Liakhovetski , tiwai@suse.de, Pan Xiuli , Keyon Jie , Takashi Iwai , srinivas.kandagatla@linaro.org, jank@cadence.com, Bard liao , YueHaibing , Pierre-Louis Bossart , Fred Oh , Ranjani Sridharan , Rander Wang , Arnd Bergmann , broonie@kernel.org, Daniel Baluta , Zhu Yingjiang , Kai Vehmanen , gregkh@linuxfoundation.org, Liam Girdwood , linux-kernel@vger.kernel.org, vkoul@kernel.org, slawomir.blauciak@intel.com Subject: [alsa-devel] [RFC PATCH 3/5] ASoC: SOF: Intel: hda: add SoundWire IP support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The Core0 needs to be powered before the SoundWire IP is initialized. Call sdw_intel_init/exit and store the context. We only have one context, but depending on the hardware capabilities and BIOS settings may enable multiple SoundWire links. Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/intel/hda.c | 40 +++++++++++++++++++++++++++++++++------ sound/soc/sof/intel/hda.h | 5 +++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index a968890d0754..e754058e3679 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -57,6 +57,8 @@ static int hda_sdw_init(struct snd_sof_dev *sdev) { acpi_handle handle; struct sdw_intel_res res; + struct sof_intel_hda_dev *hdev; + void *sdw; handle = ACPI_HANDLE(sdev->dev); @@ -66,23 +68,32 @@ static int hda_sdw_init(struct snd_sof_dev *sdev) res.irq = sdev->ipc_irq; res.parent = sdev->dev; - hda_sdw_int_enable(sdev, true); - - sdev->sdw = sdw_intel_init(handle, &res); - if (!sdev->sdw) { + sdw = sdw_intel_init(handle, &res); + if (!sdw) { dev_err(sdev->dev, "SDW Init failed\n"); return -EIO; } + hda_sdw_int_enable(sdev, true); + + /* save context */ + hdev = sdev->pdata->hw_pdata; + hdev->sdw = sdw; + return 0; } static int hda_sdw_exit(struct snd_sof_dev *sdev) { + struct sof_intel_hda_dev *hdev; + + hdev = sdev->pdata->hw_pdata; + hda_sdw_int_enable(sdev, false); - if (sdev->sdw) - sdw_intel_exit(sdev->sdw); + if (hdev->sdw) + sdw_intel_exit(hdev->sdw); + hdev->sdw = NULL; return 0; } @@ -713,6 +724,21 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) /* set default mailbox offset for FW ready message */ sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; + /* need to power-up core before setting-up capabilities */ + ret = hda_dsp_core_power_up(sdev, HDA_DSP_CORE_MASK(0)); + if (ret < 0) { + dev_err(sdev->dev, "error: could not power-up DSP subsystem\n"); + goto free_ipc_irq; + } + + /* initialize SoundWire capabilities */ + ret = hda_sdw_init(sdev); + if (ret < 0) { + dev_err(sdev->dev, "error: SoundWire get caps error\n"); + hda_dsp_core_power_down(sdev, HDA_DSP_CORE_MASK(0)); + goto free_ipc_irq; + } + return 0; free_ipc_irq: @@ -744,6 +770,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) snd_hdac_ext_bus_device_remove(bus); #endif + hda_sdw_exit(sdev); + if (!IS_ERR_OR_NULL(hda->dmic_dev)) platform_device_unregister(hda->dmic_dev); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index c8f93317aeb4..48e09b7daf0a 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -399,6 +399,11 @@ struct sof_intel_hda_dev { /* DMIC device */ struct platform_device *dmic_dev; + +#if IS_ENABLED(CONFIG_SOUNDWIRE_INTEL) + /* sdw context */ + void *sdw; +#endif }; static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)