Files
linux-nv-oot/drivers/platform/tegra/dce/dce-ipc-signal.c
Mahesh Kumar 9a401f8077 platform: dce: Halify HSP functions
This patch Halify HSP access functions. SOC-specific HSP functions
are assigned during driver prob based on of_device_is_compatible check.

Jira TDS-15438

Change-Id: Ia8d68cd658eaa06dd5d06e8ba92f32907a31fd4f
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3225858
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2025-07-24 10:19:09 +00:00

151 lines
3.6 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved.
*/
#include <dce.h>
#include <dce-ipc.h>
#include <dce-util-common.h>
#include <interface/dce-interface.h>
static struct dce_ipc_signal_instance *mb_signals[DCE_NUM_MBOX_REGS];
static void dce_ipc_mbox_notify(struct tegra_dce *d,
struct dce_ipc_signal_instance *s)
{
if (s == NULL) {
dce_info(d, "Invalid signal instance for notification");
return;
}
if (s->sema_num < DCE_NUM_SEMA_REGS)
d->hsp.ss_set(d, s->sema_bit, d->hsp_id, s->sema_num);
dce_mailbox_set_full_interrupt(d, s->form.mbox.mb_type);
}
static void dce_ipc_mbox_handle_signal(struct tegra_dce *d, void *data)
{
u32 sema_val;
struct dce_ipc_channel *ch;
struct dce_ipc_signal_instance *s;
struct dce_ipc_signal_instance *cur_s;
s = (struct dce_ipc_signal_instance *)data;
if ((s == NULL) || (s->signal == NULL) ||
(s->signal->ch == NULL) ||
(s->form.mbox.mb_num > DCE_NUM_MBOX_REGS)) {
dce_err(d, "Invalid signal instance in mailbox callback");
return;
}
for (cur_s = s; cur_s != NULL; cur_s = cur_s->next) {
if (cur_s->sema_num < DCE_NUM_SEMA_REGS) {
sema_val = d->hsp.ss_get_state(d, d->hsp_id, cur_s->sema_num);
if ((sema_val & BIT(cur_s->sema_bit)) == 0)
continue;
}
d->hsp.ss_clear(d, cur_s->sema_num, d->hsp_id, BIT(cur_s->sema_bit));
ch = cur_s->signal->ch;
dce_admin_ipc_handle_signal(d, ch->ch_type);
}
}
/**
* Lock is acquired in dce-ipc before calling this API.
* Shouldn't be called from anywhere else.
*/
int dce_ipc_init_signaling(struct tegra_dce *d, struct dce_ipc_channel *ch)
{
u8 mb_type;
u32 to_mbox;
u32 from_mbox;
int ret = 0;
struct dce_ipc_signal_instance *temp_s;
struct dce_ipc_signal_instance *to_d = &ch->signal.to_d;
struct dce_ipc_signal_instance *from_d = &ch->signal.from_d;
ch->signal.ch = ch;
if ((from_d == NULL) || (to_d == NULL)) {
dce_err(d, "Invalid signal instances");
ret = -1;
goto out;
}
mb_type = to_d->form.mbox.mb_type;
if (to_d->form.mbox.mb_type !=
from_d->form.mbox.mb_type) {
dce_err(d, "Mailbox type doesn't match");
ret = -1;
goto out;
}
to_mbox = to_d->form.mbox.mb_num;
from_mbox = from_d->form.mbox.mb_num;
to_d->signal = &ch->signal;
if (to_d->type == DCE_IPC_SIGNAL_MAILBOX) {
to_d->signal->notify = dce_ipc_mbox_notify;
mb_signals[to_mbox] = to_d;
} else {
dce_info(d, "Signal type not supported : [%d]", to_d->type);
}
from_d->signal = &ch->signal;
if (from_d->type == DCE_IPC_SIGNAL_MAILBOX) {
if ((from_d->next != NULL)
|| (from_mbox >= DCE_NUM_MBOX_REGS)) {
dce_err(d, "Invalid Signal Instance");
ret = -1;
goto out;
}
temp_s = mb_signals[from_mbox];
if (temp_s != NULL)
from_d->next = temp_s;
mb_signals[from_d->form.mbox.mb_num] = from_d;
} else {
dce_info(d, "Signal type not supported : [%d]", from_d->type);
}
/**
* TODO : Call this API on a conditional basis.
*/
ret = dce_mailbox_init_interface(d, mb_type,
to_mbox, from_mbox, NULL, (void *)from_d,
dce_ipc_mbox_handle_signal);
out:
return ret;
}
/**
* Lock is acquired in dce-ipc before calling this API.
* Shouldn't be called from anywhere else.
*/
void dce_ipc_deinit_signaling(struct tegra_dce *d, struct dce_ipc_channel *ch)
{
u8 mb_type;
struct dce_ipc_signal_instance *to_d = &ch->signal.to_d;
struct dce_ipc_signal_instance *from_d = &ch->signal.from_d;
/**
* TODO : Nullify other signal parameters as well.
*/
mb_type = to_d->form.mbox.mb_type;
if (to_d->form.mbox.mb_type !=
from_d->form.mbox.mb_type) {
dce_err(d, "Mailbox type doesn't match");
return;
}
dce_mailbox_deinit_interface(d, mb_type);
ch->signal.ch = NULL;
}