Path: blob/master/drivers/gpu/drm/nouveau/nouveau_bios.h
15112 views
/*1* Copyright 2007-2008 Nouveau Project2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#ifndef __NOUVEAU_BIOS_H__24#define __NOUVEAU_BIOS_H__2526#include "nvreg.h"27#include "nouveau_i2c.h"2829#define DCB_MAX_NUM_ENTRIES 1630#define DCB_MAX_NUM_I2C_ENTRIES 1631#define DCB_MAX_NUM_GPIO_ENTRIES 3232#define DCB_MAX_NUM_CONNECTOR_ENTRIES 163334#define DCB_LOC_ON_CHIP 03536#define ROM16(x) le16_to_cpu(*(uint16_t *)&(x))37#define ROM32(x) le32_to_cpu(*(uint32_t *)&(x))38#define ROMPTR(bios, x) (ROM16(x) ? &(bios)->data[ROM16(x)] : NULL)3940struct bit_entry {41uint8_t id;42uint8_t version;43uint16_t length;44uint16_t offset;45uint8_t *data;46};4748int bit_table(struct drm_device *, u8 id, struct bit_entry *);4950struct dcb_i2c_entry {51uint32_t entry;52uint8_t port_type;53uint8_t read, write;54struct nouveau_i2c_chan *chan;55};5657enum dcb_gpio_tag {58DCB_GPIO_TVDAC0 = 0xc,59DCB_GPIO_TVDAC1 = 0x2d,60};6162struct dcb_gpio_entry {63enum dcb_gpio_tag tag;64int line;65bool invert;66uint32_t entry;67uint8_t state_default;68uint8_t state[2];69};7071struct dcb_gpio_table {72int entries;73struct dcb_gpio_entry entry[DCB_MAX_NUM_GPIO_ENTRIES];74};7576enum dcb_connector_type {77DCB_CONNECTOR_VGA = 0x00,78DCB_CONNECTOR_TV_0 = 0x10,79DCB_CONNECTOR_TV_1 = 0x11,80DCB_CONNECTOR_TV_3 = 0x13,81DCB_CONNECTOR_DVI_I = 0x30,82DCB_CONNECTOR_DVI_D = 0x31,83DCB_CONNECTOR_LVDS = 0x40,84DCB_CONNECTOR_LVDS_SPWG = 0x41,85DCB_CONNECTOR_DP = 0x46,86DCB_CONNECTOR_eDP = 0x47,87DCB_CONNECTOR_HDMI_0 = 0x60,88DCB_CONNECTOR_HDMI_1 = 0x61,89DCB_CONNECTOR_NONE = 0xff90};9192struct dcb_connector_table_entry {93uint8_t index;94uint32_t entry;95enum dcb_connector_type type;96uint8_t index2;97uint8_t gpio_tag;98void *drm;99};100101struct dcb_connector_table {102int entries;103struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES];104};105106enum dcb_type {107OUTPUT_ANALOG = 0,108OUTPUT_TV = 1,109OUTPUT_TMDS = 2,110OUTPUT_LVDS = 3,111OUTPUT_DP = 6,112OUTPUT_EOL = 14, /* DCB 4.0+, appears to be end-of-list */113OUTPUT_ANY = -1114};115116struct dcb_entry {117int index; /* may not be raw dcb index if merging has happened */118enum dcb_type type;119uint8_t i2c_index;120uint8_t heads;121uint8_t connector;122uint8_t bus;123uint8_t location;124uint8_t or;125bool duallink_possible;126union {127struct sor_conf {128int link;129} sorconf;130struct {131int maxfreq;132} crtconf;133struct {134struct sor_conf sor;135bool use_straps_for_mode;136bool use_acpi_for_edid;137bool use_power_scripts;138} lvdsconf;139struct {140bool has_component_output;141} tvconf;142struct {143struct sor_conf sor;144int link_nr;145int link_bw;146} dpconf;147struct {148struct sor_conf sor;149int slave_addr;150} tmdsconf;151};152bool i2c_upper_default;153};154155struct dcb_table {156uint8_t version;157158int entries;159struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];160161uint8_t *i2c_table;162uint8_t i2c_default_indices;163struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];164165uint16_t gpio_table_ptr;166struct dcb_gpio_table gpio;167uint16_t connector_table_ptr;168struct dcb_connector_table connector;169};170171enum nouveau_or {172OUTPUT_A = (1 << 0),173OUTPUT_B = (1 << 1),174OUTPUT_C = (1 << 2)175};176177enum LVDS_script {178/* Order *does* matter here */179LVDS_INIT = 1,180LVDS_RESET,181LVDS_BACKLIGHT_ON,182LVDS_BACKLIGHT_OFF,183LVDS_PANEL_ON,184LVDS_PANEL_OFF185};186187/* these match types in pll limits table version 0x40,188* nouveau uses them on all chipsets internally where a189* specific pll needs to be referenced, but the exact190* register isn't known.191*/192enum pll_types {193PLL_CORE = 0x01,194PLL_SHADER = 0x02,195PLL_UNK03 = 0x03,196PLL_MEMORY = 0x04,197PLL_UNK05 = 0x05,198PLL_UNK40 = 0x40,199PLL_UNK41 = 0x41,200PLL_UNK42 = 0x42,201PLL_VPLL0 = 0x80,202PLL_VPLL1 = 0x81,203PLL_MAX = 0xff204};205206struct pll_lims {207u32 reg;208209struct {210int minfreq;211int maxfreq;212int min_inputfreq;213int max_inputfreq;214215uint8_t min_m;216uint8_t max_m;217uint8_t min_n;218uint8_t max_n;219} vco1, vco2;220221uint8_t max_log2p;222/*223* for most pre nv50 cards setting a log2P of 7 (the common max_log2p224* value) is no different to 6 (at least for vplls) so allowing the MNP225* calc to use 7 causes the generated clock to be out by a factor of 2.226* however, max_log2p cannot be fixed-up during parsing as the227* unmodified max_log2p value is still needed for setting mplls, hence228* an additional max_usable_log2p member229*/230uint8_t max_usable_log2p;231uint8_t log2p_bias;232233uint8_t min_p;234uint8_t max_p;235236int refclk;237};238239struct nvbios {240struct drm_device *dev;241enum {242NVBIOS_BMP,243NVBIOS_BIT244} type;245uint16_t offset;246247uint8_t chip_version;248249uint32_t dactestval;250uint32_t tvdactestval;251uint8_t digital_min_front_porch;252bool fp_no_ddc;253254spinlock_t lock;255256uint8_t data[NV_PROM_SIZE];257unsigned int length;258bool execute;259260uint8_t major_version;261uint8_t feature_byte;262bool is_mobile;263264uint32_t fmaxvco, fminvco;265266bool old_style_init;267uint16_t init_script_tbls_ptr;268uint16_t extra_init_script_tbl_ptr;269uint16_t macro_index_tbl_ptr;270uint16_t macro_tbl_ptr;271uint16_t condition_tbl_ptr;272uint16_t io_condition_tbl_ptr;273uint16_t io_flag_condition_tbl_ptr;274uint16_t init_function_tbl_ptr;275276uint16_t pll_limit_tbl_ptr;277uint16_t ram_restrict_tbl_ptr;278uint8_t ram_restrict_group_count;279280uint16_t some_script_ptr; /* BIT I + 14 */281uint16_t init96_tbl_ptr; /* BIT I + 16 */282283struct dcb_table dcb;284285struct {286int crtchead;287} state;288289struct {290struct dcb_entry *output;291uint16_t script_table_ptr;292uint16_t dp_table_ptr;293} display;294295struct {296uint16_t fptablepointer; /* also used by tmds */297uint16_t fpxlatetableptr;298int xlatwidth;299uint16_t lvdsmanufacturerpointer;300uint16_t fpxlatemanufacturertableptr;301uint16_t mode_ptr;302uint16_t xlated_entry;303bool power_off_for_reset;304bool reset_after_pclk_change;305bool dual_link;306bool link_c_increment;307bool if_is_24bit;308int duallink_transition_clk;309uint8_t strapless_is_24bit;310uint8_t *edid;311312/* will need resetting after suspend */313int last_script_invoc;314bool lvds_init_run;315} fp;316317struct {318uint16_t output0_script_ptr;319uint16_t output1_script_ptr;320} tmds;321322struct {323uint16_t mem_init_tbl_ptr;324uint16_t sdr_seq_tbl_ptr;325uint16_t ddr_seq_tbl_ptr;326327struct {328uint8_t crt, tv, panel;329} i2c_indices;330331uint16_t lvds_single_a_script_ptr;332} legacy;333};334335#endif336337338