forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/sbhnddma.h
....@@ -1,16 +1,17 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
43 * This supports the following chips: BCM42xx, 44xx, 47xx .
54 *
6
- * Copyright (C) 1999-2019, Broadcom Corporation
7
- *
5
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
6
+ *
7
+ * Copyright (C) 1999-2017, Broadcom Corporation
8
+ *
89 * Unless you and Broadcom execute a separate written software license
910 * agreement governing use of this software, this software is licensed to you
1011 * under the terms of the GNU General Public License version 2 (the "GPL"),
1112 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1213 * following added to such license:
13
- *
14
+ *
1415 * As a special exception, the copyright holders of this software give you
1516 * permission to link this software with independent modules, and to copy and
1617 * distribute the resulting executable under terms of your choice, provided that
....@@ -18,7 +19,7 @@
1819 * the license of that module. An independent module is a module which is not
1920 * derived from this software. The special exception does not apply to any
2021 * modifications of the software.
21
- *
22
+ *
2223 * Notwithstanding the above, under no circumstances may you combine this
2324 * software in any way with any other Broadcom software provided under a license
2425 * other than the GPL, without Broadcom's express prior written consent.
....@@ -26,7 +27,7 @@
2627 *
2728 * <<Broadcom-WL-IPTag/Open:>>
2829 *
29
- * $Id: sbhnddma.h 530150 2015-01-29 08:43:40Z $
30
+ * $Id: sbhnddma.h 694506 2017-04-13 05:10:05Z $
3031 */
3132
3233 #ifndef _sbhnddma_h_
....@@ -37,7 +38,6 @@
3738 * basic DMA register set is per channel(transmit or receive)
3839 * a pair of channels is defined for convenience
3940 */
40
-
4141
4242 /* 32 bits addressing */
4343
....@@ -118,6 +118,7 @@
118118 #define DMA_PC_4 1
119119 #define DMA_PC_8 2
120120 #define DMA_PC_16 3
121
+#define DMA_PC_32 4
121122 /* others: reserved */
122123
123124 /** Prefetch threshold */
....@@ -125,6 +126,10 @@
125126 #define DMA_PT_2 1
126127 #define DMA_PT_4 2
127128 #define DMA_PT_8 3
129
+
130
+/** Channel Switch */
131
+#define DMA_CS_OFF 0
132
+#define DMA_CS_ON 1
128133
129134 /* transmit descriptor table pointer */
130135 #define XP_LD_MASK 0xfff /**< last valid descriptor */
....@@ -164,7 +169,8 @@
164169 #define RC_PC_SHIFT 21
165170 #define RC_PT_MASK 0x03000000 /**< Prefetch threshold */
166171 #define RC_PT_SHIFT 24
167
-
172
+#define RC_WAITCMP_MASK 0x00001000
173
+#define RC_WAITCMP_SHIFT 12
168174 /* receive descriptor table pointer */
169175 #define RP_LD_MASK 0xfff /**< last valid descriptor */
170176
....@@ -274,13 +280,12 @@
274280 #define D64_DEF_USBBURSTLEN 2
275281 #define D64_DEF_SDIOBURSTLEN 1
276282
277
-
278283 #ifndef D64_USBBURSTLEN
279284 #define D64_USBBURSTLEN DMA_BL_64
280
-#endif
285
+#endif // endif
281286 #ifndef D64_SDIOBURSTLEN
282287 #define D64_SDIOBURSTLEN DMA_BL_32
283
-#endif
288
+#endif // endif
284289
285290 /* transmit channel control */
286291 #define D64_XC_XE 0x00000001 /**< transmit enable */
....@@ -289,6 +294,8 @@
289294 #define D64_XC_FL 0x00000010 /**< flush request */
290295 #define D64_XC_MR_MASK 0x000001C0 /**< Multiple outstanding reads */
291296 #define D64_XC_MR_SHIFT 6
297
+#define D64_XC_CS_SHIFT 9 /**< channel switch enable */
298
+#define D64_XC_CS_MASK 0x00000200 /**< channel switch enable */
292299 #define D64_XC_PD 0x00000800 /**< parity check disable */
293300 #define D64_XC_AE 0x00030000 /**< address extension bits */
294301 #define D64_XC_AE_SHIFT 16
....@@ -298,6 +305,8 @@
298305 #define D64_XC_PC_SHIFT 21
299306 #define D64_XC_PT_MASK 0x03000000 /**< Prefetch threshold */
300307 #define D64_XC_PT_SHIFT 24
308
+#define D64_XC_CO_MASK 0x04000000 /**< coherent transactions for descriptors */
309
+#define D64_XC_CO_SHIFT 26
301310
302311 /* transmit descriptor table pointer */
303312 #define D64_XP_LD_MASK 0x00001fff /**< last valid descriptor */
....@@ -331,6 +340,8 @@
331340 #define D64_RC_SHIFT 9 /**< separate rx header descriptor enable */
332341 #define D64_RC_OC 0x00000400 /**< overflow continue */
333342 #define D64_RC_PD 0x00000800 /**< parity check disable */
343
+#define D64_RC_WAITCMP_MASK 0x00001000
344
+#define D64_RC_WAITCMP_SHIFT 12
334345 #define D64_RC_SA 0x00002000 /**< select active */
335346 #define D64_RC_GE 0x00004000 /**< Glom enable */
336347 #define D64_RC_AE 0x00030000 /**< address extension bits */
....@@ -341,6 +352,10 @@
341352 #define D64_RC_PC_SHIFT 21
342353 #define D64_RC_PT_MASK 0x03000000 /**< Prefetch threshold */
343354 #define D64_RC_PT_SHIFT 24
355
+#define D64_RC_CO_MASK 0x04000000 /**< coherent transactions for descriptors */
356
+#define D64_RC_CO_SHIFT 26
357
+#define D64_RC_ROEXT_MASK 0x08000000 /**< receive frame offset extension bit */
358
+#define D64_RC_ROEXT_SHIFT 27
344359
345360 /* flags for dma controller */
346361 #define DMA_CTRL_PEN (1 << 0) /**< partity enable */
....@@ -351,6 +366,15 @@
351366 #define DMA_CTRL_DMA_AVOIDANCE_WAR (1 << 5) /**< DMA avoidance WAR for 4331 */
352367 #define DMA_CTRL_RXSINGLE (1 << 6) /**< always single buffer */
353368 #define DMA_CTRL_SDIO_RXGLOM (1 << 7) /**< DMA Rx glome is enabled */
369
+#define DMA_CTRL_DESC_ONLY_FLAG (1 << 8) /**< For DMA which posts only descriptors,
370
+ * no packets
371
+ */
372
+#define DMA_CTRL_DESC_CD_WAR (1 << 9) /**< WAR for descriptor only DMA's CD not being
373
+ * updated correctly by HW in CT mode.
374
+ */
375
+#define DMA_CTRL_CS (1 << 10) /* channel switch enable */
376
+#define DMA_CTRL_ROEXT (1 << 11) /* receive frame offset extension support */
377
+#define DMA_CTRL_RX_ALIGN_8BYTE (1 << 12) /* RXDMA address 8-byte aligned for 43684A0 */
354378
355379 /* receive descriptor table pointer */
356380 #define D64_RP_LD_MASK 0x00001fff /**< last valid descriptor */
....@@ -365,8 +389,8 @@
365389 #define D64_RS0_RS_STOPPED 0x30000000 /**< stopped */
366390 #define D64_RS0_RS_SUSP 0x40000000 /**< suspend pending */
367391
368
-#define D64_RS1_AD_MASK 0x0001ffff /**< active descriptor */
369
-#define D64_RS1_RE_MASK 0xf0000000 /**< receive errors */
392
+#define D64_RS1_AD_MASK (di->d64_rs1_ad_mask) /* active descriptor pointer */
393
+#define D64_RS1_RE_MASK 0xf0000000 /* receive errors */
370394 #define D64_RS1_RE_SHIFT 28
371395 #define D64_RS1_RE_NOERR 0x00000000 /**< no error */
372396 #define D64_RS1_RE_DPO 0x10000000 /**< descriptor protocol error */
....@@ -392,6 +416,7 @@
392416
393417 /* descriptor control flags 1 */
394418 #define D64_CTRL_COREFLAGS 0x0ff00000 /**< core specific flags */
419
+#define D64_CTRL1_COHERENT ((uint32)1 << 17) /* cache coherent per transaction */
395420 #define D64_CTRL1_NOTPCIE ((uint32)1 << 18) /**< buirst size control */
396421 #define D64_CTRL1_EOT ((uint32)1 << 28) /**< end of descriptor table */
397422 #define D64_CTRL1_IOC ((uint32)1 << 29) /**< interrupt on completion */
....@@ -399,7 +424,8 @@
399424 #define D64_CTRL1_SOF ((uint32)1 << 31) /**< start of frame */
400425
401426 /* descriptor control flags 2 */
402
-#define D64_CTRL2_BC_MASK 0x00007fff /**< buffer byte count. real data len must <= 16KB */
427
+#define D64_CTRL2_MAX_LEN 0x0000fff7 /* Max transfer length (buffer byte count) <= 65527 */
428
+#define D64_CTRL2_BC_MASK 0x0000ffff /**< mask for buffer byte count */
403429 #define D64_CTRL2_AE 0x00030000 /**< address extension bits */
404430 #define D64_CTRL2_AE_SHIFT 16
405431 #define D64_CTRL2_PARITY 0x00040000 /* parity bit */
....@@ -410,8 +436,12 @@
410436 #define D64_RX_FRM_STS_LEN 0x0000ffff /**< frame length mask */
411437 #define D64_RX_FRM_STS_OVFL 0x00800000 /**< RxOverFlow */
412438 #define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /**< no. of descriptors used - 1, d11corerev >= 22 */
439
+#define D64_RX_FRM_STS_DSCRCNT_SHIFT 24 /* Shift for no .of dma descriptor field */
413440 #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /**< core-dependent data type */
414441
442
+#define BCM_D64_CTRL2_BOUND_DMA_LENGTH(len) \
443
+(((len) > D64_CTRL2_MAX_LEN) ? D64_CTRL2_MAX_LEN : (len))
444
+
415445 /** receive frame status */
416446 typedef volatile struct {
417447 uint16 len;