AnsweredAssumed Answered

Mipi Csi2 Camera Driver csi_mclk erro

Question asked by Mustafa Bakırcıoglu on Jul 16, 2017
Latest reply on Jul 16, 2017 by igorpadykov

Hello ;

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

 

This is 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;
    }
    
    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;
}

This is the device tree;

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>;

I think the csi_mclk should be taken from device tree without any error because it is just a device driver macro  and  imx290_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); should work but I dont understand what is wrong ? My mind confused a lot while trying to solve this problem , I need  help about that.

 

Thanks

Best Regards

Outcomes