On Mon, Jan 20, 2014 at 09:56:20AM +0800, Li Jun wrote: > This patch add a debug file for OTG vairables show and registers dump.
%s/add/adds > > Signed-off-by: Li Jun <b47...@freescale.com> > --- > drivers/usb/chipidea/debug.c | 102 > ++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 102 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c > index 96d899a..1001a47 100644 > --- a/drivers/usb/chipidea/debug.c > +++ b/drivers/usb/chipidea/debug.c > @@ -7,6 +7,9 @@ > #include <linux/uaccess.h> > #include <linux/usb/ch9.h> > #include <linux/usb/gadget.h> > +#include <linux/usb/phy.h> > +#include <linux/usb/otg.h> > +#include <linux/usb/otg-fsm.h> > > #include "ci.h" > #include "udc.h" > @@ -204,6 +207,98 @@ static const struct file_operations ci_requests_fops = { > .release = single_release, > }; > > +int ci_otg_show(struct seq_file *s, void *unused) > +{ > + struct ci_hdrc *ci = s->private; > + struct otg_fsm *fsm; > + u32 tmp_reg; > + > + if (!ci || !ci->is_otg || !ci->fsm) > + return 0; > + > + fsm = ci->fsm; > + > + /* ------ Registers ----- */ > + tmp_reg = hw_read(ci, OP_OTGSC, ~0); > + seq_printf(s, "OTGSC reg: %08x\n", tmp_reg); > + > + tmp_reg = hw_read(ci, OP_PORTSC, ~0); > + seq_printf(s, "PORTSC reg: %08x\n", tmp_reg); > + > + tmp_reg = hw_read(ci, OP_USBMODE, ~0); > + seq_printf(s, "USBMODE reg: %08x\n", tmp_reg); > + > + tmp_reg = hw_read(ci, OP_USBCMD, ~0); > + seq_printf(s, "USBCMD reg: %08x\n", tmp_reg); > + > + tmp_reg = hw_read(ci, OP_USBSTS, ~0); > + seq_printf(s, "USBSTS reg: %08x\n", tmp_reg); > + > + /* ------ State ----- */ > + seq_printf(s, > + "OTG state: %s\n\n", > + usb_otg_state_string(ci->transceiver->state)); > + > + /* ------ State Machine Variables ----- */ > + seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); > + > + seq_printf(s, "a_bus_req: %d\n", fsm->a_bus_req); > + > + seq_printf(s, "a_srp_det: %d\n", fsm->a_srp_det); > + > + seq_printf(s, "a_vbus_vld: %d\n", fsm->a_vbus_vld); > + > + seq_printf(s, "b_conn: %d\n", fsm->b_conn); > + > + seq_printf(s, "adp_change: %d\n", fsm->adp_change); > + > + seq_printf(s, "power_up: %d\n", fsm->power_up); > + > + seq_printf(s, "a_bus_resume: %d\n", fsm->a_bus_resume); > + > + seq_printf(s, "a_bus_suspend: %d\n", fsm->a_bus_suspend); > + > + seq_printf(s, "a_conn: %d\n", fsm->a_conn); > + > + seq_printf(s, "b_bus_req: %d\n", fsm->b_bus_req); > + > + seq_printf(s, "b_bus_suspend: %d\n", fsm->b_bus_suspend); > + > + seq_printf(s, "b_se0_srp: %d\n", fsm->b_se0_srp); > + > + seq_printf(s, "b_ssend_srp: %d\n", fsm->b_ssend_srp); > + > + seq_printf(s, "b_sess_vld: %d\n", fsm->b_sess_vld); > + > + seq_printf(s, "b_srp_done: %d\n", fsm->b_srp_done); > + > + seq_printf(s, "drv_vbus: %d\n", fsm->drv_vbus); > + > + seq_printf(s, "loc_conn: %d\n", fsm->loc_conn); > + > + seq_printf(s, "loc_sof: %d\n", fsm->loc_sof); > + > + seq_printf(s, "adp_prb: %d\n", fsm->adp_prb); > + > + seq_printf(s, "id: %d\n", fsm->id); > + > + seq_printf(s, "protocol: %d\n", fsm->protocol); > + > + return 0; > +} > + I wonder if you can create separate entry for register dump, and including all necessary registers in it. In that way, the other chipidea users can be benefit of it. Peter > +static int ci_otg_open(struct inode *inode, struct file *file) > +{ > + return single_open(file, ci_otg_show, inode->i_private); > +} > + > +static const struct file_operations ci_otg_fops = { > + .open = ci_otg_open, > + .read = seq_read, > + .llseek = seq_lseek, > + .release = single_release, > +}; > + > static int ci_role_show(struct seq_file *s, void *data) > { > struct ci_hdrc *ci = s->private; > @@ -287,6 +382,13 @@ int dbg_create_files(struct ci_hdrc *ci) > if (!dent) > goto err; > > + if (ci->is_otg) { > + dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci, > + &ci_otg_fops); > + if (!dent) > + goto err; > + } > + > dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci, > &ci_role_fops); > if (dent) > -- > 1.7.8 > > -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html