#include "smuio/smuio_11_0_0_offset.h"
#include "smuio/smuio_11_0_0_sh_mask.h"
#include "smu_v11_0_i2c.h"
#include "amdgpu.h"
#include "amdgpu_dpm.h"
#include "soc15_common.h"
#include <drm/drm_fixed.h>
#include <drm/drm_drv.h>
#include "amdgpu_amdkfd.h"
#include <linux/i2c.h>
#include <linux/pci.h>
#define I2C_OK …
#define I2C_NAK_7B_ADDR_NOACK …
#define I2C_NAK_TXDATA_NOACK …
#define I2C_TIMEOUT …
#define I2C_SW_TIMEOUT …
#define I2C_ABORT …
#define I2C_X_RESTART …
static void smu_v11_0_i2c_set_clock_gating(struct i2c_adapter *control, bool en)
{ … }
#define I2C_SPEED_MODE_FAST …
#define T_I2C_POLL_US …
#define I2C_MAX_T_POLL_COUNT …
static int smu_v11_0_i2c_enable(struct i2c_adapter *control, bool enable)
{ … }
static void smu_v11_0_i2c_clear_status(struct i2c_adapter *control)
{ … }
static void smu_v11_0_i2c_configure(struct i2c_adapter *control)
{ … }
static void smu_v11_0_i2c_set_clock(struct i2c_adapter *control)
{ … }
static void smu_v11_0_i2c_set_address(struct i2c_adapter *control, u16 address)
{ … }
static uint32_t smu_v11_0_i2c_poll_tx_status(struct i2c_adapter *control)
{ … }
static uint32_t smu_v11_0_i2c_poll_rx_status(struct i2c_adapter *control)
{ … }
static uint32_t smu_v11_0_i2c_transmit(struct i2c_adapter *control,
u16 address, u8 *data,
u32 numbytes, u32 i2c_flag)
{ … }
static uint32_t smu_v11_0_i2c_receive(struct i2c_adapter *control,
u16 address, u8 *data,
u32 numbytes, u32 i2c_flag)
{ … }
static void smu_v11_0_i2c_abort(struct i2c_adapter *control)
{ … }
static bool smu_v11_0_i2c_activity_done(struct i2c_adapter *control)
{ … }
static void smu_v11_0_i2c_init(struct i2c_adapter *control)
{ … }
static void smu_v11_0_i2c_fini(struct i2c_adapter *control)
{ … }
static bool smu_v11_0_i2c_bus_lock(struct i2c_adapter *control)
{ … }
static bool smu_v11_0_i2c_bus_unlock(struct i2c_adapter *control)
{ … }
static uint32_t smu_v11_0_i2c_read_data(struct i2c_adapter *control,
struct i2c_msg *msg, uint32_t i2c_flag)
{ … }
static uint32_t smu_v11_0_i2c_write_data(struct i2c_adapter *control,
struct i2c_msg *msg, uint32_t i2c_flag)
{ … }
static void lock_bus(struct i2c_adapter *i2c, unsigned int flags)
{ … }
static int trylock_bus(struct i2c_adapter *i2c, unsigned int flags)
{ … }
static void unlock_bus(struct i2c_adapter *i2c, unsigned int flags)
{ … }
static const struct i2c_lock_operations smu_v11_0_i2c_i2c_lock_ops = …;
static int smu_v11_0_i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg *msg, int num)
{ … }
static u32 smu_v11_0_i2c_func(struct i2c_adapter *adap)
{ … }
static const struct i2c_algorithm smu_v11_0_i2c_algo = …;
static const struct i2c_adapter_quirks smu_v11_0_i2c_control_quirks = …;
int smu_v11_0_i2c_control_init(struct amdgpu_device *adev)
{ … }
void smu_v11_0_i2c_control_fini(struct amdgpu_device *adev)
{ … }
#if 0
#define I2C_TARGET_ADDR …
bool smu_v11_0_i2c_test_bus(struct i2c_adapter *control)
{
uint32_t ret = I2C_OK;
uint8_t data[6] = {0xf, 0, 0xde, 0xad, 0xbe, 0xef};
DRM_INFO("Begin");
if (!smu_v11_0_i2c_bus_lock(control)) {
DRM_ERROR("Failed to lock the bus!.");
return false;
}
smu_v11_0_i2c_init(control);
ret = smu_v11_0_i2c_write_data(control, I2C_TARGET_ADDR, data, 6);
ret = smu_v11_0_i2c_read_data(control, I2C_TARGET_ADDR, data, 6);
smu_v11_0_i2c_fini(control);
smu_v11_0_i2c_bus_unlock(control);
DRM_INFO("End");
return true;
}
#endif