Lines Matching +full:dsp +full:- +full:reset
1 // SPDX-License-Identifier: GPL-2.0-only
3 * skl-sst-dsp.c - SKL SST library generic function
5 * Copyright (C) 2014-15, Intel Corporation.
12 #include "../common/sst-dsp.h"
13 #include "../common/sst-ipc.h"
14 #include "../common/sst-dsp-priv.h"
24 mutex_lock(&ctx->mutex); in skl_dsp_set_state_locked()
25 ctx->sst_state = state; in skl_dsp_set_state_locked()
26 mutex_unlock(&ctx->mutex); in skl_dsp_set_state_locked()
32 * will be reset
36 struct skl_dev *skl = ctx->thread_context; in skl_dsp_init_core_state()
39 skl->cores.state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING; in skl_dsp_init_core_state()
40 skl->cores.usage_count[SKL_DSP_CORE0_ID] = 1; in skl_dsp_init_core_state()
42 for (i = SKL_DSP_CORE0_ID + 1; i < skl->cores.count; i++) { in skl_dsp_init_core_state()
43 skl->cores.state[i] = SKL_DSP_RESET; in skl_dsp_init_core_state()
44 skl->cores.usage_count[i] = 0; in skl_dsp_init_core_state()
51 struct skl_dev *skl = ctx->thread_context; in skl_dsp_get_enabled_cores()
55 core_mask = SKL_DSP_CORES_MASK(skl->cores.count); in skl_dsp_get_enabled_cores()
72 dev_dbg(ctx->dev, "DSP enabled cores mask = %x\n", en_cores_mask); in skl_dsp_get_enabled_cores()
93 "Set reset"); in skl_dsp_core_set_reset_state()
97 dev_err(ctx->dev, "Set reset state failed: core_mask %x\n", in skl_dsp_core_set_reset_state()
99 ret = -EIO; in skl_dsp_core_set_reset_state()
110 dev_dbg(ctx->dev, "In %s\n", __func__); in skl_dsp_core_unset_reset_state()
122 "Unset reset"); in skl_dsp_core_unset_reset_state()
126 dev_err(ctx->dev, "Unset reset state failed: core_mask %x\n", in skl_dsp_core_unset_reset_state()
128 ret = -EIO; in skl_dsp_core_unset_reset_state()
147 dev_dbg(ctx->dev, "DSP core(s) enabled? %d : core_mask %x\n", in is_skl_dsp_core_enable()
160 /* set reset state */ in skl_dsp_reset_core()
168 /* unset reset state */ in skl_dsp_start_core()
174 dev_dbg(ctx->dev, "unstall/run core: core_mask = %x\n", core_mask); in skl_dsp_start_core()
180 dev_err(ctx->dev, "DSP start core failed: core_mask %x\n", in skl_dsp_start_core()
182 ret = -EIO; in skl_dsp_start_core()
208 dev_err(ctx->dev, "DSP core power up failed: core_mask %x\n", in skl_dsp_core_power_up()
210 ret = -EIO; in skl_dsp_core_power_up()
238 dev_err(ctx->dev, "dsp core power up failed: core_mask %x\n", in skl_dsp_enable_core()
252 dev_err(ctx->dev, "dsp core reset failed: core_mask %x\n", in skl_dsp_disable_core()
260 dev_err(ctx->dev, "dsp core power down fail mask %x: %d\n", in skl_dsp_disable_core()
266 dev_err(ctx->dev, "dsp core disable fail mask %x: %d\n", in skl_dsp_disable_core()
268 ret = -EIO; in skl_dsp_disable_core()
281 dev_err(ctx->dev, "dsp core0 reset fail: %d\n", ret); in skl_dsp_boot()
287 dev_err(ctx->dev, "dsp core0 start fail: %d\n", ret); in skl_dsp_boot()
293 dev_err(ctx->dev, "dsp core0 disable fail: %d\n", ret); in skl_dsp_boot()
308 spin_lock(&ctx->spinlock); in skl_dsp_sst_interrupt()
311 ctx->intr_status = val; in skl_dsp_sst_interrupt()
314 spin_unlock(&ctx->spinlock); in skl_dsp_sst_interrupt()
328 spin_unlock(&ctx->spinlock); in skl_dsp_sst_interrupt()
338 struct skl_dev *skl = ctx->thread_context; in skl_dsp_get_core()
341 if (core_id >= skl->cores.count) { in skl_dsp_get_core()
342 dev_err(ctx->dev, "invalid core id: %d\n", core_id); in skl_dsp_get_core()
343 return -EINVAL; in skl_dsp_get_core()
346 skl->cores.usage_count[core_id]++; in skl_dsp_get_core()
348 if (skl->cores.state[core_id] == SKL_DSP_RESET) { in skl_dsp_get_core()
349 ret = ctx->fw_ops.set_state_D0(ctx, core_id); in skl_dsp_get_core()
351 dev_err(ctx->dev, "unable to get core%d\n", core_id); in skl_dsp_get_core()
357 dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n", in skl_dsp_get_core()
358 core_id, skl->cores.state[core_id], in skl_dsp_get_core()
359 skl->cores.usage_count[core_id]); in skl_dsp_get_core()
367 struct skl_dev *skl = ctx->thread_context; in skl_dsp_put_core()
370 if (core_id >= skl->cores.count) { in skl_dsp_put_core()
371 dev_err(ctx->dev, "invalid core id: %d\n", core_id); in skl_dsp_put_core()
372 return -EINVAL; in skl_dsp_put_core()
375 if ((--skl->cores.usage_count[core_id] == 0) && in skl_dsp_put_core()
376 (skl->cores.state[core_id] != SKL_DSP_RESET)) { in skl_dsp_put_core()
377 ret = ctx->fw_ops.set_state_D3(ctx, core_id); in skl_dsp_put_core()
379 dev_err(ctx->dev, "unable to put core %d: %d\n", in skl_dsp_put_core()
381 skl->cores.usage_count[core_id]++; in skl_dsp_put_core()
385 dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n", in skl_dsp_put_core()
386 core_id, skl->cores.state[core_id], in skl_dsp_put_core()
387 skl->cores.usage_count[core_id]); in skl_dsp_put_core()
415 spin_lock_init(&sst->spinlock); in skl_dsp_ctx_init()
416 mutex_init(&sst->mutex); in skl_dsp_ctx_init()
417 sst->dev = dev; in skl_dsp_ctx_init()
418 sst->sst_dev = sst_dev; in skl_dsp_ctx_init()
419 sst->irq = irq; in skl_dsp_ctx_init()
420 sst->ops = sst_dev->ops; in skl_dsp_ctx_init()
421 sst->thread_context = sst_dev->thread_context; in skl_dsp_ctx_init()
423 /* Initialise SST Audio DSP */ in skl_dsp_ctx_init()
424 if (sst->ops->init) { in skl_dsp_ctx_init()
425 ret = sst->ops->init(sst); in skl_dsp_ctx_init()
435 struct sst_dsp_device *sst_dev = sst->sst_dev; in skl_dsp_acquire_irq()
439 ret = request_threaded_irq(sst->irq, sst->ops->irq_handler, in skl_dsp_acquire_irq()
440 sst_dev->thread, IRQF_SHARED, "AudioDSP", sst); in skl_dsp_acquire_irq()
442 dev_err(sst->dev, "unable to grab threaded IRQ %d, disabling device\n", in skl_dsp_acquire_irq()
443 sst->irq); in skl_dsp_acquire_irq()
448 void skl_dsp_free(struct sst_dsp *dsp) in skl_dsp_free() argument
450 skl_ipc_int_disable(dsp); in skl_dsp_free()
452 free_irq(dsp->irq, dsp); in skl_dsp_free()
453 skl_ipc_op_int_disable(dsp); in skl_dsp_free()
454 skl_dsp_disable_core(dsp, SKL_DSP_CORE0_MASK); in skl_dsp_free()
460 return (ctx->sst_state == SKL_DSP_RUNNING); in is_skl_dsp_running()