18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * IMI RDACM20 GMSL Camera Driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2017-2020 Jacopo Mondi
68c2ecf20Sopenharmony_ci * Copyright (C) 2017-2020 Kieran Bingham
78c2ecf20Sopenharmony_ci * Copyright (C) 2017-2019 Laurent Pinchart
88c2ecf20Sopenharmony_ci * Copyright (C) 2017-2019 Niklas Söderlund
98c2ecf20Sopenharmony_ci * Copyright (C) 2016 Renesas Electronics Corporation
108c2ecf20Sopenharmony_ci * Copyright (C) 2015 Cogent Embedded, Inc.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * The camera is made of an Omnivision OV10635 sensor connected to a Maxim
158c2ecf20Sopenharmony_ci * MAX9271 GMSL serializer.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <linux/delay.h>
198c2ecf20Sopenharmony_ci#include <linux/fwnode.h>
208c2ecf20Sopenharmony_ci#include <linux/init.h>
218c2ecf20Sopenharmony_ci#include <linux/i2c.h>
228c2ecf20Sopenharmony_ci#include <linux/module.h>
238c2ecf20Sopenharmony_ci#include <linux/slab.h>
248c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <media/v4l2-async.h>
278c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h>
288c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#include "max9271.h"
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define OV10635_I2C_ADDRESS		0x30
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define OV10635_SOFTWARE_RESET		0x0103
358c2ecf20Sopenharmony_ci#define OV10635_PID			0x300a
368c2ecf20Sopenharmony_ci#define OV10635_VER			0x300b
378c2ecf20Sopenharmony_ci#define OV10635_SC_CMMN_SCCB_ID		0x300c
388c2ecf20Sopenharmony_ci#define OV10635_SC_CMMN_SCCB_ID_SELECT	BIT(0)
398c2ecf20Sopenharmony_ci#define OV10635_VERSION			0xa635
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define OV10635_WIDTH			1280
428c2ecf20Sopenharmony_ci#define OV10635_HEIGHT			800
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* VTS = PCLK / FPS / HTS / 2 (= 88MHz / 1572 / 30 / 2) */
458c2ecf20Sopenharmony_ci#define OV10635_HTS			1572
468c2ecf20Sopenharmony_ci/* FPS = 29,9998 */
478c2ecf20Sopenharmony_ci#define OV10635_VTS			933
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/*
508c2ecf20Sopenharmony_ci * As the drivers supports a single MEDIA_BUS_FMT_UYVY8_2X8 format we
518c2ecf20Sopenharmony_ci * can harcode the pixel rate.
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci * PCLK is fed through the system clock, programmed @88MHz.
548c2ecf20Sopenharmony_ci * MEDIA_BUS_FMT_UYVY8_2X8 format = 2 samples per pixel.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * Pixelrate = PCLK / 2
578c2ecf20Sopenharmony_ci * FPS = (OV10635_VTS * OV10635_HTS) / PixelRate
588c2ecf20Sopenharmony_ci *     = 29,9998
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ci#define OV10635_PIXEL_RATE		(44000000)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic const struct ov10635_reg {
638c2ecf20Sopenharmony_ci	u16	reg;
648c2ecf20Sopenharmony_ci	u8	val;
658c2ecf20Sopenharmony_ci} ov10635_regs_wizard[] = {
668c2ecf20Sopenharmony_ci	{ 0x301b, 0xff }, { 0x301c, 0xff }, { 0x301a, 0xff }, { 0x3011, 0x42 },
678c2ecf20Sopenharmony_ci	{ 0x6900, 0x0c }, { 0x6901, 0x19 }, { 0x3503, 0x10 }, { 0x3025, 0x03 },
688c2ecf20Sopenharmony_ci	{ 0x3003, 0x16 }, { 0x3004, 0x30 }, { 0x3005, 0x40 }, { 0x3006, 0x91 },
698c2ecf20Sopenharmony_ci	{ 0x3600, 0x74 }, { 0x3601, 0x2b }, { 0x3612, 0x00 }, { 0x3611, 0x67 },
708c2ecf20Sopenharmony_ci	{ 0x3633, 0xca }, { 0x3602, 0xaf }, { 0x3603, 0x04 }, { 0x3630, 0x28 },
718c2ecf20Sopenharmony_ci	{ 0x3631, 0x16 }, { 0x3714, 0x10 }, { 0x371d, 0x01 }, { 0x4300, 0x3a },
728c2ecf20Sopenharmony_ci	{ 0x3007, 0x01 }, { 0x3024, 0x03 }, { 0x3020, 0x0a }, { 0x3702, 0x0d },
738c2ecf20Sopenharmony_ci	{ 0x3703, 0x20 }, { 0x3704, 0x15 }, { 0x3709, 0xa8 }, { 0x370c, 0xc7 },
748c2ecf20Sopenharmony_ci	{ 0x370d, 0x80 }, { 0x3712, 0x00 }, { 0x3713, 0x20 }, { 0x3715, 0x04 },
758c2ecf20Sopenharmony_ci	{ 0x381d, 0x40 }, { 0x381c, 0x00 }, { 0x3822, 0x50 }, { 0x3824, 0x10 },
768c2ecf20Sopenharmony_ci	{ 0x3815, 0x8c }, { 0x3804, 0x05 }, { 0x3805, 0x1f }, { 0x3800, 0x00 },
778c2ecf20Sopenharmony_ci	{ 0x3801, 0x00 }, { 0x3806, 0x03 }, { 0x3807, 0x28 }, { 0x3802, 0x00 },
788c2ecf20Sopenharmony_ci	{ 0x3803, 0x07 }, { 0x3808, 0x05 }, { 0x3809, 0x00 }, { 0x380a, 0x03 },
798c2ecf20Sopenharmony_ci	{ 0x380b, 0x20 }, { 0x380c, OV10635_HTS >> 8 },
808c2ecf20Sopenharmony_ci	{ 0x380d, OV10635_HTS & 0xff }, { 0x380e, OV10635_VTS >> 8 },
818c2ecf20Sopenharmony_ci	{ 0x380f, OV10635_VTS & 0xff },	{ 0x3813, 0x02 }, { 0x3811, 0x08 },
828c2ecf20Sopenharmony_ci	{ 0x381f, 0x0c }, { 0x3819, 0x04 }, { 0x3804, 0x01 }, { 0x3805, 0x00 },
838c2ecf20Sopenharmony_ci	{ 0x3828, 0x03 }, { 0x3829, 0x10 }, { 0x382a, 0x10 }, { 0x3621, 0x63 },
848c2ecf20Sopenharmony_ci	{ 0x5005, 0x08 }, { 0x56d5, 0x00 }, { 0x56d6, 0x80 }, { 0x56d7, 0x00 },
858c2ecf20Sopenharmony_ci	{ 0x56d8, 0x00 }, { 0x56d9, 0x00 }, { 0x56da, 0x80 }, { 0x56db, 0x00 },
868c2ecf20Sopenharmony_ci	{ 0x56dc, 0x00 }, { 0x56e8, 0x00 }, { 0x56e9, 0x7f }, { 0x56ea, 0x00 },
878c2ecf20Sopenharmony_ci	{ 0x56eb, 0x7f }, { 0x5100, 0x00 }, { 0x5101, 0x80 }, { 0x5102, 0x00 },
888c2ecf20Sopenharmony_ci	{ 0x5103, 0x80 }, { 0x5104, 0x00 }, { 0x5105, 0x80 }, { 0x5106, 0x00 },
898c2ecf20Sopenharmony_ci	{ 0x5107, 0x80 }, { 0x5108, 0x00 }, { 0x5109, 0x00 }, { 0x510a, 0x00 },
908c2ecf20Sopenharmony_ci	{ 0x510b, 0x00 }, { 0x510c, 0x00 }, { 0x510d, 0x00 }, { 0x510e, 0x00 },
918c2ecf20Sopenharmony_ci	{ 0x510f, 0x00 }, { 0x5110, 0x00 }, { 0x5111, 0x80 }, { 0x5112, 0x00 },
928c2ecf20Sopenharmony_ci	{ 0x5113, 0x80 }, { 0x5114, 0x00 }, { 0x5115, 0x80 }, { 0x5116, 0x00 },
938c2ecf20Sopenharmony_ci	{ 0x5117, 0x80 }, { 0x5118, 0x00 }, { 0x5119, 0x00 }, { 0x511a, 0x00 },
948c2ecf20Sopenharmony_ci	{ 0x511b, 0x00 }, { 0x511c, 0x00 }, { 0x511d, 0x00 }, { 0x511e, 0x00 },
958c2ecf20Sopenharmony_ci	{ 0x511f, 0x00 }, { 0x56d0, 0x00 }, { 0x5006, 0x04 }, { 0x5608, 0x05 },
968c2ecf20Sopenharmony_ci	{ 0x52d7, 0x06 }, { 0x528d, 0x08 }, { 0x5293, 0x12 }, { 0x52d3, 0x12 },
978c2ecf20Sopenharmony_ci	{ 0x5288, 0x06 }, { 0x5289, 0x20 }, { 0x52c8, 0x06 }, { 0x52c9, 0x20 },
988c2ecf20Sopenharmony_ci	{ 0x52cd, 0x04 }, { 0x5381, 0x00 }, { 0x5382, 0xff }, { 0x5589, 0x76 },
998c2ecf20Sopenharmony_ci	{ 0x558a, 0x47 }, { 0x558b, 0xef }, { 0x558c, 0xc9 }, { 0x558d, 0x49 },
1008c2ecf20Sopenharmony_ci	{ 0x558e, 0x30 }, { 0x558f, 0x67 }, { 0x5590, 0x3f }, { 0x5591, 0xf0 },
1018c2ecf20Sopenharmony_ci	{ 0x5592, 0x10 }, { 0x55a2, 0x6d }, { 0x55a3, 0x55 }, { 0x55a4, 0xc3 },
1028c2ecf20Sopenharmony_ci	{ 0x55a5, 0xb5 }, { 0x55a6, 0x43 }, { 0x55a7, 0x38 }, { 0x55a8, 0x5f },
1038c2ecf20Sopenharmony_ci	{ 0x55a9, 0x4b }, { 0x55aa, 0xf0 }, { 0x55ab, 0x10 }, { 0x5581, 0x52 },
1048c2ecf20Sopenharmony_ci	{ 0x5300, 0x01 }, { 0x5301, 0x00 }, { 0x5302, 0x00 }, { 0x5303, 0x0e },
1058c2ecf20Sopenharmony_ci	{ 0x5304, 0x00 }, { 0x5305, 0x0e }, { 0x5306, 0x00 }, { 0x5307, 0x36 },
1068c2ecf20Sopenharmony_ci	{ 0x5308, 0x00 }, { 0x5309, 0xd9 }, { 0x530a, 0x00 }, { 0x530b, 0x0f },
1078c2ecf20Sopenharmony_ci	{ 0x530c, 0x00 }, { 0x530d, 0x2c }, { 0x530e, 0x00 }, { 0x530f, 0x59 },
1088c2ecf20Sopenharmony_ci	{ 0x5310, 0x00 }, { 0x5311, 0x7b }, { 0x5312, 0x00 }, { 0x5313, 0x22 },
1098c2ecf20Sopenharmony_ci	{ 0x5314, 0x00 }, { 0x5315, 0xd5 }, { 0x5316, 0x00 }, { 0x5317, 0x13 },
1108c2ecf20Sopenharmony_ci	{ 0x5318, 0x00 }, { 0x5319, 0x18 }, { 0x531a, 0x00 }, { 0x531b, 0x26 },
1118c2ecf20Sopenharmony_ci	{ 0x531c, 0x00 }, { 0x531d, 0xdc }, { 0x531e, 0x00 }, { 0x531f, 0x02 },
1128c2ecf20Sopenharmony_ci	{ 0x5320, 0x00 }, { 0x5321, 0x24 }, { 0x5322, 0x00 }, { 0x5323, 0x56 },
1138c2ecf20Sopenharmony_ci	{ 0x5324, 0x00 }, { 0x5325, 0x85 }, { 0x5326, 0x00 }, { 0x5327, 0x20 },
1148c2ecf20Sopenharmony_ci	{ 0x5609, 0x01 }, { 0x560a, 0x40 }, { 0x560b, 0x01 }, { 0x560c, 0x40 },
1158c2ecf20Sopenharmony_ci	{ 0x560d, 0x00 }, { 0x560e, 0xfa }, { 0x560f, 0x00 }, { 0x5610, 0xfa },
1168c2ecf20Sopenharmony_ci	{ 0x5611, 0x02 }, { 0x5612, 0x80 }, { 0x5613, 0x02 }, { 0x5614, 0x80 },
1178c2ecf20Sopenharmony_ci	{ 0x5615, 0x01 }, { 0x5616, 0x2c }, { 0x5617, 0x01 }, { 0x5618, 0x2c },
1188c2ecf20Sopenharmony_ci	{ 0x563b, 0x01 }, { 0x563c, 0x01 }, { 0x563d, 0x01 }, { 0x563e, 0x01 },
1198c2ecf20Sopenharmony_ci	{ 0x563f, 0x03 }, { 0x5640, 0x03 }, { 0x5641, 0x03 }, { 0x5642, 0x05 },
1208c2ecf20Sopenharmony_ci	{ 0x5643, 0x09 }, { 0x5644, 0x05 }, { 0x5645, 0x05 }, { 0x5646, 0x05 },
1218c2ecf20Sopenharmony_ci	{ 0x5647, 0x05 }, { 0x5651, 0x00 }, { 0x5652, 0x80 }, { 0x521a, 0x01 },
1228c2ecf20Sopenharmony_ci	{ 0x521b, 0x03 }, { 0x521c, 0x06 }, { 0x521d, 0x0a }, { 0x521e, 0x0e },
1238c2ecf20Sopenharmony_ci	{ 0x521f, 0x12 }, { 0x5220, 0x16 }, { 0x5223, 0x02 }, { 0x5225, 0x04 },
1248c2ecf20Sopenharmony_ci	{ 0x5227, 0x08 }, { 0x5229, 0x0c }, { 0x522b, 0x12 }, { 0x522d, 0x18 },
1258c2ecf20Sopenharmony_ci	{ 0x522f, 0x1e }, { 0x5241, 0x04 }, { 0x5242, 0x01 }, { 0x5243, 0x03 },
1268c2ecf20Sopenharmony_ci	{ 0x5244, 0x06 }, { 0x5245, 0x0a }, { 0x5246, 0x0e }, { 0x5247, 0x12 },
1278c2ecf20Sopenharmony_ci	{ 0x5248, 0x16 }, { 0x524a, 0x03 }, { 0x524c, 0x04 }, { 0x524e, 0x08 },
1288c2ecf20Sopenharmony_ci	{ 0x5250, 0x0c }, { 0x5252, 0x12 }, { 0x5254, 0x18 }, { 0x5256, 0x1e },
1298c2ecf20Sopenharmony_ci	/* fifo_line_length = 2*hts */
1308c2ecf20Sopenharmony_ci	{ 0x4606, (2 * OV10635_HTS) >> 8 }, { 0x4607, (2 * OV10635_HTS) & 0xff },
1318c2ecf20Sopenharmony_ci	/* fifo_hsync_start = 2*(hts - xres) */
1328c2ecf20Sopenharmony_ci	{ 0x460a, (2 * (OV10635_HTS - OV10635_WIDTH)) >> 8 },
1338c2ecf20Sopenharmony_ci	{ 0x460b, (2 * (OV10635_HTS - OV10635_WIDTH)) & 0xff },
1348c2ecf20Sopenharmony_ci	{ 0x460c, 0x00 }, { 0x4620, 0x0e },
1358c2ecf20Sopenharmony_ci	/* BT601: 0x08 is also acceptable as HS/VS mode */
1368c2ecf20Sopenharmony_ci	{ 0x4700, 0x04 }, { 0x4701, 0x00 }, { 0x4702, 0x01 }, { 0x4004, 0x04 },
1378c2ecf20Sopenharmony_ci	{ 0x4005, 0x18 }, { 0x4001, 0x06 }, { 0x4050, 0x22 }, { 0x4051, 0x24 },
1388c2ecf20Sopenharmony_ci	{ 0x4052, 0x02 }, { 0x4057, 0x9c }, { 0x405a, 0x00 }, { 0x4202, 0x02 },
1398c2ecf20Sopenharmony_ci	{ 0x3023, 0x10 }, { 0x0100, 0x01 }, { 0x0100, 0x01 }, { 0x6f10, 0x07 },
1408c2ecf20Sopenharmony_ci	{ 0x6f11, 0x82 }, { 0x6f12, 0x04 }, { 0x6f13, 0x00 }, { 0xd000, 0x19 },
1418c2ecf20Sopenharmony_ci	{ 0xd001, 0xa0 }, { 0xd002, 0x00 }, { 0xd003, 0x01 }, { 0xd004, 0xa9 },
1428c2ecf20Sopenharmony_ci	{ 0xd005, 0xad }, { 0xd006, 0x10 }, { 0xd007, 0x40 }, { 0xd008, 0x44 },
1438c2ecf20Sopenharmony_ci	{ 0xd009, 0x00 }, { 0xd00a, 0x68 }, { 0xd00b, 0x00 }, { 0xd00c, 0x15 },
1448c2ecf20Sopenharmony_ci	{ 0xd00d, 0x00 }, { 0xd00e, 0x00 }, { 0xd00f, 0x00 }, { 0xd040, 0x9c },
1458c2ecf20Sopenharmony_ci	{ 0xd041, 0x21 }, { 0xd042, 0xff }, { 0xd043, 0xf8 }, { 0xd044, 0xd4 },
1468c2ecf20Sopenharmony_ci	{ 0xd045, 0x01 }, { 0xd046, 0x48 }, { 0xd047, 0x00 }, { 0xd048, 0xd4 },
1478c2ecf20Sopenharmony_ci	{ 0xd049, 0x01 }, { 0xd04a, 0x50 }, { 0xd04b, 0x04 }, { 0xd04c, 0x18 },
1488c2ecf20Sopenharmony_ci	{ 0xd04d, 0x60 }, { 0xd04e, 0x00 }, { 0xd04f, 0x01 }, { 0xd050, 0xa8 },
1498c2ecf20Sopenharmony_ci	{ 0xd051, 0x63 }, { 0xd052, 0x02 }, { 0xd053, 0xa4 }, { 0xd054, 0x85 },
1508c2ecf20Sopenharmony_ci	{ 0xd055, 0x43 }, { 0xd056, 0x00 }, { 0xd057, 0x00 }, { 0xd058, 0x18 },
1518c2ecf20Sopenharmony_ci	{ 0xd059, 0x60 }, { 0xd05a, 0x00 }, { 0xd05b, 0x01 }, { 0xd05c, 0xa8 },
1528c2ecf20Sopenharmony_ci	{ 0xd05d, 0x63 }, { 0xd05e, 0x03 }, { 0xd05f, 0xf0 }, { 0xd060, 0x98 },
1538c2ecf20Sopenharmony_ci	{ 0xd061, 0xa3 }, { 0xd062, 0x00 }, { 0xd063, 0x00 }, { 0xd064, 0x8c },
1548c2ecf20Sopenharmony_ci	{ 0xd065, 0x6a }, { 0xd066, 0x00 }, { 0xd067, 0x6e }, { 0xd068, 0xe5 },
1558c2ecf20Sopenharmony_ci	{ 0xd069, 0x85 }, { 0xd06a, 0x18 }, { 0xd06b, 0x00 }, { 0xd06c, 0x10 },
1568c2ecf20Sopenharmony_ci	{ 0xd06d, 0x00 }, { 0xd06e, 0x00 }, { 0xd06f, 0x10 }, { 0xd070, 0x9c },
1578c2ecf20Sopenharmony_ci	{ 0xd071, 0x80 }, { 0xd072, 0x00 }, { 0xd073, 0x03 }, { 0xd074, 0x18 },
1588c2ecf20Sopenharmony_ci	{ 0xd075, 0x60 }, { 0xd076, 0x00 }, { 0xd077, 0x01 }, { 0xd078, 0xa8 },
1598c2ecf20Sopenharmony_ci	{ 0xd079, 0x63 }, { 0xd07a, 0x07 }, { 0xd07b, 0x80 }, { 0xd07c, 0x07 },
1608c2ecf20Sopenharmony_ci	{ 0xd07d, 0xff }, { 0xd07e, 0xf9 }, { 0xd07f, 0x03 }, { 0xd080, 0x8c },
1618c2ecf20Sopenharmony_ci	{ 0xd081, 0x63 }, { 0xd082, 0x00 }, { 0xd083, 0x00 }, { 0xd084, 0xa5 },
1628c2ecf20Sopenharmony_ci	{ 0xd085, 0x6b }, { 0xd086, 0x00 }, { 0xd087, 0xff }, { 0xd088, 0x18 },
1638c2ecf20Sopenharmony_ci	{ 0xd089, 0x80 }, { 0xd08a, 0x00 }, { 0xd08b, 0x01 }, { 0xd08c, 0xa8 },
1648c2ecf20Sopenharmony_ci	{ 0xd08d, 0x84 }, { 0xd08e, 0x01 }, { 0xd08f, 0x04 }, { 0xd090, 0xe1 },
1658c2ecf20Sopenharmony_ci	{ 0xd091, 0x6b }, { 0xd092, 0x58 }, { 0xd093, 0x00 }, { 0xd094, 0x94 },
1668c2ecf20Sopenharmony_ci	{ 0xd095, 0x6a }, { 0xd096, 0x00 }, { 0xd097, 0x70 }, { 0xd098, 0xe1 },
1678c2ecf20Sopenharmony_ci	{ 0xd099, 0x6b }, { 0xd09a, 0x20 }, { 0xd09b, 0x00 }, { 0xd09c, 0x95 },
1688c2ecf20Sopenharmony_ci	{ 0xd09d, 0x6b }, { 0xd09e, 0x00 }, { 0xd09f, 0x00 }, { 0xd0a0, 0xe4 },
1698c2ecf20Sopenharmony_ci	{ 0xd0a1, 0x8b }, { 0xd0a2, 0x18 }, { 0xd0a3, 0x00 }, { 0xd0a4, 0x0c },
1708c2ecf20Sopenharmony_ci	{ 0xd0a5, 0x00 }, { 0xd0a6, 0x00 }, { 0xd0a7, 0x23 }, { 0xd0a8, 0x15 },
1718c2ecf20Sopenharmony_ci	{ 0xd0a9, 0x00 }, { 0xd0aa, 0x00 }, { 0xd0ab, 0x00 }, { 0xd0ac, 0x18 },
1728c2ecf20Sopenharmony_ci	{ 0xd0ad, 0x60 }, { 0xd0ae, 0x80 }, { 0xd0af, 0x06 }, { 0xd0b0, 0xa8 },
1738c2ecf20Sopenharmony_ci	{ 0xd0b1, 0x83 }, { 0xd0b2, 0x40 }, { 0xd0b3, 0x08 }, { 0xd0b4, 0xa8 },
1748c2ecf20Sopenharmony_ci	{ 0xd0b5, 0xe3 }, { 0xd0b6, 0x38 }, { 0xd0b7, 0x2a }, { 0xd0b8, 0xa8 },
1758c2ecf20Sopenharmony_ci	{ 0xd0b9, 0xc3 }, { 0xd0ba, 0x40 }, { 0xd0bb, 0x09 }, { 0xd0bc, 0xa8 },
1768c2ecf20Sopenharmony_ci	{ 0xd0bd, 0xa3 }, { 0xd0be, 0x38 }, { 0xd0bf, 0x29 }, { 0xd0c0, 0x8c },
1778c2ecf20Sopenharmony_ci	{ 0xd0c1, 0x65 }, { 0xd0c2, 0x00 }, { 0xd0c3, 0x00 }, { 0xd0c4, 0xd8 },
1788c2ecf20Sopenharmony_ci	{ 0xd0c5, 0x04 }, { 0xd0c6, 0x18 }, { 0xd0c7, 0x00 }, { 0xd0c8, 0x8c },
1798c2ecf20Sopenharmony_ci	{ 0xd0c9, 0x67 }, { 0xd0ca, 0x00 }, { 0xd0cb, 0x00 }, { 0xd0cc, 0xd8 },
1808c2ecf20Sopenharmony_ci	{ 0xd0cd, 0x06 }, { 0xd0ce, 0x18 }, { 0xd0cf, 0x00 }, { 0xd0d0, 0x18 },
1818c2ecf20Sopenharmony_ci	{ 0xd0d1, 0x60 }, { 0xd0d2, 0x80 }, { 0xd0d3, 0x06 }, { 0xd0d4, 0xa8 },
1828c2ecf20Sopenharmony_ci	{ 0xd0d5, 0xe3 }, { 0xd0d6, 0x67 }, { 0xd0d7, 0x02 }, { 0xd0d8, 0xa9 },
1838c2ecf20Sopenharmony_ci	{ 0xd0d9, 0x03 }, { 0xd0da, 0x67 }, { 0xd0db, 0x03 }, { 0xd0dc, 0xa8 },
1848c2ecf20Sopenharmony_ci	{ 0xd0dd, 0xc3 }, { 0xd0de, 0x3d }, { 0xd0df, 0x05 }, { 0xd0e0, 0x8c },
1858c2ecf20Sopenharmony_ci	{ 0xd0e1, 0x66 }, { 0xd0e2, 0x00 }, { 0xd0e3, 0x00 }, { 0xd0e4, 0xb8 },
1868c2ecf20Sopenharmony_ci	{ 0xd0e5, 0x63 }, { 0xd0e6, 0x00 }, { 0xd0e7, 0x18 }, { 0xd0e8, 0xb8 },
1878c2ecf20Sopenharmony_ci	{ 0xd0e9, 0x63 }, { 0xd0ea, 0x00 }, { 0xd0eb, 0x98 }, { 0xd0ec, 0xbc },
1888c2ecf20Sopenharmony_ci	{ 0xd0ed, 0x03 }, { 0xd0ee, 0x00 }, { 0xd0ef, 0x00 }, { 0xd0f0, 0x10 },
1898c2ecf20Sopenharmony_ci	{ 0xd0f1, 0x00 }, { 0xd0f2, 0x00 }, { 0xd0f3, 0x16 }, { 0xd0f4, 0xb8 },
1908c2ecf20Sopenharmony_ci	{ 0xd0f5, 0x83 }, { 0xd0f6, 0x00 }, { 0xd0f7, 0x19 }, { 0xd0f8, 0x8c },
1918c2ecf20Sopenharmony_ci	{ 0xd0f9, 0x67 }, { 0xd0fa, 0x00 }, { 0xd0fb, 0x00 }, { 0xd0fc, 0xb8 },
1928c2ecf20Sopenharmony_ci	{ 0xd0fd, 0xa4 }, { 0xd0fe, 0x00 }, { 0xd0ff, 0x98 }, { 0xd100, 0xb8 },
1938c2ecf20Sopenharmony_ci	{ 0xd101, 0x83 }, { 0xd102, 0x00 }, { 0xd103, 0x08 }, { 0xd104, 0x8c },
1948c2ecf20Sopenharmony_ci	{ 0xd105, 0x68 }, { 0xd106, 0x00 }, { 0xd107, 0x00 }, { 0xd108, 0xe0 },
1958c2ecf20Sopenharmony_ci	{ 0xd109, 0x63 }, { 0xd10a, 0x20 }, { 0xd10b, 0x04 }, { 0xd10c, 0xe0 },
1968c2ecf20Sopenharmony_ci	{ 0xd10d, 0x65 }, { 0xd10e, 0x18 }, { 0xd10f, 0x00 }, { 0xd110, 0xa4 },
1978c2ecf20Sopenharmony_ci	{ 0xd111, 0x83 }, { 0xd112, 0xff }, { 0xd113, 0xff }, { 0xd114, 0xb8 },
1988c2ecf20Sopenharmony_ci	{ 0xd115, 0x64 }, { 0xd116, 0x00 }, { 0xd117, 0x48 }, { 0xd118, 0xd8 },
1998c2ecf20Sopenharmony_ci	{ 0xd119, 0x07 }, { 0xd11a, 0x18 }, { 0xd11b, 0x00 }, { 0xd11c, 0xd8 },
2008c2ecf20Sopenharmony_ci	{ 0xd11d, 0x08 }, { 0xd11e, 0x20 }, { 0xd11f, 0x00 }, { 0xd120, 0x9c },
2018c2ecf20Sopenharmony_ci	{ 0xd121, 0x60 }, { 0xd122, 0x00 }, { 0xd123, 0x00 }, { 0xd124, 0xd8 },
2028c2ecf20Sopenharmony_ci	{ 0xd125, 0x06 }, { 0xd126, 0x18 }, { 0xd127, 0x00 }, { 0xd128, 0x00 },
2038c2ecf20Sopenharmony_ci	{ 0xd129, 0x00 }, { 0xd12a, 0x00 }, { 0xd12b, 0x08 }, { 0xd12c, 0x15 },
2048c2ecf20Sopenharmony_ci	{ 0xd12d, 0x00 }, { 0xd12e, 0x00 }, { 0xd12f, 0x00 }, { 0xd130, 0x8c },
2058c2ecf20Sopenharmony_ci	{ 0xd131, 0x6a }, { 0xd132, 0x00 }, { 0xd133, 0x76 }, { 0xd134, 0xbc },
2068c2ecf20Sopenharmony_ci	{ 0xd135, 0x23 }, { 0xd136, 0x00 }, { 0xd137, 0x00 }, { 0xd138, 0x13 },
2078c2ecf20Sopenharmony_ci	{ 0xd139, 0xff }, { 0xd13a, 0xff }, { 0xd13b, 0xe6 }, { 0xd13c, 0x18 },
2088c2ecf20Sopenharmony_ci	{ 0xd13d, 0x60 }, { 0xd13e, 0x80 }, { 0xd13f, 0x06 }, { 0xd140, 0x03 },
2098c2ecf20Sopenharmony_ci	{ 0xd141, 0xff }, { 0xd142, 0xff }, { 0xd143, 0xdd }, { 0xd144, 0xa8 },
2108c2ecf20Sopenharmony_ci	{ 0xd145, 0x83 }, { 0xd146, 0x40 }, { 0xd147, 0x08 }, { 0xd148, 0x85 },
2118c2ecf20Sopenharmony_ci	{ 0xd149, 0x21 }, { 0xd14a, 0x00 }, { 0xd14b, 0x00 }, { 0xd14c, 0x85 },
2128c2ecf20Sopenharmony_ci	{ 0xd14d, 0x41 }, { 0xd14e, 0x00 }, { 0xd14f, 0x04 }, { 0xd150, 0x44 },
2138c2ecf20Sopenharmony_ci	{ 0xd151, 0x00 }, { 0xd152, 0x48 }, { 0xd153, 0x00 }, { 0xd154, 0x9c },
2148c2ecf20Sopenharmony_ci	{ 0xd155, 0x21 }, { 0xd156, 0x00 }, { 0xd157, 0x08 }, { 0x6f0e, 0x03 },
2158c2ecf20Sopenharmony_ci	{ 0x6f0f, 0x00 }, { 0x460e, 0x08 }, { 0x460f, 0x01 }, { 0x4610, 0x00 },
2168c2ecf20Sopenharmony_ci	{ 0x4611, 0x01 }, { 0x4612, 0x00 }, { 0x4613, 0x01 },
2178c2ecf20Sopenharmony_ci	/* 8 bits */
2188c2ecf20Sopenharmony_ci	{ 0x4605, 0x08 },
2198c2ecf20Sopenharmony_ci	/* Swap data bits order [9:0] -> [0:9] */
2208c2ecf20Sopenharmony_ci	{ 0x4709, 0x10 }, { 0x4608, 0x00 }, { 0x4609, 0x08 }, { 0x6804, 0x00 },
2218c2ecf20Sopenharmony_ci	{ 0x6805, 0x06 }, { 0x6806, 0x00 }, { 0x5120, 0x00 }, { 0x3510, 0x00 },
2228c2ecf20Sopenharmony_ci	{ 0x3504, 0x00 }, { 0x6800, 0x00 }, { 0x6f0d, 0x01 },
2238c2ecf20Sopenharmony_ci	/* PCLK falling edge */
2248c2ecf20Sopenharmony_ci	{ 0x4708, 0x01 }, { 0x5000, 0xff }, { 0x5001, 0xbf }, { 0x5002, 0x7e },
2258c2ecf20Sopenharmony_ci	{ 0x503d, 0x00 }, { 0xc450, 0x01 }, { 0xc452, 0x04 }, { 0xc453, 0x00 },
2268c2ecf20Sopenharmony_ci	{ 0xc454, 0x00 }, { 0xc455, 0x01 }, { 0xc456, 0x01 }, { 0xc457, 0x00 },
2278c2ecf20Sopenharmony_ci	{ 0xc458, 0x00 }, { 0xc459, 0x00 }, { 0xc45b, 0x00 }, { 0xc45c, 0x01 },
2288c2ecf20Sopenharmony_ci	{ 0xc45d, 0x00 }, { 0xc45e, 0x00 }, { 0xc45f, 0x00 }, { 0xc460, 0x00 },
2298c2ecf20Sopenharmony_ci	{ 0xc461, 0x01 }, { 0xc462, 0x01 }, { 0xc464, 0x03 }, { 0xc465, 0x00 },
2308c2ecf20Sopenharmony_ci	{ 0xc466, 0x8a }, { 0xc467, 0x00 }, { 0xc468, 0x86 }, { 0xc469, 0x00 },
2318c2ecf20Sopenharmony_ci	{ 0xc46a, 0x40 }, { 0xc46b, 0x50 }, { 0xc46c, 0x30 }, { 0xc46d, 0x28 },
2328c2ecf20Sopenharmony_ci	{ 0xc46e, 0x60 }, { 0xc46f, 0x40 }, { 0xc47c, 0x01 }, { 0xc47d, 0x38 },
2338c2ecf20Sopenharmony_ci	{ 0xc47e, 0x00 }, { 0xc47f, 0x00 }, { 0xc480, 0x00 }, { 0xc481, 0xff },
2348c2ecf20Sopenharmony_ci	{ 0xc482, 0x00 }, { 0xc483, 0x40 }, { 0xc484, 0x00 }, { 0xc485, 0x18 },
2358c2ecf20Sopenharmony_ci	{ 0xc486, 0x00 }, { 0xc487, 0x18 },
2368c2ecf20Sopenharmony_ci	{ 0xc488, (OV10635_VTS - 8) * 16 >> 8},
2378c2ecf20Sopenharmony_ci	{ 0xc489, (OV10635_VTS - 8) * 16 & 0xff},
2388c2ecf20Sopenharmony_ci	{ 0xc48a, (OV10635_VTS - 8) * 16 >> 8},
2398c2ecf20Sopenharmony_ci	{ 0xc48b, (OV10635_VTS - 8) * 16 & 0xff}, { 0xc48c, 0x00 },
2408c2ecf20Sopenharmony_ci	{ 0xc48d, 0x04 }, { 0xc48e, 0x00 }, { 0xc48f, 0x04 }, { 0xc490, 0x03 },
2418c2ecf20Sopenharmony_ci	{ 0xc492, 0x20 }, { 0xc493, 0x08 }, { 0xc498, 0x02 }, { 0xc499, 0x00 },
2428c2ecf20Sopenharmony_ci	{ 0xc49a, 0x02 }, { 0xc49b, 0x00 }, { 0xc49c, 0x02 }, { 0xc49d, 0x00 },
2438c2ecf20Sopenharmony_ci	{ 0xc49e, 0x02 }, { 0xc49f, 0x60 }, { 0xc4a0, 0x03 }, { 0xc4a1, 0x00 },
2448c2ecf20Sopenharmony_ci	{ 0xc4a2, 0x04 }, { 0xc4a3, 0x00 }, { 0xc4a4, 0x00 }, { 0xc4a5, 0x10 },
2458c2ecf20Sopenharmony_ci	{ 0xc4a6, 0x00 }, { 0xc4a7, 0x40 }, { 0xc4a8, 0x00 }, { 0xc4a9, 0x80 },
2468c2ecf20Sopenharmony_ci	{ 0xc4aa, 0x0d }, { 0xc4ab, 0x00 }, { 0xc4ac, 0x0f }, { 0xc4ad, 0xc0 },
2478c2ecf20Sopenharmony_ci	{ 0xc4b4, 0x01 }, { 0xc4b5, 0x01 }, { 0xc4b6, 0x00 }, { 0xc4b7, 0x01 },
2488c2ecf20Sopenharmony_ci	{ 0xc4b8, 0x00 }, { 0xc4b9, 0x01 }, { 0xc4ba, 0x01 }, { 0xc4bb, 0x00 },
2498c2ecf20Sopenharmony_ci	{ 0xc4bc, 0x01 }, { 0xc4bd, 0x60 }, { 0xc4be, 0x02 }, { 0xc4bf, 0x33 },
2508c2ecf20Sopenharmony_ci	{ 0xc4c8, 0x03 }, { 0xc4c9, 0xd0 }, { 0xc4ca, 0x0e }, { 0xc4cb, 0x00 },
2518c2ecf20Sopenharmony_ci	{ 0xc4cc, 0x0e }, { 0xc4cd, 0x51 }, { 0xc4ce, 0x0e }, { 0xc4cf, 0x51 },
2528c2ecf20Sopenharmony_ci	{ 0xc4d0, 0x04 }, { 0xc4d1, 0x80 }, { 0xc4e0, 0x04 }, { 0xc4e1, 0x02 },
2538c2ecf20Sopenharmony_ci	{ 0xc4e2, 0x01 }, { 0xc4e4, 0x10 }, { 0xc4e5, 0x20 }, { 0xc4e6, 0x30 },
2548c2ecf20Sopenharmony_ci	{ 0xc4e7, 0x40 }, { 0xc4e8, 0x50 }, { 0xc4e9, 0x60 }, { 0xc4ea, 0x70 },
2558c2ecf20Sopenharmony_ci	{ 0xc4eb, 0x80 }, { 0xc4ec, 0x90 }, { 0xc4ed, 0xa0 }, { 0xc4ee, 0xb0 },
2568c2ecf20Sopenharmony_ci	{ 0xc4ef, 0xc0 }, { 0xc4f0, 0xd0 }, { 0xc4f1, 0xe0 }, { 0xc4f2, 0xf0 },
2578c2ecf20Sopenharmony_ci	{ 0xc4f3, 0x80 }, { 0xc4f4, 0x00 }, { 0xc4f5, 0x20 }, { 0xc4f6, 0x02 },
2588c2ecf20Sopenharmony_ci	{ 0xc4f7, 0x00 }, { 0xc4f8, 0x00 }, { 0xc4f9, 0x00 }, { 0xc4fa, 0x00 },
2598c2ecf20Sopenharmony_ci	{ 0xc4fb, 0x01 }, { 0xc4fc, 0x01 }, { 0xc4fd, 0x00 }, { 0xc4fe, 0x04 },
2608c2ecf20Sopenharmony_ci	{ 0xc4ff, 0x02 }, { 0xc500, 0x48 }, { 0xc501, 0x74 }, { 0xc502, 0x58 },
2618c2ecf20Sopenharmony_ci	{ 0xc503, 0x80 }, { 0xc504, 0x05 }, { 0xc505, 0x80 }, { 0xc506, 0x03 },
2628c2ecf20Sopenharmony_ci	{ 0xc507, 0x80 }, { 0xc508, 0x01 }, { 0xc509, 0xc0 }, { 0xc50a, 0x01 },
2638c2ecf20Sopenharmony_ci	{ 0xc50b, 0xa0 }, { 0xc50c, 0x01 }, { 0xc50d, 0x2c }, { 0xc50e, 0x01 },
2648c2ecf20Sopenharmony_ci	{ 0xc50f, 0x0a }, { 0xc510, 0x00 }, { 0xc511, 0x00 }, { 0xc512, 0xe5 },
2658c2ecf20Sopenharmony_ci	{ 0xc513, 0x14 }, { 0xc514, 0x04 }, { 0xc515, 0x00 }, { 0xc518, OV10635_VTS >> 8},
2668c2ecf20Sopenharmony_ci	{ 0xc519, OV10635_VTS & 0xff}, { 0xc51a, OV10635_HTS >> 8},
2678c2ecf20Sopenharmony_ci	{ 0xc51b, OV10635_HTS & 0xff}, { 0xc2e0, 0x00 }, { 0xc2e1, 0x51 },
2688c2ecf20Sopenharmony_ci	{ 0xc2e2, 0x00 }, { 0xc2e3, 0xd6 }, { 0xc2e4, 0x01 }, { 0xc2e5, 0x5e },
2698c2ecf20Sopenharmony_ci	{ 0xc2e9, 0x01 }, { 0xc2ea, 0x7a }, { 0xc2eb, 0x90 }, { 0xc2ed, 0x00 },
2708c2ecf20Sopenharmony_ci	{ 0xc2ee, 0x7a }, { 0xc2ef, 0x64 }, { 0xc308, 0x00 }, { 0xc309, 0x00 },
2718c2ecf20Sopenharmony_ci	{ 0xc30a, 0x00 }, { 0xc30c, 0x00 }, { 0xc30d, 0x01 }, { 0xc30e, 0x00 },
2728c2ecf20Sopenharmony_ci	{ 0xc30f, 0x00 }, { 0xc310, 0x01 }, { 0xc311, 0x60 }, { 0xc312, 0xff },
2738c2ecf20Sopenharmony_ci	{ 0xc313, 0x08 }, { 0xc314, 0x01 }, { 0xc315, 0x00 }, { 0xc316, 0xff },
2748c2ecf20Sopenharmony_ci	{ 0xc317, 0x0b }, { 0xc318, 0x00 }, { 0xc319, 0x0c }, { 0xc31a, 0x00 },
2758c2ecf20Sopenharmony_ci	{ 0xc31b, 0xe0 }, { 0xc31c, 0x00 }, { 0xc31d, 0x14 }, { 0xc31e, 0x00 },
2768c2ecf20Sopenharmony_ci	{ 0xc31f, 0xc5 }, { 0xc320, 0xff }, { 0xc321, 0x4b }, { 0xc322, 0xff },
2778c2ecf20Sopenharmony_ci	{ 0xc323, 0xf0 }, { 0xc324, 0xff }, { 0xc325, 0xe8 }, { 0xc326, 0x00 },
2788c2ecf20Sopenharmony_ci	{ 0xc327, 0x46 }, { 0xc328, 0xff }, { 0xc329, 0xd2 }, { 0xc32a, 0xff },
2798c2ecf20Sopenharmony_ci	{ 0xc32b, 0xe4 }, { 0xc32c, 0xff }, { 0xc32d, 0xbb }, { 0xc32e, 0x00 },
2808c2ecf20Sopenharmony_ci	{ 0xc32f, 0x61 }, { 0xc330, 0xff }, { 0xc331, 0xf9 }, { 0xc332, 0x00 },
2818c2ecf20Sopenharmony_ci	{ 0xc333, 0xd9 }, { 0xc334, 0x00 }, { 0xc335, 0x2e }, { 0xc336, 0x00 },
2828c2ecf20Sopenharmony_ci	{ 0xc337, 0xb1 }, { 0xc338, 0xff }, { 0xc339, 0x64 }, { 0xc33a, 0xff },
2838c2ecf20Sopenharmony_ci	{ 0xc33b, 0xeb }, { 0xc33c, 0xff }, { 0xc33d, 0xe8 }, { 0xc33e, 0x00 },
2848c2ecf20Sopenharmony_ci	{ 0xc33f, 0x48 }, { 0xc340, 0xff }, { 0xc341, 0xd0 }, { 0xc342, 0xff },
2858c2ecf20Sopenharmony_ci	{ 0xc343, 0xed }, { 0xc344, 0xff }, { 0xc345, 0xad }, { 0xc346, 0x00 },
2868c2ecf20Sopenharmony_ci	{ 0xc347, 0x66 }, { 0xc348, 0x01 }, { 0xc349, 0x00 }, { 0x6700, 0x04 },
2878c2ecf20Sopenharmony_ci	{ 0x6701, 0x7b }, { 0x6702, 0xfd }, { 0x6703, 0xf9 }, { 0x6704, 0x3d },
2888c2ecf20Sopenharmony_ci	{ 0x6705, 0x71 }, { 0x6706, 0x78 }, { 0x6708, 0x05 }, { 0x6f06, 0x6f },
2898c2ecf20Sopenharmony_ci	{ 0x6f07, 0x00 }, { 0x6f0a, 0x6f }, { 0x6f0b, 0x00 }, { 0x6f00, 0x03 },
2908c2ecf20Sopenharmony_ci	{ 0xc34c, 0x01 }, { 0xc34d, 0x00 }, { 0xc34e, 0x46 }, { 0xc34f, 0x55 },
2918c2ecf20Sopenharmony_ci	{ 0xc350, 0x00 }, { 0xc351, 0x40 }, { 0xc352, 0x00 }, { 0xc353, 0xff },
2928c2ecf20Sopenharmony_ci	{ 0xc354, 0x04 }, { 0xc355, 0x08 }, { 0xc356, 0x01 }, { 0xc357, 0xef },
2938c2ecf20Sopenharmony_ci	{ 0xc358, 0x30 }, { 0xc359, 0x01 }, { 0xc35a, 0x64 }, { 0xc35b, 0x46 },
2948c2ecf20Sopenharmony_ci	{ 0xc35c, 0x00 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
2958c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
2968c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
2978c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
2988c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
2998c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 },
3008c2ecf20Sopenharmony_ci	{ 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0x3042, 0xf0 }, { 0xc261, 0x01 },
3018c2ecf20Sopenharmony_ci	{ 0x301b, 0xf0 }, { 0x301c, 0xf0 }, { 0x301a, 0xf0 }, { 0x6f00, 0xc3 },
3028c2ecf20Sopenharmony_ci	{ 0xc46a, 0x30 }, { 0xc46d, 0x20 }, { 0xc464, 0x84 }, { 0xc465, 0x00 },
3038c2ecf20Sopenharmony_ci	{ 0x6f00, 0x03 }, { 0x6f00, 0x43 }, { 0x381c, 0x00 }, { 0x381d, 0x40 },
3048c2ecf20Sopenharmony_ci	{ 0xc454, 0x01 }, { 0x6f00, 0xc3 }, { 0xc454, 0x00 }, { 0xc4b1, 0x02 },
3058c2ecf20Sopenharmony_ci	{ 0xc4b2, 0x01 }, { 0xc4b3, 0x03 }, { 0x6f00, 0x03 }, { 0x6f00, 0x43 },
3068c2ecf20Sopenharmony_ci	/* enable FSIN (FRAMESYNC input) functionality */
3078c2ecf20Sopenharmony_ci	{ 0x3832, (0x0d + 2 * 0x20 + 0x15 + 38) >> 8 },
3088c2ecf20Sopenharmony_ci	{ 0x3833, (0x0d + 2 * 0x20 + 0x15 + 38) & 0xff },
3098c2ecf20Sopenharmony_ci	{ 0x3834, OV10635_VTS >> 8 }, { 0x3835, OV10635_VTS & 0xff },
3108c2ecf20Sopenharmony_ci	{ 0x302e, 0x01 },
3118c2ecf20Sopenharmony_ci};
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistruct rdacm20_device {
3148c2ecf20Sopenharmony_ci	struct device			*dev;
3158c2ecf20Sopenharmony_ci	struct max9271_device		*serializer;
3168c2ecf20Sopenharmony_ci	struct i2c_client		*sensor;
3178c2ecf20Sopenharmony_ci	struct v4l2_subdev		sd;
3188c2ecf20Sopenharmony_ci	struct media_pad		pad;
3198c2ecf20Sopenharmony_ci	struct v4l2_ctrl_handler	ctrls;
3208c2ecf20Sopenharmony_ci	u32				addrs[2];
3218c2ecf20Sopenharmony_ci};
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_cistatic inline struct rdacm20_device *sd_to_rdacm20(struct v4l2_subdev *sd)
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	return container_of(sd, struct rdacm20_device, sd);
3268c2ecf20Sopenharmony_ci}
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic inline struct rdacm20_device *i2c_to_rdacm20(struct i2c_client *client)
3298c2ecf20Sopenharmony_ci{
3308c2ecf20Sopenharmony_ci	return sd_to_rdacm20(i2c_get_clientdata(client));
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic int ov10635_read16(struct rdacm20_device *dev, u16 reg)
3348c2ecf20Sopenharmony_ci{
3358c2ecf20Sopenharmony_ci	u8 buf[2] = { reg >> 8, reg & 0xff };
3368c2ecf20Sopenharmony_ci	int ret;
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci	ret = i2c_master_send(dev->sensor, buf, 2);
3398c2ecf20Sopenharmony_ci	if (ret != 2) {
3408c2ecf20Sopenharmony_ci		dev_dbg(dev->dev, "%s: register 0x%04x write failed (%d)\n",
3418c2ecf20Sopenharmony_ci			__func__, reg, ret);
3428c2ecf20Sopenharmony_ci		return ret;
3438c2ecf20Sopenharmony_ci	}
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	ret = i2c_master_recv(dev->sensor, buf, 2);
3468c2ecf20Sopenharmony_ci	if (ret < 0) {
3478c2ecf20Sopenharmony_ci		dev_dbg(dev->dev, "%s: register 0x%04x read failed (%d)\n",
3488c2ecf20Sopenharmony_ci			__func__, reg, ret);
3498c2ecf20Sopenharmony_ci		return ret;
3508c2ecf20Sopenharmony_ci	}
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci	return (buf[0] << 8) | buf[1];
3538c2ecf20Sopenharmony_ci}
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_cistatic int __ov10635_write(struct rdacm20_device *dev, u16 reg, u8 val)
3568c2ecf20Sopenharmony_ci{
3578c2ecf20Sopenharmony_ci	u8 buf[3] = { reg >> 8, reg & 0xff, val };
3588c2ecf20Sopenharmony_ci	int ret;
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	dev_dbg(dev->dev, "%s(0x%04x, 0x%02x)\n", __func__, reg, val);
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci	ret = i2c_master_send(dev->sensor, buf, 3);
3638c2ecf20Sopenharmony_ci	return ret < 0 ? ret : 0;
3648c2ecf20Sopenharmony_ci}
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cistatic int ov10635_write(struct rdacm20_device *dev, u16 reg, u8 val)
3678c2ecf20Sopenharmony_ci{
3688c2ecf20Sopenharmony_ci	int ret;
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	ret = __ov10635_write(dev, reg, val);
3718c2ecf20Sopenharmony_ci	if (ret < 0)
3728c2ecf20Sopenharmony_ci		dev_err(dev->dev, "%s: register 0x%04x write failed (%d)\n",
3738c2ecf20Sopenharmony_ci			__func__, reg, ret);
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci	return ret;
3768c2ecf20Sopenharmony_ci}
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistatic int ov10635_set_regs(struct rdacm20_device *dev,
3798c2ecf20Sopenharmony_ci			    const struct ov10635_reg *regs,
3808c2ecf20Sopenharmony_ci			    unsigned int nr_regs)
3818c2ecf20Sopenharmony_ci{
3828c2ecf20Sopenharmony_ci	unsigned int i;
3838c2ecf20Sopenharmony_ci	int ret;
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci	for (i = 0; i < nr_regs; i++) {
3868c2ecf20Sopenharmony_ci		ret = __ov10635_write(dev, regs[i].reg, regs[i].val);
3878c2ecf20Sopenharmony_ci		if (ret) {
3888c2ecf20Sopenharmony_ci			dev_err(dev->dev,
3898c2ecf20Sopenharmony_ci				"%s: register %u (0x%04x) write failed (%d)\n",
3908c2ecf20Sopenharmony_ci				__func__, i, regs[i].reg, ret);
3918c2ecf20Sopenharmony_ci			return ret;
3928c2ecf20Sopenharmony_ci		}
3938c2ecf20Sopenharmony_ci	}
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci	return 0;
3968c2ecf20Sopenharmony_ci}
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_cistatic int rdacm20_s_stream(struct v4l2_subdev *sd, int enable)
3998c2ecf20Sopenharmony_ci{
4008c2ecf20Sopenharmony_ci	struct rdacm20_device *dev = sd_to_rdacm20(sd);
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci	return max9271_set_serial_link(dev->serializer, enable);
4038c2ecf20Sopenharmony_ci}
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_cistatic int rdacm20_enum_mbus_code(struct v4l2_subdev *sd,
4068c2ecf20Sopenharmony_ci				  struct v4l2_subdev_pad_config *cfg,
4078c2ecf20Sopenharmony_ci				  struct v4l2_subdev_mbus_code_enum *code)
4088c2ecf20Sopenharmony_ci{
4098c2ecf20Sopenharmony_ci	if (code->pad || code->index > 0)
4108c2ecf20Sopenharmony_ci		return -EINVAL;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	code->code = MEDIA_BUS_FMT_UYVY8_2X8;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	return 0;
4158c2ecf20Sopenharmony_ci}
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_cistatic int rdacm20_get_fmt(struct v4l2_subdev *sd,
4188c2ecf20Sopenharmony_ci			   struct v4l2_subdev_pad_config *cfg,
4198c2ecf20Sopenharmony_ci			   struct v4l2_subdev_format *format)
4208c2ecf20Sopenharmony_ci{
4218c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *mf = &format->format;
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci	if (format->pad)
4248c2ecf20Sopenharmony_ci		return -EINVAL;
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	mf->width		= OV10635_WIDTH;
4278c2ecf20Sopenharmony_ci	mf->height		= OV10635_HEIGHT;
4288c2ecf20Sopenharmony_ci	mf->code		= MEDIA_BUS_FMT_UYVY8_2X8;
4298c2ecf20Sopenharmony_ci	mf->colorspace		= V4L2_COLORSPACE_RAW;
4308c2ecf20Sopenharmony_ci	mf->field		= V4L2_FIELD_NONE;
4318c2ecf20Sopenharmony_ci	mf->ycbcr_enc		= V4L2_YCBCR_ENC_601;
4328c2ecf20Sopenharmony_ci	mf->quantization	= V4L2_QUANTIZATION_FULL_RANGE;
4338c2ecf20Sopenharmony_ci	mf->xfer_func		= V4L2_XFER_FUNC_NONE;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	return 0;
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic struct v4l2_subdev_video_ops rdacm20_video_ops = {
4398c2ecf20Sopenharmony_ci	.s_stream	= rdacm20_s_stream,
4408c2ecf20Sopenharmony_ci};
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = {
4438c2ecf20Sopenharmony_ci	.enum_mbus_code = rdacm20_enum_mbus_code,
4448c2ecf20Sopenharmony_ci	.get_fmt	= rdacm20_get_fmt,
4458c2ecf20Sopenharmony_ci	.set_fmt	= rdacm20_get_fmt,
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic struct v4l2_subdev_ops rdacm20_subdev_ops = {
4498c2ecf20Sopenharmony_ci	.video		= &rdacm20_video_ops,
4508c2ecf20Sopenharmony_ci	.pad		= &rdacm20_subdev_pad_ops,
4518c2ecf20Sopenharmony_ci};
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_cistatic int rdacm20_initialize(struct rdacm20_device *dev)
4548c2ecf20Sopenharmony_ci{
4558c2ecf20Sopenharmony_ci	unsigned int retry = 3;
4568c2ecf20Sopenharmony_ci	int ret;
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ci	/* Verify communication with the MAX9271: ping to wakeup. */
4598c2ecf20Sopenharmony_ci	dev->serializer->client->addr = MAX9271_DEFAULT_ADDR;
4608c2ecf20Sopenharmony_ci	i2c_smbus_read_byte(dev->serializer->client);
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci	/* Serial link disabled during config as it needs a valid pixel clock. */
4638c2ecf20Sopenharmony_ci	ret = max9271_set_serial_link(dev->serializer, false);
4648c2ecf20Sopenharmony_ci	if (ret)
4658c2ecf20Sopenharmony_ci		return ret;
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci	/*
4688c2ecf20Sopenharmony_ci	 *  Ensure that we have a good link configuration before attempting to
4698c2ecf20Sopenharmony_ci	 *  identify the device.
4708c2ecf20Sopenharmony_ci	 */
4718c2ecf20Sopenharmony_ci	max9271_configure_i2c(dev->serializer, MAX9271_I2CSLVSH_469NS_234NS |
4728c2ecf20Sopenharmony_ci					       MAX9271_I2CSLVTO_1024US |
4738c2ecf20Sopenharmony_ci					       MAX9271_I2CMSTBT_105KBPS);
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci	max9271_configure_gmsl_link(dev->serializer);
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci	ret = max9271_verify_id(dev->serializer);
4788c2ecf20Sopenharmony_ci	if (ret < 0)
4798c2ecf20Sopenharmony_ci		return ret;
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci	ret = max9271_set_address(dev->serializer, dev->addrs[0]);
4828c2ecf20Sopenharmony_ci	if (ret < 0)
4838c2ecf20Sopenharmony_ci		return ret;
4848c2ecf20Sopenharmony_ci	dev->serializer->client->addr = dev->addrs[0];
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	/*
4878c2ecf20Sopenharmony_ci	 * Reset the sensor by cycling the OV10635 reset signal connected to the
4888c2ecf20Sopenharmony_ci	 * MAX9271 GPIO1 and verify communication with the OV10635.
4898c2ecf20Sopenharmony_ci	 */
4908c2ecf20Sopenharmony_ci	ret = max9271_enable_gpios(dev->serializer, MAX9271_GPIO1OUT);
4918c2ecf20Sopenharmony_ci	if (ret)
4928c2ecf20Sopenharmony_ci		return ret;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	ret = max9271_clear_gpios(dev->serializer, MAX9271_GPIO1OUT);
4958c2ecf20Sopenharmony_ci	if (ret)
4968c2ecf20Sopenharmony_ci		return ret;
4978c2ecf20Sopenharmony_ci	usleep_range(10000, 15000);
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	ret = max9271_set_gpios(dev->serializer, MAX9271_GPIO1OUT);
5008c2ecf20Sopenharmony_ci	if (ret)
5018c2ecf20Sopenharmony_ci		return ret;
5028c2ecf20Sopenharmony_ci	usleep_range(10000, 15000);
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ciagain:
5058c2ecf20Sopenharmony_ci	ret = ov10635_read16(dev, OV10635_PID);
5068c2ecf20Sopenharmony_ci	if (ret < 0) {
5078c2ecf20Sopenharmony_ci		if (retry--)
5088c2ecf20Sopenharmony_ci			goto again;
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci		dev_err(dev->dev, "OV10635 ID read failed (%d)\n",
5118c2ecf20Sopenharmony_ci			ret);
5128c2ecf20Sopenharmony_ci		return -ENXIO;
5138c2ecf20Sopenharmony_ci	}
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	if (ret != OV10635_VERSION) {
5168c2ecf20Sopenharmony_ci		if (retry--)
5178c2ecf20Sopenharmony_ci			goto again;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci		dev_err(dev->dev, "OV10635 ID mismatch (0x%04x)\n",
5208c2ecf20Sopenharmony_ci			ret);
5218c2ecf20Sopenharmony_ci		return -ENXIO;
5228c2ecf20Sopenharmony_ci	}
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci	/* Change the sensor I2C address. */
5258c2ecf20Sopenharmony_ci	ret = ov10635_write(dev, OV10635_SC_CMMN_SCCB_ID,
5268c2ecf20Sopenharmony_ci			    (dev->addrs[1] << 1) |
5278c2ecf20Sopenharmony_ci			    OV10635_SC_CMMN_SCCB_ID_SELECT);
5288c2ecf20Sopenharmony_ci	if (ret < 0) {
5298c2ecf20Sopenharmony_ci		dev_err(dev->dev,
5308c2ecf20Sopenharmony_ci			"OV10635 I2C address change failed (%d)\n", ret);
5318c2ecf20Sopenharmony_ci		return ret;
5328c2ecf20Sopenharmony_ci	}
5338c2ecf20Sopenharmony_ci	dev->sensor->addr = dev->addrs[1];
5348c2ecf20Sopenharmony_ci	usleep_range(3500, 5000);
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci	/* Program the 0V10635 initial configuration. */
5378c2ecf20Sopenharmony_ci	ret = ov10635_set_regs(dev, ov10635_regs_wizard,
5388c2ecf20Sopenharmony_ci			       ARRAY_SIZE(ov10635_regs_wizard));
5398c2ecf20Sopenharmony_ci	if (ret)
5408c2ecf20Sopenharmony_ci		return ret;
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	dev_info(dev->dev, "Identified MAX9271 + OV10635 device\n");
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci	return 0;
5458c2ecf20Sopenharmony_ci}
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_cistatic int rdacm20_probe(struct i2c_client *client)
5488c2ecf20Sopenharmony_ci{
5498c2ecf20Sopenharmony_ci	struct rdacm20_device *dev;
5508c2ecf20Sopenharmony_ci	struct fwnode_handle *ep;
5518c2ecf20Sopenharmony_ci	int ret;
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci	dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
5548c2ecf20Sopenharmony_ci	if (!dev)
5558c2ecf20Sopenharmony_ci		return -ENOMEM;
5568c2ecf20Sopenharmony_ci	dev->dev = &client->dev;
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	dev->serializer = devm_kzalloc(&client->dev, sizeof(*dev->serializer),
5598c2ecf20Sopenharmony_ci				       GFP_KERNEL);
5608c2ecf20Sopenharmony_ci	if (!dev->serializer)
5618c2ecf20Sopenharmony_ci		return -ENOMEM;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	dev->serializer->client = client;
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci	ret = of_property_read_u32_array(client->dev.of_node, "reg",
5668c2ecf20Sopenharmony_ci					 dev->addrs, 2);
5678c2ecf20Sopenharmony_ci	if (ret < 0) {
5688c2ecf20Sopenharmony_ci		dev_err(dev->dev, "Invalid DT reg property: %d\n", ret);
5698c2ecf20Sopenharmony_ci		return -EINVAL;
5708c2ecf20Sopenharmony_ci	}
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci	/* Create the dummy I2C client for the sensor. */
5738c2ecf20Sopenharmony_ci	dev->sensor = i2c_new_dummy_device(client->adapter,
5748c2ecf20Sopenharmony_ci					   OV10635_I2C_ADDRESS);
5758c2ecf20Sopenharmony_ci	if (IS_ERR(dev->sensor)) {
5768c2ecf20Sopenharmony_ci		ret = PTR_ERR(dev->sensor);
5778c2ecf20Sopenharmony_ci		goto error;
5788c2ecf20Sopenharmony_ci	}
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci	/* Initialize the hardware. */
5818c2ecf20Sopenharmony_ci	ret = rdacm20_initialize(dev);
5828c2ecf20Sopenharmony_ci	if (ret < 0)
5838c2ecf20Sopenharmony_ci		goto error;
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_ci	/* Initialize and register the subdevice. */
5868c2ecf20Sopenharmony_ci	v4l2_i2c_subdev_init(&dev->sd, client, &rdacm20_subdev_ops);
5878c2ecf20Sopenharmony_ci	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_init(&dev->ctrls, 1);
5908c2ecf20Sopenharmony_ci	v4l2_ctrl_new_std(&dev->ctrls, NULL, V4L2_CID_PIXEL_RATE,
5918c2ecf20Sopenharmony_ci			  OV10635_PIXEL_RATE, OV10635_PIXEL_RATE, 1,
5928c2ecf20Sopenharmony_ci			  OV10635_PIXEL_RATE);
5938c2ecf20Sopenharmony_ci	dev->sd.ctrl_handler = &dev->ctrls;
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ci	ret = dev->ctrls.error;
5968c2ecf20Sopenharmony_ci	if (ret)
5978c2ecf20Sopenharmony_ci		goto error_free_ctrls;
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
6008c2ecf20Sopenharmony_ci	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
6018c2ecf20Sopenharmony_ci	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
6028c2ecf20Sopenharmony_ci	if (ret < 0)
6038c2ecf20Sopenharmony_ci		goto error_free_ctrls;
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci	ep = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL);
6068c2ecf20Sopenharmony_ci	if (!ep) {
6078c2ecf20Sopenharmony_ci		dev_err(&client->dev,
6088c2ecf20Sopenharmony_ci			"Unable to get endpoint in node %pOF\n",
6098c2ecf20Sopenharmony_ci			client->dev.of_node);
6108c2ecf20Sopenharmony_ci		ret = -ENOENT;
6118c2ecf20Sopenharmony_ci		goto error_free_ctrls;
6128c2ecf20Sopenharmony_ci	}
6138c2ecf20Sopenharmony_ci	dev->sd.fwnode = ep;
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	ret = v4l2_async_register_subdev(&dev->sd);
6168c2ecf20Sopenharmony_ci	if (ret)
6178c2ecf20Sopenharmony_ci		goto error_put_node;
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci	return 0;
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_cierror_put_node:
6228c2ecf20Sopenharmony_ci	fwnode_handle_put(ep);
6238c2ecf20Sopenharmony_cierror_free_ctrls:
6248c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_free(&dev->ctrls);
6258c2ecf20Sopenharmony_cierror:
6268c2ecf20Sopenharmony_ci	media_entity_cleanup(&dev->sd.entity);
6278c2ecf20Sopenharmony_ci	if (dev->sensor)
6288c2ecf20Sopenharmony_ci		i2c_unregister_device(dev->sensor);
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	dev_err(&client->dev, "probe failed\n");
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	return ret;
6338c2ecf20Sopenharmony_ci}
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_cistatic int rdacm20_remove(struct i2c_client *client)
6368c2ecf20Sopenharmony_ci{
6378c2ecf20Sopenharmony_ci	struct rdacm20_device *dev = i2c_to_rdacm20(client);
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci	fwnode_handle_put(dev->sd.fwnode);
6408c2ecf20Sopenharmony_ci	v4l2_async_unregister_subdev(&dev->sd);
6418c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_free(&dev->ctrls);
6428c2ecf20Sopenharmony_ci	media_entity_cleanup(&dev->sd.entity);
6438c2ecf20Sopenharmony_ci	i2c_unregister_device(dev->sensor);
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_ci	return 0;
6468c2ecf20Sopenharmony_ci}
6478c2ecf20Sopenharmony_ci
6488c2ecf20Sopenharmony_cistatic void rdacm20_shutdown(struct i2c_client *client)
6498c2ecf20Sopenharmony_ci{
6508c2ecf20Sopenharmony_ci	struct rdacm20_device *dev = i2c_to_rdacm20(client);
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci	/* make sure stream off during shutdown (reset/reboot) */
6538c2ecf20Sopenharmony_ci	rdacm20_s_stream(&dev->sd, 0);
6548c2ecf20Sopenharmony_ci}
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_cistatic const struct of_device_id rdacm20_of_ids[] = {
6578c2ecf20Sopenharmony_ci	{ .compatible = "imi,rdacm20", },
6588c2ecf20Sopenharmony_ci	{ }
6598c2ecf20Sopenharmony_ci};
6608c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, rdacm20_of_ids);
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_cistatic struct i2c_driver rdacm20_i2c_driver = {
6638c2ecf20Sopenharmony_ci	.driver	= {
6648c2ecf20Sopenharmony_ci		.name	= "rdacm20",
6658c2ecf20Sopenharmony_ci		.of_match_table = rdacm20_of_ids,
6668c2ecf20Sopenharmony_ci	},
6678c2ecf20Sopenharmony_ci	.probe_new	= rdacm20_probe,
6688c2ecf20Sopenharmony_ci	.remove		= rdacm20_remove,
6698c2ecf20Sopenharmony_ci	.shutdown	= rdacm20_shutdown,
6708c2ecf20Sopenharmony_ci};
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_cimodule_i2c_driver(rdacm20_i2c_driver);
6738c2ecf20Sopenharmony_ci
6748c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("GMSL Camera driver for RDACM20");
6758c2ecf20Sopenharmony_ciMODULE_AUTHOR("Vladimir Barinov");
6768c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
677