blob: 38c856fae14132b9f4a3ce3286ce8d487e455b90 [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
2 * Copyright 2007-2008 Nouveau Project
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef __NOUVEAU_BIOS_H__
25#define __NOUVEAU_BIOS_H__
26
27#include "nvreg.h"
28#include "nouveau_i2c.h"
29
30#define DCB_MAX_NUM_ENTRIES 16
31#define DCB_MAX_NUM_I2C_ENTRIES 16
32#define DCB_MAX_NUM_GPIO_ENTRIES 32
33#define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
34
35#define DCB_LOC_ON_CHIP 0
36
37struct dcb_entry {
38 int index; /* may not be raw dcb index if merging has happened */
39 uint8_t type;
40 uint8_t i2c_index;
41 uint8_t heads;
42 uint8_t connector;
43 uint8_t bus;
44 uint8_t location;
45 uint8_t or;
46 bool duallink_possible;
47 union {
48 struct sor_conf {
49 int link;
50 } sorconf;
51 struct {
52 int maxfreq;
53 } crtconf;
54 struct {
55 struct sor_conf sor;
56 bool use_straps_for_mode;
57 bool use_power_scripts;
58 } lvdsconf;
59 struct {
60 bool has_component_output;
61 } tvconf;
62 struct {
63 struct sor_conf sor;
64 int link_nr;
65 int link_bw;
66 } dpconf;
67 struct {
68 struct sor_conf sor;
69 } tmdsconf;
70 };
71 bool i2c_upper_default;
72};
73
74struct dcb_i2c_entry {
75 uint8_t port_type;
76 uint8_t read, write;
77 struct nouveau_i2c_chan *chan;
78};
79
Ben Skeggs6ee73862009-12-11 19:24:15 +100080enum dcb_gpio_tag {
81 DCB_GPIO_TVDAC0 = 0xc,
82 DCB_GPIO_TVDAC1 = 0x2d,
83};
84
85struct dcb_gpio_entry {
86 enum dcb_gpio_tag tag;
87 int line;
88 bool invert;
89};
90
Ben Skeggsa6678b22010-02-24 09:46:27 +100091struct dcb_gpio_table {
Ben Skeggs6ee73862009-12-11 19:24:15 +100092 int entries;
93 struct dcb_gpio_entry entry[DCB_MAX_NUM_GPIO_ENTRIES];
94};
95
96struct dcb_connector_table_entry {
97 uint32_t entry;
98 uint8_t type;
99 uint8_t index;
100 uint8_t gpio_tag;
101};
102
103struct dcb_connector_table {
104 int entries;
105 struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES];
106};
107
Ben Skeggs7f245b22010-02-24 09:56:18 +1000108struct dcb_table {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000109 uint8_t version;
110
Ben Skeggs7f245b22010-02-24 09:56:18 +1000111 int entries;
112 struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000113
114 uint8_t *i2c_table;
115 uint8_t i2c_default_indices;
Ben Skeggs7f245b22010-02-24 09:56:18 +1000116 struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000117
118 uint16_t gpio_table_ptr;
Ben Skeggsa6678b22010-02-24 09:46:27 +1000119 struct dcb_gpio_table gpio;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000120 uint16_t connector_table_ptr;
121 struct dcb_connector_table connector;
122};
123
124enum nouveau_encoder_type {
125 OUTPUT_ANALOG = 0,
126 OUTPUT_TV = 1,
127 OUTPUT_TMDS = 2,
128 OUTPUT_LVDS = 3,
129 OUTPUT_DP = 6,
130 OUTPUT_ANY = -1
131};
132
133enum nouveau_or {
134 OUTPUT_A = (1 << 0),
135 OUTPUT_B = (1 << 1),
136 OUTPUT_C = (1 << 2)
137};
138
139enum LVDS_script {
140 /* Order *does* matter here */
141 LVDS_INIT = 1,
142 LVDS_RESET,
143 LVDS_BACKLIGHT_ON,
144 LVDS_BACKLIGHT_OFF,
145 LVDS_PANEL_ON,
146 LVDS_PANEL_OFF
147};
148
149/* changing these requires matching changes to reg tables in nv_get_clock */
150#define MAX_PLL_TYPES 4
151enum pll_types {
152 NVPLL,
153 MPLL,
154 VPLL1,
155 VPLL2
156};
157
158struct pll_lims {
159 struct {
160 int minfreq;
161 int maxfreq;
162 int min_inputfreq;
163 int max_inputfreq;
164
165 uint8_t min_m;
166 uint8_t max_m;
167 uint8_t min_n;
168 uint8_t max_n;
169 } vco1, vco2;
170
171 uint8_t max_log2p;
172 /*
173 * for most pre nv50 cards setting a log2P of 7 (the common max_log2p
174 * value) is no different to 6 (at least for vplls) so allowing the MNP
175 * calc to use 7 causes the generated clock to be out by a factor of 2.
176 * however, max_log2p cannot be fixed-up during parsing as the
177 * unmodified max_log2p value is still needed for setting mplls, hence
178 * an additional max_usable_log2p member
179 */
180 uint8_t max_usable_log2p;
181 uint8_t log2p_bias;
182
183 uint8_t min_p;
184 uint8_t max_p;
185
186 int refclk;
187};
188
Ben Skeggs04a39c52010-02-24 10:03:05 +1000189struct nvbios {
190 struct drm_device *dev;
191
Ben Skeggs6ee73862009-12-11 19:24:15 +1000192 uint8_t chip_version;
193
194 uint32_t dactestval;
195 uint32_t tvdactestval;
196 uint8_t digital_min_front_porch;
197 bool fp_no_ddc;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000198
Ben Skeggsd9184fa2010-02-16 11:14:14 +1000199 struct mutex lock;
Ben Skeggs39c9bfb2010-02-09 10:22:29 +1000200
Ben Skeggs6ee73862009-12-11 19:24:15 +1000201 uint8_t data[NV_PROM_SIZE];
202 unsigned int length;
203 bool execute;
204
205 uint8_t major_version;
206 uint8_t feature_byte;
207 bool is_mobile;
208
209 uint32_t fmaxvco, fminvco;
210
211 bool old_style_init;
212 uint16_t init_script_tbls_ptr;
213 uint16_t extra_init_script_tbl_ptr;
214 uint16_t macro_index_tbl_ptr;
215 uint16_t macro_tbl_ptr;
216 uint16_t condition_tbl_ptr;
217 uint16_t io_condition_tbl_ptr;
218 uint16_t io_flag_condition_tbl_ptr;
219 uint16_t init_function_tbl_ptr;
220
221 uint16_t pll_limit_tbl_ptr;
222 uint16_t ram_restrict_tbl_ptr;
Marcin Koƛcielnicki37383652009-12-15 00:37:31 +0000223 uint8_t ram_restrict_group_count;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000224
225 uint16_t some_script_ptr; /* BIT I + 14 */
226 uint16_t init96_tbl_ptr; /* BIT I + 16 */
227
Ben Skeggs7f245b22010-02-24 09:56:18 +1000228 struct dcb_table dcb;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000229
230 struct {
231 int crtchead;
232 /* these need remembering across suspend */
233 uint32_t saved_nv_pfb_cfg0;
234 } state;
235
236 struct {
237 struct dcb_entry *output;
238 uint16_t script_table_ptr;
239 uint16_t dp_table_ptr;
240 } display;
241
242 struct {
243 uint16_t fptablepointer; /* also used by tmds */
244 uint16_t fpxlatetableptr;
245 int xlatwidth;
246 uint16_t lvdsmanufacturerpointer;
247 uint16_t fpxlatemanufacturertableptr;
248 uint16_t mode_ptr;
249 uint16_t xlated_entry;
250 bool power_off_for_reset;
251 bool reset_after_pclk_change;
252 bool dual_link;
253 bool link_c_increment;
254 bool BITbit1;
255 bool if_is_24bit;
256 int duallink_transition_clk;
257 uint8_t strapless_is_24bit;
258 uint8_t *edid;
259
260 /* will need resetting after suspend */
261 int last_script_invoc;
262 bool lvds_init_run;
263 } fp;
264
265 struct {
266 uint16_t output0_script_ptr;
267 uint16_t output1_script_ptr;
268 } tmds;
269
270 struct {
271 uint16_t mem_init_tbl_ptr;
272 uint16_t sdr_seq_tbl_ptr;
273 uint16_t ddr_seq_tbl_ptr;
274
275 struct {
276 uint8_t crt, tv, panel;
277 } i2c_indices;
278
279 uint16_t lvds_single_a_script_ptr;
280 } legacy;
281};
282
283#endif