hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/sound/soc/intel/skylake/cnl-sst.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * cnl-sst.c - DSP library functions for CNL platform
34 *
....@@ -11,15 +12,6 @@
1112 *
1213 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1314 *
14
- * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License as version 2, as
16
- * published by the Free Software Foundation.
17
- *
18
- * This program is distributed in the hope that it will be useful, but
19
- * WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
- * General Public License for more details.
22
- *
2315 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2416 */
2517
....@@ -32,8 +24,7 @@
3224 #include "../common/sst-dsp-priv.h"
3325 #include "../common/sst-ipc.h"
3426 #include "cnl-sst-dsp.h"
35
-#include "skl-sst-dsp.h"
36
-#include "skl-sst-ipc.h"
27
+#include "skl.h"
3728
3829 #define CNL_FW_ROM_INIT 0x1
3930 #define CNL_FW_INIT 0x5
....@@ -66,15 +57,31 @@
6657 ctx->dsp_ops.stream_tag = stream_tag;
6758 memcpy(ctx->dmab.area, fwdata, fwsize);
6859
60
+ ret = skl_dsp_core_power_up(ctx, SKL_DSP_CORE0_MASK);
61
+ if (ret < 0) {
62
+ dev_err(ctx->dev, "dsp core0 power up failed\n");
63
+ ret = -EIO;
64
+ goto base_fw_load_failed;
65
+ }
66
+
6967 /* purge FW request */
7068 sst_dsp_shim_write(ctx, CNL_ADSP_REG_HIPCIDR,
7169 CNL_ADSP_REG_HIPCIDR_BUSY | (CNL_IPC_PURGE |
7270 ((stream_tag - 1) << CNL_ROM_CTRL_DMA_ID)));
7371
74
- ret = cnl_dsp_enable_core(ctx, SKL_DSP_CORE0_MASK);
72
+ ret = skl_dsp_start_core(ctx, SKL_DSP_CORE0_MASK);
7573 if (ret < 0) {
76
- dev_err(ctx->dev, "dsp boot core failed ret: %d\n", ret);
74
+ dev_err(ctx->dev, "Start dsp core failed ret: %d\n", ret);
7775 ret = -EIO;
76
+ goto base_fw_load_failed;
77
+ }
78
+
79
+ ret = sst_dsp_register_poll(ctx, CNL_ADSP_REG_HIPCIDA,
80
+ CNL_ADSP_REG_HIPCIDA_DONE,
81
+ CNL_ADSP_REG_HIPCIDA_DONE,
82
+ BXT_INIT_TIMEOUT, "HIPCIDA Done");
83
+ if (ret < 0) {
84
+ dev_err(ctx->dev, "timeout for purge request: %d\n", ret);
7885 goto base_fw_load_failed;
7986 }
8087
....@@ -117,8 +124,8 @@
117124 static int cnl_load_base_firmware(struct sst_dsp *ctx)
118125 {
119126 struct firmware stripped_fw;
120
- struct skl_sst *cnl = ctx->thread_context;
121
- int ret;
127
+ struct skl_dev *cnl = ctx->thread_context;
128
+ int ret, i;
122129
123130 if (!ctx->fw) {
124131 ret = request_firmware(&ctx->fw, ctx->fw_name, ctx->dev);
....@@ -140,11 +147,15 @@
140147 stripped_fw.size = ctx->fw->size;
141148 skl_dsp_strip_extended_manifest(&stripped_fw);
142149
143
- ret = cnl_prepare_fw(ctx, stripped_fw.data, stripped_fw.size);
144
- if (ret < 0) {
145
- dev_err(ctx->dev, "prepare firmware failed: %d\n", ret);
146
- goto cnl_load_base_firmware_failed;
150
+ for (i = 0; i < BXT_FW_ROM_INIT_RETRY; i++) {
151
+ ret = cnl_prepare_fw(ctx, stripped_fw.data, stripped_fw.size);
152
+ if (!ret)
153
+ break;
154
+ dev_dbg(ctx->dev, "prepare firmware failed: %d\n", ret);
147155 }
156
+
157
+ if (ret < 0)
158
+ goto cnl_load_base_firmware_failed;
148159
149160 ret = sst_transfer_fw_host_dma(ctx);
150161 if (ret < 0) {
....@@ -167,6 +178,7 @@
167178 return 0;
168179
169180 cnl_load_base_firmware_failed:
181
+ dev_err(ctx->dev, "firmware load failed: %d\n", ret);
170182 release_firmware(ctx->fw);
171183 ctx->fw = NULL;
172184
....@@ -175,7 +187,7 @@
175187
176188 static int cnl_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id)
177189 {
178
- struct skl_sst *cnl = ctx->thread_context;
190
+ struct skl_dev *cnl = ctx->thread_context;
179191 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
180192 struct skl_ipc_dxstate_info dx;
181193 int ret;
....@@ -238,7 +250,7 @@
238250
239251 static int cnl_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id)
240252 {
241
- struct skl_sst *cnl = ctx->thread_context;
253
+ struct skl_dev *cnl = ctx->thread_context;
242254 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
243255 struct skl_ipc_dxstate_info dx;
244256 int ret;
....@@ -289,8 +301,6 @@
289301 .irq_handler = cnl_dsp_sst_interrupt,
290302 .write = sst_shim32_write,
291303 .read = sst_shim32_read,
292
- .ram_read = sst_memcpy_fromio_32,
293
- .ram_write = sst_memcpy_toio_32,
294304 .free = cnl_dsp_free,
295305 };
296306
....@@ -302,7 +312,7 @@
302312 static irqreturn_t cnl_dsp_irq_thread_handler(int irq, void *context)
303313 {
304314 struct sst_dsp *dsp = context;
305
- struct skl_sst *cnl = sst_dsp_get_thread_context(dsp);
315
+ struct skl_dev *cnl = dsp->thread_context;
306316 struct sst_generic_ipc *ipc = &cnl->ipc;
307317 struct skl_ipc_header header = {0};
308318 u32 hipcida, hipctdr, hipctdd;
....@@ -314,6 +324,7 @@
314324
315325 hipcida = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCIDA);
316326 hipctdr = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCTDR);
327
+ hipctdd = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCTDD);
317328
318329 /* reply message from dsp */
319330 if (hipcida & CNL_ADSP_REG_HIPCIDA_DONE) {
....@@ -333,7 +344,6 @@
333344
334345 /* new message from dsp */
335346 if (hipctdr & CNL_ADSP_REG_HIPCTDR_BUSY) {
336
- hipctdd = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCTDD);
337347 header.primary = hipctdr;
338348 header.extension = hipctdd;
339349 dev_dbg(dsp->dev, "IPC irq: Firmware respond primary:%x",
....@@ -376,10 +386,10 @@
376386
377387 static void cnl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
378388 {
379
- struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header);
389
+ struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->tx.header);
380390
381
- if (msg->tx_size)
382
- sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size);
391
+ if (msg->tx.size)
392
+ sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
383393 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDD,
384394 header->extension);
385395 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDR,
....@@ -395,7 +405,7 @@
395405 return (hipcidr & CNL_ADSP_REG_HIPCIDR_BUSY);
396406 }
397407
398
-static int cnl_ipc_init(struct device *dev, struct skl_sst *cnl)
408
+static int cnl_ipc_init(struct device *dev, struct skl_dev *cnl)
399409 {
400410 struct sst_generic_ipc *ipc;
401411 int err;
....@@ -424,9 +434,9 @@
424434
425435 int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
426436 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
427
- struct skl_sst **dsp)
437
+ struct skl_dev **dsp)
428438 {
429
- struct skl_sst *cnl;
439
+ struct skl_dev *cnl;
430440 struct sst_dsp *sst;
431441 int ret;
432442
....@@ -463,12 +473,12 @@
463473 }
464474 EXPORT_SYMBOL_GPL(cnl_sst_dsp_init);
465475
466
-int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx)
476
+int cnl_sst_init_fw(struct device *dev, struct skl_dev *skl)
467477 {
468478 int ret;
469
- struct sst_dsp *sst = ctx->dsp;
479
+ struct sst_dsp *sst = skl->dsp;
470480
471
- ret = ctx->dsp->fw_ops.load_fw(sst);
481
+ ret = skl->dsp->fw_ops.load_fw(sst);
472482 if (ret < 0) {
473483 dev_err(dev, "load base fw failed: %d", ret);
474484 return ret;
....@@ -476,21 +486,21 @@
476486
477487 skl_dsp_init_core_state(sst);
478488
479
- ctx->is_first_boot = false;
489
+ skl->is_first_boot = false;
480490
481491 return 0;
482492 }
483493 EXPORT_SYMBOL_GPL(cnl_sst_init_fw);
484494
485
-void cnl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
495
+void cnl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
486496 {
487
- if (ctx->dsp->fw)
488
- release_firmware(ctx->dsp->fw);
497
+ if (skl->dsp->fw)
498
+ release_firmware(skl->dsp->fw);
489499
490
- skl_freeup_uuid_list(ctx);
491
- cnl_ipc_free(&ctx->ipc);
500
+ skl_freeup_uuid_list(skl);
501
+ cnl_ipc_free(&skl->ipc);
492502
493
- ctx->dsp->ops->free(ctx->dsp);
503
+ skl->dsp->ops->free(skl->dsp);
494504 }
495505 EXPORT_SYMBOL_GPL(cnl_sst_dsp_cleanup);
496506