Mipi Csi2 Error: could not get clock csi_mclk

2019-09-17 06:28发布

问题:

I have been working on writing mipi csi-2 imx290 camera driver. I have faced with csi_clock error.

This is my imx290_probe function;

static int imx290_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
{

  struct device *dev = &client->dev;
  int retval;
  int value;




  /* request reset pin */
  xclr = of_get_named_gpio(dev->of_node, "rst-gpios", 0);
  if (!gpio_is_valid(xclr)) {
    dev_warn(dev, "no sensor reset pin available");
    return -EINVAL;
  }

  retval = devm_gpio_request_one(dev, xclr, GPIOF_OUT_INIT_LOW,"imx290_mipi_reset");
  if (retval < 0)
    return retval;


  /* Set initial values for the sensor struct. */
  memset(&imx290_data, 0, sizeof(imx290_data));
  imx290_data.sensor_clk = devm_clk_get(dev, "csi_mclk");

  if (IS_ERR(imx290_data.sensor_clk)) {

    /* assuming clock enabled by default */
    imx290_data.sensor_clk = NULL;
    dev_err(dev, "clock-frequency missing or invalid\n");
    return PTR_ERR(imx290_data.sensor_clk);
  }


  retval = of_property_read_u32(dev->of_node, "mclk",&(imx290_data.mclk));

  if (retval) {
    dev_err(dev, "mclk missing or invalid\n");
    return retval;
  }

  retval = of_property_read_u32(dev->of_node, "mclk_source",
          (u32 *) &(imx290_data.mclk_source));
  if (retval) {
    dev_err(dev, "mclk_source missing or invalid\n");
    return retval;
  }

  retval = of_property_read_u32(dev->of_node, "csi_id",
          &(imx290_data.csi));
  if (retval) {
    dev_err(dev, "csi id missing or invalid\n");
    return retval;
  }
  pr_info("Line 10 is Ok\n ");
  clk_prepare_enable(imx290_data.sensor_clk);

  imx290_data.io_init = imx290_reset;
  imx290_data.i2c_client = client;
  imx290_data.pix.pixelformat = V4L2_PIX_FMT_UYVY;
  imx290_data.pix.width = 1920;
  imx290_data.pix.height = 1080;
  imx290_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | V4L2_CAP_TIMEPERFRAME;
  imx290_data.streamcap.capturemode = 0;
  imx290_data.streamcap.timeperframe.denominator = DEFAULT_FPS;
  imx290_data.streamcap.timeperframe.numerator = 1;

  imx290_power_on(dev);

  imx290_reset();

  retval = imx290_write_reg(IMX290_REG_STANDBY, 0x1,NULL);

  imx290_int_device.priv = &imx290_data;
  retval = v4l2_int_device_register(&imx290_int_device);

  clk_disable_unprepare(imx290_data.sensor_clk);

  pr_info("camera imx290_mipi is found\n");
  return retval;
}

and also I m giving the device tree configuration,

imx290_mipi: imx290_mipi@1a {
    compatible = "sony,imx290lqr,imx290,imx290_camera";
    reg = <0x1a>;
    clocks = <&clks 200>;
    clock-names = "csi_mclk";   
    OVDD = <&reg_1p8v>;
    AVDD = <&reg_2p9v>;
    DVDD = <&reg_1p2v>;
    pwn-gpios = <&gpio1 6 1>;
    rst-gpios = <&gpio4 14 0>; /// xclr 
    ipu_id = <0>;
    csi_id = <0>;
    mclk = <37125000>;
    mclk_source = <0>;
    lanes = <4>;
}

What can be wrong while doing this because this probe function as similar as ov5640 camera probe function and it doesn't give any error while probing. My mind get confused a lot , I need second opinion and suggestion.

Thanks

Best Regards

Mustafa