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

Commit 1d79547b 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 I2C flash" into camera-kernel.lnx.3.1

parents 094c2d94 1540124a
Loading
Loading
Loading
Loading
+25 −4
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 <linux/module.h>
@@ -131,6 +131,7 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,

		CAM_DBG(CAM_FLASH, "CAM_QUERY_CAP");
		flash_cap.slot_info  = fctrl->soc_info.index;
		flash_cap.flash_type = soc_private->flash_type;
		for (i = 0; i < fctrl->flash_num_sources; i++) {
			flash_cap.max_current_flash[i] =
				soc_private->flash_max_current[i];
@@ -403,6 +404,7 @@ static int32_t cam_flash_platform_probe(struct platform_device *pdev)
	int32_t rc = 0, i = 0;
	struct cam_flash_ctrl *fctrl     = NULL;
	struct device_node *of_parent    = NULL;
	struct cam_hw_soc_info *soc_info = NULL;

	CAM_DBG(CAM_FLASH, "Enter");
	if (!pdev->dev.of_node) {
@@ -458,6 +460,25 @@ static int32_t cam_flash_platform_probe(struct platform_device *pdev)
		fctrl->io_master_info.cci_client->cci_device = fctrl->cci_num;
		CAM_DBG(CAM_FLASH, "cci-index %d", fctrl->cci_num, rc);

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

		if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
			CAM_INFO(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");
			return -EINVAL;
		}

		fctrl->i2c_data.per_frame =
			kzalloc(sizeof(struct i2c_settings_array) *
			MAX_PER_FRAME_ARRAY, GFP_KERNEL);
+4 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved.
 */

#ifndef _CAM_FLASH_DEV_H_
@@ -24,6 +24,7 @@
#include "cam_subdev.h"
#include "cam_mem_mgr.h"
#include "cam_sensor_cmn_header.h"
#include "cam_sensor_util.h"
#include "cam_soc_util.h"
#include "cam_debug_util.h"
#include "cam_sensor_io.h"
@@ -130,6 +131,7 @@ struct cam_flash_frame_setting {
 * @torch_op_current    : Torch operational current
 * @torch_max_current   : Max supported current for LED in torch mode
 * @is_wled_flash       : Detection between WLED/LED flash
 * @flash_type          : Flash type
 */

struct cam_flash_private_soc {
@@ -142,6 +144,7 @@ struct cam_flash_private_soc {
	uint32_t     torch_op_current[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t     torch_max_current[CAM_FLASH_MAX_LED_TRIGGERS];
	bool         is_wled_flash;
	uint32_t     flash_type;
};

struct cam_flash_func_tbl {
+9 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, 2020, 2021 The Linux Foundation. All rights reserved.
 */

#include <linux/of.h>
#include <linux/of_gpio.h>
#include "cam_flash_soc.h"
#include "cam_res_mgr_api.h"
#include <dt-bindings/msm/msm-camera.h>

static int32_t cam_get_source_node_info(
	struct device_node *of_node,
@@ -22,6 +23,13 @@ static int32_t cam_get_source_node_info(
	soc_private->is_wled_flash =
		of_property_read_bool(of_node, "wled-flash-support");

	rc = of_property_read_u32(of_node,
			"flash-type", &soc_private->flash_type);
	if (rc) {
		CAM_ERR(CAM_FLASH, "flash-type read failed rc=%d", rc);
		soc_private->flash_type = CAM_FLASH_TYPE_PMIC;
	}

	switch_src_node = of_parse_phandle(of_node, "switch-source", 0);
	if (!switch_src_node) {
		CAM_WARN(CAM_FLASH, "switch_src_node NULL");
+3 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2019, 2021 The Linux Foundation. All rights reserved.
 */

#ifndef __UAPI_CAM_SENSOR_H__
@@ -474,6 +474,7 @@ struct cam_flash_query_curr {
 * @max_current_flash   :  max supported current for flash
 * @max_duration_flash  :  max flash turn on duration
 * @max_current_torch   :  max supported current for torch
 * @flash_type          :  Indicates about the flash type -I2C,GPIO,PMIC
 *
 */
struct cam_flash_query_cap_info {
@@ -481,6 +482,7 @@ struct cam_flash_query_cap_info {
	uint32_t    max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t    max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t    max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
	uint32_t    flash_type;
} __attribute__ ((packed));

#endif