mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
Add a bus multiplexer device
This patch set adds a bus multiplexer and the necessary infrastructure in the I2C code to allow it to work. These are common on systems with lots of I2C devices, like an IPMI BMC. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE/Q1c5nzg9ZpmiCaGYfOMkJGb/4EFAmCdnpcACgkQYfOMkJGb /4EG7BAAkUB1QbYzUChbTqVwrjxBcYmcSSdehKcZlACr9oIjwH/EutKdve/qt+fE xCHkxQAo1s+cFMoV0aFlE0UuwSxR42JwuALQcbz0UNGk0uJsgglVS65qqpwQkbiO pRnbW7ZjOxVpcjwvP9RvOIaBabUnEvNqrA7SUqs5+yPZVfhi0NqJ0DHZuvv/5L9c DV96Adv2UIKA1vqw6aOBULWm5J5zRN+6IjacZ2Qd7xQplilUcJQ5ZqiYskHF9LuT NuXoBMk5Dqqy01LYDdnjwxHAUEG31hIhtoaWgqW9AIlPuHUSxesZNsy/3BKZzWhD JX5WfKwkAzWx5pfVbmRzNSG8XqHR5nJqOdaJdWsSl2MGgjQ1/MtoIV/uLMozSVu3 5arQ7frhCXA2Dy1ozPiqIhrdiNlOHDKRTsu468o5eyxzAf+FclVPPZoKsQttaOA9 eNu+RNFY/nKCW8iAOPdSV4gQ9QwvUv3Z91lVOQjEiBbll3Iix/3r0/bZmQRArLzY 6WX0hVrhGIqdCFv5aVar0uFZz1n/G6nv3RBo6a6C72Tf+8KvjMrfA/mAXmQLJ/o1 j0s7G65lE9blyRmg7aBrfASTBPsT+JocIqeLMdMLIVxAAJLhpnQtjSRILmPy9zjl TMicA5MEC4BlXqGTJNoMTlOVyG7iC5VZ5qkeFPe1q5A/b5HxwyM= =IamZ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cminyard/tags/for-qemu-6.1-v1' into staging Add a bus multiplexer device This patch set adds a bus multiplexer and the necessary infrastructure in the I2C code to allow it to work. These are common on systems with lots of I2C devices, like an IPMI BMC. # gpg: Signature made Thu 13 May 2021 22:48:07 BST # gpg: using RSA key FD0D5CE67CE0F59A6688268661F38C90919BFF81 # gpg: Good signature from "Corey Minyard <cminyard@mvista.com>" [unknown] # gpg: aka "Corey Minyard <minyard@acm.org>" [unknown] # gpg: aka "Corey Minyard <corey@minyard.net>" [unknown] # gpg: aka "Corey Minyard <minyard@mvista.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: FD0D 5CE6 7CE0 F59A 6688 2686 61F3 8C90 919B FF81 * remotes/cminyard/tags/for-qemu-6.1-v1: hw/i2c: add pca954x i2c-mux switch hw/i2c: move search to i2c_scan_bus method hw/i2c: add match method for device search hw/i2c: name I2CNode list in I2CBus Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
499063d00a
8 changed files with 383 additions and 14 deletions
|
@ -16,6 +16,7 @@ enum i2c_event {
|
|||
I2C_NACK /* Masker NACKed a receive byte. */
|
||||
};
|
||||
|
||||
typedef struct I2CNodeList I2CNodeList;
|
||||
|
||||
#define TYPE_I2C_SLAVE "i2c-slave"
|
||||
OBJECT_DECLARE_TYPE(I2CSlave, I2CSlaveClass,
|
||||
|
@ -39,6 +40,16 @@ struct I2CSlaveClass {
|
|||
* return code is not used and should be zero.
|
||||
*/
|
||||
int (*event)(I2CSlave *s, enum i2c_event event);
|
||||
|
||||
/*
|
||||
* Check if this device matches the address provided. Returns bool of
|
||||
* true if it matches (or broadcast), and updates the device list, false
|
||||
* otherwise.
|
||||
*
|
||||
* If broadcast is true, match should add the device and return true.
|
||||
*/
|
||||
bool (*match_and_add)(I2CSlave *candidate, uint8_t address, bool broadcast,
|
||||
I2CNodeList *current_devs);
|
||||
};
|
||||
|
||||
struct I2CSlave {
|
||||
|
@ -58,9 +69,11 @@ struct I2CNode {
|
|||
QLIST_ENTRY(I2CNode) next;
|
||||
};
|
||||
|
||||
typedef QLIST_HEAD(I2CNodeList, I2CNode) I2CNodeList;
|
||||
|
||||
struct I2CBus {
|
||||
BusState qbus;
|
||||
QLIST_HEAD(, I2CNode) current_devs;
|
||||
I2CNodeList current_devs;
|
||||
uint8_t saved_address;
|
||||
bool broadcast;
|
||||
};
|
||||
|
@ -74,6 +87,8 @@ void i2c_nack(I2CBus *bus);
|
|||
int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send);
|
||||
int i2c_send(I2CBus *bus, uint8_t data);
|
||||
uint8_t i2c_recv(I2CBus *bus);
|
||||
bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool broadcast,
|
||||
I2CNodeList *current_devs);
|
||||
|
||||
/**
|
||||
* Create an I2C slave device on the heap.
|
||||
|
|
19
include/hw/i2c/i2c_mux_pca954x.h
Normal file
19
include/hw/i2c/i2c_mux_pca954x.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef QEMU_I2C_MUX_PCA954X
|
||||
#define QEMU_I2C_MUX_PCA954X
|
||||
|
||||
#include "hw/i2c/i2c.h"
|
||||
|
||||
#define TYPE_PCA9546 "pca9546"
|
||||
#define TYPE_PCA9548 "pca9548"
|
||||
|
||||
/**
|
||||
* Retrieves the i2c bus associated with the specified channel on this i2c
|
||||
* mux.
|
||||
* @mux: an i2c mux device.
|
||||
* @channel: the i2c channel requested
|
||||
*
|
||||
* Returns: a pointer to the associated i2c bus.
|
||||
*/
|
||||
I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue