aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/pcie.h
diff options
context:
space:
mode:
authorAvinash Patil <patila@marvell.com>2013-02-08 21:18:06 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-02-11 15:34:56 -0500
commitdd04e6acd828d51255fbb2d9b7b0e5b85df04f0b (patch)
treee5e301e71fb4eec49755172ae9740d3fd52cdb2b /drivers/net/wireless/mwifiex/pcie.h
parent1a6404a1d8497692f31808319d662c739033c491 (diff)
mwifiex: store card specific data in PCI device table entry
This patch adds support for storing PCIe device specific data into driver_data structure of pci_device_id. When a device with known device_id is probed, we use this driver_data to populate card specific structres in driver. This enables to remove device specific defines for scratch registers, firmware name, FW download block size, etc. from source code. This will make addition of support for new chipsets a lot easier. Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/pcie.h')
-rw-r--r--drivers/net/wireless/mwifiex/pcie.h113
1 files changed, 84 insertions, 29 deletions
diff --git a/drivers/net/wireless/mwifiex/pcie.h b/drivers/net/wireless/mwifiex/pcie.h
index 37eeb2ca6b29..7ef660ec058e 100644
--- a/drivers/net/wireless/mwifiex/pcie.h
+++ b/drivers/net/wireless/mwifiex/pcie.h
@@ -75,27 +75,6 @@
75#define MWIFIEX_BD_FLAG_ROLLOVER_IND BIT(7) 75#define MWIFIEX_BD_FLAG_ROLLOVER_IND BIT(7)
76#define MWIFIEX_BD_FLAG_FIRST_DESC BIT(0) 76#define MWIFIEX_BD_FLAG_FIRST_DESC BIT(0)
77#define MWIFIEX_BD_FLAG_LAST_DESC BIT(1) 77#define MWIFIEX_BD_FLAG_LAST_DESC BIT(1)
78#define REG_CMD_ADDR_LO PCIE_SCRATCH_0_REG
79#define REG_CMD_ADDR_HI PCIE_SCRATCH_1_REG
80#define REG_CMD_SIZE PCIE_SCRATCH_2_REG
81
82#define REG_CMDRSP_ADDR_LO PCIE_SCRATCH_4_REG
83#define REG_CMDRSP_ADDR_HI PCIE_SCRATCH_5_REG
84
85/* TX buffer description read pointer */
86#define REG_TXBD_RDPTR PCIE_SCRATCH_6_REG
87/* TX buffer description write pointer */
88#define REG_TXBD_WRPTR PCIE_SCRATCH_7_REG
89/* RX buffer description read pointer */
90#define REG_RXBD_RDPTR PCIE_SCRATCH_8_REG
91/* RX buffer description write pointer */
92#define REG_RXBD_WRPTR PCIE_SCRATCH_9_REG
93/* Event buffer description read pointer */
94#define REG_EVTBD_RDPTR PCIE_SCRATCH_10_REG
95/* Event buffer description write pointer */
96#define REG_EVTBD_WRPTR PCIE_SCRATCH_11_REG
97/* Driver ready signature write pointer */
98#define REG_DRV_READY PCIE_SCRATCH_12_REG
99 78
100/* Max retry number of command write */ 79/* Max retry number of command write */
101#define MAX_WRITE_IOMEM_RETRY 2 80#define MAX_WRITE_IOMEM_RETRY 2
@@ -104,6 +83,78 @@
104/* FW awake cookie after FW ready */ 83/* FW awake cookie after FW ready */
105#define FW_AWAKE_COOKIE (0xAA55AA55) 84#define FW_AWAKE_COOKIE (0xAA55AA55)
106 85
86struct mwifiex_pcie_card_reg {
87 u16 cmd_addr_lo;
88 u16 cmd_addr_hi;
89 u16 fw_status;
90 u16 cmd_size;
91 u16 cmdrsp_addr_lo;
92 u16 cmdrsp_addr_hi;
93 u16 tx_rdptr;
94 u16 tx_wrptr;
95 u16 rx_rdptr;
96 u16 rx_wrptr;
97 u16 evt_rdptr;
98 u16 evt_wrptr;
99 u16 drv_rdy;
100 u16 tx_start_ptr;
101 u32 tx_mask;
102 u32 tx_wrap_mask;
103 u32 rx_mask;
104 u32 rx_wrap_mask;
105 u32 tx_rollover_ind;
106 u32 rx_rollover_ind;
107 u32 evt_rollover_ind;
108 u8 ring_flag_sop;
109 u8 ring_flag_eop;
110 u8 ring_flag_xs_sop;
111 u8 ring_flag_xs_eop;
112 u32 ring_tx_start_ptr;
113 u8 pfu_enabled;
114};
115
116static const struct mwifiex_pcie_card_reg mwifiex_reg_8766 = {
117 .cmd_addr_lo = PCIE_SCRATCH_0_REG,
118 .cmd_addr_hi = PCIE_SCRATCH_1_REG,
119 .cmd_size = PCIE_SCRATCH_2_REG,
120 .fw_status = PCIE_SCRATCH_3_REG,
121 .cmdrsp_addr_lo = PCIE_SCRATCH_4_REG,
122 .cmdrsp_addr_hi = PCIE_SCRATCH_5_REG,
123 .tx_rdptr = PCIE_SCRATCH_6_REG,
124 .tx_wrptr = PCIE_SCRATCH_7_REG,
125 .rx_rdptr = PCIE_SCRATCH_8_REG,
126 .rx_wrptr = PCIE_SCRATCH_9_REG,
127 .evt_rdptr = PCIE_SCRATCH_10_REG,
128 .evt_wrptr = PCIE_SCRATCH_11_REG,
129 .drv_rdy = PCIE_SCRATCH_12_REG,
130 .tx_start_ptr = 0,
131 .tx_mask = MWIFIEX_TXBD_MASK,
132 .tx_wrap_mask = 0,
133 .rx_mask = MWIFIEX_RXBD_MASK,
134 .rx_wrap_mask = 0,
135 .tx_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND,
136 .rx_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND,
137 .evt_rollover_ind = MWIFIEX_BD_FLAG_ROLLOVER_IND,
138 .ring_flag_sop = 0,
139 .ring_flag_eop = 0,
140 .ring_flag_xs_sop = 0,
141 .ring_flag_xs_eop = 0,
142 .ring_tx_start_ptr = 0,
143 .pfu_enabled = 0,
144};
145
146struct mwifiex_pcie_device {
147 const char *firmware;
148 const struct mwifiex_pcie_card_reg *reg;
149 u16 blksz_fw_dl;
150};
151
152static const struct mwifiex_pcie_device mwifiex_pcie8766 = {
153 .firmware = PCIE8766_DEFAULT_FW_NAME,
154 .reg = &mwifiex_reg_8766,
155 .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD,
156};
157
107struct mwifiex_pcie_buf_desc { 158struct mwifiex_pcie_buf_desc {
108 u64 paddr; 159 u64 paddr;
109 u16 len; 160 u16 len;
@@ -113,6 +164,7 @@ struct mwifiex_pcie_buf_desc {
113struct pcie_service_card { 164struct pcie_service_card {
114 struct pci_dev *dev; 165 struct pci_dev *dev;
115 struct mwifiex_adapter *adapter; 166 struct mwifiex_adapter *adapter;
167 struct mwifiex_pcie_device pcie;
116 168
117 u8 txbd_flush; 169 u8 txbd_flush;
118 u32 txbd_wrptr; 170 u32 txbd_wrptr;
@@ -150,10 +202,11 @@ struct pcie_service_card {
150static inline int 202static inline int
151mwifiex_pcie_txbd_empty(struct pcie_service_card *card, u32 rdptr) 203mwifiex_pcie_txbd_empty(struct pcie_service_card *card, u32 rdptr)
152{ 204{
153 if (((card->txbd_wrptr & MWIFIEX_TXBD_MASK) == 205 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
154 (rdptr & MWIFIEX_TXBD_MASK)) && 206
155 ((card->txbd_wrptr & MWIFIEX_BD_FLAG_ROLLOVER_IND) != 207 if (((card->txbd_wrptr & reg->tx_mask) == (rdptr & reg->tx_mask)) &&
156 (rdptr & MWIFIEX_BD_FLAG_ROLLOVER_IND))) 208 ((card->txbd_wrptr & reg->tx_rollover_ind) !=
209 (rdptr & reg->tx_rollover_ind)))
157 return 1; 210 return 1;
158 211
159 return 0; 212 return 0;
@@ -162,10 +215,12 @@ mwifiex_pcie_txbd_empty(struct pcie_service_card *card, u32 rdptr)
162static inline int 215static inline int
163mwifiex_pcie_txbd_not_full(struct pcie_service_card *card) 216mwifiex_pcie_txbd_not_full(struct pcie_service_card *card)
164{ 217{
165 if (((card->txbd_wrptr & MWIFIEX_TXBD_MASK) != 218 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
166 (card->txbd_rdptr & MWIFIEX_TXBD_MASK)) || 219
167 ((card->txbd_wrptr & MWIFIEX_BD_FLAG_ROLLOVER_IND) != 220 if (((card->txbd_wrptr & reg->tx_mask) !=
168 (card->txbd_rdptr & MWIFIEX_BD_FLAG_ROLLOVER_IND))) 221 (card->txbd_rdptr & reg->tx_mask)) ||
222 ((card->txbd_wrptr & reg->tx_rollover_ind) !=
223 (card->txbd_rdptr & reg->tx_rollover_ind)))
169 return 1; 224 return 1;
170 225
171 return 0; 226 return 0;