2 * Wireless Host Controller (WHC) debug.
4 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <linux/slab.h>
19 #include <linux/kernel.h>
20 #include <linux/debugfs.h>
21 #include <linux/seq_file.h>
23 #include "../../wusbcore/wusbhc.h"
33 static void qset_print(struct seq_file
*s
, struct whc_qset
*qset
)
35 static const char *qh_type
[] = {
36 "ctrl", "isoc", "bulk", "intr", "rsvd", "rsvd", "rsvd", "lpintr", };
38 struct urb
*urb
= NULL
;
41 seq_printf(s
, "qset %08x", (u32
)qset
->qset_dma
);
42 if (&qset
->list_node
== qset
->whc
->async_list
.prev
) {
43 seq_printf(s
, " (dummy)\n");
45 seq_printf(s
, " ep%d%s-%s maxpkt: %d\n",
46 qset
->qh
.info1
& 0x0f,
47 (qset
->qh
.info1
>> 4) & 0x1 ? "in" : "out",
48 qh_type
[(qset
->qh
.info1
>> 5) & 0x7],
49 (qset
->qh
.info1
>> 16) & 0xffff);
51 seq_printf(s
, " -> %08x\n", (u32
)qset
->qh
.link
);
52 seq_printf(s
, " info: %08x %08x %08x\n",
53 qset
->qh
.info1
, qset
->qh
.info2
, qset
->qh
.info3
);
54 seq_printf(s
, " sts: %04x errs: %d curwin: %08x\n",
55 qset
->qh
.status
, qset
->qh
.err_count
, qset
->qh
.cur_window
);
56 seq_printf(s
, " TD: sts: %08x opts: %08x\n",
57 qset
->qh
.overlay
.qtd
.status
, qset
->qh
.overlay
.qtd
.options
);
59 for (i
= 0; i
< WHCI_QSET_TD_MAX
; i
++) {
60 seq_printf(s
, " %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
61 i
== qset
->td_start
? 'S' : ' ',
62 i
== qset
->td_end
? 'E' : ' ',
63 i
, qset
->qtd
[i
].status
, qset
->qtd
[i
].options
,
64 (u32
)qset
->qtd
[i
].page_list_ptr
);
66 seq_printf(s
, " ntds: %d\n", qset
->ntds
);
67 list_for_each_entry(std
, &qset
->stds
, list_node
) {
68 if (urb
!= std
->urb
) {
70 seq_printf(s
, " urb %p transferred: %d bytes\n", urb
,
74 seq_printf(s
, " sTD[%td]: %zu bytes @ %08x\n",
75 std
->qtd
- &qset
->qtd
[0],
76 std
->len
, std
->num_pointers
?
77 (u32
)(std
->pl_virt
[0].buf_ptr
) : (u32
)std
->dma_addr
);
79 seq_printf(s
, " sTD[-]: %zd bytes @ %08x\n",
80 std
->len
, std
->num_pointers
?
81 (u32
)(std
->pl_virt
[0].buf_ptr
) : (u32
)std
->dma_addr
);
85 static int di_print(struct seq_file
*s
, void *p
)
87 struct whc
*whc
= s
->private;
91 for (d
= 0; d
< whc
->n_devices
; d
++) {
92 struct di_buf_entry
*di
= &whc
->di_buf
[d
];
94 bitmap_scnprintf(buf
, sizeof(buf
),
95 (unsigned long *)di
->availability_info
, UWB_NUM_MAS
);
97 seq_printf(s
, "DI[%d]\n", d
);
98 seq_printf(s
, " availability: %s\n", buf
);
99 seq_printf(s
, " %c%c key idx: %d dev addr: %d\n",
100 (di
->addr_sec_info
& WHC_DI_SECURE
) ? 'S' : ' ',
101 (di
->addr_sec_info
& WHC_DI_DISABLE
) ? 'D' : ' ',
102 (di
->addr_sec_info
& WHC_DI_KEY_IDX_MASK
) >> 8,
103 (di
->addr_sec_info
& WHC_DI_DEV_ADDR_MASK
));
108 static int asl_print(struct seq_file
*s
, void *p
)
110 struct whc
*whc
= s
->private;
111 struct whc_qset
*qset
;
113 list_for_each_entry(qset
, &whc
->async_list
, list_node
) {
120 static int pzl_print(struct seq_file
*s
, void *p
)
122 struct whc
*whc
= s
->private;
123 struct whc_qset
*qset
;
126 for (period
= 0; period
< 5; period
++) {
127 seq_printf(s
, "Period %d\n", period
);
128 list_for_each_entry(qset
, &whc
->periodic_list
[period
], list_node
) {
135 static int di_open(struct inode
*inode
, struct file
*file
)
137 return single_open(file
, di_print
, inode
->i_private
);
140 static int asl_open(struct inode
*inode
, struct file
*file
)
142 return single_open(file
, asl_print
, inode
->i_private
);
145 static int pzl_open(struct inode
*inode
, struct file
*file
)
147 return single_open(file
, pzl_print
, inode
->i_private
);
150 static const struct file_operations di_fops
= {
154 .release
= single_release
,
155 .owner
= THIS_MODULE
,
158 static const struct file_operations asl_fops
= {
162 .release
= single_release
,
163 .owner
= THIS_MODULE
,
166 static const struct file_operations pzl_fops
= {
170 .release
= single_release
,
171 .owner
= THIS_MODULE
,
174 void whc_dbg_init(struct whc
*whc
)
176 if (whc
->wusbhc
.pal
.debugfs_dir
== NULL
)
179 whc
->dbg
= kzalloc(sizeof(struct whc_dbg
), GFP_KERNEL
);
180 if (whc
->dbg
== NULL
)
183 whc
->dbg
->di_f
= debugfs_create_file("di", 0444,
184 whc
->wusbhc
.pal
.debugfs_dir
, whc
,
186 whc
->dbg
->asl_f
= debugfs_create_file("asl", 0444,
187 whc
->wusbhc
.pal
.debugfs_dir
, whc
,
189 whc
->dbg
->pzl_f
= debugfs_create_file("pzl", 0444,
190 whc
->wusbhc
.pal
.debugfs_dir
, whc
,
194 void whc_dbg_clean_up(struct whc
*whc
)
197 debugfs_remove(whc
->dbg
->pzl_f
);
198 debugfs_remove(whc
->dbg
->asl_f
);
199 debugfs_remove(whc
->dbg
->di_f
);