atom.h 4.8 KB

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