18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008-2015 Freescale Semiconductor Inc. 38c2ecf20Sopenharmony_ci * Copyright 2020 NXP 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 68c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 78c2ecf20Sopenharmony_ci * * Redistributions of source code must retain the above copyright 88c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 98c2ecf20Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 108c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 118c2ecf20Sopenharmony_ci * documentation and/or other materials provided with the distribution. 128c2ecf20Sopenharmony_ci * * Neither the name of Freescale Semiconductor nor the 138c2ecf20Sopenharmony_ci * names of its contributors may be used to endorse or promote products 148c2ecf20Sopenharmony_ci * derived from this software without specific prior written permission. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * ALTERNATIVELY, this software may be distributed under the terms of the 188c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") as published by the Free Software 198c2ecf20Sopenharmony_ci * Foundation, either version 2 of that License or (at your option) any 208c2ecf20Sopenharmony_ci * later version. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 238c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 248c2ecf20Sopenharmony_ci * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 258c2ecf20Sopenharmony_ci * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 268c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 278c2ecf20Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 288c2ecf20Sopenharmony_ci * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 298c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 308c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 318c2ecf20Sopenharmony_ci * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#ifndef __FM_H 358c2ecf20Sopenharmony_ci#define __FM_H 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include <linux/io.h> 388c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 398c2ecf20Sopenharmony_ci#include <linux/of_irq.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* FM Frame descriptor macros */ 428c2ecf20Sopenharmony_ci/* Frame queue Context Override */ 438c2ecf20Sopenharmony_ci#define FM_FD_CMD_FCO 0x80000000 448c2ecf20Sopenharmony_ci#define FM_FD_CMD_RPD 0x40000000 /* Read Prepended Data */ 458c2ecf20Sopenharmony_ci#define FM_FD_CMD_UPD 0x20000000 /* Update Prepended Data */ 468c2ecf20Sopenharmony_ci#define FM_FD_CMD_DTC 0x10000000 /* Do L4 Checksum */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* TX-Port: Unsupported Format */ 498c2ecf20Sopenharmony_ci#define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000 508c2ecf20Sopenharmony_ci/* TX Port: Length Error */ 518c2ecf20Sopenharmony_ci#define FM_FD_ERR_LENGTH 0x02000000 528c2ecf20Sopenharmony_ci#define FM_FD_ERR_DMA 0x01000000 /* DMA Data error */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* IPR frame (not error) */ 558c2ecf20Sopenharmony_ci#define FM_FD_IPR 0x00000001 568c2ecf20Sopenharmony_ci/* IPR non-consistent-sp */ 578c2ecf20Sopenharmony_ci#define FM_FD_ERR_IPR_NCSP (0x00100000 | FM_FD_IPR) 588c2ecf20Sopenharmony_ci/* IPR error */ 598c2ecf20Sopenharmony_ci#define FM_FD_ERR_IPR (0x00200000 | FM_FD_IPR) 608c2ecf20Sopenharmony_ci/* IPR timeout */ 618c2ecf20Sopenharmony_ci#define FM_FD_ERR_IPR_TO (0x00300000 | FM_FD_IPR) 628c2ecf20Sopenharmony_ci/* TX Port: Length Error */ 638c2ecf20Sopenharmony_ci#define FM_FD_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Rx FIFO overflow, FCS error, code error, running disparity error 668c2ecf20Sopenharmony_ci * (SGMII and TBI modes), FIFO parity error. PHY Sequence error, 678c2ecf20Sopenharmony_ci * PHY error control character detected. 688c2ecf20Sopenharmony_ci */ 698c2ecf20Sopenharmony_ci#define FM_FD_ERR_PHYSICAL 0x00080000 708c2ecf20Sopenharmony_ci/* Frame too long OR Frame size exceeds max_length_frame */ 718c2ecf20Sopenharmony_ci#define FM_FD_ERR_SIZE 0x00040000 728c2ecf20Sopenharmony_ci/* classification discard */ 738c2ecf20Sopenharmony_ci#define FM_FD_ERR_CLS_DISCARD 0x00020000 748c2ecf20Sopenharmony_ci/* Extract Out of Frame */ 758c2ecf20Sopenharmony_ci#define FM_FD_ERR_EXTRACTION 0x00008000 768c2ecf20Sopenharmony_ci/* No Scheme Selected */ 778c2ecf20Sopenharmony_ci#define FM_FD_ERR_NO_SCHEME 0x00004000 788c2ecf20Sopenharmony_ci/* Keysize Overflow */ 798c2ecf20Sopenharmony_ci#define FM_FD_ERR_KEYSIZE_OVERFLOW 0x00002000 808c2ecf20Sopenharmony_ci/* Frame color is red */ 818c2ecf20Sopenharmony_ci#define FM_FD_ERR_COLOR_RED 0x00000800 828c2ecf20Sopenharmony_ci/* Frame color is yellow */ 838c2ecf20Sopenharmony_ci#define FM_FD_ERR_COLOR_YELLOW 0x00000400 848c2ecf20Sopenharmony_ci/* Parser Time out Exceed */ 858c2ecf20Sopenharmony_ci#define FM_FD_ERR_PRS_TIMEOUT 0x00000080 868c2ecf20Sopenharmony_ci/* Invalid Soft Parser instruction */ 878c2ecf20Sopenharmony_ci#define FM_FD_ERR_PRS_ILL_INSTRUCT 0x00000040 888c2ecf20Sopenharmony_ci/* Header error was identified during parsing */ 898c2ecf20Sopenharmony_ci#define FM_FD_ERR_PRS_HDR_ERR 0x00000020 908c2ecf20Sopenharmony_ci/* Frame parsed beyind 256 first bytes */ 918c2ecf20Sopenharmony_ci#define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* non Frame-Manager error */ 948c2ecf20Sopenharmony_ci#define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* FMan driver defines */ 978c2ecf20Sopenharmony_ci#define FMAN_BMI_FIFO_UNITS 0x100 988c2ecf20Sopenharmony_ci#define OFFSET_UNITS 16 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/* BMan defines */ 1018c2ecf20Sopenharmony_ci#define BM_MAX_NUM_OF_POOLS 64 /* Buffers pools */ 1028c2ecf20Sopenharmony_ci#define FMAN_PORT_MAX_EXT_POOLS_NUM 8 /* External BM pools per Rx port */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct fman; /* FMan data */ 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Enum for defining port types */ 1078c2ecf20Sopenharmony_cienum fman_port_type { 1088c2ecf20Sopenharmony_ci FMAN_PORT_TYPE_TX = 0, /* TX Port */ 1098c2ecf20Sopenharmony_ci FMAN_PORT_TYPE_RX, /* RX Port */ 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistruct fman_rev_info { 1138c2ecf20Sopenharmony_ci u8 major; /* Major revision */ 1148c2ecf20Sopenharmony_ci u8 minor; /* Minor revision */ 1158c2ecf20Sopenharmony_ci}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cienum fman_exceptions { 1188c2ecf20Sopenharmony_ci FMAN_EX_DMA_BUS_ERROR = 0, /* DMA bus error. */ 1198c2ecf20Sopenharmony_ci FMAN_EX_DMA_READ_ECC, /* Read Buffer ECC error */ 1208c2ecf20Sopenharmony_ci FMAN_EX_DMA_SYSTEM_WRITE_ECC, /* Write Buffer ECC err on sys side */ 1218c2ecf20Sopenharmony_ci FMAN_EX_DMA_FM_WRITE_ECC, /* Write Buffer ECC error on FM side */ 1228c2ecf20Sopenharmony_ci FMAN_EX_DMA_SINGLE_PORT_ECC, /* Single Port ECC error on FM side */ 1238c2ecf20Sopenharmony_ci FMAN_EX_FPM_STALL_ON_TASKS, /* Stall of tasks on FPM */ 1248c2ecf20Sopenharmony_ci FMAN_EX_FPM_SINGLE_ECC, /* Single ECC on FPM. */ 1258c2ecf20Sopenharmony_ci FMAN_EX_FPM_DOUBLE_ECC, /* Double ECC error on FPM ram access */ 1268c2ecf20Sopenharmony_ci FMAN_EX_QMI_SINGLE_ECC, /* Single ECC on QMI. */ 1278c2ecf20Sopenharmony_ci FMAN_EX_QMI_DOUBLE_ECC, /* Double bit ECC occurred on QMI */ 1288c2ecf20Sopenharmony_ci FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/* DeQ from unknown port id */ 1298c2ecf20Sopenharmony_ci FMAN_EX_BMI_LIST_RAM_ECC, /* Linked List RAM ECC error */ 1308c2ecf20Sopenharmony_ci FMAN_EX_BMI_STORAGE_PROFILE_ECC,/* storage profile */ 1318c2ecf20Sopenharmony_ci FMAN_EX_BMI_STATISTICS_RAM_ECC,/* Statistics RAM ECC Err Enable */ 1328c2ecf20Sopenharmony_ci FMAN_EX_BMI_DISPATCH_RAM_ECC, /* Dispatch RAM ECC Error Enable */ 1338c2ecf20Sopenharmony_ci FMAN_EX_IRAM_ECC, /* Double bit ECC occurred on IRAM */ 1348c2ecf20Sopenharmony_ci FMAN_EX_MURAM_ECC /* Double bit ECC occurred on MURAM */ 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* Parse results memory layout */ 1388c2ecf20Sopenharmony_cistruct fman_prs_result { 1398c2ecf20Sopenharmony_ci u8 lpid; /* Logical port id */ 1408c2ecf20Sopenharmony_ci u8 shimr; /* Shim header result */ 1418c2ecf20Sopenharmony_ci __be16 l2r; /* Layer 2 result */ 1428c2ecf20Sopenharmony_ci __be16 l3r; /* Layer 3 result */ 1438c2ecf20Sopenharmony_ci u8 l4r; /* Layer 4 result */ 1448c2ecf20Sopenharmony_ci u8 cplan; /* Classification plan id */ 1458c2ecf20Sopenharmony_ci __be16 nxthdr; /* Next Header */ 1468c2ecf20Sopenharmony_ci __be16 cksum; /* Running-sum */ 1478c2ecf20Sopenharmony_ci /* Flags&fragment-offset field of the last IP-header */ 1488c2ecf20Sopenharmony_ci __be16 flags_frag_off; 1498c2ecf20Sopenharmony_ci /* Routing type field of a IPV6 routing extension header */ 1508c2ecf20Sopenharmony_ci u8 route_type; 1518c2ecf20Sopenharmony_ci /* Routing Extension Header Present; last bit is IP valid */ 1528c2ecf20Sopenharmony_ci u8 rhp_ip_valid; 1538c2ecf20Sopenharmony_ci u8 shim_off[2]; /* Shim offset */ 1548c2ecf20Sopenharmony_ci u8 ip_pid_off; /* IP PID (last IP-proto) offset */ 1558c2ecf20Sopenharmony_ci u8 eth_off; /* ETH offset */ 1568c2ecf20Sopenharmony_ci u8 llc_snap_off; /* LLC_SNAP offset */ 1578c2ecf20Sopenharmony_ci u8 vlan_off[2]; /* VLAN offset */ 1588c2ecf20Sopenharmony_ci u8 etype_off; /* ETYPE offset */ 1598c2ecf20Sopenharmony_ci u8 pppoe_off; /* PPP offset */ 1608c2ecf20Sopenharmony_ci u8 mpls_off[2]; /* MPLS offset */ 1618c2ecf20Sopenharmony_ci u8 ip_off[2]; /* IP offset */ 1628c2ecf20Sopenharmony_ci u8 gre_off; /* GRE offset */ 1638c2ecf20Sopenharmony_ci u8 l4_off; /* Layer 4 offset */ 1648c2ecf20Sopenharmony_ci u8 nxthdr_off; /* Parser end point */ 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* A structure for defining buffer prefix area content. */ 1688c2ecf20Sopenharmony_cistruct fman_buffer_prefix_content { 1698c2ecf20Sopenharmony_ci /* Number of bytes to be left at the beginning of the external 1708c2ecf20Sopenharmony_ci * buffer; Note that the private-area will start from the base 1718c2ecf20Sopenharmony_ci * of the buffer address. 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci u16 priv_data_size; 1748c2ecf20Sopenharmony_ci /* true to pass the parse result to/from the FM; 1758c2ecf20Sopenharmony_ci * User may use FM_PORT_GetBufferPrsResult() in 1768c2ecf20Sopenharmony_ci * order to get the parser-result from a buffer. 1778c2ecf20Sopenharmony_ci */ 1788c2ecf20Sopenharmony_ci bool pass_prs_result; 1798c2ecf20Sopenharmony_ci /* true to pass the timeStamp to/from the FM User */ 1808c2ecf20Sopenharmony_ci bool pass_time_stamp; 1818c2ecf20Sopenharmony_ci /* true to pass the KG hash result to/from the FM User may 1828c2ecf20Sopenharmony_ci * use FM_PORT_GetBufferHashResult() in order to get the 1838c2ecf20Sopenharmony_ci * parser-result from a buffer. 1848c2ecf20Sopenharmony_ci */ 1858c2ecf20Sopenharmony_ci bool pass_hash_result; 1868c2ecf20Sopenharmony_ci /* Add all other Internal-Context information: AD, 1878c2ecf20Sopenharmony_ci * hash-result, key, etc. 1888c2ecf20Sopenharmony_ci */ 1898c2ecf20Sopenharmony_ci u16 data_align; 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci/* A structure of information about each of the external 1938c2ecf20Sopenharmony_ci * buffer pools used by a port or storage-profile. 1948c2ecf20Sopenharmony_ci */ 1958c2ecf20Sopenharmony_cistruct fman_ext_pool_params { 1968c2ecf20Sopenharmony_ci u8 id; /* External buffer pool id */ 1978c2ecf20Sopenharmony_ci u16 size; /* External buffer pool buffer size */ 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci/* A structure for informing the driver about the external 2018c2ecf20Sopenharmony_ci * buffer pools allocated in the BM and used by a port or a 2028c2ecf20Sopenharmony_ci * storage-profile. 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_cistruct fman_ext_pools { 2058c2ecf20Sopenharmony_ci u8 num_of_pools_used; /* Number of pools use by this port */ 2068c2ecf20Sopenharmony_ci struct fman_ext_pool_params ext_buf_pool[FMAN_PORT_MAX_EXT_POOLS_NUM]; 2078c2ecf20Sopenharmony_ci /* Parameters for each port */ 2088c2ecf20Sopenharmony_ci}; 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci/* A structure for defining BM pool depletion criteria */ 2118c2ecf20Sopenharmony_cistruct fman_buf_pool_depletion { 2128c2ecf20Sopenharmony_ci /* select mode in which pause frames will be sent after a 2138c2ecf20Sopenharmony_ci * number of pools (all together!) are depleted 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci bool pools_grp_mode_enable; 2168c2ecf20Sopenharmony_ci /* the number of depleted pools that will invoke pause 2178c2ecf20Sopenharmony_ci * frames transmission. 2188c2ecf20Sopenharmony_ci */ 2198c2ecf20Sopenharmony_ci u8 num_of_pools; 2208c2ecf20Sopenharmony_ci /* For each pool, true if it should be considered for 2218c2ecf20Sopenharmony_ci * depletion (Note - this pool must be used by this port!). 2228c2ecf20Sopenharmony_ci */ 2238c2ecf20Sopenharmony_ci bool pools_to_consider[BM_MAX_NUM_OF_POOLS]; 2248c2ecf20Sopenharmony_ci /* select mode in which pause frames will be sent 2258c2ecf20Sopenharmony_ci * after a single-pool is depleted; 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_ci bool single_pool_mode_enable; 2288c2ecf20Sopenharmony_ci /* For each pool, true if it should be considered 2298c2ecf20Sopenharmony_ci * for depletion (Note - this pool must be used by this port!) 2308c2ecf20Sopenharmony_ci */ 2318c2ecf20Sopenharmony_ci bool pools_to_consider_for_single_mode[BM_MAX_NUM_OF_POOLS]; 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci/* Enum for inter-module interrupts registration */ 2358c2ecf20Sopenharmony_cienum fman_event_modules { 2368c2ecf20Sopenharmony_ci FMAN_MOD_MAC = 0, /* MAC event */ 2378c2ecf20Sopenharmony_ci FMAN_MOD_FMAN_CTRL, /* FMAN Controller */ 2388c2ecf20Sopenharmony_ci FMAN_MOD_DUMMY_LAST 2398c2ecf20Sopenharmony_ci}; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci/* Enum for interrupts types */ 2428c2ecf20Sopenharmony_cienum fman_intr_type { 2438c2ecf20Sopenharmony_ci FMAN_INTR_TYPE_ERR, 2448c2ecf20Sopenharmony_ci FMAN_INTR_TYPE_NORMAL 2458c2ecf20Sopenharmony_ci}; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* Enum for inter-module interrupts registration */ 2488c2ecf20Sopenharmony_cienum fman_inter_module_event { 2498c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC0 = 0, /* MAC 0 error event */ 2508c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC1, /* MAC 1 error event */ 2518c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC2, /* MAC 2 error event */ 2528c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC3, /* MAC 3 error event */ 2538c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC4, /* MAC 4 error event */ 2548c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC5, /* MAC 5 error event */ 2558c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC6, /* MAC 6 error event */ 2568c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC7, /* MAC 7 error event */ 2578c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC8, /* MAC 8 error event */ 2588c2ecf20Sopenharmony_ci FMAN_EV_ERR_MAC9, /* MAC 9 error event */ 2598c2ecf20Sopenharmony_ci FMAN_EV_MAC0, /* MAC 0 event (Magic packet detection) */ 2608c2ecf20Sopenharmony_ci FMAN_EV_MAC1, /* MAC 1 event (Magic packet detection) */ 2618c2ecf20Sopenharmony_ci FMAN_EV_MAC2, /* MAC 2 (Magic packet detection) */ 2628c2ecf20Sopenharmony_ci FMAN_EV_MAC3, /* MAC 3 (Magic packet detection) */ 2638c2ecf20Sopenharmony_ci FMAN_EV_MAC4, /* MAC 4 (Magic packet detection) */ 2648c2ecf20Sopenharmony_ci FMAN_EV_MAC5, /* MAC 5 (Magic packet detection) */ 2658c2ecf20Sopenharmony_ci FMAN_EV_MAC6, /* MAC 6 (Magic packet detection) */ 2668c2ecf20Sopenharmony_ci FMAN_EV_MAC7, /* MAC 7 (Magic packet detection) */ 2678c2ecf20Sopenharmony_ci FMAN_EV_MAC8, /* MAC 8 event (Magic packet detection) */ 2688c2ecf20Sopenharmony_ci FMAN_EV_MAC9, /* MAC 9 event (Magic packet detection) */ 2698c2ecf20Sopenharmony_ci FMAN_EV_FMAN_CTRL_0, /* Fman controller event 0 */ 2708c2ecf20Sopenharmony_ci FMAN_EV_FMAN_CTRL_1, /* Fman controller event 1 */ 2718c2ecf20Sopenharmony_ci FMAN_EV_FMAN_CTRL_2, /* Fman controller event 2 */ 2728c2ecf20Sopenharmony_ci FMAN_EV_FMAN_CTRL_3, /* Fman controller event 3 */ 2738c2ecf20Sopenharmony_ci FMAN_EV_CNT 2748c2ecf20Sopenharmony_ci}; 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cistruct fman_intr_src { 2778c2ecf20Sopenharmony_ci void (*isr_cb)(void *src_arg); 2788c2ecf20Sopenharmony_ci void *src_handle; 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci/** fman_exceptions_cb 2828c2ecf20Sopenharmony_ci * fman - Pointer to FMan 2838c2ecf20Sopenharmony_ci * exception - The exception. 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * Exceptions user callback routine, will be called upon an exception 2868c2ecf20Sopenharmony_ci * passing the exception identification. 2878c2ecf20Sopenharmony_ci * 2888c2ecf20Sopenharmony_ci * Return: irq status 2898c2ecf20Sopenharmony_ci */ 2908c2ecf20Sopenharmony_citypedef irqreturn_t (fman_exceptions_cb)(struct fman *fman, 2918c2ecf20Sopenharmony_ci enum fman_exceptions exception); 2928c2ecf20Sopenharmony_ci/** fman_bus_error_cb 2938c2ecf20Sopenharmony_ci * fman - Pointer to FMan 2948c2ecf20Sopenharmony_ci * port_id - Port id 2958c2ecf20Sopenharmony_ci * addr - Address that caused the error 2968c2ecf20Sopenharmony_ci * tnum - Owner of error 2978c2ecf20Sopenharmony_ci * liodn - Logical IO device number 2988c2ecf20Sopenharmony_ci * 2998c2ecf20Sopenharmony_ci * Bus error user callback routine, will be called upon bus error, 3008c2ecf20Sopenharmony_ci * passing parameters describing the errors and the owner. 3018c2ecf20Sopenharmony_ci * 3028c2ecf20Sopenharmony_ci * Return: IRQ status 3038c2ecf20Sopenharmony_ci */ 3048c2ecf20Sopenharmony_citypedef irqreturn_t (fman_bus_error_cb)(struct fman *fman, u8 port_id, 3058c2ecf20Sopenharmony_ci u64 addr, u8 tnum, u16 liodn); 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci/* Structure that holds information received from device tree */ 3088c2ecf20Sopenharmony_cistruct fman_dts_params { 3098c2ecf20Sopenharmony_ci void __iomem *base_addr; /* FMan virtual address */ 3108c2ecf20Sopenharmony_ci struct resource *res; /* FMan memory resource */ 3118c2ecf20Sopenharmony_ci u8 id; /* FMan ID */ 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci int err_irq; /* FMan Error IRQ */ 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci u16 clk_freq; /* FMan clock freq (In Mhz) */ 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci u32 qman_channel_base; /* QMan channels base */ 3188c2ecf20Sopenharmony_ci u32 num_of_qman_channels; /* Number of QMan channels */ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci struct resource muram_res; /* MURAM resource */ 3218c2ecf20Sopenharmony_ci}; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_cistruct fman { 3248c2ecf20Sopenharmony_ci struct device *dev; 3258c2ecf20Sopenharmony_ci void __iomem *base_addr; 3268c2ecf20Sopenharmony_ci struct fman_intr_src intr_mng[FMAN_EV_CNT]; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci struct fman_fpm_regs __iomem *fpm_regs; 3298c2ecf20Sopenharmony_ci struct fman_bmi_regs __iomem *bmi_regs; 3308c2ecf20Sopenharmony_ci struct fman_qmi_regs __iomem *qmi_regs; 3318c2ecf20Sopenharmony_ci struct fman_dma_regs __iomem *dma_regs; 3328c2ecf20Sopenharmony_ci struct fman_hwp_regs __iomem *hwp_regs; 3338c2ecf20Sopenharmony_ci struct fman_kg_regs __iomem *kg_regs; 3348c2ecf20Sopenharmony_ci fman_exceptions_cb *exception_cb; 3358c2ecf20Sopenharmony_ci fman_bus_error_cb *bus_error_cb; 3368c2ecf20Sopenharmony_ci /* Spinlock for FMan use */ 3378c2ecf20Sopenharmony_ci spinlock_t spinlock; 3388c2ecf20Sopenharmony_ci struct fman_state_struct *state; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci struct fman_cfg *cfg; 3418c2ecf20Sopenharmony_ci struct muram_info *muram; 3428c2ecf20Sopenharmony_ci struct fman_keygen *keygen; 3438c2ecf20Sopenharmony_ci /* cam section in muram */ 3448c2ecf20Sopenharmony_ci unsigned long cam_offset; 3458c2ecf20Sopenharmony_ci size_t cam_size; 3468c2ecf20Sopenharmony_ci /* Fifo in MURAM */ 3478c2ecf20Sopenharmony_ci unsigned long fifo_offset; 3488c2ecf20Sopenharmony_ci size_t fifo_size; 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci u32 liodn_base[64]; 3518c2ecf20Sopenharmony_ci u32 liodn_offset[64]; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci struct fman_dts_params dts_params; 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci/* Structure for port-FM communication during fman_port_init. */ 3578c2ecf20Sopenharmony_cistruct fman_port_init_params { 3588c2ecf20Sopenharmony_ci u8 port_id; /* port Id */ 3598c2ecf20Sopenharmony_ci enum fman_port_type port_type; /* Port type */ 3608c2ecf20Sopenharmony_ci u16 port_speed; /* Port speed */ 3618c2ecf20Sopenharmony_ci u16 liodn_offset; /* Port's requested resource */ 3628c2ecf20Sopenharmony_ci u8 num_of_tasks; /* Port's requested resource */ 3638c2ecf20Sopenharmony_ci u8 num_of_extra_tasks; /* Port's requested resource */ 3648c2ecf20Sopenharmony_ci u8 num_of_open_dmas; /* Port's requested resource */ 3658c2ecf20Sopenharmony_ci u8 num_of_extra_open_dmas; /* Port's requested resource */ 3668c2ecf20Sopenharmony_ci u32 size_of_fifo; /* Port's requested resource */ 3678c2ecf20Sopenharmony_ci u32 extra_size_of_fifo; /* Port's requested resource */ 3688c2ecf20Sopenharmony_ci u8 deq_pipeline_depth; /* Port's requested resource */ 3698c2ecf20Sopenharmony_ci u16 max_frame_length; /* Port's max frame length. */ 3708c2ecf20Sopenharmony_ci u16 liodn_base; 3718c2ecf20Sopenharmony_ci /* LIODN base for this port, to be used together with LIODN offset. */ 3728c2ecf20Sopenharmony_ci}; 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_civoid fman_get_revision(struct fman *fman, struct fman_rev_info *rev_info); 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_civoid fman_register_intr(struct fman *fman, enum fman_event_modules mod, 3778c2ecf20Sopenharmony_ci u8 mod_id, enum fman_intr_type intr_type, 3788c2ecf20Sopenharmony_ci void (*f_isr)(void *h_src_arg), void *h_src_arg); 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_civoid fman_unregister_intr(struct fman *fman, enum fman_event_modules mod, 3818c2ecf20Sopenharmony_ci u8 mod_id, enum fman_intr_type intr_type); 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ciint fman_set_port_params(struct fman *fman, 3848c2ecf20Sopenharmony_ci struct fman_port_init_params *port_params); 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ciint fman_reset_mac(struct fman *fman, u8 mac_id); 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ciu16 fman_get_clock_freq(struct fman *fman); 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ciu32 fman_get_bmi_max_fifo_size(struct fman *fman); 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ciint fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ciu32 fman_get_qman_channel_id(struct fman *fman, u32 port_id); 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_cistruct resource *fman_get_mem_region(struct fman *fman); 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ciu16 fman_get_max_frm(void); 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ciint fman_get_rx_extra_headroom(void); 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci#ifdef CONFIG_DPAA_ERRATUM_A050385 4038c2ecf20Sopenharmony_cibool fman_has_errata_a050385(void); 4048c2ecf20Sopenharmony_ci#endif 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistruct fman *fman_bind(struct device *dev); 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci#endif /* __FM_H */ 409