Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30da00d2 authored by Camera Software Integration's avatar Camera Software Integration Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: flash: Add support for qup i2c flash" into camera-kernel.lnx.4.0

parents 0695f8ed 77cf2e39
Loading
Loading
Loading
Loading
+48 −6
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ static int cam_flash_component_bind(struct device *dev,
		return -ENOMEM;

	fctrl->pdev = pdev;
	fctrl->of_node = pdev->dev.of_node;
	fctrl->soc_info.pdev = pdev;
	fctrl->soc_info.dev = &pdev->dev;
	fctrl->soc_info.dev_name = pdev->name;
@@ -600,13 +601,18 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
{
	int32_t rc = 0, i = 0;
	struct cam_flash_ctrl *fctrl;
	struct cam_hw_soc_info *soc_info = NULL;

	if (client == NULL || id == NULL) {
		CAM_ERR(CAM_FLASH, "Invalid Args client: %pK id: %pK",
			client, id);
	if (client == NULL) {
		CAM_ERR(CAM_FLASH, "Invalid Args client: %pK",
			client);
		return -EINVAL;
	}

	if (id == NULL) {
		CAM_DBG(CAM_FLASH, "device id is Null");
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		CAM_ERR(CAM_FLASH, "%s :: i2c_check_functionality failed",
			 client->name);
@@ -618,9 +624,9 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
	if (!fctrl)
		return -ENOMEM;

	i2c_set_clientdata(client, fctrl);

	client->dev.driver_data = fctrl;
	fctrl->io_master_info.client = client;
	fctrl->of_node = client->dev.of_node;
	fctrl->soc_info.dev = &client->dev;
	fctrl->soc_info.dev_name = client->name;
	fctrl->io_master_info.master_type = I2C_MASTER;
@@ -631,6 +637,40 @@ static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
		goto free_ctrl;
	}

	rc = cam_flash_init_default_params(fctrl);
	if (rc) {
		CAM_ERR(CAM_FLASH,
				"failed: cam_flash_init_default_params rc %d",
				rc);
		goto free_ctrl;
	}

	soc_info = &fctrl->soc_info;
	rc = cam_sensor_util_regulator_powerup(soc_info);
	if (rc < 0) {
		CAM_ERR(CAM_FLASH, "regulator power up for flash failed %d",
				rc);
		goto free_ctrl;
	}

	if (!soc_info->gpio_data) {
		CAM_DBG(CAM_FLASH, "No GPIO found");
		rc = 0;
		return rc;
	}

	if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
		CAM_DBG(CAM_FLASH, "No GPIO found");
		return -EINVAL;
	}

	rc = cam_sensor_util_init_gpio_pin_tbl(soc_info,
			&fctrl->power_info.gpio_num_info);
	if ((rc < 0) || (!fctrl->power_info.gpio_num_info)) {
		CAM_ERR(CAM_FLASH, "No/Error Flash GPIOs");
		goto free_ctrl;
	}

	rc = cam_flash_init_subdev(fctrl);
	if (rc)
		goto free_ctrl;
@@ -699,6 +739,7 @@ static struct i2c_driver cam_flash_i2c_driver = {
	.remove = cam_flash_i2c_driver_remove,
	.driver = {
		.name = FLASH_DRIVER_I2C,
		.of_match_table = cam_flash_dt_match,
	},
};

@@ -713,8 +754,9 @@ int32_t cam_flash_init_module(void)
	}

	rc = i2c_add_driver(&cam_flash_i2c_driver);
	if (rc)
	if (rc < 0)
		CAM_ERR(CAM_FLASH, "i2c_add_driver failed rc: %d", rc);

	return rc;
}

+8 −1
Original line number Diff line number Diff line
@@ -293,7 +293,14 @@ int cam_flash_get_dt_data(struct cam_flash_ctrl *fctrl,
		rc = -ENOMEM;
		goto release_soc_res;
	}
	of_node = fctrl->pdev->dev.of_node;

	if (fctrl->of_node == NULL) {
		CAM_ERR(CAM_FLASH, "device node is NULL");
		rc = -EINVAL;
		goto free_soc_private;
	}

	of_node = fctrl->of_node;

	rc = cam_soc_util_get_dt_properties(soc_info);
	if (rc) {
+15 −5
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 */

#include "cam_sensor_cmn_header.h"
@@ -31,10 +31,15 @@ static int32_t cam_qup_i2c_rxdata(
		},
	};
	rc = i2c_transfer(dev_client->adapter, msgs, 2);
	if (rc < 0)
	if (rc < 0) {
		CAM_ERR(CAM_SENSOR, "failed 0x%x", saddr);
		return rc;
	}
	/* Returns negative errno */
	/* else the number of messages executed. */
	/* So positive values are not errors. */
	return 0;
}


static int32_t cam_qup_i2c_txdata(
@@ -52,10 +57,15 @@ static int32_t cam_qup_i2c_txdata(
		 },
	};
	rc = i2c_transfer(dev_client->client->adapter, msg, 1);
	if (rc < 0)
	if (rc < 0) {
		CAM_ERR(CAM_SENSOR, "failed 0x%x", saddr);
		return rc;
	}
	/* Returns negative errno, */
	/* else the number of messages executed. */
	/* So positive values are not errors. */
	return 0;
}

int32_t cam_qup_i2c_read(struct i2c_client *client,
	uint32_t addr, uint32_t *data,
+2 −2
Original line number Diff line number Diff line
@@ -74,11 +74,11 @@ int32_t cam_sensor_util_regulator_powerup(struct cam_hw_soc_info *soc_info)
		if (IS_ERR_OR_NULL(soc_info->rgltr[i])) {
			rc = PTR_ERR(soc_info->rgltr[i]);
			rc = rc ? rc : -EINVAL;
			CAM_ERR(CAM_ACTUATOR, "get failed for regulator %s %d",
			CAM_ERR(CAM_SENSOR, "get failed for regulator %s %d",
				 soc_info->rgltr_name[i], rc);
			return rc;
		}
		CAM_DBG(CAM_ACTUATOR, "get for regulator %s",
		CAM_DBG(CAM_SENSOR, "get for regulator %s",
			soc_info->rgltr_name[i]);
	}