From patchwork Sun Mar 13 08:14:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 8573151 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7742FC0553 for ; Sun, 13 Mar 2016 08:16:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 789EC20306 for ; Sun, 13 Mar 2016 08:16:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 24709202B8 for ; Sun, 13 Mar 2016 08:16:57 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9DA1B261A1A; Sun, 13 Mar 2016 09:16:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AA525261A34; Sun, 13 Mar 2016 09:15:23 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C5AD62605B2; Sun, 13 Mar 2016 09:15:21 +0100 (CET) Received: from mezzanine.sirena.org.uk (mezzanine.sirena.org.uk [106.187.55.193]) by alsa0.perex.cz (Postfix) with ESMTP id 53678260511 for ; Sun, 13 Mar 2016 09:15:11 +0100 (CET) Received: from [2a01:348:6:8808:7e7a:91ff:fede:4a45] (helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1af1B2-0002KF-9N; Sun, 13 Mar 2016 08:15:08 +0000 Received: from broonie by finisterre with local (Exim 4.86) (envelope-from ) id 1af1Ax-0004H7-Qj; Sun, 13 Mar 2016 15:14:59 +0700 From: Mark Brown To: Jeeja KP , Vinod Koul , Mark Brown In-Reply-To: <1457671376-18667-6-git-send-email-vinod.koul@intel.com> Message-Id: Date: Sun, 13 Mar 2016 15:14:59 +0700 X-SA-Exim-Connect-IP: 2a01:348:6:8808:7e7a:91ff:fede:4a45 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] Applied "ASoC: Intel: Skylake: Move Skylake dsp ops & loader ops" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The patch ASoC: Intel: Skylake: Move Skylake dsp ops & loader ops has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From bc23ca35cfb18b0a98afa42de1df1efc7e2e9f8f Mon Sep 17 00:00:00 2001 From: Jeeja KP Date: Fri, 11 Mar 2016 10:12:53 +0530 Subject: [PATCH] ASoC: Intel: Skylake: Move Skylake dsp ops & loader ops The code loading for Skylake and other platforms is different, so add a dsp_ops and a loader_ops which can be defined for each platform. Move the dsp init, cleanup and loader ops (alloc and free dma) to these ops Signed-off-by: Jeeja KP Signed-off-by: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 62 +++++++++++++++++++++++++++++----- sound/soc/intel/skylake/skl.h | 12 ++++++- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 737934cc620d..79c5089b85d6 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -72,17 +72,47 @@ static void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable) skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)&mask); } +static struct skl_dsp_loader_ops skl_get_loader_ops(void) +{ + struct skl_dsp_loader_ops loader_ops; + + memset(&loader_ops, 0, sizeof(struct skl_dsp_loader_ops)); + + loader_ops.alloc_dma_buf = skl_alloc_dma_buf; + loader_ops.free_dma_buf = skl_free_dma_buf; + + return loader_ops; +}; + +static const struct skl_dsp_ops dsp_ops[] = { + { + .id = 0x9d70, + .loader_ops = skl_get_loader_ops, + .init = skl_sst_dsp_init, + .cleanup = skl_sst_dsp_cleanup + }, +}; + +static int skl_get_dsp_ops(int pci_id) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(dsp_ops); i++) { + if (dsp_ops[i].id == pci_id) + return i; + } + + return -EINVAL; +} + int skl_init_dsp(struct skl *skl) { void __iomem *mmio_base; struct hdac_ext_bus *ebus = &skl->ebus; struct hdac_bus *bus = ebus_to_hbus(ebus); - int irq = bus->irq; struct skl_dsp_loader_ops loader_ops; - int ret; - - loader_ops.alloc_dma_buf = skl_alloc_dma_buf; - loader_ops.free_dma_buf = skl_free_dma_buf; + int irq = bus->irq; + int ret, index; /* enable ppcap interrupt */ snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); @@ -95,8 +125,14 @@ int skl_init_dsp(struct skl *skl) return -ENXIO; } - ret = skl_sst_dsp_init(bus->dev, mmio_base, irq, + index = skl_get_dsp_ops(skl->pci->device); + if (index < 0) + return -EINVAL; + + loader_ops = dsp_ops[index].loader_ops(); + ret = dsp_ops[index].init(bus->dev, mmio_base, irq, skl->fw_name, loader_ops, &skl->skl_sst); + if (ret < 0) return ret; @@ -106,18 +142,26 @@ int skl_init_dsp(struct skl *skl) return ret; } -void skl_free_dsp(struct skl *skl) +int skl_free_dsp(struct skl *skl) { struct hdac_ext_bus *ebus = &skl->ebus; struct hdac_bus *bus = ebus_to_hbus(ebus); - struct skl_sst *ctx = skl->skl_sst; + struct skl_sst *ctx = skl->skl_sst; + int index; /* disable ppcap interrupt */ snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false); - skl_sst_dsp_cleanup(bus->dev, ctx); + index = skl_get_dsp_ops(skl->pci->device); + if (index < 0) + return -EIO; + + dsp_ops[index].cleanup(bus->dev, ctx); + if (ctx->dsp->addr.lpe) iounmap(ctx->dsp->addr.lpe); + + return 0; } int skl_suspend_dsp(struct skl *skl) diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 1ca1911f1587..39e16fa7a92b 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -90,6 +90,16 @@ struct skl_dma_params { u8 stream_tag; }; +struct skl_dsp_ops { + int id; + struct skl_dsp_loader_ops (*loader_ops)(void); + int (*init)(struct device *dev, void __iomem *mmio_base, + int irq, const char *fw_name, + struct skl_dsp_loader_ops loader_ops, + struct skl_sst **skl_sst); + void (*cleanup)(struct device *dev, struct skl_sst *ctx); +}; + int skl_platform_unregister(struct device *dev); int skl_platform_register(struct device *dev); @@ -100,7 +110,7 @@ struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance, int skl_nhlt_update_topology_bin(struct skl *skl); int skl_init_dsp(struct skl *skl); -void skl_free_dsp(struct skl *skl); +int skl_free_dsp(struct skl *skl); int skl_suspend_dsp(struct skl *skl); int skl_resume_dsp(struct skl *skl); #endif /* __SOUND_SOC_SKL_H */