TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
jtag_bitbang.c File Reference
#include "axi.h"
#include "jtag_profile_functions.h"
#include "tenstorrent/bitrev.h"
#include "jtag_priv.h"
#include <stdint.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/jtag.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/util.h>
Include dependency graph for jtag_bitbang.c:

Data Structures

struct  jtag_instr_t
union  jtag_instr_u

Macros

#define DT_DRV_COMPAT   zephyr_jtag_gpio
#define MST_TAP_OP_ISCAN_SEL   (2)
#define MST_TAP_OP_DEVID_SEL   (6)
#define TENSIX_SM_RTAP   (0x19e)
#define TENSIX_SM_SIBLEN   (4)
#define TENSIX_SM_TDRLEN   (32)
#define TENSIX_SIBLEN_PLUS_1_OR_0   ((TENSIX_SM_SIBLEN > 0) ? (TENSIX_SM_SIBLEN + 1) : 0)
#define TENSIX_TDRLEN_SIBLEN_PLUS_1   (1 + TENSIX_SM_TDRLEN + TENSIX_SM_SIBLEN)
#define SIBSHIFT(x)
#define SIBSHIFTUP(x)
#define INSTR_REG_BISTEN_SEL_END_0   (9)
#define INSTR_REG_BISTEN_SEL_START_0   (7)
#define INSTR_REG_BISTEN_SEL_MASK_0   (7)
#define INSTR_REG_BISTEN_SEL_MASK_1   (0x3f)
#define IF_TDI(config, stmt)
#define JTAG_BB_GPIOS_GET_REG(n, gpios)
#define JTAG_BB_DEVICE_DEFINE(n)

Functions

 LOG_MODULE_REGISTER (jtag_bitbang, CONFIG_JTAG_LOG_LEVEL)
static void SET_TCK (const struct jtag_config *config)
static void CLR_TCK (const struct jtag_config *config)
static void SET_TDI (const struct jtag_config *config)
static void CLR_TDI (const struct jtag_config *config)
static bool GET_TDO (const struct jtag_config *config)
static void SET_TMS (const struct jtag_config *config)
static void CLR_TMS (const struct jtag_config *config)
static ALWAYS_INLINE void jtag_bitbang_tick (const struct device *dev, uint32_t count)
int jtag_bitbang_reset (const struct device *dev)
static ALWAYS_INLINE void jtag_bitbang_update_ir (const struct device *dev, uint32_t count, uint64_t data)
static ALWAYS_INLINE uint64_t jtag_bitbang_xfer_dr (const struct device *dev, uint32_t count, uint64_t data_in, bool idle, bool capture)
static ALWAYS_INLINE uint64_t jtag_bitbang_capture_dr_idle (const struct device *dev, uint32_t count, uint64_t data_in)
static ALWAYS_INLINE uint64_t jtag_bitbang_capture_dr (const struct device *dev, uint32_t count, uint64_t data_in)
static ALWAYS_INLINE void jtag_bitbang_update_dr_idle (const struct device *dev, uint32_t count, uint64_t data_in)
static ALWAYS_INLINE void jtag_bitbang_update_dr (const struct device *dev, uint32_t count, uint64_t data_in)
int jtag_bitbang_read_id (const struct device *dev, uint32_t *id)
int jtag_bitbang_setup (const struct device *dev)
static int jtag_bitbang_teardown (const struct device *dev)
static ALWAYS_INLINE void jtag_setup_access (const struct device *dev, uint32_t rtap_addr)
static ALWAYS_INLINE uint32_t jtag_access_rtap_tdr_idle (const struct device *dev, uint32_t rtap_addr, uint32_t tdr_addr, uint32_t wrdata)
static ALWAYS_INLINE uint32_t jtag_access_rtap_tdr (const struct device *dev, uint32_t rtap_addr, uint32_t tdr_addr, uint32_t wrdata)
static ALWAYS_INLINE void jtag_wr_tensix_sm_rtap_tdr_idle (const struct device *dev, uint32_t tdr_addr, uint32_t wrvalue)
static ALWAYS_INLINE void jtag_wr_tensix_sm_rtap_tdr (const struct device *dev, uint32_t tdr_addr, uint32_t wrvalue)
static ALWAYS_INLINE uint32_t jtag_rd_tensix_sm_rtap_tdr_idle (const struct device *dev, uint32_t tdr_addr)
static ALWAYS_INLINE uint32_t jtag_rd_tensix_sm_rtap_tdr (const struct device *dev, uint32_t tdr_addr)
void jtag_req_clear (const struct device *dev)
int jtag_axiread (const struct device *dev, uint32_t addr, uint32_t *result)
int jtag_axiwrite (const struct device *dev, uint32_t addr, uint32_t value)
int jtag_axi_blockwrite (const struct device *dev, uint32_t addr, const uint32_t *value, uint32_t len)
static int jtag_bitbang_init (const struct device *dev)

Variables

static struct jtag_api jtag_bitbang_api

Macro Definition Documentation

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   zephyr_jtag_gpio

◆ IF_TDI

#define IF_TDI ( config,
stmt )
Value:
do { \
if (stmt) { \
SET_TDI(config); \
} else { \
CLR_TDI(config); \
} \
} while (0)

◆ INSTR_REG_BISTEN_SEL_END_0

#define INSTR_REG_BISTEN_SEL_END_0   (9)

◆ INSTR_REG_BISTEN_SEL_MASK_0

#define INSTR_REG_BISTEN_SEL_MASK_0   (7)

◆ INSTR_REG_BISTEN_SEL_MASK_1

#define INSTR_REG_BISTEN_SEL_MASK_1   (0x3f)

◆ INSTR_REG_BISTEN_SEL_START_0

#define INSTR_REG_BISTEN_SEL_START_0   (7)

◆ JTAG_BB_DEVICE_DEFINE

#define JTAG_BB_DEVICE_DEFINE ( n)
Value:
static const struct jtag_config jtag_bitbang_config_##n = { \
.tck = GPIO_DT_SPEC_INST_GET(n, tck_gpios), \
.tdi = GPIO_DT_SPEC_INST_GET(n, tdi_gpios), \
.tdo = GPIO_DT_SPEC_INST_GET(n, tdo_gpios), \
.tms = GPIO_DT_SPEC_INST_GET(n, tms_gpios), \
.trst = GPIO_DT_SPEC_INST_GET_OR(n, trst_gpios, {0}), \
COND_CODE_1(CONFIG_JTAG_USE_MMAPPED_IO, \
(.tck_reg = JTAG_BB_GPIOS_GET_REG(n, tck_gpios), \
.tdi_reg = JTAG_BB_GPIOS_GET_REG(n, tdi_gpios), \
.tdo_reg = JTAG_BB_GPIOS_GET_REG(n, tdo_gpios), \
.tms_reg = JTAG_BB_GPIOS_GET_REG(n, tms_gpios), \
.port_write_cycles = DT_INST_PROP(n, port_write_cycles), \
), \
())}; \
\
static struct jtag_data jtag_bitbang_data_##n; \
\
DEVICE_DT_INST_DEFINE(n, jtag_bitbang_init, NULL, &jtag_bitbang_data_##n, \
&jtag_bitbang_config_##n, POST_KERNEL, CONFIG_JTAG_INIT_PRIO, \
#define NULL
Definition avs.c:45
#define DT_INST_PROP(inst, prop)
#define GPIO_DT_SPEC_INST_GET(inst, prop)
#define GPIO_DT_SPEC_INST_GET_OR(inst, prop, default_value)
#define COND_CODE_1(_flag, _if_1_code, _else_code)
static int jtag_bitbang_init(const struct device *dev)
Definition jtag_bitbang.c:496
static struct jtag_api jtag_bitbang_api
Definition jtag_bitbang.c:488
#define JTAG_BB_GPIOS_GET_REG(n, gpios)
Definition jtag_bitbang.c:501
Definition jtag_priv.h:58

◆ JTAG_BB_GPIOS_GET_REG

#define JTAG_BB_GPIOS_GET_REG ( n,
gpios )
Value:
#define DT_PHANDLE(node_id, prop)
#define DT_DRV_INST(inst)
#define DT_INST_NODE_HAS_PROP(inst, prop)
#define DT_REG_ADDR(node_id)
#define INT_TO_POINTER(x)

◆ MST_TAP_OP_DEVID_SEL

#define MST_TAP_OP_DEVID_SEL   (6)

◆ MST_TAP_OP_ISCAN_SEL

#define MST_TAP_OP_ISCAN_SEL   (2)

◆ SIBSHIFT

#define SIBSHIFT ( x)
Value:
#define TENSIX_SM_SIBLEN
Definition jtag_bitbang.c:28

◆ SIBSHIFTUP

#define SIBSHIFTUP ( x)
Value:

◆ TENSIX_SIBLEN_PLUS_1_OR_0

#define TENSIX_SIBLEN_PLUS_1_OR_0   ((TENSIX_SM_SIBLEN > 0) ? (TENSIX_SM_SIBLEN + 1) : 0)

◆ TENSIX_SM_RTAP

#define TENSIX_SM_RTAP   (0x19e)

◆ TENSIX_SM_SIBLEN

#define TENSIX_SM_SIBLEN   (4)

◆ TENSIX_SM_TDRLEN

#define TENSIX_SM_TDRLEN   (32)

◆ TENSIX_TDRLEN_SIBLEN_PLUS_1

#define TENSIX_TDRLEN_SIBLEN_PLUS_1   (1 + TENSIX_SM_TDRLEN + TENSIX_SM_SIBLEN)

Function Documentation

◆ CLR_TCK()

void CLR_TCK ( const struct jtag_config * config)
static

◆ CLR_TDI()

void CLR_TDI ( const struct jtag_config * config)
static

◆ CLR_TMS()

void CLR_TMS ( const struct jtag_config * config)
static

◆ GET_TDO()

bool GET_TDO ( const struct jtag_config * config)
static

◆ jtag_access_rtap_tdr()

ALWAYS_INLINE uint32_t jtag_access_rtap_tdr ( const struct device * dev,
uint32_t rtap_addr,
uint32_t tdr_addr,
uint32_t wrdata )
static

◆ jtag_access_rtap_tdr_idle()

ALWAYS_INLINE uint32_t jtag_access_rtap_tdr_idle ( const struct device * dev,
uint32_t rtap_addr,
uint32_t tdr_addr,
uint32_t wrdata )
static

◆ jtag_axi_blockwrite()

int jtag_axi_blockwrite ( const struct device * dev,
uint32_t addr,
const uint32_t * value,
uint32_t len )

◆ jtag_axiread()

int jtag_axiread ( const struct device * dev,
uint32_t addr,
uint32_t * result )

◆ jtag_axiwrite()

int jtag_axiwrite ( const struct device * dev,
uint32_t addr,
uint32_t value )

◆ jtag_bitbang_capture_dr()

ALWAYS_INLINE uint64_t jtag_bitbang_capture_dr ( const struct device * dev,
uint32_t count,
uint64_t data_in )
static

◆ jtag_bitbang_capture_dr_idle()

ALWAYS_INLINE uint64_t jtag_bitbang_capture_dr_idle ( const struct device * dev,
uint32_t count,
uint64_t data_in )
static

◆ jtag_bitbang_init()

int jtag_bitbang_init ( const struct device * dev)
static

◆ jtag_bitbang_read_id()

int jtag_bitbang_read_id ( const struct device * dev,
uint32_t * id )

◆ jtag_bitbang_reset()

int jtag_bitbang_reset ( const struct device * dev)

◆ jtag_bitbang_setup()

int jtag_bitbang_setup ( const struct device * dev)

◆ jtag_bitbang_teardown()

int jtag_bitbang_teardown ( const struct device * dev)
static

◆ jtag_bitbang_tick()

ALWAYS_INLINE void jtag_bitbang_tick ( const struct device * dev,
uint32_t count )
static

◆ jtag_bitbang_update_dr()

ALWAYS_INLINE void jtag_bitbang_update_dr ( const struct device * dev,
uint32_t count,
uint64_t data_in )
static

◆ jtag_bitbang_update_dr_idle()

ALWAYS_INLINE void jtag_bitbang_update_dr_idle ( const struct device * dev,
uint32_t count,
uint64_t data_in )
static

◆ jtag_bitbang_update_ir()

ALWAYS_INLINE void jtag_bitbang_update_ir ( const struct device * dev,
uint32_t count,
uint64_t data )
static

◆ jtag_bitbang_xfer_dr()

ALWAYS_INLINE uint64_t jtag_bitbang_xfer_dr ( const struct device * dev,
uint32_t count,
uint64_t data_in,
bool idle,
bool capture )
static

◆ jtag_rd_tensix_sm_rtap_tdr()

ALWAYS_INLINE uint32_t jtag_rd_tensix_sm_rtap_tdr ( const struct device * dev,
uint32_t tdr_addr )
static

◆ jtag_rd_tensix_sm_rtap_tdr_idle()

ALWAYS_INLINE uint32_t jtag_rd_tensix_sm_rtap_tdr_idle ( const struct device * dev,
uint32_t tdr_addr )
static

◆ jtag_req_clear()

void jtag_req_clear ( const struct device * dev)

◆ jtag_setup_access()

ALWAYS_INLINE void jtag_setup_access ( const struct device * dev,
uint32_t rtap_addr )
static

◆ jtag_wr_tensix_sm_rtap_tdr()

ALWAYS_INLINE void jtag_wr_tensix_sm_rtap_tdr ( const struct device * dev,
uint32_t tdr_addr,
uint32_t wrvalue )
static

◆ jtag_wr_tensix_sm_rtap_tdr_idle()

ALWAYS_INLINE void jtag_wr_tensix_sm_rtap_tdr_idle ( const struct device * dev,
uint32_t tdr_addr,
uint32_t wrvalue )
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( jtag_bitbang ,
CONFIG_JTAG_LOG_LEVEL  )

◆ SET_TCK()

void SET_TCK ( const struct jtag_config * config)
static

◆ SET_TDI()

void SET_TDI ( const struct jtag_config * config)
static

◆ SET_TMS()

void SET_TMS ( const struct jtag_config * config)
static

Variable Documentation

◆ jtag_bitbang_api

struct jtag_api jtag_bitbang_api
static
Initial value:
= {.setup = jtag_bitbang_setup,
.teardown = jtag_bitbang_teardown,
.axi_read32 = jtag_axiread,
.axi_write32 = jtag_axiwrite,
.axi_block_write = jtag_axi_blockwrite}
int jtag_bitbang_reset(const struct device *dev)
Definition jtag_bitbang.c:166
int jtag_axiwrite(const struct device *dev, uint32_t addr, uint32_t value)
Definition jtag_bitbang.c:458
int jtag_bitbang_setup(const struct device *dev)
Definition jtag_bitbang.c:308
int jtag_axiread(const struct device *dev, uint32_t addr, uint32_t *result)
Definition jtag_bitbang.c:434
int jtag_axi_blockwrite(const struct device *dev, uint32_t addr, const uint32_t *value, uint32_t len)
Definition jtag_bitbang.c:474
int jtag_bitbang_read_id(const struct device *dev, uint32_t *id)
Definition jtag_bitbang.c:299
static int jtag_bitbang_teardown(const struct device *dev)
Definition jtag_bitbang.c:338