1 /* SPDX-License-Identifier: ISC */
2 
3 #include "mt7603.h"
4 
5 static int
6 mt7603_reset_read(struct seq_file *s, void *data)
7 {
8 	struct mt7603_dev *dev = dev_get_drvdata(s->private);
9 	static const char * const reset_cause_str[] = {
10 		[RESET_CAUSE_TX_HANG] = "TX hang",
11 		[RESET_CAUSE_TX_BUSY] = "TX DMA busy stuck",
12 		[RESET_CAUSE_RX_BUSY] = "RX DMA busy stuck",
13 		[RESET_CAUSE_RX_PSE_BUSY] = "RX PSE busy stuck",
14 		[RESET_CAUSE_BEACON_STUCK] = "Beacon stuck",
15 		[RESET_CAUSE_MCU_HANG] = "MCU hang",
16 		[RESET_CAUSE_RESET_FAILED] = "PSE reset failed",
17 	};
18 	int i;
19 
20 	for (i = 0; i < ARRAY_SIZE(reset_cause_str); i++) {
21 		if (!reset_cause_str[i])
22 			continue;
23 
24 		seq_printf(s, "%20s: %u\n", reset_cause_str[i],
25 			   dev->reset_cause[i]);
26 	}
27 
28 	return 0;
29 }
30 
31 static int
32 mt7603_radio_read(struct seq_file *s, void *data)
33 {
34 	struct mt7603_dev *dev = dev_get_drvdata(s->private);
35 
36 	seq_printf(s, "Sensitivity: %d\n", dev->sensitivity);
37 	seq_printf(s, "False CCA: ofdm=%d cck=%d\n",
38 		   dev->false_cca_ofdm, dev->false_cca_cck);
39 
40 	return 0;
41 }
42 
43 void mt7603_init_debugfs(struct mt7603_dev *dev)
44 {
45 	struct dentry *dir;
46 
47 	dir = mt76_register_debugfs(&dev->mt76);
48 	if (!dir)
49 		return;
50 
51 	debugfs_create_u32("reset_test", 0600, dir, &dev->reset_test);
52 	debugfs_create_devm_seqfile(dev->mt76.dev, "reset", dir,
53 				    mt7603_reset_read);
54 	debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,
55 				    mt7603_radio_read);
56 }
57