/* * gevntadr_reg.c * * Created on: 20-Apr-2023 * Author: pushpkant */ #include "ltcusb_regs_ops.h" static GEVNTADR gevntadr_reg; int gevntadr_init(uint32_t device_number, uint64_t gevntadr_val) { if(device_number >= DWC_USB3_DEVICE_NUM_INT) { return -1; } uintptr_t reg_offset = GEVNTADR_OFFSET + (device_number * 0x10); uint32_t gevntadr_lo = (uint32_t)gevntadr_val; gevntadr_val >>= 32; uint32_t gevntadr_hi = (uint32_t)gevntadr_val; gevntadr_reg.dev[device_number].LO = reg_setup(reg_offset); gevntadr_reg.dev[device_number].LO->EVNTADRLO = gevntadr_lo; ltcusb_raw_write(); gevntadr_reg.dev[device_number].HI = reg_setup(reg_offset + 0x4); gevntadr_reg.dev[device_number].HI->EVNTADRHI = gevntadr_hi; ltcusb_raw_write(); return 0; } int gevntadr_get(uint32_t device_number, uint64_t *genvtadr_val) { if(device_number >= DWC_USB3_DEVICE_NUM_INT) { return -1; } uintptr_t reg_offset = GEVNTADR_OFFSET + (device_number * 0x10); gevntadr_reg.dev[device_number].LO = reg_setup(reg_offset); uint32_t gevntadr_lo = gevntadr_reg.dev[device_number].LO->EVNTADRLO; gevntadr_reg.dev[device_number].HI = reg_setup(reg_offset + 0x4); uint32_t gevntadr_hi = gevntadr_reg.dev[device_number].HI->EVNTADRHI; *genvtadr_val = ((uint64_t)gevntadr_lo) | (((uint64_t)gevntadr_hi) << 32); return 0; }