Skip to content

Commit 82852ab

Browse files
media: platform: raspberrypi: rp1_cfe: Add more debug registers
Dump ISP-FE registers FE_DEBUG_FIFO_FULLNESS and FE_DEBUG_STATUS2. The latter gives an atomic snapshot of state and frames completed. Dump a CSI-2 Host register which shows which lanes are in LP11. Dump some sticky error registers from the D-PHY and CSI-2 Host; note that they will be cleared on every read. This is harmless, since they are not used for any purpose other than debug. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
1 parent 060fea8 commit 82852ab

4 files changed

Lines changed: 50 additions & 5 deletions

File tree

drivers/media/platform/raspberrypi/rp1_cfe/csi2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ int csi2_init(struct csi2_device *csi2, struct dentry *debugfs)
574574
spin_lock_init(&csi2->errors_lock);
575575

576576
csi2->dphy.dev = csi2->v4l2_dev->dev;
577-
dphy_probe(&csi2->dphy);
577+
dphy_probe(&csi2->dphy, debugfs);
578578

579579
debugfs_create_file("csi2_regs", 0444, debugfs, csi2, &csi2_regs_fops);
580580

drivers/media/platform/raspberrypi/rp1_cfe/dphy.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define dphy_info(fmt, arg...) dev_info(dphy->dev, fmt, ##arg)
1717
#define dphy_err(fmt, arg...) dev_err(dphy->dev, fmt, ##arg)
1818

19-
/* DW dphy Host registers */
19+
/* DW CSI-2 Host registers */
2020
#define VERSION 0x000
2121
#define N_LANES 0x004
2222
#define RESETN 0x008
@@ -29,7 +29,14 @@
2929
#define PHY2_TST_CTRL0 0x058
3030
#define PHY2_TST_CTRL1 0x05c
3131

32-
/* DW dphy Host Transactions */
32+
/* DW CSI-2 Host and PHY debug registers */
33+
#define INT_ST_PHY_FATAL 0x0e0
34+
#define INT_ST_PKT_FATAL 0x0f0
35+
#define INT_ST_FRAME_FATAL 0x100
36+
#define INT_ST_PHY 0x110
37+
#define INT_ST_PKT 0x120
38+
39+
/* DW D-PHY transaction codes */
3340
#define DPHY_HS_RX_CTRL_LANE0_OFFSET 0x44
3441
#define DPHY_PLL_INPUT_DIV_OFFSET 0x17
3542
#define DPHY_PLL_LOOP_DIV_OFFSET 0x18
@@ -183,7 +190,37 @@ void dphy_stop(struct dphy_data *dphy)
183190
*/
184191
}
185192

186-
void dphy_probe(struct dphy_data *dphy)
193+
static int dphy_debug_show(struct seq_file *s, void *data)
194+
{
195+
/*
196+
* Here we expose various error flags in the CSI-2 Host and PHY.
197+
* All these registers apart from PHY_STOPSTATE are read-to-clear.
198+
* The only reliable way to count errors would be to service a
199+
* dedicated interrupt. For now, we'll just read (and clear) them.
200+
*/
201+
struct dphy_data *dphy = s->private;
202+
int ret;
203+
204+
ret = pm_runtime_resume_and_get(dphy->dev);
205+
if (ret)
206+
return ret;
207+
208+
#define DUMP(reg) seq_printf(s, #reg " \t0x%08x\n", dw_csi2_host_read(dphy, reg))
209+
DUMP(PHY_STOPSTATE); /* Data lane (bits 0-3) or clock (bit 16) is in stopstate */
210+
DUMP(INT_ST_PHY_FATAL); /* HS start sync error for each data lane (bits 0-3) */
211+
DUMP(INT_ST_PKT_FATAL); /* CRC error on VC (bits 0-3); ECC unrecoverable error (bit 16) */
212+
DUMP(INT_ST_FRAME_FATAL); /* FS/FE mismatch (bits 0-3), seq (8-11), CRC error (16-19) */
213+
DUMP(INT_ST_PHY); /* Non-fatal error for each data lane HS (bits 0-3), LP (16-19) */
214+
DUMP(INT_ST_PKT); /* Unknown DT on VC (bits 0-3); ECC corrected error (b16-19) */
215+
#undef DUMP
216+
217+
pm_runtime_put(dphy->dev);
218+
return 0;
219+
}
220+
221+
DEFINE_SHOW_ATTRIBUTE(dphy_debug);
222+
223+
void dphy_probe(struct dphy_data *dphy, struct dentry *debugfs)
187224
{
188225
u32 host_ver;
189226
u8 host_ver_major, host_ver_minor;
@@ -195,4 +232,7 @@ void dphy_probe(struct dphy_data *dphy)
195232
host_ver_minor += (u8)((host_ver >> 8) - '0');
196233

197234
dphy_info("DW dphy Host HW v%u.%u\n", host_ver_major, host_ver_minor);
235+
236+
if (debugfs)
237+
debugfs_create_file("dphy_debug", 0444, debugfs, dphy, &dphy_debug_fops);
198238
}

drivers/media/platform/raspberrypi/rp1_cfe/dphy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _RP1_DPHY_
88
#define _RP1_DPHY_
99

10+
#include <linux/debugfs.h>
1011
#include <linux/io.h>
1112
#include <linux/types.h>
1213
#include <media/v4l2-mediabus.h>
@@ -22,7 +23,7 @@ struct dphy_data {
2223
bool lane_polarities[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES];
2324
};
2425

25-
void dphy_probe(struct dphy_data *dphy);
26+
void dphy_probe(struct dphy_data *dphy, struct dentry *debugfs);
2627
void dphy_start(struct dphy_data *dphy);
2728
void dphy_stop(struct dphy_data *dphy);
2829

drivers/media/platform/raspberrypi/rp1_cfe/pisp_fe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#define FE_OUTPUT_STATUS 0x014
2525
#define FE_INT_EN 0x018
2626
#define FE_INT_STATUS 0x01c
27+
#define FE_DEBUG_FIFO_FULLNESS 0x024
28+
#define FE_DEBUG_STATUS2 0x02c
2729

2830
/* CONTROL */
2931
#define FE_CONTROL_QUEUE BIT(0)
@@ -162,6 +164,8 @@ static int pisp_regs_show(struct seq_file *s, void *data)
162164
DUMP(FE_OUTPUT_STATUS);
163165
DUMP(FE_INT_EN);
164166
DUMP(FE_INT_STATUS);
167+
DUMP(FE_DEBUG_FIFO_FULLNESS);
168+
DUMP(FE_DEBUG_STATUS2);
165169
#undef DUMP
166170

167171
pm_runtime_put(fe->v4l2_dev->dev);

0 commit comments

Comments
 (0)