summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJae Hyun Yoo <jae.hyun.yoo@intel.com>2019-03-08 02:17:40 +0300
committerJae Hyun Yoo <jae.hyun.yoo@linux.intel.com>2021-11-05 10:22:07 +0300
commitc2e14a9df5334f7284bfa2b36408eb7d67628dd9 (patch)
tree9b2b51331d6dfee189d464d23ae454a210ca8058 /drivers/i2c
parent5652a04f2654d8b0c6883a254d01fbf22260e701 (diff)
downloadlinux-c2e14a9df5334f7284bfa2b36408eb7d67628dd9.tar.xz
Add bus-timeout-ms and #retries device tree properties
BMC uses I2C bus 7 as a PMBus channel to communicate with PSUs, also ME uses this bus as SMLink to control PSUs so this bus is managed by multi-masters. In this use case, some arbitration errors are expected so we need to add retry logic. And PMBus subsystem uses I2C bus in kernel internally so retry logic should be supported in kernel level. To support the use case, this commit adds 'bus-timeout-ms' and '#retries' device tree properties to set the bus specific parameters at kernel boot time without using any additional ioctls from user space. This patch would not be accepted by I2C maintainer in linux upstream because he doesn't like adding these legacy properties into device tree, so keep it only in downstream. Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-aspeed.c1
-rw-r--r--drivers/i2c/i2c-core-base.c12
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 3b9fd2cf3f9a..cd3509a4ff18 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -1044,7 +1044,6 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
spin_lock_init(&bus->lock);
init_completion(&bus->cmd_complete);
bus->adap.owner = THIS_MODULE;
- bus->adap.retries = 0;
bus->adap.algo = &aspeed_i2c_algo;
bus->adap.dev.parent = &pdev->dev;
bus->adap.dev.of_node = pdev->dev.of_node;
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 734834779d41..9eaf3f89aa7f 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1546,6 +1546,7 @@ static void i2c_adapter_unhold_work(struct work_struct *work)
static int i2c_register_adapter(struct i2c_adapter *adap)
{
+ u32 bus_timeout_ms = 0;
int res = -EINVAL;
/* Can't register until after driver model init */
@@ -1573,8 +1574,15 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
INIT_LIST_HEAD(&adap->userspace_clients);
/* Set default timeout to 1 second if not already set */
- if (adap->timeout == 0)
- adap->timeout = HZ;
+ if (adap->timeout == 0) {
+ device_property_read_u32(&adap->dev, "bus-timeout-ms",
+ &bus_timeout_ms);
+ adap->timeout = bus_timeout_ms ?
+ msecs_to_jiffies(bus_timeout_ms) : HZ;
+ }
+
+ /* Set retries count if it has the property setting */
+ device_property_read_u32(&adap->dev, "#retries", &adap->retries);
/* register soft irqs for Host Notify */
res = i2c_setup_host_notify_irq_domain(adap);