aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorThéo Lebrun <theo.lebrun@bootlin.com>2024-03-06 18:59:27 +0100
committerAndi Shyti <andi.shyti@kernel.org>2024-03-12 11:50:44 +0100
commitec189b9fb83cd1c869d45bfe3c9cb27b71093a16 (patch)
tree117552002fc518b8386e08e6f4c5c0961eff4371 /drivers/i2c/busses
parentc763072ab4533f0669b19c60d8a18b31f2877164 (diff)
downloadlinux-ec189b9fb83cd1c869d45bfe3c9cb27b71093a16.tar.gz
i2c: nomadik: fetch i2c-transfer-timeout-us property from devicetree
Allow overriding the default timeout value (200ms) from devicetree, using the generic i2c-transfer-timeout-us property. The i2c_adapter->timeout field is an unaccurate jiffies amount; i2c-nomadik uses hrtimers for timeouts below one jiffy. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 020beb8ffa17fb..2e738b18677e37 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -975,6 +975,8 @@ static const struct i2c_algorithm nmk_i2c_algo = {
static void nmk_i2c_of_probe(struct device_node *np,
struct nmk_i2c_dev *priv)
{
+ u32 timeout_usecs;
+
/* Default to 100 kHz if no frequency is given in the node */
if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq))
priv->clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
@@ -986,7 +988,12 @@ static void nmk_i2c_of_probe(struct device_node *np,
priv->sm = I2C_FREQ_MODE_FAST;
priv->tft = 1; /* Tx FIFO threshold */
priv->rft = 8; /* Rx FIFO threshold */
- priv->timeout_usecs = 200 * USEC_PER_MSEC; /* Slave response timeout */
+
+ /* Slave response timeout */
+ if (!of_property_read_u32(np, "i2c-transfer-timeout-us", &timeout_usecs))
+ priv->timeout_usecs = timeout_usecs;
+ else
+ priv->timeout_usecs = 200 * USEC_PER_MSEC;
}
static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)