]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ASoC: Intel: Skylake: Move sst common initialization to a helper function
authorG Kranthi <gudishax.kranthikumar@intel.com>
Tue, 25 Apr 2017 06:48:19 +0000 (12:18 +0530)
committerMark Brown <broonie@kernel.org>
Wed, 26 Apr 2017 14:47:28 +0000 (15:47 +0100)
Some skl sst context are not dependent of platform and initializing them
independently for each platform can lead to errors. So optimize by
moving them to a helper function and platform specific init code can
call this.

Signed-off-by: G Kranthi <gudishax.kranthikumar@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/bxt-sst.c
sound/soc/intel/skylake/skl-sst-dsp.h
sound/soc/intel/skylake/skl-sst-utils.c
sound/soc/intel/skylake/skl-sst.c

index 268bdaec8042e6814f363db1c99a7e66814e26c7..2bf6ebe29f50120412a6027944834197e60c380c 100644 (file)
@@ -590,23 +590,14 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
        struct sst_dsp *sst;
        int ret;
 
-       skl = devm_kzalloc(dev, sizeof(*skl), GFP_KERNEL);
-       if (skl == NULL)
-               return -ENOMEM;
-
-       skl->dev = dev;
-       skl_dev.thread_context = skl;
-       INIT_LIST_HEAD(&skl->uuid_list);
-
-       skl->dsp = skl_dsp_ctx_init(dev, &skl_dev, irq);
-       if (!skl->dsp) {
-               dev_err(skl->dev, "skl_dsp_ctx_init failed\n");
-               return -ENODEV;
+       ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
+       if (ret < 0) {
+               dev_err(skl->dev, "%s: no device\n", __func__);
+               return ret;
        }
 
+       skl = *dsp;
        sst = skl->dsp;
-       sst->fw_name = fw_name;
-       sst->dsp_ops = dsp_ops;
        sst->fw_ops = bxt_fw_ops;
        sst->addr.lpe = mmio_base;
        sst->addr.shim = mmio_base;
@@ -614,24 +605,15 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
        sst_dsp_mailbox_init(sst, (BXT_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
                        SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
-       INIT_LIST_HEAD(&sst->module_list);
-       ret = skl_ipc_init(dev, skl);
-       if (ret)
-               return ret;
-
        /* set the D0i3 check */
        skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0;
 
        skl->cores.count = 2;
        skl->boot_complete = false;
        init_waitqueue_head(&skl->boot_wait);
-       skl->is_first_boot = true;
        INIT_DELAYED_WORK(&skl->d0i3.work, bxt_set_dsp_D0i3);
        skl->d0i3.state = SKL_DSP_D0I3_NONE;
 
-       if (dsp)
-               *dsp = skl;
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(bxt_sst_dsp_init);
index 7229a12b4c94a5a397a723b1ad55d11ad3a8e86e..c1f95e23933d33f59546e8d8bf960f0e157f898b 100644 (file)
@@ -247,5 +247,8 @@ void skl_freeup_uuid_list(struct skl_sst *ctx);
 
 int skl_dsp_strip_extended_manifest(struct firmware *fw);
 void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable);
+int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name,
+               struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp,
+               struct sst_dsp_device *skl_dev);
 
 #endif /*__SKL_SST_DSP_H__*/
index 6d5bff04bf65f037cac35f9a51836b87f32b98bd..a72152123c3c0e3666be17a7e2c37e9288f33094 100644 (file)
@@ -361,3 +361,40 @@ int skl_dsp_strip_extended_manifest(struct firmware *fw)
 
        return 0;
 }
+
+int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name,
+       struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp,
+       struct sst_dsp_device *skl_dev)
+{
+       struct skl_sst *skl;
+       struct sst_dsp *sst;
+       int ret;
+
+       skl = devm_kzalloc(dev, sizeof(*skl), GFP_KERNEL);
+       if (skl == NULL)
+               return -ENOMEM;
+
+       skl->dev = dev;
+       skl_dev->thread_context = skl;
+       INIT_LIST_HEAD(&skl->uuid_list);
+       skl->dsp = skl_dsp_ctx_init(dev, skl_dev, irq);
+       if (!skl->dsp) {
+               dev_err(skl->dev, "%s: no device\n", __func__);
+               return -ENODEV;
+       }
+
+       sst = skl->dsp;
+       sst->fw_name = fw_name;
+       sst->dsp_ops = dsp_ops;
+       init_waitqueue_head(&skl->mod_load_wait);
+       INIT_LIST_HEAD(&sst->module_list);
+       ret = skl_ipc_init(dev, skl);
+       if (ret)
+               return ret;
+
+       skl->is_first_boot = true;
+       if (dsp)
+               *dsp = skl;
+
+       return ret;
+}
index 539529729e3f9520c87ee19ab945b3833cb97a57..4fdd503a837c53444b9dd3b60334bf1664b42fe7 100644 (file)
@@ -330,7 +330,6 @@ static int skl_transfer_module(struct sst_dsp *ctx, const void *data,
        int ret, bytes_left, curr_pos;
        struct skl_sst *skl = ctx->thread_context;
        skl->mod_load_complete = false;
-       init_waitqueue_head(&skl->mod_load_wait);
 
        bytes_left = ctx->cl_dev.ops.cl_copy_to_dmabuf(ctx, data, size, false);
        if (bytes_left < 0)
@@ -489,43 +488,24 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
        struct sst_dsp *sst;
        int ret;
 
-       skl = devm_kzalloc(dev, sizeof(*skl), GFP_KERNEL);
-       if (skl == NULL)
-               return -ENOMEM;
-
-       skl->dev = dev;
-       skl_dev.thread_context = skl;
-       INIT_LIST_HEAD(&skl->uuid_list);
-
-       skl->dsp = skl_dsp_ctx_init(dev, &skl_dev, irq);
-       if (!skl->dsp) {
-               dev_err(skl->dev, "%s: no device\n", __func__);
-               return -ENODEV;
+       ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
+       if (ret < 0) {
+               dev_err(dev, "%s: no device\n", __func__);
+               return ret;
        }
 
+       skl = *dsp;
        sst = skl->dsp;
-
-       sst->fw_name = fw_name;
        sst->addr.lpe = mmio_base;
        sst->addr.shim = mmio_base;
        sst_dsp_mailbox_init(sst, (SKL_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),
                        SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
-       INIT_LIST_HEAD(&sst->module_list);
-       sst->dsp_ops = dsp_ops;
        sst->fw_ops = skl_fw_ops;
 
-       ret = skl_ipc_init(dev, skl);
-       if (ret)
-               return ret;
-
        skl->cores.count = 2;
-       skl->is_first_boot = true;
-
-       if (dsp)
-               *dsp = skl;
 
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(skl_sst_dsp_init);