Skip to content

Commit ec189b9

Browse files
tlebAndi Shyti
authored andcommitted
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>
1 parent c763072 commit ec189b9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/i2c/busses/i2c-nomadik.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ static const struct i2c_algorithm nmk_i2c_algo = {
975975
static void nmk_i2c_of_probe(struct device_node *np,
976976
struct nmk_i2c_dev *priv)
977977
{
978+
u32 timeout_usecs;
979+
978980
/* Default to 100 kHz if no frequency is given in the node */
979981
if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq))
980982
priv->clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
@@ -986,7 +988,12 @@ static void nmk_i2c_of_probe(struct device_node *np,
986988
priv->sm = I2C_FREQ_MODE_FAST;
987989
priv->tft = 1; /* Tx FIFO threshold */
988990
priv->rft = 8; /* Rx FIFO threshold */
989-
priv->timeout_usecs = 200 * USEC_PER_MSEC; /* Slave response timeout */
991+
992+
/* Slave response timeout */
993+
if (!of_property_read_u32(np, "i2c-transfer-timeout-us", &timeout_usecs))
994+
priv->timeout_usecs = timeout_usecs;
995+
else
996+
priv->timeout_usecs = 200 * USEC_PER_MSEC;
990997
}
991998

992999
static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)

0 commit comments

Comments
 (0)