Skip to content

Commit

Permalink
Add GpuAsyncCore version register
Browse files Browse the repository at this point in the history
  • Loading branch information
JJL772 committed Jan 27, 2025
1 parent ebaf294 commit b4459a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/driver/data_dev_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ int32_t DataDev_Command(struct DmaDevice *dev, uint32_t cmd, uint64_t arg) {
case GPU_Add_Nvidia_Memory:
case GPU_Rem_Nvidia_Memory:
case GPU_Set_Write_Enable:
return Gpu_Command(dev, cmd, arg);
return dev->gpuEn ? Gpu_Command(dev, cmd, arg) : -1;
#endif

case AVER_Get:
Expand Down Expand Up @@ -423,8 +423,10 @@ void DataDev_SeqShow(struct seq_file *s, struct DmaDevice *dev) {
AxisG2_SeqShow(s, dev);

#ifdef DATA_GPU
// Display DataGPU-specific state information
Gpu_Show(s, dev);
if (dev->gpuEn) {
// Display DataGPU-specific state information
Gpu_Show(s, dev);
}
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions common/driver/dma_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ struct DmaDevice {
// Debug flag
uint8_t debug;

// GPU-capable flag
uint8_t gpuEn;

// IRQ
uint32_t irq;

Expand Down
7 changes: 7 additions & 0 deletions common/driver/gpu_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
void Gpu_Init(struct DmaDevice *dev, uint32_t offset) {
struct GpuData *gpuData;

uint8_t* gpuBase = dev->base + offset;
dev->gpuEn = !!readGpuAsyncReg(gpuBase, &GpuAsyncReg_Version);

/* GPU not enabled, avoid allocating GPU data */
if (!dev->gpuEn)
return;

/* Allocate memory for GPU utility data */
gpuData = (struct GpuData *)kzalloc(sizeof(struct GpuData), GFP_KERNEL);
if (!gpuData)
Expand Down
2 changes: 2 additions & 0 deletions include/GpuAsyncRegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ GPU_ASYNC_DEF_REG(DynamicRouteDests0, 0x2C, 8, 0xFF00);
GPU_ASYNC_DEF_REG(DynamicRouteMasks1, 0x2C, 16, 0xFF0000);
GPU_ASYNC_DEF_REG(DynamicRouteDests1, 0x2C, 24, 0xFF000000);

GPU_ASYNC_DEF_REG(Version, 0x30, 0, 0x1);

// The following register defintiions are firmware specific. GpuAsyncCore can have up to 16 buffers, but defaults to 4.
// You must check the MaxBuffers register for the true value

Expand Down

0 comments on commit b4459a9

Please sign in to comment.