From b38a0988d7138f32e3e22f85faf80b80da5e7332 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Thu, 2 May 2013 18:24:21 -0700 Subject: i2c: Allow for i2c "ping" that's a write of 0 bytes The i2cdetect command on Linux likes to probe by doing a write of 0 bytes. Rather than always returning success because there was nothing to write, let's actually implement this command. At the moment we only implement for the stm32l. We also don't try to implement the "read of 0" bytes since I don't think anyone uses that. BUG=chrome-os-partner:18778 BRANCH=none TEST=i2cdetect -y -a 20 now detects the right devices Change-Id: Ia159ce9b8c957d5cd11f187f1a179ca5967bf96f Signed-off-by: Doug Anderson Reviewed-on: https://gerrit.chromium.org/gerrit/50009 Reviewed-by: Simon Glass Tested-by: Simon Glass --- chip/stm32/i2c-stm32l15x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chip/stm32/i2c-stm32l15x.c b/chip/stm32/i2c-stm32l15x.c index dc138ba107..8434db02f2 100644 --- a/chip/stm32/i2c-stm32l15x.c +++ b/chip/stm32/i2c-stm32l15x.c @@ -153,7 +153,9 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes, STM32_I2C_CR1_STOP | STM32_I2C_CR1_POS | STM32_I2C_CR1_ACK); - if (out_bytes) { + + /* No out bytes and no in bytes means just check for active */ + if (out_bytes || !in_bytes) { if (!started) { rv = send_start(port, slave_addr); if (rv) -- cgit v1.2.1