2022-05-16 18:47:07 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2019-04-13 00:05:12 +08:00
|
|
|
//
|
2022-05-16 18:47:07 +08:00
|
|
|
// Copyright(c) 2022 Intel Corporation. All rights reserved.
|
2019-04-13 00:05:12 +08:00
|
|
|
|
|
|
|
#include "sof-priv.h"
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
int sof_fw_trace_init(struct snd_sof_dev *sdev)
|
2019-05-25 03:23:06 +08:00
|
|
|
{
|
2022-12-21 18:23:27 +08:00
|
|
|
const struct sof_ipc_fw_tracing_ops *fw_tracing = sof_ipc_get_ops(sdev, fw_tracing);
|
|
|
|
|
|
|
|
if (!fw_tracing) {
|
2022-05-16 18:47:07 +08:00
|
|
|
dev_info(sdev->dev, "Firmware tracing is not available\n");
|
2022-05-16 18:47:05 +08:00
|
|
|
sdev->fw_trace_is_supported = false;
|
2022-05-06 21:02:29 +08:00
|
|
|
|
2019-09-28 04:05:28 +08:00
|
|
|
return 0;
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|
|
|
|
|
2022-12-21 18:23:27 +08:00
|
|
|
return fw_tracing->init(sdev);
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
void sof_fw_trace_free(struct snd_sof_dev *sdev)
|
2019-04-13 00:05:12 +08:00
|
|
|
{
|
2022-12-21 18:23:28 +08:00
|
|
|
if (!sdev->fw_trace_is_supported)
|
2022-05-16 18:47:07 +08:00
|
|
|
return;
|
2019-04-13 00:05:12 +08:00
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
if (sdev->ipc->ops->fw_tracing->free)
|
|
|
|
sdev->ipc->ops->fw_tracing->free(sdev);
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
void sof_fw_trace_fw_crashed(struct snd_sof_dev *sdev)
|
2019-04-13 00:05:12 +08:00
|
|
|
{
|
2022-05-16 18:47:05 +08:00
|
|
|
if (!sdev->fw_trace_is_supported)
|
2019-09-28 04:05:28 +08:00
|
|
|
return;
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
if (sdev->ipc->ops->fw_tracing->fw_crashed)
|
|
|
|
sdev->ipc->ops->fw_tracing->fw_crashed(sdev);
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
void sof_fw_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state)
|
2019-04-13 00:05:12 +08:00
|
|
|
{
|
2022-05-16 18:47:07 +08:00
|
|
|
if (!sdev->fw_trace_is_supported)
|
2019-04-13 00:05:12 +08:00
|
|
|
return;
|
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
sdev->ipc->ops->fw_tracing->suspend(sdev, pm_state);
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|
2022-03-31 04:19:21 +08:00
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
int sof_fw_trace_resume(struct snd_sof_dev *sdev)
|
2019-04-13 00:05:12 +08:00
|
|
|
{
|
2022-05-16 18:47:05 +08:00
|
|
|
if (!sdev->fw_trace_is_supported)
|
2022-05-16 18:47:07 +08:00
|
|
|
return 0;
|
2019-04-13 00:05:12 +08:00
|
|
|
|
2022-05-16 18:47:07 +08:00
|
|
|
return sdev->ipc->ops->fw_tracing->resume(sdev);
|
2019-04-13 00:05:12 +08:00
|
|
|
}
|