sandbox: i2c: Support i2c emulation with of-platdata
At present the i2c emulators require access to the devicetree, which is not possible (by design) with of-platdata. Add a way for drivers to record the of-platdata index of their emulator, so that we can still find the emulator. This allows i2c emulation to work with of-platdata. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -93,6 +93,8 @@ struct udevice;
|
||||
* datasheet explains it's usage of this addressing
|
||||
* mode.
|
||||
* @emul: Emulator for this chip address (only used for emulation)
|
||||
* @emul_idx: Emulator index, used for of-platdata and set by each i2c chip's
|
||||
* bind() method. This allows i2c_emul_find() to work with of-platdata.
|
||||
*/
|
||||
struct dm_i2c_chip {
|
||||
uint chip_addr;
|
||||
@@ -102,6 +104,7 @@ struct dm_i2c_chip {
|
||||
#ifdef CONFIG_SANDBOX
|
||||
struct udevice *emul;
|
||||
bool test_mode;
|
||||
int emul_idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -554,6 +557,18 @@ void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs);
|
||||
*/
|
||||
int i2c_emul_find(struct udevice *dev, struct udevice **emulp);
|
||||
|
||||
/**
|
||||
* i2c_emul_set_idx() - Set the emulator index for an i2c sandbox device
|
||||
*
|
||||
* With of-platdata we cannot find the emulator using the device tree, so rely
|
||||
* on the bind() method of each i2c driver calling this function to tell us
|
||||
* the of-platdata idx of the emulator
|
||||
*
|
||||
* @dev: i2c device to set the emulator for
|
||||
* @emul_idx: of-platdata index for that emulator
|
||||
*/
|
||||
void i2c_emul_set_idx(struct udevice *dev, int emul_idx);
|
||||
|
||||
/**
|
||||
* i2c_emul_get_device() - Find the device being emulated
|
||||
*
|
||||
|
Reference in New Issue
Block a user