linux/drivers/i2c/busses/i2c-nvidia-gpu.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Nvidia GPU I2C controller Driver
 *
 * Copyright (C) 2018 NVIDIA Corporation. All rights reserved.
 * Author: Ajay Gupta <[email protected]>
 */
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/power_supply.h>

#include <asm/unaligned.h>

#include "i2c-ccgx-ucsi.h"

/* I2C definitions */
#define I2C_MST_CNTL
#define I2C_MST_CNTL_GEN_START
#define I2C_MST_CNTL_GEN_STOP
#define I2C_MST_CNTL_CMD_READ
#define I2C_MST_CNTL_CMD_WRITE
#define I2C_MST_CNTL_BURST_SIZE_SHIFT
#define I2C_MST_CNTL_GEN_NACK
#define I2C_MST_CNTL_STATUS
#define I2C_MST_CNTL_STATUS_OKAY
#define I2C_MST_CNTL_STATUS_NO_ACK
#define I2C_MST_CNTL_STATUS_TIMEOUT
#define I2C_MST_CNTL_STATUS_BUS_BUSY
#define I2C_MST_CNTL_CYCLE_TRIGGER

#define I2C_MST_ADDR

#define I2C_MST_I2C0_TIMING
#define I2C_MST_I2C0_TIMING_SCL_PERIOD_100KHZ
#define I2C_MST_I2C0_TIMING_TIMEOUT_CLK_CNT
#define I2C_MST_I2C0_TIMING_TIMEOUT_CLK_CNT_MAX
#define I2C_MST_I2C0_TIMING_TIMEOUT_CHECK

#define I2C_MST_DATA

#define I2C_MST_HYBRID_PADCTL
#define I2C_MST_HYBRID_PADCTL_MODE_I2C
#define I2C_MST_HYBRID_PADCTL_I2C_SCL_INPUT_RCV
#define I2C_MST_HYBRID_PADCTL_I2C_SDA_INPUT_RCV

struct gpu_i2c_dev {};

static void gpu_enable_i2c_bus(struct gpu_i2c_dev *i2cd)
{}

static int gpu_i2c_check_status(struct gpu_i2c_dev *i2cd)
{}

static int gpu_i2c_read(struct gpu_i2c_dev *i2cd, u8 *data, u16 len)
{}

static int gpu_i2c_start(struct gpu_i2c_dev *i2cd)
{}

static int gpu_i2c_stop(struct gpu_i2c_dev *i2cd)
{}

static int gpu_i2c_write(struct gpu_i2c_dev *i2cd, u8 data)
{}

static int gpu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{}

static const struct i2c_adapter_quirks gpu_i2c_quirks =;

static u32 gpu_i2c_functionality(struct i2c_adapter *adap)
{}

static const struct i2c_algorithm gpu_i2c_algorithm =;

/*
 * This driver is for Nvidia GPU cards with USB Type-C interface.
 * We want to identify the cards using vendor ID and class code only
 * to avoid dependency of adding product id for any new card which
 * requires this driver.
 * Currently there is no class code defined for UCSI device over PCI
 * so using UNKNOWN class for now and it will be updated when UCSI
 * over PCI gets a class code.
 * There is no other NVIDIA cards with UNKNOWN class code. Even if the
 * driver gets loaded for an undesired card then eventually i2c_read()
 * (initiated from UCSI i2c_client) will timeout or UCSI commands will
 * timeout.
 */
#define PCI_CLASS_SERIAL_UNKNOWN
static const struct pci_device_id gpu_i2c_ids[] =;
MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);

static const struct property_entry ccgx_props[] =;

static const struct software_node ccgx_node =;

static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void gpu_i2c_remove(struct pci_dev *pdev)
{}

#define gpu_i2c_suspend

static __maybe_unused int gpu_i2c_resume(struct device *dev)
{}

static UNIVERSAL_DEV_PM_OPS(gpu_i2c_driver_pm, gpu_i2c_suspend, gpu_i2c_resume,
			    NULL);

static struct pci_driver gpu_i2c_driver =;

module_pci_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();