Skip to content

Commit 9e0bf83

Browse files
Jacopo Mondimchehab
authored andcommitted
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 <[email protected]> Reviewed-by: Kieran Bingham <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent ad01032 commit 9e0bf83

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

drivers/media/i2c/max9271.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ static int max9271_pclk_detect(struct max9271_device *dev)
8080
return -EIO;
8181
}
8282

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+
8395
int max9271_set_serial_link(struct max9271_device *dev, bool enable)
8496
{
8597
int ret;

drivers/media/i2c/max9271.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ struct max9271_device {
8585
struct i2c_client *client;
8686
};
8787

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+
8897
/**
8998
* max9271_set_serial_link() - Enable/disable serial link
9099
* @dev: The max9271 device

drivers/media/i2c/rdacm20.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,7 @@ static int rdacm20_initialize(struct rdacm20_device *dev)
455455
unsigned int retry = 3;
456456
int ret;
457457

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);
461459

462460
/* Serial link disabled during config as it needs a valid pixel clock. */
463461
ret = max9271_set_serial_link(dev->serializer, false);

drivers/media/i2c/rdacm21.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,7 @@ static int rdacm21_initialize(struct rdacm21_device *dev)
450450
{
451451
int ret;
452452

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);
457454

458455
/* Enable reverse channel and disable the serial link. */
459456
ret = max9271_set_serial_link(&dev->serializer, false);

0 commit comments

Comments
 (0)