| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 1 | /* |
|---|
| 3 | 2 | * Generic Broadcom Home Networking Division (HND) DMA engine HW interface |
|---|
| 4 | 3 | * This supports the following chips: BCM42xx, 44xx, 47xx . |
|---|
| 5 | 4 | * |
|---|
| 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 | + * |
|---|
| 8 | 9 | * Unless you and Broadcom execute a separate written software license |
|---|
| 9 | 10 | * agreement governing use of this software, this software is licensed to you |
|---|
| 10 | 11 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
|---|
| 11 | 12 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
|---|
| 12 | 13 | * following added to such license: |
|---|
| 13 | | - * |
|---|
| 14 | + * |
|---|
| 14 | 15 | * As a special exception, the copyright holders of this software give you |
|---|
| 15 | 16 | * permission to link this software with independent modules, and to copy and |
|---|
| 16 | 17 | * distribute the resulting executable under terms of your choice, provided that |
|---|
| .. | .. |
|---|
| 18 | 19 | * the license of that module. An independent module is a module which is not |
|---|
| 19 | 20 | * derived from this software. The special exception does not apply to any |
|---|
| 20 | 21 | * modifications of the software. |
|---|
| 21 | | - * |
|---|
| 22 | + * |
|---|
| 22 | 23 | * Notwithstanding the above, under no circumstances may you combine this |
|---|
| 23 | 24 | * software in any way with any other Broadcom software provided under a license |
|---|
| 24 | 25 | * other than the GPL, without Broadcom's express prior written consent. |
|---|
| .. | .. |
|---|
| 26 | 27 | * |
|---|
| 27 | 28 | * <<Broadcom-WL-IPTag/Open:>> |
|---|
| 28 | 29 | * |
|---|
| 29 | | - * $Id: sbhnddma.h 530150 2015-01-29 08:43:40Z $ |
|---|
| 30 | + * $Id: sbhnddma.h 694506 2017-04-13 05:10:05Z $ |
|---|
| 30 | 31 | */ |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | #ifndef _sbhnddma_h_ |
|---|
| .. | .. |
|---|
| 37 | 38 | * basic DMA register set is per channel(transmit or receive) |
|---|
| 38 | 39 | * a pair of channels is defined for convenience |
|---|
| 39 | 40 | */ |
|---|
| 40 | | - |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | /* 32 bits addressing */ |
|---|
| 43 | 43 | |
|---|
| .. | .. |
|---|
| 118 | 118 | #define DMA_PC_4 1 |
|---|
| 119 | 119 | #define DMA_PC_8 2 |
|---|
| 120 | 120 | #define DMA_PC_16 3 |
|---|
| 121 | +#define DMA_PC_32 4 |
|---|
| 121 | 122 | /* others: reserved */ |
|---|
| 122 | 123 | |
|---|
| 123 | 124 | /** Prefetch threshold */ |
|---|
| .. | .. |
|---|
| 125 | 126 | #define DMA_PT_2 1 |
|---|
| 126 | 127 | #define DMA_PT_4 2 |
|---|
| 127 | 128 | #define DMA_PT_8 3 |
|---|
| 129 | + |
|---|
| 130 | +/** Channel Switch */ |
|---|
| 131 | +#define DMA_CS_OFF 0 |
|---|
| 132 | +#define DMA_CS_ON 1 |
|---|
| 128 | 133 | |
|---|
| 129 | 134 | /* transmit descriptor table pointer */ |
|---|
| 130 | 135 | #define XP_LD_MASK 0xfff /**< last valid descriptor */ |
|---|
| .. | .. |
|---|
| 164 | 169 | #define RC_PC_SHIFT 21 |
|---|
| 165 | 170 | #define RC_PT_MASK 0x03000000 /**< Prefetch threshold */ |
|---|
| 166 | 171 | #define RC_PT_SHIFT 24 |
|---|
| 167 | | - |
|---|
| 172 | +#define RC_WAITCMP_MASK 0x00001000 |
|---|
| 173 | +#define RC_WAITCMP_SHIFT 12 |
|---|
| 168 | 174 | /* receive descriptor table pointer */ |
|---|
| 169 | 175 | #define RP_LD_MASK 0xfff /**< last valid descriptor */ |
|---|
| 170 | 176 | |
|---|
| .. | .. |
|---|
| 274 | 280 | #define D64_DEF_USBBURSTLEN 2 |
|---|
| 275 | 281 | #define D64_DEF_SDIOBURSTLEN 1 |
|---|
| 276 | 282 | |
|---|
| 277 | | - |
|---|
| 278 | 283 | #ifndef D64_USBBURSTLEN |
|---|
| 279 | 284 | #define D64_USBBURSTLEN DMA_BL_64 |
|---|
| 280 | | -#endif |
|---|
| 285 | +#endif // endif |
|---|
| 281 | 286 | #ifndef D64_SDIOBURSTLEN |
|---|
| 282 | 287 | #define D64_SDIOBURSTLEN DMA_BL_32 |
|---|
| 283 | | -#endif |
|---|
| 288 | +#endif // endif |
|---|
| 284 | 289 | |
|---|
| 285 | 290 | /* transmit channel control */ |
|---|
| 286 | 291 | #define D64_XC_XE 0x00000001 /**< transmit enable */ |
|---|
| .. | .. |
|---|
| 289 | 294 | #define D64_XC_FL 0x00000010 /**< flush request */ |
|---|
| 290 | 295 | #define D64_XC_MR_MASK 0x000001C0 /**< Multiple outstanding reads */ |
|---|
| 291 | 296 | #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 */ |
|---|
| 292 | 299 | #define D64_XC_PD 0x00000800 /**< parity check disable */ |
|---|
| 293 | 300 | #define D64_XC_AE 0x00030000 /**< address extension bits */ |
|---|
| 294 | 301 | #define D64_XC_AE_SHIFT 16 |
|---|
| .. | .. |
|---|
| 298 | 305 | #define D64_XC_PC_SHIFT 21 |
|---|
| 299 | 306 | #define D64_XC_PT_MASK 0x03000000 /**< Prefetch threshold */ |
|---|
| 300 | 307 | #define D64_XC_PT_SHIFT 24 |
|---|
| 308 | +#define D64_XC_CO_MASK 0x04000000 /**< coherent transactions for descriptors */ |
|---|
| 309 | +#define D64_XC_CO_SHIFT 26 |
|---|
| 301 | 310 | |
|---|
| 302 | 311 | /* transmit descriptor table pointer */ |
|---|
| 303 | 312 | #define D64_XP_LD_MASK 0x00001fff /**< last valid descriptor */ |
|---|
| .. | .. |
|---|
| 331 | 340 | #define D64_RC_SHIFT 9 /**< separate rx header descriptor enable */ |
|---|
| 332 | 341 | #define D64_RC_OC 0x00000400 /**< overflow continue */ |
|---|
| 333 | 342 | #define D64_RC_PD 0x00000800 /**< parity check disable */ |
|---|
| 343 | +#define D64_RC_WAITCMP_MASK 0x00001000 |
|---|
| 344 | +#define D64_RC_WAITCMP_SHIFT 12 |
|---|
| 334 | 345 | #define D64_RC_SA 0x00002000 /**< select active */ |
|---|
| 335 | 346 | #define D64_RC_GE 0x00004000 /**< Glom enable */ |
|---|
| 336 | 347 | #define D64_RC_AE 0x00030000 /**< address extension bits */ |
|---|
| .. | .. |
|---|
| 341 | 352 | #define D64_RC_PC_SHIFT 21 |
|---|
| 342 | 353 | #define D64_RC_PT_MASK 0x03000000 /**< Prefetch threshold */ |
|---|
| 343 | 354 | #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 |
|---|
| 344 | 359 | |
|---|
| 345 | 360 | /* flags for dma controller */ |
|---|
| 346 | 361 | #define DMA_CTRL_PEN (1 << 0) /**< partity enable */ |
|---|
| .. | .. |
|---|
| 351 | 366 | #define DMA_CTRL_DMA_AVOIDANCE_WAR (1 << 5) /**< DMA avoidance WAR for 4331 */ |
|---|
| 352 | 367 | #define DMA_CTRL_RXSINGLE (1 << 6) /**< always single buffer */ |
|---|
| 353 | 368 | #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 */ |
|---|
| 354 | 378 | |
|---|
| 355 | 379 | /* receive descriptor table pointer */ |
|---|
| 356 | 380 | #define D64_RP_LD_MASK 0x00001fff /**< last valid descriptor */ |
|---|
| .. | .. |
|---|
| 365 | 389 | #define D64_RS0_RS_STOPPED 0x30000000 /**< stopped */ |
|---|
| 366 | 390 | #define D64_RS0_RS_SUSP 0x40000000 /**< suspend pending */ |
|---|
| 367 | 391 | |
|---|
| 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 */ |
|---|
| 370 | 394 | #define D64_RS1_RE_SHIFT 28 |
|---|
| 371 | 395 | #define D64_RS1_RE_NOERR 0x00000000 /**< no error */ |
|---|
| 372 | 396 | #define D64_RS1_RE_DPO 0x10000000 /**< descriptor protocol error */ |
|---|
| .. | .. |
|---|
| 392 | 416 | |
|---|
| 393 | 417 | /* descriptor control flags 1 */ |
|---|
| 394 | 418 | #define D64_CTRL_COREFLAGS 0x0ff00000 /**< core specific flags */ |
|---|
| 419 | +#define D64_CTRL1_COHERENT ((uint32)1 << 17) /* cache coherent per transaction */ |
|---|
| 395 | 420 | #define D64_CTRL1_NOTPCIE ((uint32)1 << 18) /**< buirst size control */ |
|---|
| 396 | 421 | #define D64_CTRL1_EOT ((uint32)1 << 28) /**< end of descriptor table */ |
|---|
| 397 | 422 | #define D64_CTRL1_IOC ((uint32)1 << 29) /**< interrupt on completion */ |
|---|
| .. | .. |
|---|
| 399 | 424 | #define D64_CTRL1_SOF ((uint32)1 << 31) /**< start of frame */ |
|---|
| 400 | 425 | |
|---|
| 401 | 426 | /* 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 */ |
|---|
| 403 | 429 | #define D64_CTRL2_AE 0x00030000 /**< address extension bits */ |
|---|
| 404 | 430 | #define D64_CTRL2_AE_SHIFT 16 |
|---|
| 405 | 431 | #define D64_CTRL2_PARITY 0x00040000 /* parity bit */ |
|---|
| .. | .. |
|---|
| 410 | 436 | #define D64_RX_FRM_STS_LEN 0x0000ffff /**< frame length mask */ |
|---|
| 411 | 437 | #define D64_RX_FRM_STS_OVFL 0x00800000 /**< RxOverFlow */ |
|---|
| 412 | 438 | #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 */ |
|---|
| 413 | 440 | #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /**< core-dependent data type */ |
|---|
| 414 | 441 | |
|---|
| 442 | +#define BCM_D64_CTRL2_BOUND_DMA_LENGTH(len) \ |
|---|
| 443 | +(((len) > D64_CTRL2_MAX_LEN) ? D64_CTRL2_MAX_LEN : (len)) |
|---|
| 444 | + |
|---|
| 415 | 445 | /** receive frame status */ |
|---|
| 416 | 446 | typedef volatile struct { |
|---|
| 417 | 447 | uint16 len; |
|---|