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

media: ov5693: Convert to new CCI register access helpers

Use the new comon CCI register access helpers to replace the private
register access helpers in the ov5693 driver.

[Sakari Ailus: Squashed the patch to address a merge issue in Kconfig]

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Hans de Goede and committed by
Mauro Carvalho Chehab
f3a5e2cc 613cbb91

+229 -357
+1
drivers/media/i2c/Kconfig
··· 425 425 426 426 config VIDEO_OV5693 427 427 tristate "OmniVision OV5693 sensor support" 428 + select V4L2_CCI_I2C 428 429 help 429 430 This is a Video4Linux2 sensor driver for the OmniVision 430 431 OV5693 camera.
+228 -357
drivers/media/i2c/ov5693.c
··· 12 12 * Jake Day 13 13 */ 14 14 15 - #include <asm/unaligned.h> 16 15 #include <linux/acpi.h> 17 16 #include <linux/clk.h> 18 17 #include <linux/delay.h> ··· 22 23 #include <linux/regulator/consumer.h> 23 24 #include <linux/slab.h> 24 25 #include <linux/types.h> 26 + 27 + #include <media/v4l2-cci.h> 25 28 #include <media/v4l2-ctrls.h> 26 29 #include <media/v4l2-device.h> 27 30 #include <media/v4l2-fwnode.h> 28 31 29 - #define OV5693_REG_8BIT(n) ((1 << 16) | (n)) 30 - #define OV5693_REG_16BIT(n) ((2 << 16) | (n)) 31 - #define OV5693_REG_24BIT(n) ((3 << 16) | (n)) 32 - #define OV5693_REG_SIZE_SHIFT 16 33 - #define OV5693_REG_ADDR_MASK 0xffff 34 - 35 32 /* System Control */ 36 - #define OV5693_SW_RESET_REG OV5693_REG_8BIT(0x0103) 37 - #define OV5693_SW_STREAM_REG OV5693_REG_8BIT(0x0100) 33 + #define OV5693_SW_RESET_REG CCI_REG8(0x0103) 34 + #define OV5693_SW_STREAM_REG CCI_REG8(0x0100) 38 35 #define OV5693_START_STREAMING 0x01 39 36 #define OV5693_STOP_STREAMING 0x00 40 37 #define OV5693_SW_RESET 0x01 41 38 42 - #define OV5693_REG_CHIP_ID OV5693_REG_16BIT(0x300a) 39 + #define OV5693_REG_CHIP_ID CCI_REG16(0x300a) 43 40 /* Yes, this is right. The datasheet for the OV5693 gives its ID as 0x5690 */ 44 41 #define OV5693_CHIP_ID 0x5690 45 42 46 43 /* Exposure */ 47 - #define OV5693_EXPOSURE_CTRL_REG OV5693_REG_24BIT(0x3500) 44 + #define OV5693_EXPOSURE_CTRL_REG CCI_REG24(0x3500) 48 45 #define OV5693_EXPOSURE_CTRL_MASK GENMASK(19, 4) 49 46 #define OV5693_INTEGRATION_TIME_MARGIN 8 50 47 #define OV5693_EXPOSURE_MIN 1 51 48 #define OV5693_EXPOSURE_STEP 1 52 49 53 50 /* Analogue Gain */ 54 - #define OV5693_GAIN_CTRL_REG OV5693_REG_16BIT(0x350a) 51 + #define OV5693_GAIN_CTRL_REG CCI_REG16(0x350a) 55 52 #define OV5693_GAIN_CTRL_MASK GENMASK(10, 4) 56 53 #define OV5693_GAIN_MIN 1 57 54 #define OV5693_GAIN_MAX 127 ··· 55 60 #define OV5693_GAIN_STEP 1 56 61 57 62 /* Digital Gain */ 58 - #define OV5693_MWB_RED_GAIN_REG OV5693_REG_16BIT(0x3400) 59 - #define OV5693_MWB_GREEN_GAIN_REG OV5693_REG_16BIT(0x3402) 60 - #define OV5693_MWB_BLUE_GAIN_REG OV5693_REG_16BIT(0x3404) 63 + #define OV5693_MWB_RED_GAIN_REG CCI_REG16(0x3400) 64 + #define OV5693_MWB_GREEN_GAIN_REG CCI_REG16(0x3402) 65 + #define OV5693_MWB_BLUE_GAIN_REG CCI_REG16(0x3404) 61 66 #define OV5693_MWB_GAIN_MASK GENMASK(11, 0) 62 67 #define OV5693_MWB_GAIN_MAX 0x0fff 63 68 #define OV5693_DIGITAL_GAIN_MIN 1 ··· 66 71 #define OV5693_DIGITAL_GAIN_STEP 1 67 72 68 73 /* Timing and Format */ 69 - #define OV5693_CROP_START_X_REG OV5693_REG_16BIT(0x3800) 70 - #define OV5693_CROP_START_Y_REG OV5693_REG_16BIT(0x3802) 71 - #define OV5693_CROP_END_X_REG OV5693_REG_16BIT(0x3804) 72 - #define OV5693_CROP_END_Y_REG OV5693_REG_16BIT(0x3806) 73 - #define OV5693_OUTPUT_SIZE_X_REG OV5693_REG_16BIT(0x3808) 74 - #define OV5693_OUTPUT_SIZE_Y_REG OV5693_REG_16BIT(0x380a) 74 + #define OV5693_CROP_START_X_REG CCI_REG16(0x3800) 75 + #define OV5693_CROP_START_Y_REG CCI_REG16(0x3802) 76 + #define OV5693_CROP_END_X_REG CCI_REG16(0x3804) 77 + #define OV5693_CROP_END_Y_REG CCI_REG16(0x3806) 78 + #define OV5693_OUTPUT_SIZE_X_REG CCI_REG16(0x3808) 79 + #define OV5693_OUTPUT_SIZE_Y_REG CCI_REG16(0x380a) 75 80 76 - #define OV5693_TIMING_HTS_REG OV5693_REG_16BIT(0x380c) 81 + #define OV5693_TIMING_HTS_REG CCI_REG16(0x380c) 77 82 #define OV5693_FIXED_PPL 2688U 78 - #define OV5693_TIMING_VTS_REG OV5693_REG_16BIT(0x380e) 83 + #define OV5693_TIMING_VTS_REG CCI_REG16(0x380e) 79 84 #define OV5693_TIMING_MAX_VTS 0xffff 80 85 #define OV5693_TIMING_MIN_VTS 0x04 81 86 82 - #define OV5693_OFFSET_START_X_REG OV5693_REG_16BIT(0x3810) 83 - #define OV5693_OFFSET_START_Y_REG OV5693_REG_16BIT(0x3812) 87 + #define OV5693_OFFSET_START_X_REG CCI_REG16(0x3810) 88 + #define OV5693_OFFSET_START_Y_REG CCI_REG16(0x3812) 84 89 85 - #define OV5693_SUB_INC_X_REG OV5693_REG_8BIT(0x3814) 86 - #define OV5693_SUB_INC_Y_REG OV5693_REG_8BIT(0x3815) 90 + #define OV5693_SUB_INC_X_REG CCI_REG8(0x3814) 91 + #define OV5693_SUB_INC_Y_REG CCI_REG8(0x3815) 87 92 88 - #define OV5693_FORMAT1_REG OV5693_REG_8BIT(0x3820) 93 + #define OV5693_FORMAT1_REG CCI_REG8(0x3820) 89 94 #define OV5693_FORMAT1_FLIP_VERT_ISP_EN BIT(6) 90 95 #define OV5693_FORMAT1_FLIP_VERT_SENSOR_EN BIT(1) 91 96 #define OV5693_FORMAT1_VBIN_EN BIT(0) 92 - #define OV5693_FORMAT2_REG OV5693_REG_8BIT(0x3821) 97 + #define OV5693_FORMAT2_REG CCI_REG8(0x3821) 93 98 #define OV5693_FORMAT2_HDR_EN BIT(7) 94 99 #define OV5693_FORMAT2_FLIP_HORZ_ISP_EN BIT(2) 95 100 #define OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN BIT(1) 96 101 #define OV5693_FORMAT2_HBIN_EN BIT(0) 97 102 98 - #define OV5693_ISP_CTRL2_REG OV5693_REG_8BIT(0x5002) 103 + #define OV5693_ISP_CTRL2_REG CCI_REG8(0x5002) 99 104 #define OV5693_ISP_SCALE_ENABLE BIT(7) 100 105 101 106 /* Pixel Array */ ··· 111 116 #define OV5693_MIN_CROP_HEIGHT 2 112 117 113 118 /* Test Pattern */ 114 - #define OV5693_TEST_PATTERN_REG OV5693_REG_8BIT(0x5e00) 119 + #define OV5693_TEST_PATTERN_REG CCI_REG8(0x5e00) 115 120 #define OV5693_TEST_PATTERN_ENABLE BIT(7) 116 121 #define OV5693_TEST_PATTERN_ROLLING BIT(6) 117 122 #define OV5693_TEST_PATTERN_RANDOM 0x01 ··· 132 137 133 138 #define OV5693_NUM_SUPPLIES ARRAY_SIZE(ov5693_supply_names) 134 139 135 - struct ov5693_reg { 136 - u32 reg; 137 - u8 val; 138 - }; 139 - 140 - struct ov5693_reg_list { 141 - u32 num_regs; 142 - const struct ov5693_reg *regs; 143 - }; 144 - 145 140 struct ov5693_device { 146 - struct i2c_client *client; 147 141 struct device *dev; 142 + struct regmap *regmap; 148 143 149 144 /* Protect against concurrent changes to controls */ 150 145 struct mutex lock; ··· 174 189 } ctrls; 175 190 }; 176 191 177 - static const struct ov5693_reg ov5693_global_regs[] = { 178 - {OV5693_REG_8BIT(0x3016), 0xf0}, 179 - {OV5693_REG_8BIT(0x3017), 0xf0}, 180 - {OV5693_REG_8BIT(0x3018), 0xf0}, 181 - {OV5693_REG_8BIT(0x3022), 0x01}, 182 - {OV5693_REG_8BIT(0x3028), 0x44}, 183 - {OV5693_REG_8BIT(0x3098), 0x02}, 184 - {OV5693_REG_8BIT(0x3099), 0x19}, 185 - {OV5693_REG_8BIT(0x309a), 0x02}, 186 - {OV5693_REG_8BIT(0x309b), 0x01}, 187 - {OV5693_REG_8BIT(0x309c), 0x00}, 188 - {OV5693_REG_8BIT(0x30a0), 0xd2}, 189 - {OV5693_REG_8BIT(0x30a2), 0x01}, 190 - {OV5693_REG_8BIT(0x30b2), 0x00}, 191 - {OV5693_REG_8BIT(0x30b3), 0x83}, 192 - {OV5693_REG_8BIT(0x30b4), 0x03}, 193 - {OV5693_REG_8BIT(0x30b5), 0x04}, 194 - {OV5693_REG_8BIT(0x30b6), 0x01}, 195 - {OV5693_REG_8BIT(0x3080), 0x01}, 196 - {OV5693_REG_8BIT(0x3104), 0x21}, 197 - {OV5693_REG_8BIT(0x3106), 0x00}, 198 - {OV5693_REG_8BIT(0x3406), 0x01}, 199 - {OV5693_REG_8BIT(0x3503), 0x07}, 200 - {OV5693_REG_8BIT(0x350b), 0x40}, 201 - {OV5693_REG_8BIT(0x3601), 0x0a}, 202 - {OV5693_REG_8BIT(0x3602), 0x38}, 203 - {OV5693_REG_8BIT(0x3612), 0x80}, 204 - {OV5693_REG_8BIT(0x3620), 0x54}, 205 - {OV5693_REG_8BIT(0x3621), 0xc7}, 206 - {OV5693_REG_8BIT(0x3622), 0x0f}, 207 - {OV5693_REG_8BIT(0x3625), 0x10}, 208 - {OV5693_REG_8BIT(0x3630), 0x55}, 209 - {OV5693_REG_8BIT(0x3631), 0xf4}, 210 - {OV5693_REG_8BIT(0x3632), 0x00}, 211 - {OV5693_REG_8BIT(0x3633), 0x34}, 212 - {OV5693_REG_8BIT(0x3634), 0x02}, 213 - {OV5693_REG_8BIT(0x364d), 0x0d}, 214 - {OV5693_REG_8BIT(0x364f), 0xdd}, 215 - {OV5693_REG_8BIT(0x3660), 0x04}, 216 - {OV5693_REG_8BIT(0x3662), 0x10}, 217 - {OV5693_REG_8BIT(0x3663), 0xf1}, 218 - {OV5693_REG_8BIT(0x3665), 0x00}, 219 - {OV5693_REG_8BIT(0x3666), 0x20}, 220 - {OV5693_REG_8BIT(0x3667), 0x00}, 221 - {OV5693_REG_8BIT(0x366a), 0x80}, 222 - {OV5693_REG_8BIT(0x3680), 0xe0}, 223 - {OV5693_REG_8BIT(0x3681), 0x00}, 224 - {OV5693_REG_8BIT(0x3700), 0x42}, 225 - {OV5693_REG_8BIT(0x3701), 0x14}, 226 - {OV5693_REG_8BIT(0x3702), 0xa0}, 227 - {OV5693_REG_8BIT(0x3703), 0xd8}, 228 - {OV5693_REG_8BIT(0x3704), 0x78}, 229 - {OV5693_REG_8BIT(0x3705), 0x02}, 230 - {OV5693_REG_8BIT(0x370a), 0x00}, 231 - {OV5693_REG_8BIT(0x370b), 0x20}, 232 - {OV5693_REG_8BIT(0x370c), 0x0c}, 233 - {OV5693_REG_8BIT(0x370d), 0x11}, 234 - {OV5693_REG_8BIT(0x370e), 0x00}, 235 - {OV5693_REG_8BIT(0x370f), 0x40}, 236 - {OV5693_REG_8BIT(0x3710), 0x00}, 237 - {OV5693_REG_8BIT(0x371a), 0x1c}, 238 - {OV5693_REG_8BIT(0x371b), 0x05}, 239 - {OV5693_REG_8BIT(0x371c), 0x01}, 240 - {OV5693_REG_8BIT(0x371e), 0xa1}, 241 - {OV5693_REG_8BIT(0x371f), 0x0c}, 242 - {OV5693_REG_8BIT(0x3721), 0x00}, 243 - {OV5693_REG_8BIT(0x3724), 0x10}, 244 - {OV5693_REG_8BIT(0x3726), 0x00}, 245 - {OV5693_REG_8BIT(0x372a), 0x01}, 246 - {OV5693_REG_8BIT(0x3730), 0x10}, 247 - {OV5693_REG_8BIT(0x3738), 0x22}, 248 - {OV5693_REG_8BIT(0x3739), 0xe5}, 249 - {OV5693_REG_8BIT(0x373a), 0x50}, 250 - {OV5693_REG_8BIT(0x373b), 0x02}, 251 - {OV5693_REG_8BIT(0x373c), 0x41}, 252 - {OV5693_REG_8BIT(0x373f), 0x02}, 253 - {OV5693_REG_8BIT(0x3740), 0x42}, 254 - {OV5693_REG_8BIT(0x3741), 0x02}, 255 - {OV5693_REG_8BIT(0x3742), 0x18}, 256 - {OV5693_REG_8BIT(0x3743), 0x01}, 257 - {OV5693_REG_8BIT(0x3744), 0x02}, 258 - {OV5693_REG_8BIT(0x3747), 0x10}, 259 - {OV5693_REG_8BIT(0x374c), 0x04}, 260 - {OV5693_REG_8BIT(0x3751), 0xf0}, 261 - {OV5693_REG_8BIT(0x3752), 0x00}, 262 - {OV5693_REG_8BIT(0x3753), 0x00}, 263 - {OV5693_REG_8BIT(0x3754), 0xc0}, 264 - {OV5693_REG_8BIT(0x3755), 0x00}, 265 - {OV5693_REG_8BIT(0x3756), 0x1a}, 266 - {OV5693_REG_8BIT(0x3758), 0x00}, 267 - {OV5693_REG_8BIT(0x3759), 0x0f}, 268 - {OV5693_REG_8BIT(0x376b), 0x44}, 269 - {OV5693_REG_8BIT(0x375c), 0x04}, 270 - {OV5693_REG_8BIT(0x3774), 0x10}, 271 - {OV5693_REG_8BIT(0x3776), 0x00}, 272 - {OV5693_REG_8BIT(0x377f), 0x08}, 273 - {OV5693_REG_8BIT(0x3780), 0x22}, 274 - {OV5693_REG_8BIT(0x3781), 0x0c}, 275 - {OV5693_REG_8BIT(0x3784), 0x2c}, 276 - {OV5693_REG_8BIT(0x3785), 0x1e}, 277 - {OV5693_REG_8BIT(0x378f), 0xf5}, 278 - {OV5693_REG_8BIT(0x3791), 0xb0}, 279 - {OV5693_REG_8BIT(0x3795), 0x00}, 280 - {OV5693_REG_8BIT(0x3796), 0x64}, 281 - {OV5693_REG_8BIT(0x3797), 0x11}, 282 - {OV5693_REG_8BIT(0x3798), 0x30}, 283 - {OV5693_REG_8BIT(0x3799), 0x41}, 284 - {OV5693_REG_8BIT(0x379a), 0x07}, 285 - {OV5693_REG_8BIT(0x379b), 0xb0}, 286 - {OV5693_REG_8BIT(0x379c), 0x0c}, 287 - {OV5693_REG_8BIT(0x3a04), 0x06}, 288 - {OV5693_REG_8BIT(0x3a05), 0x14}, 289 - {OV5693_REG_8BIT(0x3e07), 0x20}, 290 - {OV5693_REG_8BIT(0x4000), 0x08}, 291 - {OV5693_REG_8BIT(0x4001), 0x04}, 292 - {OV5693_REG_8BIT(0x4004), 0x08}, 293 - {OV5693_REG_8BIT(0x4006), 0x20}, 294 - {OV5693_REG_8BIT(0x4008), 0x24}, 295 - {OV5693_REG_8BIT(0x4009), 0x10}, 296 - {OV5693_REG_8BIT(0x4058), 0x00}, 297 - {OV5693_REG_8BIT(0x4101), 0xb2}, 298 - {OV5693_REG_8BIT(0x4307), 0x31}, 299 - {OV5693_REG_8BIT(0x4511), 0x05}, 300 - {OV5693_REG_8BIT(0x4512), 0x01}, 301 - {OV5693_REG_8BIT(0x481f), 0x30}, 302 - {OV5693_REG_8BIT(0x4826), 0x2c}, 303 - {OV5693_REG_8BIT(0x4d02), 0xfd}, 304 - {OV5693_REG_8BIT(0x4d03), 0xf5}, 305 - {OV5693_REG_8BIT(0x4d04), 0x0c}, 306 - {OV5693_REG_8BIT(0x4d05), 0xcc}, 307 - {OV5693_REG_8BIT(0x4837), 0x0a}, 308 - {OV5693_REG_8BIT(0x5003), 0x20}, 309 - {OV5693_REG_8BIT(0x5013), 0x00}, 310 - {OV5693_REG_8BIT(0x5842), 0x01}, 311 - {OV5693_REG_8BIT(0x5843), 0x2b}, 312 - {OV5693_REG_8BIT(0x5844), 0x01}, 313 - {OV5693_REG_8BIT(0x5845), 0x92}, 314 - {OV5693_REG_8BIT(0x5846), 0x01}, 315 - {OV5693_REG_8BIT(0x5847), 0x8f}, 316 - {OV5693_REG_8BIT(0x5848), 0x01}, 317 - {OV5693_REG_8BIT(0x5849), 0x0c}, 318 - {OV5693_REG_8BIT(0x5e10), 0x0c}, 319 - {OV5693_REG_8BIT(0x3820), 0x00}, 320 - {OV5693_REG_8BIT(0x3821), 0x1e}, 321 - {OV5693_REG_8BIT(0x5041), 0x14} 322 - }; 323 - 324 - static const struct ov5693_reg_list ov5693_global_setting = { 325 - .num_regs = ARRAY_SIZE(ov5693_global_regs), 326 - .regs = ov5693_global_regs, 192 + static const struct cci_reg_sequence ov5693_global_regs[] = { 193 + {CCI_REG8(0x3016), 0xf0}, 194 + {CCI_REG8(0x3017), 0xf0}, 195 + {CCI_REG8(0x3018), 0xf0}, 196 + {CCI_REG8(0x3022), 0x01}, 197 + {CCI_REG8(0x3028), 0x44}, 198 + {CCI_REG8(0x3098), 0x02}, 199 + {CCI_REG8(0x3099), 0x19}, 200 + {CCI_REG8(0x309a), 0x02}, 201 + {CCI_REG8(0x309b), 0x01}, 202 + {CCI_REG8(0x309c), 0x00}, 203 + {CCI_REG8(0x30a0), 0xd2}, 204 + {CCI_REG8(0x30a2), 0x01}, 205 + {CCI_REG8(0x30b2), 0x00}, 206 + {CCI_REG8(0x30b3), 0x83}, 207 + {CCI_REG8(0x30b4), 0x03}, 208 + {CCI_REG8(0x30b5), 0x04}, 209 + {CCI_REG8(0x30b6), 0x01}, 210 + {CCI_REG8(0x3080), 0x01}, 211 + {CCI_REG8(0x3104), 0x21}, 212 + {CCI_REG8(0x3106), 0x00}, 213 + {CCI_REG8(0x3406), 0x01}, 214 + {CCI_REG8(0x3503), 0x07}, 215 + {CCI_REG8(0x350b), 0x40}, 216 + {CCI_REG8(0x3601), 0x0a}, 217 + {CCI_REG8(0x3602), 0x38}, 218 + {CCI_REG8(0x3612), 0x80}, 219 + {CCI_REG8(0x3620), 0x54}, 220 + {CCI_REG8(0x3621), 0xc7}, 221 + {CCI_REG8(0x3622), 0x0f}, 222 + {CCI_REG8(0x3625), 0x10}, 223 + {CCI_REG8(0x3630), 0x55}, 224 + {CCI_REG8(0x3631), 0xf4}, 225 + {CCI_REG8(0x3632), 0x00}, 226 + {CCI_REG8(0x3633), 0x34}, 227 + {CCI_REG8(0x3634), 0x02}, 228 + {CCI_REG8(0x364d), 0x0d}, 229 + {CCI_REG8(0x364f), 0xdd}, 230 + {CCI_REG8(0x3660), 0x04}, 231 + {CCI_REG8(0x3662), 0x10}, 232 + {CCI_REG8(0x3663), 0xf1}, 233 + {CCI_REG8(0x3665), 0x00}, 234 + {CCI_REG8(0x3666), 0x20}, 235 + {CCI_REG8(0x3667), 0x00}, 236 + {CCI_REG8(0x366a), 0x80}, 237 + {CCI_REG8(0x3680), 0xe0}, 238 + {CCI_REG8(0x3681), 0x00}, 239 + {CCI_REG8(0x3700), 0x42}, 240 + {CCI_REG8(0x3701), 0x14}, 241 + {CCI_REG8(0x3702), 0xa0}, 242 + {CCI_REG8(0x3703), 0xd8}, 243 + {CCI_REG8(0x3704), 0x78}, 244 + {CCI_REG8(0x3705), 0x02}, 245 + {CCI_REG8(0x370a), 0x00}, 246 + {CCI_REG8(0x370b), 0x20}, 247 + {CCI_REG8(0x370c), 0x0c}, 248 + {CCI_REG8(0x370d), 0x11}, 249 + {CCI_REG8(0x370e), 0x00}, 250 + {CCI_REG8(0x370f), 0x40}, 251 + {CCI_REG8(0x3710), 0x00}, 252 + {CCI_REG8(0x371a), 0x1c}, 253 + {CCI_REG8(0x371b), 0x05}, 254 + {CCI_REG8(0x371c), 0x01}, 255 + {CCI_REG8(0x371e), 0xa1}, 256 + {CCI_REG8(0x371f), 0x0c}, 257 + {CCI_REG8(0x3721), 0x00}, 258 + {CCI_REG8(0x3724), 0x10}, 259 + {CCI_REG8(0x3726), 0x00}, 260 + {CCI_REG8(0x372a), 0x01}, 261 + {CCI_REG8(0x3730), 0x10}, 262 + {CCI_REG8(0x3738), 0x22}, 263 + {CCI_REG8(0x3739), 0xe5}, 264 + {CCI_REG8(0x373a), 0x50}, 265 + {CCI_REG8(0x373b), 0x02}, 266 + {CCI_REG8(0x373c), 0x41}, 267 + {CCI_REG8(0x373f), 0x02}, 268 + {CCI_REG8(0x3740), 0x42}, 269 + {CCI_REG8(0x3741), 0x02}, 270 + {CCI_REG8(0x3742), 0x18}, 271 + {CCI_REG8(0x3743), 0x01}, 272 + {CCI_REG8(0x3744), 0x02}, 273 + {CCI_REG8(0x3747), 0x10}, 274 + {CCI_REG8(0x374c), 0x04}, 275 + {CCI_REG8(0x3751), 0xf0}, 276 + {CCI_REG8(0x3752), 0x00}, 277 + {CCI_REG8(0x3753), 0x00}, 278 + {CCI_REG8(0x3754), 0xc0}, 279 + {CCI_REG8(0x3755), 0x00}, 280 + {CCI_REG8(0x3756), 0x1a}, 281 + {CCI_REG8(0x3758), 0x00}, 282 + {CCI_REG8(0x3759), 0x0f}, 283 + {CCI_REG8(0x376b), 0x44}, 284 + {CCI_REG8(0x375c), 0x04}, 285 + {CCI_REG8(0x3774), 0x10}, 286 + {CCI_REG8(0x3776), 0x00}, 287 + {CCI_REG8(0x377f), 0x08}, 288 + {CCI_REG8(0x3780), 0x22}, 289 + {CCI_REG8(0x3781), 0x0c}, 290 + {CCI_REG8(0x3784), 0x2c}, 291 + {CCI_REG8(0x3785), 0x1e}, 292 + {CCI_REG8(0x378f), 0xf5}, 293 + {CCI_REG8(0x3791), 0xb0}, 294 + {CCI_REG8(0x3795), 0x00}, 295 + {CCI_REG8(0x3796), 0x64}, 296 + {CCI_REG8(0x3797), 0x11}, 297 + {CCI_REG8(0x3798), 0x30}, 298 + {CCI_REG8(0x3799), 0x41}, 299 + {CCI_REG8(0x379a), 0x07}, 300 + {CCI_REG8(0x379b), 0xb0}, 301 + {CCI_REG8(0x379c), 0x0c}, 302 + {CCI_REG8(0x3a04), 0x06}, 303 + {CCI_REG8(0x3a05), 0x14}, 304 + {CCI_REG8(0x3e07), 0x20}, 305 + {CCI_REG8(0x4000), 0x08}, 306 + {CCI_REG8(0x4001), 0x04}, 307 + {CCI_REG8(0x4004), 0x08}, 308 + {CCI_REG8(0x4006), 0x20}, 309 + {CCI_REG8(0x4008), 0x24}, 310 + {CCI_REG8(0x4009), 0x10}, 311 + {CCI_REG8(0x4058), 0x00}, 312 + {CCI_REG8(0x4101), 0xb2}, 313 + {CCI_REG8(0x4307), 0x31}, 314 + {CCI_REG8(0x4511), 0x05}, 315 + {CCI_REG8(0x4512), 0x01}, 316 + {CCI_REG8(0x481f), 0x30}, 317 + {CCI_REG8(0x4826), 0x2c}, 318 + {CCI_REG8(0x4d02), 0xfd}, 319 + {CCI_REG8(0x4d03), 0xf5}, 320 + {CCI_REG8(0x4d04), 0x0c}, 321 + {CCI_REG8(0x4d05), 0xcc}, 322 + {CCI_REG8(0x4837), 0x0a}, 323 + {CCI_REG8(0x5003), 0x20}, 324 + {CCI_REG8(0x5013), 0x00}, 325 + {CCI_REG8(0x5842), 0x01}, 326 + {CCI_REG8(0x5843), 0x2b}, 327 + {CCI_REG8(0x5844), 0x01}, 328 + {CCI_REG8(0x5845), 0x92}, 329 + {CCI_REG8(0x5846), 0x01}, 330 + {CCI_REG8(0x5847), 0x8f}, 331 + {CCI_REG8(0x5848), 0x01}, 332 + {CCI_REG8(0x5849), 0x0c}, 333 + {CCI_REG8(0x5e10), 0x0c}, 334 + {CCI_REG8(0x3820), 0x00}, 335 + {CCI_REG8(0x3821), 0x1e}, 336 + {CCI_REG8(0x5041), 0x14} 327 337 }; 328 338 329 339 static const struct v4l2_rect ov5693_default_crop = { ··· 353 373 OV5693_TEST_PATTERN_ROLLING, 354 374 }; 355 375 356 - /* I2C I/O Operations */ 357 - 358 - static int ov5693_read_reg(struct ov5693_device *ov5693, u32 addr, u32 *value) 359 - { 360 - struct i2c_client *client = ov5693->client; 361 - __be16 reg; 362 - u8 val[4]; 363 - struct i2c_msg msg[] = { 364 - { 365 - .addr = client->addr, 366 - .flags = 0, 367 - .len = 2, 368 - .buf = (u8 *)&reg, 369 - }, 370 - { 371 - .addr = client->addr, 372 - .flags = I2C_M_RD, 373 - .buf = (u8 *)&val, 374 - }, 375 - }; 376 - unsigned int len = ((addr >> OV5693_REG_SIZE_SHIFT) & 3); 377 - unsigned int i; 378 - int ret; 379 - 380 - reg = cpu_to_be16(addr & OV5693_REG_ADDR_MASK); 381 - 382 - msg[1].len = len; 383 - 384 - ret = i2c_transfer(client->adapter, msg, 2); 385 - if (ret < 0) 386 - return dev_err_probe(&client->dev, ret, 387 - "Failed to read register 0x%04x\n", 388 - addr & OV5693_REG_ADDR_MASK); 389 - 390 - *value = 0; 391 - for (i = 0; i < len; ++i) { 392 - *value <<= 8; 393 - *value |= val[i]; 394 - } 395 - 396 - return 0; 397 - } 398 - 399 - static void ov5693_write_reg(struct ov5693_device *ov5693, u32 addr, u32 value, 400 - int *error) 401 - { 402 - struct i2c_client *client = ov5693->client; 403 - struct { 404 - __be16 reg; 405 - u8 val[4]; 406 - } __packed buf; 407 - struct i2c_msg msg = { 408 - .addr = client->addr, 409 - .buf = (u8 *)&buf, 410 - }; 411 - unsigned int len = ((addr >> OV5693_REG_SIZE_SHIFT) & 3); 412 - unsigned int i; 413 - int ret; 414 - 415 - if (*error < 0) 416 - return; 417 - 418 - buf.reg = cpu_to_be16(addr & OV5693_REG_ADDR_MASK); 419 - for (i = 0; i < len; ++i) { 420 - buf.val[len - i - 1] = value & 0xff; 421 - value >>= 8; 422 - } 423 - 424 - msg.len = len + 2; 425 - 426 - ret = i2c_transfer(client->adapter, &msg, 1); 427 - if (ret < 0) { 428 - dev_err(&client->dev, "Failed to write register 0x%04x: %d\n", 429 - addr & OV5693_REG_ADDR_MASK, ret); 430 - *error = ret; 431 - } 432 - } 433 - 434 - static int ov5693_write_reg_array(struct ov5693_device *ov5693, 435 - const struct ov5693_reg_list *reglist) 436 - { 437 - unsigned int i; 438 - int ret = 0; 439 - 440 - for (i = 0; i < reglist->num_regs; i++) 441 - ov5693_write_reg(ov5693, reglist->regs[i].reg, 442 - reglist->regs[i].val, &ret); 443 - 444 - return ret; 445 - } 446 - 447 - static int ov5693_update_bits(struct ov5693_device *ov5693, u32 address, 448 - u32 mask, u32 bits) 449 - { 450 - u32 value = 0; 451 - int ret; 452 - 453 - ret = ov5693_read_reg(ov5693, address, &value); 454 - if (ret) 455 - return ret; 456 - 457 - value &= ~mask; 458 - value |= bits; 459 - 460 - ov5693_write_reg(ov5693, address, value, &ret); 461 - 462 - return ret; 463 - } 464 - 465 376 /* V4L2 Controls Functions */ 466 377 467 378 static int ov5693_flip_vert_configure(struct ov5693_device *ov5693, ··· 362 491 OV5693_FORMAT1_FLIP_VERT_SENSOR_EN; 363 492 int ret; 364 493 365 - ret = ov5693_update_bits(ov5693, OV5693_FORMAT1_REG, bits, 366 - enable ? bits : 0); 494 + ret = cci_update_bits(ov5693->regmap, OV5693_FORMAT1_REG, bits, 495 + enable ? bits : 0, NULL); 367 496 if (ret) 368 497 return ret; 369 498 ··· 377 506 OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN; 378 507 int ret; 379 508 380 - ret = ov5693_update_bits(ov5693, OV5693_FORMAT2_REG, bits, 381 - enable ? bits : 0); 509 + ret = cci_update_bits(ov5693->regmap, OV5693_FORMAT2_REG, bits, 510 + enable ? bits : 0, NULL); 382 511 if (ret) 383 512 return ret; 384 513 ··· 387 516 388 517 static int ov5693_get_exposure(struct ov5693_device *ov5693, s32 *value) 389 518 { 390 - u32 exposure; 519 + u64 exposure; 391 520 int ret; 392 521 393 - ret = ov5693_read_reg(ov5693, OV5693_EXPOSURE_CTRL_REG, &exposure); 522 + ret = cci_read(ov5693->regmap, OV5693_EXPOSURE_CTRL_REG, &exposure, 523 + NULL); 394 524 if (ret) 395 525 return ret; 396 526 ··· 408 536 409 537 exposure = (exposure << 4) & OV5693_EXPOSURE_CTRL_MASK; 410 538 411 - ov5693_write_reg(ov5693, OV5693_EXPOSURE_CTRL_REG, exposure, &ret); 539 + cci_write(ov5693->regmap, OV5693_EXPOSURE_CTRL_REG, exposure, &ret); 412 540 413 541 return ret; 414 542 } 415 543 416 544 static int ov5693_get_gain(struct ov5693_device *ov5693, u32 *gain) 417 545 { 418 - u32 value; 546 + u64 value; 419 547 int ret; 420 548 421 - ret = ov5693_read_reg(ov5693, OV5693_GAIN_CTRL_REG, &value); 549 + ret = cci_read(ov5693->regmap, OV5693_GAIN_CTRL_REG, &value, NULL); 422 550 if (ret) 423 551 return ret; 424 552 ··· 435 563 436 564 gain &= OV5693_MWB_GAIN_MASK; 437 565 438 - ov5693_write_reg(ov5693, OV5693_MWB_RED_GAIN_REG, gain, &ret); 439 - ov5693_write_reg(ov5693, OV5693_MWB_GREEN_GAIN_REG, gain, &ret); 440 - ov5693_write_reg(ov5693, OV5693_MWB_BLUE_GAIN_REG, gain, &ret); 566 + cci_write(ov5693->regmap, OV5693_MWB_RED_GAIN_REG, gain, &ret); 567 + cci_write(ov5693->regmap, OV5693_MWB_GREEN_GAIN_REG, gain, &ret); 568 + cci_write(ov5693->regmap, OV5693_MWB_BLUE_GAIN_REG, gain, &ret); 441 569 442 570 return ret; 443 571 } ··· 448 576 449 577 gain = (gain << 4) & OV5693_GAIN_CTRL_MASK; 450 578 451 - ov5693_write_reg(ov5693, OV5693_GAIN_CTRL_REG, gain, &ret); 579 + cci_write(ov5693->regmap, OV5693_GAIN_CTRL_REG, gain, &ret); 452 580 453 581 return ret; 454 582 } ··· 458 586 u16 vts = ov5693->mode.format.height + vblank; 459 587 int ret = 0; 460 588 461 - ov5693_write_reg(ov5693, OV5693_TIMING_VTS_REG, vts, &ret); 589 + cci_write(ov5693->regmap, OV5693_TIMING_VTS_REG, vts, &ret); 462 590 463 591 return ret; 464 592 } ··· 467 595 { 468 596 int ret = 0; 469 597 470 - ov5693_write_reg(ov5693, OV5693_TEST_PATTERN_REG, 471 - ov5693_test_pattern_bits[idx], &ret); 598 + cci_write(ov5693->regmap, OV5693_TEST_PATTERN_REG, 599 + ov5693_test_pattern_bits[idx], &ret); 472 600 473 601 return ret; 474 602 } ··· 557 685 int ret = 0; 558 686 559 687 /* Crop Start X */ 560 - ov5693_write_reg(ov5693, OV5693_CROP_START_X_REG, mode->crop.left, 561 - &ret); 688 + cci_write(ov5693->regmap, OV5693_CROP_START_X_REG, mode->crop.left, 689 + &ret); 562 690 563 691 /* Offset X */ 564 - ov5693_write_reg(ov5693, OV5693_OFFSET_START_X_REG, 0, &ret); 692 + cci_write(ov5693->regmap, OV5693_OFFSET_START_X_REG, 0, &ret); 565 693 566 694 /* Output Size X */ 567 - ov5693_write_reg(ov5693, OV5693_OUTPUT_SIZE_X_REG, mode->format.width, 568 - &ret); 695 + cci_write(ov5693->regmap, OV5693_OUTPUT_SIZE_X_REG, mode->format.width, 696 + &ret); 569 697 570 698 /* Crop End X */ 571 - ov5693_write_reg(ov5693, OV5693_CROP_END_X_REG, 572 - mode->crop.left + mode->crop.width, &ret); 699 + cci_write(ov5693->regmap, OV5693_CROP_END_X_REG, 700 + mode->crop.left + mode->crop.width, &ret); 573 701 574 702 /* Horizontal Total Size */ 575 - ov5693_write_reg(ov5693, OV5693_TIMING_HTS_REG, OV5693_FIXED_PPL, 576 - &ret); 703 + cci_write(ov5693->regmap, OV5693_TIMING_HTS_REG, OV5693_FIXED_PPL, 704 + &ret); 577 705 578 706 /* Crop Start Y */ 579 - ov5693_write_reg(ov5693, OV5693_CROP_START_Y_REG, mode->crop.top, 580 - &ret); 707 + cci_write(ov5693->regmap, OV5693_CROP_START_Y_REG, mode->crop.top, 708 + &ret); 581 709 582 710 /* Offset Y */ 583 - ov5693_write_reg(ov5693, OV5693_OFFSET_START_Y_REG, 0, &ret); 711 + cci_write(ov5693->regmap, OV5693_OFFSET_START_Y_REG, 0, &ret); 584 712 585 713 /* Output Size Y */ 586 - ov5693_write_reg(ov5693, OV5693_OUTPUT_SIZE_Y_REG, mode->format.height, 587 - &ret); 714 + cci_write(ov5693->regmap, OV5693_OUTPUT_SIZE_Y_REG, mode->format.height, 715 + &ret); 588 716 589 717 /* Crop End Y */ 590 - ov5693_write_reg(ov5693, OV5693_CROP_END_Y_REG, 591 - mode->crop.top + mode->crop.height, &ret); 718 + cci_write(ov5693->regmap, OV5693_CROP_END_Y_REG, 719 + mode->crop.top + mode->crop.height, &ret); 592 720 593 721 /* Subsample X increase */ 594 - ov5693_write_reg(ov5693, OV5693_SUB_INC_X_REG, 595 - ((mode->inc_x_odd << 4) & 0xf0) | 0x01, &ret); 722 + cci_write(ov5693->regmap, OV5693_SUB_INC_X_REG, 723 + ((mode->inc_x_odd << 4) & 0xf0) | 0x01, &ret); 596 724 /* Subsample Y increase */ 597 - ov5693_write_reg(ov5693, OV5693_SUB_INC_Y_REG, 598 - ((mode->inc_y_odd << 4) & 0xf0) | 0x01, &ret); 599 - 600 - if (ret) 601 - return ret; 725 + cci_write(ov5693->regmap, OV5693_SUB_INC_Y_REG, 726 + ((mode->inc_y_odd << 4) & 0xf0) | 0x01, &ret); 602 727 603 728 /* Binning */ 604 - ret = ov5693_update_bits(ov5693, OV5693_FORMAT1_REG, 605 - OV5693_FORMAT1_VBIN_EN, 606 - mode->binning_y ? OV5693_FORMAT1_VBIN_EN : 0); 607 - if (ret) 608 - return ret; 729 + cci_update_bits(ov5693->regmap, OV5693_FORMAT1_REG, 730 + OV5693_FORMAT1_VBIN_EN, 731 + mode->binning_y ? OV5693_FORMAT1_VBIN_EN : 0, &ret); 609 732 610 - ret = ov5693_update_bits(ov5693, OV5693_FORMAT2_REG, 611 - OV5693_FORMAT2_HBIN_EN, 612 - mode->binning_x ? OV5693_FORMAT2_HBIN_EN : 0); 733 + cci_update_bits(ov5693->regmap, OV5693_FORMAT2_REG, 734 + OV5693_FORMAT2_HBIN_EN, 735 + mode->binning_x ? OV5693_FORMAT2_HBIN_EN : 0, &ret); 613 736 614 737 return ret; 615 738 } ··· 613 746 { 614 747 int ret = 0; 615 748 616 - ov5693_write_reg(ov5693, OV5693_SW_STREAM_REG, 617 - enable ? OV5693_START_STREAMING : 618 - OV5693_STOP_STREAMING, &ret); 749 + cci_write(ov5693->regmap, OV5693_SW_STREAM_REG, 750 + enable ? OV5693_START_STREAMING : OV5693_STOP_STREAMING, 751 + &ret); 619 752 620 753 return ret; 621 754 } ··· 624 757 { 625 758 int ret = 0; 626 759 627 - ov5693_write_reg(ov5693, OV5693_SW_RESET_REG, OV5693_SW_RESET, &ret); 760 + cci_write(ov5693->regmap, OV5693_SW_RESET_REG, OV5693_SW_RESET, &ret); 628 761 629 762 return ret; 630 763 } ··· 638 771 return dev_err_probe(ov5693->dev, ret, 639 772 "software reset error\n"); 640 773 641 - ret = ov5693_write_reg_array(ov5693, &ov5693_global_setting); 774 + ret = cci_multi_reg_write(ov5693->regmap, ov5693_global_regs, 775 + ARRAY_SIZE(ov5693_global_regs), NULL); 642 776 if (ret) 643 777 return dev_err_probe(ov5693->dev, ret, 644 778 "global settings error\n"); ··· 739 871 static int ov5693_detect(struct ov5693_device *ov5693) 740 872 { 741 873 int ret; 742 - u32 id; 874 + u64 id; 743 875 744 - ret = ov5693_read_reg(ov5693, OV5693_REG_CHIP_ID, &id); 876 + ret = cci_read(ov5693->regmap, OV5693_REG_CHIP_ID, &id, NULL); 745 877 if (ret) 746 878 return ret; 747 879 748 880 if (id != OV5693_CHIP_ID) 749 881 return dev_err_probe(ov5693->dev, -ENODEV, 750 - "sensor ID mismatch. Found 0x%04x\n", id); 882 + "sensor ID mismatch. Got 0x%04llx\n", id); 751 883 752 884 return 0; 753 885 } ··· 1275 1407 if (!ov5693) 1276 1408 return -ENOMEM; 1277 1409 1278 - ov5693->client = client; 1279 1410 ov5693->dev = &client->dev; 1411 + 1412 + ov5693->regmap = devm_cci_regmap_init_i2c(client, 16); 1413 + if (IS_ERR(ov5693->regmap)) 1414 + return PTR_ERR(ov5693->regmap); 1280 1415 1281 1416 ret = ov5693_check_hwcfg(ov5693); 1282 1417 if (ret)