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