This was optional behavior controlled by separate module
parameter.  The option allowed for the use the atombios
command tables for i2c transactions rather than direct
bit banging.  It was off by default and now that the legacy
non-DC display code is gone, there is not much point in
keeping it around.

Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/Makefile          |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h          |   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c |  18 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c      |   8 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c      |  53 ++----
 drivers/gpu/drm/amd/amdgpu/atombios_i2c.c    | 176 -------------------
 drivers/gpu/drm/amd/amdgpu/atombios_i2c.h    |  33 ----
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c        |   1 -
 9 files changed, 40 insertions(+), 255 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/atombios_i2c.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index e363b012bb4b7..a2c35ea112ac8 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -58,7 +58,7 @@ amdgpu-y += amdgpu_device.o amdgpu_reg_access.o 
amdgpu_doorbell_mgr.o amdgpu_kms
        amdgpu_gem.o amdgpu_ring.o \
        amdgpu_cs.o amdgpu_bios.o amdgpu_benchmark.o \
        amdgpu_trace_points.o \
-       amdgpu_sa.o atombios_i2c.o \
+       amdgpu_sa.o \
        amdgpu_dma_buf.o amdgpu_vm.o amdgpu_vm_pt.o amdgpu_vm_tlb_fence.o \
        amdgpu_ib.o \
        amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index fc8c53c61ee26..f02e9660a9eb3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -163,7 +163,6 @@ extern int amdgpu_gart_size;
 extern int amdgpu_gtt_size;
 extern int amdgpu_moverate;
 extern int amdgpu_audio;
-extern int amdgpu_hw_i2c;
 extern int amdgpu_pcie_gen2;
 extern int amdgpu_msi;
 extern char amdgpu_lockup_timeout[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index f17d6da396b06..4e436fb5405b8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -187,6 +187,24 @@ void amdgpu_atombios_oem_i2c_init(struct amdgpu_device 
*adev, u8 i2c_id)
        }
 }
 
+#define TARGET_HW_I2C_CLOCK 50
+
+void amdgpu_atombios_i2c_channel_trans(struct amdgpu_device *adev, u8 
slave_addr, u8 line_number, u8 offset, u8 data)
+{
+       PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
+       int index = GetIndexIntoMasterTable(COMMAND, 
ProcessI2cChannelTransaction);
+
+       args.ucRegIndex = offset;
+       args.lpI2CDataOut = data;
+       args.ucFlag = 1;
+       args.ucI2CSpeed = TARGET_HW_I2C_CLOCK;
+       args.ucTransBytes = 1;
+       args.ucSlaveAddr = slave_addr;
+       args.ucLineNumber = line_number;
+
+       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, 
(uint32_t *)&args, sizeof(args));
+}
+
 union firmware_info {
        ATOM_FIRMWARE_INFO info;
        ATOM_FIRMWARE_INFO_V1_2 info_12;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
index b840707b3c40b..27f02d8e26197 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
@@ -134,6 +134,9 @@ struct amdgpu_i2c_bus_rec 
amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *
 void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);
 void amdgpu_atombios_oem_i2c_init(struct amdgpu_device *adev, u8 i2c_id);
 
+void amdgpu_atombios_i2c_channel_trans(struct amdgpu_device* adev,
+               u8 slave_addr, u8 line_number, u8 offset, u8 data);
+
 int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
 
 int amdgpu_atombios_get_gfx_info(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index a8b1eb4e8ddfe..812b7ce7d40b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -160,7 +160,6 @@ int amdgpu_gart_size = -1; /* auto */
 int amdgpu_gtt_size = -1; /* auto */
 int amdgpu_moverate = -1; /* auto */
 int amdgpu_audio = -1;
-int amdgpu_hw_i2c;
 int amdgpu_pcie_gen2 = -1;
 int amdgpu_msi = -1;
 char amdgpu_lockup_timeout[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH];
@@ -321,13 +320,6 @@ module_param_named(moverate, amdgpu_moverate, int, 0600);
 MODULE_PARM_DESC(audio, "HDMI/DP Audio enable for displays (-1 = auto, 0 = 
disable, 1 = enable)");
 module_param_named(audio, amdgpu_audio, int, 0444);
 
-/**
- * DOC: hw_i2c (int)
- * To enable hw i2c engine. Only affects non-DC display handling. The default 
is 0 (Disabled).
- */
-MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
-module_param_named(hw_i2c, amdgpu_hw_i2c, int, 0444);
-
 /**
  * DOC: pcie_gen2 (int)
  * To disable PCIE Gen2/3 mode (0 = disable, 1 = enable). The default is -1 
(auto, enabled).
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
index bcf1007011bf4..0e82a041330ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
@@ -32,7 +32,6 @@
 #include "amdgpu_i2c.h"
 #include "amdgpu_atombios.h"
 #include "atom.h"
-#include "atombios_i2c.h"
 
 /* bit banging i2c */
 static int amdgpu_i2c_pre_xfer(struct i2c_adapter *i2c_adap)
@@ -151,11 +150,6 @@ static void amdgpu_i2c_set_data(void *i2c_priv, int data)
        WREG32(rec->en_data_reg, val);
 }
 
-static const struct i2c_algorithm amdgpu_atombios_i2c_algo = {
-       .master_xfer = amdgpu_atombios_i2c_xfer,
-       .functionality = amdgpu_atombios_i2c_func,
-};
-
 struct amdgpu_i2c_chan *amdgpu_i2c_create(struct drm_device *dev,
                                          const struct amdgpu_i2c_bus_rec *rec,
                                          const char *name)
@@ -164,7 +158,7 @@ struct amdgpu_i2c_chan *amdgpu_i2c_create(struct drm_device 
*dev,
        int ret;
 
        /* don't add the mm_i2c bus unless hw_i2c is enabled */
-       if (rec->mm_i2c && (amdgpu_hw_i2c == 0))
+       if (rec->mm_i2c)
                return NULL;
 
        i2c = kzalloc_obj(struct amdgpu_i2c_chan);
@@ -177,34 +171,23 @@ struct amdgpu_i2c_chan *amdgpu_i2c_create(struct 
drm_device *dev,
        i2c->dev = dev;
        i2c_set_adapdata(&i2c->adapter, i2c);
        mutex_init(&i2c->mutex);
-       if (rec->hw_capable &&
-           amdgpu_hw_i2c) {
-               /* hw i2c using atom */
-               snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
-                        "AMDGPU i2c hw bus %s", name);
-               i2c->adapter.algo = &amdgpu_atombios_i2c_algo;
-               ret = devm_i2c_add_adapter(dev->dev, &i2c->adapter);
-               if (ret)
-                       goto out_free;
-       } else {
-               /* set the amdgpu bit adapter */
-               snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
-                        "AMDGPU i2c bit bus %s", name);
-               i2c->adapter.algo_data = &i2c->bit;
-               i2c->bit.pre_xfer = amdgpu_i2c_pre_xfer;
-               i2c->bit.post_xfer = amdgpu_i2c_post_xfer;
-               i2c->bit.setsda = amdgpu_i2c_set_data;
-               i2c->bit.setscl = amdgpu_i2c_set_clock;
-               i2c->bit.getsda = amdgpu_i2c_get_data;
-               i2c->bit.getscl = amdgpu_i2c_get_clock;
-               i2c->bit.udelay = 10;
-               i2c->bit.timeout = usecs_to_jiffies(2200);      /* from VESA */
-               i2c->bit.data = i2c;
-               ret = i2c_bit_add_bus(&i2c->adapter);
-               if (ret) {
-                       DRM_ERROR("Failed to register bit i2c %s\n", name);
-                       goto out_free;
-               }
+       /* set the amdgpu bit adapter */
+       snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+                "AMDGPU i2c bit bus %s", name);
+       i2c->adapter.algo_data = &i2c->bit;
+       i2c->bit.pre_xfer = amdgpu_i2c_pre_xfer;
+       i2c->bit.post_xfer = amdgpu_i2c_post_xfer;
+       i2c->bit.setsda = amdgpu_i2c_set_data;
+       i2c->bit.setscl = amdgpu_i2c_set_clock;
+       i2c->bit.getsda = amdgpu_i2c_get_data;
+       i2c->bit.getscl = amdgpu_i2c_get_clock;
+       i2c->bit.udelay = 10;
+       i2c->bit.timeout = usecs_to_jiffies(2200);      /* from VESA */
+       i2c->bit.data = i2c;
+       ret = i2c_bit_add_bus(&i2c->adapter);
+       if (ret) {
+               DRM_ERROR("Failed to register bit i2c %s\n", name);
+               goto out_free;
        }
 
        return i2c;
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c 
b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
deleted file mode 100644
index a6501114322fd..0000000000000
--- a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2011 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Alex Deucher
- *
- */
-
-#include <drm/amdgpu_drm.h>
-#include "amdgpu.h"
-#include "atom.h"
-#include "amdgpu_atombios.h"
-#include "atombios_i2c.h"
-
-#define TARGET_HW_I2C_CLOCK 50
-
-/* these are a limitation of ProcessI2cChannelTransaction not the hw */
-#define ATOM_MAX_HW_I2C_WRITE 3
-#define ATOM_MAX_HW_I2C_READ  255
-
-static int amdgpu_atombios_i2c_process_i2c_ch(struct amdgpu_i2c_chan *chan,
-                                      u8 slave_addr, u8 flags,
-                                      u8 *buf, u8 num)
-{
-       struct drm_device *dev = chan->dev;
-       struct amdgpu_device *adev = drm_to_adev(dev);
-       PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
-       int index = GetIndexIntoMasterTable(COMMAND, 
ProcessI2cChannelTransaction);
-       unsigned char *base;
-       u16 out = cpu_to_le16(0);
-       int r = 0;
-
-       memset(&args, 0, sizeof(args));
-
-       mutex_lock(&chan->mutex);
-
-       base = (unsigned char *)adev->mode_info.atom_context->scratch;
-
-       if (flags & HW_I2C_WRITE) {
-               if (num > ATOM_MAX_HW_I2C_WRITE) {
-                       DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 
3)\n", num);
-                       r = -EINVAL;
-                       goto done;
-               }
-               if (buf == NULL)
-                       args.ucRegIndex = 0;
-               else
-                       args.ucRegIndex = buf[0];
-               if (num)
-                       num--;
-               if (num) {
-                       if (buf) {
-                               memcpy(&out, &buf[1], num);
-                       } else {
-                               DRM_ERROR("hw i2c: missing buf with num > 1\n");
-                               r = -EINVAL;
-                               goto done;
-                       }
-               }
-               args.lpI2CDataOut = cpu_to_le16(out);
-       } else {
-               args.ucRegIndex = 0;
-               args.lpI2CDataOut = 0;
-       }
-
-       args.ucFlag = flags;
-       args.ucI2CSpeed = TARGET_HW_I2C_CLOCK;
-       args.ucTransBytes = num;
-       args.ucSlaveAddr = slave_addr << 1;
-       args.ucLineNumber = chan->rec.i2c_id;
-
-       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, 
(uint32_t *)&args, sizeof(args));
-
-       /* error */
-       if (args.ucStatus != HW_ASSISTED_I2C_STATUS_SUCCESS) {
-               DRM_DEBUG_KMS("hw_i2c error\n");
-               r = -EIO;
-               goto done;
-       }
-
-       if (!(flags & HW_I2C_WRITE))
-               amdgpu_atombios_copy_swap(buf, base, num, false);
-
-done:
-       mutex_unlock(&chan->mutex);
-
-       return r;
-}
-
-int amdgpu_atombios_i2c_xfer(struct i2c_adapter *i2c_adap,
-                     struct i2c_msg *msgs, int num)
-{
-       struct amdgpu_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
-       struct i2c_msg *p;
-       int i, remaining, current_count, buffer_offset, max_bytes, ret;
-       u8 flags;
-
-       /* check for bus probe */
-       p = &msgs[0];
-       if ((num == 1) && (p->len == 0)) {
-               ret = amdgpu_atombios_i2c_process_i2c_ch(i2c,
-                                                 p->addr, HW_I2C_WRITE,
-                                                 NULL, 0);
-               if (ret)
-                       return ret;
-               else
-                       return num;
-       }
-
-       for (i = 0; i < num; i++) {
-               p = &msgs[i];
-               remaining = p->len;
-               buffer_offset = 0;
-               /* max_bytes are a limitation of ProcessI2cChannelTransaction 
not the hw */
-               if (p->flags & I2C_M_RD) {
-                       max_bytes = ATOM_MAX_HW_I2C_READ;
-                       flags = HW_I2C_READ;
-               } else {
-                       max_bytes = ATOM_MAX_HW_I2C_WRITE;
-                       flags = HW_I2C_WRITE;
-               }
-               while (remaining) {
-                       if (remaining > max_bytes)
-                               current_count = max_bytes;
-                       else
-                               current_count = remaining;
-                       ret = amdgpu_atombios_i2c_process_i2c_ch(i2c,
-                                                         p->addr, flags,
-                                                         
&p->buf[buffer_offset], current_count);
-                       if (ret)
-                               return ret;
-                       remaining -= current_count;
-                       buffer_offset += current_count;
-               }
-       }
-
-       return num;
-}
-
-u32 amdgpu_atombios_i2c_func(struct i2c_adapter *adap)
-{
-       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
-}
-
-void amdgpu_atombios_i2c_channel_trans(struct amdgpu_device *adev, u8 
slave_addr, u8 line_number, u8 offset, u8 data)
-{
-       PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
-       int index = GetIndexIntoMasterTable(COMMAND, 
ProcessI2cChannelTransaction);
-
-       args.ucRegIndex = offset;
-       args.lpI2CDataOut = data;
-       args.ucFlag = 1;
-       args.ucI2CSpeed = TARGET_HW_I2C_CLOCK;
-       args.ucTransBytes = 1;
-       args.ucSlaveAddr = slave_addr;
-       args.ucLineNumber = line_number;
-
-       amdgpu_atom_execute_table(adev->mode_info.atom_context, index, 
(uint32_t *)&args, sizeof(args));
-}
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.h 
b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.h
deleted file mode 100644
index 251aaf41f65d5..0000000000000
--- a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifndef __ATOMBIOS_I2C_H__
-#define __ATOMBIOS_I2C_H__
-
-int amdgpu_atombios_i2c_xfer(struct i2c_adapter *i2c_adap,
-                     struct i2c_msg *msgs, int num);
-u32 amdgpu_atombios_i2c_func(struct i2c_adapter *adap);
-void amdgpu_atombios_i2c_channel_trans(struct amdgpu_device* adev,
-               u8 slave_addr, u8 line_number, u8 offset, u8 data);
-
-#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 4666aa5b38c75..654b313b0de01 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -35,7 +35,6 @@
 #include "vid.h"
 #include "amdgpu_ucode.h"
 #include "amdgpu_atombios.h"
-#include "atombios_i2c.h"
 #include "clearstate_vi.h"
 
 #include "gmc/gmc_8_2_d.h"
-- 
2.56.0

Reply via email to