usb.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2
  6. * as published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __MT7601U_USB_H
  14. #define __MT7601U_USB_H
  15. #include "mt7601u.h"
  16. #define MT7601U_FIRMWARE "mt7601u.bin"
  17. #define MT_VEND_REQ_MAX_RETRY 10
  18. #define MT_VEND_REQ_TOUT_MS 300
  19. #define MT_VEND_DEV_MODE_RESET 1
  20. #define MT_VEND_BUF sizeof(__le32)
  21. enum mt_vendor_req {
  22. MT_VEND_DEV_MODE = 1,
  23. MT_VEND_WRITE = 2,
  24. MT_VEND_MULTI_READ = 7,
  25. MT_VEND_WRITE_FCE = 0x42,
  26. };
  27. enum mt_usb_ep_in {
  28. MT_EP_IN_PKT_RX,
  29. MT_EP_IN_CMD_RESP,
  30. __MT_EP_IN_MAX,
  31. };
  32. enum mt_usb_ep_out {
  33. MT_EP_OUT_INBAND_CMD,
  34. MT_EP_OUT_AC_BK,
  35. MT_EP_OUT_AC_BE,
  36. MT_EP_OUT_AC_VI,
  37. MT_EP_OUT_AC_VO,
  38. MT_EP_OUT_HCCA,
  39. __MT_EP_OUT_MAX,
  40. };
  41. static inline struct usb_device *mt7601u_to_usb_dev(struct mt7601u_dev *mt7601u)
  42. {
  43. return interface_to_usbdev(to_usb_interface(mt7601u->dev));
  44. }
  45. static inline bool mt7601u_urb_has_error(struct urb *urb)
  46. {
  47. return urb->status &&
  48. urb->status != -ENOENT &&
  49. urb->status != -ECONNRESET &&
  50. urb->status != -ESHUTDOWN;
  51. }
  52. bool mt7601u_usb_alloc_buf(struct mt7601u_dev *dev, size_t len,
  53. struct mt7601u_dma_buf *buf);
  54. void mt7601u_usb_free_buf(struct mt7601u_dev *dev, struct mt7601u_dma_buf *buf);
  55. int mt7601u_usb_submit_buf(struct mt7601u_dev *dev, int dir, int ep_idx,
  56. struct mt7601u_dma_buf *buf, gfp_t gfp,
  57. usb_complete_t complete_fn, void *context);
  58. void mt7601u_complete_urb(struct urb *urb);
  59. int mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req,
  60. const u8 direction, const u16 val, const u16 offset,
  61. void *buf, const size_t buflen);
  62. void mt7601u_vendor_reset(struct mt7601u_dev *dev);
  63. int mt7601u_vendor_single_wr(struct mt7601u_dev *dev, const u8 req,
  64. const u16 offset, const u32 val);
  65. #endif