p54usb.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #ifndef P54USB_H
  2. #define P54USB_H
  3. /*
  4. * Defines for USB based mac80211 Prism54 driver
  5. *
  6. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  7. *
  8. * Based on the islsm (softmac prism54) driver, which is:
  9. * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. /* for isl3886 register definitions used on ver 1 devices */
  16. #include "p54pci.h"
  17. #include <linux/usb/net2280.h>
  18. /* pci */
  19. #define NET2280_BASE 0x10000000
  20. #define NET2280_BASE2 0x20000000
  21. /* gpio */
  22. #define P54U_BRG_POWER_UP (1 << GPIO0_DATA)
  23. #define P54U_BRG_POWER_DOWN (1 << GPIO1_DATA)
  24. /* devinit */
  25. #define NET2280_CLK_4Mhz (15 << LOCAL_CLOCK_FREQUENCY)
  26. #define NET2280_CLK_30Mhz (2 << LOCAL_CLOCK_FREQUENCY)
  27. #define NET2280_CLK_60Mhz (1 << LOCAL_CLOCK_FREQUENCY)
  28. #define NET2280_CLK_STOP (0 << LOCAL_CLOCK_FREQUENCY)
  29. #define NET2280_PCI_ENABLE (1 << PCI_ENABLE)
  30. #define NET2280_PCI_SOFT_RESET (1 << PCI_SOFT_RESET)
  31. /* endpoints */
  32. #define NET2280_CLEAR_NAK_OUT_PACKETS_MODE (1 << CLEAR_NAK_OUT_PACKETS_MODE)
  33. #define NET2280_FIFO_FLUSH (1 << FIFO_FLUSH)
  34. /* irq */
  35. #define NET2280_USB_INTERRUPT_ENABLE (1 << USB_INTERRUPT_ENABLE)
  36. #define NET2280_PCI_INTA_INTERRUPT (1 << PCI_INTA_INTERRUPT)
  37. #define NET2280_PCI_INTA_INTERRUPT_ENABLE (1 << PCI_INTA_INTERRUPT_ENABLE)
  38. /* registers */
  39. #define NET2280_DEVINIT 0x00
  40. #define NET2280_USBIRQENB1 0x24
  41. #define NET2280_IRQSTAT1 0x2c
  42. #define NET2280_FIFOCTL 0x38
  43. #define NET2280_GPIOCTL 0x50
  44. #define NET2280_RELNUM 0x88
  45. #define NET2280_EPA_RSP 0x324
  46. #define NET2280_EPA_STAT 0x32c
  47. #define NET2280_EPB_STAT 0x34c
  48. #define NET2280_EPC_RSP 0x364
  49. #define NET2280_EPC_STAT 0x36c
  50. #define NET2280_EPD_STAT 0x38c
  51. #define NET2280_EPA_CFG 0x320
  52. #define NET2280_EPB_CFG 0x340
  53. #define NET2280_EPC_CFG 0x360
  54. #define NET2280_EPD_CFG 0x380
  55. #define NET2280_EPE_CFG 0x3A0
  56. #define NET2280_EPF_CFG 0x3C0
  57. #define P54U_DEV_BASE 0x40000000
  58. struct net2280_tx_hdr {
  59. __le32 device_addr;
  60. __le16 len;
  61. __le16 follower; /* ? */
  62. u8 padding[8];
  63. } __packed;
  64. struct lm87_tx_hdr {
  65. __le32 device_addr;
  66. __le32 chksum;
  67. } __packed;
  68. /* Some flags for the isl hardware registers controlling DMA inside the
  69. * chip */
  70. #define ISL38XX_DMA_STATUS_DONE 0x00000001
  71. #define ISL38XX_DMA_STATUS_READY 0x00000002
  72. #define NET2280_EPA_FIFO_PCI_ADDR 0x20000000
  73. #define ISL38XX_DMA_MASTER_CONTROL_TRIGGER 0x00000004
  74. enum net2280_op_type {
  75. NET2280_BRG_U32 = 0x001F,
  76. NET2280_BRG_CFG_U32 = 0x000F,
  77. NET2280_BRG_CFG_U16 = 0x0003,
  78. NET2280_DEV_U32 = 0x080F,
  79. NET2280_DEV_CFG_U32 = 0x088F,
  80. NET2280_DEV_CFG_U16 = 0x0883
  81. };
  82. struct net2280_reg_write {
  83. __le16 port;
  84. __le32 addr;
  85. __le32 val;
  86. } __packed;
  87. struct net2280_reg_read {
  88. __le16 port;
  89. __le32 addr;
  90. } __packed;
  91. #define P54U_FW_BLOCK 2048
  92. #define X2_SIGNATURE "x2 "
  93. #define X2_SIGNATURE_SIZE 4
  94. struct x2_header {
  95. u8 signature[X2_SIGNATURE_SIZE];
  96. __le32 fw_load_addr;
  97. __le32 fw_length;
  98. __le32 crc;
  99. } __packed;
  100. /* pipes 3 and 4 are not used by the driver */
  101. #define P54U_PIPE_NUMBER 9
  102. enum p54u_pipe_addr {
  103. P54U_PIPE_DATA = 0x01,
  104. P54U_PIPE_MGMT = 0x02,
  105. P54U_PIPE_3 = 0x03,
  106. P54U_PIPE_4 = 0x04,
  107. P54U_PIPE_BRG = 0x0d,
  108. P54U_PIPE_DEV = 0x0e,
  109. P54U_PIPE_INT = 0x0f
  110. };
  111. struct p54u_rx_info {
  112. struct urb *urb;
  113. struct ieee80211_hw *dev;
  114. };
  115. enum p54u_hw_type {
  116. P54U_INVALID_HW,
  117. P54U_NET2280,
  118. P54U_3887,
  119. /* keep last */
  120. __NUM_P54U_HWTYPES,
  121. };
  122. struct p54u_priv {
  123. struct p54_common common;
  124. struct usb_device *udev;
  125. struct usb_interface *intf;
  126. int (*upload_fw)(struct ieee80211_hw *dev);
  127. enum p54u_hw_type hw_type;
  128. spinlock_t lock;
  129. struct sk_buff_head rx_queue;
  130. struct usb_anchor submitted;
  131. const struct firmware *fw;
  132. /* asynchronous firmware callback */
  133. struct completion fw_wait_load;
  134. };
  135. #endif /* P54USB_H */