linux/drivers/i2c/i2c-atr.c

// SPDX-License-Identifier: GPL-2.0
/*
 * I2C Address Translator
 *
 * Copyright (c) 2019,2022 Luca Ceresoli <[email protected]>
 * Copyright (c) 2022,2023 Tomi Valkeinen <[email protected]>
 *
 * Originally based on i2c-mux.c
 */

#include <linux/fwnode.h>
#include <linux/i2c-atr.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/spinlock.h>

#define ATR_MAX_ADAPTERS
#define ATR_MAX_SYMLINK_LEN

/**
 * struct i2c_atr_alias_pair - Holds the alias assigned to a client.
 * @node:   List node
 * @client: Pointer to the client on the child bus
 * @alias:  I2C alias address assigned by the driver.
 *          This is the address that will be used to issue I2C transactions
 *          on the parent (physical) bus.
 */
struct i2c_atr_alias_pair {};

/**
 * struct i2c_atr_chan - Data for a channel.
 * @adap:            The &struct i2c_adapter for the channel
 * @atr:             The parent I2C ATR
 * @chan_id:         The ID of this channel
 * @alias_list:      List of @struct i2c_atr_alias_pair containing the
 *                   assigned aliases
 * @orig_addrs_lock: Mutex protecting @orig_addrs
 * @orig_addrs:      Buffer used to store the original addresses during transmit
 * @orig_addrs_size: Size of @orig_addrs
 */
struct i2c_atr_chan {};

/**
 * struct i2c_atr - The I2C ATR instance
 * @parent:    The parent &struct i2c_adapter
 * @dev:       The device that owns the I2C ATR instance
 * @ops:       &struct i2c_atr_ops
 * @priv:      Private driver data, set with i2c_atr_set_driver_data()
 * @algo:      The &struct i2c_algorithm for adapters
 * @lock:      Lock for the I2C bus segment (see &struct i2c_lock_operations)
 * @max_adapters: Maximum number of adapters this I2C ATR can have
 * @num_aliases: Number of aliases in the aliases array
 * @aliases:   The aliases array
 * @alias_mask_lock: Lock protecting alias_use_mask
 * @alias_use_mask: Bitmask for used aliases in aliases array
 * @i2c_nb:    Notifier for remote client add & del events
 * @adapter:   Array of adapters
 */
struct i2c_atr {};

static struct i2c_atr_alias_pair *
i2c_atr_find_mapping_by_client(const struct list_head *list,
			       const struct i2c_client *client)
{}

static struct i2c_atr_alias_pair *
i2c_atr_find_mapping_by_addr(const struct list_head *list, u16 phys_addr)
{}

/*
 * Replace all message addresses with their aliases, saving the original
 * addresses.
 *
 * This function is internal for use in i2c_atr_master_xfer(). It must be
 * followed by i2c_atr_unmap_msgs() to restore the original addresses.
 */
static int i2c_atr_map_msgs(struct i2c_atr_chan *chan, struct i2c_msg *msgs,
			    int num)
{}

/*
 * Restore all message address aliases with the original addresses. This
 * function is internal for use in i2c_atr_master_xfer() and for this reason it
 * needs no null and size checks on orig_addr.
 *
 * @see i2c_atr_map_msgs()
 */
static void i2c_atr_unmap_msgs(struct i2c_atr_chan *chan, struct i2c_msg *msgs,
			       int num)
{}

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

static int i2c_atr_smbus_xfer(struct i2c_adapter *adap, u16 addr,
			      unsigned short flags, char read_write, u8 command,
			      int size, union i2c_smbus_data *data)
{}

static u32 i2c_atr_functionality(struct i2c_adapter *adap)
{}

static void i2c_atr_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
{}

static int i2c_atr_trylock_bus(struct i2c_adapter *adapter, unsigned int flags)
{}

static void i2c_atr_unlock_bus(struct i2c_adapter *adapter, unsigned int flags)
{}

static const struct i2c_lock_operations i2c_atr_lock_ops =;

static int i2c_atr_reserve_alias(struct i2c_atr *atr)
{}

static void i2c_atr_release_alias(struct i2c_atr *atr, u16 alias)
{}

static int i2c_atr_attach_client(struct i2c_adapter *adapter,
				 const struct i2c_client *client)
{}

static void i2c_atr_detach_client(struct i2c_adapter *adapter,
				  const struct i2c_client *client)
{}

static int i2c_atr_bus_notifier_call(struct notifier_block *nb,
				     unsigned long event, void *device)
{}

static int i2c_atr_parse_alias_pool(struct i2c_atr *atr)
{}

struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
			    const struct i2c_atr_ops *ops, int max_adapters)
{}
EXPORT_SYMBOL_NS_GPL();

void i2c_atr_delete(struct i2c_atr *atr)
{}
EXPORT_SYMBOL_NS_GPL();

int i2c_atr_add_adapter(struct i2c_atr *atr, u32 chan_id,
			struct device *adapter_parent,
			struct fwnode_handle *bus_handle)
{}
EXPORT_SYMBOL_NS_GPL();

void i2c_atr_del_adapter(struct i2c_atr *atr, u32 chan_id)
{}
EXPORT_SYMBOL_NS_GPL();

void i2c_atr_set_driver_data(struct i2c_atr *atr, void *data)
{}
EXPORT_SYMBOL_NS_GPL();

void *i2c_atr_get_driver_data(struct i2c_atr *atr)
{}
EXPORT_SYMBOL_NS_GPL();

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