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

Commit 47cb7dc0 authored by Tony Lijo Jose's avatar Tony Lijo Jose
Browse files

msm: camera: sensor: Read gpios property from dt node



Currently cam-res-mgr uses the virtual gpio number (A global gpio number
among all the gpio modules) in case of shared gpio. We cannot know this
upfront as the mapping varies between targets. This change allows to use
the shared gpios using gpios property, where we can mention the gpio module
and the gpio number used.

CRs-Fixed: 2994159
Change-Id: Ic60eeace89e5223eaeee5a7709bb3beee4127bb0
Signed-off-by: default avatarTony Lijo Jose <tjose@codeaurora.org>
parent ad4b86bd
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/init.h>
@@ -9,6 +9,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include "cam_debug_util.h"
#include "cam_res_mgr_api.h"
#include "cam_res_mgr_private.h"
@@ -604,15 +605,13 @@ EXPORT_SYMBOL(cam_res_mgr_shared_clk_config);

static int cam_res_mgr_parse_dt(struct device *dev)
{
	int rc = 0;
	int rc = 0, i = 0;
	struct device_node *of_node = NULL;
	struct cam_res_mgr_dt *dt = &cam_res->dt;

	of_node = dev->of_node;

	dt->num_shared_gpio = of_property_count_u32_elems(of_node,
		"shared-gpios");

	dt->num_shared_gpio = of_gpio_count(of_node);
	if (dt->num_shared_gpio > MAX_SHARED_GPIO_SIZE ||
		dt->num_shared_gpio <= 0) {
		/*
@@ -624,12 +623,15 @@ static int cam_res_mgr_parse_dt(struct device *dev)
		return -EINVAL;
	}

	rc = of_property_read_u32_array(of_node, "shared-gpios",
		dt->shared_gpio, dt->num_shared_gpio);
	if (rc) {
	for (i = 0; i < dt->num_shared_gpio; i++) {
		dt->shared_gpio[i] = of_get_gpio(of_node, i);
		if (dt->shared_gpio[i] < 0) {
			CAM_ERR(CAM_RES, "Get shared gpio array failed.");
			return -EINVAL;
		}
		CAM_DBG(CAM_UTIL, "shared_gpio[%d] = %d",
				i, dt->shared_gpio[i]);
	}

	dt->pinctrl_info.pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR_OR_NULL(dt->pinctrl_info.pinctrl)) {