diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-05-21 09:10:25 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-05-24 05:58:42 -0600 |
| commit | e15674334408644143aa6dbce6657614e59da370 (patch) | |
| tree | 44f276379356394a144dc07f5291fdeeb26f73bb | |
| parent | 1dc93e3fedbea8759f49cb3a2e11eb3afdaf5ef5 (diff) | |
platform/wavelet3d/host_sw: iniital commit, gfx probing
| -rw-r--r-- | platform/wavelet3d/host_sw/main.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/platform/wavelet3d/host_sw/main.c b/platform/wavelet3d/host_sw/main.c new file mode 100644 index 0000000..5dfedce --- /dev/null +++ b/platform/wavelet3d/host_sw/main.c @@ -0,0 +1,72 @@ +#include <stdio.h> + +struct gfx_hw_id +{ + unsigned patch : 8; + unsigned minor : 8; + unsigned major : 8; + unsigned rsvd : 8; +}; + +struct gfx_fw_id +{ + unsigned build : 10; + unsigned day : 5; + unsigned month : 4; + unsigned year : 12; + unsigned rsvd : 1; +}; + +#define GFX_CTRL_BASE 0x20000000 +#define GFX_CTRL_MAGIC (*(volatile unsigned *)(GFX_CTRL_BASE + 0x00)) +#define GFX_CTRL_HW_ID (*(volatile struct gfx_hw_id *)(GFX_CTRL_BASE + 0x04)) +#define GFX_CTRL_FW_ID (*(volatile struct gfx_fw_id *)(GFX_CTRL_BASE + 0x08)) +#define GFX_CTRL_HOSTIF_REV (*(volatile unsigned *)(GFX_CTRL_BASE + 0x0c)) + +#define GFX_MAGIC_ID 0x4a7a7b0c + +int main() +{ + printf("gfx: probing 0x%08x\n", GFX_CTRL_BASE); + + unsigned magic = GFX_CTRL_MAGIC; + printf("gfx: magic=0x%08x\n", magic); + + if (magic != GFX_MAGIC_ID) + printf("gfx: bad magic, probe failed\n"); + + printf("gfx: magic ok\n"); + + struct gfx_hw_id hw_id = GFX_CTRL_HW_ID; + struct gfx_fw_id fw_id = GFX_CTRL_FW_ID; + unsigned hostif_rev = GFX_CTRL_HOSTIF_REV; + + printf + ( + "gfx: 3D graphics accelerator IP core v%u.%u.%u\n", + hw_id.major, hw_id.minor, hw_id.patch + ); + + switch (hostif_rev) { + case 0: + printf("gfx: scheduler is in bootloader rom\n"); + break; + + case 1: + printf("gfx: detected regmap revision %u\n", hostif_rev); + break; + + default: + printf("gfx: unknown regmap revision %u\n", hostif_rev); + break; + } + + printf + ( + "gfx: %s rev %u.%u.%02u #%02u\n", + hostif_rev ? "firmware" : "bootloader", + fw_id.year, fw_id.month, fw_id.day, fw_id.build + ); + + return 0; +} |
