media: i2c: Add driver for THine THP7312

The THP7312 is an external camera ISP from THine. Add a V4L2 subdev
driver for it.

Signed-off-by: Paul Elder <>
Co-developed-by: Laurent Pinchart <>
Signed-off-by: Laurent Pinchart <>
Changes since v7:

- Initialize new_state variable in thp7312_set_focus()

Changes since v6:

- Rebase on top of subdev API changes scheduled for v6.8

Changes since v5:

- Use fwnode API
- Use uapi/ in header path
- Drop TODO comment about THP7312_REG_AF_SETTING
- Drop TODO comment about boot mode check
- Store firmware version in single 16-bit field
- Don't expose AF controls if not supported by the sensor
- Use THP7312_FOCUS_METHOD_* values in AF method control definition
- Drop unused i2c_addr field from thp7312_sensor_info
- Drop support for sensor regulators

Changes since v4:

- Mark runtime PM handlers with __maybe_unused
- Fix indentation in register macros
- Replace ROTATE control with HFLIP and VFLIP
- Add more register bits macros
- Replace macros with direct usage of ARRAY_SIZE
- Drop unused structure fields
- Reorder fw update fields to save space
- Pass explicit true/false values to thp7312_stream_enable()
- Reduce reset pulse length
- White space fixes
- Drop unneeded dev_dbg() message
- Drop unneeded value clamp
- Initialize bus type explicitly
- Move sensor_info to thp7312_sensor
- Cache data lane mappings
- Add LINK_FREQ control
- Rename error labels
- Fix runtime PM initialization and cleanup
- Use runtime PM autosuspend
- Fix power handling in firmware update mode
- Configure MIPI lanes at power up
- Don't setup controls unnecessarily
- Drop unneeded local variable
- Use pm_runtime_get_if_active()

Changes since v3:

- Move thp7312_get_regulators() to probe section
- Turn firmware update handlers static
- Wire up power management in struct driver
- Remove unnecessary double underscore function prefixes
- Configure CSI-2 lanes at stream on time
- Clean up naming of power management functions

Changes since v2:

- Make boot-mode property optional
- Fix dev_err_probe() usage in DT parsing
- Additional dev_err_probe() usage
- Use %u instead of %d for unsigned values
- Don't split lines unnecessarily
- Fix error handling in firmware upload initialization
- Use CCI helpers in firmware update code
- Fix runtime PM usage count
4 files changed