Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Add DCN3 GPIO

Add support to program GPIO HW block

Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Bhawanpreet Lakha and committed by
Alex Deucher
666ed8bf 21f4809a

+738 -1
+10
drivers/gpu/drm/amd/display/dc/gpio/Makefile
··· 87 87 AMD_DISPLAY_FILES += $(AMD_DAL_GPIO_DCN21) 88 88 endif 89 89 ############################################################################### 90 + # DCN 3 91 + ############################################################################### 92 + ifdef CONFIG_DRM_AMD_DC_DCN3_0 93 + GPIO_DCN30 = hw_translate_dcn30.o hw_factory_dcn30.o 94 + 95 + AMD_DAL_GPIO_DCN30 = $(addprefix $(AMDDALPATH)/dc/gpio/dcn30/,$(GPIO_DCN30)) 96 + 97 + AMD_DISPLAY_FILES += $(AMD_DAL_GPIO_DCN30) 98 + endif 99 + ############################################################################### 90 100 # Diagnostics on FPGA 91 101 ############################################################################### 92 102 GPIO_DIAG_FPGA = hw_translate_diag.o hw_factory_diag.o
+257
drivers/gpu/drm/amd/display/dc/gpio/dcn30/hw_factory_dcn30.c
··· 1 + /* 2 + * Copyright 2020 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 + * Authors: AMD 23 + * 24 + */ 25 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 26 + #include "dm_services.h" 27 + #include "include/gpio_types.h" 28 + #include "../hw_factory.h" 29 + 30 + 31 + #include "../hw_gpio.h" 32 + #include "../hw_ddc.h" 33 + #include "../hw_hpd.h" 34 + #include "../hw_generic.h" 35 + 36 + #include "hw_factory_dcn30.h" 37 + 38 + 39 + #include "sienna_cichlid_ip_offset.h" 40 + #include "dcn/dcn_3_0_0_offset.h" 41 + #include "dcn/dcn_3_0_0_sh_mask.h" 42 + 43 + #include "nbio/nbio_7_4_offset.h" 44 + 45 + #include "dcn/dpcs_3_0_0_offset.h" 46 + #include "dcn/dpcs_3_0_0_sh_mask.h" 47 + 48 + #include "mmhub/mmhub_2_0_0_offset.h" 49 + #include "mmhub/mmhub_2_0_0_sh_mask.h" 50 + 51 + #include "reg_helper.h" 52 + #include "../hpd_regs.h" 53 + /* begin ********************* 54 + * macros to expend register list macro defined in HW object header file */ 55 + 56 + /* DCN */ 57 + #define block HPD 58 + #define reg_num 0 59 + 60 + #undef BASE_INNER 61 + #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg 62 + 63 + #define BASE(seg) BASE_INNER(seg) 64 + 65 + 66 + 67 + #define REG(reg_name)\ 68 + BASE(mm ## reg_name ## _BASE_IDX) + mm ## reg_name 69 + 70 + #define SF_HPD(reg_name, field_name, post_fix)\ 71 + .field_name = HPD0_ ## reg_name ## __ ## field_name ## post_fix 72 + 73 + #define REGI(reg_name, block, id)\ 74 + BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 75 + mm ## block ## id ## _ ## reg_name 76 + 77 + #define SF(reg_name, field_name, post_fix)\ 78 + .field_name = reg_name ## __ ## field_name ## post_fix 79 + 80 + /* macros to expend register list macro defined in HW object header file 81 + * end *********************/ 82 + 83 + 84 + 85 + #define hpd_regs(id) \ 86 + {\ 87 + HPD_REG_LIST(id)\ 88 + } 89 + 90 + static const struct hpd_registers hpd_regs[] = { 91 + hpd_regs(0), 92 + hpd_regs(1), 93 + hpd_regs(2), 94 + hpd_regs(3), 95 + hpd_regs(4), 96 + hpd_regs(5), 97 + }; 98 + 99 + static const struct hpd_sh_mask hpd_shift = { 100 + HPD_MASK_SH_LIST(__SHIFT) 101 + }; 102 + 103 + static const struct hpd_sh_mask hpd_mask = { 104 + HPD_MASK_SH_LIST(_MASK) 105 + }; 106 + 107 + #include "../ddc_regs.h" 108 + 109 + /* set field name */ 110 + #define SF_DDC(reg_name, field_name, post_fix)\ 111 + .field_name = reg_name ## __ ## field_name ## post_fix 112 + 113 + static const struct ddc_registers ddc_data_regs_dcn[] = { 114 + ddc_data_regs_dcn2(1), 115 + ddc_data_regs_dcn2(2), 116 + ddc_data_regs_dcn2(3), 117 + ddc_data_regs_dcn2(4), 118 + ddc_data_regs_dcn2(5), 119 + ddc_data_regs_dcn2(6), 120 + }; 121 + 122 + static const struct ddc_registers ddc_clk_regs_dcn[] = { 123 + ddc_clk_regs_dcn2(1), 124 + ddc_clk_regs_dcn2(2), 125 + ddc_clk_regs_dcn2(3), 126 + ddc_clk_regs_dcn2(4), 127 + ddc_clk_regs_dcn2(5), 128 + ddc_clk_regs_dcn2(6), 129 + }; 130 + 131 + static const struct ddc_sh_mask ddc_shift[] = { 132 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 1), 133 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 2), 134 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 3), 135 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 4), 136 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 5), 137 + DDC_MASK_SH_LIST_DCN2(__SHIFT, 6) 138 + }; 139 + 140 + static const struct ddc_sh_mask ddc_mask[] = { 141 + DDC_MASK_SH_LIST_DCN2(_MASK, 1), 142 + DDC_MASK_SH_LIST_DCN2(_MASK, 2), 143 + DDC_MASK_SH_LIST_DCN2(_MASK, 3), 144 + DDC_MASK_SH_LIST_DCN2(_MASK, 4), 145 + DDC_MASK_SH_LIST_DCN2(_MASK, 5), 146 + DDC_MASK_SH_LIST_DCN2(_MASK, 6) 147 + }; 148 + 149 + #include "../generic_regs.h" 150 + 151 + /* set field name */ 152 + #define SF_GENERIC(reg_name, field_name, post_fix)\ 153 + .field_name = reg_name ## __ ## field_name ## post_fix 154 + 155 + #define generic_regs(id) \ 156 + {\ 157 + GENERIC_REG_LIST(id)\ 158 + } 159 + 160 + static const struct generic_registers generic_regs[] = { 161 + generic_regs(A), 162 + generic_regs(B), 163 + }; 164 + 165 + static const struct generic_sh_mask generic_shift[] = { 166 + GENERIC_MASK_SH_LIST(__SHIFT, A), 167 + GENERIC_MASK_SH_LIST(__SHIFT, B), 168 + }; 169 + 170 + static const struct generic_sh_mask generic_mask[] = { 171 + GENERIC_MASK_SH_LIST(_MASK, A), 172 + GENERIC_MASK_SH_LIST(_MASK, B), 173 + }; 174 + 175 + static void define_generic_registers(struct hw_gpio_pin *pin, uint32_t en) 176 + { 177 + struct hw_generic *generic = HW_GENERIC_FROM_BASE(pin); 178 + 179 + generic->regs = &generic_regs[en]; 180 + generic->shifts = &generic_shift[en]; 181 + generic->masks = &generic_mask[en]; 182 + generic->base.regs = &generic_regs[en].gpio; 183 + } 184 + 185 + static void define_ddc_registers( 186 + struct hw_gpio_pin *pin, 187 + uint32_t en) 188 + { 189 + struct hw_ddc *ddc = HW_DDC_FROM_BASE(pin); 190 + 191 + switch (pin->id) { 192 + case GPIO_ID_DDC_DATA: 193 + ddc->regs = &ddc_data_regs_dcn[en]; 194 + ddc->base.regs = &ddc_data_regs_dcn[en].gpio; 195 + break; 196 + case GPIO_ID_DDC_CLOCK: 197 + ddc->regs = &ddc_clk_regs_dcn[en]; 198 + ddc->base.regs = &ddc_clk_regs_dcn[en].gpio; 199 + break; 200 + default: 201 + ASSERT_CRITICAL(false); 202 + return; 203 + } 204 + 205 + ddc->shifts = &ddc_shift[en]; 206 + ddc->masks = &ddc_mask[en]; 207 + 208 + } 209 + 210 + static void define_hpd_registers(struct hw_gpio_pin *pin, uint32_t en) 211 + { 212 + struct hw_hpd *hpd = HW_HPD_FROM_BASE(pin); 213 + 214 + hpd->regs = &hpd_regs[en]; 215 + hpd->shifts = &hpd_shift; 216 + hpd->masks = &hpd_mask; 217 + hpd->base.regs = &hpd_regs[en].gpio; 218 + } 219 + 220 + 221 + /* fucntion table */ 222 + static const struct hw_factory_funcs funcs = { 223 + .init_ddc_data = dal_hw_ddc_init, 224 + .init_generic = dal_hw_generic_init, 225 + .init_hpd = dal_hw_hpd_init, 226 + .get_ddc_pin = dal_hw_ddc_get_pin, 227 + .get_hpd_pin = dal_hw_hpd_get_pin, 228 + .get_generic_pin = dal_hw_generic_get_pin, 229 + .define_hpd_registers = define_hpd_registers, 230 + .define_ddc_registers = define_ddc_registers, 231 + .define_generic_registers = define_generic_registers 232 + }; 233 + /* 234 + * dal_hw_factory_dcn10_init 235 + * 236 + * @brief 237 + * Initialize HW factory function pointers and pin info 238 + * 239 + * @param 240 + * struct hw_factory *factory - [out] struct of function pointers 241 + */ 242 + void dal_hw_factory_dcn30_init(struct hw_factory *factory) 243 + { 244 + /*TODO check ASIC CAPs*/ 245 + factory->number_of_pins[GPIO_ID_DDC_DATA] = 8; 246 + factory->number_of_pins[GPIO_ID_DDC_CLOCK] = 8; 247 + factory->number_of_pins[GPIO_ID_GENERIC] = 4; 248 + factory->number_of_pins[GPIO_ID_HPD] = 6; 249 + factory->number_of_pins[GPIO_ID_GPIO_PAD] = 28; 250 + factory->number_of_pins[GPIO_ID_VIP_PAD] = 0; 251 + factory->number_of_pins[GPIO_ID_SYNC] = 0; 252 + factory->number_of_pins[GPIO_ID_GSL] = 0;/*add this*/ 253 + 254 + factory->funcs = &funcs; 255 + } 256 + 257 + #endif
+33
drivers/gpu/drm/amd/display/dc/gpio/dcn30/hw_factory_dcn30.h
··· 1 + /* 2 + * Copyright 2020 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 + * Authors: AMD 23 + * 24 + */ 25 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 26 + #ifndef __DAL_HW_FACTORY_DCN30_H__ 27 + #define __DAL_HW_FACTORY_DCN30_H__ 28 + 29 + /* Initialize HW factory function pointers and pin info */ 30 + void dal_hw_factory_dcn30_init(struct hw_factory *factory); 31 + 32 + #endif /* __DAL_HW_FACTORY_DCN30_H__ */ 33 + #endif
+387
drivers/gpu/drm/amd/display/dc/gpio/dcn30/hw_translate_dcn30.c
··· 1 + /* 2 + * Copyright 2020 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 + * Authors: AMD 23 + * 24 + */ 25 + 26 + /* 27 + * Pre-requisites: headers required by header of this unit 28 + */ 29 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 30 + #include "hw_translate_dcn30.h" 31 + 32 + #include "dm_services.h" 33 + #include "include/gpio_types.h" 34 + #include "../hw_translate.h" 35 + 36 + 37 + #include "sienna_cichlid_ip_offset.h" 38 + #include "dcn/dcn_3_0_0_offset.h" 39 + #include "dcn/dcn_3_0_0_sh_mask.h" 40 + 41 + #include "nbio/nbio_7_4_offset.h" 42 + 43 + #include "dcn/dpcs_3_0_0_offset.h" 44 + #include "dcn/dpcs_3_0_0_sh_mask.h" 45 + 46 + #include "mmhub/mmhub_2_0_0_offset.h" 47 + #include "mmhub/mmhub_2_0_0_sh_mask.h" 48 + /* begin ********************* 49 + * macros to expend register list macro defined in HW object header file */ 50 + 51 + /* DCN */ 52 + #define block HPD 53 + #define reg_num 0 54 + 55 + #undef BASE_INNER 56 + #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg 57 + 58 + #define BASE(seg) BASE_INNER(seg) 59 + 60 + #undef REG 61 + #define REG(reg_name)\ 62 + BASE(mm ## reg_name ## _BASE_IDX) + mm ## reg_name 63 + #define SF_HPD(reg_name, field_name, post_fix)\ 64 + .field_name = reg_name ## __ ## field_name ## post_fix 65 + 66 + 67 + /* macros to expend register list macro defined in HW object header file 68 + * end *********************/ 69 + 70 + 71 + static bool offset_to_id( 72 + uint32_t offset, 73 + uint32_t mask, 74 + enum gpio_id *id, 75 + uint32_t *en) 76 + { 77 + switch (offset) { 78 + /* GENERIC */ 79 + case REG(DC_GPIO_GENERIC_A): 80 + *id = GPIO_ID_GENERIC; 81 + switch (mask) { 82 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICA_A_MASK: 83 + *en = GPIO_GENERIC_A; 84 + return true; 85 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICB_A_MASK: 86 + *en = GPIO_GENERIC_B; 87 + return true; 88 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICC_A_MASK: 89 + *en = GPIO_GENERIC_C; 90 + return true; 91 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICD_A_MASK: 92 + *en = GPIO_GENERIC_D; 93 + return true; 94 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICE_A_MASK: 95 + *en = GPIO_GENERIC_E; 96 + return true; 97 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICF_A_MASK: 98 + *en = GPIO_GENERIC_F; 99 + return true; 100 + case DC_GPIO_GENERIC_A__DC_GPIO_GENERICG_A_MASK: 101 + *en = GPIO_GENERIC_G; 102 + return true; 103 + default: 104 + ASSERT_CRITICAL(false); 105 + return false; 106 + } 107 + break; 108 + /* HPD */ 109 + case REG(DC_GPIO_HPD_A): 110 + *id = GPIO_ID_HPD; 111 + switch (mask) { 112 + case DC_GPIO_HPD_A__DC_GPIO_HPD1_A_MASK: 113 + *en = GPIO_HPD_1; 114 + return true; 115 + case DC_GPIO_HPD_A__DC_GPIO_HPD2_A_MASK: 116 + *en = GPIO_HPD_2; 117 + return true; 118 + case DC_GPIO_HPD_A__DC_GPIO_HPD3_A_MASK: 119 + *en = GPIO_HPD_3; 120 + return true; 121 + case DC_GPIO_HPD_A__DC_GPIO_HPD4_A_MASK: 122 + *en = GPIO_HPD_4; 123 + return true; 124 + case DC_GPIO_HPD_A__DC_GPIO_HPD5_A_MASK: 125 + *en = GPIO_HPD_5; 126 + return true; 127 + case DC_GPIO_HPD_A__DC_GPIO_HPD6_A_MASK: 128 + *en = GPIO_HPD_6; 129 + return true; 130 + default: 131 + ASSERT_CRITICAL(false); 132 + return false; 133 + } 134 + break; 135 + /* REG(DC_GPIO_GENLK_MASK */ 136 + case REG(DC_GPIO_GENLK_A): 137 + *id = GPIO_ID_GSL; 138 + switch (mask) { 139 + case DC_GPIO_GENLK_A__DC_GPIO_GENLK_CLK_A_MASK: 140 + *en = GPIO_GSL_GENLOCK_CLOCK; 141 + return true; 142 + case DC_GPIO_GENLK_A__DC_GPIO_GENLK_VSYNC_A_MASK: 143 + *en = GPIO_GSL_GENLOCK_VSYNC; 144 + return true; 145 + case DC_GPIO_GENLK_A__DC_GPIO_SWAPLOCK_A_A_MASK: 146 + *en = GPIO_GSL_SWAPLOCK_A; 147 + return true; 148 + case DC_GPIO_GENLK_A__DC_GPIO_SWAPLOCK_B_A_MASK: 149 + *en = GPIO_GSL_SWAPLOCK_B; 150 + return true; 151 + default: 152 + ASSERT_CRITICAL(false); 153 + return false; 154 + } 155 + break; 156 + /* DDC */ 157 + /* we don't care about the GPIO_ID for DDC 158 + * in DdcHandle it will use GPIO_ID_DDC_DATA/GPIO_ID_DDC_CLOCK 159 + * directly in the create method */ 160 + case REG(DC_GPIO_DDC1_A): 161 + *en = GPIO_DDC_LINE_DDC1; 162 + return true; 163 + case REG(DC_GPIO_DDC2_A): 164 + *en = GPIO_DDC_LINE_DDC2; 165 + return true; 166 + case REG(DC_GPIO_DDC3_A): 167 + *en = GPIO_DDC_LINE_DDC3; 168 + return true; 169 + case REG(DC_GPIO_DDC4_A): 170 + *en = GPIO_DDC_LINE_DDC4; 171 + return true; 172 + case REG(DC_GPIO_DDC5_A): 173 + *en = GPIO_DDC_LINE_DDC5; 174 + return true; 175 + case REG(DC_GPIO_DDC6_A): 176 + *en = GPIO_DDC_LINE_DDC6; 177 + return true; 178 + case REG(DC_GPIO_DDCVGA_A): 179 + *en = GPIO_DDC_LINE_DDC_VGA; 180 + return true; 181 + 182 + // case REG(DC_GPIO_I2CPAD_A): not exit 183 + // case REG(DC_GPIO_PWRSEQ_A): 184 + // case REG(DC_GPIO_PAD_STRENGTH_1): 185 + // case REG(DC_GPIO_PAD_STRENGTH_2): 186 + // case REG(DC_GPIO_DEBUG): 187 + /* UNEXPECTED */ 188 + default: 189 + // case REG(DC_GPIO_SYNCA_A): not exist 190 + ASSERT_CRITICAL(false); 191 + return false; 192 + } 193 + } 194 + 195 + static bool id_to_offset( 196 + enum gpio_id id, 197 + uint32_t en, 198 + struct gpio_pin_info *info) 199 + { 200 + bool result = true; 201 + 202 + switch (id) { 203 + case GPIO_ID_DDC_DATA: 204 + info->mask = DC_GPIO_DDC6_A__DC_GPIO_DDC6DATA_A_MASK; 205 + switch (en) { 206 + case GPIO_DDC_LINE_DDC1: 207 + info->offset = REG(DC_GPIO_DDC1_A); 208 + break; 209 + case GPIO_DDC_LINE_DDC2: 210 + info->offset = REG(DC_GPIO_DDC2_A); 211 + break; 212 + case GPIO_DDC_LINE_DDC3: 213 + info->offset = REG(DC_GPIO_DDC3_A); 214 + break; 215 + case GPIO_DDC_LINE_DDC4: 216 + info->offset = REG(DC_GPIO_DDC4_A); 217 + break; 218 + case GPIO_DDC_LINE_DDC5: 219 + info->offset = REG(DC_GPIO_DDC5_A); 220 + break; 221 + case GPIO_DDC_LINE_DDC6: 222 + info->offset = REG(DC_GPIO_DDC6_A); 223 + break; 224 + case GPIO_DDC_LINE_DDC_VGA: 225 + info->offset = REG(DC_GPIO_DDCVGA_A); 226 + break; 227 + case GPIO_DDC_LINE_I2C_PAD: 228 + default: 229 + ASSERT_CRITICAL(false); 230 + result = false; 231 + } 232 + break; 233 + case GPIO_ID_DDC_CLOCK: 234 + info->mask = DC_GPIO_DDC6_A__DC_GPIO_DDC6CLK_A_MASK; 235 + switch (en) { 236 + case GPIO_DDC_LINE_DDC1: 237 + info->offset = REG(DC_GPIO_DDC1_A); 238 + break; 239 + case GPIO_DDC_LINE_DDC2: 240 + info->offset = REG(DC_GPIO_DDC2_A); 241 + break; 242 + case GPIO_DDC_LINE_DDC3: 243 + info->offset = REG(DC_GPIO_DDC3_A); 244 + break; 245 + case GPIO_DDC_LINE_DDC4: 246 + info->offset = REG(DC_GPIO_DDC4_A); 247 + break; 248 + case GPIO_DDC_LINE_DDC5: 249 + info->offset = REG(DC_GPIO_DDC5_A); 250 + break; 251 + case GPIO_DDC_LINE_DDC6: 252 + info->offset = REG(DC_GPIO_DDC6_A); 253 + break; 254 + case GPIO_DDC_LINE_DDC_VGA: 255 + info->offset = REG(DC_GPIO_DDCVGA_A); 256 + break; 257 + case GPIO_DDC_LINE_I2C_PAD: 258 + default: 259 + ASSERT_CRITICAL(false); 260 + result = false; 261 + } 262 + break; 263 + case GPIO_ID_GENERIC: 264 + info->offset = REG(DC_GPIO_GENERIC_A); 265 + switch (en) { 266 + case GPIO_GENERIC_A: 267 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICA_A_MASK; 268 + break; 269 + case GPIO_GENERIC_B: 270 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICB_A_MASK; 271 + break; 272 + case GPIO_GENERIC_C: 273 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICC_A_MASK; 274 + break; 275 + case GPIO_GENERIC_D: 276 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICD_A_MASK; 277 + break; 278 + case GPIO_GENERIC_E: 279 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICE_A_MASK; 280 + break; 281 + case GPIO_GENERIC_F: 282 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICF_A_MASK; 283 + break; 284 + case GPIO_GENERIC_G: 285 + info->mask = DC_GPIO_GENERIC_A__DC_GPIO_GENERICG_A_MASK; 286 + break; 287 + default: 288 + ASSERT_CRITICAL(false); 289 + result = false; 290 + } 291 + break; 292 + case GPIO_ID_HPD: 293 + info->offset = REG(DC_GPIO_HPD_A); 294 + switch (en) { 295 + case GPIO_HPD_1: 296 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD1_A_MASK; 297 + break; 298 + case GPIO_HPD_2: 299 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD2_A_MASK; 300 + break; 301 + case GPIO_HPD_3: 302 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD3_A_MASK; 303 + break; 304 + case GPIO_HPD_4: 305 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD4_A_MASK; 306 + break; 307 + case GPIO_HPD_5: 308 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD5_A_MASK; 309 + break; 310 + case GPIO_HPD_6: 311 + info->mask = DC_GPIO_HPD_A__DC_GPIO_HPD6_A_MASK; 312 + break; 313 + default: 314 + ASSERT_CRITICAL(false); 315 + result = false; 316 + } 317 + break; 318 + case GPIO_ID_GSL: 319 + switch (en) { 320 + case GPIO_GSL_GENLOCK_CLOCK: 321 + /*not implmented*/ 322 + ASSERT_CRITICAL(false); 323 + result = false; 324 + break; 325 + case GPIO_GSL_GENLOCK_VSYNC: 326 + /*not implmented*/ 327 + ASSERT_CRITICAL(false); 328 + result = false; 329 + break; 330 + case GPIO_GSL_SWAPLOCK_A: 331 + /*not implmented*/ 332 + ASSERT_CRITICAL(false); 333 + result = false; 334 + break; 335 + case GPIO_GSL_SWAPLOCK_B: 336 + /*not implmented*/ 337 + ASSERT_CRITICAL(false); 338 + result = false; 339 + 340 + break; 341 + default: 342 + ASSERT_CRITICAL(false); 343 + result = false; 344 + } 345 + break; 346 + case GPIO_ID_SYNC: 347 + case GPIO_ID_VIP_PAD: 348 + default: 349 + ASSERT_CRITICAL(false); 350 + result = false; 351 + } 352 + 353 + if (result) { 354 + info->offset_y = info->offset + 2; 355 + info->offset_en = info->offset + 1; 356 + info->offset_mask = info->offset - 1; 357 + 358 + info->mask_y = info->mask; 359 + info->mask_en = info->mask; 360 + info->mask_mask = info->mask; 361 + } 362 + 363 + return result; 364 + } 365 + 366 + /* function table */ 367 + static const struct hw_translate_funcs funcs = { 368 + .offset_to_id = offset_to_id, 369 + .id_to_offset = id_to_offset, 370 + }; 371 + 372 + /* 373 + * dal_hw_translate_dcn10_init 374 + * 375 + * @brief 376 + * Initialize Hw translate function pointers. 377 + * 378 + * @param 379 + * struct hw_translate *tr - [out] struct of function pointers 380 + * 381 + */ 382 + void dal_hw_translate_dcn30_init(struct hw_translate *tr) 383 + { 384 + tr->funcs = &funcs; 385 + } 386 + 387 + #endif
+35
drivers/gpu/drm/amd/display/dc/gpio/dcn30/hw_translate_dcn30.h
··· 1 + /* 2 + * Copyright 2020 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 + * Authors: AMD 23 + * 24 + */ 25 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 26 + #ifndef __DAL_HW_TRANSLATE_DCN30_H__ 27 + #define __DAL_HW_TRANSLATE_DCN30_H__ 28 + 29 + struct hw_translate; 30 + 31 + /* Initialize Hw translate function pointers */ 32 + void dal_hw_translate_dcn30_init(struct hw_translate *tr); 33 + 34 + #endif /* __DAL_HW_TRANSLATE_DCN30_H__ */ 35 + #endif
+8 -1
drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c
··· 50 50 #include "dcn20/hw_factory_dcn20.h" 51 51 #include "dcn21/hw_factory_dcn21.h" 52 52 #endif 53 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 54 + #include "dcn30/hw_factory_dcn30.h" 55 + #endif 53 56 54 57 #include "diagnostics/hw_factory_diag.h" 55 58 ··· 102 99 dal_hw_factory_dcn21_init(factory); 103 100 return true; 104 101 #endif 105 - 102 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 103 + case DCN_VERSION_3_0: 104 + dal_hw_factory_dcn30_init(factory); 105 + return true; 106 + #endif 106 107 default: 107 108 ASSERT_CRITICAL(false); 108 109 return false;
+8
drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c
··· 48 48 #include "dcn20/hw_translate_dcn20.h" 49 49 #include "dcn21/hw_translate_dcn21.h" 50 50 #endif 51 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 52 + #include "dcn30/hw_translate_dcn30.h" 53 + #endif 51 54 52 55 #include "diagnostics/hw_translate_diag.h" 53 56 ··· 95 92 return true; 96 93 case DCN_VERSION_2_1: 97 94 dal_hw_translate_dcn21_init(translate); 95 + return true; 96 + #endif 97 + #if defined(CONFIG_DRM_AMD_DC_DCN3_0) 98 + case DCN_VERSION_3_0: 99 + dal_hw_translate_dcn30_init(translate); 98 100 return true; 99 101 #endif 100 102