Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: max9271: Introduce wake_up() function

The MAX9271 chip manual prescribes a delay of 5 milliseconds
after the chip exits from low power state.

Add a new function to the max9271 library driver that wakes up the chip
with a dummy i2c transaction and implements the correct delay of 5
milliseconds after the chip exits from low power state.

Use the newly introduced function in the rdacm20 and rdacm21 camera
drivers. The former was not respecting the required delay while the
latter was waiting for a too-short timeout.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Jacopo Mondi and committed by
Mauro Carvalho Chehab
9e0bf839 ad01032a

+23 -7
+12
drivers/media/i2c/max9271.c
··· 80 80 return -EIO; 81 81 } 82 82 83 + void max9271_wake_up(struct max9271_device *dev) 84 + { 85 + /* 86 + * Use the chip default address as this function has to be called 87 + * before any other one. 88 + */ 89 + dev->client->addr = MAX9271_DEFAULT_ADDR; 90 + i2c_smbus_read_byte(dev->client); 91 + usleep_range(5000, 8000); 92 + } 93 + EXPORT_SYMBOL_GPL(max9271_wake_up); 94 + 83 95 int max9271_set_serial_link(struct max9271_device *dev, bool enable) 84 96 { 85 97 int ret;
+9
drivers/media/i2c/max9271.h
··· 86 86 }; 87 87 88 88 /** 89 + * max9271_wake_up() - Wake up the serializer by issuing an i2c transaction 90 + * @dev: The max9271 device 91 + * 92 + * This function shall be called before any other interaction with the 93 + * serializer. 94 + */ 95 + void max9271_wake_up(struct max9271_device *dev); 96 + 97 + /** 89 98 * max9271_set_serial_link() - Enable/disable serial link 90 99 * @dev: The max9271 device 91 100 * @enable: Serial link enable/disable flag
+1 -3
drivers/media/i2c/rdacm20.c
··· 455 455 unsigned int retry = 3; 456 456 int ret; 457 457 458 - /* Verify communication with the MAX9271: ping to wakeup. */ 459 - dev->serializer->client->addr = MAX9271_DEFAULT_ADDR; 460 - i2c_smbus_read_byte(dev->serializer->client); 458 + max9271_wake_up(dev->serializer); 461 459 462 460 /* Serial link disabled during config as it needs a valid pixel clock. */ 463 461 ret = max9271_set_serial_link(dev->serializer, false);
+1 -4
drivers/media/i2c/rdacm21.c
··· 450 450 { 451 451 int ret; 452 452 453 - /* Verify communication with the MAX9271: ping to wakeup. */ 454 - dev->serializer.client->addr = MAX9271_DEFAULT_ADDR; 455 - i2c_smbus_read_byte(dev->serializer.client); 456 - usleep_range(3000, 5000); 453 + max9271_wake_up(&dev->serializer); 457 454 458 455 /* Enable reverse channel and disable the serial link. */ 459 456 ret = max9271_set_serial_link(&dev->serializer, false);