Home | History | Annotate | Line # | Download | only in src
      1 /*	$NetBSD: dmub_dcn20.h,v 1.2 2021/12/18 23:45:07 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2019 Advanced Micro Devices, Inc.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  * Authors: AMD
     25  *
     26  */
     27 
     28 #ifndef _DMUB_DCN20_H_
     29 #define _DMUB_DCN20_H_
     30 
     31 #include "../inc/dmub_types.h"
     32 
     33 struct dmub_srv;
     34 
     35 /* DCN20 register definitions. */
     36 
     37 #define DMUB_COMMON_REGS() \
     38 	DMUB_SR(DMCUB_CNTL) \
     39 	DMUB_SR(DMCUB_MEM_CNTL) \
     40 	DMUB_SR(DMCUB_SEC_CNTL) \
     41 	DMUB_SR(DMCUB_INBOX1_BASE_ADDRESS) \
     42 	DMUB_SR(DMCUB_INBOX1_SIZE) \
     43 	DMUB_SR(DMCUB_INBOX1_RPTR) \
     44 	DMUB_SR(DMCUB_INBOX1_WPTR) \
     45 	DMUB_SR(DMCUB_REGION3_CW0_OFFSET) \
     46 	DMUB_SR(DMCUB_REGION3_CW1_OFFSET) \
     47 	DMUB_SR(DMCUB_REGION3_CW2_OFFSET) \
     48 	DMUB_SR(DMCUB_REGION3_CW3_OFFSET) \
     49 	DMUB_SR(DMCUB_REGION3_CW4_OFFSET) \
     50 	DMUB_SR(DMCUB_REGION3_CW5_OFFSET) \
     51 	DMUB_SR(DMCUB_REGION3_CW6_OFFSET) \
     52 	DMUB_SR(DMCUB_REGION3_CW7_OFFSET) \
     53 	DMUB_SR(DMCUB_REGION3_CW0_OFFSET_HIGH) \
     54 	DMUB_SR(DMCUB_REGION3_CW1_OFFSET_HIGH) \
     55 	DMUB_SR(DMCUB_REGION3_CW2_OFFSET_HIGH) \
     56 	DMUB_SR(DMCUB_REGION3_CW3_OFFSET_HIGH) \
     57 	DMUB_SR(DMCUB_REGION3_CW4_OFFSET_HIGH) \
     58 	DMUB_SR(DMCUB_REGION3_CW5_OFFSET_HIGH) \
     59 	DMUB_SR(DMCUB_REGION3_CW6_OFFSET_HIGH) \
     60 	DMUB_SR(DMCUB_REGION3_CW7_OFFSET_HIGH) \
     61 	DMUB_SR(DMCUB_REGION3_CW0_BASE_ADDRESS) \
     62 	DMUB_SR(DMCUB_REGION3_CW1_BASE_ADDRESS) \
     63 	DMUB_SR(DMCUB_REGION3_CW2_BASE_ADDRESS) \
     64 	DMUB_SR(DMCUB_REGION3_CW3_BASE_ADDRESS) \
     65 	DMUB_SR(DMCUB_REGION3_CW4_BASE_ADDRESS) \
     66 	DMUB_SR(DMCUB_REGION3_CW5_BASE_ADDRESS) \
     67 	DMUB_SR(DMCUB_REGION3_CW6_BASE_ADDRESS) \
     68 	DMUB_SR(DMCUB_REGION3_CW7_BASE_ADDRESS) \
     69 	DMUB_SR(DMCUB_REGION3_CW0_TOP_ADDRESS) \
     70 	DMUB_SR(DMCUB_REGION3_CW1_TOP_ADDRESS) \
     71 	DMUB_SR(DMCUB_REGION3_CW2_TOP_ADDRESS) \
     72 	DMUB_SR(DMCUB_REGION3_CW3_TOP_ADDRESS) \
     73 	DMUB_SR(DMCUB_REGION3_CW4_TOP_ADDRESS) \
     74 	DMUB_SR(DMCUB_REGION3_CW5_TOP_ADDRESS) \
     75 	DMUB_SR(DMCUB_REGION3_CW6_TOP_ADDRESS) \
     76 	DMUB_SR(DMCUB_REGION3_CW7_TOP_ADDRESS) \
     77 	DMUB_SR(DMCUB_REGION4_OFFSET) \
     78 	DMUB_SR(DMCUB_REGION4_OFFSET_HIGH) \
     79 	DMUB_SR(DMCUB_REGION4_TOP_ADDRESS) \
     80 	DMUB_SR(DMCUB_SCRATCH0) \
     81 	DMUB_SR(DMCUB_SCRATCH1) \
     82 	DMUB_SR(DMCUB_SCRATCH2) \
     83 	DMUB_SR(DMCUB_SCRATCH3) \
     84 	DMUB_SR(DMCUB_SCRATCH4) \
     85 	DMUB_SR(DMCUB_SCRATCH5) \
     86 	DMUB_SR(DMCUB_SCRATCH6) \
     87 	DMUB_SR(DMCUB_SCRATCH7) \
     88 	DMUB_SR(DMCUB_SCRATCH8) \
     89 	DMUB_SR(DMCUB_SCRATCH9) \
     90 	DMUB_SR(DMCUB_SCRATCH10) \
     91 	DMUB_SR(DMCUB_SCRATCH11) \
     92 	DMUB_SR(DMCUB_SCRATCH12) \
     93 	DMUB_SR(DMCUB_SCRATCH13) \
     94 	DMUB_SR(DMCUB_SCRATCH14) \
     95 	DMUB_SR(DMCUB_SCRATCH15) \
     96 	DMUB_SR(CC_DC_PIPE_DIS) \
     97 	DMUB_SR(MMHUBBUB_SOFT_RESET) \
     98 	DMUB_SR(DCN_VM_FB_LOCATION_BASE) \
     99 	DMUB_SR(DCN_VM_FB_OFFSET)
    100 
    101 #define DMUB_COMMON_FIELDS() \
    102 	DMUB_SF(DMCUB_CNTL, DMCUB_ENABLE) \
    103 	DMUB_SF(DMCUB_CNTL, DMCUB_SOFT_RESET) \
    104 	DMUB_SF(DMCUB_CNTL, DMCUB_TRACEPORT_EN) \
    105 	DMUB_SF(DMCUB_MEM_CNTL, DMCUB_MEM_READ_SPACE) \
    106 	DMUB_SF(DMCUB_MEM_CNTL, DMCUB_MEM_WRITE_SPACE) \
    107 	DMUB_SF(DMCUB_SEC_CNTL, DMCUB_SEC_RESET) \
    108 	DMUB_SF(DMCUB_SEC_CNTL, DMCUB_MEM_UNIT_ID) \
    109 	DMUB_SF(DMCUB_REGION3_CW0_TOP_ADDRESS, DMCUB_REGION3_CW0_TOP_ADDRESS) \
    110 	DMUB_SF(DMCUB_REGION3_CW0_TOP_ADDRESS, DMCUB_REGION3_CW0_ENABLE) \
    111 	DMUB_SF(DMCUB_REGION3_CW1_TOP_ADDRESS, DMCUB_REGION3_CW1_TOP_ADDRESS) \
    112 	DMUB_SF(DMCUB_REGION3_CW1_TOP_ADDRESS, DMCUB_REGION3_CW1_ENABLE) \
    113 	DMUB_SF(DMCUB_REGION3_CW2_TOP_ADDRESS, DMCUB_REGION3_CW2_TOP_ADDRESS) \
    114 	DMUB_SF(DMCUB_REGION3_CW2_TOP_ADDRESS, DMCUB_REGION3_CW2_ENABLE) \
    115 	DMUB_SF(DMCUB_REGION3_CW3_TOP_ADDRESS, DMCUB_REGION3_CW3_TOP_ADDRESS) \
    116 	DMUB_SF(DMCUB_REGION3_CW3_TOP_ADDRESS, DMCUB_REGION3_CW3_ENABLE) \
    117 	DMUB_SF(DMCUB_REGION3_CW4_TOP_ADDRESS, DMCUB_REGION3_CW4_TOP_ADDRESS) \
    118 	DMUB_SF(DMCUB_REGION3_CW4_TOP_ADDRESS, DMCUB_REGION3_CW4_ENABLE) \
    119 	DMUB_SF(DMCUB_REGION3_CW5_TOP_ADDRESS, DMCUB_REGION3_CW5_TOP_ADDRESS) \
    120 	DMUB_SF(DMCUB_REGION3_CW5_TOP_ADDRESS, DMCUB_REGION3_CW5_ENABLE) \
    121 	DMUB_SF(DMCUB_REGION3_CW6_TOP_ADDRESS, DMCUB_REGION3_CW6_TOP_ADDRESS) \
    122 	DMUB_SF(DMCUB_REGION3_CW6_TOP_ADDRESS, DMCUB_REGION3_CW6_ENABLE) \
    123 	DMUB_SF(DMCUB_REGION3_CW7_TOP_ADDRESS, DMCUB_REGION3_CW7_TOP_ADDRESS) \
    124 	DMUB_SF(DMCUB_REGION3_CW7_TOP_ADDRESS, DMCUB_REGION3_CW7_ENABLE) \
    125 	DMUB_SF(DMCUB_REGION4_TOP_ADDRESS, DMCUB_REGION4_TOP_ADDRESS) \
    126 	DMUB_SF(DMCUB_REGION4_TOP_ADDRESS, DMCUB_REGION4_ENABLE) \
    127 	DMUB_SF(CC_DC_PIPE_DIS, DC_DMCUB_ENABLE) \
    128 	DMUB_SF(MMHUBBUB_SOFT_RESET, DMUIF_SOFT_RESET) \
    129 	DMUB_SF(DCN_VM_FB_LOCATION_BASE, FB_BASE) \
    130 	DMUB_SF(DCN_VM_FB_OFFSET, FB_OFFSET)
    131 
    132 struct dmub_srv_common_reg_offset {
    133 #define DMUB_SR(reg) uint32_t reg;
    134 	DMUB_COMMON_REGS()
    135 #undef DMUB_SR
    136 };
    137 
    138 struct dmub_srv_common_reg_shift {
    139 #define DMUB_SF(reg, field) uint8_t reg##__##field;
    140 	DMUB_COMMON_FIELDS()
    141 #undef DMUB_SF
    142 };
    143 
    144 struct dmub_srv_common_reg_mask {
    145 #define DMUB_SF(reg, field) uint32_t reg##__##field;
    146 	DMUB_COMMON_FIELDS()
    147 #undef DMUB_SF
    148 };
    149 
    150 struct dmub_srv_common_regs {
    151 	const struct dmub_srv_common_reg_offset offset;
    152 	const struct dmub_srv_common_reg_mask mask;
    153 	const struct dmub_srv_common_reg_shift shift;
    154 };
    155 
    156 extern const struct dmub_srv_common_regs dmub_srv_dcn20_regs;
    157 
    158 /* Hardware functions. */
    159 
    160 void dmub_dcn20_init(struct dmub_srv *dmub);
    161 
    162 void dmub_dcn20_reset(struct dmub_srv *dmub);
    163 
    164 void dmub_dcn20_reset_release(struct dmub_srv *dmub);
    165 
    166 void dmub_dcn20_backdoor_load(struct dmub_srv *dmub,
    167 			      const struct dmub_window *cw0,
    168 			      const struct dmub_window *cw1);
    169 
    170 void dmub_dcn20_setup_windows(struct dmub_srv *dmub,
    171 			      const struct dmub_window *cw2,
    172 			      const struct dmub_window *cw3,
    173 			      const struct dmub_window *cw4,
    174 			      const struct dmub_window *cw5,
    175 			      const struct dmub_window *cw6);
    176 
    177 void dmub_dcn20_setup_mailbox(struct dmub_srv *dmub,
    178 			      const struct dmub_region *inbox1);
    179 
    180 uint32_t dmub_dcn20_get_inbox1_rptr(struct dmub_srv *dmub);
    181 
    182 void dmub_dcn20_set_inbox1_wptr(struct dmub_srv *dmub, uint32_t wptr_offset);
    183 
    184 bool dmub_dcn20_is_hw_init(struct dmub_srv *dmub);
    185 
    186 bool dmub_dcn20_is_supported(struct dmub_srv *dmub);
    187 
    188 #endif /* _DMUB_DCN20_H_ */
    189