Lines Matching +full:data +full:- +full:role

1 // SPDX-License-Identifier: GPL-2.0
13 #include <linux/usb/otg-fsm.h>
24 static int ci_device_show(struct seq_file *s, void *data) in ci_device_show() argument
26 struct ci_hdrc *ci = s->private; in ci_device_show()
27 struct usb_gadget *gadget = &ci->gadget; in ci_device_show()
29 seq_printf(s, "speed = %d\n", gadget->speed); in ci_device_show()
30 seq_printf(s, "max_speed = %d\n", gadget->max_speed); in ci_device_show()
31 seq_printf(s, "is_otg = %d\n", gadget->is_otg); in ci_device_show()
32 seq_printf(s, "is_a_peripheral = %d\n", gadget->is_a_peripheral); in ci_device_show()
33 seq_printf(s, "b_hnp_enable = %d\n", gadget->b_hnp_enable); in ci_device_show()
34 seq_printf(s, "a_hnp_support = %d\n", gadget->a_hnp_support); in ci_device_show()
35 seq_printf(s, "a_alt_hnp_support = %d\n", gadget->a_alt_hnp_support); in ci_device_show()
37 (gadget->name ? gadget->name : "")); in ci_device_show()
39 if (!ci->driver) in ci_device_show()
43 (ci->driver->function ? ci->driver->function : "")); in ci_device_show()
44 seq_printf(s, "gadget max speed = %d\n", ci->driver->max_speed); in ci_device_show()
53 static int ci_port_test_show(struct seq_file *s, void *data) in ci_port_test_show() argument
55 struct ci_hdrc *ci = s->private; in ci_port_test_show()
59 pm_runtime_get_sync(ci->dev); in ci_port_test_show()
60 spin_lock_irqsave(&ci->lock, flags); in ci_port_test_show()
62 spin_unlock_irqrestore(&ci->lock, flags); in ci_port_test_show()
63 pm_runtime_put_sync(ci->dev); in ci_port_test_show()
76 struct seq_file *s = file->private_data; in ci_port_test_write()
77 struct ci_hdrc *ci = s->private; in ci_port_test_write()
83 count = min_t(size_t, sizeof(buf) - 1, count); in ci_port_test_write()
85 return -EFAULT; in ci_port_test_write()
91 return -EINVAL; in ci_port_test_write()
94 return -EBADRQC; in ci_port_test_write()
96 pm_runtime_get_sync(ci->dev); in ci_port_test_write()
97 spin_lock_irqsave(&ci->lock, flags); in ci_port_test_write()
99 spin_unlock_irqrestore(&ci->lock, flags); in ci_port_test_write()
100 pm_runtime_put_sync(ci->dev); in ci_port_test_write()
107 return single_open(file, ci_port_test_show, inode->i_private); in ci_port_test_open()
121 static int ci_qheads_show(struct seq_file *s, void *data) in ci_qheads_show() argument
123 struct ci_hdrc *ci = s->private; in ci_qheads_show()
127 if (ci->role != CI_ROLE_GADGET) { in ci_qheads_show()
132 spin_lock_irqsave(&ci->lock, flags); in ci_qheads_show()
133 for (i = 0; i < ci->hw_ep_max/2; i++) { in ci_qheads_show()
134 struct ci_hw_ep *hweprx = &ci->ci_hw_ep[i]; in ci_qheads_show()
136 &ci->ci_hw_ep[i + ci->hw_ep_max/2]; in ci_qheads_show()
138 i, (u32)hweprx->qh.dma, (u32)hweptx->qh.dma); in ci_qheads_show()
141 *((u32 *)hweprx->qh.ptr + j), in ci_qheads_show()
142 *((u32 *)hweptx->qh.ptr + j)); in ci_qheads_show()
144 spin_unlock_irqrestore(&ci->lock, flags); in ci_qheads_show()
153 static int ci_requests_show(struct seq_file *s, void *data) in ci_requests_show() argument
155 struct ci_hdrc *ci = s->private; in ci_requests_show()
161 if (ci->role != CI_ROLE_GADGET) { in ci_requests_show()
166 spin_lock_irqsave(&ci->lock, flags); in ci_requests_show()
167 for (i = 0; i < ci->hw_ep_max; i++) in ci_requests_show()
168 list_for_each_entry(req, &ci->ci_hw_ep[i].qh.queue, queue) { in ci_requests_show()
169 list_for_each_entry_safe(node, tmpnode, &req->tds, td) { in ci_requests_show()
171 i % (ci->hw_ep_max / 2), in ci_requests_show()
172 (u32)node->dma, in ci_requests_show()
173 ((i < ci->hw_ep_max/2) ? in ci_requests_show()
178 *((u32 *)node->ptr + j)); in ci_requests_show()
181 spin_unlock_irqrestore(&ci->lock, flags); in ci_requests_show()
189 struct ci_hdrc *ci = s->private; in ci_otg_show()
195 fsm = &ci->fsm; in ci_otg_show()
197 /* ------ State ----- */ in ci_otg_show()
199 usb_otg_state_string(ci->otg.state)); in ci_otg_show()
201 /* ------ State Machine Variables ----- */ in ci_otg_show()
202 seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); in ci_otg_show()
204 seq_printf(s, "a_bus_req: %d\n", fsm->a_bus_req); in ci_otg_show()
206 seq_printf(s, "a_srp_det: %d\n", fsm->a_srp_det); in ci_otg_show()
208 seq_printf(s, "a_vbus_vld: %d\n", fsm->a_vbus_vld); in ci_otg_show()
210 seq_printf(s, "b_conn: %d\n", fsm->b_conn); in ci_otg_show()
212 seq_printf(s, "adp_change: %d\n", fsm->adp_change); in ci_otg_show()
214 seq_printf(s, "power_up: %d\n", fsm->power_up); in ci_otg_show()
216 seq_printf(s, "a_bus_resume: %d\n", fsm->a_bus_resume); in ci_otg_show()
218 seq_printf(s, "a_bus_suspend: %d\n", fsm->a_bus_suspend); in ci_otg_show()
220 seq_printf(s, "a_conn: %d\n", fsm->a_conn); in ci_otg_show()
222 seq_printf(s, "b_bus_req: %d\n", fsm->b_bus_req); in ci_otg_show()
224 seq_printf(s, "b_bus_suspend: %d\n", fsm->b_bus_suspend); in ci_otg_show()
226 seq_printf(s, "b_se0_srp: %d\n", fsm->b_se0_srp); in ci_otg_show()
228 seq_printf(s, "b_ssend_srp: %d\n", fsm->b_ssend_srp); in ci_otg_show()
230 seq_printf(s, "b_sess_vld: %d\n", fsm->b_sess_vld); in ci_otg_show()
232 seq_printf(s, "b_srp_done: %d\n", fsm->b_srp_done); in ci_otg_show()
234 seq_printf(s, "drv_vbus: %d\n", fsm->drv_vbus); in ci_otg_show()
236 seq_printf(s, "loc_conn: %d\n", fsm->loc_conn); in ci_otg_show()
238 seq_printf(s, "loc_sof: %d\n", fsm->loc_sof); in ci_otg_show()
240 seq_printf(s, "adp_prb: %d\n", fsm->adp_prb); in ci_otg_show()
242 seq_printf(s, "id: %d\n", fsm->id); in ci_otg_show()
244 seq_printf(s, "protocol: %d\n", fsm->protocol); in ci_otg_show()
250 static int ci_role_show(struct seq_file *s, void *data) in ci_role_show() argument
252 struct ci_hdrc *ci = s->private; in ci_role_show()
254 if (ci->role != CI_ROLE_END) in ci_role_show()
255 seq_printf(s, "%s\n", ci_role(ci)->name); in ci_role_show()
263 struct seq_file *s = file->private_data; in ci_role_write()
264 struct ci_hdrc *ci = s->private; in ci_role_write()
265 enum ci_role role; in ci_role_write() local
269 if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) in ci_role_write()
270 return -EFAULT; in ci_role_write()
272 for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++) in ci_role_write()
273 if (ci->roles[role] && in ci_role_write()
274 !strncmp(buf, ci->roles[role]->name, in ci_role_write()
275 strlen(ci->roles[role]->name))) in ci_role_write()
278 if (role == CI_ROLE_END || role == ci->role) in ci_role_write()
279 return -EINVAL; in ci_role_write()
281 pm_runtime_get_sync(ci->dev); in ci_role_write()
282 disable_irq(ci->irq); in ci_role_write()
284 ret = ci_role_start(ci, role); in ci_role_write()
285 enable_irq(ci->irq); in ci_role_write()
286 pm_runtime_put_sync(ci->dev); in ci_role_write()
293 return single_open(file, ci_role_show, inode->i_private); in ci_role_open()
306 struct ci_hdrc *ci = s->private; in ci_registers_show()
309 if (!ci || ci->in_lpm) in ci_registers_show()
310 return -EPERM; in ci_registers_show()
312 /* ------ Registers ----- */ in ci_registers_show()
328 if (ci->is_otg) { in ci_registers_show()
345 ci->debugfs = debugfs_create_dir(dev_name(ci->dev), usb_debug_root); in dbg_create_files()
347 debugfs_create_file("device", S_IRUGO, ci->debugfs, ci, in dbg_create_files()
349 debugfs_create_file("port_test", S_IRUGO | S_IWUSR, ci->debugfs, ci, in dbg_create_files()
351 debugfs_create_file("qheads", S_IRUGO, ci->debugfs, ci, in dbg_create_files()
353 debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci, in dbg_create_files()
357 debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci, in dbg_create_files()
361 debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci, in dbg_create_files()
363 debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci, in dbg_create_files()
373 debugfs_remove_recursive(ci->debugfs); in dbg_remove_files()