TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
dma_tt_bh_noc.c File Reference
#include <zephyr/device.h>
#include <zephyr/drivers/dma.h>
#include <zephyr/drivers/dma/dma_tt_bh_noc.h>
#include <zephyr/irq.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/sys_io.h>
#include <zephyr/kernel.h>
#include <string.h>
#include "noc_init.h"
#include "noc2axi.h"
#include "util.h"
Include dependency graph for dma_tt_bh_noc.c:

Data Structures

struct  tt_bh_dma_channel_resettable_data
struct  tt_bh_dma_channel_data
struct  tt_bh_dma_noc_config
struct  tt_bh_dma_noc_data

Macros

#define DT_DRV_COMPAT   tenstorrent_noc_dma
#define NOC_DMA_TLB   0
#define NOC_DMA_NOC_ID   0
#define NOC_DMA_TIMEOUT_MS   50
#define NOC_MAX_BURST_SIZE   16384
#define DMA_MAX_TRANSFER_BLOCKS   4
#define NOC_CMD_CPY   (0 << 0)
#define NOC_CMD_RD   (0 << 1)
#define NOC_CMD_WR   (1 << 1)
#define NOC_CMD_RESP_MARKED   (1 << 4)
#define NOC_CMD_BRCST_PACKET   (1 << 5)
#define NOC_CMD_PATH_RESERVE   (1 << 8)
#define NOC_CMD_BRCST_SRC_INCLUDE   (1 << 17)
#define TARGET_ADDR_LO   0xFFB20000
#define TARGET_ADDR_MID   0xFFB20004
#define TARGET_ADDR_HI   0xFFB20008
#define RET_ADDR_LO   0xFFB2000C
#define RET_ADDR_MID   0xFFB20010
#define RET_ADDR_HI   0xFFB20014
#define PACKET_TAG   0xFFB20018
#define CMD_BRCST   0xFFB2001C
#define AT_LEN   0xFFB20020
#define AT_LEN_1   0xFFB20024
#define AT_DATA   0xFFB20028
#define BRCST_EXCLUDE   0xFFB2002C
#define CMD_CTRL   0xFFB20040
#define NIU_MST_WR_ACK_RECEIVED   0xFFB20204
#define NIU_MST_RD_RESP_RECEIVED   0xFFB20208
#define DMA_CHANNEL_INVALID   0xFFFFFFFF
#define TT_BH_DMA_NOC_INIT(inst)

Functions

 LOG_MODULE_REGISTER (dma_noc_tt_bh, CONFIG_DMA_LOG_LEVEL)
static bool noc_wait_cmd_ready (void)
static uint32_t get_expected_acks (uint32_t noc_cmd, uint64_t size)
static bool is_behind (uint32_t current, uint32_t target)
static uint32_t noc_coord_encode (uint32_t x, uint32_t y)
static uint32_t noc_coord_encode_range (uint32_t start_x, uint32_t start_y, uint32_t end_x, uint32_t end_y)
static void handle_transfer_callbacks (const struct device *dev, struct tt_bh_dma_channel_data *chan_data, uint32_t channel, int transfer_ret, bool is_final_block)
static int noc_dma_transfer (uint32_t cmd, uint32_t ret_coord, uint64_t ret_addr, uint32_t targ_coord, uint64_t targ_addr, uint32_t size, bool multicast, uint8_t transaction_id, bool include_self, uint32_t *noc_cmd_out, uint32_t *expected_acks_out)
static int tt_bh_dma_noc_config (const struct device *dev, uint32_t channel, struct dma_config *config)
static int noc_dma_write_multicast (uint8_t local_x, uint8_t local_y, uint64_t local_addr, uint8_t remote_start_x, uint8_t remote_start_y, uint8_t remote_end_x, uint8_t remote_end_y, uint64_t remote_addr, uint32_t size, bool include_self, uint32_t *noc_cmd_out, uint32_t *expected_acks_out)
static int tt_bh_dma_noc_start_mem_to_per (const struct device *dev, uint32_t channel)
static int tt_bh_dma_noc_start_per_to_mem (const struct device *dev, uint32_t channel)
static int tt_bh_dma_noc_start (const struct device *dev, uint32_t channel)
static int tt_bh_dma_noc_init (const struct device *dev)
static int tt_bh_dma_noc_get_status (const struct device *dev, uint32_t channel, struct dma_status *status)
static int tt_bh_dma_noc_stop (const struct device *dev, uint32_t channel)

Variables

static const struct dma_driver_api tt_bh_dma_noc_api

Macro Definition Documentation

◆ AT_DATA

#define AT_DATA   0xFFB20028

◆ AT_LEN

#define AT_LEN   0xFFB20020

◆ AT_LEN_1

#define AT_LEN_1   0xFFB20024

◆ BRCST_EXCLUDE

#define BRCST_EXCLUDE   0xFFB2002C

◆ CMD_BRCST

#define CMD_BRCST   0xFFB2001C

◆ CMD_CTRL

#define CMD_CTRL   0xFFB20040

◆ DMA_CHANNEL_INVALID

#define DMA_CHANNEL_INVALID   0xFFFFFFFF

◆ DMA_MAX_TRANSFER_BLOCKS

#define DMA_MAX_TRANSFER_BLOCKS   4

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   tenstorrent_noc_dma

◆ NIU_MST_RD_RESP_RECEIVED

#define NIU_MST_RD_RESP_RECEIVED   0xFFB20208

◆ NIU_MST_WR_ACK_RECEIVED

#define NIU_MST_WR_ACK_RECEIVED   0xFFB20204

◆ NOC_CMD_BRCST_PACKET

#define NOC_CMD_BRCST_PACKET   (1 << 5)

◆ NOC_CMD_BRCST_SRC_INCLUDE

#define NOC_CMD_BRCST_SRC_INCLUDE   (1 << 17)

◆ NOC_CMD_CPY

#define NOC_CMD_CPY   (0 << 0)

◆ NOC_CMD_PATH_RESERVE

#define NOC_CMD_PATH_RESERVE   (1 << 8)

◆ NOC_CMD_RD

#define NOC_CMD_RD   (0 << 1)

◆ NOC_CMD_RESP_MARKED

#define NOC_CMD_RESP_MARKED   (1 << 4)

◆ NOC_CMD_WR

#define NOC_CMD_WR   (1 << 1)

◆ NOC_DMA_NOC_ID

#define NOC_DMA_NOC_ID   0

◆ NOC_DMA_TIMEOUT_MS

#define NOC_DMA_TIMEOUT_MS   50

◆ NOC_DMA_TLB

#define NOC_DMA_TLB   0

◆ NOC_MAX_BURST_SIZE

#define NOC_MAX_BURST_SIZE   16384

◆ PACKET_TAG

#define PACKET_TAG   0xFFB20018

◆ RET_ADDR_HI

#define RET_ADDR_HI   0xFFB20014

◆ RET_ADDR_LO

#define RET_ADDR_LO   0xFFB2000C

◆ RET_ADDR_MID

#define RET_ADDR_MID   0xFFB20010

◆ TARGET_ADDR_HI

#define TARGET_ADDR_HI   0xFFB20008

◆ TARGET_ADDR_LO

#define TARGET_ADDR_LO   0xFFB20000

◆ TARGET_ADDR_MID

#define TARGET_ADDR_MID   0xFFB20004

◆ TT_BH_DMA_NOC_INIT

#define TT_BH_DMA_NOC_INIT ( inst)
Value:
static struct tt_bh_dma_channel_data \
tt_bh_dma_noc_channels_##inst[DT_INST_PROP(inst, dma_channels)]; \
\
static const struct tt_bh_dma_noc_config noc_dma_config_##inst = { \
.channels = tt_bh_dma_noc_channels_##inst, \
.num_channels = DT_INST_PROP(inst, dma_channels), \
}; \
\
static struct tt_bh_dma_noc_data noc_dma_data_##inst = {}; \
\
DEVICE_DT_INST_DEFINE(inst, &tt_bh_dma_noc_init, NULL, &noc_dma_data_##inst, \
&noc_dma_config_##inst, POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, \
#define NULL
Definition avs.c:45
static const struct dma_driver_api tt_bh_dma_noc_api
Definition dma_tt_bh_noc.c:520
static int tt_bh_dma_noc_init(const struct device *dev)
Definition dma_tt_bh_noc.c:488
#define DT_INST_PROP(inst, prop)
Definition dma_tt_bh_noc.c:69
Definition dma_tt_bh_noc.c:79
uint8_t num_channels
Definition dma_tt_bh_noc.c:84
Definition dma_tt_bh_noc.c:90

Function Documentation

◆ get_expected_acks()

uint32_t get_expected_acks ( uint32_t noc_cmd,
uint64_t size )
static

◆ handle_transfer_callbacks()

void handle_transfer_callbacks ( const struct device * dev,
struct tt_bh_dma_channel_data * chan_data,
uint32_t channel,
int transfer_ret,
bool is_final_block )
static

◆ is_behind()

bool is_behind ( uint32_t current,
uint32_t target )
inlinestatic

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( dma_noc_tt_bh ,
CONFIG_DMA_LOG_LEVEL  )

◆ noc_coord_encode()

uint32_t noc_coord_encode ( uint32_t x,
uint32_t y )
inlinestatic

◆ noc_coord_encode_range()

uint32_t noc_coord_encode_range ( uint32_t start_x,
uint32_t start_y,
uint32_t end_x,
uint32_t end_y )
inlinestatic

◆ noc_dma_transfer()

int noc_dma_transfer ( uint32_t cmd,
uint32_t ret_coord,
uint64_t ret_addr,
uint32_t targ_coord,
uint64_t targ_addr,
uint32_t size,
bool multicast,
uint8_t transaction_id,
bool include_self,
uint32_t * noc_cmd_out,
uint32_t * expected_acks_out )
static

◆ noc_dma_write_multicast()

int noc_dma_write_multicast ( uint8_t local_x,
uint8_t local_y,
uint64_t local_addr,
uint8_t remote_start_x,
uint8_t remote_start_y,
uint8_t remote_end_x,
uint8_t remote_end_y,
uint64_t remote_addr,
uint32_t size,
bool include_self,
uint32_t * noc_cmd_out,
uint32_t * expected_acks_out )
static

◆ noc_wait_cmd_ready()

bool noc_wait_cmd_ready ( void )
static

◆ tt_bh_dma_noc_config()

int tt_bh_dma_noc_config ( const struct device * dev,
uint32_t channel,
struct dma_config * config )
static

◆ tt_bh_dma_noc_get_status()

int tt_bh_dma_noc_get_status ( const struct device * dev,
uint32_t channel,
struct dma_status * status )
static

◆ tt_bh_dma_noc_init()

int tt_bh_dma_noc_init ( const struct device * dev)
static

◆ tt_bh_dma_noc_start()

int tt_bh_dma_noc_start ( const struct device * dev,
uint32_t channel )
static

◆ tt_bh_dma_noc_start_mem_to_per()

int tt_bh_dma_noc_start_mem_to_per ( const struct device * dev,
uint32_t channel )
static

◆ tt_bh_dma_noc_start_per_to_mem()

int tt_bh_dma_noc_start_per_to_mem ( const struct device * dev,
uint32_t channel )
static

◆ tt_bh_dma_noc_stop()

int tt_bh_dma_noc_stop ( const struct device * dev,
uint32_t channel )
static

Variable Documentation

◆ tt_bh_dma_noc_api

const struct dma_driver_api tt_bh_dma_noc_api
static
Initial value:
= {
.reload = NULL,
.suspend = NULL,
.resume = NULL,
.get_status = tt_bh_dma_noc_get_status,
.get_attribute = NULL,
.chan_filter = NULL,
.chan_release = NULL,
}
static int tt_bh_dma_noc_get_status(const struct device *dev, uint32_t channel, struct dma_status *status)
Definition dma_tt_bh_noc.c:493
static int tt_bh_dma_noc_stop(const struct device *dev, uint32_t channel)
Definition dma_tt_bh_noc.c:515
static int tt_bh_dma_noc_start(const struct device *dev, uint32_t channel)
Definition dma_tt_bh_noc.c:357