TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
mbox_tt_grendel.c File Reference

Driver for Tenstorrent Grendel SMC Mailbox. More...

#include <zephyr/device.h>
#include <zephyr/drivers/mbox.h>
#include <zephyr/irq.h>
#include <zephyr/logging/log.h>
#include "platform.h"
Include dependency graph for mbox_tt_grendel.c:

Data Structures

struct  tt_grendel_mbox_config
struct  tt_grendel_mbox_data

Macros

#define DT_DRV_COMPAT   tenstorrent_grendel_mbox
#define MBOX_CHANNEL_STRIDE   0x800
#define TT_GRENDEL_MBOX_MSG_MAX_SIZE   8
#define MBOX_WRITE_DATA_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_WRITE_DATA_REG_OFFSET
#define MBOX_READ_DATA_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_READ_DATA_REG_OFFSET
#define MBOX_STATUS_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_STATUS_REG_OFFSET
#define MBOX_IRQEN_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_IRQEN_REG_OFFSET
#define MBOX_IRQP_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_IRQP_REG_OFFSET
#define MBOX_IRQS_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_IRQS_REG_OFFSET
#define MBOX_WIRQT_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_WIRQT_REG_OFFSET
#define MBOX_RIRQT_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_RIRQT_REG_OFFSET
#define MBOX_BASE(cfg, channel)
 Test class.
#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_DEFINE(channel_id, _)
#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_CONNECT(channel_id, inst)
#define TT_GRENDEL_MBOX_DEFINE(inst)

Functions

 LOG_MODULE_REGISTER (mbox_tt_grendel, CONFIG_MBOX_LOG_LEVEL)
static int tt_grendel_mbox_mtu_get (const struct device *dev)
static uint32_t tt_grendel_mbox_max_channels_get (const struct device *dev)
static int tt_grendel_mbox_register_callback (const struct device *dev, mbox_channel_id_t channel_id, mbox_callback_t cb, void *user_data)
static int tt_grendel_mbox_send (const struct device *dev, mbox_channel_id_t channel_id, const struct mbox_msg *msg)
static int tt_grendel_mbox_set_enabled (const struct device *dev, mbox_channel_id_t channel_id, bool enabled)
static int tt_grendel_mbox_init (const struct device *dev)
static void tt_grendel_mbox_isr (const struct device *dev, mbox_channel_id_t channel_id)

Variables

static const struct mbox_driver_api tt_grendel_mbox_api

Detailed Description

Driver for Tenstorrent Grendel SMC Mailbox.

MBOX IP Design Overview

dot_inline_dotgraph_1.png

Messaging Protocol

  • To message the SMC core: write to the outbound mailbox channels (even channel numbers)
  • To message other system components: write to the inbound mailbox channels (odd channel numbers)
  • To listen for a message within the SMC core: listen for interrupts on the inbound mailbox channels
  • To listen for a message within other system components: listen for interrupts on the outbound mailbox channels (not supported by this driver)

Interrupt Handling

The SMC only has inbound mailbox interrupts connected, so in order to message the SMC core a message must be written to the outbound mailbox. This can be done using this driver or from a remote host writing to the SMC's outbound mailbox registers directly.

Outbound MBOX interrupts would be routed to other system components (such as Ascalon) rather than the SMC core, and would be triggered by writing to an inbound mailbox channel.

Macro Definition Documentation

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   tenstorrent_grendel_mbox

◆ MBOX_BASE

#define MBOX_BASE ( cfg,
channel )
Value:
(cfg->base_addr + (channel * MBOX_CHANNEL_STRIDE))
#define MBOX_CHANNEL_STRIDE
Definition mbox_tt_grendel.c:72

Test class.

dot_inline_dotgraph_2.png

◆ MBOX_CHANNEL_STRIDE

#define MBOX_CHANNEL_STRIDE   0x800

◆ MBOX_IRQEN_REG_OFFSET

#define MBOX_IRQEN_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_IRQEN_REG_OFFSET

◆ MBOX_IRQP_REG_OFFSET

#define MBOX_IRQP_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_IRQP_REG_OFFSET

◆ MBOX_IRQS_REG_OFFSET

#define MBOX_IRQS_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_IRQS_REG_OFFSET

◆ MBOX_READ_DATA_REG_OFFSET

#define MBOX_READ_DATA_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_READ_DATA_REG_OFFSET

◆ MBOX_RIRQT_REG_OFFSET

#define MBOX_RIRQT_REG_OFFSET   SMC_CPU_SMC_INBOUND_MAILBOX_0_RIRQT_REG_OFFSET

◆ MBOX_STATUS_REG_OFFSET

#define MBOX_STATUS_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_STATUS_REG_OFFSET

◆ MBOX_WIRQT_REG_OFFSET

#define MBOX_WIRQT_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_WIRQT_REG_OFFSET

◆ MBOX_WRITE_DATA_REG_OFFSET

#define MBOX_WRITE_DATA_REG_OFFSET   SMC_CPU_SMC_OUTBOUND_MAILBOX_0_WRITE_DATA_REG_OFFSET

◆ TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_CONNECT

#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_CONNECT ( channel_id,
inst )
Value:
IRQ_CONNECT(DT_INST_IRQN_BY_IDX(inst, channel_id), \
DT_INST_IRQ_BY_IDX(inst, channel_id, priority), \
tt_grendel_mbox_isr_##channel_id, DEVICE_DT_INST_GET(inst), 0); \
irq_enable(DT_INST_IRQN_BY_IDX(inst, channel_id));
#define DEVICE_DT_INST_GET(inst)
#define DT_INST_IRQ_BY_IDX(inst, idx, cell)
#define DT_INST_IRQN_BY_IDX(inst, idx)
#define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)

◆ TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_DEFINE

#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_DEFINE ( channel_id,
_ )
Value:
static void tt_grendel_mbox_isr_##channel_id(const struct device *dev) \
{ \
/* Interrupts only fire on inbound channel IDs */ \
tt_grendel_mbox_isr(dev, (channel_id * 2) + 1); \
}

◆ TT_GRENDEL_MBOX_DEFINE

#define TT_GRENDEL_MBOX_DEFINE ( inst)
Value:
LISTIFY(DT_INST_PROP(inst, channel_pairs), \
(;)) \
\
static void tt_grendel_mbox_irq_config_func_##inst(const struct device *dev) \
{ \
ARG_UNUSED(dev); \
LISTIFY(DT_INST_PROP(inst, channel_pairs), \
} \
\
static const struct tt_grendel_mbox_config tt_grendel_mbox_config_##inst = { \
.irq_config_func = tt_grendel_mbox_irq_config_func_##inst, \
.channel_pairs = DT_INST_PROP(inst, channel_pairs), \
}; \
\
static mbox_callback_t \
tt_grendel_mbox_callbacks_##inst[DT_INST_PROP(inst, channel_pairs)]; \
static void *tt_grendel_mbox_callback_user_data_##inst[DT_INST_PROP(inst, channel_pairs)]; \
\
static struct tt_grendel_mbox_data tt_grendel_mbox_data_##inst = { \
.callbacks = tt_grendel_mbox_callbacks_##inst, \
.callback_user_data = tt_grendel_mbox_callback_user_data_##inst, \
}; \
\
DEVICE_DT_INST_DEFINE(inst, tt_grendel_mbox_init, NULL, &tt_grendel_mbox_data_##inst, \
&tt_grendel_mbox_config_##inst, POST_KERNEL, \
CONFIG_MBOX_INIT_PRIORITY, &tt_grendel_mbox_api);
#define NULL
Definition avs.c:45
#define DT_INST_PROP(inst, prop)
#define DT_INST_REG_ADDR(inst)
#define LISTIFY(LEN, F, sep,...)
static const struct mbox_driver_api tt_grendel_mbox_api
Definition mbox_tt_grendel.c:214
static int tt_grendel_mbox_init(const struct device *dev)
Definition mbox_tt_grendel.c:222
#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_DEFINE(channel_id, _)
Definition mbox_tt_grendel.c:284
#define TT_GRENDEL_MBOX_CHANNEL_IRQ_HANDLER_CONNECT(channel_id, inst)
Definition mbox_tt_grendel.c:291
Definition mbox_tt_grendel.c:118
uint32_t base_addr
Definition mbox_tt_grendel.c:120

◆ TT_GRENDEL_MBOX_MSG_MAX_SIZE

#define TT_GRENDEL_MBOX_MSG_MAX_SIZE   8

Function Documentation

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mbox_tt_grendel ,
CONFIG_MBOX_LOG_LEVEL  )

◆ tt_grendel_mbox_init()

int tt_grendel_mbox_init ( const struct device * dev)
static

◆ tt_grendel_mbox_isr()

void tt_grendel_mbox_isr ( const struct device * dev,
mbox_channel_id_t channel_id )
static

◆ tt_grendel_mbox_max_channels_get()

uint32_t tt_grendel_mbox_max_channels_get ( const struct device * dev)
static

◆ tt_grendel_mbox_mtu_get()

int tt_grendel_mbox_mtu_get ( const struct device * dev)
static

◆ tt_grendel_mbox_register_callback()

int tt_grendel_mbox_register_callback ( const struct device * dev,
mbox_channel_id_t channel_id,
mbox_callback_t cb,
void * user_data )
static

◆ tt_grendel_mbox_send()

int tt_grendel_mbox_send ( const struct device * dev,
mbox_channel_id_t channel_id,
const struct mbox_msg * msg )
static

◆ tt_grendel_mbox_set_enabled()

int tt_grendel_mbox_set_enabled ( const struct device * dev,
mbox_channel_id_t channel_id,
bool enabled )
static

Variable Documentation

◆ tt_grendel_mbox_api

const struct mbox_driver_api tt_grendel_mbox_api
static
Initial value:
= {
.max_channels_get = tt_grendel_mbox_max_channels_get,
.register_callback = tt_grendel_mbox_register_callback,
}
static uint32_t tt_grendel_mbox_max_channels_get(const struct device *dev)
Definition mbox_tt_grendel.c:134
static int tt_grendel_mbox_mtu_get(const struct device *dev)
Definition mbox_tt_grendel.c:129
static int tt_grendel_mbox_set_enabled(const struct device *dev, mbox_channel_id_t channel_id, bool enabled)
Definition mbox_tt_grendel.c:193
static int tt_grendel_mbox_send(const struct device *dev, mbox_channel_id_t channel_id, const struct mbox_msg *msg)
Definition mbox_tt_grendel.c:157
static int tt_grendel_mbox_register_callback(const struct device *dev, mbox_channel_id_t channel_id, mbox_callback_t cb, void *user_data)
Definition mbox_tt_grendel.c:141