Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  1/*
  2 * Wireless Host Controller (WHC) debug.
  3 *
  4 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
  5 *
  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.
  9 *
 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.
 14 *
 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/>.
 17 */
 18#include <linux/slab.h>
 19#include <linux/kernel.h>
 20#include <linux/debugfs.h>
 21#include <linux/seq_file.h>
 22#include <linux/export.h>
 23
 24#include "../../wusbcore/wusbhc.h"
 25
 26#include "whcd.h"
 27
 28struct whc_dbg {
 29	struct dentry *di_f;
 30	struct dentry *asl_f;
 31	struct dentry *pzl_f;
 32};
 33
 34static void qset_print(struct seq_file *s, struct whc_qset *qset)
 35{
 36	static const char *qh_type[] = {
 37		"ctrl", "isoc", "bulk", "intr", "rsvd", "rsvd", "rsvd", "lpintr", };
 38	struct whc_std *std;
 39	struct urb *urb = NULL;
 40	int i;
 41
 42	seq_printf(s, "qset %08x", (u32)qset->qset_dma);
 43	if (&qset->list_node == qset->whc->async_list.prev) {
 44		seq_printf(s, " (dummy)\n");
 45	} else {
 46		seq_printf(s, " ep%d%s-%s maxpkt: %d\n",
 47			   qset->qh.info1 & 0x0f,
 48			   (qset->qh.info1 >> 4) & 0x1 ? "in" : "out",
 49			   qh_type[(qset->qh.info1 >> 5) & 0x7],
 50			   (qset->qh.info1 >> 16) & 0xffff);
 51	}
 52	seq_printf(s, "  -> %08x\n", (u32)qset->qh.link);
 53	seq_printf(s, "  info: %08x %08x %08x\n",
 54		   qset->qh.info1, qset->qh.info2,  qset->qh.info3);
 55	seq_printf(s, "  sts: %04x errs: %d curwin: %08x\n",
 56		   qset->qh.status, qset->qh.err_count, qset->qh.cur_window);
 57	seq_printf(s, "  TD: sts: %08x opts: %08x\n",
 58		   qset->qh.overlay.qtd.status, qset->qh.overlay.qtd.options);
 59
 60	for (i = 0; i < WHCI_QSET_TD_MAX; i++) {
 61		seq_printf(s, "  %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
 62			i == qset->td_start ? 'S' : ' ',
 63			i == qset->td_end ? 'E' : ' ',
 64			i, qset->qtd[i].status, qset->qtd[i].options,
 65			(u32)qset->qtd[i].page_list_ptr);
 66	}
 67	seq_printf(s, "  ntds: %d\n", qset->ntds);
 68	list_for_each_entry(std, &qset->stds, list_node) {
 69		if (urb != std->urb) {
 70			urb = std->urb;
 71			seq_printf(s, "  urb %p transferred: %d bytes\n", urb,
 72				urb->actual_length);
 73		}
 74		if (std->qtd)
 75			seq_printf(s, "    sTD[%td]: %zu bytes @ %08x\n",
 76				std->qtd - &qset->qtd[0],
 77				std->len, std->num_pointers ?
 78				(u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
 79		else
 80			seq_printf(s, "    sTD[-]: %zd bytes @ %08x\n",
 81				std->len, std->num_pointers ?
 82				(u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
 83	}
 84}
 85
 86static int di_print(struct seq_file *s, void *p)
 87{
 88	struct whc *whc = s->private;
 89	int d;
 90
 91	for (d = 0; d < whc->n_devices; d++) {
 92		struct di_buf_entry *di = &whc->di_buf[d];
 93
 94		seq_printf(s, "DI[%d]\n", d);
 95		seq_printf(s, "  availability: %*pb\n",
 96			   UWB_NUM_MAS, (unsigned long *)di->availability_info);
 97		seq_printf(s, "  %c%c key idx: %d dev addr: %d\n",
 98			   (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ',
 99			   (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
100			   (di->addr_sec_info & WHC_DI_KEY_IDX_MASK) >> 8,
101			   (di->addr_sec_info & WHC_DI_DEV_ADDR_MASK));
102	}
103	return 0;
104}
105
106static int asl_print(struct seq_file *s, void *p)
107{
108	struct whc *whc = s->private;
109	struct whc_qset *qset;
110
111	list_for_each_entry(qset, &whc->async_list, list_node) {
112		qset_print(s, qset);
113	}
114
115	return 0;
116}
117
118static int pzl_print(struct seq_file *s, void *p)
119{
120	struct whc *whc = s->private;
121	struct whc_qset *qset;
122	int period;
123
124	for (period = 0; period < 5; period++) {
125		seq_printf(s, "Period %d\n", period);
126		list_for_each_entry(qset, &whc->periodic_list[period], list_node) {
127			qset_print(s, qset);
128		}
129	}
130	return 0;
131}
132
133static int di_open(struct inode *inode, struct file *file)
134{
135	return single_open(file, di_print, inode->i_private);
136}
137
138static int asl_open(struct inode *inode, struct file *file)
139{
140	return single_open(file, asl_print, inode->i_private);
141}
142
143static int pzl_open(struct inode *inode, struct file *file)
144{
145	return single_open(file, pzl_print, inode->i_private);
146}
147
148static const struct file_operations di_fops = {
149	.open    = di_open,
150	.read    = seq_read,
151	.llseek  = seq_lseek,
152	.release = single_release,
153	.owner   = THIS_MODULE,
154};
155
156static const struct file_operations asl_fops = {
157	.open    = asl_open,
158	.read    = seq_read,
159	.llseek  = seq_lseek,
160	.release = single_release,
161	.owner   = THIS_MODULE,
162};
163
164static const struct file_operations pzl_fops = {
165	.open    = pzl_open,
166	.read    = seq_read,
167	.llseek  = seq_lseek,
168	.release = single_release,
169	.owner   = THIS_MODULE,
170};
171
172void whc_dbg_init(struct whc *whc)
173{
174	if (whc->wusbhc.pal.debugfs_dir == NULL)
175		return;
176
177	whc->dbg = kzalloc(sizeof(struct whc_dbg), GFP_KERNEL);
178	if (whc->dbg == NULL)
179		return;
180
181	whc->dbg->di_f = debugfs_create_file("di", 0444,
182					      whc->wusbhc.pal.debugfs_dir, whc,
183					      &di_fops);
184	whc->dbg->asl_f = debugfs_create_file("asl", 0444,
185					      whc->wusbhc.pal.debugfs_dir, whc,
186					      &asl_fops);
187	whc->dbg->pzl_f = debugfs_create_file("pzl", 0444,
188					      whc->wusbhc.pal.debugfs_dir, whc,
189					      &pzl_fops);
190}
191
192void whc_dbg_clean_up(struct whc *whc)
193{
194	if (whc->dbg) {
195		debugfs_remove(whc->dbg->pzl_f);
196		debugfs_remove(whc->dbg->asl_f);
197		debugfs_remove(whc->dbg->di_f);
198		kfree(whc->dbg);
199	}
200}