Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 #ifndef P54USB_H
0003 #define P54USB_H
0004 
0005 /*
0006  * Defines for USB based mac80211 Prism54 driver
0007  *
0008  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
0009  *
0010  * Based on the islsm (softmac prism54) driver, which is:
0011  * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
0012  */
0013 
0014 /* for isl3886 register definitions used on ver 1 devices */
0015 #include "p54pci.h"
0016 #include <linux/usb/net2280.h>
0017 
0018 /* pci */
0019 #define NET2280_BASE        0x10000000
0020 #define NET2280_BASE2       0x20000000
0021 
0022 /* gpio */
0023 #define P54U_BRG_POWER_UP   (1 << GPIO0_DATA)
0024 #define P54U_BRG_POWER_DOWN (1 << GPIO1_DATA)
0025 
0026 /* devinit */
0027 #define NET2280_CLK_4Mhz    (15 << LOCAL_CLOCK_FREQUENCY)
0028 #define NET2280_CLK_30Mhz   (2 << LOCAL_CLOCK_FREQUENCY)
0029 #define NET2280_CLK_60Mhz   (1 << LOCAL_CLOCK_FREQUENCY)
0030 #define NET2280_CLK_STOP    (0 << LOCAL_CLOCK_FREQUENCY)
0031 #define NET2280_PCI_ENABLE  (1 << PCI_ENABLE)
0032 #define NET2280_PCI_SOFT_RESET  (1 << PCI_SOFT_RESET)
0033 
0034 /* endpoints */
0035 #define NET2280_CLEAR_NAK_OUT_PACKETS_MODE  (1 << CLEAR_NAK_OUT_PACKETS_MODE)
0036 #define NET2280_FIFO_FLUSH          (1 << FIFO_FLUSH)
0037 
0038 /* irq */
0039 #define NET2280_USB_INTERRUPT_ENABLE        (1 << USB_INTERRUPT_ENABLE)
0040 #define NET2280_PCI_INTA_INTERRUPT      (1 << PCI_INTA_INTERRUPT)
0041 #define NET2280_PCI_INTA_INTERRUPT_ENABLE   (1 << PCI_INTA_INTERRUPT_ENABLE)
0042 
0043 /* registers */
0044 #define NET2280_DEVINIT     0x00
0045 #define NET2280_USBIRQENB1  0x24
0046 #define NET2280_IRQSTAT1    0x2c
0047 #define NET2280_FIFOCTL         0x38
0048 #define NET2280_GPIOCTL     0x50
0049 #define NET2280_RELNUM      0x88
0050 #define NET2280_EPA_RSP     0x324
0051 #define NET2280_EPA_STAT    0x32c
0052 #define NET2280_EPB_STAT    0x34c
0053 #define NET2280_EPC_RSP     0x364
0054 #define NET2280_EPC_STAT    0x36c
0055 #define NET2280_EPD_STAT    0x38c
0056 
0057 #define NET2280_EPA_CFG     0x320
0058 #define NET2280_EPB_CFG     0x340
0059 #define NET2280_EPC_CFG     0x360
0060 #define NET2280_EPD_CFG     0x380
0061 #define NET2280_EPE_CFG     0x3A0
0062 #define NET2280_EPF_CFG     0x3C0
0063 #define P54U_DEV_BASE 0x40000000
0064 
0065 struct net2280_tx_hdr {
0066     __le32 device_addr;
0067     __le16 len;
0068     __le16 follower;    /* ? */
0069     u8 padding[8];
0070 } __packed;
0071 
0072 struct lm87_tx_hdr {
0073     __le32 device_addr;
0074     __le32 chksum;
0075 } __packed;
0076 
0077 /* Some flags for the isl hardware registers controlling DMA inside the
0078  * chip */
0079 #define ISL38XX_DMA_STATUS_DONE         0x00000001
0080 #define ISL38XX_DMA_STATUS_READY        0x00000002
0081 #define NET2280_EPA_FIFO_PCI_ADDR       0x20000000
0082 #define ISL38XX_DMA_MASTER_CONTROL_TRIGGER  0x00000004
0083 
0084 enum net2280_op_type {
0085     NET2280_BRG_U32     = 0x001F,
0086     NET2280_BRG_CFG_U32 = 0x000F,
0087     NET2280_BRG_CFG_U16 = 0x0003,
0088     NET2280_DEV_U32     = 0x080F,
0089     NET2280_DEV_CFG_U32 = 0x088F,
0090     NET2280_DEV_CFG_U16 = 0x0883
0091 };
0092 
0093 struct net2280_reg_write {
0094     __le16 port;
0095     __le32 addr;
0096     __le32 val;
0097 } __packed;
0098 
0099 struct net2280_reg_read {
0100     __le16 port;
0101     __le32 addr;
0102 } __packed;
0103 
0104 #define P54U_FW_BLOCK 2048
0105 
0106 #define X2_SIGNATURE "x2  "
0107 #define X2_SIGNATURE_SIZE 4
0108 
0109 struct x2_header {
0110     u8 signature[X2_SIGNATURE_SIZE];
0111     __le32 fw_load_addr;
0112     __le32 fw_length;
0113     __le32 crc;
0114 } __packed;
0115 
0116 /* pipes 3 and 4 are not used by the driver */
0117 #define P54U_PIPE_NUMBER 9
0118 
0119 enum p54u_pipe_addr {
0120         P54U_PIPE_DATA = 0x01,
0121         P54U_PIPE_MGMT = 0x02,
0122         P54U_PIPE_3 = 0x03,
0123         P54U_PIPE_4 = 0x04,
0124         P54U_PIPE_BRG = 0x0d,
0125         P54U_PIPE_DEV = 0x0e,
0126         P54U_PIPE_INT = 0x0f
0127 };
0128 
0129 struct p54u_rx_info {
0130     struct urb *urb;
0131     struct ieee80211_hw *dev;
0132 };
0133 
0134 enum p54u_hw_type {
0135     P54U_INVALID_HW,
0136     P54U_NET2280,
0137     P54U_3887,
0138 
0139     /* keep last */
0140     __NUM_P54U_HWTYPES,
0141 };
0142 
0143 struct p54u_priv {
0144     struct p54_common common;
0145     struct usb_device *udev;
0146     struct usb_interface *intf;
0147     int (*upload_fw)(struct ieee80211_hw *dev);
0148 
0149     enum p54u_hw_type hw_type;
0150     spinlock_t lock;
0151     struct sk_buff_head rx_queue;
0152     struct usb_anchor submitted;
0153     const struct firmware *fw;
0154 
0155     /* asynchronous firmware callback */
0156     struct completion fw_wait_load;
0157 };
0158 
0159 #endif /* P54USB_H */