atom.h revision 1.2.2.2 1 1.2.2.2 tls /*
2 1.2.2.2 tls * Copyright 2008 Advanced Micro Devices, Inc.
3 1.2.2.2 tls *
4 1.2.2.2 tls * Permission is hereby granted, free of charge, to any person obtaining a
5 1.2.2.2 tls * copy of this software and associated documentation files (the "Software"),
6 1.2.2.2 tls * to deal in the Software without restriction, including without limitation
7 1.2.2.2 tls * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 1.2.2.2 tls * and/or sell copies of the Software, and to permit persons to whom the
9 1.2.2.2 tls * Software is furnished to do so, subject to the following conditions:
10 1.2.2.2 tls *
11 1.2.2.2 tls * The above copyright notice and this permission notice shall be included in
12 1.2.2.2 tls * all copies or substantial portions of the Software.
13 1.2.2.2 tls *
14 1.2.2.2 tls * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 1.2.2.2 tls * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 1.2.2.2 tls * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 1.2.2.2 tls * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 1.2.2.2 tls * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 1.2.2.2 tls * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 1.2.2.2 tls * OTHER DEALINGS IN THE SOFTWARE.
21 1.2.2.2 tls *
22 1.2.2.2 tls * Author: Stanislaw Skowronek
23 1.2.2.2 tls */
24 1.2.2.2 tls
25 1.2.2.2 tls #ifndef ATOM_H
26 1.2.2.2 tls #define ATOM_H
27 1.2.2.2 tls
28 1.2.2.2 tls #include <linux/types.h>
29 1.2.2.2 tls #include <drm/drmP.h>
30 1.2.2.2 tls
31 1.2.2.2 tls #define ATOM_BIOS_MAGIC 0xAA55
32 1.2.2.2 tls #define ATOM_ATI_MAGIC_PTR 0x30
33 1.2.2.2 tls #define ATOM_ATI_MAGIC " 761295520"
34 1.2.2.2 tls #define ATOM_ROM_TABLE_PTR 0x48
35 1.2.2.2 tls
36 1.2.2.2 tls #define ATOM_ROM_MAGIC "ATOM"
37 1.2.2.2 tls #define ATOM_ROM_MAGIC_PTR 4
38 1.2.2.2 tls
39 1.2.2.2 tls #define ATOM_ROM_MSG_PTR 0x10
40 1.2.2.2 tls #define ATOM_ROM_CMD_PTR 0x1E
41 1.2.2.2 tls #define ATOM_ROM_DATA_PTR 0x20
42 1.2.2.2 tls
43 1.2.2.2 tls #define ATOM_CMD_INIT 0
44 1.2.2.2 tls #define ATOM_CMD_SETSCLK 0x0A
45 1.2.2.2 tls #define ATOM_CMD_SETMCLK 0x0B
46 1.2.2.2 tls #define ATOM_CMD_SETPCLK 0x0C
47 1.2.2.2 tls #define ATOM_CMD_SPDFANCNTL 0x39
48 1.2.2.2 tls
49 1.2.2.2 tls #define ATOM_DATA_FWI_PTR 0xC
50 1.2.2.2 tls #define ATOM_DATA_IIO_PTR 0x32
51 1.2.2.2 tls
52 1.2.2.2 tls #define ATOM_FWI_DEFSCLK_PTR 8
53 1.2.2.2 tls #define ATOM_FWI_DEFMCLK_PTR 0xC
54 1.2.2.2 tls #define ATOM_FWI_MAXSCLK_PTR 0x24
55 1.2.2.2 tls #define ATOM_FWI_MAXMCLK_PTR 0x28
56 1.2.2.2 tls
57 1.2.2.2 tls #define ATOM_CT_SIZE_PTR 0
58 1.2.2.2 tls #define ATOM_CT_WS_PTR 4
59 1.2.2.2 tls #define ATOM_CT_PS_PTR 5
60 1.2.2.2 tls #define ATOM_CT_PS_MASK 0x7F
61 1.2.2.2 tls #define ATOM_CT_CODE_PTR 6
62 1.2.2.2 tls
63 1.2.2.2 tls #define ATOM_OP_CNT 123
64 1.2.2.2 tls #define ATOM_OP_EOT 91
65 1.2.2.2 tls
66 1.2.2.2 tls #define ATOM_CASE_MAGIC 0x63
67 1.2.2.2 tls #define ATOM_CASE_END 0x5A5A
68 1.2.2.2 tls
69 1.2.2.2 tls #define ATOM_ARG_REG 0
70 1.2.2.2 tls #define ATOM_ARG_PS 1
71 1.2.2.2 tls #define ATOM_ARG_WS 2
72 1.2.2.2 tls #define ATOM_ARG_FB 3
73 1.2.2.2 tls #define ATOM_ARG_ID 4
74 1.2.2.2 tls #define ATOM_ARG_IMM 5
75 1.2.2.2 tls #define ATOM_ARG_PLL 6
76 1.2.2.2 tls #define ATOM_ARG_MC 7
77 1.2.2.2 tls
78 1.2.2.2 tls #define ATOM_SRC_DWORD 0
79 1.2.2.2 tls #define ATOM_SRC_WORD0 1
80 1.2.2.2 tls #define ATOM_SRC_WORD8 2
81 1.2.2.2 tls #define ATOM_SRC_WORD16 3
82 1.2.2.2 tls #define ATOM_SRC_BYTE0 4
83 1.2.2.2 tls #define ATOM_SRC_BYTE8 5
84 1.2.2.2 tls #define ATOM_SRC_BYTE16 6
85 1.2.2.2 tls #define ATOM_SRC_BYTE24 7
86 1.2.2.2 tls
87 1.2.2.2 tls #define ATOM_WS_QUOTIENT 0x40
88 1.2.2.2 tls #define ATOM_WS_REMAINDER 0x41
89 1.2.2.2 tls #define ATOM_WS_DATAPTR 0x42
90 1.2.2.2 tls #define ATOM_WS_SHIFT 0x43
91 1.2.2.2 tls #define ATOM_WS_OR_MASK 0x44
92 1.2.2.2 tls #define ATOM_WS_AND_MASK 0x45
93 1.2.2.2 tls #define ATOM_WS_FB_WINDOW 0x46
94 1.2.2.2 tls #define ATOM_WS_ATTRIBUTES 0x47
95 1.2.2.2 tls #define ATOM_WS_REGPTR 0x48
96 1.2.2.2 tls
97 1.2.2.2 tls #define ATOM_IIO_NOP 0
98 1.2.2.2 tls #define ATOM_IIO_START 1
99 1.2.2.2 tls #define ATOM_IIO_READ 2
100 1.2.2.2 tls #define ATOM_IIO_WRITE 3
101 1.2.2.2 tls #define ATOM_IIO_CLEAR 4
102 1.2.2.2 tls #define ATOM_IIO_SET 5
103 1.2.2.2 tls #define ATOM_IIO_MOVE_INDEX 6
104 1.2.2.2 tls #define ATOM_IIO_MOVE_ATTR 7
105 1.2.2.2 tls #define ATOM_IIO_MOVE_DATA 8
106 1.2.2.2 tls #define ATOM_IIO_END 9
107 1.2.2.2 tls
108 1.2.2.2 tls #define ATOM_IO_MM 0
109 1.2.2.2 tls #define ATOM_IO_PCI 1
110 1.2.2.2 tls #define ATOM_IO_SYSIO 2
111 1.2.2.2 tls #define ATOM_IO_IIO 0x80
112 1.2.2.2 tls
113 1.2.2.2 tls struct card_info {
114 1.2.2.2 tls struct drm_device *dev;
115 1.2.2.2 tls void (* reg_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */
116 1.2.2.2 tls uint32_t (* reg_read)(struct card_info *, uint32_t); /* filled by driver */
117 1.2.2.2 tls void (* ioreg_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */
118 1.2.2.2 tls uint32_t (* ioreg_read)(struct card_info *, uint32_t); /* filled by driver */
119 1.2.2.2 tls void (* mc_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */
120 1.2.2.2 tls uint32_t (* mc_read)(struct card_info *, uint32_t); /* filled by driver */
121 1.2.2.2 tls void (* pll_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */
122 1.2.2.2 tls uint32_t (* pll_read)(struct card_info *, uint32_t); /* filled by driver */
123 1.2.2.2 tls };
124 1.2.2.2 tls
125 1.2.2.2 tls struct atom_context {
126 1.2.2.2 tls struct card_info *card;
127 1.2.2.2 tls struct mutex mutex;
128 1.2.2.2 tls uint8_t *bios;
129 1.2.2.2 tls uint32_t cmd_table, data_table;
130 1.2.2.2 tls uint16_t *iio;
131 1.2.2.2 tls
132 1.2.2.2 tls uint16_t data_block;
133 1.2.2.2 tls uint32_t fb_base;
134 1.2.2.2 tls uint32_t divmul[2];
135 1.2.2.2 tls uint16_t io_attr;
136 1.2.2.2 tls uint16_t reg_block;
137 1.2.2.2 tls uint8_t shift;
138 1.2.2.2 tls int cs_equal, cs_above;
139 1.2.2.2 tls int io_mode;
140 1.2.2.2 tls uint32_t *scratch;
141 1.2.2.2 tls int scratch_size_bytes;
142 1.2.2.2 tls };
143 1.2.2.2 tls
144 1.2.2.2 tls extern int atom_debug;
145 1.2.2.2 tls
146 1.2.2.2 tls struct atom_context *atom_parse(struct card_info *, void *);
147 1.2.2.2 tls int atom_execute_table(struct atom_context *, int, uint32_t *);
148 1.2.2.2 tls int atom_asic_init(struct atom_context *);
149 1.2.2.2 tls void atom_destroy(struct atom_context *);
150 1.2.2.2 tls bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
151 1.2.2.2 tls uint8_t *frev, uint8_t *crev, uint16_t *data_start);
152 1.2.2.2 tls bool atom_parse_cmd_header(struct atom_context *ctx, int index,
153 1.2.2.2 tls uint8_t *frev, uint8_t *crev);
154 1.2.2.2 tls int atom_allocate_fb_scratch(struct atom_context *ctx);
155 1.2.2.2 tls #include "atom-types.h"
156 1.2.2.2 tls #include "atombios.h"
157 1.2.2.2 tls #include "ObjectID.h"
158 1.2.2.2 tls
159 1.2.2.2 tls #endif
160