From patchwork Thu Aug 22 19:04:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 11109901 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 02C2B1399 for ; Thu, 22 Aug 2019 19:22:30 +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 8DD6223401 for ; Thu, 22 Aug 2019 19:22:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="fb1xTE0X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD6223401 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=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 DAAC6168A; Thu, 22 Aug 2019 21:21:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DAAC6168A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1566501747; bh=EAlL93jB1MuZH4trMq5PzvuD6EIub+kc7ik4CcF4FLA=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fb1xTE0XcaEZh2ush2cYKP56ImbGuJbzveIrLZ+QbUkBFst0Ua5moo26x60xNkkSK flF9j1inGScfOn9IeesgcK7EIOy2EL6dTjwCwgSwxz5u0WmuaYgLRgHorHbz7BRLDl R54KQ1F3ilVooe/WvEx0qxoGIClmoeHrr1hQ4dmU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 12A2FF807C3; Thu, 22 Aug 2019 21:06:46 +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 C36B6F8070D; Thu, 22 Aug 2019 21:05:53 +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_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 45291F8064C for ; Thu, 22 Aug 2019 21:05:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 45291F8064C X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 12:05:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,417,1559545200"; d="scan'208";a="203524536" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmsmga004.fm.intel.com with ESMTP; 22 Aug 2019 12:05:19 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Date: Thu, 22 Aug 2019 21:04:14 +0200 Message-Id: <20190822190425.23001-25-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190822190425.23001-1-cezary.rojewski@intel.com> References: <20190822190425.23001-1-cezary.rojewski@intel.com> Cc: lgirdwood@gmail.com, Cezary Rojewski , broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.intel.com Subject: [alsa-devel] [PATCH 24/35] ASoC: Intel: Refactor probing of ACPI devices 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Baytrail and Haswell ACPI loading is now separated and no longer clutters common code. Let's improve the loading procedure and remove some superfluous members. This change removes sst_pdata::resindex_dma_base as it is a duplication of dma_base. dma_base field has had it's type changed to allow for -1 (not used) value. ACPI descriptor: sst_acpi_desc loses machines field and sst_id - now accessed via sst_pdata::boards and sst_pdata::id respectively. Cleanup consists mainly of legacy platform-specific probe routines being provided for each descendant. Prevents code duplications, especially for HSW/ BDW case while not losing any readability. Signed-off-by: Cezary Rojewski --- sound/soc/intel/baytrail/acpi.c | 43 +++++++++++----- sound/soc/intel/common/sst-acpi.c | 21 +++----- sound/soc/intel/common/sst-dsp.h | 8 +-- sound/soc/intel/common/sst-firmware.c | 2 +- sound/soc/intel/haswell/acpi.c | 65 +++++++++++++++---------- sound/soc/intel/skylake/skl-sst-utils.c | 2 +- 6 files changed, 82 insertions(+), 59 deletions(-) diff --git a/sound/soc/intel/baytrail/acpi.c b/sound/soc/intel/baytrail/acpi.c index 57d10a6e3be2..bf2560a8f3e2 100644 --- a/sound/soc/intel/baytrail/acpi.c +++ b/sound/soc/intel/baytrail/acpi.c @@ -11,25 +11,46 @@ #include #include "../common/sst-dsp.h" -static struct sst_acpi_desc byt_acpi_desc = { - .drv_name = "baytrail-pcm-audio", - .machines = snd_soc_acpi_intel_baytrail_legacy_machines, - .resindex_lpe_base = 0, - .resindex_pcicfg_base = 1, - .resindex_fw_base = 2, - .irqindex_host_ipc = 5, - .sst_id = SST_DEV_ID_BYT, - .resindex_dma_base = -1, +static struct sst_pdata byt_desc = { + .id = SST_DEV_ID_BYT, + .fw_name = "intel/fw_sst_0f28.bin-48kHz_i2s_master", + .boards = snd_soc_acpi_intel_baytrail_legacy_machines, + .dma_base = -1, }; static const struct acpi_device_id byt_acpi_ids[] = { - { "80860F28", (unsigned long)&byt_acpi_desc }, + { "80860F28", (unsigned long)&byt_desc }, { } }; MODULE_DEVICE_TABLE(acpi, byt_acpi_ids); +static int byt_acpi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct sst_acpi_desc *acpi_desc; + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return -ENODEV; + + acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); + if (!acpi_desc) + return -ENOMEM; + + acpi_desc->drv_name = "baytrail-pcm-audio"; + acpi_desc->pdata = (struct sst_pdata *)id->driver_data; + acpi_desc->resindex_lpe_base = 0; + acpi_desc->resindex_pcicfg_base = 1; + acpi_desc->resindex_fw_base = 2; + acpi_desc->irqindex_host_ipc = 5; + platform_set_drvdata(pdev, acpi_desc); + + return sst_acpi_probe(pdev); +} + static struct platform_driver byt_acpi_driver = { - .probe = sst_acpi_probe, + .probe = byt_acpi_probe, .remove = sst_acpi_remove, .driver = { .name = "byt-acpi", diff --git a/sound/soc/intel/common/sst-acpi.c b/sound/soc/intel/common/sst-acpi.c index 8e75126106ea..53ac23f05966 100644 --- a/sound/soc/intel/common/sst-acpi.c +++ b/sound/soc/intel/common/sst-acpi.c @@ -17,7 +17,6 @@ struct sst_acpi_priv { struct platform_device *pdev_mach; struct platform_device *pdev_pcm; - struct sst_pdata sst_pdata; struct sst_acpi_desc *desc; struct snd_soc_acpi_mach *mach; }; @@ -27,8 +26,8 @@ static void sst_acpi_fw_cb(const struct firmware *fw, void *context) struct platform_device *pdev = context; struct device *dev = &pdev->dev; struct sst_acpi_priv *sst_acpi = platform_get_drvdata(pdev); - struct sst_pdata *sst_pdata = &sst_acpi->sst_pdata; struct sst_acpi_desc *desc = sst_acpi->desc; + struct sst_pdata *sst_pdata = desc->pdata; struct snd_soc_acpi_mach *mach = sst_acpi->mach; sst_pdata->fw = fw; @@ -51,7 +50,6 @@ static void sst_acpi_fw_cb(const struct firmware *fw, void *context) int sst_acpi_probe(struct platform_device *pdev) { - const struct acpi_device_id *id; struct device *dev = &pdev->dev; struct sst_acpi_priv *sst_acpi; struct sst_pdata *sst_pdata; @@ -64,27 +62,20 @@ int sst_acpi_probe(struct platform_device *pdev) if (sst_acpi == NULL) return -ENOMEM; - id = acpi_match_device(dev->driver->acpi_match_table, dev); - if (!id) - return -ENODEV; - - desc = (struct sst_acpi_desc *)id->driver_data; - mach = snd_soc_acpi_find_machine(desc->machines); + desc = platform_get_drvdata(pdev); + sst_pdata = desc->pdata; + mach = snd_soc_acpi_find_machine(sst_pdata->boards); if (mach == NULL) { dev_err(dev, "No matching ASoC machine driver found\n"); return -ENODEV; } - sst_pdata = &sst_acpi->sst_pdata; - sst_pdata->id = desc->sst_id; sst_pdata->dma_dev = dev; sst_acpi->desc = desc; sst_acpi->mach = mach; - sst_pdata->resindex_dma_base = desc->resindex_dma_base; - if (desc->resindex_dma_base >= 0) { + if (sst_pdata->dma_base >= 0) { sst_pdata->dma_engine = desc->dma_engine; - sst_pdata->dma_base = desc->resindex_dma_base; sst_pdata->dma_size = desc->dma_size; } @@ -140,7 +131,7 @@ EXPORT_SYMBOL_GPL(sst_acpi_probe); int sst_acpi_remove(struct platform_device *pdev) { struct sst_acpi_priv *sst_acpi = platform_get_drvdata(pdev); - struct sst_pdata *sst_pdata = &sst_acpi->sst_pdata; + struct sst_pdata *sst_pdata = sst_acpi->desc->pdata; platform_device_unregister(sst_acpi->pdev_mach); if (!IS_ERR_OR_NULL(sst_acpi->pdev_pcm)) diff --git a/sound/soc/intel/common/sst-dsp.h b/sound/soc/intel/common/sst-dsp.h index a2ac7998fbdb..87d39b0e79c0 100644 --- a/sound/soc/intel/common/sst-dsp.h +++ b/sound/soc/intel/common/sst-dsp.h @@ -171,16 +171,13 @@ struct platform_device; /* Descriptor for setting up SST platform data */ struct sst_acpi_desc { const char *drv_name; - struct snd_soc_acpi_mach *machines; + struct sst_pdata *pdata; /* Platform resource indexes. Must set to -1 if not used */ int resindex_lpe_base; int resindex_pcicfg_base; int resindex_fw_base; int irqindex_host_ipc; int resindex_dma_base; - /* Unique number identifying the SST core on platform */ - int sst_id; - /* DMA only valid when resindex_dma_base != -1*/ int dma_engine; int dma_size; }; @@ -205,8 +202,7 @@ struct sst_pdata { const struct firmware *fw; /* DMA */ - int resindex_dma_base; /* other fields invalid if equals to -1 */ - u32 dma_base; + int dma_base; /* other fields invalid if equals to -1 */ u32 dma_size; int dma_engine; struct device *dma_dev; diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c index 6b6af11c32c3..61d3e6e46b98 100644 --- a/sound/soc/intel/common/sst-firmware.c +++ b/sound/soc/intel/common/sst-firmware.c @@ -268,7 +268,7 @@ static int sst_dma_new(struct sst_dsp *sst) struct resource mem; int ret = 0; - if (sst->pdata->resindex_dma_base == -1) + if (sst->pdata->dma_base == -1) /* DMA is not used, return and squelsh error messages */ return 0; diff --git a/sound/soc/intel/haswell/acpi.c b/sound/soc/intel/haswell/acpi.c index 7bd8b03851c4..3c49ec257e56 100644 --- a/sound/soc/intel/haswell/acpi.c +++ b/sound/soc/intel/haswell/acpi.c @@ -15,41 +15,56 @@ #define SST_WPT_DSP_DMA_ADDR_OFFSET 0x0FE000 #define SST_LPT_DSP_DMA_SIZE (1024 - 1) -static struct sst_acpi_desc hsw_acpi_desc = { - .drv_name = "haswell-pcm-audio", - .machines = snd_soc_acpi_intel_haswell_machines, - .resindex_lpe_base = 0, - .resindex_pcicfg_base = 1, - .resindex_fw_base = -1, - .irqindex_host_ipc = 0, - .sst_id = SST_DEV_ID_LYNX_POINT, - .dma_engine = SST_DMA_TYPE_DW, - .resindex_dma_base = SST_LPT_DSP_DMA_ADDR_OFFSET, - .dma_size = SST_LPT_DSP_DMA_SIZE, +static struct sst_pdata hsw_desc = { + .id = SST_DEV_ID_LYNX_POINT, + .fw_name = "intel/IntcSST1.bin", + .boards = snd_soc_acpi_intel_haswell_machines, + .dma_base = SST_LPT_DSP_DMA_ADDR_OFFSET, }; -static struct sst_acpi_desc bdw_acpi_desc = { - .drv_name = "haswell-pcm-audio", - .machines = snd_soc_acpi_intel_broadwell_machines, - .resindex_lpe_base = 0, - .resindex_pcicfg_base = 1, - .resindex_fw_base = -1, - .irqindex_host_ipc = 0, - .sst_id = SST_DEV_ID_WILDCAT_POINT, - .dma_engine = SST_DMA_TYPE_DW, - .resindex_dma_base = SST_WPT_DSP_DMA_ADDR_OFFSET, - .dma_size = SST_LPT_DSP_DMA_SIZE, +static struct sst_pdata bdw_desc = { + .id = SST_DEV_ID_WILDCAT_POINT, + .fw_name = "intel/IntcSST2.bin", + .boards = snd_soc_acpi_intel_broadwell_machines, + .dma_base = SST_WPT_DSP_DMA_ADDR_OFFSET, }; static const struct acpi_device_id hsw_acpi_ids[] = { - { "INT33C8", (unsigned long)&hsw_acpi_desc }, - { "INT3438", (unsigned long)&bdw_acpi_desc }, + { "INT33C8", (unsigned long)&hsw_desc }, + { "INT3438", (unsigned long)&bdw_desc }, { } }; MODULE_DEVICE_TABLE(acpi, hsw_acpi_ids); +static int hsw_acpi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct sst_acpi_desc *acpi_desc; + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return -ENODEV; + + acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); + if (!acpi_desc) + return -ENOMEM; + + acpi_desc->drv_name = "haswell-pcm-audio"; + acpi_desc->pdata = (struct sst_pdata *)id->driver_data; + acpi_desc->resindex_lpe_base = 0; + acpi_desc->resindex_pcicfg_base = 1; + acpi_desc->resindex_fw_base = -1; + acpi_desc->irqindex_host_ipc = 0; + acpi_desc->dma_engine = SST_DMA_TYPE_DW; + acpi_desc->dma_size = SST_LPT_DSP_DMA_SIZE; + platform_set_drvdata(pdev, acpi_desc); + + return sst_acpi_probe(pdev); +} + static struct platform_driver hsw_acpi_driver = { - .probe = sst_acpi_probe, + .probe = hsw_acpi_probe, .remove = sst_acpi_remove, .driver = { .name = "hsw-acpi", diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c index bbe67e298efe..ac0a0e4c2d68 100644 --- a/sound/soc/intel/skylake/skl-sst-utils.c +++ b/sound/soc/intel/skylake/skl-sst-utils.c @@ -363,7 +363,7 @@ int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, pdata->id = skl->pci->device; pdata->irq = irq; - pdata->resindex_dma_base = -1; + pdata->dma_base = -1; skl->dev = dev; pdata->dsp = skl; INIT_LIST_HEAD(&skl->uuid_list);