Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2008 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Author: Stanislaw Skowronek
0023  */
0024 
0025 #ifndef ATOM_H
0026 #define ATOM_H
0027 
0028 #include <linux/types.h>
0029 
0030 struct drm_device;
0031 
0032 #define ATOM_BIOS_MAGIC     0xAA55
0033 #define ATOM_ATI_MAGIC_PTR  0x30
0034 #define ATOM_ATI_MAGIC      " 761295520"
0035 #define ATOM_ROM_TABLE_PTR  0x48
0036 #define ATOM_ROM_PART_NUMBER_PTR    0x6E
0037 
0038 #define ATOM_ROM_MAGIC      "ATOM"
0039 #define ATOM_ROM_MAGIC_PTR  4
0040 
0041 #define ATOM_ROM_MSG_PTR    0x10
0042 #define ATOM_ROM_CMD_PTR    0x1E
0043 #define ATOM_ROM_DATA_PTR   0x20
0044 
0045 #define ATOM_CMD_INIT       0
0046 #define ATOM_CMD_SETSCLK    0x0A
0047 #define ATOM_CMD_SETMCLK    0x0B
0048 #define ATOM_CMD_SETPCLK    0x0C
0049 #define ATOM_CMD_SPDFANCNTL 0x39
0050 
0051 #define ATOM_DATA_FWI_PTR   0xC
0052 #define ATOM_DATA_IIO_PTR   0x32
0053 
0054 #define ATOM_FWI_DEFSCLK_PTR    8
0055 #define ATOM_FWI_DEFMCLK_PTR    0xC
0056 #define ATOM_FWI_MAXSCLK_PTR    0x24
0057 #define ATOM_FWI_MAXMCLK_PTR    0x28
0058 
0059 #define ATOM_CT_SIZE_PTR    0
0060 #define ATOM_CT_WS_PTR      4
0061 #define ATOM_CT_PS_PTR      5
0062 #define ATOM_CT_PS_MASK     0x7F
0063 #define ATOM_CT_CODE_PTR    6
0064 
0065 #define ATOM_OP_CNT     127
0066 #define ATOM_OP_EOT     91
0067 
0068 #define ATOM_CASE_MAGIC     0x63
0069 #define ATOM_CASE_END       0x5A5A
0070 
0071 #define ATOM_ARG_REG        0
0072 #define ATOM_ARG_PS     1
0073 #define ATOM_ARG_WS     2
0074 #define ATOM_ARG_FB     3
0075 #define ATOM_ARG_ID     4
0076 #define ATOM_ARG_IMM        5
0077 #define ATOM_ARG_PLL        6
0078 #define ATOM_ARG_MC     7
0079 
0080 #define ATOM_SRC_DWORD      0
0081 #define ATOM_SRC_WORD0      1
0082 #define ATOM_SRC_WORD8      2
0083 #define ATOM_SRC_WORD16     3
0084 #define ATOM_SRC_BYTE0      4
0085 #define ATOM_SRC_BYTE8      5
0086 #define ATOM_SRC_BYTE16     6
0087 #define ATOM_SRC_BYTE24     7
0088 
0089 #define ATOM_WS_QUOTIENT    0x40
0090 #define ATOM_WS_REMAINDER   0x41
0091 #define ATOM_WS_DATAPTR     0x42
0092 #define ATOM_WS_SHIFT       0x43
0093 #define ATOM_WS_OR_MASK     0x44
0094 #define ATOM_WS_AND_MASK    0x45
0095 #define ATOM_WS_FB_WINDOW   0x46
0096 #define ATOM_WS_ATTRIBUTES  0x47
0097 #define ATOM_WS_REGPTR      0x48
0098 
0099 #define ATOM_IIO_NOP        0
0100 #define ATOM_IIO_START      1
0101 #define ATOM_IIO_READ       2
0102 #define ATOM_IIO_WRITE      3
0103 #define ATOM_IIO_CLEAR      4
0104 #define ATOM_IIO_SET        5
0105 #define ATOM_IIO_MOVE_INDEX 6
0106 #define ATOM_IIO_MOVE_ATTR  7
0107 #define ATOM_IIO_MOVE_DATA  8
0108 #define ATOM_IIO_END        9
0109 
0110 #define ATOM_IO_MM      0
0111 #define ATOM_IO_PCI     1
0112 #define ATOM_IO_SYSIO       2
0113 #define ATOM_IO_IIO     0x80
0114 
0115 #define STRLEN_NORMAL       32
0116 #define STRLEN_LONG     64
0117 #define STRLEN_VERYLONG     254
0118 
0119 struct card_info {
0120     struct drm_device *dev;
0121     void (* reg_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
0122     uint32_t (* reg_read)(struct card_info *, uint32_t);          /*  filled by driver */
0123     void (* mc_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
0124     uint32_t (* mc_read)(struct card_info *, uint32_t);          /*  filled by driver */
0125     void (* pll_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
0126     uint32_t (* pll_read)(struct card_info *, uint32_t);          /*  filled by driver */
0127 };
0128 
0129 struct atom_context {
0130     struct card_info *card;
0131     struct mutex mutex;
0132     void *bios;
0133     uint32_t cmd_table, data_table;
0134     uint16_t *iio;
0135 
0136     uint16_t data_block;
0137     uint32_t fb_base;
0138     uint32_t divmul[2];
0139     uint16_t io_attr;
0140     uint16_t reg_block;
0141     uint8_t shift;
0142     int cs_equal, cs_above;
0143     int io_mode;
0144     uint32_t *scratch;
0145     int scratch_size_bytes;
0146     char vbios_version[20];
0147 
0148     uint8_t name[STRLEN_LONG];
0149     uint8_t vbios_pn[STRLEN_LONG];
0150     uint32_t version;
0151     uint8_t vbios_ver_str[STRLEN_NORMAL];
0152     uint8_t date[STRLEN_NORMAL];
0153 };
0154 
0155 extern int amdgpu_atom_debug;
0156 
0157 struct atom_context *amdgpu_atom_parse(struct card_info *, void *);
0158 int amdgpu_atom_execute_table(struct atom_context *, int, uint32_t *);
0159 int amdgpu_atom_asic_init(struct atom_context *);
0160 void amdgpu_atom_destroy(struct atom_context *);
0161 bool amdgpu_atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
0162                 uint8_t *frev, uint8_t *crev, uint16_t *data_start);
0163 bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index,
0164                uint8_t *frev, uint8_t *crev);
0165 #include "atom-types.h"
0166 #include "atombios.h"
0167 #include "ObjectID.h"
0168 
0169 #endif