Home | History | Annotate | Line # | Download | only in nouveau
      1  1.5  riastrad /*	$NetBSD: nouveau_bios.h,v 1.5 2021/12/18 23:45:32 riastradh Exp $	*/
      2  1.3  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2007-2008 Nouveau Project
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     14  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     15  1.1  riastrad  * Software.
     16  1.1  riastrad  *
     17  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  1.1  riastrad  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     21  1.1  riastrad  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     22  1.1  riastrad  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     23  1.1  riastrad  * DEALINGS IN THE SOFTWARE.
     24  1.1  riastrad  */
     25  1.1  riastrad 
     26  1.1  riastrad #ifndef __NOUVEAU_DISPBIOS_H__
     27  1.1  riastrad #define __NOUVEAU_DISPBIOS_H__
     28  1.1  riastrad 
     29  1.1  riastrad #define DCB_MAX_NUM_ENTRIES 16
     30  1.1  riastrad #define DCB_MAX_NUM_I2C_ENTRIES 16
     31  1.1  riastrad #define DCB_MAX_NUM_GPIO_ENTRIES 32
     32  1.1  riastrad #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
     33  1.1  riastrad 
     34  1.1  riastrad #define DCB_LOC_ON_CHIP 0
     35  1.1  riastrad 
     36  1.5  riastrad #define ROM16(x) get_unaligned_le16(&(x))
     37  1.5  riastrad #define ROM32(x) get_unaligned_le32(&(x))
     38  1.1  riastrad #define ROMPTR(d,x) ({            \
     39  1.1  riastrad 	struct nouveau_drm *drm = nouveau_drm((d)); \
     40  1.1  riastrad 	ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
     41  1.1  riastrad })
     42  1.1  riastrad 
     43  1.1  riastrad struct bit_entry {
     44  1.1  riastrad 	uint8_t  id;
     45  1.1  riastrad 	uint8_t  version;
     46  1.1  riastrad 	uint16_t length;
     47  1.1  riastrad 	uint16_t offset;
     48  1.1  riastrad 	uint8_t *data;
     49  1.1  riastrad };
     50  1.1  riastrad 
     51  1.1  riastrad int bit_table(struct drm_device *, u8 id, struct bit_entry *);
     52  1.1  riastrad 
     53  1.1  riastrad #include <subdev/bios/dcb.h>
     54  1.1  riastrad #include <subdev/bios/conn.h>
     55  1.1  riastrad 
     56  1.1  riastrad struct dcb_table {
     57  1.1  riastrad 	uint8_t version;
     58  1.1  riastrad 	int entries;
     59  1.1  riastrad 	struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
     60  1.1  riastrad };
     61  1.1  riastrad 
     62  1.1  riastrad enum nouveau_or {
     63  1.1  riastrad 	DCB_OUTPUT_A = (1 << 0),
     64  1.1  riastrad 	DCB_OUTPUT_B = (1 << 1),
     65  1.1  riastrad 	DCB_OUTPUT_C = (1 << 2)
     66  1.1  riastrad };
     67  1.1  riastrad 
     68  1.1  riastrad enum LVDS_script {
     69  1.1  riastrad 	/* Order *does* matter here */
     70  1.1  riastrad 	LVDS_INIT = 1,
     71  1.1  riastrad 	LVDS_RESET,
     72  1.1  riastrad 	LVDS_BACKLIGHT_ON,
     73  1.1  riastrad 	LVDS_BACKLIGHT_OFF,
     74  1.1  riastrad 	LVDS_PANEL_ON,
     75  1.1  riastrad 	LVDS_PANEL_OFF
     76  1.1  riastrad };
     77  1.1  riastrad 
     78  1.1  riastrad struct nvbios {
     79  1.1  riastrad 	struct drm_device *dev;
     80  1.1  riastrad 	enum {
     81  1.1  riastrad 		NVBIOS_BMP,
     82  1.1  riastrad 		NVBIOS_BIT
     83  1.1  riastrad 	} type;
     84  1.1  riastrad 	uint16_t offset;
     85  1.1  riastrad 	uint32_t length;
     86  1.1  riastrad 	uint8_t *data;
     87  1.1  riastrad 
     88  1.1  riastrad 	uint8_t chip_version;
     89  1.1  riastrad 
     90  1.1  riastrad 	uint32_t dactestval;
     91  1.1  riastrad 	uint32_t tvdactestval;
     92  1.1  riastrad 	uint8_t digital_min_front_porch;
     93  1.1  riastrad 	bool fp_no_ddc;
     94  1.1  riastrad 
     95  1.1  riastrad 	spinlock_t lock;
     96  1.1  riastrad 
     97  1.1  riastrad 	bool execute;
     98  1.1  riastrad 
     99  1.1  riastrad 	uint8_t major_version;
    100  1.1  riastrad 	uint8_t feature_byte;
    101  1.1  riastrad 	bool is_mobile;
    102  1.1  riastrad 
    103  1.1  riastrad 	uint32_t fmaxvco, fminvco;
    104  1.1  riastrad 
    105  1.1  riastrad 	bool old_style_init;
    106  1.1  riastrad 	uint16_t init_script_tbls_ptr;
    107  1.1  riastrad 	uint16_t extra_init_script_tbl_ptr;
    108  1.1  riastrad 
    109  1.1  riastrad 	uint16_t ram_restrict_tbl_ptr;
    110  1.1  riastrad 	uint8_t ram_restrict_group_count;
    111  1.1  riastrad 
    112  1.1  riastrad 	struct dcb_table dcb;
    113  1.1  riastrad 
    114  1.1  riastrad 	struct {
    115  1.1  riastrad 		int crtchead;
    116  1.1  riastrad 	} state;
    117  1.1  riastrad 
    118  1.1  riastrad 	struct {
    119  1.1  riastrad 		uint16_t fptablepointer;	/* also used by tmds */
    120  1.1  riastrad 		uint16_t fpxlatetableptr;
    121  1.1  riastrad 		int xlatwidth;
    122  1.1  riastrad 		uint16_t lvdsmanufacturerpointer;
    123  1.1  riastrad 		uint16_t fpxlatemanufacturertableptr;
    124  1.1  riastrad 		uint16_t mode_ptr;
    125  1.1  riastrad 		uint16_t xlated_entry;
    126  1.1  riastrad 		bool power_off_for_reset;
    127  1.1  riastrad 		bool reset_after_pclk_change;
    128  1.1  riastrad 		bool dual_link;
    129  1.1  riastrad 		bool link_c_increment;
    130  1.1  riastrad 		bool if_is_24bit;
    131  1.1  riastrad 		int duallink_transition_clk;
    132  1.1  riastrad 		uint8_t strapless_is_24bit;
    133  1.1  riastrad 		uint8_t *edid;
    134  1.1  riastrad 
    135  1.1  riastrad 		/* will need resetting after suspend */
    136  1.1  riastrad 		int last_script_invoc;
    137  1.1  riastrad 		bool lvds_init_run;
    138  1.1  riastrad 	} fp;
    139  1.1  riastrad 
    140  1.1  riastrad 	struct {
    141  1.1  riastrad 		uint16_t output0_script_ptr;
    142  1.1  riastrad 		uint16_t output1_script_ptr;
    143  1.1  riastrad 	} tmds;
    144  1.1  riastrad 
    145  1.1  riastrad 	struct {
    146  1.1  riastrad 		uint16_t mem_init_tbl_ptr;
    147  1.1  riastrad 		uint16_t sdr_seq_tbl_ptr;
    148  1.1  riastrad 		uint16_t ddr_seq_tbl_ptr;
    149  1.1  riastrad 
    150  1.1  riastrad 		struct {
    151  1.1  riastrad 			uint8_t crt, tv, panel;
    152  1.1  riastrad 		} i2c_indices;
    153  1.1  riastrad 
    154  1.1  riastrad 		uint16_t lvds_single_a_script_ptr;
    155  1.1  riastrad 	} legacy;
    156  1.1  riastrad };
    157  1.1  riastrad 
    158  1.1  riastrad void *olddcb_table(struct drm_device *);
    159  1.1  riastrad void *olddcb_outp(struct drm_device *, u8 idx);
    160  1.1  riastrad int olddcb_outp_foreach(struct drm_device *, void *data,
    161  1.1  riastrad 		     int (*)(struct drm_device *, void *, int idx, u8 *outp));
    162  1.1  riastrad u8 *olddcb_conntab(struct drm_device *);
    163  1.1  riastrad u8 *olddcb_conn(struct drm_device *, u8 idx);
    164  1.1  riastrad 
    165  1.1  riastrad int nouveau_bios_init(struct drm_device *);
    166  1.1  riastrad void nouveau_bios_takedown(struct drm_device *dev);
    167  1.1  riastrad int nouveau_run_vbios_init(struct drm_device *);
    168  1.1  riastrad struct dcb_connector_table_entry *
    169  1.1  riastrad nouveau_bios_connector_entry(struct drm_device *, int index);
    170  1.1  riastrad bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
    171  1.1  riastrad uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
    172  1.1  riastrad int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
    173  1.1  riastrad 					 bool *dl, bool *if_is_24bit);
    174  1.1  riastrad int run_tmds_table(struct drm_device *, struct dcb_output *,
    175  1.1  riastrad 			  int head, int pxclk);
    176  1.1  riastrad int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
    177  1.1  riastrad 			    enum LVDS_script, int pxclk);
    178  1.1  riastrad 
    179  1.1  riastrad #endif
    180