1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 3 * I2C Address Translator 4 * 5 * Copyright (c) 2019,2022 Luca Ceresoli <luca 6 * Copyright (c) 2022,2023 Tomi Valkeinen <tom 7 * 8 * Based on i2c-mux.h 9 */ 10 11 #ifndef _LINUX_I2C_ATR_H 12 #define _LINUX_I2C_ATR_H 13 14 #include <linux/i2c.h> 15 #include <linux/types.h> 16 17 struct device; 18 struct fwnode_handle; 19 struct i2c_atr; 20 21 /** 22 * struct i2c_atr_ops - Callbacks from ATR to 23 * @attach_client: Notify the driver of a new 24 * bus, with the alias assigne 25 * configure the hardware to u 26 * @detach_client: Notify the driver of a devi 27 * driver must configure the h 28 * alias. 29 * 30 * All these functions return 0 on success, a 31 */ 32 struct i2c_atr_ops { 33 int (*attach_client)(struct i2c_atr *a 34 const struct i2c_ 35 void (*detach_client)(struct i2c_atr * 36 const struct i2c 37 }; 38 39 /** 40 * i2c_atr_new() - Allocate and initialize an 41 * @parent: The parent (upstream) adapte 42 * @dev: The device acting as an ATR 43 * @ops: Driver-specific callbacks 44 * @max_adapters: Maximum number of child adap 45 * 46 * The new ATR helper is connected to the pare 47 * adapters. Call i2c_atr_add_adapter() to add 48 * 49 * Call i2c_atr_delete() to remove. 50 * 51 * Return: pointer to the new ATR helper objec 52 */ 53 struct i2c_atr *i2c_atr_new(struct i2c_adapter 54 const struct i2c_a 55 56 /** 57 * i2c_atr_delete - Delete an I2C ATR helper. 58 * @atr: I2C ATR helper to be deleted. 59 * 60 * Precondition: all the adapters added with i 61 * removed by calling i2c_atr_del_adapter(). 62 */ 63 void i2c_atr_delete(struct i2c_atr *atr); 64 65 /** 66 * i2c_atr_add_adapter - Create a child ("down 67 * @atr: The I2C ATR 68 * @chan_id: Index of the new adapter (0 .. 69 * passed to the callbacks in `st 70 * @adapter_parent: The device used as the par 71 * to use the i2c-atr device 72 * @bus_handle: The fwnode handle that points 73 * peripherals, or NULL. 74 * 75 * After calling this function a new i2c bus w 76 * devices on the downstream bus will result i 77 * &i2c_atr_ops->attach_client and &i2c_atr_op 78 * driver to assign an alias to the device. 79 * 80 * The adapter's fwnode is set to @bus_handle, 81 * function looks for a child node whose 'reg' 82 * under the i2c-atr device's 'i2c-atr' node. 83 * 84 * Call i2c_atr_del_adapter() to remove the ad 85 * 86 * Return: 0 on success, a negative error code 87 */ 88 int i2c_atr_add_adapter(struct i2c_atr *atr, u 89 struct device *adapter 90 struct fwnode_handle * 91 92 /** 93 * i2c_atr_del_adapter - Remove a child ("down 94 * i2c_atr_add_adapter() 95 * this function is a no 96 * @atr: The I2C ATR 97 * @chan_id: Index of the adapter to be remove 98 */ 99 void i2c_atr_del_adapter(struct i2c_atr *atr, 100 101 /** 102 * i2c_atr_set_driver_data - Set private drive 103 * @atr: The I2C ATR 104 * @data: Pointer to the data to store 105 */ 106 void i2c_atr_set_driver_data(struct i2c_atr *a 107 108 /** 109 * i2c_atr_get_driver_data - Get the stored dr 110 * @atr: The I2C ATR 111 * 112 * Return: Pointer to the stored data 113 */ 114 void *i2c_atr_get_driver_data(struct i2c_atr * 115 116 #endif /* _LINUX_I2C_ATR_H */ 117
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.