summaryrefslogtreecommitdiff
path: root/platform/wavelet3d/host_sw/main.c
blob: 5dfedcea61e91949119ed16ddcb729ea6a889052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
}