0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef ATOM_H
0026 #define ATOM_H
0027
0028 #include <linux/mutex.h>
0029 #include <linux/types.h>
0030
0031 #define ATOM_BIOS_MAGIC 0xAA55
0032 #define ATOM_ATI_MAGIC_PTR 0x30
0033 #define ATOM_ATI_MAGIC " 761295520"
0034 #define ATOM_ROM_TABLE_PTR 0x48
0035
0036 #define ATOM_ROM_MAGIC "ATOM"
0037 #define ATOM_ROM_MAGIC_PTR 4
0038
0039 #define ATOM_ROM_MSG_PTR 0x10
0040 #define ATOM_ROM_CMD_PTR 0x1E
0041 #define ATOM_ROM_DATA_PTR 0x20
0042
0043 #define ATOM_CMD_INIT 0
0044 #define ATOM_CMD_SETSCLK 0x0A
0045 #define ATOM_CMD_SETMCLK 0x0B
0046 #define ATOM_CMD_SETPCLK 0x0C
0047 #define ATOM_CMD_SPDFANCNTL 0x39
0048
0049 #define ATOM_DATA_FWI_PTR 0xC
0050 #define ATOM_DATA_IIO_PTR 0x32
0051
0052 #define ATOM_FWI_DEFSCLK_PTR 8
0053 #define ATOM_FWI_DEFMCLK_PTR 0xC
0054 #define ATOM_FWI_MAXSCLK_PTR 0x24
0055 #define ATOM_FWI_MAXMCLK_PTR 0x28
0056
0057 #define ATOM_CT_SIZE_PTR 0
0058 #define ATOM_CT_WS_PTR 4
0059 #define ATOM_CT_PS_PTR 5
0060 #define ATOM_CT_PS_MASK 0x7F
0061 #define ATOM_CT_CODE_PTR 6
0062
0063 #define ATOM_OP_CNT 123
0064 #define ATOM_OP_EOT 91
0065
0066 #define ATOM_CASE_MAGIC 0x63
0067 #define ATOM_CASE_END 0x5A5A
0068
0069 #define ATOM_ARG_REG 0
0070 #define ATOM_ARG_PS 1
0071 #define ATOM_ARG_WS 2
0072 #define ATOM_ARG_FB 3
0073 #define ATOM_ARG_ID 4
0074 #define ATOM_ARG_IMM 5
0075 #define ATOM_ARG_PLL 6
0076 #define ATOM_ARG_MC 7
0077
0078 #define ATOM_SRC_DWORD 0
0079 #define ATOM_SRC_WORD0 1
0080 #define ATOM_SRC_WORD8 2
0081 #define ATOM_SRC_WORD16 3
0082 #define ATOM_SRC_BYTE0 4
0083 #define ATOM_SRC_BYTE8 5
0084 #define ATOM_SRC_BYTE16 6
0085 #define ATOM_SRC_BYTE24 7
0086
0087 #define ATOM_WS_QUOTIENT 0x40
0088 #define ATOM_WS_REMAINDER 0x41
0089 #define ATOM_WS_DATAPTR 0x42
0090 #define ATOM_WS_SHIFT 0x43
0091 #define ATOM_WS_OR_MASK 0x44
0092 #define ATOM_WS_AND_MASK 0x45
0093 #define ATOM_WS_FB_WINDOW 0x46
0094 #define ATOM_WS_ATTRIBUTES 0x47
0095 #define ATOM_WS_REGPTR 0x48
0096
0097 #define ATOM_IIO_NOP 0
0098 #define ATOM_IIO_START 1
0099 #define ATOM_IIO_READ 2
0100 #define ATOM_IIO_WRITE 3
0101 #define ATOM_IIO_CLEAR 4
0102 #define ATOM_IIO_SET 5
0103 #define ATOM_IIO_MOVE_INDEX 6
0104 #define ATOM_IIO_MOVE_ATTR 7
0105 #define ATOM_IIO_MOVE_DATA 8
0106 #define ATOM_IIO_END 9
0107
0108 #define ATOM_IO_MM 0
0109 #define ATOM_IO_PCI 1
0110 #define ATOM_IO_SYSIO 2
0111 #define ATOM_IO_IIO 0x80
0112
0113 struct card_info {
0114 struct drm_device *dev;
0115 void (* reg_write)(struct card_info *, uint32_t, uint32_t);
0116 uint32_t (* reg_read)(struct card_info *, uint32_t);
0117 void (* ioreg_write)(struct card_info *, uint32_t, uint32_t);
0118 uint32_t (* ioreg_read)(struct card_info *, uint32_t);
0119 void (* mc_write)(struct card_info *, uint32_t, uint32_t);
0120 uint32_t (* mc_read)(struct card_info *, uint32_t);
0121 void (* pll_write)(struct card_info *, uint32_t, uint32_t);
0122 uint32_t (* pll_read)(struct card_info *, uint32_t);
0123 };
0124
0125 struct atom_context {
0126 struct card_info *card;
0127 struct mutex mutex;
0128 struct mutex scratch_mutex;
0129 void *bios;
0130 uint32_t cmd_table, data_table;
0131 uint16_t *iio;
0132
0133 uint16_t data_block;
0134 uint32_t fb_base;
0135 uint32_t divmul[2];
0136 uint16_t io_attr;
0137 uint16_t reg_block;
0138 uint8_t shift;
0139 int cs_equal, cs_above;
0140 int io_mode;
0141 uint32_t *scratch;
0142 int scratch_size_bytes;
0143 };
0144
0145 extern int atom_debug;
0146
0147 struct atom_context *atom_parse(struct card_info *, void *);
0148 int atom_execute_table(struct atom_context *, int, uint32_t *);
0149 int atom_execute_table_scratch_unlocked(struct atom_context *, int, uint32_t *);
0150 int atom_asic_init(struct atom_context *);
0151 void atom_destroy(struct atom_context *);
0152 bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
0153 uint8_t *frev, uint8_t *crev, uint16_t *data_start);
0154 bool atom_parse_cmd_header(struct atom_context *ctx, int index,
0155 uint8_t *frev, uint8_t *crev);
0156 int atom_allocate_fb_scratch(struct atom_context *ctx);
0157
0158 struct i2c_msg;
0159 struct i2c_adapter;
0160 int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
0161 struct i2c_msg *msgs, int num);
0162 u32 radeon_atom_hw_i2c_func(struct i2c_adapter *adap);
0163
0164 #include "atom-types.h"
0165 #include "atombios.h"
0166 #include "ObjectID.h"
0167
0168 #endif