PM: OMAP3: Removed a couple of unused variables from DVFS code
[linux-ginger.git] / drivers / usb / host / whci / debug.c
blob2273c815941fe1cf4a886c19831bc63cb871d0f9
1 /*
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/kernel.h>
19 #include <linux/debugfs.h>
20 #include <linux/seq_file.h>
22 #include "../../wusbcore/wusbhc.h"
24 #include "whcd.h"
26 struct whc_dbg {
27 struct dentry *di_f;
28 struct dentry *asl_f;
29 struct dentry *pzl_f;
32 void qset_print(struct seq_file *s, struct whc_qset *qset)
34 struct whc_std *std;
35 struct urb *urb = NULL;
36 int i;
38 seq_printf(s, "qset %08x\n", (u32)qset->qset_dma);
39 seq_printf(s, " -> %08x\n", (u32)qset->qh.link);
40 seq_printf(s, " info: %08x %08x %08x\n",
41 qset->qh.info1, qset->qh.info2, qset->qh.info3);
42 seq_printf(s, " sts: %04x errs: %d\n", qset->qh.status, qset->qh.err_count);
43 seq_printf(s, " TD: sts: %08x opts: %08x\n",
44 qset->qh.overlay.qtd.status, qset->qh.overlay.qtd.options);
46 for (i = 0; i < WHCI_QSET_TD_MAX; i++) {
47 seq_printf(s, " %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
48 i == qset->td_start ? 'S' : ' ',
49 i == qset->td_end ? 'E' : ' ',
50 i, qset->qtd[i].status, qset->qtd[i].options,
51 (u32)qset->qtd[i].page_list_ptr);
53 seq_printf(s, " ntds: %d\n", qset->ntds);
54 list_for_each_entry(std, &qset->stds, list_node) {
55 if (urb != std->urb) {
56 urb = std->urb;
57 seq_printf(s, " urb %p transferred: %d bytes\n", urb,
58 urb->actual_length);
60 if (std->qtd)
61 seq_printf(s, " sTD[%td]: %zu bytes @ %08x\n",
62 std->qtd - &qset->qtd[0],
63 std->len, std->num_pointers ?
64 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
65 else
66 seq_printf(s, " sTD[-]: %zd bytes @ %08x\n",
67 std->len, std->num_pointers ?
68 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
72 static int di_print(struct seq_file *s, void *p)
74 struct whc *whc = s->private;
75 char buf[72];
76 int d;
78 for (d = 0; d < whc->n_devices; d++) {
79 struct di_buf_entry *di = &whc->di_buf[d];
81 bitmap_scnprintf(buf, sizeof(buf),
82 (unsigned long *)di->availability_info, UWB_NUM_MAS);
84 seq_printf(s, "DI[%d]\n", d);
85 seq_printf(s, " availability: %s\n", buf);
86 seq_printf(s, " %c%c key idx: %d dev addr: %d\n",
87 (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ',
88 (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
89 (di->addr_sec_info & WHC_DI_KEY_IDX_MASK) >> 8,
90 (di->addr_sec_info & WHC_DI_DEV_ADDR_MASK));
92 return 0;
95 static int asl_print(struct seq_file *s, void *p)
97 struct whc *whc = s->private;
98 struct whc_qset *qset;
100 list_for_each_entry(qset, &whc->async_list, list_node) {
101 qset_print(s, qset);
104 return 0;
107 static int pzl_print(struct seq_file *s, void *p)
109 struct whc *whc = s->private;
110 struct whc_qset *qset;
111 int period;
113 for (period = 0; period < 5; period++) {
114 seq_printf(s, "Period %d\n", period);
115 list_for_each_entry(qset, &whc->periodic_list[period], list_node) {
116 qset_print(s, qset);
119 return 0;
122 static int di_open(struct inode *inode, struct file *file)
124 return single_open(file, di_print, inode->i_private);
127 static int asl_open(struct inode *inode, struct file *file)
129 return single_open(file, asl_print, inode->i_private);
132 static int pzl_open(struct inode *inode, struct file *file)
134 return single_open(file, pzl_print, inode->i_private);
137 static const struct file_operations di_fops = {
138 .open = di_open,
139 .read = seq_read,
140 .llseek = seq_lseek,
141 .release = single_release,
142 .owner = THIS_MODULE,
145 static const struct file_operations asl_fops = {
146 .open = asl_open,
147 .read = seq_read,
148 .llseek = seq_lseek,
149 .release = single_release,
150 .owner = THIS_MODULE,
153 static const struct file_operations pzl_fops = {
154 .open = pzl_open,
155 .read = seq_read,
156 .llseek = seq_lseek,
157 .release = single_release,
158 .owner = THIS_MODULE,
161 void whc_dbg_init(struct whc *whc)
163 if (whc->wusbhc.pal.debugfs_dir == NULL)
164 return;
166 whc->dbg = kzalloc(sizeof(struct whc_dbg), GFP_KERNEL);
167 if (whc->dbg == NULL)
168 return;
170 whc->dbg->di_f = debugfs_create_file("di", 0444,
171 whc->wusbhc.pal.debugfs_dir, whc,
172 &di_fops);
173 whc->dbg->asl_f = debugfs_create_file("asl", 0444,
174 whc->wusbhc.pal.debugfs_dir, whc,
175 &asl_fops);
176 whc->dbg->pzl_f = debugfs_create_file("pzl", 0444,
177 whc->wusbhc.pal.debugfs_dir, whc,
178 &pzl_fops);
181 void whc_dbg_clean_up(struct whc *whc)
183 if (whc->dbg) {
184 debugfs_remove(whc->dbg->pzl_f);
185 debugfs_remove(whc->dbg->asl_f);
186 debugfs_remove(whc->dbg->di_f);
187 kfree(whc->dbg);