How to force mclk enabled for cmos sensor driver


I’m working on a sensor driver started from imx219, any came with one issue.By test, i found that for the imx219 sensor, mclk is not outputted during device probing, but still Jetson Nano can find imx219 as I2C slave.

For my case, the sensor I2C is not working without mclk input, so currently I used an external mclk input for the sensor to enable the I2C communication between Jetson Nano and sensor.

So my question is that: is there a way to force Jetson Nano to output 24 MHz mclk all the time?
If I’m refer to the imx219 code(using camera_common_mclk_enable(s_data)), the currently desgin will only enable mclk out when streaming is on.

The sensor driver should enable the mclk by imx219_board_setup(). Please have a check it.

static int imx219_probe(struct i2c_client *client,
        const struct i2c_device_id *id)
        struct device *dev = &client->dev;
        struct tegracam_device *tc_dev;
        struct imx219 *priv;
        int err;

        dev_dbg(dev, "probing v4l2 sensor at addr 0x%0x\n", client->addr);

        if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
                return -EINVAL;

        priv = devm_kzalloc(dev,
                        sizeof(struct imx219), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;

        tc_dev = devm_kzalloc(dev,
                        sizeof(struct tegracam_device), GFP_KERNEL);
        if (!tc_dev)
                return -ENOMEM;

        priv->i2c_client = tc_dev->client = client;
        tc_dev->dev = dev;
        strncpy(tc_dev->name, "imx219", sizeof(tc_dev->name));
        tc_dev->dev_regmap_config = &sensor_regmap_config;
        tc_dev->sensor_ops = &imx219_common_ops;
        tc_dev->v4l2sd_internal_ops = &imx219_subdev_internal_ops;
        tc_dev->tcctrl_ops = &imx219_ctrl_ops;

        err = tegracam_device_register(tc_dev);
        if (err) {
                dev_err(dev, "tegra camera driver registration failed\n");
                return err;
        priv->tc_dev = tc_dev;
        priv->s_data = tc_dev->s_data;
        priv->subdev = &tc_dev->s_data->subdev;
        tegracam_set_privdata(tc_dev, (void *)priv);

        err = imx219_board_setup(priv);
        if (err) {
                dev_err(dev, "board setup failed\n");
                return err;

Hello ShaneCCC

Thanks for the reply, I referenced the 219 code to enable mclk using “camera_common_mclk_enable” interface, but my problem is that, for 219, using this interface, mclk wil only be enabled when streamming; if stremmming stopped, the mclk will not output.

For our sensor, the i2c is not working without mclk, so we need to force mclk output all the time.

Do you have any suggestions for how to do that? Do I need to modify the camera_common_mclk_enable implementation?


if (pdata->mclk_name) {
		err = camera_common_mclk_enable(s_data);
		if (err) {
			dev_err(dev, "error turning on mclk (%d)\n", err);
			goto done;

You can move the camera_common_mclk_enable(s_data) to the probe() function to enable it and disable it to the xxx_remove() for your case.