forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/skylake/skl-sst.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * skl-sst.c - HDA DSP library functions for SKL platform
34 *
....@@ -5,15 +6,6 @@
56 * Author:Rafal Redzimski <rafal.f.redzimski@intel.com>
67 * Jeeja KP <jeeja.kp@intel.com>
78 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as version 2, as
11
- * published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
179 */
1810
1911 #include <linux/module.h>
....@@ -24,7 +16,7 @@
2416 #include "../common/sst-dsp.h"
2517 #include "../common/sst-dsp-priv.h"
2618 #include "../common/sst-ipc.h"
27
-#include "skl-sst-ipc.h"
19
+#include "skl.h"
2820
2921 #define SKL_BASEFW_TIMEOUT 300
3022 #define SKL_INIT_TIMEOUT 1000
....@@ -74,7 +66,7 @@
7466 static int skl_load_base_firmware(struct sst_dsp *ctx)
7567 {
7668 int ret = 0, i;
77
- struct skl_sst *skl = ctx->thread_context;
69
+ struct skl_dev *skl = ctx->thread_context;
7870 struct firmware stripped_fw;
7971 u32 reg;
8072
....@@ -169,7 +161,7 @@
169161 {
170162 int ret;
171163 struct skl_ipc_dxstate_info dx;
172
- struct skl_sst *skl = ctx->thread_context;
164
+ struct skl_dev *skl = ctx->thread_context;
173165 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
174166
175167 /* If core0 is being turned on, we need to load the FW */
....@@ -223,7 +215,7 @@
223215 {
224216 int ret;
225217 struct skl_ipc_dxstate_info dx;
226
- struct skl_sst *skl = ctx->thread_context;
218
+ struct skl_dev *skl = ctx->thread_context;
227219 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
228220
229221 dx.core_mask = core_mask;
....@@ -340,7 +332,7 @@
340332 u32 size, u16 mod_id, u8 table_id, bool is_module)
341333 {
342334 int ret, bytes_left, curr_pos;
343
- struct skl_sst *skl = ctx->thread_context;
335
+ struct skl_dev *skl = ctx->thread_context;
344336 skl->mod_load_complete = false;
345337
346338 bytes_left = ctx->cl_dev.ops.cl_copy_to_dmabuf(ctx, data, size, false);
....@@ -362,7 +354,7 @@
362354 /*
363355 * if bytes_left > 0 then wait for BDL complete interrupt and
364356 * copy the next chunk till bytes_left is 0. if bytes_left is
365
- * is zero, then wait for load module IPC reply
357
+ * zero, then wait for load module IPC reply
366358 */
367359 while (bytes_left > 0) {
368360 curr_pos = size - bytes_left;
....@@ -392,7 +384,7 @@
392384 static int
393385 skl_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count)
394386 {
395
- struct skl_sst *skl = ctx->thread_context;
387
+ struct skl_dev *skl = ctx->thread_context;
396388 struct firmware stripped_fw;
397389 int ret, i;
398390
....@@ -420,11 +412,8 @@
420412 struct skl_module_table *module_entry = NULL;
421413 int ret = 0;
422414 char mod_name[64]; /* guid str = 32 chars + 4 hyphens */
423
- uuid_le *uuid_mod;
424415
425
- uuid_mod = (uuid_le *)guid;
426
- snprintf(mod_name, sizeof(mod_name), "%s%pUL%s",
427
- "intel/dsp_fw_", uuid_mod, ".bin");
416
+ snprintf(mod_name, sizeof(mod_name), "intel/dsp_fw_%pUL.bin", guid);
428417
429418 module_entry = skl_module_get_from_id(ctx, mod_id);
430419 if (module_entry == NULL) {
....@@ -453,7 +442,7 @@
453442 static int skl_unload_module(struct sst_dsp *ctx, u16 mod_id)
454443 {
455444 int usage_cnt;
456
- struct skl_sst *skl = ctx->thread_context;
445
+ struct skl_dev *skl = ctx->thread_context;
457446 int ret = 0;
458447
459448 usage_cnt = skl_put_module(ctx, mod_id);
....@@ -517,8 +506,6 @@
517506 .irq_handler = skl_dsp_sst_interrupt,
518507 .write = sst_shim32_write,
519508 .read = sst_shim32_read,
520
- .ram_read = sst_memcpy_fromio_32,
521
- .ram_write = sst_memcpy_toio_32,
522509 .free = skl_dsp_free,
523510 };
524511
....@@ -528,9 +515,10 @@
528515 };
529516
530517 int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
531
- const char *fw_name, struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp)
518
+ const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
519
+ struct skl_dev **dsp)
532520 {
533
- struct skl_sst *skl;
521
+ struct skl_dev *skl;
534522 struct sst_dsp *sst;
535523 int ret;
536524
....@@ -564,10 +552,10 @@
564552 }
565553 EXPORT_SYMBOL_GPL(skl_sst_dsp_init);
566554
567
-int skl_sst_init_fw(struct device *dev, struct skl_sst *ctx)
555
+int skl_sst_init_fw(struct device *dev, struct skl_dev *skl)
568556 {
569557 int ret;
570
- struct sst_dsp *sst = ctx->dsp;
558
+ struct sst_dsp *sst = skl->dsp;
571559
572560 ret = sst->fw_ops.load_fw(sst);
573561 if (ret < 0) {
....@@ -577,32 +565,32 @@
577565
578566 skl_dsp_init_core_state(sst);
579567
580
- if (ctx->lib_count > 1) {
581
- ret = sst->fw_ops.load_library(sst, ctx->lib_info,
582
- ctx->lib_count);
568
+ if (skl->lib_count > 1) {
569
+ ret = sst->fw_ops.load_library(sst, skl->lib_info,
570
+ skl->lib_count);
583571 if (ret < 0) {
584572 dev_err(dev, "Load Library failed : %x\n", ret);
585573 return ret;
586574 }
587575 }
588
- ctx->is_first_boot = false;
576
+ skl->is_first_boot = false;
589577
590578 return 0;
591579 }
592580 EXPORT_SYMBOL_GPL(skl_sst_init_fw);
593581
594
-void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
582
+void skl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
595583 {
596584
597
- if (ctx->dsp->fw)
598
- release_firmware(ctx->dsp->fw);
599
- skl_clear_module_table(ctx->dsp);
600
- skl_freeup_uuid_list(ctx);
601
- skl_ipc_free(&ctx->ipc);
602
- ctx->dsp->ops->free(ctx->dsp);
603
- if (ctx->boot_complete) {
604
- ctx->dsp->cl_dev.ops.cl_cleanup_controller(ctx->dsp);
605
- skl_cldma_int_disable(ctx->dsp);
585
+ if (skl->dsp->fw)
586
+ release_firmware(skl->dsp->fw);
587
+ skl_clear_module_table(skl->dsp);
588
+ skl_freeup_uuid_list(skl);
589
+ skl_ipc_free(&skl->ipc);
590
+ skl->dsp->ops->free(skl->dsp);
591
+ if (skl->boot_complete) {
592
+ skl->dsp->cl_dev.ops.cl_cleanup_controller(skl->dsp);
593
+ skl_cldma_int_disable(skl->dsp);
606594 }
607595 }
608596 EXPORT_SYMBOL_GPL(skl_sst_dsp_cleanup);