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

Commit 15a54054 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: Change API to populate regulator name"

parents 76341319 bed67df4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef _CAM_HW_OPS_H_
#define _CAM_HW_OPS_H_

enum cam_ahb_clk_vote {
	/* need to update the voting requests
@@ -37,3 +39,4 @@ enum cam_ahb_clk_client {
int cam_config_ahb_clk(struct device *dev, unsigned long freq,
	enum cam_ahb_clk_client id, enum cam_ahb_clk_vote vote);
int cam_ahb_clk_init(struct platform_device *pdev);
#endif /* _CAM_HW_OPS_H_ */
+52 −41
Original line number Diff line number Diff line
@@ -473,16 +473,16 @@ EXPORT_SYMBOL(msm_camera_put_clk_info_and_rates);

/* Get regulators from DT */
int msm_camera_get_regulator_info(struct platform_device *pdev,
				struct regulator ***vdd,
				struct msm_cam_regulator **vdd_info,
				int *num_reg)
{
	uint32_t cnt;
	int i, rc;
	struct device_node *of_node;
	const char *name;
	char prop_name[32];
	struct msm_cam_regulator *tmp_reg;

	if (!pdev || !vdd || !num_reg)
	if (!pdev || !vdd_info || !num_reg)
		return -EINVAL;

	of_node = pdev->dev.of_node;
@@ -499,82 +499,95 @@ int msm_camera_get_regulator_info(struct platform_device *pdev,
		return -EINVAL;
	}

	*num_reg = cnt;
	(*vdd) = devm_kcalloc(&pdev->dev, cnt, sizeof(struct regulator *),
				GFP_KERNEL);
	if (!*vdd)
	tmp_reg = devm_kcalloc(&pdev->dev, cnt,
				sizeof(struct msm_cam_regulator), GFP_KERNEL);
	if (!tmp_reg)
		return -ENOMEM;

	for (i = 0; i < cnt; i++) {
		rc = of_property_read_string_index(of_node,
			"qcom,vdd-names", i, &name);
			"qcom,vdd-names", i, &tmp_reg[i].name);
		if (rc < 0) {
			pr_err("Fail to fetch regulators: %d\n", i);
			rc = -EINVAL;
			goto err1;
		}

		CDBG("regulator-names[%d] = %s\n", i, name);
		CDBG("regulator-names[%d] = %s\n", i, tmp_reg[i].name);

		snprintf(prop_name, 32, "%s-supply", name);
		snprintf(prop_name, 32, "%s-supply", tmp_reg[i].name);

		if (of_get_property(of_node, prop_name, NULL)) {
			(*vdd)[i] = devm_regulator_get(&pdev->dev, name);
			if (IS_ERR((*vdd)[i])) {
			tmp_reg[i].vdd =
				devm_regulator_get(&pdev->dev, tmp_reg[i].name);
			if (IS_ERR(tmp_reg[i].vdd)) {
				rc = -EINVAL;
				pr_err("Fail to get regulator :%d\n", i);
				goto err1;
			}
		} else {
			pr_err("Regulator phandle not found :%s\n", name);
			pr_err("Regulator phandle not found :%s\n",
				tmp_reg[i].name);
			rc = -EINVAL;
			goto err1;
		}
		CDBG("vdd ptr[%d] :%p\n", i, (*vdd)[i]);
		CDBG("vdd ptr[%d] :%p\n", i, tmp_reg[i].vdd);
	}

	*num_reg = cnt;
	*vdd_info = tmp_reg;

	return 0;

err1:
	for (--i; i >= 0; i--)
		devm_regulator_put((*vdd)[i]);
	devm_kfree(&pdev->dev, *vdd);
		devm_regulator_put(tmp_reg[i].vdd);
	devm_kfree(&pdev->dev, tmp_reg);
	return rc;
}
EXPORT_SYMBOL(msm_camera_get_regulator_info);


/* Enable/Disable regulators */
int msm_camera_regulator_enable(struct regulator **vdd,
int msm_camera_regulator_enable(struct msm_cam_regulator *vdd_info,
				int cnt, int enable)
{
	int i;
	int rc;
	struct msm_cam_regulator *tmp = vdd_info;

	CDBG("cnt : %d, enable : %d\n", cnt, enable);
	if (!vdd) {
	if (!tmp) {
		pr_err("Invalid params");
		return -EINVAL;
	}
	CDBG("cnt : %d\n", cnt);

	for (i = 0; i < cnt; i++) {
		if (tmp && !IS_ERR_OR_NULL(tmp->vdd)) {
			CDBG("name : %s, enable : %d\n", tmp->name, enable);
			if (enable) {
			rc = regulator_enable(vdd[i]);
				rc = regulator_enable(tmp->vdd);
				if (rc < 0) {
				pr_err("regulator enable failed %d\n", i);
					pr_err("regulator enable failed %d\n",
						i);
					goto error;
				}
			} else {
			rc = regulator_disable(vdd[i]);
				rc = regulator_disable(tmp->vdd);
				if (rc < 0)
				pr_err("regulator disable failed %d\n", i);
					pr_err("regulator disable failed %d\n",
						i);
			}
		}
		tmp++;
	}

	return 0;
error:
	for (--i; i > 0; i--) {
		if (!IS_ERR_OR_NULL(vdd[i]))
			regulator_disable(vdd[i]);
		--tmp;
		if (!IS_ERR_OR_NULL(tmp->vdd))
			regulator_disable(tmp->vdd);
	}
	return rc;
}
@@ -582,24 +595,23 @@ EXPORT_SYMBOL(msm_camera_regulator_enable);

/* Put regulators regulators */
void msm_camera_put_regulators(struct platform_device *pdev,
							struct regulator ***vdd,
							int cnt)
	struct msm_cam_regulator **vdd_info, int cnt)
{
	int i;

	if (!*vdd) {
	if (!vdd_info || !*vdd_info) {
		pr_err("Invalid params\n");
		return;
	}

	for (i = cnt - 1; i >= 0; i--) {
		if (!IS_ERR_OR_NULL((*vdd)[i]))
			devm_regulator_put((*vdd)[i]);
			CDBG("vdd ptr[%d] :%p\n", i, (*vdd)[i]);
		if (vdd_info[i] && !IS_ERR_OR_NULL(vdd_info[i]->vdd))
			devm_regulator_put(vdd_info[i]->vdd);
			CDBG("vdd ptr[%d] :%p\n", i, vdd_info[i]->vdd);
	}

	devm_kfree(&pdev->dev, *vdd);
	*vdd = NULL;
	devm_kfree(&pdev->dev, *vdd_info);
	*vdd_info = NULL;
}
EXPORT_SYMBOL(msm_camera_put_regulators);

@@ -643,12 +655,11 @@ EXPORT_SYMBOL(msm_camera_register_irq);
int msm_camera_register_threaded_irq(struct platform_device *pdev,
			struct resource *irq, irq_handler_t handler_fn,
			irq_handler_t thread_fn, unsigned long irqflags,
			char *irq_name, void *dev_id)
			const char *irq_name, void *dev_id)
{
	int rc = 0;

	if (!pdev || !irq || !handler_fn || !thread_fn ||
		!irq_name || !dev_id) {
	if (!pdev || !irq || !irq_name || !dev_id) {
		pr_err("Invalid params\n");
		return -EINVAL;
	}
+12 −8
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@ enum cam_bus_client {
	CAM_BUS_CLIENT_MAX
};

struct msm_cam_regulator {
	const char *name;
	struct regulator *vdd;
};

/**
 * @brief      : Gets clock information from dtsi
 *
@@ -154,28 +159,28 @@ long msm_camera_clk_set_rate(struct device *dev,
 * platform device
 *
 * @param pdev   : platform device to get regulator information
 * @param vdd: Pointer to populate the regulator names
 * @param vdd_info: Pointer to populate the regulator names
 * @param num_reg: Pointer to populate the number of regulators
 *                 extracted from dtsi
 *
 * @return Status of operation. Negative in case of error. Zero otherwise.
 */
int msm_camera_get_regulator_info(struct platform_device *pdev,
		struct regulator ***vddd, int *num_reg);
		struct msm_cam_regulator **vdd_info, int *num_reg);
/**
 * @brief      : Enable/Disable the regultors
 *
 * This function enables/disables the regulators for a specific
 * platform device
 *
 * @param vdd: Pointer to list of regulators
 * @param vdd_info: Pointer to list of regulators
 * @param cnt: Number of regulators to enable/disable
 * @param enable: Flags specifies either enable/disable
 *
 * @return Status of operation. Negative in case of error. Zero otherwise.
 */

int msm_camera_regulator_enable(struct regulator **vdd,
int msm_camera_regulator_enable(struct msm_cam_regulator *vdd_info,
				int cnt, int enable);

/**
@@ -184,13 +189,12 @@ int msm_camera_regulator_enable(struct regulator **vdd,
 * This function releases the regulator resources.
 *
 * @param pdev: Pointer to platform device
 * @param vdd: Pointer to list of regulators
 * @param vdd_info: Pointer to list of regulators
 * @param cnt: Number of regulators to release
 */

void msm_camera_put_regulators(struct platform_device *pdev,
							struct regulator ***vdd,
							int cnt);
	struct msm_cam_regulator **vdd_info, int cnt);
/**
 * @brief      : Get the IRQ resource
 *
@@ -248,7 +252,7 @@ int msm_camera_register_threaded_irq(struct platform_device *pdev,
						irq_handler_t handler_fn,
						irq_handler_t thread_fn,
						unsigned long irqflags,
						char *irq_name,
						const char *irq_name,
						void *dev);

/**
+3 −3
Original line number Diff line number Diff line
@@ -1222,7 +1222,7 @@ static int fd_probe(struct platform_device *pdev)
		goto error_mem_resources;
	}

	ret = msm_camera_get_regulator_info(pdev, &fd->vdd,
	ret = msm_camera_get_regulator_info(pdev, &fd->vdd_info,
		&fd->num_reg);
	if (ret < 0) {
		dev_err(&pdev->dev, "Fail to get regulators\n");
@@ -1296,7 +1296,7 @@ error_get_bus:
	msm_camera_put_clk_info_and_rates(pdev, &fd->clk_info,
		&fd->clk, &fd->clk_rates, fd->clk_rates_num, fd->clk_num);
error_get_clocks:
	msm_camera_put_regulators(pdev, &fd->vdd, fd->num_reg);
	msm_camera_put_regulators(pdev, &fd->vdd_info, fd->num_reg);
error_get_regulator:
	msm_fd_hw_release_mem_resources(fd);
error_mem_resources:
@@ -1323,7 +1323,7 @@ static int fd_device_remove(struct platform_device *pdev)
	msm_camera_unregister_bus_client(CAM_BUS_CLIENT_FD);
	msm_camera_put_clk_info_and_rates(pdev, &fd->clk_info,
		&fd->clk, &fd->clk_rates, fd->clk_rates_num, fd->clk_num);
	msm_camera_put_regulators(pdev, &fd->vdd, fd->num_reg);
	msm_camera_put_regulators(pdev, &fd->vdd_info, fd->num_reg);
	msm_fd_hw_release_mem_resources(fd);
	kfree(fd);

+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ struct msm_fd_device {
	int irq_num;
	void __iomem *iomem_base[MSM_FD_IOMEM_LAST];
	struct msm_cam_clk_info *clk_info;
	struct regulator **vdd;
	struct msm_cam_regulator *vdd_info;
	int num_reg;
	struct resource *irq;

Loading