?? dwc_otg_attr.c
字號:
#endif hprt0_data_t val; val.d32 = dwc_read_reg32 (otg_dev->core_if->host_if->hprt0); return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);}/** * Set the Bus Suspend status */static ssize_t bussuspend_store( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif const char *buf, size_t count ) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif uint32_t in = simple_strtoul(buf, NULL, 16); uint32_t *addr = (uint32_t *)otg_dev->core_if->host_if->hprt0; hprt0_data_t mem; mem.d32 = dwc_read_reg32(addr); mem.b.prtsusp = in; dev_dbg(_dev, "Storing Address=0x%08x Data=0x%08x\n", (uint32_t)addr, mem.d32); dwc_write_reg32(addr, mem.d32); return count;}DEVICE_ATTR(bussuspend, 0644, bussuspend_show, bussuspend_store);/** * Show the status of Remote Wakeup. */static ssize_t remote_wakeup_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#ifndef DWC_HOST_ONLY#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dctl_data_t val; val.d32 = dwc_read_reg32( &otg_dev->core_if->dev_if->dev_global_regs->dctl); return sprintf( buf, "Remote Wakeup = %d Enabled = %d\n", val.b.rmtwkupsig, otg_dev->pcd->remote_wakeup_enable);#else return sprintf(buf, "Host Only Mode!\n");#endif}/** * Initiate a remote wakeup of the host. The Device control register * Remote Wakeup Signal bit is written if the PCD Remote wakeup enable * flag is set. * */static ssize_t remote_wakeup_store( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif const char *buf, size_t count ) {#ifndef DWC_HOST_ONLY#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif uint32_t val = simple_strtoul(buf, NULL, 16); if (val&1) { dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 1); } else { dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 0); }#endif return count;}DEVICE_ATTR(remote_wakeup, S_IRUGO|S_IWUSR, remote_wakeup_show, remote_wakeup_store);/** * Dump global registers and either host or device registers (depending on the * current mode of the core). */static ssize_t regdump_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dwc_otg_dump_global_registers( otg_dev->core_if); if (dwc_otg_is_host_mode(otg_dev->core_if)) { dwc_otg_dump_host_registers( otg_dev->core_if); } else { dwc_otg_dump_dev_registers( otg_dev->core_if); } return sprintf( buf, "Register Dump\n" );}DEVICE_ATTR(regdump, S_IRUGO|S_IWUSR, regdump_show, 0);/** * Dump global registers and either host or device registers (depending on the * current mode of the core). */static ssize_t spramdump_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dwc_otg_dump_spram( otg_dev->core_if); return sprintf( buf, "SPRAM Dump\n" );}DEVICE_ATTR(spramdump, S_IRUGO|S_IWUSR, spramdump_show, 0);/** * Dump global registers and either host or device registers (depending on the * current mode of the core). */static ssize_t ep0descdump_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dwc_otg_dump_ep0desc( otg_dev->core_if); return sprintf( buf, "Desc Dump\n" );}DEVICE_ATTR(ep0descdump, S_IRUGO|S_IWUSR, ep0descdump_show, 0);/** * Dump the current hcd state. */static ssize_t hcddump_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#ifndef DWC_DEVICE_ONLY#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dwc_otg_hcd_dump_state(otg_dev->hcd);#endif return sprintf( buf, "HCD Dump\n" );}DEVICE_ATTR(hcddump, S_IRUGO|S_IWUSR, hcddump_show, 0);/** * Dump the average frame remaining at SOF. This can be used to * determine average interrupt latency. Frame remaining is also shown for * start transfer and two additional sample points. */static ssize_t hcd_frrem_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#ifndef DWC_DEVICE_ONLY#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif dwc_otg_hcd_dump_frrem(otg_dev->hcd);#endif return sprintf( buf, "HCD Dump Frame Remaining\n" );}DEVICE_ATTR(hcd_frrem, S_IRUGO|S_IWUSR, hcd_frrem_show, 0);/** * Displays the time required to read the GNPTXFSIZ register many times (the * output shows the number of times the register is read). */#define RW_REG_COUNT 10000000#define MSEC_PER_JIFFIE 1000/HZ static ssize_t rd_reg_test_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif int i; int time; int start_jiffies; printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", HZ, MSEC_PER_JIFFIE, loops_per_jiffy); start_jiffies = jiffies; for (i = 0; i < RW_REG_COUNT; i++) { dwc_read_reg32(&otg_dev->core_if->core_global_regs->gnptxfsiz); } time = jiffies - start_jiffies; return sprintf( buf, "Time to read GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n", RW_REG_COUNT, time * MSEC_PER_JIFFIE, time );}DEVICE_ATTR(rd_reg_test, S_IRUGO|S_IWUSR, rd_reg_test_show, 0);/** * Displays the time required to write the GNPTXFSIZ register many times (the * output shows the number of times the register is written). */static ssize_t wr_reg_test_show( struct device *_dev,#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct device_attribute *attr,#endif char *buf) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev);#else dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);#endif uint32_t reg_val; int i; int time; int start_jiffies; printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", HZ, MSEC_PER_JIFFIE, loops_per_jiffy); reg_val = dwc_read_reg32(&otg_dev->core_if->core_global_regs->gnptxfsiz); start_jiffies = jiffies; for (i = 0; i < RW_REG_COUNT; i++) { dwc_write_reg32(&otg_dev->core_if->core_global_regs->gnptxfsiz, reg_val); } time = jiffies - start_jiffies; return sprintf( buf, "Time to write GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n", RW_REG_COUNT, time * MSEC_PER_JIFFIE, time);}DEVICE_ATTR(wr_reg_test, S_IRUGO|S_IWUSR, wr_reg_test_show, 0);/**@}*//** * Create the device files */void dwc_otg_attr_create (struct lm_device *lmdev){ device_create_file(&lmdev->dev, &dev_attr_regoffset); device_create_file(&lmdev->dev, &dev_attr_regvalue); device_create_file(&lmdev->dev, &dev_attr_mode); device_create_file(&lmdev->dev, &dev_attr_hnpcapable); device_create_file(&lmdev->dev, &dev_attr_srpcapable); device_create_file(&lmdev->dev, &dev_attr_hnp); device_create_file(&lmdev->dev, &dev_attr_srp); device_create_file(&lmdev->dev, &dev_attr_buspower); device_create_file(&lmdev->dev, &dev_attr_bussuspend); device_create_file(&lmdev->dev, &dev_attr_busconnected); device_create_file(&lmdev->dev, &dev_attr_gotgctl); device_create_file(&lmdev->dev, &dev_attr_gusbcfg); device_create_file(&lmdev->dev, &dev_attr_grxfsiz); device_create_file(&lmdev->dev, &dev_attr_gnptxfsiz); device_create_file(&lmdev->dev, &dev_attr_gpvndctl); device_create_file(&lmdev->dev, &dev_attr_ggpio); device_create_file(&lmdev->dev, &dev_attr_guid); device_create_file(&lmdev->dev, &dev_attr_gsnpsid); device_create_file(&lmdev->dev, &dev_attr_devspeed); device_create_file(&lmdev->dev, &dev_attr_enumspeed); device_create_file(&lmdev->dev, &dev_attr_hptxfsiz); device_create_file(&lmdev->dev, &dev_attr_hprt0); device_create_file(&lmdev->dev, &dev_attr_remote_wakeup); device_create_file(&lmdev->dev, &dev_attr_regdump); device_create_file(&lmdev->dev, &dev_attr_spramdump); device_create_file(&lmdev->dev, &dev_attr_ep0descdump); device_create_file(&lmdev->dev, &dev_attr_hcddump); device_create_file(&lmdev->dev, &dev_attr_hcd_frrem); device_create_file(&lmdev->dev, &dev_attr_rd_reg_test); device_create_file(&lmdev->dev, &dev_attr_wr_reg_test);}/** * Remove the device files */void dwc_otg_attr_remove (struct lm_device *lmdev){ device_remove_file(&lmdev->dev, &dev_attr_regoffset); device_remove_file(&lmdev->dev, &dev_attr_regvalue); device_remove_file(&lmdev->dev, &dev_attr_mode); device_remove_file(&lmdev->dev, &dev_attr_hnpcapable); device_remove_file(&lmdev->dev, &dev_attr_srpcapable); device_remove_file(&lmdev->dev, &dev_attr_hnp); device_remove_file(&lmdev->dev, &dev_attr_srp); device_remove_file(&lmdev->dev, &dev_attr_buspower); device_remove_file(&lmdev->dev, &dev_attr_bussuspend); device_remove_file(&lmdev->dev, &dev_attr_busconnected); device_remove_file(&lmdev->dev, &dev_attr_gotgctl); device_remove_file(&lmdev->dev, &dev_attr_gusbcfg); device_remove_file(&lmdev->dev, &dev_attr_grxfsiz); device_remove_file(&lmdev->dev, &dev_attr_gnptxfsiz); device_remove_file(&lmdev->dev, &dev_attr_gpvndctl); device_remove_file(&lmdev->dev, &dev_attr_ggpio); device_remove_file(&lmdev->dev, &dev_attr_guid); device_remove_file(&lmdev->dev, &dev_attr_gsnpsid); device_remove_file(&lmdev->dev, &dev_attr_devspeed); device_remove_file(&lmdev->dev, &dev_attr_enumspeed); device_remove_file(&lmdev->dev, &dev_attr_hptxfsiz); device_remove_file(&lmdev->dev, &dev_attr_hprt0); device_remove_file(&lmdev->dev, &dev_attr_remote_wakeup); device_remove_file(&lmdev->dev, &dev_attr_regdump); device_remove_file(&lmdev->dev, &dev_attr_spramdump); device_remove_file(&lmdev->dev, &dev_attr_ep0descdump); device_remove_file(&lmdev->dev, &dev_attr_hcddump); device_remove_file(&lmdev->dev, &dev_attr_hcd_frrem); device_remove_file(&lmdev->dev, &dev_attr_rd_reg_test); device_remove_file(&lmdev->dev, &dev_attr_wr_reg_test);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -