Linux Audio

Check our new training course

Linux kernel drivers training

Mar 31-Apr 9, 2025, special US time zones
Register
Loading...
v3.1
  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#include "drmP.h"
 30
 31#define ATOM_BIOS_MAGIC		0xAA55
 32#define ATOM_ATI_MAGIC_PTR	0x30
 33#define ATOM_ATI_MAGIC		" 761295520"
 34#define ATOM_ROM_TABLE_PTR	0x48
 35
 36#define ATOM_ROM_MAGIC		"ATOM"
 37#define ATOM_ROM_MAGIC_PTR	4
 38
 39#define ATOM_ROM_MSG_PTR	0x10
 40#define ATOM_ROM_CMD_PTR	0x1E
 41#define ATOM_ROM_DATA_PTR	0x20
 42
 43#define ATOM_CMD_INIT		0
 44#define ATOM_CMD_SETSCLK	0x0A
 45#define ATOM_CMD_SETMCLK	0x0B
 46#define ATOM_CMD_SETPCLK	0x0C
 
 47
 48#define ATOM_DATA_FWI_PTR	0xC
 49#define ATOM_DATA_IIO_PTR	0x32
 50
 51#define ATOM_FWI_DEFSCLK_PTR	8
 52#define ATOM_FWI_DEFMCLK_PTR	0xC
 53#define ATOM_FWI_MAXSCLK_PTR	0x24
 54#define ATOM_FWI_MAXMCLK_PTR	0x28
 55
 56#define ATOM_CT_SIZE_PTR	0
 57#define ATOM_CT_WS_PTR		4
 58#define ATOM_CT_PS_PTR		5
 59#define ATOM_CT_PS_MASK		0x7F
 60#define ATOM_CT_CODE_PTR	6
 61
 62#define ATOM_OP_CNT		123
 63#define ATOM_OP_EOT		91
 64
 65#define ATOM_CASE_MAGIC		0x63
 66#define ATOM_CASE_END		0x5A5A
 67
 68#define ATOM_ARG_REG		0
 69#define ATOM_ARG_PS		1
 70#define ATOM_ARG_WS		2
 71#define ATOM_ARG_FB		3
 72#define ATOM_ARG_ID		4
 73#define ATOM_ARG_IMM		5
 74#define ATOM_ARG_PLL		6
 75#define ATOM_ARG_MC		7
 76
 77#define ATOM_SRC_DWORD		0
 78#define ATOM_SRC_WORD0		1
 79#define ATOM_SRC_WORD8		2
 80#define ATOM_SRC_WORD16		3
 81#define ATOM_SRC_BYTE0		4
 82#define ATOM_SRC_BYTE8		5
 83#define ATOM_SRC_BYTE16		6
 84#define ATOM_SRC_BYTE24		7
 85
 86#define ATOM_WS_QUOTIENT	0x40
 87#define ATOM_WS_REMAINDER	0x41
 88#define ATOM_WS_DATAPTR		0x42
 89#define ATOM_WS_SHIFT		0x43
 90#define ATOM_WS_OR_MASK		0x44
 91#define ATOM_WS_AND_MASK	0x45
 92#define ATOM_WS_FB_WINDOW	0x46
 93#define ATOM_WS_ATTRIBUTES	0x47
 94#define ATOM_WS_REGPTR  	0x48
 95
 96#define ATOM_IIO_NOP		0
 97#define ATOM_IIO_START		1
 98#define ATOM_IIO_READ		2
 99#define ATOM_IIO_WRITE		3
100#define ATOM_IIO_CLEAR		4
101#define ATOM_IIO_SET		5
102#define ATOM_IIO_MOVE_INDEX	6
103#define ATOM_IIO_MOVE_ATTR	7
104#define ATOM_IIO_MOVE_DATA	8
105#define ATOM_IIO_END		9
106
107#define ATOM_IO_MM		0
108#define ATOM_IO_PCI		1
109#define ATOM_IO_SYSIO		2
110#define ATOM_IO_IIO		0x80
111
112struct card_info {
113	struct drm_device *dev;
114	void (* reg_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
115        uint32_t (* reg_read)(struct card_info *, uint32_t);          /*  filled by driver */
116	void (* ioreg_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
117        uint32_t (* ioreg_read)(struct card_info *, uint32_t);          /*  filled by driver */
118	void (* mc_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
119        uint32_t (* mc_read)(struct card_info *, uint32_t);          /*  filled by driver */
120	void (* pll_write)(struct card_info *, uint32_t, uint32_t);   /*  filled by driver */
121        uint32_t (* pll_read)(struct card_info *, uint32_t);          /*  filled by driver */
122};
123
124struct atom_context {
125	struct card_info *card;
126	struct mutex mutex;
 
127	void *bios;
128	uint32_t cmd_table, data_table;
129	uint16_t *iio;
130
131	uint16_t data_block;
132	uint32_t fb_base;
133	uint32_t divmul[2];
134	uint16_t io_attr;
135	uint16_t reg_block;
136	uint8_t shift;
137	int cs_equal, cs_above;
138	int io_mode;
139	uint32_t *scratch;
140	int scratch_size_bytes;
141};
142
143extern int atom_debug;
144
145struct atom_context *atom_parse(struct card_info *, void *);
146int atom_execute_table(struct atom_context *, int, uint32_t *);
 
147int atom_asic_init(struct atom_context *);
148void atom_destroy(struct atom_context *);
149bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
150			    uint8_t *frev, uint8_t *crev, uint16_t *data_start);
151bool atom_parse_cmd_header(struct atom_context *ctx, int index,
152			   uint8_t *frev, uint8_t *crev);
153int atom_allocate_fb_scratch(struct atom_context *ctx);
 
 
 
 
 
 
 
154#include "atom-types.h"
155#include "atombios.h"
156#include "ObjectID.h"
157
158#endif
v6.2
  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/mutex.h>
 29#include <linux/types.h>
 
 30
 31#define ATOM_BIOS_MAGIC		0xAA55
 32#define ATOM_ATI_MAGIC_PTR	0x30
 33#define ATOM_ATI_MAGIC		" 761295520"
 34#define ATOM_ROM_TABLE_PTR	0x48
 35
 36#define ATOM_ROM_MAGIC		"ATOM"
 37#define ATOM_ROM_MAGIC_PTR	4
 38
 39#define ATOM_ROM_MSG_PTR	0x10
 40#define ATOM_ROM_CMD_PTR	0x1E
 41#define ATOM_ROM_DATA_PTR	0x20
 42
 43#define ATOM_CMD_INIT		0
 44#define ATOM_CMD_SETSCLK	0x0A
 45#define ATOM_CMD_SETMCLK	0x0B
 46#define ATOM_CMD_SETPCLK	0x0C
 47#define ATOM_CMD_SPDFANCNTL	0x39
 48
 49#define ATOM_DATA_FWI_PTR	0xC
 50#define ATOM_DATA_IIO_PTR	0x32
 51
 52#define ATOM_FWI_DEFSCLK_PTR	8
 53#define ATOM_FWI_DEFMCLK_PTR	0xC
 54#define ATOM_FWI_MAXSCLK_PTR	0x24
 55#define ATOM_FWI_MAXMCLK_PTR	0x28
 56
 57#define ATOM_CT_SIZE_PTR	0
 58#define ATOM_CT_WS_PTR		4
 59#define ATOM_CT_PS_PTR		5
 60#define ATOM_CT_PS_MASK		0x7F
 61#define ATOM_CT_CODE_PTR	6
 62
 63#define ATOM_OP_CNT		123
 64#define ATOM_OP_EOT		91
 65
 66#define ATOM_CASE_MAGIC		0x63
 67#define ATOM_CASE_END		0x5A5A
 68
 69#define ATOM_ARG_REG		0
 70#define ATOM_ARG_PS		1
 71#define ATOM_ARG_WS		2
 72#define ATOM_ARG_FB		3
 73#define ATOM_ARG_ID		4
 74#define ATOM_ARG_IMM		5
 75#define ATOM_ARG_PLL		6
 76#define ATOM_ARG_MC		7
 77
 78#define ATOM_SRC_DWORD		0
 79#define ATOM_SRC_WORD0		1
 80#define ATOM_SRC_WORD8		2
 81#define ATOM_SRC_WORD16		3
 82#define ATOM_SRC_BYTE0		4
 83#define ATOM_SRC_BYTE8		5
 84#define ATOM_SRC_BYTE16		6
 85#define ATOM_SRC_BYTE24		7
 86
 87#define ATOM_WS_QUOTIENT	0x40
 88#define ATOM_WS_REMAINDER	0x41
 89#define ATOM_WS_DATAPTR		0x42
 90#define ATOM_WS_SHIFT		0x43
 91#define ATOM_WS_OR_MASK		0x44
 92#define ATOM_WS_AND_MASK	0x45
 93#define ATOM_WS_FB_WINDOW	0x46
 94#define ATOM_WS_ATTRIBUTES	0x47
 95#define ATOM_WS_REGPTR  	0x48
 96
 97#define ATOM_IIO_NOP		0
 98#define ATOM_IIO_START		1
 99#define ATOM_IIO_READ		2
100#define ATOM_IIO_WRITE		3
101#define ATOM_IIO_CLEAR		4
102#define ATOM_IIO_SET		5
103#define ATOM_IIO_MOVE_INDEX	6
104#define ATOM_IIO_MOVE_ATTR	7
105#define ATOM_IIO_MOVE_DATA	8
106#define ATOM_IIO_END		9
107
108#define ATOM_IO_MM		0
109#define ATOM_IO_PCI		1
110#define ATOM_IO_SYSIO		2
111#define ATOM_IO_IIO		0x80
112
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 *);
149int atom_execute_table_scratch_unlocked(struct atom_context *, int, uint32_t *);
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#endif