From 5808b75d08d7936d19923045b7f35c0e8ae75755 Mon Sep 17 00:00:00 2001 From: Gavin Shan Date: Fri, 10 Jun 2016 15:03:30 +1000 Subject: hw/p8-i2c: Allow to set I2C request timeout Prior to PCI enumeration, the PHB slot's power state might be changed during fundamental reset. The fundamental reset is implemented by state machine and it's driven by a polling mechanism in predetermined interval (A). On the other hand, PCI slot's power supply is controlled by I2C chip on Firenze platform. It means the PCI slot's power supply state is changed through I2C request which has a timeout timer running in variable interval (B). Comparing to (A), (B) is small and short. That means I2C timeout is reached before first poll running in interval of (A). It's unexpected behaviour. This allows to set I2C request timeout ((B)) to avoid the issue. Signed-off-by: Gavin Shan Reviewed-by: Stewart Smith Signed-off-by: Stewart Smith --- include/i2c.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/i2c.h b/include/i2c.h index dea0644..83c6ec5 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -26,6 +26,8 @@ struct i2c_bus { int (*queue_req)(struct i2c_request *req); struct i2c_request *(*alloc_req)(struct i2c_bus *bus); void (*free_req)(struct i2c_request *req); + void (*set_req_timeout)(struct i2c_request *req, + uint64_t duration); }; /* @@ -80,6 +82,13 @@ static inline int i2c_queue_req(struct i2c_request *req) return req->bus->queue_req(req); } +static inline void i2c_set_req_timeout(struct i2c_request *req, + uint64_t duration) +{ + if (req->bus->set_req_timeout) + req->bus->set_req_timeout(req, duration); +} + /* P8 implementation details */ extern void p8_i2c_init(void); extern void p8_i2c_interrupt(uint32_t chip_id); -- cgit v1.1