@@ -1607,3 +1607,29 @@ void p8_i2c_init(void)
p8_i2c_init_one(i2cm, i);
}
}
+
+struct i2c_bus *p8_i2c_find_bus_by_port(uint32_t chip_id, int eng, int port_num)
+{
+ struct proc_chip *chip = get_chip(chip_id);
+ struct p8_i2c_master *m, *master = NULL;
+ struct p8_i2c_master_port *port;
+
+ if (!chip)
+ return NULL;
+
+ list_for_each(&chip->i2cms, m, link) {
+ if (m->engine_id == eng) {
+ master = m;
+ break;
+ }
+ }
+
+ if (!master)
+ return NULL;
+
+ list_for_each(&master->ports, port, link)
+ if (port->port_num == port_num)
+ return &port->bus;
+
+ return NULL;
+}
@@ -61,6 +61,9 @@ struct i2c_request {
extern void i2c_add_bus(struct i2c_bus *bus);
extern struct i2c_bus *i2c_find_bus_by_id(uint32_t opal_id);
+/* not generic, but useful */
+struct i2c_bus *p8_i2c_find_bus_by_port(uint32_t chip_id, int eng, int port_id);
+
int64_t i2c_queue_req(struct i2c_request *req);
static inline uint64_t i2c_run_req(struct i2c_request *req)
Adds a way to find the struct i2c_bus for a given chip ID, engine ID, and port ID. HDAT indicates which I2C master is relevant using this information so it comes up a fair bit. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- hw/p8-i2c.c | 26 ++++++++++++++++++++++++++ include/i2c.h | 3 +++ 2 files changed, 29 insertions(+)