All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: <linux-media@vger.kernel.org>, Benoit Parrot <bparrot@ti.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 06/19] media: ti-vpe: cal: catch error irqs and print errors
Date: Thu, 19 Mar 2020 09:50:10 +0200	[thread overview]
Message-ID: <20200319075023.22151-7-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <20200319075023.22151-1-tomi.valkeinen@ti.com>

CAL reports various errors via IRQs, which are not handled at all by the
current driver. Add code to enable and catch those IRQs and print
errors. This will make it much easier to notice and debug issues with
sensors.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/media/platform/ti-vpe/cal.c      | 46 +++++++++++++++++++++++-
 drivers/media/platform/ti-vpe/cal_regs.h |  6 ++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 4f9dee3474ba..838215a3f230 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -684,6 +684,21 @@ static void enable_irqs(struct cal_ctx *ctx)
 {
 	u32 val;
 
+	const u32 cio_err_mask =
+		CAL_CSI2_COMPLEXIO_IRQ_LANE_ERRORS_MASK |
+		CAL_CSI2_COMPLEXIO_IRQ_FIFO_OVR_MASK |
+		CAL_CSI2_COMPLEXIO_IRQ_SHORT_PACKET_MASK |
+		CAL_CSI2_COMPLEXIO_IRQ_ECC_NO_CORRECTION_MASK;
+
+	/* Enable CIO error irqs */
+	reg_write(ctx->dev, CAL_HL_IRQENABLE_SET(1),
+		  CAL_HL_IRQ_CIO_MASK(ctx->csi2_port));
+	reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_IRQENABLE(ctx->csi2_port),
+		  cio_err_mask);
+
+	/* Always enable OCPO error */
+	reg_write(ctx->dev, CAL_HL_IRQENABLE_SET(1), CAL_HL_IRQ_OCPO_ERR_MASK);
+
 	/* Enable IRQ_WDMA_END 0/1 */
 	val = 0;
 	set_field(&val, CAL_HL_IRQ_ENABLE, CAL_HL_IRQ_MASK(ctx->csi2_port));
@@ -700,6 +715,12 @@ static void disable_irqs(struct cal_ctx *ctx)
 {
 	u32 val;
 
+	/* Disable CIO error irqs */
+	reg_write(ctx->dev, CAL_HL_IRQENABLE_CLR(1),
+		  CAL_HL_IRQ_CIO_MASK(ctx->csi2_port));
+	reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_IRQENABLE(ctx->csi2_port),
+		  0);
+
 	/* Disable IRQ_WDMA_END 0/1 */
 	val = 0;
 	set_field(&val, CAL_HL_IRQ_CLEAR, CAL_HL_IRQ_MASK(ctx->csi2_port));
@@ -1171,7 +1192,30 @@ static irqreturn_t cal_irq(int irq_cal, void *data)
 	struct cal_dev *dev = (struct cal_dev *)data;
 	struct cal_ctx *ctx;
 	struct cal_dmaqueue *dma_q;
-	u32 irqst2, irqst3;
+	u32 irqst1, irqst2, irqst3;
+
+	irqst1 = reg_read(dev, CAL_HL_IRQSTATUS(1));
+	if (irqst1) {
+		int i;
+
+		reg_write(dev, CAL_HL_IRQSTATUS(1), irqst1);
+
+		if (irqst1 & CAL_HL_IRQ_OCPO_ERR_MASK)
+			dev_err_ratelimited(&dev->pdev->dev, "OCPO ERROR\n");
+
+		for (i = 1; i <= 2; ++i) {
+			if (irqst1 & CAL_HL_IRQ_CIO_MASK(i)) {
+				u32 cio_stat = reg_read(dev,
+							CAL_CSI2_COMPLEXIO_IRQSTATUS(i));
+
+				dev_err_ratelimited(&dev->pdev->dev,
+						    "CIO%d error: %#08x\n", i, cio_stat);
+
+				reg_write(dev, CAL_CSI2_COMPLEXIO_IRQSTATUS(i),
+					  cio_stat);
+			}
+		}
+	}
 
 	/* Check which DMA just finished */
 	irqst2 = reg_read(dev, CAL_HL_IRQSTATUS(2));
diff --git a/drivers/media/platform/ti-vpe/cal_regs.h b/drivers/media/platform/ti-vpe/cal_regs.h
index 0b76d1186074..2d71f1e86e2a 100644
--- a/drivers/media/platform/ti-vpe/cal_regs.h
+++ b/drivers/media/platform/ti-vpe/cal_regs.h
@@ -158,6 +158,11 @@
 #define CAL_HL_IRQ_ENABLED				0x1
 #define CAL_HL_IRQ_PENDING				0x1
 
+#define CAL_HL_IRQ_OCPO_ERR_MASK		BIT(6)
+
+#define CAL_HL_IRQ_CIO_MASK(i)			BIT(16 + ((i)-1) * 8)
+#define CAL_HL_IRQ_VC_MASK(i)			BIT(17 + ((i)-1) * 8)
+
 #define CAL_PIX_PROC_EN_MASK			BIT(0)
 #define CAL_PIX_PROC_EXTRACT_MASK		GENMASK(4, 1)
 #define CAL_PIX_PROC_EXTRACT_B6				0x0
@@ -414,6 +419,7 @@
 #define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL3_MASK		BIT(17)
 #define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL4_MASK		BIT(18)
 #define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL5_MASK		BIT(19)
+#define CAL_CSI2_COMPLEXIO_IRQ_LANE_ERRORS_MASK		GENMASK(19, 0)
 #define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM1_MASK		BIT(20)
 #define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM2_MASK		BIT(21)
 #define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM3_MASK		BIT(22)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


  parent reply	other threads:[~2020-03-19  7:50 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19  7:50 [PATCH v2 00/19] CAL fixes and improvements Tomi Valkeinen
2020-03-19  7:50 ` [PATCH v2 01/19] media: ti-vpe: cal: fix DMA memory corruption Tomi Valkeinen
2020-03-19 21:41   ` Benoit Parrot
2020-03-19 21:46     ` Benoit Parrot
2020-03-19 22:25   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 02/19] media: ti-vpe: cal: improve enable_irqs Tomi Valkeinen
2020-03-19 22:26   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 03/19] media: ti-vpe: cal: fix use of wrong macro Tomi Valkeinen
2020-03-19 22:27   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 04/19] media: ti-vpe: cal: use runtime_resume for errata handling Tomi Valkeinen
2020-03-19 22:28   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 05/19] media: ti-vpe: cal: drop cal_runtime_get/put Tomi Valkeinen
2020-03-19 22:29   ` Benoit Parrot
2020-03-19  7:50 ` Tomi Valkeinen [this message]
2020-03-19 22:32   ` [PATCH v2 06/19] media: ti-vpe: cal: catch error irqs and print errors Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 07/19] media: ti-vpe: cal: print errors on timeouts Tomi Valkeinen
2020-03-19 22:38   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 08/19] media: ti-vpe: cal: simplify irq handling Tomi Valkeinen
2020-03-19 22:39   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 09/19] media: ti-vpe: cal: remove useless CAL_GEN_* macros Tomi Valkeinen
2020-03-19 22:40   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 10/19] media: ti-vpe: cal: remove useless IRQ defines Tomi Valkeinen
2020-03-19 22:40   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 11/19] media: ti-vpe: cal: use reg_write_field Tomi Valkeinen
2020-03-19 22:41   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 12/19] media: ti-vpe: cal: cleanup CIO power enable/disable Tomi Valkeinen
2020-03-19 22:42   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 13/19] media: ti-vpe: cal: fix dummy read to phy Tomi Valkeinen
2020-03-19 22:43   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 14/19] media: ti-vpe: cal: program number of lines properly Tomi Valkeinen
2020-03-19 22:44   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 15/19] media: ti-vpe: cal: set DMA max seg size Tomi Valkeinen
2020-03-19 22:44   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 16/19] media: ti-vpe: cal: move code to separate functions Tomi Valkeinen
2020-03-19 22:45   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 17/19] media: ti-vpe: cal: improve wait for CIO resetdone Tomi Valkeinen
2020-03-19 22:46   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 18/19] media: ti-vpe: cal: improve wait for stop-state Tomi Valkeinen
2020-03-19 22:46   ` Benoit Parrot
2020-03-19  7:50 ` [PATCH v2 19/19] media: ti-vpe: cal: fix stop state timeout Tomi Valkeinen
2020-03-19 22:53   ` Benoit Parrot
2020-03-20  9:33     ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200319075023.22151-7-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=bparrot@ti.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.