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

Commit e4e543bb authored by Jigar Agrawal's avatar Jigar Agrawal Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: csiphy: Add debugfs support for csiphy



Add debugfs support for csiphy and create a new debugfs
for enable/disable csiphy irqs. Following command can be
used to enable the csiphy0 irqs:
adb shell "echo 0x1 >>
/sys/kernel/debug/camera_csiphy/csiphy0_en_irq_dump".

CRs-Fixed: 28299692
Change-Id: I769c84f0cd0bf048652cf2d186d900e470973b0a
Signed-off-by: default avatarJigar Agrawal <jigar@codeaurora.org>
parent bf2c5a30
Loading
Loading
Loading
Loading
+7 −18
Original line number Original line Diff line number Diff line
@@ -517,8 +517,6 @@ void cam_csiphy_cphy_irq_disable(struct csiphy_device *csiphy_dev)


irqreturn_t cam_csiphy_irq(int irq_num, void *data)
irqreturn_t cam_csiphy_irq(int irq_num, void *data)
{
{
	uint32_t irq;
	uint8_t i;
	struct csiphy_device *csiphy_dev =
	struct csiphy_device *csiphy_dev =
		(struct csiphy_device *)data;
		(struct csiphy_device *)data;
	struct cam_hw_soc_info *soc_info = NULL;
	struct cam_hw_soc_info *soc_info = NULL;
@@ -534,22 +532,13 @@ irqreturn_t cam_csiphy_irq(int irq_num, void *data)
	base = csiphy_dev->soc_info.reg_map[0].mem_base;
	base = csiphy_dev->soc_info.reg_map[0].mem_base;
	csiphy_reg = &csiphy_dev->ctrl_reg->csiphy_reg;
	csiphy_reg = &csiphy_dev->ctrl_reg->csiphy_reg;


	for (i = 0; i < csiphy_dev->num_irq_registers; i++) {
	if (csiphy_dev->enable_irq_dump) {
		irq = cam_io_r(base +
		cam_csiphy_status_dmp(csiphy_dev);
			csiphy_reg->mipi_csiphy_interrupt_status0_addr +
		cam_io_w_mb(0x1,
			(0x4 * i));
			base + csiphy_reg->mipi_csiphy_glbl_irq_cmd_addr);
		cam_io_w_mb(irq, base +
		cam_io_w_mb(0x0,
			csiphy_reg->mipi_csiphy_interrupt_clear0_addr +
			base + csiphy_reg->mipi_csiphy_glbl_irq_cmd_addr);
			(0x4 * i));
	}
		CAM_ERR_RATE_LIMIT(CAM_CSIPHY,
			"CSIPHY%d_IRQ_STATUS_ADDR%d = 0x%x",
			soc_info->index, i, irq);
		cam_io_w_mb(0x0, base +
			csiphy_reg->mipi_csiphy_interrupt_clear0_addr +
			(0x4 * i));
	}
	cam_io_w_mb(0x1, base + csiphy_reg->mipi_csiphy_glbl_irq_cmd_addr);
	cam_io_w_mb(0x0, base + csiphy_reg->mipi_csiphy_glbl_irq_cmd_addr);


	return IRQ_HANDLED;
	return IRQ_HANDLED;
}
}
+53 −2
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
// 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_csiphy_dev.h"
#include "cam_csiphy_dev.h"
@@ -10,6 +10,8 @@
#include <media/cam_sensor.h>
#include <media/cam_sensor.h>
#include "camera_main.h"
#include "camera_main.h"


static struct dentry *root_dentry;

static void cam_csiphy_subdev_handle_message(
static void cam_csiphy_subdev_handle_message(
		struct v4l2_subdev *sd,
		struct v4l2_subdev *sd,
		enum cam_subdev_message_type_t message_type,
		enum cam_subdev_message_type_t message_type,
@@ -29,6 +31,51 @@ static void cam_csiphy_subdev_handle_message(
	}
	}
}
}


static int cam_csiphy_debug_register(struct csiphy_device *csiphy_dev)
{
	int rc = 0;
	struct dentry *dbgfileptr = NULL;
	char debugfs_name[25];

	if (!csiphy_dev) {
		CAM_ERR(CAM_CSIPHY, "null CSIPHY dev ptr");
		return -EINVAL;
	}

	if (!root_dentry) {
		dbgfileptr = debugfs_create_dir("camera_csiphy", NULL);
		if (!dbgfileptr) {
			CAM_ERR(CAM_CSIPHY,
				"Debugfs could not create directory!");
			rc = -ENOENT;
			goto end;
		}
		/* Store parent inode for cleanup in caller */
		root_dentry = dbgfileptr;
	}

	snprintf(debugfs_name, 25, "%s%d%s", "csiphy",
		csiphy_dev->soc_info.index,
		"_en_irq_dump");
	dbgfileptr = debugfs_create_bool(debugfs_name, 0644,
		root_dentry, &csiphy_dev->enable_irq_dump);

	if (IS_ERR(dbgfileptr)) {
		if (PTR_ERR(dbgfileptr) == -ENODEV)
			CAM_WARN(CAM_CSIPHY, "DebugFS not enabled in kernel!");
		else
			rc = PTR_ERR(dbgfileptr);
	}
end:
	return rc;
}

static void cam_csiphy_debug_unregister(void)
{
	debugfs_remove_recursive(root_dentry);
	root_dentry = NULL;
}

static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
	unsigned int cmd, void *arg)
	unsigned int cmd, void *arg)
{
{
@@ -212,6 +259,7 @@ static int cam_csiphy_component_bind(struct device *dev,
	cpas_parms.userdata = new_csiphy_dev;
	cpas_parms.userdata = new_csiphy_dev;


	strlcpy(cpas_parms.identifier, "csiphy", CAM_HW_IDENTIFIER_LENGTH);
	strlcpy(cpas_parms.identifier, "csiphy", CAM_HW_IDENTIFIER_LENGTH);

	rc = cam_cpas_register_client(&cpas_parms);
	rc = cam_cpas_register_client(&cpas_parms);
	if (rc) {
	if (rc) {
		CAM_ERR(CAM_CSIPHY, "CPAS registration failed rc: %d", rc);
		CAM_ERR(CAM_CSIPHY, "CPAS registration failed rc: %d", rc);
@@ -224,9 +272,11 @@ static int cam_csiphy_component_bind(struct device *dev,


	cam_csiphy_register_baseaddress(new_csiphy_dev);
	cam_csiphy_register_baseaddress(new_csiphy_dev);



	CAM_DBG(CAM_CSIPHY, "%s component bound successfully",
	CAM_DBG(CAM_CSIPHY, "%s component bound successfully",
		pdev->name);
		pdev->name);

	cam_csiphy_debug_register(new_csiphy_dev);

	return rc;
	return rc;


csiphy_unregister_subdev:
csiphy_unregister_subdev:
@@ -246,6 +296,7 @@ static void cam_csiphy_component_unbind(struct device *dev,
	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
	struct csiphy_device *csiphy_dev = v4l2_get_subdevdata(subdev);
	struct csiphy_device *csiphy_dev = v4l2_get_subdevdata(subdev);


	cam_csiphy_debug_unregister();
	CAM_INFO(CAM_CSIPHY, "Unbind CSIPHY component");
	CAM_INFO(CAM_CSIPHY, "Unbind CSIPHY component");
	cam_cpas_unregister_client(csiphy_dev->cpas_handle);
	cam_cpas_unregister_client(csiphy_dev->cpas_handle);
	cam_csiphy_soc_release(csiphy_dev);
	cam_csiphy_soc_release(csiphy_dev);
+3 −3
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* 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.
 */
 */


#ifndef _CAM_CSIPHY_DEV_H_
#ifndef _CAM_CSIPHY_DEV_H_
@@ -64,8 +64,6 @@
#define DPHY_LANE_3    BIT(6)
#define DPHY_LANE_3    BIT(6)
#define DPHY_CLK_LN    BIT(7)
#define DPHY_CLK_LN    BIT(7)


#define ENABLE_IRQ false

enum cam_csiphy_state {
enum cam_csiphy_state {
	CAM_CSIPHY_INIT,
	CAM_CSIPHY_INIT,
	CAM_CSIPHY_ACQUIRE,
	CAM_CSIPHY_ACQUIRE,
@@ -266,6 +264,7 @@ struct cam_csiphy_param {
 * @combo_mode:                 Info regarding combo_mode is enable / disable
 * @combo_mode:                 Info regarding combo_mode is enable / disable
 * @ops:                        KMD operations
 * @ops:                        KMD operations
 * @crm_cb:                     Callback API pointers
 * @crm_cb:                     Callback API pointers
 * @enable_irq_dump:            Debugfs variable to enable hw IRQ register dump
 */
 */
struct csiphy_device {
struct csiphy_device {
	char                           device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
	char                           device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
@@ -298,6 +297,7 @@ struct csiphy_device {
	uint8_t                        cphy_dphy_combo_mode;
	uint8_t                        cphy_dphy_combo_mode;
	struct cam_req_mgr_kmd_ops     ops;
	struct cam_req_mgr_kmd_ops     ops;
	struct cam_req_mgr_crm_cb     *crm_cb;
	struct cam_req_mgr_crm_cb     *crm_cb;
	bool                           enable_irq_dump;
};
};


/**
/**
+7 −12
Original line number Original line Diff line number Diff line
@@ -111,13 +111,8 @@ int32_t cam_csiphy_status_dmp(struct csiphy_device *csiphy_dev)


	if (phy_base != NULL) {
	if (phy_base != NULL) {
		for (reg_id = 0; reg_id < size; reg_id++) {
		for (reg_id = 0; reg_id < size; reg_id++) {
			uint32_t offset;
			irq = cam_io_r(phy_base + status_reg + (0x4 * reg_id));

			cam_io_w_mb(irq, phy_base + clear_reg + (0x4 * reg_id));
			offset = status_reg + (0x4 * reg_id);
			irq = cam_io_r(phy_base +  offset);
			offset = clear_reg + (0x4 * reg_id);
			cam_io_w_mb(irq, phy_base + offset);
			cam_io_w_mb(0, phy_base + offset);


			CAM_INFO(CAM_CSIPHY,
			CAM_INFO(CAM_CSIPHY,
				"CSIPHY%d_IRQ_STATUS_ADDR%d = 0x%x",
				"CSIPHY%d_IRQ_STATUS_ADDR%d = 0x%x",
@@ -200,7 +195,7 @@ int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev, int32_t index)


	vote_level = csiphy_dev->ctrl_reg->getclockvoting(csiphy_dev, index);
	vote_level = csiphy_dev->ctrl_reg->getclockvoting(csiphy_dev, index);
	rc = cam_soc_util_enable_platform_resource(soc_info, true,
	rc = cam_soc_util_enable_platform_resource(soc_info, true,
		vote_level, ENABLE_IRQ);
		vote_level, true);
	if (rc < 0) {
	if (rc < 0) {
		CAM_ERR(CAM_CSIPHY, "failed to enable platform resources %d",
		CAM_ERR(CAM_CSIPHY, "failed to enable platform resources %d",
			rc);
			rc);