<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of sunpeng.li@amd.com <sunpeng.li@amd.com><br>
<b>Sent:</b> Friday, January 11, 2019 10:54:48 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Li, Sun peng (Leo); Francis, David; Wentland, Harry<br>
<b>Subject:</b> [PATCH] drm/amd/display: Fully remove i2caux folder</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">From: Leo Li <sunpeng.li@amd.com><br>
<br>
This is a follow up to:<br>
e28e1490794d ("drm/amd/display: Remove i2caux folder")<br>
<br>
Some files were still left, so delete all of them.<br>
<br>
CC: David Francis <David.Francis@amd.com><br>
CC: Harry Wentland <Harry.Wentland@amd.com><br>
Signed-off-by: Leo Li <sunpeng.li@amd.com><br>
---<br>
drivers/gpu/drm/amd/display/dc/i2caux/Makefile | 99 ----<br>
.../dc/i2caux/dce110/i2c_hw_engine_dce110.c | 573 ---------------------<br>
.../amd/display/dc/i2caux/dce112/i2caux_dce112.c | 129 -----<br>
.../amd/display/dc/i2caux/dce112/i2caux_dce112.h | 32 --<br>
.../display/dc/i2caux/dce80/i2c_sw_engine_dce80.c | 163 ------<br>
drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c | 491 ------------------<br>
6 files changed, 1487 deletions(-)<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/Makefile<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/dce110/i2c_hw_engine_dce110.c<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.c<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.h<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/dce80/i2c_sw_engine_dce80.c<br>
delete mode 100644 drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/Makefile b/drivers/gpu/drm/amd/display/dc/i2caux/Makefile<br>
deleted file mode 100644<br>
index 352885c..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/Makefile<br>
+++ /dev/null<br>
@@ -1,99 +0,0 @@<br>
-#<br>
-# Copyright 2017 Advanced Micro Devices, Inc.<br>
-#<br>
-# Permission is hereby granted, free of charge, to any person obtaining a<br>
-# copy of this software and associated documentation files (the "Software"),<br>
-# to deal in the Software without restriction, including without limitation<br>
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
-# and/or sell copies of the Software, and to permit persons to whom the<br>
-# Software is furnished to do so, subject to the following conditions:<br>
-#<br>
-# The above copyright notice and this permission notice shall be included in<br>
-# all copies or substantial portions of the Software.<br>
-#<br>
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
-# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
-# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
-# OTHER DEALINGS IN THE SOFTWARE.<br>
-#<br>
-#<br>
-# Makefile for the 'i2c' sub-component of DAL.<br>
-# It provides the control and status of HW i2c engine of the adapter.<br>
-<br>
-I2CAUX = aux_engine.o engine_base.o i2caux.o i2c_engine.o \<br>
- i2c_generic_hw_engine.o i2c_hw_engine.o i2c_sw_engine.o<br>
-<br>
-AMD_DAL_I2CAUX = $(addprefix $(AMDDALPATH)/dc/i2caux/,$(I2CAUX))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX)<br>
-<br>
-###############################################################################<br>
-# DCE 8x family<br>
-###############################################################################<br>
-I2CAUX_DCE80 = i2caux_dce80.o i2c_hw_engine_dce80.o \<br>
- i2c_sw_engine_dce80.o<br>
-<br>
-AMD_DAL_I2CAUX_DCE80 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce80/,$(I2CAUX_DCE80))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCE80)<br>
-<br>
-###############################################################################<br>
-# DCE 100 family<br>
-###############################################################################<br>
-I2CAUX_DCE100 = i2caux_dce100.o<br>
-<br>
-AMD_DAL_I2CAUX_DCE100 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce100/,$(I2CAUX_DCE100))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCE100)<br>
-<br>
-###############################################################################<br>
-# DCE 110 family<br>
-###############################################################################<br>
-I2CAUX_DCE110 = i2caux_dce110.o i2c_sw_engine_dce110.o i2c_hw_engine_dce110.o \<br>
- aux_engine_dce110.o<br>
-<br>
-AMD_DAL_I2CAUX_DCE110 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce110/,$(I2CAUX_DCE110))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCE110)<br>
-<br>
-###############################################################################<br>
-# DCE 112 family<br>
-###############################################################################<br>
-I2CAUX_DCE112 = i2caux_dce112.o<br>
-<br>
-AMD_DAL_I2CAUX_DCE112 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce112/,$(I2CAUX_DCE112))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCE112)<br>
-<br>
-###############################################################################<br>
-# DCN 1.0 family<br>
-###############################################################################<br>
-ifdef CONFIG_DRM_AMD_DC_DCN1_0<br>
-I2CAUX_DCN1 = i2caux_dcn10.o<br>
-<br>
-AMD_DAL_I2CAUX_DCN1 = $(addprefix $(AMDDALPATH)/dc/i2caux/dcn10/,$(I2CAUX_DCN1))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCN1)<br>
-endif<br>
-<br>
-###############################################################################<br>
-# DCE 120 family<br>
-###############################################################################<br>
-I2CAUX_DCE120 = i2caux_dce120.o<br>
-<br>
-AMD_DAL_I2CAUX_DCE120 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce120/,$(I2CAUX_DCE120))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DCE120)<br>
-<br>
-###############################################################################<br>
-# Diagnostics on FPGA<br>
-###############################################################################<br>
-I2CAUX_DIAG = i2caux_diag.o<br>
-<br>
-AMD_DAL_I2CAUX_DIAG = $(addprefix $(AMDDALPATH)/dc/i2caux/diagnostics/,$(I2CAUX_DIAG))<br>
-<br>
-AMD_DISPLAY_FILES += $(AMD_DAL_I2CAUX_DIAG)<br>
-<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/i2c_hw_engine_dce110.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/i2c_hw_engine_dce110.c<br>
deleted file mode 100644<br>
index 1373501..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/i2c_hw_engine_dce110.c<br>
+++ /dev/null<br>
@@ -1,573 +0,0 @@<br>
-/*<br>
- * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- *<br>
- * Authors: AMD<br>
- *<br>
- */<br>
-<br>
-#include "dm_services.h"<br>
-#include "include/logger_interface.h"<br>
-/*<br>
- * Pre-requisites: headers required by header of this unit<br>
- */<br>
-<br>
-#include "include/i2caux_interface.h"<br>
-#include "../engine.h"<br>
-#include "../i2c_engine.h"<br>
-#include "../i2c_hw_engine.h"<br>
-#include "../i2c_generic_hw_engine.h"<br>
-/*<br>
- * Header of this unit<br>
- */<br>
-<br>
-#include "i2c_hw_engine_dce110.h"<br>
-<br>
-/*<br>
- * Post-requisites: headers required by this unit<br>
- */<br>
-#include "reg_helper.h"<br>
-<br>
-/*<br>
- * This unit<br>
- */<br>
-#define DC_LOGGER \<br>
- hw_engine->base.base.base.ctx->logger<br>
-<br>
-enum dc_i2c_status {<br>
- DC_I2C_STATUS__DC_I2C_STATUS_IDLE,<br>
- DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_SW,<br>
- DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_HW<br>
-};<br>
-<br>
-enum dc_i2c_arbitration {<br>
- DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL,<br>
- DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_HIGH<br>
-};<br>
-<br>
-<br>
-<br>
-/*<br>
- * @brief<br>
- * Cast pointer to 'struct i2c_hw_engine *'<br>
- * to pointer 'struct i2c_hw_engine_dce110 *'<br>
- */<br>
-#define FROM_I2C_HW_ENGINE(ptr) \<br>
- container_of((ptr), struct i2c_hw_engine_dce110, base)<br>
-/*<br>
- * @brief<br>
- * Cast pointer to 'struct i2c_engine *'<br>
- * to pointer to 'struct i2c_hw_engine_dce110 *'<br>
- */<br>
-#define FROM_I2C_ENGINE(ptr) \<br>
- FROM_I2C_HW_ENGINE(container_of((ptr), struct i2c_hw_engine, base))<br>
-<br>
-/*<br>
- * @brief<br>
- * Cast pointer to 'struct engine *'<br>
- * to 'pointer to struct i2c_hw_engine_dce110 *'<br>
- */<br>
-#define FROM_ENGINE(ptr) \<br>
- FROM_I2C_ENGINE(container_of((ptr), struct i2c_engine, base))<br>
-<br>
-#define CTX \<br>
- hw_engine->base.base.base.ctx<br>
-<br>
-#define REG(reg_name)\<br>
- (hw_engine->regs->reg_name)<br>
-<br>
-#undef FN<br>
-#define FN(reg_name, field_name) \<br>
- hw_engine->i2c_shift->field_name, hw_engine->i2c_mask->field_name<br>
-<br>
-<br>
-static void disable_i2c_hw_engine(<br>
- struct i2c_hw_engine_dce110 *hw_engine)<br>
-{<br>
- REG_UPDATE_N(SETUP, 1, FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 0);<br>
-}<br>
-<br>
-static void release_engine(<br>
- struct engine *engine)<br>
-{<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_ENGINE(engine);<br>
-<br>
- struct i2c_engine *base = NULL;<br>
- bool safe_to_reset;<br>
-<br>
- base = &hw_engine->base.base;<br>
-<br>
- /* Restore original HW engine speed */<br>
-<br>
- base->funcs->set_speed(base, hw_engine->base.original_speed);<br>
-<br>
- /* Release I2C */<br>
- REG_UPDATE(DC_I2C_ARBITRATION, DC_I2C_SW_DONE_USING_I2C_REG, 1);<br>
-<br>
- /* Reset HW engine */<br>
- {<br>
- uint32_t i2c_sw_status = 0;<br>
- REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status);<br>
- /* if used by SW, safe to reset */<br>
- safe_to_reset = (i2c_sw_status == 1);<br>
- }<br>
-<br>
- if (safe_to_reset)<br>
- REG_UPDATE_2(<br>
- DC_I2C_CONTROL,<br>
- DC_I2C_SOFT_RESET, 1,<br>
- DC_I2C_SW_STATUS_RESET, 1);<br>
- else<br>
- REG_UPDATE(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, 1);<br>
-<br>
- /* HW I2c engine - clock gating feature */<br>
- if (!hw_engine->engine_keep_power_up_count)<br>
- disable_i2c_hw_engine(hw_engine);<br>
-}<br>
-<br>
-static bool setup_engine(<br>
- struct i2c_engine *i2c_engine)<br>
-{<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);<br>
- uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE;<br>
- uint32_t reset_length = 0;<br>
-<br>
- if (hw_engine->base.base.setup_limit != 0)<br>
- i2c_setup_limit = hw_engine->base.base.setup_limit;<br>
-<br>
- /* Program pin select */<br>
- REG_UPDATE_6(<br>
- DC_I2C_CONTROL,<br>
- DC_I2C_GO, 0,<br>
- DC_I2C_SOFT_RESET, 0,<br>
- DC_I2C_SEND_RESET, 0,<br>
- DC_I2C_SW_STATUS_RESET, 1,<br>
- DC_I2C_TRANSACTION_COUNT, 0,<br>
- DC_I2C_DDC_SELECT, hw_engine->engine_id);<br>
-<br>
- /* Program time limit */<br>
- if (hw_engine->base.base.send_reset_length == 0) {<br>
- /*pre-dcn*/<br>
- REG_UPDATE_N(<br>
- SETUP, 2,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), i2c_setup_limit,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1);<br>
- } else {<br>
- reset_length = hw_engine->base.base.send_reset_length;<br>
- }<br>
- /* Program HW priority<br>
- * set to High - interrupt software I2C at any time<br>
- * Enable restart of SW I2C that was interrupted by HW<br>
- * disable queuing of software while I2C is in use by HW */<br>
- REG_UPDATE_2(<br>
- DC_I2C_ARBITRATION,<br>
- DC_I2C_NO_QUEUED_SW_GO, 0,<br>
- DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL);<br>
-<br>
- return true;<br>
-}<br>
-<br>
-static uint32_t get_speed(<br>
- const struct i2c_engine *i2c_engine)<br>
-{<br>
- const struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);<br>
- uint32_t pre_scale = 0;<br>
-<br>
- REG_GET(SPEED, DC_I2C_DDC1_PRESCALE, &pre_scale);<br>
-<br>
- /* [anaumov] it seems following is unnecessary */<br>
- /*ASSERT(value.bits.DC_I2C_DDC1_PRESCALE);*/<br>
- return pre_scale ?<br>
- hw_engine->reference_frequency / pre_scale :<br>
- hw_engine->base.default_speed;<br>
-}<br>
-<br>
-static void set_speed(<br>
- struct i2c_engine *i2c_engine,<br>
- uint32_t speed)<br>
-{<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);<br>
-<br>
- if (speed) {<br>
- if (hw_engine->i2c_mask->DC_I2C_DDC1_START_STOP_TIMING_CNTL)<br>
- REG_UPDATE_N(<br>
- SPEED, 3,<br>
- FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), hw_engine->reference_frequency / speed,<br>
- FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2,<br>
- FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1);<br>
- else<br>
- REG_UPDATE_N(<br>
- SPEED, 2,<br>
- FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), hw_engine->reference_frequency / speed,<br>
- FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2);<br>
- }<br>
-}<br>
-<br>
-static inline void reset_hw_engine(struct engine *engine)<br>
-{<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_ENGINE(engine);<br>
-<br>
- REG_UPDATE_2(<br>
- DC_I2C_CONTROL,<br>
- DC_I2C_SW_STATUS_RESET, 1,<br>
- DC_I2C_SW_STATUS_RESET, 1);<br>
-}<br>
-<br>
-static bool is_hw_busy(struct engine *engine)<br>
-{<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_ENGINE(engine);<br>
- uint32_t i2c_sw_status = 0;<br>
-<br>
- REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status);<br>
- if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_IDLE)<br>
- return false;<br>
-<br>
- reset_hw_engine(engine);<br>
-<br>
- REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status);<br>
- return i2c_sw_status != DC_I2C_STATUS__DC_I2C_STATUS_IDLE;<br>
-}<br>
-<br>
-<br>
-#define STOP_TRANS_PREDICAT \<br>
- ((hw_engine->transaction_count == 3) || \<br>
- (request->action == I2CAUX_TRANSACTION_ACTION_I2C_WRITE) || \<br>
- (request->action & I2CAUX_TRANSACTION_ACTION_I2C_READ))<br>
-<br>
-#define SET_I2C_TRANSACTION(id) \<br>
- do { \<br>
- REG_UPDATE_N(DC_I2C_TRANSACTION##id, 5, \<br>
- FN(DC_I2C_TRANSACTION0, DC_I2C_STOP_ON_NACK0), 1, \<br>
- FN(DC_I2C_TRANSACTION0, DC_I2C_START0), 1, \<br>
- FN(DC_I2C_TRANSACTION0, DC_I2C_STOP0), STOP_TRANS_PREDICAT ? 1:0, \<br>
- FN(DC_I2C_TRANSACTION0, DC_I2C_RW0), (0 != (request->action & I2CAUX_TRANSACTION_ACTION_I2C_READ)), \<br>
- FN(DC_I2C_TRANSACTION0, DC_I2C_COUNT0), length); \<br>
- if (STOP_TRANS_PREDICAT) \<br>
- last_transaction = true; \<br>
- } while (false)<br>
-<br>
-<br>
-static bool process_transaction(<br>
- struct i2c_hw_engine_dce110 *hw_engine,<br>
- struct i2c_request_transaction_data *request)<br>
-{<br>
- uint32_t length = request->length;<br>
- uint8_t *buffer = request->data;<br>
- uint32_t value = 0;<br>
-<br>
- bool last_transaction = false;<br>
-<br>
- struct dc_context *ctx = NULL;<br>
-<br>
- ctx = hw_engine->base.base.base.ctx;<br>
-<br>
-<br>
-<br>
- switch (hw_engine->transaction_count) {<br>
- case 0:<br>
- SET_I2C_TRANSACTION(0);<br>
- break;<br>
- case 1:<br>
- SET_I2C_TRANSACTION(1);<br>
- break;<br>
- case 2:<br>
- SET_I2C_TRANSACTION(2);<br>
- break;<br>
- case 3:<br>
- SET_I2C_TRANSACTION(3);<br>
- break;<br>
- default:<br>
- /* TODO Warning ? */<br>
- break;<br>
- }<br>
-<br>
-<br>
- /* Write the I2C address and I2C data<br>
- * into the hardware circular buffer, one byte per entry.<br>
- * As an example, the 7-bit I2C slave address for CRT monitor<br>
- * for reading DDC/EDID information is 0b1010001.<br>
- * For an I2C send operation, the LSB must be programmed to 0;<br>
- * for I2C receive operation, the LSB must be programmed to 1. */<br>
- if (hw_engine->transaction_count == 0) {<br>
- value = REG_SET_4(DC_I2C_DATA, 0,<br>
- DC_I2C_DATA_RW, false,<br>
- DC_I2C_DATA, request->address,<br>
- DC_I2C_INDEX, 0,<br>
- DC_I2C_INDEX_WRITE, 1);<br>
- hw_engine->buffer_used_write = 0;<br>
- } else<br>
- value = REG_SET_2(DC_I2C_DATA, 0,<br>
- DC_I2C_DATA_RW, false,<br>
- DC_I2C_DATA, request->address);<br>
-<br>
- hw_engine->buffer_used_write++;<br>
-<br>
- if (!(request->action & I2CAUX_TRANSACTION_ACTION_I2C_READ)) {<br>
- while (length) {<br>
- REG_SET_2(DC_I2C_DATA, value,<br>
- DC_I2C_INDEX_WRITE, 0,<br>
- DC_I2C_DATA, *buffer++);<br>
- hw_engine->buffer_used_write++;<br>
- --length;<br>
- }<br>
- }<br>
-<br>
- ++hw_engine->transaction_count;<br>
- hw_engine->buffer_used_bytes += length + 1;<br>
-<br>
- return last_transaction;<br>
-}<br>
-<br>
-static void execute_transaction(<br>
- struct i2c_hw_engine_dce110 *hw_engine)<br>
-{<br>
- REG_UPDATE_N(SETUP, 5,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN), 0,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN), 0,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL), 0,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY), 0,<br>
- FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY), 0);<br>
-<br>
-<br>
- REG_UPDATE_5(DC_I2C_CONTROL,<br>
- DC_I2C_SOFT_RESET, 0,<br>
- DC_I2C_SW_STATUS_RESET, 0,<br>
- DC_I2C_SEND_RESET, 0,<br>
- DC_I2C_GO, 0,<br>
- DC_I2C_TRANSACTION_COUNT, hw_engine->transaction_count - 1);<br>
-<br>
- /* start I2C transfer */<br>
- REG_UPDATE(DC_I2C_CONTROL, DC_I2C_GO, 1);<br>
-<br>
- /* all transactions were executed and HW buffer became empty<br>
- * (even though it actually happens when status becomes DONE) */<br>
- hw_engine->transaction_count = 0;<br>
- hw_engine->buffer_used_bytes = 0;<br>
-}<br>
-<br>
-static void submit_channel_request(<br>
- struct i2c_engine *engine,<br>
- struct i2c_request_transaction_data *request)<br>
-{<br>
- request->status = I2C_CHANNEL_OPERATION_SUCCEEDED;<br>
-<br>
- if (!process_transaction(FROM_I2C_ENGINE(engine), request))<br>
- return;<br>
-<br>
- if (is_hw_busy(&engine->base)) {<br>
- request->status = I2C_CHANNEL_OPERATION_ENGINE_BUSY;<br>
- return;<br>
- }<br>
-<br>
- execute_transaction(FROM_I2C_ENGINE(engine));<br>
-}<br>
-<br>
-static void process_channel_reply(<br>
- struct i2c_engine *engine,<br>
- struct i2c_reply_transaction_data *reply)<br>
-{<br>
- uint32_t length = reply->length;<br>
- uint8_t *buffer = reply->data;<br>
-<br>
- struct i2c_hw_engine_dce110 *hw_engine =<br>
- FROM_I2C_ENGINE(engine);<br>
-<br>
-<br>
- REG_SET_3(DC_I2C_DATA, 0,<br>
- DC_I2C_INDEX, hw_engine->buffer_used_write,<br>
- DC_I2C_DATA_RW, 1,<br>
- DC_I2C_INDEX_WRITE, 1);<br>
-<br>
- while (length) {<br>
- /* after reading the status,<br>
- * if the I2C operation executed successfully<br>
- * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller<br>
- * should read data bytes from I2C circular data buffer */<br>
-<br>
- uint32_t i2c_data;<br>
-<br>
- REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data);<br>
- *buffer++ = i2c_data;<br>
-<br>
- --length;<br>
- }<br>
-}<br>
-<br>
-static enum i2c_channel_operation_result get_channel_status(<br>
- struct i2c_engine *i2c_engine,<br>
- uint8_t *returned_bytes)<br>
-{<br>
- uint32_t i2c_sw_status = 0;<br>
- struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);<br>
- uint32_t value =<br>
- REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status);<br>
-<br>
- if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_SW)<br>
- return I2C_CHANNEL_OPERATION_ENGINE_BUSY;<br>
- else if (value & hw_engine->i2c_mask->DC_I2C_SW_STOPPED_ON_NACK)<br>
- return I2C_CHANNEL_OPERATION_NO_RESPONSE;<br>
- else if (value & hw_engine->i2c_mask->DC_I2C_SW_TIMEOUT)<br>
- return I2C_CHANNEL_OPERATION_TIMEOUT;<br>
- else if (value & hw_engine->i2c_mask->DC_I2C_SW_ABORTED)<br>
- return I2C_CHANNEL_OPERATION_FAILED;<br>
- else if (value & hw_engine->i2c_mask->DC_I2C_SW_DONE)<br>
- return I2C_CHANNEL_OPERATION_SUCCEEDED;<br>
-<br>
- /*<br>
- * this is the case when HW used for communication, I2C_SW_STATUS<br>
- * could be zero<br>
- */<br>
- return I2C_CHANNEL_OPERATION_SUCCEEDED;<br>
-}<br>
-<br>
-static uint32_t get_hw_buffer_available_size(<br>
- const struct i2c_hw_engine *engine)<br>
-{<br>
- return I2C_HW_BUFFER_SIZE -<br>
- FROM_I2C_HW_ENGINE(engine)->buffer_used_bytes;<br>
-}<br>
-<br>
-static uint32_t get_transaction_timeout(<br>
- const struct i2c_hw_engine *engine,<br>
- uint32_t length)<br>
-{<br>
- uint32_t speed = engine->base.funcs->get_speed(&engine->base);<br>
-<br>
- uint32_t period_timeout;<br>
- uint32_t num_of_clock_stretches;<br>
-<br>
- if (!speed)<br>
- return 0;<br>
-<br>
- period_timeout = (1000 * TRANSACTION_TIMEOUT_IN_I2C_CLOCKS) / speed;<br>
-<br>
- num_of_clock_stretches = 1 + (length << 3) + 1;<br>
- num_of_clock_stretches +=<br>
- (FROM_I2C_HW_ENGINE(engine)->buffer_used_bytes << 3) +<br>
- (FROM_I2C_HW_ENGINE(engine)->transaction_count << 1);<br>
-<br>
- return period_timeout * num_of_clock_stretches;<br>
-}<br>
-<br>
-static void destroy(<br>
- struct i2c_engine **i2c_engine)<br>
-{<br>
- struct i2c_hw_engine_dce110 *engine_dce110 =<br>
- FROM_I2C_ENGINE(*i2c_engine);<br>
-<br>
- dal_i2c_hw_engine_destruct(&engine_dce110->base);<br>
-<br>
- kfree(engine_dce110);<br>
-<br>
- *i2c_engine = NULL;<br>
-}<br>
-<br>
-static const struct i2c_engine_funcs i2c_engine_funcs = {<br>
- .destroy = destroy,<br>
- .get_speed = get_speed,<br>
- .set_speed = set_speed,<br>
- .setup_engine = setup_engine,<br>
- .submit_channel_request = submit_channel_request,<br>
- .process_channel_reply = process_channel_reply,<br>
- .get_channel_status = get_channel_status,<br>
- .acquire_engine = dal_i2c_hw_engine_acquire_engine,<br>
-};<br>
-<br>
-static const struct engine_funcs engine_funcs = {<br>
- .release_engine = release_engine,<br>
- .get_engine_type = dal_i2c_hw_engine_get_engine_type,<br>
- .acquire = dal_i2c_engine_acquire,<br>
- .submit_request = dal_i2c_hw_engine_submit_request,<br>
-};<br>
-<br>
-static const struct i2c_hw_engine_funcs i2c_hw_engine_funcs = {<br>
- .get_hw_buffer_available_size = get_hw_buffer_available_size,<br>
- .get_transaction_timeout = get_transaction_timeout,<br>
- .wait_on_operation_result = dal_i2c_hw_engine_wait_on_operation_result,<br>
-};<br>
-<br>
-static void construct(<br>
- struct i2c_hw_engine_dce110 *hw_engine,<br>
- const struct i2c_hw_engine_dce110_create_arg *arg)<br>
-{<br>
- uint32_t xtal_ref_div = 0;<br>
-<br>
- dal_i2c_hw_engine_construct(&hw_engine->base, arg->ctx);<br>
-<br>
- hw_engine->base.base.base.funcs = &engine_funcs;<br>
- hw_engine->base.base.funcs = &i2c_engine_funcs;<br>
- hw_engine->base.funcs = &i2c_hw_engine_funcs;<br>
- hw_engine->base.default_speed = arg->default_speed;<br>
-<br>
- hw_engine->regs = arg->regs;<br>
- hw_engine->i2c_shift = arg->i2c_shift;<br>
- hw_engine->i2c_mask = arg->i2c_mask;<br>
-<br>
- hw_engine->engine_id = arg->engine_id;<br>
-<br>
- hw_engine->buffer_used_bytes = 0;<br>
- hw_engine->transaction_count = 0;<br>
- hw_engine->engine_keep_power_up_count = 1;<br>
-<br>
-<br>
- REG_GET(MICROSECOND_TIME_BASE_DIV, XTAL_REF_DIV, &xtal_ref_div);<br>
-<br>
- if (xtal_ref_div == 0) {<br>
- DC_LOG_WARNING("Invalid base timer divider [%s]\n",<br>
- __func__);<br>
- xtal_ref_div = 2;<br>
- }<br>
-<br>
- /*Calculating Reference Clock by divding original frequency by<br>
- * XTAL_REF_DIV.<br>
- * At upper level, uint32_t reference_frequency =<br>
- * dal_i2caux_get_reference_clock(as) >> 1<br>
- * which already divided by 2. So we need x2 to get original<br>
- * reference clock from ppll_info<br>
- */<br>
- hw_engine->reference_frequency =<br>
- (arg->reference_frequency * 2) / xtal_ref_div;<br>
-}<br>
-<br>
-struct i2c_engine *dal_i2c_hw_engine_dce110_create(<br>
- const struct i2c_hw_engine_dce110_create_arg *arg)<br>
-{<br>
- struct i2c_hw_engine_dce110 *engine_dce10;<br>
-<br>
- if (!arg) {<br>
- ASSERT_CRITICAL(false);<br>
- return NULL;<br>
- }<br>
- if (!arg->reference_frequency) {<br>
- ASSERT_CRITICAL(false);<br>
- return NULL;<br>
- }<br>
-<br>
- engine_dce10 = kzalloc(sizeof(struct i2c_hw_engine_dce110),<br>
- GFP_KERNEL);<br>
-<br>
- if (!engine_dce10) {<br>
- ASSERT_CRITICAL(false);<br>
- return NULL;<br>
- }<br>
-<br>
- construct(engine_dce10, arg);<br>
- return &engine_dce10->base.base;<br>
-}<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.c<br>
deleted file mode 100644<br>
index a9db047..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.c<br>
+++ /dev/null<br>
@@ -1,129 +0,0 @@<br>
-/*<br>
- * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- *<br>
- * Authors: AMD<br>
- *<br>
- */<br>
-<br>
-#include "dm_services.h"<br>
-<br>
-#include "include/i2caux_interface.h"<br>
-#include "../i2caux.h"<br>
-#include "../engine.h"<br>
-#include "../i2c_engine.h"<br>
-#include "../i2c_sw_engine.h"<br>
-#include "../i2c_hw_engine.h"<br>
-<br>
-#include "../dce110/i2caux_dce110.h"<br>
-#include "i2caux_dce112.h"<br>
-<br>
-#include "../dce110/aux_engine_dce110.h"<br>
-<br>
-#include "../dce110/i2c_hw_engine_dce110.h"<br>
-<br>
-#include "dce/dce_11_2_d.h"<br>
-#include "dce/dce_11_2_sh_mask.h"<br>
-<br>
-/* set register offset */<br>
-#define SR(reg_name)\<br>
- .reg_name = mm ## reg_name<br>
-<br>
-/* set register offset with instance */<br>
-#define SRI(reg_name, block, id)\<br>
- .reg_name = mm ## block ## id ## _ ## reg_name<br>
-<br>
-#define aux_regs(id)\<br>
-[id] = {\<br>
- AUX_COMMON_REG_LIST(id), \<br>
- .AUX_RESET_MASK = AUX_CONTROL__AUX_RESET_MASK \<br>
-}<br>
-<br>
-#define hw_engine_regs(id)\<br>
-{\<br>
- I2C_HW_ENGINE_COMMON_REG_LIST(id) \<br>
-}<br>
-<br>
-static const struct dce110_aux_registers dce112_aux_regs[] = {<br>
- aux_regs(0),<br>
- aux_regs(1),<br>
- aux_regs(2),<br>
- aux_regs(3),<br>
- aux_regs(4),<br>
- aux_regs(5),<br>
-};<br>
-<br>
-static const struct dce110_i2c_hw_engine_registers dce112_hw_engine_regs[] = {<br>
- hw_engine_regs(1),<br>
- hw_engine_regs(2),<br>
- hw_engine_regs(3),<br>
- hw_engine_regs(4),<br>
- hw_engine_regs(5),<br>
- hw_engine_regs(6)<br>
-};<br>
-<br>
-static const struct dce110_i2c_hw_engine_shift i2c_shift = {<br>
- I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT)<br>
-};<br>
-<br>
-static const struct dce110_i2c_hw_engine_mask i2c_mask = {<br>
- I2C_COMMON_MASK_SH_LIST_DCE110(_MASK)<br>
-};<br>
-<br>
-static void construct(<br>
- struct i2caux_dce110 *i2caux_dce110,<br>
- struct dc_context *ctx)<br>
-{<br>
- dal_i2caux_dce110_construct(i2caux_dce110,<br>
- ctx,<br>
- ARRAY_SIZE(dce112_aux_regs),<br>
- dce112_aux_regs,<br>
- dce112_hw_engine_regs,<br>
- &i2c_shift,<br>
- &i2c_mask);<br>
-}<br>
-<br>
-/*<br>
- * dal_i2caux_dce110_create<br>
- *<br>
- * @brief<br>
- * public interface to allocate memory for DCE11 I2CAUX<br>
- *<br>
- * @param<br>
- * struct adapter_service *as - [in]<br>
- * struct dc_context *ctx - [in]<br>
- *<br>
- * @return<br>
- * pointer to the base struct of DCE11 I2CAUX<br>
- */<br>
-struct i2caux *dal_i2caux_dce112_create(<br>
- struct dc_context *ctx)<br>
-{<br>
- struct i2caux_dce110 *i2caux_dce110 =<br>
- kzalloc(sizeof(struct i2caux_dce110), GFP_KERNEL);<br>
-<br>
- if (!i2caux_dce110) {<br>
- ASSERT_CRITICAL(false);<br>
- return NULL;<br>
- }<br>
-<br>
- construct(i2caux_dce110, ctx);<br>
- return &i2caux_dce110->base;<br>
-}<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.h b/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.h<br>
deleted file mode 100644<br>
index 8d35453..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/dce112/i2caux_dce112.h<br>
+++ /dev/null<br>
@@ -1,32 +0,0 @@<br>
-/*<br>
- * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- *<br>
- * Authors: AMD<br>
- *<br>
- */<br>
-<br>
-#ifndef __DAL_I2C_AUX_DCE112_H__<br>
-#define __DAL_I2C_AUX_DCE112_H__<br>
-<br>
-struct i2caux *dal_i2caux_dce112_create(<br>
- struct dc_context *ctx);<br>
-<br>
-#endif /* __DAL_I2C_AUX_DCE112_H__ */<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce80/i2c_sw_engine_dce80.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce80/i2c_sw_engine_dce80.c<br>
deleted file mode 100644<br>
index c9d6cf0..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/dce80/i2c_sw_engine_dce80.c<br>
+++ /dev/null<br>
@@ -1,163 +0,0 @@<br>
-/*<br>
- * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- *<br>
- * Authors: AMD<br>
- *<br>
- */<br>
-<br>
-#include "dm_services.h"<br>
-<br>
-/*<br>
- * Pre-requisites: headers required by header of this unit<br>
- */<br>
-#include "include/i2caux_interface.h"<br>
-#include "../engine.h"<br>
-#include "../i2c_engine.h"<br>
-#include "../i2c_sw_engine.h"<br>
-<br>
-/*<br>
- * Header of this unit<br>
- */<br>
-<br>
-#include "i2c_sw_engine_dce80.h"<br>
-<br>
-/*<br>
- * Post-requisites: headers required by this unit<br>
- */<br>
-<br>
-#include "dce/dce_8_0_d.h"<br>
-#include "dce/dce_8_0_sh_mask.h"<br>
-<br>
-/*<br>
- * This unit<br>
- */<br>
-<br>
-/*<br>
- * @brief<br>
- * Cast 'struct i2c_sw_engine *'<br>
- * to 'struct i2c_sw_engine_dce80 *'<br>
- */<br>
-#define FROM_I2C_SW_ENGINE(ptr) \<br>
- container_of((ptr), struct i2c_sw_engine_dce80, base)<br>
-<br>
-/*<br>
- * @brief<br>
- * Cast 'struct i2c_engine *'<br>
- * to 'struct i2c_sw_engine_dce80 *'<br>
- */<br>
-#define FROM_I2C_ENGINE(ptr) \<br>
- FROM_I2C_SW_ENGINE(container_of((ptr), struct i2c_sw_engine, base))<br>
-<br>
-/*<br>
- * @brief<br>
- * Cast 'struct engine *'<br>
- * to 'struct i2c_sw_engine_dce80 *'<br>
- */<br>
-#define FROM_ENGINE(ptr) \<br>
- FROM_I2C_ENGINE(container_of((ptr), struct i2c_engine, base))<br>
-<br>
-static void release_engine(<br>
- struct engine *engine)<br>
-{<br>
-<br>
-}<br>
-<br>
-static void destruct(<br>
- struct i2c_sw_engine_dce80 *engine)<br>
-{<br>
- dal_i2c_sw_engine_destruct(&engine->base);<br>
-}<br>
-<br>
-static void destroy(<br>
- struct i2c_engine **engine)<br>
-{<br>
- struct i2c_sw_engine_dce80 *sw_engine = FROM_I2C_ENGINE(*engine);<br>
-<br>
- destruct(sw_engine);<br>
-<br>
- kfree(sw_engine);<br>
-<br>
- *engine = NULL;<br>
-}<br>
-<br>
-static bool acquire_engine(<br>
- struct i2c_engine *engine,<br>
- struct ddc *ddc_handle)<br>
-{<br>
- return dal_i2caux_i2c_sw_engine_acquire_engine(engine, ddc_handle);<br>
-}<br>
-<br>
-static const struct i2c_engine_funcs i2c_engine_funcs = {<br>
- .acquire_engine = acquire_engine,<br>
- .destroy = destroy,<br>
- .get_speed = dal_i2c_sw_engine_get_speed,<br>
- .set_speed = dal_i2c_sw_engine_set_speed,<br>
- .setup_engine = dal_i2c_engine_setup_i2c_engine,<br>
- .submit_channel_request = dal_i2c_sw_engine_submit_channel_request,<br>
- .process_channel_reply = dal_i2c_engine_process_channel_reply,<br>
- .get_channel_status = dal_i2c_sw_engine_get_channel_status,<br>
-};<br>
-<br>
-static const struct engine_funcs engine_funcs = {<br>
- .release_engine = release_engine,<br>
- .get_engine_type = dal_i2c_sw_engine_get_engine_type,<br>
- .acquire = dal_i2c_engine_acquire,<br>
- .submit_request = dal_i2c_sw_engine_submit_request,<br>
-};<br>
-<br>
-static void construct(<br>
- struct i2c_sw_engine_dce80 *engine,<br>
- const struct i2c_sw_engine_dce80_create_arg *arg)<br>
-{<br>
- struct i2c_sw_engine_create_arg arg_base;<br>
-<br>
- arg_base.ctx = arg->ctx;<br>
- arg_base.default_speed = arg->default_speed;<br>
-<br>
- dal_i2c_sw_engine_construct(&engine->base, &arg_base);<br>
-<br>
- engine->base.base.base.funcs = &engine_funcs;<br>
- engine->base.base.funcs = &i2c_engine_funcs;<br>
- engine->base.default_speed = arg->default_speed;<br>
- engine->engine_id = arg->engine_id;<br>
-}<br>
-<br>
-struct i2c_engine *dal_i2c_sw_engine_dce80_create(<br>
- const struct i2c_sw_engine_dce80_create_arg *arg)<br>
-{<br>
- struct i2c_sw_engine_dce80 *engine;<br>
-<br>
- if (!arg) {<br>
- BREAK_TO_DEBUGGER();<br>
- return NULL;<br>
- }<br>
-<br>
- engine = kzalloc(sizeof(struct i2c_sw_engine_dce80), GFP_KERNEL);<br>
-<br>
- if (!engine) {<br>
- BREAK_TO_DEBUGGER();<br>
- return NULL;<br>
- }<br>
-<br>
- construct(engine, arg);<br>
- return &engine->base.base;<br>
-}<br>
-<br>
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c<br>
deleted file mode 100644<br>
index 1ad6e49..0000000<br>
--- a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c<br>
+++ /dev/null<br>
@@ -1,491 +0,0 @@<br>
-/*<br>
- * Copyright 2012-15 Advanced Micro Devices, Inc.<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice shall be included in<br>
- * all copies or substantial portions of the Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
- * OTHER DEALINGS IN THE SOFTWARE.<br>
- *<br>
- * Authors: AMD<br>
- *<br>
- */<br>
-<br>
-#include "dm_services.h"<br>
-<br>
-/*<br>
- * Pre-requisites: headers required by header of this unit<br>
- */<br>
-#include "include/i2caux_interface.h"<br>
-#include "dc_bios_types.h"<br>
-<br>
-/*<br>
- * Header of this unit<br>
- */<br>
-<br>
-#include "i2caux.h"<br>
-<br>
-/*<br>
- * Post-requisites: headers required by this unit<br>
- */<br>
-<br>
-#include "engine.h"<br>
-#include "i2c_engine.h"<br>
-#include "aux_engine.h"<br>
-<br>
-/*<br>
- * This unit<br>
- */<br>
-<br>
-#include "dce80/i2caux_dce80.h"<br>
-<br>
-#include "dce100/i2caux_dce100.h"<br>
-<br>
-#include "dce110/i2caux_dce110.h"<br>
-<br>
-#include "dce112/i2caux_dce112.h"<br>
-<br>
-#include "dce120/i2caux_dce120.h"<br>
-<br>
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)<br>
-#include "dcn10/i2caux_dcn10.h"<br>
-#endif<br>
-<br>
-#include "diagnostics/i2caux_diag.h"<br>
-<br>
-/*<br>
- * @brief<br>
- * Plain API, available publicly<br>
- */<br>
-<br>
-struct i2caux *dal_i2caux_create(<br>
- struct dc_context *ctx)<br>
-{<br>
- if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {<br>
- return dal_i2caux_diag_fpga_create(ctx);<br>
- }<br>
-<br>
- switch (ctx->dce_version) {<br>
- case DCE_VERSION_8_0:<br>
- case DCE_VERSION_8_1:<br>
- case DCE_VERSION_8_3:<br>
- return dal_i2caux_dce80_create(ctx);<br>
- case DCE_VERSION_11_2:<br>
- case DCE_VERSION_11_22:<br>
- return dal_i2caux_dce112_create(ctx);<br>
- case DCE_VERSION_11_0:<br>
- return dal_i2caux_dce110_create(ctx);<br>
- case DCE_VERSION_10_0:<br>
- return dal_i2caux_dce100_create(ctx);<br>
- case DCE_VERSION_12_0:<br>
- case DCE_VERSION_12_1:<br>
- return dal_i2caux_dce120_create(ctx);<br>
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)<br>
- case DCN_VERSION_1_0:<br>
- return dal_i2caux_dcn10_create(ctx);<br>
-#endif<br>
-<br>
-#if defined(CONFIG_DRM_AMD_DC_DCN1_01)<br>
- case DCN_VERSION_1_01:<br>
- return dal_i2caux_dcn10_create(ctx);<br>
-#endif<br>
- default:<br>
- BREAK_TO_DEBUGGER();<br>
- return NULL;<br>
- }<br>
-}<br>
-<br>
-bool dal_i2caux_submit_i2c_command(<br>
- struct i2caux *i2caux,<br>
- struct ddc *ddc,<br>
- struct i2c_command *cmd)<br>
-{<br>
- struct i2c_engine *engine;<br>
- uint8_t index_of_payload = 0;<br>
- bool result;<br>
-<br>
- if (!ddc) {<br>
- BREAK_TO_DEBUGGER();<br>
- return false;<br>
- }<br>
-<br>
- if (!cmd) {<br>
- BREAK_TO_DEBUGGER();<br>
- return false;<br>
- }<br>
-<br>
- /*<br>
- * default will be SW, however there is a feature flag in adapter<br>
- * service that determines whether SW i2c_engine will be available or<br>
- * not, if sw i2c is not available we will fallback to hw. This feature<br>
- * flag is set to not creating sw i2c engine for every dce except dce80<br>
- * currently<br>
- */<br>
- switch (cmd->engine) {<br>
- case I2C_COMMAND_ENGINE_DEFAULT:<br>
- case I2C_COMMAND_ENGINE_SW:<br>
- /* try to acquire SW engine first,<br>
- * acquire HW engine if SW engine not available */<br>
- engine = i2caux->funcs->acquire_i2c_sw_engine(i2caux, ddc);<br>
-<br>
- if (!engine)<br>
- engine = i2caux->funcs->acquire_i2c_hw_engine(<br>
- i2caux, ddc);<br>
- break;<br>
- case I2C_COMMAND_ENGINE_HW:<br>
- default:<br>
- /* try to acquire HW engine first,<br>
- * acquire SW engine if HW engine not available */<br>
- engine = i2caux->funcs->acquire_i2c_hw_engine(i2caux, ddc);<br>
-<br>
- if (!engine)<br>
- engine = i2caux->funcs->acquire_i2c_sw_engine(<br>
- i2caux, ddc);<br>
- }<br>
-<br>
- if (!engine)<br>
- return false;<br>
-<br>
- engine->funcs->set_speed(engine, cmd->speed);<br>
-<br>
- result = true;<br>
-<br>
- while (index_of_payload < cmd->number_of_payloads) {<br>
- bool mot = (index_of_payload != cmd->number_of_payloads - 1);<br>
-<br>
- struct i2c_payload *payload = cmd->payloads + index_of_payload;<br>
-<br>
- struct i2caux_transaction_request request = { 0 };<br>
-<br>
- request.operation = payload->write ?<br>
- I2CAUX_TRANSACTION_WRITE :<br>
- I2CAUX_TRANSACTION_READ;<br>
-<br>
- request.payload.address_space =<br>
- I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C;<br>
- request.payload.address = (payload->address << 1) |<br>
- !payload->write;<br>
- request.payload.length = payload->length;<br>
- request.payload.data = payload->data;<br>
-<br>
- if (!engine->base.funcs->submit_request(<br>
- &engine->base, &request, mot)) {<br>
- result = false;<br>
- break;<br>
- }<br>
-<br>
- ++index_of_payload;<br>
- }<br>
-<br>
- i2caux->funcs->release_engine(i2caux, &engine->base);<br>
-<br>
- return result;<br>
-}<br>
-<br>
-bool dal_i2caux_submit_aux_command(<br>
- struct i2caux *i2caux,<br>
- struct ddc *ddc,<br>
- struct aux_command *cmd)<br>
-{<br>
- struct aux_engine *engine;<br>
- uint8_t index_of_payload = 0;<br>
- bool result;<br>
- bool mot;<br>
-<br>
- if (!ddc) {<br>
- BREAK_TO_DEBUGGER();<br>
- return false;<br>
- }<br>
-<br>
- if (!cmd) {<br>
- BREAK_TO_DEBUGGER();<br>
- return false;<br>
- }<br>
-<br>
- engine = i2caux->funcs->acquire_aux_engine(i2caux, ddc);<br>
-<br>
- if (!engine)<br>
- return false;<br>
-<br>
- engine->delay = cmd->defer_delay;<br>
- engine->max_defer_write_retry = cmd->max_defer_write_retry;<br>
-<br>
- result = true;<br>
-<br>
- while (index_of_payload < cmd->number_of_payloads) {<br>
- struct aux_payload *payload = cmd->payloads + index_of_payload;<br>
- struct i2caux_transaction_request request = { 0 };<br>
-<br>
- if (cmd->mot == I2C_MOT_UNDEF)<br>
- mot = (index_of_payload != cmd->number_of_payloads - 1);<br>
- else<br>
- mot = (cmd->mot == I2C_MOT_TRUE);<br>
-<br>
- request.operation = payload->write ?<br>
- I2CAUX_TRANSACTION_WRITE :<br>
- I2CAUX_TRANSACTION_READ;<br>
-<br>
- if (payload->i2c_over_aux) {<br>
- request.payload.address_space =<br>
- I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C;<br>
-<br>
- request.payload.address = (payload->address << 1) |<br>
- !payload->write;<br>
- } else {<br>
- request.payload.address_space =<br>
- I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD;<br>
-<br>
- request.payload.address = payload->address;<br>
- }<br>
-<br>
- request.payload.length = payload->length;<br>
- request.payload.data = payload->data;<br>
-<br>
- if (!engine->base.funcs->submit_request(<br>
- &engine->base, &request, mot)) {<br>
- result = false;<br>
- break;<br>
- }<br>
-<br>
- ++index_of_payload;<br>
- }<br>
-<br>
- i2caux->funcs->release_engine(i2caux, &engine->base);<br>
-<br>
- return result;<br>
-}<br>
-<br>
-static bool get_hw_supported_ddc_line(<br>
- struct ddc *ddc,<br>
- enum gpio_ddc_line *line)<br>
-{<br>
- enum gpio_ddc_line line_found;<br>
-<br>
- *line = GPIO_DDC_LINE_UNKNOWN;<br>
-<br>
- if (!ddc) {<br>
- BREAK_TO_DEBUGGER();<br>
- return false;<br>
- }<br>
-<br>
- if (!ddc->hw_info.hw_supported)<br>
- return false;<br>
-<br>
- line_found = dal_ddc_get_line(ddc);<br>
-<br>
- if (line_found >= GPIO_DDC_LINE_COUNT)<br>
- return false;<br>
-<br>
- *line = line_found;<br>
-<br>
- return true;<br>
-}<br>
-<br>
-void dal_i2caux_configure_aux(<br>
- struct i2caux *i2caux,<br>
- struct ddc *ddc,<br>
- union aux_config cfg)<br>
-{<br>
- struct aux_engine *engine =<br>
- i2caux->funcs->acquire_aux_engine(i2caux, ddc);<br>
-<br>
- if (!engine)<br>
- return;<br>
-<br>
- engine->funcs->configure(engine, cfg);<br>
-<br>
- i2caux->funcs->release_engine(i2caux, &engine->base);<br>
-}<br>
-<br>
-void dal_i2caux_destroy(<br>
- struct i2caux **i2caux)<br>
-{<br>
- if (!i2caux || !*i2caux) {<br>
- BREAK_TO_DEBUGGER();<br>
- return;<br>
- }<br>
-<br>
- (*i2caux)->funcs->destroy(i2caux);<br>
-<br>
- *i2caux = NULL;<br>
-}<br>
-<br>
-/*<br>
- * @brief<br>
- * An utility function used by 'struct i2caux' and its descendants<br>
- */<br>
-<br>
-uint32_t dal_i2caux_get_reference_clock(<br>
- struct dc_bios *bios)<br>
-{<br>
- struct dc_firmware_info info = { { 0 } };<br>
-<br>
- if (bios->funcs->get_firmware_info(bios, &info) != BP_RESULT_OK)<br>
- return 0;<br>
-<br>
- return info.pll_info.crystal_frequency;<br>
-}<br>
-<br>
-/*<br>
- * @brief<br>
- * i2caux<br>
- */<br>
-<br>
-enum {<br>
- /* following are expressed in KHz */<br>
- DEFAULT_I2C_SW_SPEED = 50,<br>
- DEFAULT_I2C_HW_SPEED = 50,<br>
-<br>
- DEFAULT_I2C_SW_SPEED_100KHZ = 100,<br>
- DEFAULT_I2C_HW_SPEED_100KHZ = 100,<br>
-<br>
- /* This is the timeout as defined in DP 1.2a,<br>
- * 2.3.4 "Detailed uPacket TX AUX CH State Description". */<br>
- AUX_TIMEOUT_PERIOD = 400,<br>
-<br>
- /* Ideally, the SW timeout should be just above 550usec<br>
- * which is programmed in HW.<br>
- * But the SW timeout of 600usec is not reliable,<br>
- * because on some systems, delay_in_microseconds()<br>
- * returns faster than it should.<br>
- * EPR #379763: by trial-and-error on different systems,<br>
- * 700usec is the minimum reliable SW timeout for polling<br>
- * the AUX_SW_STATUS.AUX_SW_DONE bit.<br>
- * This timeout expires *only* when there is<br>
- * AUX Error or AUX Timeout conditions - not during normal operation.<br>
- * During normal operation, AUX_SW_STATUS.AUX_SW_DONE bit is set<br>
- * at most within ~240usec. That means,<br>
- * increasing this timeout will not affect normal operation,<br>
- * and we'll timeout after<br>
- * SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD = 1600usec.<br>
- * This timeout is especially important for<br>
- * resume from S3 and CTS. */<br>
- SW_AUX_TIMEOUT_PERIOD_MULTIPLIER = 4<br>
-};<br>
-<br>
-struct i2c_engine *dal_i2caux_acquire_i2c_sw_engine(<br>
- struct i2caux *i2caux,<br>
- struct ddc *ddc)<br>
-{<br>
- enum gpio_ddc_line line;<br>
- struct i2c_engine *engine = NULL;<br>
-<br>
- if (get_hw_supported_ddc_line(ddc, &line))<br>
- engine = i2caux->i2c_sw_engines[line];<br>
-<br>
- if (!engine)<br>
- engine = i2caux->i2c_generic_sw_engine;<br>
-<br>
- if (!engine)<br>
- return NULL;<br>
-<br>
- if (!engine->base.funcs->acquire(&engine->base, ddc))<br>
- return NULL;<br>
-<br>
- return engine;<br>
-}<br>
-<br>
-struct aux_engine *dal_i2caux_acquire_aux_engine(<br>
- struct i2caux *i2caux,<br>
- struct ddc *ddc)<br>
-{<br>
- enum gpio_ddc_line line;<br>
- struct aux_engine *engine;<br>
-<br>
- if (!get_hw_supported_ddc_line(ddc, &line))<br>
- return NULL;<br>
-<br>
- engine = i2caux->aux_engines[line];<br>
-<br>
- if (!engine)<br>
- return NULL;<br>
-<br>
- if (!engine->base.funcs->acquire(&engine->base, ddc))<br>
- return NULL;<br>
-<br>
- return engine;<br>
-}<br>
-<br>
-void dal_i2caux_release_engine(<br>
- struct i2caux *i2caux,<br>
- struct engine *engine)<br>
-{<br>
- engine->funcs->release_engine(engine);<br>
-<br>
- dal_ddc_close(engine->ddc);<br>
-<br>
- engine->ddc = NULL;<br>
-}<br>
-<br>
-void dal_i2caux_construct(<br>
- struct i2caux *i2caux,<br>
- struct dc_context *ctx)<br>
-{<br>
- uint32_t i = 0;<br>
-<br>
- i2caux->ctx = ctx;<br>
- do {<br>
- i2caux->i2c_sw_engines[i] = NULL;<br>
- i2caux->i2c_hw_engines[i] = NULL;<br>
- i2caux->aux_engines[i] = NULL;<br>
-<br>
- ++i;<br>
- } while (i < GPIO_DDC_LINE_COUNT);<br>
-<br>
- i2caux->i2c_generic_sw_engine = NULL;<br>
- i2caux->i2c_generic_hw_engine = NULL;<br>
-<br>
- i2caux->aux_timeout_period =<br>
- SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD;<br>
-<br>
- if (ctx->dce_version >= DCE_VERSION_11_2) {<br>
- i2caux->default_i2c_hw_speed = DEFAULT_I2C_HW_SPEED_100KHZ;<br>
- i2caux->default_i2c_sw_speed = DEFAULT_I2C_SW_SPEED_100KHZ;<br>
- } else {<br>
- i2caux->default_i2c_hw_speed = DEFAULT_I2C_HW_SPEED;<br>
- i2caux->default_i2c_sw_speed = DEFAULT_I2C_SW_SPEED;<br>
- }<br>
-}<br>
-<br>
-void dal_i2caux_destruct(<br>
- struct i2caux *i2caux)<br>
-{<br>
- uint32_t i = 0;<br>
-<br>
- if (i2caux->i2c_generic_hw_engine)<br>
- i2caux->i2c_generic_hw_engine->funcs->destroy(<br>
- &i2caux->i2c_generic_hw_engine);<br>
-<br>
- if (i2caux->i2c_generic_sw_engine)<br>
- i2caux->i2c_generic_sw_engine->funcs->destroy(<br>
- &i2caux->i2c_generic_sw_engine);<br>
-<br>
- do {<br>
- if (i2caux->aux_engines[i])<br>
- i2caux->aux_engines[i]->funcs->destroy(<br>
- &i2caux->aux_engines[i]);<br>
-<br>
- if (i2caux->i2c_hw_engines[i])<br>
- i2caux->i2c_hw_engines[i]->funcs->destroy(<br>
- &i2caux->i2c_hw_engines[i]);<br>
-<br>
- if (i2caux->i2c_sw_engines[i])<br>
- i2caux->i2c_sw_engines[i]->funcs->destroy(<br>
- &i2caux->i2c_sw_engines[i]);<br>
-<br>
- ++i;<br>
- } while (i < GPIO_DDC_LINE_COUNT);<br>
-}<br>
-<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>