brintos

brintos / linux-shallow public Read only

0
0
Text · 5.1 KiB · 5bf06c0 Raw
169 lines · c
1/*2 * Copyright 2008 Advanced Micro Devices, Inc.3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 * and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18 * 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 OR20 * OTHER DEALINGS IN THE SOFTWARE.21 *22 * Author: Stanislaw Skowronek23 */24 25#ifndef ATOM_H26#define ATOM_H27 28#include <linux/mutex.h>29#include <linux/types.h>30 31#define ATOM_BIOS_MAGIC		0xAA5532#define ATOM_ATI_MAGIC_PTR	0x3033#define ATOM_ATI_MAGIC		" 761295520"34#define ATOM_ROM_TABLE_PTR	0x4835 36#define ATOM_ROM_MAGIC		"ATOM"37#define ATOM_ROM_MAGIC_PTR	438 39#define ATOM_ROM_MSG_PTR	0x1040#define ATOM_ROM_CMD_PTR	0x1E41#define ATOM_ROM_DATA_PTR	0x2042 43#define ATOM_CMD_INIT		044#define ATOM_CMD_SETSCLK	0x0A45#define ATOM_CMD_SETMCLK	0x0B46#define ATOM_CMD_SETPCLK	0x0C47#define ATOM_CMD_SPDFANCNTL	0x3948 49#define ATOM_DATA_FWI_PTR	0xC50#define ATOM_DATA_IIO_PTR	0x3251 52#define ATOM_FWI_DEFSCLK_PTR	853#define ATOM_FWI_DEFMCLK_PTR	0xC54#define ATOM_FWI_MAXSCLK_PTR	0x2455#define ATOM_FWI_MAXMCLK_PTR	0x2856 57#define ATOM_CT_SIZE_PTR	058#define ATOM_CT_WS_PTR		459#define ATOM_CT_PS_PTR		560#define ATOM_CT_PS_MASK		0x7F61#define ATOM_CT_CODE_PTR	662 63#define ATOM_OP_CNT		12364#define ATOM_OP_EOT		9165 66#define ATOM_CASE_MAGIC		0x6367#define ATOM_CASE_END		0x5A5A68 69#define ATOM_ARG_REG		070#define ATOM_ARG_PS		171#define ATOM_ARG_WS		272#define ATOM_ARG_FB		373#define ATOM_ARG_ID		474#define ATOM_ARG_IMM		575#define ATOM_ARG_PLL		676#define ATOM_ARG_MC		777 78#define ATOM_SRC_DWORD		079#define ATOM_SRC_WORD0		180#define ATOM_SRC_WORD8		281#define ATOM_SRC_WORD16		382#define ATOM_SRC_BYTE0		483#define ATOM_SRC_BYTE8		584#define ATOM_SRC_BYTE16		685#define ATOM_SRC_BYTE24		786 87#define ATOM_WS_QUOTIENT	0x4088#define ATOM_WS_REMAINDER	0x4189#define ATOM_WS_DATAPTR		0x4290#define ATOM_WS_SHIFT		0x4391#define ATOM_WS_OR_MASK		0x4492#define ATOM_WS_AND_MASK	0x4593#define ATOM_WS_FB_WINDOW	0x4694#define ATOM_WS_ATTRIBUTES	0x4795#define ATOM_WS_REGPTR  	0x4896 97#define ATOM_IIO_NOP		098#define ATOM_IIO_START		199#define ATOM_IIO_READ		2100#define ATOM_IIO_WRITE		3101#define ATOM_IIO_CLEAR		4102#define ATOM_IIO_SET		5103#define ATOM_IIO_MOVE_INDEX	6104#define ATOM_IIO_MOVE_ATTR	7105#define ATOM_IIO_MOVE_DATA	8106#define ATOM_IIO_END		9107 108#define ATOM_IO_MM		0109#define ATOM_IO_PCI		1110#define ATOM_IO_SYSIO		2111#define ATOM_IO_IIO		0x80112 113struct card_info {114	struct drm_device *dev;115	void (* reg_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */116        uint32_t (* reg_read)(struct card_info *, uint32_t);          /*  filled by driver */117	void (* ioreg_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */118        uint32_t (* ioreg_read)(struct card_info *, uint32_t);          /*  filled by driver */119	void (* mc_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */120        uint32_t (* mc_read)(struct card_info *, uint32_t);          /*  filled by driver */121	void (* pll_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */122        uint32_t (* pll_read)(struct card_info *, uint32_t);          /*  filled by driver */123};124 125struct atom_context {126	struct card_info *card;127	struct mutex mutex;128	struct mutex scratch_mutex;129	void *bios;130	uint32_t cmd_table, data_table;131	uint16_t *iio;132 133	uint16_t data_block;134	uint32_t fb_base;135	uint32_t divmul[2];136	uint16_t io_attr;137	uint16_t reg_block;138	uint8_t shift;139	int cs_equal, cs_above;140	int io_mode;141	uint32_t *scratch;142	int scratch_size_bytes;143};144 145extern int atom_debug;146 147struct atom_context *atom_parse(struct card_info *, void *);148int atom_execute_table(struct atom_context *, int, uint32_t *, int);149int atom_execute_table_scratch_unlocked(struct atom_context *, int, uint32_t *, int);150int atom_asic_init(struct atom_context *);151void atom_destroy(struct atom_context *);152bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,153			    uint8_t *frev, uint8_t *crev, uint16_t *data_start);154bool atom_parse_cmd_header(struct atom_context *ctx, int index,155			   uint8_t *frev, uint8_t *crev);156int atom_allocate_fb_scratch(struct atom_context *ctx);157 158struct i2c_msg;159struct i2c_adapter;160int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap,161			    struct i2c_msg *msgs, int num);162u32 radeon_atom_hw_i2c_func(struct i2c_adapter *adap);163 164#include "atom-types.h"165#include "atombios.h"166#include "ObjectID.h"167 168#endif169