forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/intel/skylake/bxt-sst.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * bxt-sst.c - DSP library functions for BXT platform
34 *
45 * Copyright (C) 2015-16 Intel Corp
56 * Author:Rafal Redzimski <rafal.f.redzimski@intel.com>
67 * Jeeja KP <jeeja.kp@intel.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; version 2 of the License.
11
- *
12
- * This program is distributed in the hope that it will be useful, but
13
- * WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * General Public License for more details.
168 */
179
1810 #include <linux/module.h>
....@@ -22,10 +14,9 @@
2214
2315 #include "../common/sst-dsp.h"
2416 #include "../common/sst-dsp-priv.h"
25
-#include "skl-sst-ipc.h"
17
+#include "skl.h"
2618
2719 #define BXT_BASEFW_TIMEOUT 3000
28
-#define BXT_INIT_TIMEOUT 300
2920 #define BXT_ROM_INIT_TIMEOUT 70
3021 #define BXT_IPC_PURGE_FW 0x01004000
3122
....@@ -46,8 +37,6 @@
4637 /* Delay before scheduling D0i3 entry */
4738 #define BXT_D0I3_DELAY 5000
4839
49
-#define BXT_FW_ROM_INIT_RETRY 3
50
-
5140 static unsigned int bxt_get_errorcode(struct sst_dsp *ctx)
5241 {
5342 return sst_dsp_shim_read(ctx, BXT_ADSP_ERROR_CODE);
....@@ -57,7 +46,7 @@
5746 bxt_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count)
5847 {
5948 struct snd_dma_buffer dmab;
60
- struct skl_sst *skl = ctx->thread_context;
49
+ struct skl_dev *skl = ctx->thread_context;
6150 struct firmware stripped_fw;
6251 int ret = 0, i, dma_id, stream_tag;
6352
....@@ -192,7 +181,7 @@
192181 static int bxt_load_base_firmware(struct sst_dsp *ctx)
193182 {
194183 struct firmware stripped_fw;
195
- struct skl_sst *skl = ctx->thread_context;
184
+ struct skl_dev *skl = ctx->thread_context;
196185 int ret, i;
197186
198187 if (ctx->fw == NULL) {
....@@ -276,7 +265,7 @@
276265 */
277266 static int bxt_d0i3_target_state(struct sst_dsp *ctx)
278267 {
279
- struct skl_sst *skl = ctx->thread_context;
268
+ struct skl_dev *skl = ctx->thread_context;
280269 struct skl_d0i3_data *d0i3 = &skl->d0i3;
281270
282271 if (skl->cores.state[SKL_DSP_CORE0_ID] != SKL_DSP_RUNNING)
....@@ -296,8 +285,8 @@
296285 {
297286 int ret;
298287 struct skl_ipc_d0ix_msg msg;
299
- struct skl_sst *skl = container_of(work,
300
- struct skl_sst, d0i3.work.work);
288
+ struct skl_dev *skl = container_of(work,
289
+ struct skl_dev, d0i3.work.work);
301290 struct sst_dsp *ctx = skl->dsp;
302291 struct skl_d0i3_data *d0i3 = &skl->d0i3;
303292 int target_state;
....@@ -339,7 +328,7 @@
339328
340329 static int bxt_schedule_dsp_D0i3(struct sst_dsp *ctx)
341330 {
342
- struct skl_sst *skl = ctx->thread_context;
331
+ struct skl_dev *skl = ctx->thread_context;
343332 struct skl_d0i3_data *d0i3 = &skl->d0i3;
344333
345334 /* Schedule D0i3 only if the usecase ref counts are appropriate */
....@@ -358,7 +347,7 @@
358347 {
359348 int ret;
360349 struct skl_ipc_d0ix_msg msg;
361
- struct skl_sst *skl = ctx->thread_context;
350
+ struct skl_dev *skl = ctx->thread_context;
362351
363352 dev_dbg(ctx->dev, "In %s:\n", __func__);
364353
....@@ -397,7 +386,7 @@
397386
398387 static int bxt_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id)
399388 {
400
- struct skl_sst *skl = ctx->thread_context;
389
+ struct skl_dev *skl = ctx->thread_context;
401390 int ret;
402391 struct skl_ipc_dxstate_info dx;
403392 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
....@@ -494,7 +483,7 @@
494483 {
495484 int ret;
496485 struct skl_ipc_dxstate_info dx;
497
- struct skl_sst *skl = ctx->thread_context;
486
+ struct skl_dev *skl = ctx->thread_context;
498487 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
499488
500489 dx.core_mask = core_mask;
....@@ -544,8 +533,6 @@
544533 .irq_handler = skl_dsp_sst_interrupt,
545534 .write = sst_shim32_write,
546535 .read = sst_shim32_read,
547
- .ram_read = sst_memcpy_fromio_32,
548
- .ram_write = sst_memcpy_toio_32,
549536 .free = skl_dsp_free,
550537 };
551538
....@@ -556,9 +543,9 @@
556543
557544 int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
558545 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
559
- struct skl_sst **dsp)
546
+ struct skl_dev **dsp)
560547 {
561
- struct skl_sst *skl;
548
+ struct skl_dev *skl;
562549 struct sst_dsp *sst;
563550 int ret;
564551
....@@ -599,10 +586,10 @@
599586 }
600587 EXPORT_SYMBOL_GPL(bxt_sst_dsp_init);
601588
602
-int bxt_sst_init_fw(struct device *dev, struct skl_sst *ctx)
589
+int bxt_sst_init_fw(struct device *dev, struct skl_dev *skl)
603590 {
604591 int ret;
605
- struct sst_dsp *sst = ctx->dsp;
592
+ struct sst_dsp *sst = skl->dsp;
606593
607594 ret = sst->fw_ops.load_fw(sst);
608595 if (ret < 0) {
....@@ -612,29 +599,29 @@
612599
613600 skl_dsp_init_core_state(sst);
614601
615
- if (ctx->lib_count > 1) {
616
- ret = sst->fw_ops.load_library(sst, ctx->lib_info,
617
- ctx->lib_count);
602
+ if (skl->lib_count > 1) {
603
+ ret = sst->fw_ops.load_library(sst, skl->lib_info,
604
+ skl->lib_count);
618605 if (ret < 0) {
619606 dev_err(dev, "Load Library failed : %x\n", ret);
620607 return ret;
621608 }
622609 }
623
- ctx->is_first_boot = false;
610
+ skl->is_first_boot = false;
624611
625612 return 0;
626613 }
627614 EXPORT_SYMBOL_GPL(bxt_sst_init_fw);
628615
629
-void bxt_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
616
+void bxt_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
630617 {
631618
632
- skl_release_library(ctx->lib_info, ctx->lib_count);
633
- if (ctx->dsp->fw)
634
- release_firmware(ctx->dsp->fw);
635
- skl_freeup_uuid_list(ctx);
636
- skl_ipc_free(&ctx->ipc);
637
- ctx->dsp->ops->free(ctx->dsp);
619
+ skl_release_library(skl->lib_info, skl->lib_count);
620
+ if (skl->dsp->fw)
621
+ release_firmware(skl->dsp->fw);
622
+ skl_freeup_uuid_list(skl);
623
+ skl_ipc_free(&skl->ipc);
624
+ skl->dsp->ops->free(skl->dsp);
638625 }
639626 EXPORT_SYMBOL_GPL(bxt_sst_dsp_cleanup);
640627