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