1926deccbSFrançois Tigeot /* 2926deccbSFrançois Tigeot * Copyright 2008 Advanced Micro Devices, Inc. 3926deccbSFrançois Tigeot * 4926deccbSFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a 5926deccbSFrançois Tigeot * copy of this software and associated documentation files (the "Software"), 6926deccbSFrançois Tigeot * to deal in the Software without restriction, including without limitation 7926deccbSFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8926deccbSFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the 9926deccbSFrançois Tigeot * Software is furnished to do so, subject to the following conditions: 10926deccbSFrançois Tigeot * 11926deccbSFrançois Tigeot * The above copyright notice and this permission notice shall be included in 12926deccbSFrançois Tigeot * all copies or substantial portions of the Software. 13926deccbSFrançois Tigeot * 14926deccbSFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15926deccbSFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16926deccbSFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17926deccbSFrançois Tigeot * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18926deccbSFrançois Tigeot * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19926deccbSFrançois Tigeot * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20926deccbSFrançois Tigeot * OTHER DEALINGS IN THE SOFTWARE. 21926deccbSFrançois Tigeot * 22926deccbSFrançois Tigeot * Author: Stanislaw Skowronek 23926deccbSFrançois Tigeot */ 24926deccbSFrançois Tigeot 25926deccbSFrançois Tigeot #ifndef ATOM_H 26926deccbSFrançois Tigeot #define ATOM_H 27926deccbSFrançois Tigeot 28a39b2473SFrançois Tigeot #include <linux/types.h> 29926deccbSFrançois Tigeot #include <drm/drmP.h> 30926deccbSFrançois Tigeot 31926deccbSFrançois Tigeot #define ATOM_BIOS_MAGIC 0xAA55 32926deccbSFrançois Tigeot #define ATOM_ATI_MAGIC_PTR 0x30 33926deccbSFrançois Tigeot #define ATOM_ATI_MAGIC " 761295520" 34926deccbSFrançois Tigeot #define ATOM_ROM_TABLE_PTR 0x48 35926deccbSFrançois Tigeot 36926deccbSFrançois Tigeot #define ATOM_ROM_MAGIC "ATOM" 37926deccbSFrançois Tigeot #define ATOM_ROM_MAGIC_PTR 4 38926deccbSFrançois Tigeot 39926deccbSFrançois Tigeot #define ATOM_ROM_MSG_PTR 0x10 40926deccbSFrançois Tigeot #define ATOM_ROM_CMD_PTR 0x1E 41926deccbSFrançois Tigeot #define ATOM_ROM_DATA_PTR 0x20 42926deccbSFrançois Tigeot 43926deccbSFrançois Tigeot #define ATOM_CMD_INIT 0 44926deccbSFrançois Tigeot #define ATOM_CMD_SETSCLK 0x0A 45926deccbSFrançois Tigeot #define ATOM_CMD_SETMCLK 0x0B 46926deccbSFrançois Tigeot #define ATOM_CMD_SETPCLK 0x0C 47926deccbSFrançois Tigeot #define ATOM_CMD_SPDFANCNTL 0x39 48926deccbSFrançois Tigeot 49926deccbSFrançois Tigeot #define ATOM_DATA_FWI_PTR 0xC 50926deccbSFrançois Tigeot #define ATOM_DATA_IIO_PTR 0x32 51926deccbSFrançois Tigeot 52926deccbSFrançois Tigeot #define ATOM_FWI_DEFSCLK_PTR 8 53926deccbSFrançois Tigeot #define ATOM_FWI_DEFMCLK_PTR 0xC 54926deccbSFrançois Tigeot #define ATOM_FWI_MAXSCLK_PTR 0x24 55926deccbSFrançois Tigeot #define ATOM_FWI_MAXMCLK_PTR 0x28 56926deccbSFrançois Tigeot 57926deccbSFrançois Tigeot #define ATOM_CT_SIZE_PTR 0 58926deccbSFrançois Tigeot #define ATOM_CT_WS_PTR 4 59926deccbSFrançois Tigeot #define ATOM_CT_PS_PTR 5 60926deccbSFrançois Tigeot #define ATOM_CT_PS_MASK 0x7F 61926deccbSFrançois Tigeot #define ATOM_CT_CODE_PTR 6 62926deccbSFrançois Tigeot 63926deccbSFrançois Tigeot #define ATOM_OP_CNT 123 64926deccbSFrançois Tigeot #define ATOM_OP_EOT 91 65926deccbSFrançois Tigeot 66926deccbSFrançois Tigeot #define ATOM_CASE_MAGIC 0x63 67926deccbSFrançois Tigeot #define ATOM_CASE_END 0x5A5A 68926deccbSFrançois Tigeot 69926deccbSFrançois Tigeot #define ATOM_ARG_REG 0 70926deccbSFrançois Tigeot #define ATOM_ARG_PS 1 71926deccbSFrançois Tigeot #define ATOM_ARG_WS 2 72926deccbSFrançois Tigeot #define ATOM_ARG_FB 3 73926deccbSFrançois Tigeot #define ATOM_ARG_ID 4 74926deccbSFrançois Tigeot #define ATOM_ARG_IMM 5 75926deccbSFrançois Tigeot #define ATOM_ARG_PLL 6 76926deccbSFrançois Tigeot #define ATOM_ARG_MC 7 77926deccbSFrançois Tigeot 78926deccbSFrançois Tigeot #define ATOM_SRC_DWORD 0 79926deccbSFrançois Tigeot #define ATOM_SRC_WORD0 1 80926deccbSFrançois Tigeot #define ATOM_SRC_WORD8 2 81926deccbSFrançois Tigeot #define ATOM_SRC_WORD16 3 82926deccbSFrançois Tigeot #define ATOM_SRC_BYTE0 4 83926deccbSFrançois Tigeot #define ATOM_SRC_BYTE8 5 84926deccbSFrançois Tigeot #define ATOM_SRC_BYTE16 6 85926deccbSFrançois Tigeot #define ATOM_SRC_BYTE24 7 86926deccbSFrançois Tigeot 87926deccbSFrançois Tigeot #define ATOM_WS_QUOTIENT 0x40 88926deccbSFrançois Tigeot #define ATOM_WS_REMAINDER 0x41 89926deccbSFrançois Tigeot #define ATOM_WS_DATAPTR 0x42 90926deccbSFrançois Tigeot #define ATOM_WS_SHIFT 0x43 91926deccbSFrançois Tigeot #define ATOM_WS_OR_MASK 0x44 92926deccbSFrançois Tigeot #define ATOM_WS_AND_MASK 0x45 93926deccbSFrançois Tigeot #define ATOM_WS_FB_WINDOW 0x46 94926deccbSFrançois Tigeot #define ATOM_WS_ATTRIBUTES 0x47 95926deccbSFrançois Tigeot #define ATOM_WS_REGPTR 0x48 96926deccbSFrançois Tigeot 97926deccbSFrançois Tigeot #define ATOM_IIO_NOP 0 98926deccbSFrançois Tigeot #define ATOM_IIO_START 1 99926deccbSFrançois Tigeot #define ATOM_IIO_READ 2 100926deccbSFrançois Tigeot #define ATOM_IIO_WRITE 3 101926deccbSFrançois Tigeot #define ATOM_IIO_CLEAR 4 102926deccbSFrançois Tigeot #define ATOM_IIO_SET 5 103926deccbSFrançois Tigeot #define ATOM_IIO_MOVE_INDEX 6 104926deccbSFrançois Tigeot #define ATOM_IIO_MOVE_ATTR 7 105926deccbSFrançois Tigeot #define ATOM_IIO_MOVE_DATA 8 106926deccbSFrançois Tigeot #define ATOM_IIO_END 9 107926deccbSFrançois Tigeot 108926deccbSFrançois Tigeot #define ATOM_IO_MM 0 109926deccbSFrançois Tigeot #define ATOM_IO_PCI 1 110926deccbSFrançois Tigeot #define ATOM_IO_SYSIO 2 111926deccbSFrançois Tigeot #define ATOM_IO_IIO 0x80 112926deccbSFrançois Tigeot 113926deccbSFrançois Tigeot struct card_info { 114926deccbSFrançois Tigeot struct drm_device *dev; 115926deccbSFrançois Tigeot void (* reg_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */ 116926deccbSFrançois Tigeot uint32_t (* reg_read)(struct card_info *, uint32_t); /* filled by driver */ 117926deccbSFrançois Tigeot void (* ioreg_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */ 118926deccbSFrançois Tigeot uint32_t (* ioreg_read)(struct card_info *, uint32_t); /* filled by driver */ 119926deccbSFrançois Tigeot void (* mc_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */ 120926deccbSFrançois Tigeot uint32_t (* mc_read)(struct card_info *, uint32_t); /* filled by driver */ 121926deccbSFrançois Tigeot void (* pll_write)(struct card_info *, uint32_t, uint32_t); /* filled by driver */ 122926deccbSFrançois Tigeot uint32_t (* pll_read)(struct card_info *, uint32_t); /* filled by driver */ 123926deccbSFrançois Tigeot }; 124926deccbSFrançois Tigeot 125926deccbSFrançois Tigeot struct atom_context { 126926deccbSFrançois Tigeot struct card_info *card; 127926deccbSFrançois Tigeot struct lock mutex; 128591d5043SFrançois Tigeot struct lock scratch_mutex; 129*a85cb24fSFrançois Tigeot void *bios; 130926deccbSFrançois Tigeot uint32_t cmd_table, data_table; 131926deccbSFrançois Tigeot uint16_t *iio; 132926deccbSFrançois Tigeot 133926deccbSFrançois Tigeot uint16_t data_block; 134926deccbSFrançois Tigeot uint32_t fb_base; 135926deccbSFrançois Tigeot uint32_t divmul[2]; 136926deccbSFrançois Tigeot uint16_t io_attr; 137926deccbSFrançois Tigeot uint16_t reg_block; 138926deccbSFrançois Tigeot uint8_t shift; 139926deccbSFrançois Tigeot int cs_equal, cs_above; 140926deccbSFrançois Tigeot int io_mode; 141926deccbSFrançois Tigeot uint32_t *scratch; 142926deccbSFrançois Tigeot int scratch_size_bytes; 143926deccbSFrançois Tigeot }; 144926deccbSFrançois Tigeot 145926deccbSFrançois Tigeot extern int atom_debug; 146926deccbSFrançois Tigeot 147926deccbSFrançois Tigeot struct atom_context *atom_parse(struct card_info *, void *); 148926deccbSFrançois Tigeot int atom_execute_table(struct atom_context *, int, uint32_t *); 149591d5043SFrançois Tigeot int atom_execute_table_scratch_unlocked(struct atom_context *, int, uint32_t *); 150926deccbSFrançois Tigeot int atom_asic_init(struct atom_context *); 151926deccbSFrançois Tigeot void atom_destroy(struct atom_context *); 152926deccbSFrançois Tigeot bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size, 153926deccbSFrançois Tigeot uint8_t *frev, uint8_t *crev, uint16_t *data_start); 154926deccbSFrançois Tigeot bool atom_parse_cmd_header(struct atom_context *ctx, int index, 155926deccbSFrançois Tigeot uint8_t *frev, uint8_t *crev); 156926deccbSFrançois Tigeot int atom_allocate_fb_scratch(struct atom_context *ctx); 157926deccbSFrançois Tigeot #include "atom-types.h" 158926deccbSFrançois Tigeot #include "atombios.h" 159926deccbSFrançois Tigeot #include "ObjectID.h" 160926deccbSFrançois Tigeot 161926deccbSFrançois Tigeot #endif 162