USB: fix Coding Style.
[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 #define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_, _string_) \
336 static ssize_t _otg_attr_name_##_show(struct device *_dev, struct device_attribute *attr, char *buf) \
337 { \
338          \
339         dwc_otg_device_t *otg_dev = _dev->platform_data;                \
340         uint32_t val; \
341         val = dwc_otg_get_##_otg_attr_name_(otg_dev->core_if); \
342         return sprintf(buf, "%s = 0x%x\n", _string_, val); \
343 }
344 #define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_, _string_) \
345 static ssize_t _otg_attr_name_##_store(struct device *_dev, struct device_attribute *attr, \
346                                         const char *buf, size_t count) \
347 { \
348          \
349         dwc_otg_device_t *otg_dev = _dev->platform_data; \
350         uint32_t set = simple_strtoul(buf, NULL, 16); \
351         dwc_otg_set_##_otg_attr_name_(otg_dev->core_if, set);\
352         return count; \
353 }
354
355 /*
356  * MACROs for defining sysfs attribute for 32-bit registers
357  */
358
359 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_, _string_) \
360 static ssize_t _otg_attr_name_##_show(struct device *_dev, struct device_attribute *attr, char *buf) \
361 { \
362          \
363         dwc_otg_device_t *otg_dev = _dev->platform_data; \
364         uint32_t val; \
365         val = dwc_otg_get_##_otg_attr_name_(otg_dev->core_if); \
366         return sprintf(buf, "%s = 0x%08x\n", _string_, val); \
367 }
368 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_, _string_) \
369 static ssize_t _otg_attr_name_##_store(struct device *_dev, struct device_attribute *attr, \
370                                         const char *buf, size_t count) \
371 { \
372          \
373         dwc_otg_device_t *otg_dev = _dev->platform_data; \
374         uint32_t val = simple_strtoul(buf, NULL, 16); \
375         dwc_otg_set_##_otg_attr_name_(otg_dev->core_if, val); \
376         return count; \
377 }
378
379 #define DWC_OTG_DEVICE_ATTR_BITFIELD_RW(_otg_attr_name_, _string_) \
380 DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_, _string_) \
381 DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_, _string_) \
382 DEVICE_ATTR(_otg_attr_name_, 0644, _otg_attr_name_##_show, \
383             _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, \
393             _otg_attr_name_##_store);
394
395 #define DWC_OTG_DEVICE_ATTR_REG32_RO(_otg_attr_name_, _addr_, _string_) \
396 DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_, _string_) \
397 DEVICE_ATTR(_otg_attr_name_, 0444, _otg_attr_name_##_show, NULL);
398
399 void dwc_set_device_platform_data(struct platform_device *pdev, void *data)
400 {
401         if (NULL == pdev || NULL == &pdev->dev)
402                 DWC_ERROR("NULL Pointer in func %s \n", __func__);
403
404         pdev->dev.platform_data = data;
405 }
406
407 void *dwc_get_device_platform_data(const struct platform_device *pdev)
408 {
409         if (NULL == pdev || NULL == &pdev->dev)
410                 DWC_ERROR("NULL Pointer in func %s \n", __func__);
411
412         return pdev->dev.platform_data;
413 }
414
415 /** @name Functions for Show/Store of Attributes */
416 /**@{*/
417
418 /**
419  * Show the register offset of the Register Access.
420  */
421 static ssize_t regoffset_show(struct device *_dev,
422                               struct device_attribute *attr, char *buf)
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         dwc_otg_device_t *otg_dev = _dev->platform_data;
440         uint32_t offset = simple_strtoul(buf, NULL, 16);
441
442         if (offset < SZ_256K)
443                 otg_dev->os_dep.reg_offset = offset;
444         else
445                 dev_err(_dev, "invalid offset\n");
446
447         return count;
448 }
449
450 DEVICE_ATTR(regoffset, S_IRUGO | S_IWUSR, regoffset_show, regoffset_store);
451
452 /**
453  * Show the value of the register at the offset in the reg_offset
454  * attribute.
455  */
456 static ssize_t regvalue_show(struct device *_dev,
457                              struct device_attribute *attr, char *buf)
458 {
459
460         dwc_otg_device_t *otg_dev = _dev->platform_data;
461         uint32_t val;
462         volatile uint32_t *addr;
463
464         if (otg_dev->os_dep.reg_offset != 0xFFFFFFFF
465             && 0 != otg_dev->os_dep.base) {
466                 /* Calculate the address */
467                 addr = (uint32_t *) (otg_dev->os_dep.reg_offset +
468                                      (uint8_t *) otg_dev->os_dep.base);
469                 val = DWC_READ_REG32(addr);
470                 return snprintf(buf,
471                                 sizeof("Reg@0xFFFFFFFF = 0xFFFFFFFF\n") + 1,
472                                 "Reg@0x%06x = 0x%08x\n",
473                                 otg_dev->os_dep.reg_offset, val);
474         } else {
475                 dev_err(_dev, "Invalid offset (0x%0x)\n",
476                         otg_dev->os_dep.reg_offset);
477                 return sprintf(buf, "invalid offset\n");
478         }
479 }
480
481 /**
482  * Store the value in the register at the offset in the reg_offset
483  * attribute.
484  *
485  */
486 static ssize_t regvalue_store(struct device *_dev,
487                               struct device_attribute *attr,
488                               const char *buf, size_t count)
489 {
490
491         dwc_otg_device_t *otg_dev = _dev->platform_data;
492         volatile uint32_t *addr;
493         uint32_t val = simple_strtoul(buf, NULL, 16);
494         /* dev_dbg(_dev, "Offset=0x%08x Val=0x%08x\n",
495          * otg_dev->reg_offset, val);
496          */
497         if (otg_dev->os_dep.reg_offset != 0xFFFFFFFF
498             && 0 != otg_dev->os_dep.base) {
499                 /* Calculate the address */
500                 addr = (uint32_t *) (otg_dev->os_dep.reg_offset +
501                                      (uint8_t *) otg_dev->os_dep.base);
502                 DWC_WRITE_REG32(addr, val);
503         } else {
504                 dev_err(_dev, "Invalid Register Offset (0x%08x)\n",
505                         otg_dev->os_dep.reg_offset);
506         }
507         return count;
508 }
509
510 DEVICE_ATTR(regvalue, S_IRUGO | S_IWUSR, regvalue_show, regvalue_store);
511
512 /*
513  * Attributes
514  */
515 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(mode, "Mode");
516 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(hnpcapable, "HNPCapable");
517 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(srpcapable, "SRPCapable");
518 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(hsic_connect, "HSIC Connect");
519 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(inv_sel_hsic, "Invert Select HSIC");
520
521 /* DWC_OTG_DEVICE_ATTR_BITFIELD_RW(buspower,
522  * &(otg_dev->core_if->core_global_regs->gotgctl), (1<<8), 8, "Mode");
523  */
524 /* DWC_OTG_DEVICE_ATTR_BITFIELD_RW(bussuspend,
525  * &(otg_dev->core_if->core_global_regs->gotgctl), (1<<8), 8, "Mode");
526  */
527 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(busconnected, "Bus Connected");
528
529 DWC_OTG_DEVICE_ATTR_REG32_RW(gotgctl, 0, "GOTGCTL");
530 DWC_OTG_DEVICE_ATTR_REG32_RW(gusbcfg,
531                              &(otg_dev->core_if->core_global_regs->gusbcfg),
532                              "GUSBCFG");
533 DWC_OTG_DEVICE_ATTR_REG32_RW(grxfsiz,
534                              &(otg_dev->core_if->core_global_regs->grxfsiz),
535                              "GRXFSIZ");
536 DWC_OTG_DEVICE_ATTR_REG32_RW(gnptxfsiz,
537                              &(otg_dev->core_if->core_global_regs->gnptxfsiz),
538                              "GNPTXFSIZ");
539 DWC_OTG_DEVICE_ATTR_REG32_RW(gpvndctl,
540                              &(otg_dev->core_if->core_global_regs->gpvndctl),
541                              "GPVNDCTL");
542 DWC_OTG_DEVICE_ATTR_REG32_RW(ggpio,
543                              &(otg_dev->core_if->core_global_regs->ggpio),
544                              "GGPIO");
545 DWC_OTG_DEVICE_ATTR_REG32_RW(guid, &(otg_dev->core_if->core_global_regs->guid),
546                              "GUID");
547 DWC_OTG_DEVICE_ATTR_REG32_RO(gsnpsid,
548                              &(otg_dev->core_if->core_global_regs->gsnpsid),
549                              "GSNPSID");
550 DWC_OTG_DEVICE_ATTR_BITFIELD_RW(devspeed, "Device Speed");
551 DWC_OTG_DEVICE_ATTR_BITFIELD_RO(enumspeed, "Device Enumeration Speed");
552
553 DWC_OTG_DEVICE_ATTR_REG32_RO(hptxfsiz,
554                              &(otg_dev->core_if->core_global_regs->hptxfsiz),
555                              "HPTXFSIZ");
556 DWC_OTG_DEVICE_ATTR_REG32_RW(hprt0, otg_dev->core_if->host_if->hprt0, "HPRT0");
557
558 /**
559  * @todo Add code to initiate the HNP.
560  */
561 /**
562  * Show the HNP status bit
563  */
564 static ssize_t hnp_show(struct device *_dev,
565                         struct device_attribute *attr, char *buf)
566 {
567
568         dwc_otg_device_t *otg_dev = _dev->platform_data;
569         return sprintf(buf, "HstNegScs = 0x%x\n",
570                        dwc_otg_get_hnpstatus(otg_dev->core_if));
571 }
572
573 /**
574  * Set the HNP Request bit
575  */
576 static ssize_t hnp_store(struct device *_dev,
577                          struct device_attribute *attr,
578                          const char *buf, size_t count)
579 {
580
581         dwc_otg_device_t *otg_dev = _dev->platform_data;
582         uint32_t in = simple_strtoul(buf, NULL, 16);
583         dwc_otg_set_hnpreq(otg_dev->core_if, in);
584         return count;
585 }
586
587 DEVICE_ATTR(hnp, 0644, hnp_show, hnp_store);
588
589 /**
590  * @todo Add code to initiate the SRP.
591  */
592 /**
593  * Show the SRP status bit
594  */
595 static ssize_t srp_show(struct device *_dev,
596                         struct device_attribute *attr, char *buf)
597 {
598 #ifndef DWC_HOST_ONLY
599
600         dwc_otg_device_t *otg_dev = _dev->platform_data;
601         return sprintf(buf, "SesReqScs = 0x%x\n",
602                        dwc_otg_get_srpstatus(otg_dev->core_if));
603 #else
604         return sprintf(buf, "Host Only Mode!\n");
605 #endif
606 }
607
608 /**
609  * Set the SRP Request bit
610  */
611 static ssize_t srp_store(struct device *_dev,
612                          struct device_attribute *attr,
613                          const char *buf, size_t count)
614 {
615 #ifndef DWC_HOST_ONLY
616
617         dwc_otg_device_t *otg_dev = _dev->platform_data;
618         dwc_otg_pcd_initiate_srp(otg_dev->pcd);
619 #endif
620         return count;
621 }
622
623 DEVICE_ATTR(srp, 0644, srp_show, srp_store);
624
625 /**
626  * @todo Need to do more for power on/off?
627  */
628 /**
629  * Show the Bus Power status
630  */
631 static ssize_t buspower_show(struct device *_dev,
632                              struct device_attribute *attr, char *buf)
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         dwc_otg_device_t *otg_dev = _dev->platform_data;
649         uint32_t on = simple_strtoul(buf, NULL, 16);
650         dwc_otg_set_prtpower(otg_dev->core_if, on);
651         return count;
652 }
653
654 DEVICE_ATTR(buspower, 0644, buspower_show, buspower_store);
655
656 /**
657  * @todo Need to do more for suspend?
658  */
659 /**
660  * Show the Bus Suspend status
661  */
662 static ssize_t bussuspend_show(struct device *_dev,
663                                struct device_attribute *attr, char *buf)
664 {
665
666         dwc_otg_device_t *otg_dev = _dev->platform_data;
667         return sprintf(buf, "Bus Suspend = 0x%x\n",
668                        dwc_otg_get_prtsuspend(otg_dev->core_if));
669 }
670
671 /**
672  * Set the Bus Suspend status
673  */
674 static ssize_t bussuspend_store(struct device *_dev,
675                                 struct device_attribute *attr,
676                                 const char *buf, size_t count)
677 {
678
679         dwc_otg_device_t *otg_dev = _dev->platform_data;
680         uint32_t in = simple_strtoul(buf, NULL, 16);
681         dwc_otg_set_prtsuspend(otg_dev->core_if, in);
682         return count;
683 }
684
685 DEVICE_ATTR(bussuspend, 0644, bussuspend_show, bussuspend_store);
686
687 /**
688  * Show the Mode Change Ready Timer status
689  */
690 static ssize_t mode_ch_tim_en_show(struct device *_dev,
691                                    struct device_attribute *attr, char *buf)
692 {
693
694         dwc_otg_device_t *otg_dev = _dev->platform_data;
695         return sprintf(buf, "Mode Change Ready Timer Enable = 0x%x\n",
696                        dwc_otg_get_mode_ch_tim(otg_dev->core_if));
697 }
698
699 /**
700  * Set the Mode Change Ready Timer status
701  */
702 static ssize_t mode_ch_tim_en_store(struct device *_dev,
703                                     struct device_attribute *attr,
704                                     const char *buf, size_t count)
705 {
706
707         dwc_otg_device_t *otg_dev = _dev->platform_data;
708         uint32_t in = simple_strtoul(buf, NULL, 16);
709         dwc_otg_set_mode_ch_tim(otg_dev->core_if, in);
710         return count;
711 }
712
713 DEVICE_ATTR(mode_ch_tim_en, 0644, mode_ch_tim_en_show, mode_ch_tim_en_store);
714
715 /**
716  * Show the value of HFIR Frame Interval bitfield
717  */
718 static ssize_t fr_interval_show(struct device *_dev,
719                                 struct device_attribute *attr, char *buf)
720 {
721
722         dwc_otg_device_t *otg_dev = _dev->platform_data;
723         return sprintf(buf, "Frame Interval = 0x%x\n",
724                        dwc_otg_get_fr_interval(otg_dev->core_if));
725 }
726
727 /**
728  * Set the HFIR Frame Interval value
729  */
730 static ssize_t fr_interval_store(struct device *_dev,
731                                  struct device_attribute *attr,
732                                  const char *buf, size_t count)
733 {
734
735         dwc_otg_device_t *otg_dev = _dev->platform_data;
736         uint32_t in = simple_strtoul(buf, NULL, 10);
737         dwc_otg_set_fr_interval(otg_dev->core_if, in);
738         return count;
739 }
740
741 DEVICE_ATTR(fr_interval, 0644, fr_interval_show, fr_interval_store);
742
743 /**
744  * Show the status of Remote Wakeup.
745  */
746 static ssize_t remote_wakeup_show(struct device *_dev,
747                                   struct device_attribute *attr, char *buf)
748 {
749 #ifndef DWC_HOST_ONLY
750
751         dwc_otg_device_t *otg_dev = _dev->platform_data;
752         return sprintf(buf,
753                        "Remote Wakeup Sig = %d Enabled = %d LPM Remote Wakeup = %d\n",
754                        dwc_otg_get_remotewakesig(otg_dev->core_if),
755                        dwc_otg_pcd_get_rmwkup_enable(otg_dev->pcd),
756                        dwc_otg_get_lpm_remotewakeenabled(otg_dev->core_if));
757 #else
758         return sprintf(buf, "Host Only Mode!\n");
759 #endif /* DWC_HOST_ONLY */
760 }
761
762 /**
763  * Initiate a remote wakeup of the host.  The Device control register
764  * Remote Wakeup Signal bit is written if the PCD Remote wakeup enable
765  * flag is set.
766  *
767  */
768 static ssize_t remote_wakeup_store(struct device *_dev,
769                                    struct device_attribute *attr,
770                                    const char *buf, size_t count)
771 {
772 #ifndef DWC_HOST_ONLY
773
774         dwc_otg_device_t *otg_dev = _dev->platform_data;
775         uint32_t val = simple_strtoul(buf, NULL, 16);
776
777         if (val & 1)
778                 dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 1);
779         else
780                 dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 0);
781
782 #endif /* DWC_HOST_ONLY */
783         return count;
784 }
785
786 DEVICE_ATTR(remote_wakeup, S_IRUGO | S_IWUSR, remote_wakeup_show,
787             remote_wakeup_store);
788
789 /**
790  * Show the whether core is hibernated or not.
791  */
792 static ssize_t rem_wakeup_pwrdn_show(struct device *_dev,
793                                      struct device_attribute *attr, char *buf)
794 {
795 #ifndef DWC_HOST_ONLY
796
797         dwc_otg_device_t *otg_dev = _dev->platform_data;
798         if (dwc_otg_get_core_state(otg_dev->core_if))
799                 DWC_PRINTF("Core is in hibernation\n");
800         else
801                 DWC_PRINTF("Core is not in hibernation\n");
802
803 #endif /* DWC_HOST_ONLY */
804         return 0;
805 }
806
807 extern int dwc_otg_device_hibernation_restore(dwc_otg_core_if_t *core_if,
808                                               int rem_wakeup, int reset);
809
810 /**
811  * Initiate a remote wakeup of the device to exit from hibernation.
812  */
813 static ssize_t rem_wakeup_pwrdn_store(struct device *_dev,
814                                       struct device_attribute *attr,
815                                       const char *buf, size_t count)
816 {
817 #ifndef DWC_HOST_ONLY
818
819         dwc_otg_device_t *otg_dev = _dev->platform_data;
820         dwc_otg_device_hibernation_restore(otg_dev->core_if, 1, 0);
821 #endif
822         return count;
823 }
824
825 DEVICE_ATTR(rem_wakeup_pwrdn, S_IRUGO | S_IWUSR, rem_wakeup_pwrdn_show,
826             rem_wakeup_pwrdn_store);
827
828 static ssize_t disconnect_us(struct device *_dev,
829                              struct device_attribute *attr,
830                              const char *buf, size_t count)
831 {
832
833 #ifndef DWC_HOST_ONLY
834
835         dwc_otg_device_t *otg_dev = _dev->platform_data;
836         uint32_t val = simple_strtoul(buf, NULL, 16);
837         DWC_PRINTF("The Passed value is %04x\n", val);
838
839         dwc_otg_pcd_disconnect_us(otg_dev->pcd, 50);
840
841 #endif /* DWC_HOST_ONLY */
842         return count;
843 }
844
845 DEVICE_ATTR(disconnect_us, S_IWUSR, 0, disconnect_us);
846
847 /**
848  * Dump global registers and either host or device registers (depending on the
849  * current mode of the core).
850  */
851 static ssize_t regdump_show(struct device *_dev,
852                             struct device_attribute *attr, char *buf)
853 {
854
855         dwc_otg_device_t *otg_dev = _dev->platform_data;
856         dwc_otg_dump_global_registers(otg_dev->core_if);
857         if (dwc_otg_is_host_mode(otg_dev->core_if))
858                 dwc_otg_dump_host_registers(otg_dev->core_if);
859         else
860                 dwc_otg_dump_dev_registers(otg_dev->core_if);
861
862         return sprintf(buf, "Register Dump\n");
863 }
864
865 DEVICE_ATTR(regdump, S_IRUGO, regdump_show, 0);
866
867 /**
868  * Dump global registers and either host or device registers (depending on the
869  * current mode of the core).
870  */
871 static ssize_t spramdump_show(struct device *_dev,
872                               struct device_attribute *attr, char *buf)
873 {
874
875         dwc_otg_device_t *otg_dev = _dev->platform_data;
876         dwc_otg_dump_spram(otg_dev->core_if);
877
878         return sprintf(buf, "SPRAM Dump\n");
879 }
880
881 DEVICE_ATTR(spramdump, S_IRUGO, spramdump_show, 0);
882
883 /**
884  * Dump the current hcd state.
885  */
886 static ssize_t hcddump_show(struct device *_dev,
887                             struct device_attribute *attr, char *buf)
888 {
889 #ifndef DWC_DEVICE_ONLY
890
891         dwc_otg_device_t *otg_dev = _dev->platform_data;
892         dwc_otg_hcd_dump_state(otg_dev->hcd);
893 #endif /* DWC_DEVICE_ONLY */
894         return sprintf(buf, "HCD Dump\n");
895 }
896
897 DEVICE_ATTR(hcddump, S_IRUGO, hcddump_show, 0);
898
899 /**
900  * Dump the average frame remaining at SOF. This can be used to
901  * determine average interrupt latency. Frame remaining is also shown for
902  * start transfer and two additional sample points.
903  */
904 static ssize_t hcd_frrem_show(struct device *_dev,
905                               struct device_attribute *attr, char *buf)
906 {
907 #ifndef DWC_DEVICE_ONLY
908
909         dwc_otg_device_t *otg_dev = _dev->platform_data;
910         dwc_otg_hcd_dump_frrem(otg_dev->hcd);
911 #endif /* DWC_DEVICE_ONLY */
912         return sprintf(buf, "HCD Dump Frame Remaining\n");
913 }
914
915 DEVICE_ATTR(hcd_frrem, S_IRUGO, hcd_frrem_show, 0);
916
917 /**
918  * Displays the time required to read the GNPTXFSIZ register many times (the
919  * output shows the number of times the register is read).
920  */
921 #define RW_REG_COUNT 10000000
922 #define MSEC_PER_JIFFIE (1000/HZ)
923 static ssize_t rd_reg_test_show(struct device *_dev,
924                                 struct device_attribute *attr, char *buf)
925 {
926
927         dwc_otg_device_t *otg_dev = _dev->platform_data;
928         int i;
929         int time;
930         int start_jiffies;
931
932         printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n",
933                HZ, MSEC_PER_JIFFIE, loops_per_jiffy);
934         start_jiffies = jiffies;
935         for (i = 0; i < RW_REG_COUNT; i++)
936                 dwc_otg_get_gnptxfsiz(otg_dev->core_if);
937         time = jiffies - start_jiffies;
938         return sprintf(buf,
939                        "Time to read GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n",
940                        RW_REG_COUNT, time * MSEC_PER_JIFFIE, time);
941 }
942
943 DEVICE_ATTR(rd_reg_test, S_IRUGO, rd_reg_test_show, 0);
944
945 /**
946  * Displays the time required to write the GNPTXFSIZ register many times (the
947  * output shows the number of times the register is written).
948  */
949 static ssize_t wr_reg_test_show(struct device *_dev,
950                                 struct device_attribute *attr, char *buf)
951 {
952
953         dwc_otg_device_t *otg_dev = _dev->platform_data;
954         uint32_t reg_val;
955         int i;
956         int time;
957         int start_jiffies;
958
959         printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n",
960                HZ, MSEC_PER_JIFFIE, loops_per_jiffy);
961         reg_val = dwc_otg_get_gnptxfsiz(otg_dev->core_if);
962         start_jiffies = jiffies;
963         for (i = 0; i < RW_REG_COUNT; i++)
964                 dwc_otg_set_gnptxfsiz(otg_dev->core_if, reg_val);
965         time = jiffies - start_jiffies;
966         return sprintf(buf,
967                        "Time to write GNPTXFSIZ reg %d times: %d msecs (%d jiffies)\n",
968                        RW_REG_COUNT, time * MSEC_PER_JIFFIE, time);
969 }
970
971 DEVICE_ATTR(wr_reg_test, S_IRUGO, wr_reg_test_show, 0);
972
973 #ifdef CONFIG_USB_DWC_OTG_LPM
974
975 /**
976 * Show the lpm_response attribute.
977 */
978 static ssize_t lpmresp_show(struct device *_dev,
979                             struct device_attribute *attr, char *buf)
980 {
981
982         dwc_otg_device_t *otg_dev = _dev->platform_data;
983         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
984                 return sprintf(buf, "** LPM is DISABLED **\n");
985
986         if (!dwc_otg_is_device_mode(otg_dev->core_if))
987                 return sprintf(buf, "** Current mode is not device mode\n");
988
989         return sprintf(buf, "lpm_response = %d\n",
990                        dwc_otg_get_lpmresponse(otg_dev->core_if));
991 }
992
993 /**
994 * Store the lpm_response attribute.
995 */
996 static ssize_t lpmresp_store(struct device *_dev,
997                              struct device_attribute *attr,
998                              const char *buf, size_t count)
999 {
1000
1001         dwc_otg_device_t *otg_dev = _dev->platform_data;
1002         uint32_t val = simple_strtoul(buf, NULL, 16);
1003
1004         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1005                 return 0;
1006
1007         if (!dwc_otg_is_device_mode(otg_dev->core_if))
1008                 return 0;
1009
1010         dwc_otg_set_lpmresponse(otg_dev->core_if, val);
1011         return count;
1012 }
1013
1014 DEVICE_ATTR(lpm_response, S_IRUGO | S_IWUSR, lpmresp_show, lpmresp_store);
1015
1016 /**
1017 * Show the besl_reject attribute.
1018 */
1019 static ssize_t beslreject_show(struct device *_dev,
1020                                struct device_attribute *attr, char *buf)
1021 {
1022
1023         dwc_otg_device_t *otg_dev = _dev->platform_data;
1024
1025         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1026                 return sprintf(buf, "** LPM is DISABLED **\n");
1027         if (!dwc_otg_get_param_besl_enable(otg_dev->core_if))
1028                 return sprintf(buf, "** EnBesl is DISABLED **\n");
1029
1030         if (!dwc_otg_is_device_mode(otg_dev->core_if))
1031                 return sprintf(buf, "** Current mode is not device mode\n");
1032
1033         return sprintf(buf, "besl_reject = %d\n",
1034                        dwc_otg_get_beslreject(otg_dev->core_if));
1035 }
1036
1037 /**
1038 * Store the besl_reject attribute.
1039 */
1040 static ssize_t beslreject_store(struct device *_dev,
1041                                 struct device_attribute *attr,
1042                                 const char *buf, size_t count)
1043 {
1044
1045         dwc_otg_device_t *otg_dev = _dev->platform_data;
1046         uint32_t val = simple_strtoul(buf, NULL, 16);
1047
1048         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1049                 return 0;
1050
1051         if (!dwc_otg_get_param_besl_enable(otg_dev->core_if))
1052                 return 0;
1053
1054         if (!dwc_otg_is_device_mode(otg_dev->core_if))
1055                 return 0;
1056
1057         dwc_otg_set_beslreject(otg_dev->core_if, val);
1058
1059         return count;
1060 }
1061
1062 DEVICE_ATTR(besl_reject, S_IRUGO | S_IWUSR, beslreject_show, beslreject_store);
1063
1064 /**
1065 * Show the hird_thresh attribute.
1066 */
1067 static ssize_t hirdthresh_show(struct device *_dev,
1068                                struct device_attribute *attr, char *buf)
1069 {
1070
1071         dwc_otg_device_t *otg_dev = _dev->platform_data;
1072
1073         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1074                 return sprintf(buf, "** LPM is DISABLED **\n");
1075
1076         if (!dwc_otg_is_device_mode(otg_dev->core_if))
1077                 return sprintf(buf, "** Current mode is not device mode\n");
1078
1079         return sprintf(buf, "hirdthresh = 0x%x\n",
1080                        dwc_otg_get_hirdthresh(otg_dev->core_if));
1081 }
1082
1083 /**
1084 * Store the hird_thresh attribute.
1085 */
1086 static ssize_t hirdthresh_store(struct device *_dev,
1087                                 struct device_attribute *attr,
1088                                 const char *buf, size_t count)
1089 {
1090
1091         dwc_otg_device_t *otg_dev = _dev->platform_data;
1092
1093         uint32_t val = simple_strtoul(buf, NULL, 16);
1094
1095         if (!dwc_otg_get_param_lpm_enable(otg_dev->core_if))
1096                 return 0;
1097
1098         if (!dwc_otg_is_device_mode(otg_dev->core_if))
1099                 return 0;
1100
1101         dwc_otg_set_hirdthresh(otg_dev->core_if, val);
1102
1103         return count;
1104 }
1105
1106 DEVICE_ATTR(hird_thres, S_IRUGO | S_IWUSR, hirdthresh_show, hirdthresh_store);
1107
1108 /**
1109 * Show the sleep_status attribute.
1110 */
1111 static ssize_t sleepstatus_show(struct device *_dev,
1112                                 struct device_attribute *attr, char *buf)
1113 {
1114
1115         dwc_otg_device_t *otg_dev = _dev->platform_data;
1116         return sprintf(buf, "Sleep Status = %d\n",
1117                        dwc_otg_get_lpm_portsleepstatus(otg_dev->core_if));
1118 }
1119
1120 /**
1121  * Store the sleep_status attribure.
1122  */
1123 static ssize_t sleepstatus_store(struct device *_dev,
1124                                  struct device_attribute *attr,
1125                                  const char *buf, size_t count)
1126 {
1127
1128         dwc_otg_device_t *otg_dev = _dev->platform_data;
1129         dwc_otg_core_if_t *core_if = otg_dev->core_if;
1130
1131         if (dwc_otg_get_lpm_portsleepstatus(otg_dev->core_if)) {
1132                 if (dwc_otg_is_host_mode(core_if)) {
1133
1134                         DWC_PRINTF("Host initiated resume\n");
1135                         dwc_otg_set_prtresume(otg_dev->core_if, 1);
1136                 }
1137         }
1138
1139         return count;
1140 }
1141
1142 DEVICE_ATTR(sleep_status, S_IRUGO | S_IWUSR, sleepstatus_show,
1143             sleepstatus_store);
1144
1145 #endif /* CONFIG_USB_DWC_OTG_LPM_ENABLE */
1146
1147 /**@}*/
1148
1149 /**
1150  * Create the device files
1151  */
1152 void dwc_otg_attr_create(struct platform_device *dev)
1153 {
1154         int error;
1155
1156         error = device_create_file(&dev->dev, &dev_attr_regoffset);
1157         error = device_create_file(&dev->dev, &dev_attr_regvalue);
1158         error = device_create_file(&dev->dev, &dev_attr_mode);
1159         error = device_create_file(&dev->dev, &dev_attr_hnpcapable);
1160         error = device_create_file(&dev->dev, &dev_attr_srpcapable);
1161         error = device_create_file(&dev->dev, &dev_attr_hsic_connect);
1162         error = device_create_file(&dev->dev, &dev_attr_inv_sel_hsic);
1163         error = device_create_file(&dev->dev, &dev_attr_hnp);
1164         error = device_create_file(&dev->dev, &dev_attr_srp);
1165         error = device_create_file(&dev->dev, &dev_attr_buspower);
1166         error = device_create_file(&dev->dev, &dev_attr_bussuspend);
1167         error = device_create_file(&dev->dev, &dev_attr_mode_ch_tim_en);
1168         error = device_create_file(&dev->dev, &dev_attr_fr_interval);
1169         error = device_create_file(&dev->dev, &dev_attr_busconnected);
1170         error = device_create_file(&dev->dev, &dev_attr_gotgctl);
1171         error = device_create_file(&dev->dev, &dev_attr_gusbcfg);
1172         error = device_create_file(&dev->dev, &dev_attr_grxfsiz);
1173         error = device_create_file(&dev->dev, &dev_attr_gnptxfsiz);
1174         error = device_create_file(&dev->dev, &dev_attr_gpvndctl);
1175         error = device_create_file(&dev->dev, &dev_attr_ggpio);
1176         error = device_create_file(&dev->dev, &dev_attr_guid);
1177         error = device_create_file(&dev->dev, &dev_attr_gsnpsid);
1178         error = device_create_file(&dev->dev, &dev_attr_devspeed);
1179         error = device_create_file(&dev->dev, &dev_attr_enumspeed);
1180         error = device_create_file(&dev->dev, &dev_attr_hptxfsiz);
1181         error = device_create_file(&dev->dev, &dev_attr_hprt0);
1182         error = device_create_file(&dev->dev, &dev_attr_remote_wakeup);
1183         error = device_create_file(&dev->dev, &dev_attr_rem_wakeup_pwrdn);
1184         error = device_create_file(&dev->dev, &dev_attr_disconnect_us);
1185         error = device_create_file(&dev->dev, &dev_attr_regdump);
1186         error = device_create_file(&dev->dev, &dev_attr_spramdump);
1187         error = device_create_file(&dev->dev, &dev_attr_hcddump);
1188         error = device_create_file(&dev->dev, &dev_attr_hcd_frrem);
1189         error = device_create_file(&dev->dev, &dev_attr_rd_reg_test);
1190         error = device_create_file(&dev->dev, &dev_attr_wr_reg_test);
1191 #ifdef CONFIG_USB_DWC_OTG_LPM
1192         error = device_create_file(&dev->dev, &dev_attr_lpm_response);
1193         error = device_create_file(&dev->dev, &dev_attr_sleep_status);
1194         error = device_create_file(&dev->dev, &dev_attr_besl_reject);
1195         error = device_create_file(&dev->dev, &dev_attr_hird_thres);
1196 #endif
1197 }
1198
1199 /**
1200  * Remove the device files
1201  */
1202 void dwc_otg_attr_remove(struct platform_device *dev)
1203 {
1204         device_remove_file(&dev->dev, &dev_attr_regoffset);
1205         device_remove_file(&dev->dev, &dev_attr_regvalue);
1206         device_remove_file(&dev->dev, &dev_attr_mode);
1207         device_remove_file(&dev->dev, &dev_attr_hnpcapable);
1208         device_remove_file(&dev->dev, &dev_attr_srpcapable);
1209         device_remove_file(&dev->dev, &dev_attr_hsic_connect);
1210         device_remove_file(&dev->dev, &dev_attr_inv_sel_hsic);
1211         device_remove_file(&dev->dev, &dev_attr_hnp);
1212         device_remove_file(&dev->dev, &dev_attr_srp);
1213         device_remove_file(&dev->dev, &dev_attr_buspower);
1214         device_remove_file(&dev->dev, &dev_attr_bussuspend);
1215         device_remove_file(&dev->dev, &dev_attr_mode_ch_tim_en);
1216         device_remove_file(&dev->dev, &dev_attr_fr_interval);
1217         device_remove_file(&dev->dev, &dev_attr_busconnected);
1218         device_remove_file(&dev->dev, &dev_attr_gotgctl);
1219         device_remove_file(&dev->dev, &dev_attr_gusbcfg);
1220         device_remove_file(&dev->dev, &dev_attr_grxfsiz);
1221         device_remove_file(&dev->dev, &dev_attr_gnptxfsiz);
1222         device_remove_file(&dev->dev, &dev_attr_gpvndctl);
1223         device_remove_file(&dev->dev, &dev_attr_ggpio);
1224         device_remove_file(&dev->dev, &dev_attr_guid);
1225         device_remove_file(&dev->dev, &dev_attr_gsnpsid);
1226         device_remove_file(&dev->dev, &dev_attr_devspeed);
1227         device_remove_file(&dev->dev, &dev_attr_enumspeed);
1228         device_remove_file(&dev->dev, &dev_attr_hptxfsiz);
1229         device_remove_file(&dev->dev, &dev_attr_hprt0);
1230         device_remove_file(&dev->dev, &dev_attr_remote_wakeup);
1231         device_remove_file(&dev->dev, &dev_attr_rem_wakeup_pwrdn);
1232         device_remove_file(&dev->dev, &dev_attr_disconnect_us);
1233         device_remove_file(&dev->dev, &dev_attr_regdump);
1234         device_remove_file(&dev->dev, &dev_attr_spramdump);
1235         device_remove_file(&dev->dev, &dev_attr_hcddump);
1236         device_remove_file(&dev->dev, &dev_attr_hcd_frrem);
1237         device_remove_file(&dev->dev, &dev_attr_rd_reg_test);
1238         device_remove_file(&dev->dev, &dev_attr_wr_reg_test);
1239 #ifdef CONFIG_USB_DWC_OTG_LPM
1240         device_remove_file(&dev->dev, &dev_attr_lpm_response);
1241         device_remove_file(&dev->dev, &dev_attr_sleep_status);
1242         device_remove_file(&dev->dev, &dev_attr_besl_reject);
1243         device_remove_file(&dev->dev, &dev_attr_hird_thres);
1244 #endif
1245 }