usb_ops_linux.h 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #ifndef __USB_OPS_LINUX_H__
  16. #define __USB_OPS_LINUX_H__
  17. #define VENDOR_CMD_MAX_DATA_LEN 254
  18. #define FW_START_ADDRESS 0x1000
  19. #define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */
  20. #define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */
  21. #define RECV_BULK_IN_ADDR 0x80/* assign by drv, not real address */
  22. #define RECV_INT_IN_ADDR 0x81/* assign by drv, not real address */
  23. #define INTERRUPT_MSG_FORMAT_LEN 60
  24. #if defined(CONFIG_VENDOR_REQ_RETRY) && defined(CONFIG_USB_VENDOR_REQ_MUTEX)
  25. /* vendor req retry should be in the situation when each vendor req is atomically submitted from others */
  26. #define MAX_USBCTRL_VENDORREQ_TIMES 10
  27. #else
  28. #define MAX_USBCTRL_VENDORREQ_TIMES 1
  29. #endif
  30. #define RTW_USB_BULKOUT_TIMEOUT 5000/* ms */
  31. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18))
  32. #define _usbctrl_vendorreq_async_callback(urb, regs) _usbctrl_vendorreq_async_callback(urb)
  33. #define usb_bulkout_zero_complete(purb, regs) usb_bulkout_zero_complete(purb)
  34. #define usb_write_mem_complete(purb, regs) usb_write_mem_complete(purb)
  35. #define usb_write_port_complete(purb, regs) usb_write_port_complete(purb)
  36. #define usb_read_port_complete(purb, regs) usb_read_port_complete(purb)
  37. #define usb_read_interrupt_complete(purb, regs) usb_read_interrupt_complete(purb)
  38. #endif
  39. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12))
  40. #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
  41. usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms))
  42. #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
  43. usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms))
  44. #else
  45. #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
  46. usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \
  47. ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1)
  48. #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
  49. usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
  50. ((timeout_ms) == 0) || ((timeout_ms) * HZ / 1000 > 0) ? ((timeout_ms) * HZ / 1000) : 1)
  51. #endif
  52. #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
  53. int usb_async_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val);
  54. int usb_async_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val);
  55. int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val);
  56. #endif /* CONFIG_USB_SUPPORT_ASYNC_VDN_REQ */
  57. unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr);
  58. void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
  59. void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem);
  60. void usb_read_port_cancel(struct intf_hdl *pintfhdl);
  61. u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem);
  62. void usb_write_port_cancel(struct intf_hdl *pintfhdl);
  63. int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype);
  64. #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
  65. int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
  66. u16 value, u16 index, void *pdata, u16 len, u8 requesttype);
  67. #endif /* CONFIG_USB_SUPPORT_ASYNC_VDN_REQ */
  68. u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr);
  69. u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr);
  70. u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr);
  71. int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val);
  72. int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val);
  73. int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val);
  74. int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
  75. u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem);
  76. void usb_recv_tasklet(void *priv);
  77. #ifdef CONFIG_USB_INTERRUPT_IN_PIPE
  78. void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs);
  79. u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr);
  80. #endif
  81. #endif