Squashed GMSL patches with full history contained within the commitlogs
v4l: Add RDACM20 driver

The RDACM20 is a GMSL camera developed by IMI based on an Omnivision
10635 sensor and a Maxim MAX9271 GMSL serializer.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---

media: i2c: rdacm20: Remove cross-device writes in s_stream

Remove writes to max9286 subdevice in rdacm20 s_stream now that we have
an s_stream operation in max9286 driver

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

media: i2c: rdacm20: Remove commented out writes in s_stream

Remove writes commented out in rdacm20 s_stream operation.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

v4l: rdacm20: Initialize the hardware before the V4L2 subdev

This ensures that the hardware is responsive before proceeding with
further initialization.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Use an I2C dummy client to communicate with the sensor

Use the right API for the job instead of modifying the address of the
I2C client on the fly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Check the MAX9271 ID register at probe time

This ensures proper communication with the hardware.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Initialize the OV10635 unconditionally

We don't support "MAXIM_IMI_MCU_POWERED" cameras, whatever they are.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Read sensor ID after resetting it

Resetting the sensor first makes sure it will respond properly to the ID
read messages.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Add macros for MAX9271 register bits

The register addresses are left as hardcoded numbers as registers are
not named in the datasheet. Register bits, however, have a name, so
macros can be defined for them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Disable the serial link at startup and stream off time

The serial link only needs to be enabled when streaming video. Disable
it at all other times.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Set I2C addresses of MAX9271 and OV10635 to unique values

Change the address of the MAX9271 and OV10635 from their boot time value
to unique values provided through DT to avoid address conflicts between
multiple channels of a MAX9286 or between multiple MAX9286. I2C address
translation isn't needed with that setup, so we don't configure it.

We have to remove the writes to the OV10635 address register from its
initialization array, otherwise it will be reset to the default address.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Log and react to all I2C communication errors

I2C communication error are bad enough to warrant error messages,
instead of disabled-by-default debug messages.

They also warrant stopping on the first write failure when writing the
sensor initial configuration instead of ignoring all errors.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Configure the MAX9271

Perform the MAX9271 configuration steps that are currently performed by
the max9286 driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: Remove duplicate device address from error messages

The device address is printed by dev_err() as part of the device name,
there's no need to duplicate it in the error message itself.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

v4l: rdacm20: increase delay after enabling control link

The datasheet states that you should wait more then 3ms for the control
link to become available after enabling it. This was discovered while
working with a problematic camera that sporadically failed to probed
with i2c write errors after the control link was enabled.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: read device id after configuration link is enabled

I'm not sure why but some cameras always fail to probe if the driver
tries to read the device ID before first writing to the 0x04 register. I
have no idea why this is, maybe the MCU dose something funny but that
seems unlikely. This should most likely be reverted once the true
problem is found, but for now keep it.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: add delay after changing i2c address

It's not documented in the datasheet but testing shows that
cameras who have a hard time reliably being probed, manage to probe much
more reliably if the driver is delayed by the same amount of time as
when enabling/disabling the control link when reprogramming an i2c
address.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: change i2c address of the max9271 as first step

Move the reprogramming of the max9271 slave address as the first step in
the initialize sequence. This more closely matches the programming guide
and it decreases the chances of failure when communicating with the
max9271.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: use GPIO to rest the OV10635

Software reset don't seem to do the trick. Switching to a hard reset by
toggling the GPIO pin of the max9271 get rids of lots of probe errors
where communication with the OV10635 fails after a short while.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: add delay after hard reset of the OV10635

Allow some time for the OV10635 to power on after toggling the GPIO ping
to reset the sensor. Without this fix there are lots of failures
communicating with the OV10635 shortly after it have been reset.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: rdacm20: add delay after configuring data mode and rate

According to the programming guide one should delay 2ms after changing
this register. Write failures have been observed after this write using
the cameras which needs auto-ack enabled on the MAX9286 to probe. Adding
the delay here fixes the write failure.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

v4l: i2c: rdacm20: Register subdevice on endpoint

v4l2-async framework assigns to subdevice's fwnode the fwnode associated
with device node when the subdevice is registered with fwnode field not
set.
As max9286 registered notifier expects to match the fwnode associated
with the remote endpoint, fix this by assigning the subdevice fwnode
with the endpoint of rdacm20 device node.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

rdacm20: do not sleep after starting the camera

There is no need to sleep here, the max9286 handles the synchronization
by waiting for FSYNC. Sleeping here will only delay to start of multiple
cameras.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

media: i2c: rdacm20: Break MAX9271 configuration into functions

Split the rdacm20_initialize code that modifies the MAX9271 state into
smaller functions, to ease refactoring and allow clear visibility of
configuration orders.

This commit should be a non-configurational change - however it's not.

Please note this commit pulls the configuration of register 0x04 and
0x07 into a single function - and changes the sequence of programming.

The original code flow was: 0x00, 0x04, (r)0x1e, 0x08, 0x0d, 0x07
This new code flow is     : 0x00, 0x04, 0x07, (r)0x1e, 0x08, 0x0d

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

---
This change is probably overkill - but it does / did help me get my head
around the ordering of the configuration - and makes it much easier to
add extra calls to read/verify the ID and try different configuration
orderings.

media: i2c: rdacm20: Increase configuration delays

The deserializer data sheet recommends delays of 5 ms. During testing,
occasional bit errors are seen after or around the writes for
configuration registers, including registers writes not making it across
the bus at all.

Increase the delays to the more conservative 5ms minimum, and also add a
delay which appeared to be missing after register write to 0x0d
configuring the I2C speed.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

media: i2c: rdacm20: Configure I2C and GMSL link before identifying device

Ensure that we make a full attempt at configuring both the GMSL link and
the I2C link before we try to read from the device.

This is vital in ensuring link stability and correct configuration to be
able to read the device ID correctly, and program the new device
address.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

rdacm20: Fix SPDX and copyrights

media: i2c: rdacm20: Detect PCLK before SEREN

Detect valid pixel clock signal from camera before enabling the
serializer serial link.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

media: i2c: gmsl: Use Cogent's settings

Use sensor settings from Cogent ov10635.h sensor driver.
Register values have been compared using a script tool that parses the
sensor configuration.

Notable changes:
* ov10635: Remove dead code
* ov10635: Do not hardcode sizes but use macros
* ov10635: Use falling edge pixel clock

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

media: i2c: rdacm20: Fix a compiler warning

Fix the following compiler warning:
../drivers/media/i2c/rdacm20.c:558:4 warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

rdacm20-ov10635: Hex to lower:

Perform the following operation on the ov10635 register tables:

  sed  -re 's/(0x[0-9a-fA-F]+)/\L\1/g'

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

rdacm20: GPL licence is 2.0+

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

media: i2c: rdacm20: Adjust color space and ycbcr_enc

Set colorspace description informations to correct values.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
4 files changed