USB: support DWC_OTG Driver Version3.10 and used by default
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc_otg_310 / dwc_otg_attr.c
1 /* ==========================================================================
2  * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_attr.c $
3  * $Revision: #46 $
4  * $Date: 2012/12/12 $
5  * $Change: 2124654 $
6  *
7  * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
8  * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
9  * otherwise expressly agreed to in writing between Synopsys and you.
10  *
11  * The Software IS NOT an item of Licensed Software or Licensed Product under
12  * any End User Software License Agreement or Agreement for Licensed Product
13  * with Synopsys or any supplement thereto. You are permitted to use and
14  * redistribute this Software in source and binary forms, with or without
15  * modification, provided that redistributions of source code must retain this
16  * notice. You may not view, use, disclose, copy or distribute this file or
17  * any information contained herein except pursuant to this license grant from
18  * Synopsys. If you do not agree with this notice, including the disclaimer
19  * below, then you are not authorized to use the Software.
20  *
21  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31  * DAMAGE.
32  * ========================================================================== */
33
34 /** @file
35  *
36  * The diagnostic interface will provide access to the controller for
37  * bringing up the hardware and testing.  The Linux driver attributes
38  * feature will be used to provide the Linux Diagnostic
39  * Interface. These attributes are accessed through sysfs.
40  */
41
42 /** @page "Linux Module Attributes"
43  *
44  * The Linux module attributes feature is used to provide the Linux
45  * Diagnostic Interface.  These attributes are accessed through sysfs.
46  * The diagnostic interface will provide access to the controller for
47  * bringing up the hardware and testing.
48
49  The following table shows the attributes.
50  <table>
51  <tr>
52  <td><b> Name</b></td>
53  <td><b> Description</b></td>
54  <td><b> Access</b></td>
55  </tr>
56
57  <tr>
58  <td> mode </td>
59  <td> Returns the current mode: 0 for device mode, 1 for host mode</td>
60  <td> Read</td>
61  </tr>
62
63  <tr>
64  <td> hnpcapable </td>
65  <td> Gets or sets the "HNP-capable" bit in the Core USB Configuraton Register.
66  Read returns the current value.</td>
67  <td> Read/Write</td>
68  </tr>
69
70  <tr>
71  <td> srpcapable </td>
72  <td> Gets or sets the "SRP-capable" bit in the Core USB Configuraton Register.
73  Read returns the current value.</td>
74  <td> Read/Write</td>
75  </tr>
76
77  <tr>
78  <td> hsic_connect </td>
79  <td> Gets or sets the "HSIC-Connect" bit in the GLPMCFG Register.
80  Read returns the current value.</td>
81  <td> Read/Write</td>
82  </tr>
83
84  <tr>
85  <td> inv_sel_hsic </td>
86  <td> Gets or sets the "Invert Select HSIC" bit in the GLPMFG Register.
87  Read returns the current value.</td>
88  <td> Read/Write</td>
89  </tr>
90
91  <tr>
92  <td> hnp </td>
93  <td> Initiates the Host Negotiation Protocol.  Read returns the status.</td>
94  <td> Read/Write</td>
95  </tr>
96
97  <tr>
98  <td> srp </td>
99  <td> Initiates the Session Request Protocol.  Read returns the status.</td>
100  <td> Read/Write</td>
101  </tr>
102
103  <tr>
104  <td> buspower </td>
105  <td> Gets or sets the Power State of the bus (0 - Off or 1 - On)</td>
106  <td> Read/Write</td>
107  </tr>
108
109  <tr>
110  <td> bussuspend </td>
111  <td> Suspends the USB bus.</td>
112  <td> Read/Write</td>
113  </tr>
114
115  <tr>
116  <td> busconnected </td>
117  <td> Gets the connection status of the bus</td>
118  <td> Read</td>
119  </tr>
120
121  <tr>
122  <td> gotgctl </td>
123  <td> Gets or sets the Core Control Status Register.</td>
124  <td> Read/Write</td>
125  </tr>
126
127  <tr>
128  <td> gusbcfg </td>
129  <td> Gets or sets the Core USB Configuration Register</td>
130  <td> Read/Write</td>
131  </tr>
132
133  <tr>
134  <td> grxfsiz </td>
135  <td> Gets or sets the Receive FIFO Size Register</td>
136  <td> Read/Write</td>
137  </tr>
138
139  <tr>
140  <td> gnptxfsiz </td>
141  <td> Gets or sets the non-periodic Transmit Size Register</td>
142  <td> Read/Write</td>
143  </tr>
144
145  <tr>
146  <td> gpvndctl </td>
147  <td> Gets or sets the PHY Vendor Control Register</td>
148  <td> Read/Write</td>
149  </tr>
150
151  <tr>
152  <td> ggpio </td>
153  <td> Gets the value in the lower 16-bits of the General Purpose IO Register
154  or sets the upper 16 bits.</td>
155  <td> Read/Write</td>
156  </tr>
157
158  <tr>
159  <td> guid </td>
160  <td> Gets or sets the value of the User ID Register</td>
161  <td> Read/Write</td>
162  </tr>
163
164  <tr>
165  <td> gsnpsid </td>
166  <td> Gets the value of the Synopsys ID Regester</td>
167  <td> Read</td>
168  </tr>
169
170  <tr>
171  <td> devspeed </td>
172  <td> Gets or sets the device speed setting in the DCFG register</td>
173  <td> Read/Write</td>
174  </tr>
175
176  <tr>
177  <td> enumspeed </td>
178  <td> Gets the device enumeration Speed.</td>
179  <td> Read</td>
180  </tr>
181
182  <tr>
183  <td> hptxfsiz </td>
184  <td> Gets the value of the Host Periodic Transmit FIFO</td>
185  <td> Read</td>
186  </tr>
187
188  <tr>
189  <td> hprt0 </td>
190  <td> Gets or sets the value in the Host Port Control and Status Register</td>
191  <td> Read/Write</td>
192  </tr>
193
194  <tr>
195  <td> regoffset </td>
196  <td> Sets the register offset for the next Register Access</td>
197  <td> Read/Write</td>
198  </tr>
199
200  <tr>
201  <td> regvalue </td>
202  <td> Gets or sets the value of the register at the offset in the regoffset attribute.</td>
203  <td> Read/Write</td>
204  </tr>
205
206  <tr>
207  <td> remote_wakeup </td>
208  <td> On read, shows the status of Remote Wakeup. On write, initiates a remote
209  wakeup of the host. When bit 0 is 1 and Remote Wakeup is enabled, the Remote
210  Wakeup signalling bit in the Device Control Register is set for 1
211  milli-second.</td>
212  <td> Read/Write</td>
213  </tr>
214
215  <tr>
216  <td> rem_wakeup_pwrdn </td>
217  <td> On read, shows the status core - hibernated or not. On write, initiates 
218  a remote wakeup of the device from Hibernation. </td>
219  <td> Read/Write</td>
220  </tr>
221
222  <tr>
223  <td> mode_ch_tim_en </td>
224  <td> This bit is used to enable or disable the host core to wait for 200 PHY 
225  clock cycles at the end of Resume to change the opmode signal to the PHY to 00
226  after Suspend or LPM. </td>
227  <td> Read/Write</td>
228  </tr>
229  
230  <tr>
231  <td> fr_interval </td>
232  <td> On read, shows the value of HFIR Frame Interval. On write, dynamically 
233  reload HFIR register during runtime. The application can write a value to this
234  register only after the Port Enable bit of the Host Port Control and Status 
235  register (HPRT.PrtEnaPort) has been set </td>
236  <td> Read/Write</td>
237  </tr>
238  
239  <tr>
240  <td> disconnect_us </td>
241  <td> On read, shows the status of disconnect_device_us. On write, sets disconnect_us
242  which causes soft disconnect for 100us. Applicable only for device mode of operation.</td>
243  <td> Read/Write</td>
244  </tr>
245
246  <tr>
247  <td> regdump </td>
248  <td> Dumps the contents of core registers.</td>
249  <td> Read</td>
250  </tr>
251
252  <tr>
253  <td> spramdump </td>
254  <td> Dumps the contents of core registers.</td>
255  <td> Read</td>
256  </tr>
257
258  <tr>
259  <td> hcddump </td>
260  <td> Dumps the current HCD state.</td>
261  <td> Read</td>
262  </tr>
263
264  <tr>
265  <td> hcd_frrem </td>
266  <td> Shows the average value of the Frame Remaining
267  field in the Host Frame Number/Frame Remaining register when an SOF interrupt
268  occurs. This can be used to determine the average interrupt latency. Also
269  shows the average Frame Remaining value for start_transfer and the "a" and
270  "b" sample points. The "a" and "b" sample points may be used during debugging
271  bto determine how long it takes to execute a section of the HCD code.</td>
272  <td> Read</td>
273  </tr>
274
275  <tr>
276  <td> rd_reg_test </td>
277  <td> Displays the time required to read the GNPTXFSIZ register many times
278  (the output shows the number of times the register is read).
279  <td> Read</td>
280  </tr>
281
282  <tr>
283  <td> wr_reg_test </td>
284  <td> Displays the time required to write the GNPTXFSIZ register many times
285  (the output shows the number of times the register is written).
286  <td> Read</td>
287  </tr>
288
289  <tr>
290  <td> lpm_response </td>
291  <td> Gets or sets lpm_response mode. Applicable only in device mode.
292  <td> Write</td>
293  </tr>
294
295  <tr>
296  <td> sleep_status </td>
297  <td> Shows sleep status of device.
298  <td> Read</td>
299  </tr>
300  
301  <tr>
302  <td> hird_thres </td>
303  <td> Gets or sets the "HIRD_Thres[3:0]" bits in the Core LPM Configuration Register.
304  <td> Read/Write</td>
305  </tr>
306  
307  <tr>
308  <td> besl_reject </td>
309  <td> Gets or sets the "besl_reject" bit in the Device Control Register.
310  <td> Read/Write</td>
311  </tr>
312
313  </table>
314
315  Example usage:
316  To get the current mode:
317  cat /sys/devices/lm0/mode
318
319  To power down the USB:
320  echo 0 > /sys/devices/lm0/buspower
321  */
322
323 #include "dwc_otg_os_dep.h"
324 #include "common_port/dwc_os.h"
325 #include "dwc_otg_driver.h"
326 #include "dwc_otg_attr.h"
327 #include "dwc_otg_core_if.h"
328 #include "dwc_otg_pcd_if.h"
329 #include "dwc_otg_hcd_if.h"
330
331 /*
332  * MACROs for defining sysfs attribute
333  */
334
335
336 #define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_string_) \
337 static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \
338 { \
339          \
340         dwc_otg_device_t *otg_dev = _dev->platform_data;                \
341         uint32_t val; \
342         val = dwc_otg_get_##_otg_attr_name_ (otg_dev->core_if); \
343         return sprintf (buf, "%s = 0x%x\n", _string_, val); \
344 }
345 #define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_string_) \
346 static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \
347                                         const char *buf, size_t count) \
348 { \
349          \
350         dwc_otg_device_t *otg_dev = _dev->platform_data; \
351         uint32_t set = simple_strtoul(buf, NULL, 16); \
352         dwc_otg_set_##_otg_attr_name_(otg_dev->core_if, set);\
353         return count; \
354 }
355
356 /*
357  * MACROs for defining sysfs attribute for 32-bit registers
358  */
359
360 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_string_) \
361 static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \
362 { \
363          \
364         dwc_otg_device_t *otg_dev = _dev->platform_data; \
365         uint32_t val; \
366         val = dwc_otg_get_##_otg_attr_name_ (otg_dev->core_if); \
367         return sprintf (buf, "%s = 0x%08x\n", _string_, val); \
368 }
369 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_string_) \
370 static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \
371                                         const char *buf, size_t count) \
372 { \
373          \
374         dwc_otg_device_t *otg_dev = _dev->platform_data; \
375         uint32_t val = simple_strtoul(buf, NULL, 16); \
376         dwc_otg_set_##_otg_attr_name_ (otg_dev->core_if, val); \
377         return count; \
378 }
379
380 #define DWC_OTG_DEVICE_ATTR_BITFIELD_RW(_otg_attr_name_,_string_) \
381 DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_string_) \
382 DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_string_) \
383 DEVICE_ATTR(_otg_attr_name_,0644,_otg_attr_name_##_show,_otg_attr_name_##_store);
384
385 #define DWC_OTG_DEVICE_ATTR_BITFIELD_RO(_otg_attr_name_,_string_) \
386 DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_string_) \
387 DEVICE_ATTR(_otg_attr_name_,0444,_otg_attr_name_##_show,NULL);
388
389 #define DWC_OTG_DEVICE_ATTR_REG32_RW(_otg_attr_name_,_addr_,_string_) \
390 DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_string_) \
391 DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_string_) \
392 DEVICE_ATTR(_otg_attr_name_,0644,_otg_attr_name_##_show,_otg_attr_name_##_store);
393
394 #define DWC_OTG_DEVICE_ATTR_REG32_RO(_otg_attr_name_,_addr_,_string_) \
395 DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_string_) \
396 DEVICE_ATTR(_otg_attr_name_,0444,_otg_attr_name_##_show,NULL);
397
398 void dwc_set_device_platform_data(struct platform_device *pdev, void *data)
399 {
400         if(NULL == pdev || NULL == &pdev->dev)
401         DWC_ERROR("NULL Pointer in func %s \n", __func__);
402
403         pdev->dev.platform_data = data;
404 }
405
406 void *dwc_get_device_platform_data(const struct platform_device *pdev)
407 {
408         if(NULL == pdev || NULL == &pdev->dev)
409        DWC_ERROR("NULL Pointer in func %s \n", __func__);
410
411         return pdev->dev.platform_data;
412 }
413
414 /** @name Functions for Show/Store of Attributes */
415 /**@{*/
416
417 /**
418  * Show the register offset of the Register Access.
419  */
420 static ssize_t regoffset_show(struct device *_dev,
421                               struct device_attribute *attr, char *buf)
422 {
423
424         
425         dwc_otg_device_t *otg_dev = _dev->platform_data;
426
427         return snprintf(buf, sizeof("0xFFFFFFFF\n") + 1, "0x%08x\n",
428                         otg_dev->os_dep.reg_offset);
429 }
430
431 /**
432  * Set the register offset for the next Register Access         Read/Write
433  */
434 static ssize_t regoffset_store(struct device *_dev,
435                                struct device_attribute *attr,
436                                const char *buf, size_t count)
437 {
438
439         
440         dwc_otg_device_t *otg_dev = _dev->platform_data;
441         uint32_t offset = simple_strtoul(buf, NULL, 16);
442
443         if (offset < SZ_256K) {
444                 otg_dev->os_dep.reg_offset = offset;
445         } else {
446                 dev_err(_dev, "invalid offset\n");
447         }
448
449         return count;
450 }
451
452 DEVICE_ATTR(regoffset, S_IRUGO | S_IWUSR, regoffset_show, regoffset_store);
453
454 /**
455  * Show the value of the register at the offset in the reg_offset
456  * attribute.
457  */
458 static ssize_t regvalue_show(struct device *_dev,
459                              struct device_attribute *attr, char *buf)
460 {
461
462         
463         dwc_otg_device_t *otg_dev = _dev->platform_data;
464         uint32_t val;
465         volatile uint32_t *addr;
466
467         if (otg_dev->os_dep.reg_offset != 0xFFFFFFFF && 0 != otg_dev->os_dep.base) {
468                 /* Calculate the address */
469                 addr = (uint32_t *) (otg_dev->os_dep.reg_offset +
470                                      (uint8_t *) otg_dev->os_dep.base);
471                 val = DWC_READ_REG32(addr);
472                 return snprintf(buf,
473                                 sizeof("Reg@0xFFFFFFFF = 0xFFFFFFFF\n") + 1,
474                                 "Reg@0x%06x = 0x%08x\n", otg_dev->os_dep.reg_offset,
475                                 val);
476         } else {
477                 dev_err(_dev, "Invalid offset (0x%0x)\n", otg_dev->os_dep.reg_offset);
478                 return sprintf(buf, "invalid offset\n");
479         }
480 }
481
482 /**
483  * Store the value in the register at the offset in the reg_offset
484  * attribute.
485  *
486  */
487 static ssize_t regvalue_store(struct device *_dev,
488                               struct device_attribute *attr,
489                               const char *buf, size_t count)
490 {
491
492         
493         dwc_otg_device_t *otg_dev = _dev->platform_data;
494         volatile uint32_t *addr;
495         uint32_t val = simple_strtoul(buf, NULL, 16);
496         //dev_dbg(_dev, "Offset=0x%08x Val=0x%08x\n", otg_dev->reg_offset, val);
497         if (otg_dev->os_dep.reg_offset != 0xFFFFFFFF && 0 != otg_dev->os_dep.base) {
498                 /* Calculate the address */
499                 addr = (uint32_t *) (otg_dev->os_dep.reg_offset +
500                                      (uint8_t *) otg_dev->os_dep.base);
501                 DWC_WRITE_REG32(addr, val);
502         } else {
503                 dev_err(_dev, "Invalid Register Offset (0x%08x)\n",
504                         otg_dev->os_dep.reg_offset);
505         }
506         return count;
507 }
508
509 DEVICE_ATTR(regvalue, S_IRUGO | S_IWUSR, regvalue_show, regvalue_store);
510
511 /*
512  * Attributes
513  */
514 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(mode, "Mode");
515 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(hnpcapable, "HNPCapable");
516 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(srpcapable, "SRPCapable");
517 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(hsic_connect, "HSIC Connect");
518 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(inv_sel_hsic, "Invert Select HSIC");
519
520 //DWC_OTG_DEVICE_ATTR_BITFIELD_RW(buspower,&(otg_dev->core_if->core_global_regs->gotgctl),(1<<8),8,"Mode");
521 //DWC_OTG_DEVICE_ATTR_BITFIELD_RW(bussuspend,&(otg_dev->core_if->core_global_regs->gotgctl),(1<<8),8,"Mode");
522 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(busconnected, "Bus Connected");
523
524 DWC_OTG_DEVICE_ATTR_REG32_RW(gotgctl, 0, "GOTGCTL");
525 DWC_OTG_DEVICE_ATTR_REG32_RW(gusbcfg,
526                              &(otg_dev->core_if->core_global_regs->gusbcfg),
527                              "GUSBCFG");
528 DWC_OTG_DEVICE_ATTR_REG32_RW(grxfsiz,
529                              &(otg_dev->core_if->core_global_regs->grxfsiz),
530                              "GRXFSIZ");
531 DWC_OTG_DEVICE_ATTR_REG32_RW(gnptxfsiz,
532                              &(otg_dev->core_if->core_global_regs->gnptxfsiz),
533                              "GNPTXFSIZ");
534 DWC_OTG_DEVICE_ATTR_REG32_RW(gpvndctl,
535                              &(otg_dev->core_if->core_global_regs->gpvndctl),
536                              "GPVNDCTL");
537 DWC_OTG_DEVICE_ATTR_REG32_RW(ggpio,
538                              &(otg_dev->core_if->core_global_regs->ggpio),
539                              "GGPIO");
540 DWC_OTG_DEVICE_ATTR_REG32_RW(guid, &(otg_dev->core_if->core_global_regs->guid),
541                              "GUID");
542 DWC_OTG_DEVICE_ATTR_REG32_RO(gsnpsid,
543                              &(otg_dev->core_if->core_global_regs->gsnpsid),
544                              "GSNPSID");
545 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(devspeed, "Device Speed");
546 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(enumspeed, "Device Enumeration Speed");
547
548 DWC_OTG_DEVICE_ATTR_REG32_RO(hptxfsiz,
549                              &(otg_dev->core_if->core_global_regs->hptxfsiz),
550                              "HPTXFSIZ");
551 DWC_OTG_DEVICE_ATTR_REG32_RW(hprt0, otg_dev->core_if->host_if->hprt0, "HPRT0");
552
553 /**
554  * @todo Add code to initiate the HNP.
555  */
556 /**
557  * Show the HNP status bit
558  */
559 static ssize_t hnp_show(struct device *_dev,
560                         struct device_attribute *attr, char *buf)
561 {
562
563         
564         dwc_otg_device_t *otg_dev = _dev->platform_data;
565         return sprintf(buf, "HstNegScs = 0x%x\n",
566                        dwc_otg_get_hnpstatus(otg_dev->core_if));
567 }
568
569 /**
570  * Set the HNP Request bit
571  */
572 static ssize_t hnp_store(struct device *_dev,
573                          struct device_attribute *attr,
574                          const char *buf, size_t count)
575 {
576
577         
578         dwc_otg_device_t *otg_dev = _dev->platform_data;
579         uint32_t in = simple_strtoul(buf, NULL, 16);
580         dwc_otg_set_hnpreq(otg_dev->core_if, in);
581         return count;
582 }
583
584 DEVICE_ATTR(hnp, 0644, hnp_show, hnp_store);
585
586 /**
587  * @todo Add code to initiate the SRP.
588  */
589 /**
590  * Show the SRP status bit
591  */
592 static ssize_t srp_show(struct device *_dev,
593                         struct device_attribute *attr, char *buf)
594 {
595 #ifndef DWC_HOST_ONLY
596
597         
598         dwc_otg_device_t *otg_dev = _dev->platform_data;
599         return sprintf(buf, "SesReqScs = 0x%x\n",
600                        dwc_otg_get_srpstatus(otg_dev->core_if));
601 #else
602         return sprintf(buf, "Host Only Mode!\n");
603 #endif
604 }
605
606 /**
607  * Set the SRP Request bit
608  */
609 static ssize_t srp_store(struct device *_dev,
610                          struct device_attribute *attr,
611                          const char *buf, size_t count)
612 {
613 #ifndef DWC_HOST_ONLY
614
615         
616         dwc_otg_device_t *otg_dev = _dev->platform_data;
617         dwc_otg_pcd_initiate_srp(otg_dev->pcd);
618 #endif
619         return count;
620 }
621
622 DEVICE_ATTR(srp, 0644, srp_show, srp_store);
623
624 /**
625  * @todo Need to do more for power on/off?
626  */
627 /**
628  * Show the Bus Power status
629  */
630 static ssize_t buspower_show(struct device *_dev,
631                              struct device_attribute *attr, char *buf)
632 {
633
634         
635         dwc_otg_device_t *otg_dev = _dev->platform_data;
636         return sprintf(buf, "Bus Power = 0x%x\n",
637                        dwc_otg_get_prtpower(otg_dev->core_if));
638 }
639
640 /**
641  * Set the Bus Power status
642  */
643 static ssize_t buspower_store(struct device *_dev,
644                               struct device_attribute *attr,
645                               const char *buf, size_t count)
646 {
647
648         
649         dwc_otg_device_t *otg_dev = _dev->platform_data;
650         uint32_t on = simple_strtoul(buf, NULL, 16);
651         dwc_otg_set_prtpower(otg_dev->core_if, on);
652         return count;
653 }
654
655 DEVICE_ATTR(buspower, 0644, buspower_show, buspower_store);
656
657 /**
658  * @todo Need to do more for suspend?
659  */
660 /**
661  * Show the Bus Suspend status
662  */
663 static ssize_t bussuspend_show(struct device *_dev,
664                                struct device_attribute *attr, char *buf)
665 {
666
667         
668         dwc_otg_device_t *otg_dev = _dev->platform_data;
669         return sprintf(buf, "Bus Suspend = 0x%x\n",
670                        dwc_otg_get_prtsuspend(otg_dev->core_if));
671 }
672
673 /**
674  * Set the Bus Suspend status
675  */
676 static ssize_t bussuspend_store(struct device *_dev,
677                                 struct device_attribute *attr,
678                                 const char *buf, size_t count)
679 {
680
681         
682         dwc_otg_device_t *otg_dev = _dev->platform_data;
683         uint32_t in = simple_strtoul(buf, NULL, 16);
684         dwc_otg_set_prtsuspend(otg_dev->core_if, in);
685         return count;
686 }
687
688 DEVICE_ATTR(bussuspend, 0644, bussuspend_show, bussuspend_store);
689
690 /**
691  * Show the Mode Change Ready Timer status
692  */
693 static ssize_t mode_ch_tim_en_show(struct device *_dev,
694                                    struct device_attribute *attr, char *buf)
695 {
696
697         
698         dwc_otg_device_t *otg_dev = _dev->platform_data;
699         return sprintf(buf, "Mode Change Ready Timer Enable = 0x%x\n",
700                        dwc_otg_get_mode_ch_tim(otg_dev->core_if));
701 }
702
703 /**
704  * Set the Mode Change Ready Timer status
705  */
706 static ssize_t mode_ch_tim_en_store(struct device *_dev,
707                                     struct device_attribute *attr,
708                                     const char *buf, size_t count)
709 {
710
711         
712         dwc_otg_device_t *otg_dev = _dev->platform_data;
713         uint32_t in = simple_strtoul(buf, NULL, 16);
714         dwc_otg_set_mode_ch_tim(otg_dev->core_if, in);
715         return count;
716 }
717
718 DEVICE_ATTR(mode_ch_tim_en, 0644, mode_ch_tim_en_show, mode_ch_tim_en_store);
719
720 /**
721  * Show the value of HFIR Frame Interval bitfield
722  */
723 static ssize_t fr_interval_show(struct device *_dev,
724                                 struct device_attribute *attr, char *buf)
725 {
726
727         
728         dwc_otg_device_t *otg_dev = _dev->platform_data;
729         return sprintf(buf, "Frame Interval = 0x%x\n",
730                        dwc_otg_get_fr_interval(otg_dev->core_if));
731 }
732
733 /**
734  * Set the HFIR Frame Interval value
735  */
736 static ssize_t fr_interval_store(struct device *_dev,
737                                  struct device_attribute *attr,
738                                  const char *buf, size_t count)
739 {
740
741         
742         dwc_otg_device_t *otg_dev = _dev->platform_data;
743         uint32_t in = simple_strtoul(buf, NULL, 10);
744         dwc_otg_set_fr_interval(otg_dev->core_if, in);
745         return count;
746 }
747
748 DEVICE_ATTR(fr_interval, 0644, fr_interval_show, fr_interval_store);
749
750 /**
751  * Show the status of Remote Wakeup.
752  */
753 static ssize_t remote_wakeup_show(struct device *_dev,
754                                   struct device_attribute *attr, char *buf)
755 {
756 #ifndef DWC_HOST_ONLY
757
758         
759         dwc_otg_device_t *otg_dev = _dev->platform_data;
760         return sprintf(buf,
761                        "Remote Wakeup Sig = %d Enabled = %d LPM Remote Wakeup = %d\n",
762                        dwc_otg_get_remotewakesig(otg_dev->core_if),
763                        dwc_otg_pcd_get_rmwkup_enable(otg_dev->pcd),
764                        dwc_otg_get_lpm_remotewakeenabled(otg_dev->core_if));
765 #else
766         return sprintf(buf, "Host Only Mode!\n");
767 #endif /* DWC_HOST_ONLY */
768 }
769
770 /**
771  * Initiate a remote wakeup of the host.  The Device control register
772  * Remote Wakeup Signal bit is written if the PCD Remote wakeup enable
773  * flag is set.
774  *
775  */
776 static ssize_t remote_wakeup_store(struct device *_dev,
777                                    struct device_attribute *attr,
778                                    const char *buf, size_t count)
779 {
780 #ifndef DWC_HOST_ONLY
781
782         
783         dwc_otg_device_t *otg_dev = _dev->platform_data;
784         uint32_t val = simple_strtoul(buf, NULL, 16);
785
786         if (val & 1) {
787                 dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 1);
788         } else {
789                 dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 0);
790         }
791 #endif /* DWC_HOST_ONLY */
792         return count;
793 }
794
795 DEVICE_ATTR(remote_wakeup, S_IRUGO | S_IWUSR, remote_wakeup_show,
796             remote_wakeup_store);
797
798 /**
799  * Show the whether core is hibernated or not.                                  
800  */
801 static ssize_t rem_wakeup_pwrdn_show(struct device *_dev,
802                                      struct device_attribute *attr, char *buf)
803 {
804 #ifndef DWC_HOST_ONLY
805
806         
807         dwc_otg_device_t *otg_dev = _dev->platform_data;
808         if (dwc_otg_get_core_state(otg_dev->core_if)) {
809                 DWC_PRINTF("Core is in hibernation\n");
810         } else {
811                 DWC_PRINTF("Core is not in hibernation\n");
812         }
813 #endif /* DWC_HOST_ONLY */
814         return 0;
815 }
816
817 extern int dwc_otg_device_hibernation_restore(dwc_otg_core_if_t * core_if,
818                                               int rem_wakeup, int reset);
819
820 /**
821  * Initiate a remote wakeup of the device to exit from hibernation.
822  */
823 static ssize_t rem_wakeup_pwrdn_store(struct device *_dev,
824                                       struct device_attribute *attr,
825                                       const char *buf, size_t count)
826 {
827 #ifndef DWC_HOST_ONLY
828
829         
830         dwc_otg_device_t *otg_dev = _dev->platform_data;
831         dwc_otg_device_hibernation_restore(otg_dev->core_if, 1, 0);
832 #endif
833         return count;
834 }
835
836 DEVICE_ATTR(rem_wakeup_pwrdn, S_IRUGO | S_IWUSR, rem_wakeup_pwrdn_show,
837             rem_wakeup_pwrdn_store);
838
839 static ssize_t disconnect_us(struct device *_dev,
840                              struct device_attribute *attr,
841                              const char *buf, size_t count)
842 {
843
844 #ifndef DWC_HOST_ONLY
845
846         
847         dwc_otg_device_t *otg_dev = _dev->platform_data;
848         uint32_t val = simple_strtoul(buf, NULL, 16);
849         DWC_PRINTF("The Passed value is %04x\n", val);
850
851         dwc_otg_pcd_disconnect_us(otg_dev->pcd, 50);
852
853 #endif /* DWC_HOST_ONLY */
854         return count;
855 }
856
857 DEVICE_ATTR(disconnect_us, S_IWUSR, 0, disconnect_us);
858
859 /**
860  * Dump global registers and either host or device registers (depending on the
861  * current mode of the core).
862  */
863 static ssize_t regdump_show(struct device *_dev,
864                             struct device_attribute *attr, char *buf)
865 {
866
867         
868         dwc_otg_device_t *otg_dev = _dev->platform_data;
869         dwc_otg_dump_global_registers(otg_dev->core_if);
870         if (dwc_otg_is_host_mode(otg_dev->core_if)) {
871                 dwc_otg_dump_host_registers(otg_dev->core_if);
872         } else {
873                 dwc_otg_dump_dev_registers(otg_dev->core_if);
874
875         }
876         return sprintf(buf, "Register Dump\n");
877 }
878
879 DEVICE_ATTR(regdump, S_IRUGO, regdump_show, 0);
880
881 /**
882  * Dump global registers and either host or device registers (depending on the
883  * current mode of the core).
884  */
885 static ssize_t spramdump_show(struct device *_dev,
886                               struct device_attribute *attr, char *buf)
887 {
888
889         
890         dwc_otg_device_t *otg_dev = _dev->platform_data;
891         dwc_otg_dump_spram(otg_dev->core_if);
892
893         return sprintf(buf, "SPRAM Dump\n");
894 }
895
896 DEVICE_ATTR(spramdump, S_IRUGO, spramdump_show, 0);
897
898 /**
899  * Dump the current hcd state.
900  */
901 static ssize_t hcddump_show(struct device *_dev,
902                             struct device_attribute *attr, char *buf)
903 {
904 #ifndef DWC_DEVICE_ONLY
905
906         
907         dwc_otg_device_t *otg_dev = _dev->platform_data;
908         dwc_otg_hcd_dump_state(otg_dev->hcd);
909 #endif /* DWC_DEVICE_ONLY */
910         return sprintf(buf, "HCD Dump\n");
911 }
912
913 DEVICE_ATTR(hcddump, S_IRUGO, hcddump_show, 0);
914
915 /**
916  * Dump the average frame remaining at SOF. This can be used to
917  * determine average interrupt latency. Frame remaining is also shown for
918  * start transfer and two additional sample points.
919  */
920 static ssize_t hcd_frrem_show(struct device *_dev,
921                               struct device_attribute *attr, char *buf)
922 {
923 #ifndef DWC_DEVICE_ONLY
924
925         
926         dwc_otg_device_t *otg_dev = _dev->platform_data;
927         dwc_otg_hcd_dump_frrem(otg_dev->hcd);
928 #endif /* DWC_DEVICE_ONLY */
929         return sprintf(buf, "HCD Dump Frame Remaining\n");
930 }
931
932 DEVICE_ATTR(hcd_frrem, S_IRUGO, hcd_frrem_show, 0);
933
934 /**
935  * Displays the time required to read the GNPTXFSIZ register many times (the
936  * output shows the number of times the register is read).
937  */
938 #define RW_REG_COUNT 10000000
939 #define MSEC_PER_JIFFIE 1000/HZ
940 static ssize_t rd_reg_test_show(struct device *_dev,
941                                 struct device_attribute *attr, char *buf)
942 {
943
944         
945         dwc_otg_device_t *otg_dev = _dev->platform_data;
946         int i;
947         int time;
948         int start_jiffies;
949
950         printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n",
951                HZ, MSEC_PER_JIFFIE, loops_per_jiffy);
952         start_jiffies = jiffies;
953         for (i = 0; i < RW_REG_COUNT; i++) {
954                 dwc_otg_get_gnptxfsiz(otg_dev->core_if);
955         }
956         time = jiffies - start_jiffies;
957         return sprintf(buf,
958                        "Time to read GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n",
959                        RW_REG_COUNT, time * MSEC_PER_JIFFIE, time);
960 }
961
962 DEVICE_ATTR(rd_reg_test, S_IRUGO, rd_reg_test_show, 0);
963
964 /**
965  * Displays the time required to write the GNPTXFSIZ register many times (the
966  * output shows the number of times the register is written).
967  */
968 static ssize_t wr_reg_test_show(struct device *_dev,
969                                 struct device_attribute *attr, char *buf)
970 {
971
972         
973         dwc_otg_device_t *otg_dev = _dev->platform_data;
974         uint32_t reg_val;
975         int i;
976         int time;
977         int start_jiffies;
978
979         printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n",
980                HZ, MSEC_PER_JIFFIE, loops_per_jiffy);
981         reg_val = dwc_otg_get_gnptxfsiz(otg_dev->core_if);
982         start_jiffies = jiffies;
983         for (i = 0; i < RW_REG_COUNT; i++) {
984                 dwc_otg_set_gnptxfsiz(otg_dev->core_if, reg_val);
985         }
986         time = jiffies - start_jiffies;
987         return sprintf(buf,
988                        "Time to write GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n",
989                        RW_REG_COUNT, time * MSEC_PER_JIFFIE, time);
990 }
991
992 DEVICE_ATTR(wr_reg_test, S_IRUGO, wr_reg_test_show, 0);
993
994 #ifdef CONFIG_USB_DWC_OTG_LPM
995
996 /**
997 * Show the lpm_response attribute.
998 */
999 static ssize_t lpmresp_show(struct device *_dev,
1000                             struct device_attribute *attr, char *buf)
1001 {
1002
1003         
1004         dwc_otg_device_t *otg_dev = _dev->platform_data;
1005         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1006                 return sprintf(buf, "** LPM is DISABLED **\n");
1007
1008         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1009                 return sprintf(buf, "** Current mode is not device mode\n");
1010         }
1011         return sprintf(buf, "lpm_response = %d\n",
1012                        dwc_otg_get_lpmresponse(otg_dev->core_if));
1013 }
1014
1015 /**
1016 * Store the lpm_response attribute.
1017 */
1018 static ssize_t lpmresp_store(struct device *_dev,
1019                              struct device_attribute *attr,
1020                              const char *buf, size_t count)
1021 {
1022
1023         
1024         dwc_otg_device_t *otg_dev = _dev->platform_data;
1025         uint32_t val = simple_strtoul(buf, NULL, 16);
1026
1027         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if)) {
1028                 return 0;
1029         }
1030
1031         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1032                 return 0;
1033         }
1034
1035         dwc_otg_set_lpmresponse(otg_dev->core_if, val);
1036         return count;
1037 }
1038
1039 DEVICE_ATTR(lpm_response, S_IRUGO | S_IWUSR, lpmresp_show, lpmresp_store);
1040
1041 /**
1042 * Show the besl_reject attribute.
1043 */
1044 static ssize_t beslreject_show(struct device *_dev,
1045                             struct device_attribute *attr, char *buf)
1046 {
1047
1048         
1049         dwc_otg_device_t *otg_dev = _dev->platform_data;
1050         
1051         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1052                 return sprintf(buf, "** LPM is DISABLED **\n");
1053         if (!dwc_otg_get_param_besl_enable(otg_dev->core_if))
1054                 return sprintf(buf, "** EnBesl is DISABLED **\n");      
1055
1056         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1057                 return sprintf(buf, "** Current mode is not device mode\n");
1058         }
1059                         
1060         return sprintf(buf, "besl_reject = %d\n",
1061                         dwc_otg_get_beslreject(otg_dev->core_if));
1062 }
1063
1064 /**
1065 * Store the besl_reject attribute.
1066 */
1067 static ssize_t beslreject_store(struct device *_dev,
1068                              struct device_attribute *attr,
1069                              const char *buf, size_t count)
1070 {
1071
1072         
1073         dwc_otg_device_t *otg_dev = _dev->platform_data;
1074         uint32_t val = simple_strtoul(buf, NULL, 16);
1075
1076         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if)) {
1077                 return 0;
1078         }
1079         
1080         if (!dwc_otg_get_param_besl_enable(otg_dev->core_if)) {
1081                 return 0;
1082         }
1083
1084         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1085                 return 0;
1086         }
1087         
1088          dwc_otg_set_beslreject(otg_dev->core_if,val);
1089                         
1090         return count;
1091 }
1092
1093 DEVICE_ATTR(besl_reject, S_IRUGO | S_IWUSR, beslreject_show, beslreject_store);
1094
1095 /**
1096 * Show the hird_thresh attribute.
1097 */
1098 static ssize_t hirdthresh_show(struct device *_dev,
1099                             struct device_attribute *attr, char *buf)
1100 {
1101
1102         
1103         dwc_otg_device_t *otg_dev = _dev->platform_data;
1104                 
1105         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1106                 return sprintf(buf, "** LPM is DISABLED **\n");
1107         
1108         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1109                 return sprintf(buf, "** Current mode is not device mode\n");
1110         }
1111                         
1112         return sprintf(buf, "hirdthresh = 0x%x\n",
1113                         dwc_otg_get_hirdthresh(otg_dev->core_if));
1114 }
1115
1116 /**
1117 * Store the hird_thresh attribute.
1118 */
1119 static ssize_t hirdthresh_store(struct device *_dev,
1120                              struct device_attribute *attr,
1121                              const char *buf, size_t count)
1122 {
1123
1124         
1125         dwc_otg_device_t *otg_dev = _dev->platform_data;
1126
1127         uint32_t val = simple_strtoul(buf, NULL, 16);
1128
1129         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if)) {
1130                 return 0;
1131         }
1132         
1133         if (!dwc_otg_is_device_mode(otg_dev->core_if)) {
1134                 return 0;
1135         }
1136         
1137          dwc_otg_set_hirdthresh(otg_dev->core_if,val);
1138                         
1139         return count;
1140 }
1141
1142 DEVICE_ATTR(hird_thres, S_IRUGO | S_IWUSR, hirdthresh_show, hirdthresh_store);
1143
1144 /**
1145 * Show the sleep_status attribute.
1146 */
1147 static ssize_t sleepstatus_show(struct device *_dev,
1148                                 struct device_attribute *attr, char *buf)
1149 {
1150
1151         
1152         dwc_otg_device_t *otg_dev = _dev->platform_data;
1153         return sprintf(buf, "Sleep Status = %d\n",
1154                        dwc_otg_get_lpm_portsleepstatus(otg_dev->core_if));
1155 }
1156
1157 /**
1158  * Store the sleep_status attribure.
1159  */
1160 static ssize_t sleepstatus_store(struct device *_dev,
1161                                  struct device_attribute *attr,
1162                                  const char *buf, size_t count)
1163 {
1164
1165         
1166         dwc_otg_device_t *otg_dev = _dev->platform_data;
1167         dwc_otg_core_if_t *core_if = otg_dev->core_if;
1168
1169         if (dwc_otg_get_lpm_portsleepstatus(otg_dev->core_if)) {
1170                 if (dwc_otg_is_host_mode(core_if)) {
1171
1172                         DWC_PRINTF("Host initiated resume\n");
1173                         dwc_otg_set_prtresume(otg_dev->core_if, 1);
1174                 }
1175         }
1176
1177         return count;
1178 }
1179
1180 DEVICE_ATTR(sleep_status, S_IRUGO | S_IWUSR, sleepstatus_show,
1181             sleepstatus_store);
1182
1183 #endif /* CONFIG_USB_DWC_OTG_LPM_ENABLE */
1184
1185 /**@}*/
1186
1187 /**
1188  * Create the device files
1189  */
1190 void dwc_otg_attr_create(
1191
1192                                 struct platform_device *dev
1193     )
1194 {
1195         int error;
1196
1197         error = device_create_file(&dev->dev, &dev_attr_regoffset);
1198         error = device_create_file(&dev->dev, &dev_attr_regvalue);
1199         error = device_create_file(&dev->dev, &dev_attr_mode);
1200         error = device_create_file(&dev->dev, &dev_attr_hnpcapable);
1201         error = device_create_file(&dev->dev, &dev_attr_srpcapable);
1202         error = device_create_file(&dev->dev, &dev_attr_hsic_connect);
1203         error = device_create_file(&dev->dev, &dev_attr_inv_sel_hsic);
1204         error = device_create_file(&dev->dev, &dev_attr_hnp);
1205         error = device_create_file(&dev->dev, &dev_attr_srp);
1206         error = device_create_file(&dev->dev, &dev_attr_buspower);
1207         error = device_create_file(&dev->dev, &dev_attr_bussuspend);
1208         error = device_create_file(&dev->dev, &dev_attr_mode_ch_tim_en);
1209         error = device_create_file(&dev->dev, &dev_attr_fr_interval);
1210         error = device_create_file(&dev->dev, &dev_attr_busconnected);
1211         error = device_create_file(&dev->dev, &dev_attr_gotgctl);
1212         error = device_create_file(&dev->dev, &dev_attr_gusbcfg);
1213         error = device_create_file(&dev->dev, &dev_attr_grxfsiz);
1214         error = device_create_file(&dev->dev, &dev_attr_gnptxfsiz);
1215         error = device_create_file(&dev->dev, &dev_attr_gpvndctl);
1216         error = device_create_file(&dev->dev, &dev_attr_ggpio);
1217         error = device_create_file(&dev->dev, &dev_attr_guid);
1218         error = device_create_file(&dev->dev, &dev_attr_gsnpsid);
1219         error = device_create_file(&dev->dev, &dev_attr_devspeed);
1220         error = device_create_file(&dev->dev, &dev_attr_enumspeed);
1221         error = device_create_file(&dev->dev, &dev_attr_hptxfsiz);
1222         error = device_create_file(&dev->dev, &dev_attr_hprt0);
1223         error = device_create_file(&dev->dev, &dev_attr_remote_wakeup);
1224         error = device_create_file(&dev->dev, &dev_attr_rem_wakeup_pwrdn);
1225         error = device_create_file(&dev->dev, &dev_attr_disconnect_us);
1226         error = device_create_file(&dev->dev, &dev_attr_regdump);
1227         error = device_create_file(&dev->dev, &dev_attr_spramdump);
1228         error = device_create_file(&dev->dev, &dev_attr_hcddump);
1229         error = device_create_file(&dev->dev, &dev_attr_hcd_frrem);
1230         error = device_create_file(&dev->dev, &dev_attr_rd_reg_test);
1231         error = device_create_file(&dev->dev, &dev_attr_wr_reg_test);
1232 #ifdef CONFIG_USB_DWC_OTG_LPM
1233         error = device_create_file(&dev->dev, &dev_attr_lpm_response);
1234         error = device_create_file(&dev->dev, &dev_attr_sleep_status);
1235         error = device_create_file(&dev->dev, &dev_attr_besl_reject);
1236         error = device_create_file(&dev->dev, &dev_attr_hird_thres);
1237 #endif
1238 }
1239
1240 /**
1241  * Remove the device files
1242  */
1243 void dwc_otg_attr_remove(
1244
1245                                 struct platform_device *dev
1246     )
1247 {
1248         device_remove_file(&dev->dev, &dev_attr_regoffset);
1249         device_remove_file(&dev->dev, &dev_attr_regvalue);
1250         device_remove_file(&dev->dev, &dev_attr_mode);
1251         device_remove_file(&dev->dev, &dev_attr_hnpcapable);
1252         device_remove_file(&dev->dev, &dev_attr_srpcapable);
1253         device_remove_file(&dev->dev, &dev_attr_hsic_connect);
1254         device_remove_file(&dev->dev, &dev_attr_inv_sel_hsic);
1255         device_remove_file(&dev->dev, &dev_attr_hnp);
1256         device_remove_file(&dev->dev, &dev_attr_srp);
1257         device_remove_file(&dev->dev, &dev_attr_buspower);
1258         device_remove_file(&dev->dev, &dev_attr_bussuspend);
1259         device_remove_file(&dev->dev, &dev_attr_mode_ch_tim_en);
1260         device_remove_file(&dev->dev, &dev_attr_fr_interval);
1261         device_remove_file(&dev->dev, &dev_attr_busconnected);
1262         device_remove_file(&dev->dev, &dev_attr_gotgctl);
1263         device_remove_file(&dev->dev, &dev_attr_gusbcfg);
1264         device_remove_file(&dev->dev, &dev_attr_grxfsiz);
1265         device_remove_file(&dev->dev, &dev_attr_gnptxfsiz);
1266         device_remove_file(&dev->dev, &dev_attr_gpvndctl);
1267         device_remove_file(&dev->dev, &dev_attr_ggpio);
1268         device_remove_file(&dev->dev, &dev_attr_guid);
1269         device_remove_file(&dev->dev, &dev_attr_gsnpsid);
1270         device_remove_file(&dev->dev, &dev_attr_devspeed);
1271         device_remove_file(&dev->dev, &dev_attr_enumspeed);
1272         device_remove_file(&dev->dev, &dev_attr_hptxfsiz);
1273         device_remove_file(&dev->dev, &dev_attr_hprt0);
1274         device_remove_file(&dev->dev, &dev_attr_remote_wakeup);
1275         device_remove_file(&dev->dev, &dev_attr_rem_wakeup_pwrdn);
1276         device_remove_file(&dev->dev, &dev_attr_disconnect_us);
1277         device_remove_file(&dev->dev, &dev_attr_regdump);
1278         device_remove_file(&dev->dev, &dev_attr_spramdump);
1279         device_remove_file(&dev->dev, &dev_attr_hcddump);
1280         device_remove_file(&dev->dev, &dev_attr_hcd_frrem);
1281         device_remove_file(&dev->dev, &dev_attr_rd_reg_test);
1282         device_remove_file(&dev->dev, &dev_attr_wr_reg_test);
1283 #ifdef CONFIG_USB_DWC_OTG_LPM
1284         device_remove_file(&dev->dev, &dev_attr_lpm_response);
1285         device_remove_file(&dev->dev, &dev_attr_sleep_status);
1286         device_remove_file(&dev->dev, &dev_attr_besl_reject);
1287         device_remove_file(&dev->dev, &dev_attr_hird_thres);
1288 #endif
1289 }