Lines Matching +full:i2c +full:- +full:isp

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2017-2020 Jacopo Mondi
6 * Copyright (C) 2017-2019 Kieran Bingham
7 * Copyright (C) 2017-2019 Laurent Pinchart
8 * Copyright (C) 2017-2019 Niklas Söderlund
16 #include <linux/i2c.h>
21 #include <media/v4l2-async.h>
22 #include <media/v4l2-ctrls.h>
23 #include <media/v4l2-subdev.h>
80 struct i2c_client *isp; member
106 * NOTE: EMB line is still used in ISP and sensor
113 * PCLK polarity - useless due to silicon bug.
119 /* bit[3]=0 - PCLK polarity workaround. */
184 ret = i2c_master_send(dev->isp, buf, 2); in ov490_read()
186 ret = i2c_master_recv(dev->isp, val, 1); in ov490_read()
189 dev_dbg(dev->dev, "%s: register 0x%04x read failed (%d)\n", in ov490_read()
202 ret = i2c_master_send(dev->isp, buf, 3); in ov490_write()
204 dev_err(dev->dev, "%s: register 0x%04x write failed (%d)\n", in ov490_write()
218 if (page == dev->last_page) in ov490_set_page()
221 if (page_high != (dev->last_page >> 8)) { in ov490_set_page()
227 if (page_low != (u8)dev->last_page) { in ov490_set_page()
233 dev->last_page = page; in ov490_set_page()
251 dev_dbg(dev->dev, "%s: 0x%08x = 0x%02x\n", __func__, reg, *val); in ov490_read_reg()
268 dev_dbg(dev->dev, "%s: 0x%08x = 0x%02x\n", __func__, reg, val); in ov490_write_reg()
278 * Enable serial link now that the ISP provides a valid pixel clock in rdacm21_s_stream()
281 return max9271_set_serial_link(&dev->serializer, enable); in rdacm21_s_stream()
288 if (code->pad || code->index > 0) in rdacm21_enum_mbus_code()
289 return -EINVAL; in rdacm21_enum_mbus_code()
291 code->code = MEDIA_BUS_FMT_YUYV8_1X16; in rdacm21_enum_mbus_code()
300 struct v4l2_mbus_framefmt *mf = &format->format; in rdacm21_get_fmt()
303 if (format->pad) in rdacm21_get_fmt()
304 return -EINVAL; in rdacm21_get_fmt()
306 mf->width = dev->fmt.width; in rdacm21_get_fmt()
307 mf->height = dev->fmt.height; in rdacm21_get_fmt()
308 mf->code = MEDIA_BUS_FMT_YUYV8_1X16; in rdacm21_get_fmt()
309 mf->colorspace = V4L2_COLORSPACE_SRGB; in rdacm21_get_fmt()
310 mf->field = V4L2_FIELD_NONE; in rdacm21_get_fmt()
311 mf->ycbcr_enc = V4L2_YCBCR_ENC_601; in rdacm21_get_fmt()
312 mf->quantization = V4L2_QUANTIZATION_FULL_RANGE; in rdacm21_get_fmt()
313 mf->xfer_func = V4L2_XFER_FUNC_NONE; in rdacm21_get_fmt()
378 dev_err(dev->dev, "OV10640 ID mismatch: (0x%02x)\n", val); in ov10640_check_id()
379 return -ENODEV; in ov10640_check_id()
382 dev_dbg(dev->dev, "OV10640 ID = 0x%2x\n", val); in ov10640_check_id()
406 dev_err(dev->dev, "OV490 PID read failed (%d)\n", ret); in ov490_initialize()
415 dev_err(dev->dev, "OV490 ID mismatch (0x%04x)\n", in ov490_initialize()
417 return -ENODEV; in ov490_initialize()
428 dev_err(dev->dev, "Timeout waiting for firmware boot\n"); in ov490_initialize()
429 return -ENODEV; in ov490_initialize()
436 /* Program OV490 with register-value table. */ in ov490_initialize()
441 dev_err(dev->dev, in ov490_initialize()
445 return -EIO; in ov490_initialize()
452 * The ISP is programmed with the content of a serial flash memory. in ov490_initialize()
456 dev->fmt.width = (val & 0xf) << 8; in ov490_initialize()
458 dev->fmt.width |= (val & 0xff); in ov490_initialize()
461 dev->fmt.height = (val & 0xf) << 8; in ov490_initialize()
463 dev->fmt.height |= val & 0xff; in ov490_initialize()
468 dev_info(dev->dev, "Identified RDACM21 camera module\n"); in ov490_initialize()
477 max9271_wake_up(&dev->serializer); in rdacm21_initialize()
480 ret = max9271_set_serial_link(&dev->serializer, false); in rdacm21_initialize()
484 /* Configure I2C bus at 105Kbps speed and configure GMSL. */ in rdacm21_initialize()
485 ret = max9271_configure_i2c(&dev->serializer, in rdacm21_initialize()
492 ret = max9271_verify_id(&dev->serializer); in rdacm21_initialize()
500 ret = max9271_enable_gpios(&dev->serializer, MAX9271_GPIO1OUT); in rdacm21_initialize()
504 ret = max9271_clear_gpios(&dev->serializer, MAX9271_GPIO1OUT); in rdacm21_initialize()
509 ret = max9271_configure_gmsl_link(&dev->serializer); in rdacm21_initialize()
513 ret = max9271_set_address(&dev->serializer, dev->addrs[0]); in rdacm21_initialize()
516 dev->serializer.client->addr = dev->addrs[0]; in rdacm21_initialize()
518 ret = max9271_set_translation(&dev->serializer, dev->addrs[1], in rdacm21_initialize()
522 dev->isp->addr = dev->addrs[1]; in rdacm21_initialize()
525 ret = max9271_set_gpios(&dev->serializer, MAX9271_GPIO1OUT); in rdacm21_initialize()
540 return max9271_set_high_threshold(&dev->serializer, true); in rdacm21_initialize()
548 dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); in rdacm21_probe()
550 return -ENOMEM; in rdacm21_probe()
551 dev->dev = &client->dev; in rdacm21_probe()
552 dev->serializer.client = client; in rdacm21_probe()
554 ret = of_property_read_u32_array(client->dev.of_node, "reg", in rdacm21_probe()
555 dev->addrs, 2); in rdacm21_probe()
557 dev_err(dev->dev, "Invalid DT reg property: %d\n", ret); in rdacm21_probe()
558 return -EINVAL; in rdacm21_probe()
561 /* Create the dummy I2C client for the sensor. */ in rdacm21_probe()
562 dev->isp = i2c_new_dummy_device(client->adapter, OV490_I2C_ADDRESS); in rdacm21_probe()
563 if (IS_ERR(dev->isp)) in rdacm21_probe()
564 return PTR_ERR(dev->isp); in rdacm21_probe()
571 v4l2_i2c_subdev_init(&dev->sd, client, &rdacm21_subdev_ops); in rdacm21_probe()
572 dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in rdacm21_probe()
574 v4l2_ctrl_handler_init(&dev->ctrls, 1); in rdacm21_probe()
575 v4l2_ctrl_new_std(&dev->ctrls, NULL, V4L2_CID_PIXEL_RATE, in rdacm21_probe()
578 dev->sd.ctrl_handler = &dev->ctrls; in rdacm21_probe()
580 ret = dev->ctrls.error; in rdacm21_probe()
584 dev->pad.flags = MEDIA_PAD_FL_SOURCE; in rdacm21_probe()
585 dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in rdacm21_probe()
586 ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad); in rdacm21_probe()
590 ret = v4l2_async_register_subdev(&dev->sd); in rdacm21_probe()
597 v4l2_ctrl_handler_free(&dev->ctrls); in rdacm21_probe()
599 i2c_unregister_device(dev->isp); in rdacm21_probe()
608 v4l2_async_unregister_subdev(&dev->sd); in rdacm21_remove()
609 v4l2_ctrl_handler_free(&dev->ctrls); in rdacm21_remove()
610 i2c_unregister_device(dev->isp); in rdacm21_remove()