linux/drivers/i2c/busses/i2c-tegra-bpmp.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * drivers/i2c/busses/i2c-tegra-bpmp.c
 *
 * Copyright (c) 2016 NVIDIA Corporation.  All rights reserved.
 *
 * Author: Shardar Shariff Md <[email protected]>
 */

#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>

#include <soc/tegra/bpmp-abi.h>
#include <soc/tegra/bpmp.h>

/*
 * Serialized I2C message header size is 6 bytes and includes address, flags
 * and length
 */
#define SERIALI2C_HDR_SIZE

struct tegra_bpmp_i2c {};

/*
 * Linux flags are translated to BPMP defined I2C flags that are used in BPMP
 * firmware I2C driver to avoid any issues in future if Linux I2C flags are
 * changed.
 */
static void tegra_bpmp_xlate_flags(u16 flags, u16 *out)
{}

/*
 * The serialized I2C format is simply the following:
 * [addr little-endian][flags little-endian][len little-endian][data if write]
 * [addr little-endian][flags little-endian][len little-endian][data if write]
 *  ...
 *
 * The flags are translated from Linux kernel representation to seriali2c
 * representation. Any undefined flag being set causes an error.
 *
 * The data is there only for writes. Reads have the data transferred in the
 * other direction, and thus data is not present.
 *
 * See deserialize_i2c documentation for the data format in the other direction.
 */
static void tegra_bpmp_serialize_i2c_msg(struct tegra_bpmp_i2c *i2c,
					struct mrq_i2c_request *request,
					struct i2c_msg *msgs,
					unsigned int num)
{}

/*
 * The data in the BPMP -> CPU direction is composed of sequential blocks for
 * those messages that have I2C_M_RD. So, for example, if you have:
 *
 * - !I2C_M_RD, len == 5, data == a0 01 02 03 04
 * - !I2C_M_RD, len == 1, data == a0
 * - I2C_M_RD, len == 2, data == [uninitialized buffer 1]
 * - !I2C_M_RD, len == 1, data == a2
 * - I2C_M_RD, len == 2, data == [uninitialized buffer 2]
 *
 * ...then the data in the BPMP -> CPU direction would be 4 bytes total, and
 * would contain 2 bytes that will go to uninitialized buffer 1, and 2 bytes
 * that will go to uninitialized buffer 2.
 */
static int tegra_bpmp_i2c_deserialize(struct tegra_bpmp_i2c *i2c,
				      struct mrq_i2c_response *response,
				      struct i2c_msg *msgs,
				      unsigned int num)
{}

static int tegra_bpmp_i2c_msg_len_check(struct i2c_msg *msgs, unsigned int num)
{}

static int tegra_bpmp_i2c_msg_xfer(struct tegra_bpmp_i2c *i2c,
				   struct mrq_i2c_request *request,
				   struct mrq_i2c_response *response,
				   bool atomic)
{}

static int tegra_bpmp_i2c_xfer_common(struct i2c_adapter *adapter,
				      struct i2c_msg *msgs, int num,
				      bool atomic)
{}

static int tegra_bpmp_i2c_xfer(struct i2c_adapter *adapter,
			       struct i2c_msg *msgs, int num)
{}

static int tegra_bpmp_i2c_xfer_atomic(struct i2c_adapter *adapter,
				      struct i2c_msg *msgs, int num)
{}

static u32 tegra_bpmp_i2c_func(struct i2c_adapter *adapter)
{}

static const struct i2c_algorithm tegra_bpmp_i2c_algo =;

static int tegra_bpmp_i2c_probe(struct platform_device *pdev)
{}

static void tegra_bpmp_i2c_remove(struct platform_device *pdev)
{}

static const struct of_device_id tegra_bpmp_i2c_of_match[] =;
MODULE_DEVICE_TABLE(of, tegra_bpmp_i2c_of_match);

static struct platform_driver tegra_bpmp_i2c_driver =;
module_platform_driver();

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