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#ifndef ATOM_H
26#define ATOM_H
27
28#include <linux/types.h>
29#include <drm/drmP.h>
30
31#define ATOM_BIOS_MAGIC 0xAA55
32#define ATOM_ATI_MAGIC_PTR 0x30
33#define ATOM_ATI_MAGIC " 761295520"
34#define ATOM_ROM_TABLE_PTR 0x48
35#define ATOM_ROM_PART_NUMBER_PTR 0x6E
36
37#define ATOM_ROM_MAGIC "ATOM"
38#define ATOM_ROM_MAGIC_PTR 4
39
40#define ATOM_ROM_MSG_PTR 0x10
41#define ATOM_ROM_CMD_PTR 0x1E
42#define ATOM_ROM_DATA_PTR 0x20
43
44#define ATOM_CMD_INIT 0
45#define ATOM_CMD_SETSCLK 0x0A
46#define ATOM_CMD_SETMCLK 0x0B
47#define ATOM_CMD_SETPCLK 0x0C
48#define ATOM_CMD_SPDFANCNTL 0x39
49
50#define ATOM_DATA_FWI_PTR 0xC
51#define ATOM_DATA_IIO_PTR 0x32
52
53#define ATOM_FWI_DEFSCLK_PTR 8
54#define ATOM_FWI_DEFMCLK_PTR 0xC
55#define ATOM_FWI_MAXSCLK_PTR 0x24
56#define ATOM_FWI_MAXMCLK_PTR 0x28
57
58#define ATOM_CT_SIZE_PTR 0
59#define ATOM_CT_WS_PTR 4
60#define ATOM_CT_PS_PTR 5
61#define ATOM_CT_PS_MASK 0x7F
62#define ATOM_CT_CODE_PTR 6
63
64#define ATOM_OP_CNT 127
65#define ATOM_OP_EOT 91
66
67#define ATOM_CASE_MAGIC 0x63
68#define ATOM_CASE_END 0x5A5A
69
70#define ATOM_ARG_REG 0
71#define ATOM_ARG_PS 1
72#define ATOM_ARG_WS 2
73#define ATOM_ARG_FB 3
74#define ATOM_ARG_ID 4
75#define ATOM_ARG_IMM 5
76#define ATOM_ARG_PLL 6
77#define ATOM_ARG_MC 7
78
79#define ATOM_SRC_DWORD 0
80#define ATOM_SRC_WORD0 1
81#define ATOM_SRC_WORD8 2
82#define ATOM_SRC_WORD16 3
83#define ATOM_SRC_BYTE0 4
84#define ATOM_SRC_BYTE8 5
85#define ATOM_SRC_BYTE16 6
86#define ATOM_SRC_BYTE24 7
87
88#define ATOM_WS_QUOTIENT 0x40
89#define ATOM_WS_REMAINDER 0x41
90#define ATOM_WS_DATAPTR 0x42
91#define ATOM_WS_SHIFT 0x43
92#define ATOM_WS_OR_MASK 0x44
93#define ATOM_WS_AND_MASK 0x45
94#define ATOM_WS_FB_WINDOW 0x46
95#define ATOM_WS_ATTRIBUTES 0x47
96#define ATOM_WS_REGPTR 0x48
97
98#define ATOM_IIO_NOP 0
99#define ATOM_IIO_START 1
100#define ATOM_IIO_READ 2
101#define ATOM_IIO_WRITE 3
102#define ATOM_IIO_CLEAR 4
103#define ATOM_IIO_SET 5
104#define ATOM_IIO_MOVE_INDEX 6
105#define ATOM_IIO_MOVE_ATTR 7
106#define ATOM_IIO_MOVE_DATA 8
107#define ATOM_IIO_END 9
108
109#define ATOM_IO_MM 0
110#define ATOM_IO_PCI 1
111#define ATOM_IO_SYSIO 2
112#define ATOM_IO_IIO 0x80
113
114struct card_info {
115 struct drm_device *dev;
116 void (* reg_write)(struct card_info *, uint32_t, uint32_t);
117 uint32_t (* reg_read)(struct card_info *, uint32_t);
118 void (* ioreg_write)(struct card_info *, uint32_t, uint32_t);
119 uint32_t (* ioreg_read)(struct card_info *, uint32_t);
120 void (* mc_write)(struct card_info *, uint32_t, uint32_t);
121 uint32_t (* mc_read)(struct card_info *, uint32_t);
122 void (* pll_write)(struct card_info *, uint32_t, uint32_t);
123 uint32_t (* pll_read)(struct card_info *, uint32_t);
124};
125
126struct atom_context {
127 struct card_info *card;
128 struct mutex mutex;
129 void *bios;
130 uint32_t cmd_table, data_table;
131 uint16_t *iio;
132
133 uint16_t data_block;
134 uint32_t fb_base;
135 uint32_t divmul[2];
136 uint16_t io_attr;
137 uint16_t reg_block;
138 uint8_t shift;
139 int cs_equal, cs_above;
140 int io_mode;
141 uint32_t *scratch;
142 int scratch_size_bytes;
143 char vbios_version[20];
144};
145
146extern int amdgpu_atom_debug;
147
148struct atom_context *amdgpu_atom_parse(struct card_info *, void *);
149int amdgpu_atom_execute_table(struct atom_context *, int, uint32_t *);
150int amdgpu_atom_asic_init(struct atom_context *);
151void amdgpu_atom_destroy(struct atom_context *);
152bool amdgpu_atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
153 uint8_t *frev, uint8_t *crev, uint16_t *data_start);
154bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index,
155 uint8_t *frev, uint8_t *crev);
156#include "atom-types.h"
157#include "atombios.h"
158#include "ObjectID.h"
159
160#endif
161