18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2017 Microsemi Corporation
38c2ecf20Sopenharmony_ci */
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef _SOC_MSCC_OCELOT_H
68c2ecf20Sopenharmony_ci#define _SOC_MSCC_OCELOT_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h>
98c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h>
108c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
118c2ecf20Sopenharmony_ci#include <linux/regmap.h>
128c2ecf20Sopenharmony_ci#include <net/dsa.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* Port Group IDs (PGID) are masks of destination ports.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * For L2 forwarding, the switch performs 3 lookups in the PGID table for each
178c2ecf20Sopenharmony_ci * frame, and forwards the frame to the ports that are present in the logical
188c2ecf20Sopenharmony_ci * AND of all 3 PGIDs.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * These PGID lookups are:
218c2ecf20Sopenharmony_ci * - In one of PGID[0-63]: for the destination masks. There are 2 paths by
228c2ecf20Sopenharmony_ci *   which the switch selects a destination PGID:
238c2ecf20Sopenharmony_ci *     - The {DMAC, VID} is present in the MAC table. In that case, the
248c2ecf20Sopenharmony_ci *       destination PGID is given by the DEST_IDX field of the MAC table entry
258c2ecf20Sopenharmony_ci *       that matched.
268c2ecf20Sopenharmony_ci *     - The {DMAC, VID} is not present in the MAC table (it is unknown). The
278c2ecf20Sopenharmony_ci *       frame is disseminated as being either unicast, multicast or broadcast,
288c2ecf20Sopenharmony_ci *       and according to that, the destination PGID is chosen as being the
298c2ecf20Sopenharmony_ci *       value contained by ANA_FLOODING_FLD_UNICAST,
308c2ecf20Sopenharmony_ci *       ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST.
318c2ecf20Sopenharmony_ci *   The destination PGID can be an unicast set: the first PGIDs, 0 to
328c2ecf20Sopenharmony_ci *   ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from
338c2ecf20Sopenharmony_ci *   ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to
348c2ecf20Sopenharmony_ci *   a physical port and has a single bit set in the destination ports mask:
358c2ecf20Sopenharmony_ci *   that corresponding to the port number itself. In contrast, a multicast
368c2ecf20Sopenharmony_ci *   PGID will have potentially more than one single bit set in the destination
378c2ecf20Sopenharmony_ci *   ports mask.
388c2ecf20Sopenharmony_ci * - In one of PGID[64-79]: for the aggregation mask. The switch classifier
398c2ecf20Sopenharmony_ci *   dissects each frame and generates a 4-bit Link Aggregation Code which is
408c2ecf20Sopenharmony_ci *   used for this second PGID table lookup. The goal of link aggregation is to
418c2ecf20Sopenharmony_ci *   hash multiple flows within the same LAG on to different destination ports.
428c2ecf20Sopenharmony_ci *   The first lookup will result in a PGID with all the LAG members present in
438c2ecf20Sopenharmony_ci *   the destination ports mask, and the second lookup, by Link Aggregation
448c2ecf20Sopenharmony_ci *   Code, will ensure that each flow gets forwarded only to a single port out
458c2ecf20Sopenharmony_ci *   of that mask (there are no duplicates).
468c2ecf20Sopenharmony_ci * - In one of PGID[80-90]: for the source mask. The third time, the PGID table
478c2ecf20Sopenharmony_ci *   is indexed with the ingress port (plus 80). These PGIDs answer the
488c2ecf20Sopenharmony_ci *   question "is port i allowed to forward traffic to port j?" If yes, then
498c2ecf20Sopenharmony_ci *   BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used
508c2ecf20Sopenharmony_ci *   to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge.
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Reserve some destination PGIDs at the end of the range:
548c2ecf20Sopenharmony_ci * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
558c2ecf20Sopenharmony_ci *           of the switch port net devices, towards the CPU port module.
568c2ecf20Sopenharmony_ci * PGID_UC: the flooding destinations for unknown unicast traffic.
578c2ecf20Sopenharmony_ci * PGID_MC: the flooding destinations for broadcast and non-IP multicast
588c2ecf20Sopenharmony_ci *          traffic.
598c2ecf20Sopenharmony_ci * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic.
608c2ecf20Sopenharmony_ci * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#define PGID_CPU			59
638c2ecf20Sopenharmony_ci#define PGID_UC				60
648c2ecf20Sopenharmony_ci#define PGID_MC				61
658c2ecf20Sopenharmony_ci#define PGID_MCIPV4			62
668c2ecf20Sopenharmony_ci#define PGID_MCIPV6			63
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define for_each_unicast_dest_pgid(ocelot, pgid)		\
698c2ecf20Sopenharmony_ci	for ((pgid) = 0;					\
708c2ecf20Sopenharmony_ci	     (pgid) < (ocelot)->num_phys_ports;			\
718c2ecf20Sopenharmony_ci	     (pgid)++)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid)	\
748c2ecf20Sopenharmony_ci	for ((pgid) = (ocelot)->num_phys_ports + 1;		\
758c2ecf20Sopenharmony_ci	     (pgid) < PGID_CPU;					\
768c2ecf20Sopenharmony_ci	     (pgid)++)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define for_each_aggr_pgid(ocelot, pgid)			\
798c2ecf20Sopenharmony_ci	for ((pgid) = PGID_AGGR;				\
808c2ecf20Sopenharmony_ci	     (pgid) < PGID_SRC;					\
818c2ecf20Sopenharmony_ci	     (pgid)++)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* Aggregation PGIDs, one per Link Aggregation Code */
848c2ecf20Sopenharmony_ci#define PGID_AGGR			64
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* Source PGIDs, one per physical port */
878c2ecf20Sopenharmony_ci#define PGID_SRC			80
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define IFH_INJ_BYPASS			BIT(31)
908c2ecf20Sopenharmony_ci#define IFH_INJ_POP_CNT_DISABLE		(3 << 28)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define IFH_TAG_TYPE_C			0
938c2ecf20Sopenharmony_ci#define IFH_TAG_TYPE_S			1
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define IFH_REW_OP_NOOP			0x0
968c2ecf20Sopenharmony_ci#define IFH_REW_OP_DSCP			0x1
978c2ecf20Sopenharmony_ci#define IFH_REW_OP_ONE_STEP_PTP		0x2
988c2ecf20Sopenharmony_ci#define IFH_REW_OP_TWO_STEP_PTP		0x3
998c2ecf20Sopenharmony_ci#define IFH_REW_OP_ORIGIN_PTP		0x5
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define OCELOT_TAG_LEN			16
1028c2ecf20Sopenharmony_ci#define OCELOT_SHORT_PREFIX_LEN		4
1038c2ecf20Sopenharmony_ci#define OCELOT_LONG_PREFIX_LEN		16
1048c2ecf20Sopenharmony_ci#define OCELOT_TOTAL_TAG_LEN	(OCELOT_SHORT_PREFIX_LEN + OCELOT_TAG_LEN)
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#define OCELOT_SPEED_2500		0
1078c2ecf20Sopenharmony_ci#define OCELOT_SPEED_1000		1
1088c2ecf20Sopenharmony_ci#define OCELOT_SPEED_100		2
1098c2ecf20Sopenharmony_ci#define OCELOT_SPEED_10			3
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define OCELOT_PTP_PINS_NUM		4
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#define TARGET_OFFSET			24
1148c2ecf20Sopenharmony_ci#define REG_MASK			GENMASK(TARGET_OFFSET - 1, 0)
1158c2ecf20Sopenharmony_ci#define REG(reg, offset)		[reg & REG_MASK] = offset
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define REG_RESERVED_ADDR		0xffffffff
1188c2ecf20Sopenharmony_ci#define REG_RESERVED(reg)		REG(reg, REG_RESERVED_ADDR)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_cienum ocelot_target {
1218c2ecf20Sopenharmony_ci	ANA = 1,
1228c2ecf20Sopenharmony_ci	QS,
1238c2ecf20Sopenharmony_ci	QSYS,
1248c2ecf20Sopenharmony_ci	REW,
1258c2ecf20Sopenharmony_ci	SYS,
1268c2ecf20Sopenharmony_ci	S0,
1278c2ecf20Sopenharmony_ci	S1,
1288c2ecf20Sopenharmony_ci	S2,
1298c2ecf20Sopenharmony_ci	HSIO,
1308c2ecf20Sopenharmony_ci	PTP,
1318c2ecf20Sopenharmony_ci	GCB,
1328c2ecf20Sopenharmony_ci	DEV_GMII,
1338c2ecf20Sopenharmony_ci	TARGET_MAX,
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_cienum ocelot_reg {
1378c2ecf20Sopenharmony_ci	ANA_ADVLEARN = ANA << TARGET_OFFSET,
1388c2ecf20Sopenharmony_ci	ANA_VLANMASK,
1398c2ecf20Sopenharmony_ci	ANA_PORT_B_DOMAIN,
1408c2ecf20Sopenharmony_ci	ANA_ANAGEFIL,
1418c2ecf20Sopenharmony_ci	ANA_ANEVENTS,
1428c2ecf20Sopenharmony_ci	ANA_STORMLIMIT_BURST,
1438c2ecf20Sopenharmony_ci	ANA_STORMLIMIT_CFG,
1448c2ecf20Sopenharmony_ci	ANA_ISOLATED_PORTS,
1458c2ecf20Sopenharmony_ci	ANA_COMMUNITY_PORTS,
1468c2ecf20Sopenharmony_ci	ANA_AUTOAGE,
1478c2ecf20Sopenharmony_ci	ANA_MACTOPTIONS,
1488c2ecf20Sopenharmony_ci	ANA_LEARNDISC,
1498c2ecf20Sopenharmony_ci	ANA_AGENCTRL,
1508c2ecf20Sopenharmony_ci	ANA_MIRRORPORTS,
1518c2ecf20Sopenharmony_ci	ANA_EMIRRORPORTS,
1528c2ecf20Sopenharmony_ci	ANA_FLOODING,
1538c2ecf20Sopenharmony_ci	ANA_FLOODING_IPMC,
1548c2ecf20Sopenharmony_ci	ANA_SFLOW_CFG,
1558c2ecf20Sopenharmony_ci	ANA_PORT_MODE,
1568c2ecf20Sopenharmony_ci	ANA_CUT_THRU_CFG,
1578c2ecf20Sopenharmony_ci	ANA_PGID_PGID,
1588c2ecf20Sopenharmony_ci	ANA_TABLES_ANMOVED,
1598c2ecf20Sopenharmony_ci	ANA_TABLES_MACHDATA,
1608c2ecf20Sopenharmony_ci	ANA_TABLES_MACLDATA,
1618c2ecf20Sopenharmony_ci	ANA_TABLES_STREAMDATA,
1628c2ecf20Sopenharmony_ci	ANA_TABLES_MACACCESS,
1638c2ecf20Sopenharmony_ci	ANA_TABLES_MACTINDX,
1648c2ecf20Sopenharmony_ci	ANA_TABLES_VLANACCESS,
1658c2ecf20Sopenharmony_ci	ANA_TABLES_VLANTIDX,
1668c2ecf20Sopenharmony_ci	ANA_TABLES_ISDXACCESS,
1678c2ecf20Sopenharmony_ci	ANA_TABLES_ISDXTIDX,
1688c2ecf20Sopenharmony_ci	ANA_TABLES_ENTRYLIM,
1698c2ecf20Sopenharmony_ci	ANA_TABLES_PTP_ID_HIGH,
1708c2ecf20Sopenharmony_ci	ANA_TABLES_PTP_ID_LOW,
1718c2ecf20Sopenharmony_ci	ANA_TABLES_STREAMACCESS,
1728c2ecf20Sopenharmony_ci	ANA_TABLES_STREAMTIDX,
1738c2ecf20Sopenharmony_ci	ANA_TABLES_SEQ_HISTORY,
1748c2ecf20Sopenharmony_ci	ANA_TABLES_SEQ_MASK,
1758c2ecf20Sopenharmony_ci	ANA_TABLES_SFID_MASK,
1768c2ecf20Sopenharmony_ci	ANA_TABLES_SFIDACCESS,
1778c2ecf20Sopenharmony_ci	ANA_TABLES_SFIDTIDX,
1788c2ecf20Sopenharmony_ci	ANA_MSTI_STATE,
1798c2ecf20Sopenharmony_ci	ANA_OAM_UPM_LM_CNT,
1808c2ecf20Sopenharmony_ci	ANA_SG_ACCESS_CTRL,
1818c2ecf20Sopenharmony_ci	ANA_SG_CONFIG_REG_1,
1828c2ecf20Sopenharmony_ci	ANA_SG_CONFIG_REG_2,
1838c2ecf20Sopenharmony_ci	ANA_SG_CONFIG_REG_3,
1848c2ecf20Sopenharmony_ci	ANA_SG_CONFIG_REG_4,
1858c2ecf20Sopenharmony_ci	ANA_SG_CONFIG_REG_5,
1868c2ecf20Sopenharmony_ci	ANA_SG_GCL_GS_CONFIG,
1878c2ecf20Sopenharmony_ci	ANA_SG_GCL_TI_CONFIG,
1888c2ecf20Sopenharmony_ci	ANA_SG_STATUS_REG_1,
1898c2ecf20Sopenharmony_ci	ANA_SG_STATUS_REG_2,
1908c2ecf20Sopenharmony_ci	ANA_SG_STATUS_REG_3,
1918c2ecf20Sopenharmony_ci	ANA_PORT_VLAN_CFG,
1928c2ecf20Sopenharmony_ci	ANA_PORT_DROP_CFG,
1938c2ecf20Sopenharmony_ci	ANA_PORT_QOS_CFG,
1948c2ecf20Sopenharmony_ci	ANA_PORT_VCAP_CFG,
1958c2ecf20Sopenharmony_ci	ANA_PORT_VCAP_S1_KEY_CFG,
1968c2ecf20Sopenharmony_ci	ANA_PORT_VCAP_S2_CFG,
1978c2ecf20Sopenharmony_ci	ANA_PORT_PCP_DEI_MAP,
1988c2ecf20Sopenharmony_ci	ANA_PORT_CPU_FWD_CFG,
1998c2ecf20Sopenharmony_ci	ANA_PORT_CPU_FWD_BPDU_CFG,
2008c2ecf20Sopenharmony_ci	ANA_PORT_CPU_FWD_GARP_CFG,
2018c2ecf20Sopenharmony_ci	ANA_PORT_CPU_FWD_CCM_CFG,
2028c2ecf20Sopenharmony_ci	ANA_PORT_PORT_CFG,
2038c2ecf20Sopenharmony_ci	ANA_PORT_POL_CFG,
2048c2ecf20Sopenharmony_ci	ANA_PORT_PTP_CFG,
2058c2ecf20Sopenharmony_ci	ANA_PORT_PTP_DLY1_CFG,
2068c2ecf20Sopenharmony_ci	ANA_PORT_PTP_DLY2_CFG,
2078c2ecf20Sopenharmony_ci	ANA_PORT_SFID_CFG,
2088c2ecf20Sopenharmony_ci	ANA_PFC_PFC_CFG,
2098c2ecf20Sopenharmony_ci	ANA_PFC_PFC_TIMER,
2108c2ecf20Sopenharmony_ci	ANA_IPT_OAM_MEP_CFG,
2118c2ecf20Sopenharmony_ci	ANA_IPT_IPT,
2128c2ecf20Sopenharmony_ci	ANA_PPT_PPT,
2138c2ecf20Sopenharmony_ci	ANA_FID_MAP_FID_MAP,
2148c2ecf20Sopenharmony_ci	ANA_AGGR_CFG,
2158c2ecf20Sopenharmony_ci	ANA_CPUQ_CFG,
2168c2ecf20Sopenharmony_ci	ANA_CPUQ_CFG2,
2178c2ecf20Sopenharmony_ci	ANA_CPUQ_8021_CFG,
2188c2ecf20Sopenharmony_ci	ANA_DSCP_CFG,
2198c2ecf20Sopenharmony_ci	ANA_DSCP_REWR_CFG,
2208c2ecf20Sopenharmony_ci	ANA_VCAP_RNG_TYPE_CFG,
2218c2ecf20Sopenharmony_ci	ANA_VCAP_RNG_VAL_CFG,
2228c2ecf20Sopenharmony_ci	ANA_VRAP_CFG,
2238c2ecf20Sopenharmony_ci	ANA_VRAP_HDR_DATA,
2248c2ecf20Sopenharmony_ci	ANA_VRAP_HDR_MASK,
2258c2ecf20Sopenharmony_ci	ANA_DISCARD_CFG,
2268c2ecf20Sopenharmony_ci	ANA_FID_CFG,
2278c2ecf20Sopenharmony_ci	ANA_POL_PIR_CFG,
2288c2ecf20Sopenharmony_ci	ANA_POL_CIR_CFG,
2298c2ecf20Sopenharmony_ci	ANA_POL_MODE_CFG,
2308c2ecf20Sopenharmony_ci	ANA_POL_PIR_STATE,
2318c2ecf20Sopenharmony_ci	ANA_POL_CIR_STATE,
2328c2ecf20Sopenharmony_ci	ANA_POL_STATE,
2338c2ecf20Sopenharmony_ci	ANA_POL_FLOWC,
2348c2ecf20Sopenharmony_ci	ANA_POL_HYST,
2358c2ecf20Sopenharmony_ci	ANA_POL_MISC_CFG,
2368c2ecf20Sopenharmony_ci	QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
2378c2ecf20Sopenharmony_ci	QS_XTR_RD,
2388c2ecf20Sopenharmony_ci	QS_XTR_FRM_PRUNING,
2398c2ecf20Sopenharmony_ci	QS_XTR_FLUSH,
2408c2ecf20Sopenharmony_ci	QS_XTR_DATA_PRESENT,
2418c2ecf20Sopenharmony_ci	QS_XTR_CFG,
2428c2ecf20Sopenharmony_ci	QS_INJ_GRP_CFG,
2438c2ecf20Sopenharmony_ci	QS_INJ_WR,
2448c2ecf20Sopenharmony_ci	QS_INJ_CTRL,
2458c2ecf20Sopenharmony_ci	QS_INJ_STATUS,
2468c2ecf20Sopenharmony_ci	QS_INJ_ERR,
2478c2ecf20Sopenharmony_ci	QS_INH_DBG,
2488c2ecf20Sopenharmony_ci	QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
2498c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE,
2508c2ecf20Sopenharmony_ci	QSYS_STAT_CNT_CFG,
2518c2ecf20Sopenharmony_ci	QSYS_EEE_CFG,
2528c2ecf20Sopenharmony_ci	QSYS_EEE_THRES,
2538c2ecf20Sopenharmony_ci	QSYS_IGR_NO_SHARING,
2548c2ecf20Sopenharmony_ci	QSYS_EGR_NO_SHARING,
2558c2ecf20Sopenharmony_ci	QSYS_SW_STATUS,
2568c2ecf20Sopenharmony_ci	QSYS_EXT_CPU_CFG,
2578c2ecf20Sopenharmony_ci	QSYS_PAD_CFG,
2588c2ecf20Sopenharmony_ci	QSYS_CPU_GROUP_MAP,
2598c2ecf20Sopenharmony_ci	QSYS_QMAP,
2608c2ecf20Sopenharmony_ci	QSYS_ISDX_SGRP,
2618c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY,
2628c2ecf20Sopenharmony_ci	QSYS_TFRM_MISC,
2638c2ecf20Sopenharmony_ci	QSYS_TFRM_PORT_DLY,
2648c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_1,
2658c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_2,
2668c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_3,
2678c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_4,
2688c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_5,
2698c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_6,
2708c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_7,
2718c2ecf20Sopenharmony_ci	QSYS_TFRM_TIMER_CFG_8,
2728c2ecf20Sopenharmony_ci	QSYS_RED_PROFILE,
2738c2ecf20Sopenharmony_ci	QSYS_RES_QOS_MODE,
2748c2ecf20Sopenharmony_ci	QSYS_RES_CFG,
2758c2ecf20Sopenharmony_ci	QSYS_RES_STAT,
2768c2ecf20Sopenharmony_ci	QSYS_EGR_DROP_MODE,
2778c2ecf20Sopenharmony_ci	QSYS_EQ_CTRL,
2788c2ecf20Sopenharmony_ci	QSYS_EVENTS_CORE,
2798c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_0,
2808c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_1,
2818c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_2,
2828c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_3,
2838c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_4,
2848c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_5,
2858c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_6,
2868c2ecf20Sopenharmony_ci	QSYS_QMAXSDU_CFG_7,
2878c2ecf20Sopenharmony_ci	QSYS_PREEMPTION_CFG,
2888c2ecf20Sopenharmony_ci	QSYS_CIR_CFG,
2898c2ecf20Sopenharmony_ci	QSYS_EIR_CFG,
2908c2ecf20Sopenharmony_ci	QSYS_SE_CFG,
2918c2ecf20Sopenharmony_ci	QSYS_SE_DWRR_CFG,
2928c2ecf20Sopenharmony_ci	QSYS_SE_CONNECT,
2938c2ecf20Sopenharmony_ci	QSYS_SE_DLB_SENSE,
2948c2ecf20Sopenharmony_ci	QSYS_CIR_STATE,
2958c2ecf20Sopenharmony_ci	QSYS_EIR_STATE,
2968c2ecf20Sopenharmony_ci	QSYS_SE_STATE,
2978c2ecf20Sopenharmony_ci	QSYS_HSCH_MISC_CFG,
2988c2ecf20Sopenharmony_ci	QSYS_TAG_CONFIG,
2998c2ecf20Sopenharmony_ci	QSYS_TAS_PARAM_CFG_CTRL,
3008c2ecf20Sopenharmony_ci	QSYS_PORT_MAX_SDU,
3018c2ecf20Sopenharmony_ci	QSYS_PARAM_CFG_REG_1,
3028c2ecf20Sopenharmony_ci	QSYS_PARAM_CFG_REG_2,
3038c2ecf20Sopenharmony_ci	QSYS_PARAM_CFG_REG_3,
3048c2ecf20Sopenharmony_ci	QSYS_PARAM_CFG_REG_4,
3058c2ecf20Sopenharmony_ci	QSYS_PARAM_CFG_REG_5,
3068c2ecf20Sopenharmony_ci	QSYS_GCL_CFG_REG_1,
3078c2ecf20Sopenharmony_ci	QSYS_GCL_CFG_REG_2,
3088c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_1,
3098c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_2,
3108c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_3,
3118c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_4,
3128c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_5,
3138c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_6,
3148c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_7,
3158c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_8,
3168c2ecf20Sopenharmony_ci	QSYS_PARAM_STATUS_REG_9,
3178c2ecf20Sopenharmony_ci	QSYS_GCL_STATUS_REG_1,
3188c2ecf20Sopenharmony_ci	QSYS_GCL_STATUS_REG_2,
3198c2ecf20Sopenharmony_ci	REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
3208c2ecf20Sopenharmony_ci	REW_TAG_CFG,
3218c2ecf20Sopenharmony_ci	REW_PORT_CFG,
3228c2ecf20Sopenharmony_ci	REW_DSCP_CFG,
3238c2ecf20Sopenharmony_ci	REW_PCP_DEI_QOS_MAP_CFG,
3248c2ecf20Sopenharmony_ci	REW_PTP_CFG,
3258c2ecf20Sopenharmony_ci	REW_PTP_DLY1_CFG,
3268c2ecf20Sopenharmony_ci	REW_RED_TAG_CFG,
3278c2ecf20Sopenharmony_ci	REW_DSCP_REMAP_DP1_CFG,
3288c2ecf20Sopenharmony_ci	REW_DSCP_REMAP_CFG,
3298c2ecf20Sopenharmony_ci	REW_STAT_CFG,
3308c2ecf20Sopenharmony_ci	REW_REW_STICKY,
3318c2ecf20Sopenharmony_ci	REW_PPT,
3328c2ecf20Sopenharmony_ci	SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
3338c2ecf20Sopenharmony_ci	SYS_COUNT_RX_UNICAST,
3348c2ecf20Sopenharmony_ci	SYS_COUNT_RX_MULTICAST,
3358c2ecf20Sopenharmony_ci	SYS_COUNT_RX_BROADCAST,
3368c2ecf20Sopenharmony_ci	SYS_COUNT_RX_SHORTS,
3378c2ecf20Sopenharmony_ci	SYS_COUNT_RX_FRAGMENTS,
3388c2ecf20Sopenharmony_ci	SYS_COUNT_RX_JABBERS,
3398c2ecf20Sopenharmony_ci	SYS_COUNT_RX_CRC_ALIGN_ERRS,
3408c2ecf20Sopenharmony_ci	SYS_COUNT_RX_SYM_ERRS,
3418c2ecf20Sopenharmony_ci	SYS_COUNT_RX_64,
3428c2ecf20Sopenharmony_ci	SYS_COUNT_RX_65_127,
3438c2ecf20Sopenharmony_ci	SYS_COUNT_RX_128_255,
3448c2ecf20Sopenharmony_ci	SYS_COUNT_RX_256_1023,
3458c2ecf20Sopenharmony_ci	SYS_COUNT_RX_1024_1526,
3468c2ecf20Sopenharmony_ci	SYS_COUNT_RX_1527_MAX,
3478c2ecf20Sopenharmony_ci	SYS_COUNT_RX_PAUSE,
3488c2ecf20Sopenharmony_ci	SYS_COUNT_RX_CONTROL,
3498c2ecf20Sopenharmony_ci	SYS_COUNT_RX_LONGS,
3508c2ecf20Sopenharmony_ci	SYS_COUNT_RX_CLASSIFIED_DROPS,
3518c2ecf20Sopenharmony_ci	SYS_COUNT_TX_OCTETS,
3528c2ecf20Sopenharmony_ci	SYS_COUNT_TX_UNICAST,
3538c2ecf20Sopenharmony_ci	SYS_COUNT_TX_MULTICAST,
3548c2ecf20Sopenharmony_ci	SYS_COUNT_TX_BROADCAST,
3558c2ecf20Sopenharmony_ci	SYS_COUNT_TX_COLLISION,
3568c2ecf20Sopenharmony_ci	SYS_COUNT_TX_DROPS,
3578c2ecf20Sopenharmony_ci	SYS_COUNT_TX_PAUSE,
3588c2ecf20Sopenharmony_ci	SYS_COUNT_TX_64,
3598c2ecf20Sopenharmony_ci	SYS_COUNT_TX_65_127,
3608c2ecf20Sopenharmony_ci	SYS_COUNT_TX_128_511,
3618c2ecf20Sopenharmony_ci	SYS_COUNT_TX_512_1023,
3628c2ecf20Sopenharmony_ci	SYS_COUNT_TX_1024_1526,
3638c2ecf20Sopenharmony_ci	SYS_COUNT_TX_1527_MAX,
3648c2ecf20Sopenharmony_ci	SYS_COUNT_TX_AGING,
3658c2ecf20Sopenharmony_ci	SYS_RESET_CFG,
3668c2ecf20Sopenharmony_ci	SYS_SR_ETYPE_CFG,
3678c2ecf20Sopenharmony_ci	SYS_VLAN_ETYPE_CFG,
3688c2ecf20Sopenharmony_ci	SYS_PORT_MODE,
3698c2ecf20Sopenharmony_ci	SYS_FRONT_PORT_MODE,
3708c2ecf20Sopenharmony_ci	SYS_FRM_AGING,
3718c2ecf20Sopenharmony_ci	SYS_STAT_CFG,
3728c2ecf20Sopenharmony_ci	SYS_SW_STATUS,
3738c2ecf20Sopenharmony_ci	SYS_MISC_CFG,
3748c2ecf20Sopenharmony_ci	SYS_REW_MAC_HIGH_CFG,
3758c2ecf20Sopenharmony_ci	SYS_REW_MAC_LOW_CFG,
3768c2ecf20Sopenharmony_ci	SYS_TIMESTAMP_OFFSET,
3778c2ecf20Sopenharmony_ci	SYS_CMID,
3788c2ecf20Sopenharmony_ci	SYS_PAUSE_CFG,
3798c2ecf20Sopenharmony_ci	SYS_PAUSE_TOT_CFG,
3808c2ecf20Sopenharmony_ci	SYS_ATOP,
3818c2ecf20Sopenharmony_ci	SYS_ATOP_TOT_CFG,
3828c2ecf20Sopenharmony_ci	SYS_MAC_FC_CFG,
3838c2ecf20Sopenharmony_ci	SYS_MMGT,
3848c2ecf20Sopenharmony_ci	SYS_MMGT_FAST,
3858c2ecf20Sopenharmony_ci	SYS_EVENTS_DIF,
3868c2ecf20Sopenharmony_ci	SYS_EVENTS_CORE,
3878c2ecf20Sopenharmony_ci	SYS_CNT,
3888c2ecf20Sopenharmony_ci	SYS_PTP_STATUS,
3898c2ecf20Sopenharmony_ci	SYS_PTP_TXSTAMP,
3908c2ecf20Sopenharmony_ci	SYS_PTP_NXT,
3918c2ecf20Sopenharmony_ci	SYS_PTP_CFG,
3928c2ecf20Sopenharmony_ci	SYS_RAM_INIT,
3938c2ecf20Sopenharmony_ci	SYS_CM_ADDR,
3948c2ecf20Sopenharmony_ci	SYS_CM_DATA_WR,
3958c2ecf20Sopenharmony_ci	SYS_CM_DATA_RD,
3968c2ecf20Sopenharmony_ci	SYS_CM_OP,
3978c2ecf20Sopenharmony_ci	SYS_CM_DATA,
3988c2ecf20Sopenharmony_ci	PTP_PIN_CFG = PTP << TARGET_OFFSET,
3998c2ecf20Sopenharmony_ci	PTP_PIN_TOD_SEC_MSB,
4008c2ecf20Sopenharmony_ci	PTP_PIN_TOD_SEC_LSB,
4018c2ecf20Sopenharmony_ci	PTP_PIN_TOD_NSEC,
4028c2ecf20Sopenharmony_ci	PTP_PIN_WF_HIGH_PERIOD,
4038c2ecf20Sopenharmony_ci	PTP_PIN_WF_LOW_PERIOD,
4048c2ecf20Sopenharmony_ci	PTP_CFG_MISC,
4058c2ecf20Sopenharmony_ci	PTP_CLK_CFG_ADJ_CFG,
4068c2ecf20Sopenharmony_ci	PTP_CLK_CFG_ADJ_FREQ,
4078c2ecf20Sopenharmony_ci	GCB_SOFT_RST = GCB << TARGET_OFFSET,
4088c2ecf20Sopenharmony_ci	GCB_MIIM_MII_STATUS,
4098c2ecf20Sopenharmony_ci	GCB_MIIM_MII_CMD,
4108c2ecf20Sopenharmony_ci	GCB_MIIM_MII_DATA,
4118c2ecf20Sopenharmony_ci	DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET,
4128c2ecf20Sopenharmony_ci	DEV_PORT_MISC,
4138c2ecf20Sopenharmony_ci	DEV_EVENTS,
4148c2ecf20Sopenharmony_ci	DEV_EEE_CFG,
4158c2ecf20Sopenharmony_ci	DEV_RX_PATH_DELAY,
4168c2ecf20Sopenharmony_ci	DEV_TX_PATH_DELAY,
4178c2ecf20Sopenharmony_ci	DEV_PTP_PREDICT_CFG,
4188c2ecf20Sopenharmony_ci	DEV_MAC_ENA_CFG,
4198c2ecf20Sopenharmony_ci	DEV_MAC_MODE_CFG,
4208c2ecf20Sopenharmony_ci	DEV_MAC_MAXLEN_CFG,
4218c2ecf20Sopenharmony_ci	DEV_MAC_TAGS_CFG,
4228c2ecf20Sopenharmony_ci	DEV_MAC_ADV_CHK_CFG,
4238c2ecf20Sopenharmony_ci	DEV_MAC_IFG_CFG,
4248c2ecf20Sopenharmony_ci	DEV_MAC_HDX_CFG,
4258c2ecf20Sopenharmony_ci	DEV_MAC_DBG_CFG,
4268c2ecf20Sopenharmony_ci	DEV_MAC_FC_MAC_LOW_CFG,
4278c2ecf20Sopenharmony_ci	DEV_MAC_FC_MAC_HIGH_CFG,
4288c2ecf20Sopenharmony_ci	DEV_MAC_STICKY,
4298c2ecf20Sopenharmony_ci	PCS1G_CFG,
4308c2ecf20Sopenharmony_ci	PCS1G_MODE_CFG,
4318c2ecf20Sopenharmony_ci	PCS1G_SD_CFG,
4328c2ecf20Sopenharmony_ci	PCS1G_ANEG_CFG,
4338c2ecf20Sopenharmony_ci	PCS1G_ANEG_NP_CFG,
4348c2ecf20Sopenharmony_ci	PCS1G_LB_CFG,
4358c2ecf20Sopenharmony_ci	PCS1G_DBG_CFG,
4368c2ecf20Sopenharmony_ci	PCS1G_CDET_CFG,
4378c2ecf20Sopenharmony_ci	PCS1G_ANEG_STATUS,
4388c2ecf20Sopenharmony_ci	PCS1G_ANEG_NP_STATUS,
4398c2ecf20Sopenharmony_ci	PCS1G_LINK_STATUS,
4408c2ecf20Sopenharmony_ci	PCS1G_LINK_DOWN_CNT,
4418c2ecf20Sopenharmony_ci	PCS1G_STICKY,
4428c2ecf20Sopenharmony_ci	PCS1G_DEBUG_STATUS,
4438c2ecf20Sopenharmony_ci	PCS1G_LPI_CFG,
4448c2ecf20Sopenharmony_ci	PCS1G_LPI_WAKE_ERROR_CNT,
4458c2ecf20Sopenharmony_ci	PCS1G_LPI_STATUS,
4468c2ecf20Sopenharmony_ci	PCS1G_TSTPAT_MODE_CFG,
4478c2ecf20Sopenharmony_ci	PCS1G_TSTPAT_STATUS,
4488c2ecf20Sopenharmony_ci	DEV_PCS_FX100_CFG,
4498c2ecf20Sopenharmony_ci	DEV_PCS_FX100_STATUS,
4508c2ecf20Sopenharmony_ci};
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cienum ocelot_regfield {
4538c2ecf20Sopenharmony_ci	ANA_ADVLEARN_VLAN_CHK,
4548c2ecf20Sopenharmony_ci	ANA_ADVLEARN_LEARN_MIRROR,
4558c2ecf20Sopenharmony_ci	ANA_ANEVENTS_FLOOD_DISCARD,
4568c2ecf20Sopenharmony_ci	ANA_ANEVENTS_MSTI_DROP,
4578c2ecf20Sopenharmony_ci	ANA_ANEVENTS_ACLKILL,
4588c2ecf20Sopenharmony_ci	ANA_ANEVENTS_ACLUSED,
4598c2ecf20Sopenharmony_ci	ANA_ANEVENTS_AUTOAGE,
4608c2ecf20Sopenharmony_ci	ANA_ANEVENTS_VS2TTL1,
4618c2ecf20Sopenharmony_ci	ANA_ANEVENTS_STORM_DROP,
4628c2ecf20Sopenharmony_ci	ANA_ANEVENTS_LEARN_DROP,
4638c2ecf20Sopenharmony_ci	ANA_ANEVENTS_AGED_ENTRY,
4648c2ecf20Sopenharmony_ci	ANA_ANEVENTS_CPU_LEARN_FAILED,
4658c2ecf20Sopenharmony_ci	ANA_ANEVENTS_AUTO_LEARN_FAILED,
4668c2ecf20Sopenharmony_ci	ANA_ANEVENTS_LEARN_REMOVE,
4678c2ecf20Sopenharmony_ci	ANA_ANEVENTS_AUTO_LEARNED,
4688c2ecf20Sopenharmony_ci	ANA_ANEVENTS_AUTO_MOVED,
4698c2ecf20Sopenharmony_ci	ANA_ANEVENTS_DROPPED,
4708c2ecf20Sopenharmony_ci	ANA_ANEVENTS_CLASSIFIED_DROP,
4718c2ecf20Sopenharmony_ci	ANA_ANEVENTS_CLASSIFIED_COPY,
4728c2ecf20Sopenharmony_ci	ANA_ANEVENTS_VLAN_DISCARD,
4738c2ecf20Sopenharmony_ci	ANA_ANEVENTS_FWD_DISCARD,
4748c2ecf20Sopenharmony_ci	ANA_ANEVENTS_MULTICAST_FLOOD,
4758c2ecf20Sopenharmony_ci	ANA_ANEVENTS_UNICAST_FLOOD,
4768c2ecf20Sopenharmony_ci	ANA_ANEVENTS_DEST_KNOWN,
4778c2ecf20Sopenharmony_ci	ANA_ANEVENTS_BUCKET3_MATCH,
4788c2ecf20Sopenharmony_ci	ANA_ANEVENTS_BUCKET2_MATCH,
4798c2ecf20Sopenharmony_ci	ANA_ANEVENTS_BUCKET1_MATCH,
4808c2ecf20Sopenharmony_ci	ANA_ANEVENTS_BUCKET0_MATCH,
4818c2ecf20Sopenharmony_ci	ANA_ANEVENTS_CPU_OPERATION,
4828c2ecf20Sopenharmony_ci	ANA_ANEVENTS_DMAC_LOOKUP,
4838c2ecf20Sopenharmony_ci	ANA_ANEVENTS_SMAC_LOOKUP,
4848c2ecf20Sopenharmony_ci	ANA_ANEVENTS_SEQ_GEN_ERR_0,
4858c2ecf20Sopenharmony_ci	ANA_ANEVENTS_SEQ_GEN_ERR_1,
4868c2ecf20Sopenharmony_ci	ANA_TABLES_MACACCESS_B_DOM,
4878c2ecf20Sopenharmony_ci	ANA_TABLES_MACTINDX_BUCKET,
4888c2ecf20Sopenharmony_ci	ANA_TABLES_MACTINDX_M_INDEX,
4898c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_PORT_ENA,
4908c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
4918c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
4928c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
4938c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
4948c2ecf20Sopenharmony_ci	QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
4958c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
4968c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
4978c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
4988c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
4998c2ecf20Sopenharmony_ci	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
5008c2ecf20Sopenharmony_ci	SYS_PORT_MODE_DATA_WO_TS,
5018c2ecf20Sopenharmony_ci	SYS_PORT_MODE_INCL_INJ_HDR,
5028c2ecf20Sopenharmony_ci	SYS_PORT_MODE_INCL_XTR_HDR,
5038c2ecf20Sopenharmony_ci	SYS_PORT_MODE_INCL_HDR_ERR,
5048c2ecf20Sopenharmony_ci	SYS_RESET_CFG_CORE_ENA,
5058c2ecf20Sopenharmony_ci	SYS_RESET_CFG_MEM_ENA,
5068c2ecf20Sopenharmony_ci	SYS_RESET_CFG_MEM_INIT,
5078c2ecf20Sopenharmony_ci	GCB_SOFT_RST_SWC_RST,
5088c2ecf20Sopenharmony_ci	GCB_MIIM_MII_STATUS_PENDING,
5098c2ecf20Sopenharmony_ci	GCB_MIIM_MII_STATUS_BUSY,
5108c2ecf20Sopenharmony_ci	SYS_PAUSE_CFG_PAUSE_START,
5118c2ecf20Sopenharmony_ci	SYS_PAUSE_CFG_PAUSE_STOP,
5128c2ecf20Sopenharmony_ci	SYS_PAUSE_CFG_PAUSE_ENA,
5138c2ecf20Sopenharmony_ci	REGFIELD_MAX
5148c2ecf20Sopenharmony_ci};
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_cienum {
5178c2ecf20Sopenharmony_ci	/* VCAP_CORE_CFG */
5188c2ecf20Sopenharmony_ci	VCAP_CORE_UPDATE_CTRL,
5198c2ecf20Sopenharmony_ci	VCAP_CORE_MV_CFG,
5208c2ecf20Sopenharmony_ci	/* VCAP_CORE_CACHE */
5218c2ecf20Sopenharmony_ci	VCAP_CACHE_ENTRY_DAT,
5228c2ecf20Sopenharmony_ci	VCAP_CACHE_MASK_DAT,
5238c2ecf20Sopenharmony_ci	VCAP_CACHE_ACTION_DAT,
5248c2ecf20Sopenharmony_ci	VCAP_CACHE_CNT_DAT,
5258c2ecf20Sopenharmony_ci	VCAP_CACHE_TG_DAT,
5268c2ecf20Sopenharmony_ci	/* VCAP_CONST */
5278c2ecf20Sopenharmony_ci	VCAP_CONST_VCAP_VER,
5288c2ecf20Sopenharmony_ci	VCAP_CONST_ENTRY_WIDTH,
5298c2ecf20Sopenharmony_ci	VCAP_CONST_ENTRY_CNT,
5308c2ecf20Sopenharmony_ci	VCAP_CONST_ENTRY_SWCNT,
5318c2ecf20Sopenharmony_ci	VCAP_CONST_ENTRY_TG_WIDTH,
5328c2ecf20Sopenharmony_ci	VCAP_CONST_ACTION_DEF_CNT,
5338c2ecf20Sopenharmony_ci	VCAP_CONST_ACTION_WIDTH,
5348c2ecf20Sopenharmony_ci	VCAP_CONST_CNT_WIDTH,
5358c2ecf20Sopenharmony_ci	VCAP_CONST_CORE_CNT,
5368c2ecf20Sopenharmony_ci	VCAP_CONST_IF_CNT,
5378c2ecf20Sopenharmony_ci};
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_cienum ocelot_ptp_pins {
5408c2ecf20Sopenharmony_ci	PTP_PIN_0,
5418c2ecf20Sopenharmony_ci	PTP_PIN_1,
5428c2ecf20Sopenharmony_ci	PTP_PIN_2,
5438c2ecf20Sopenharmony_ci	PTP_PIN_3,
5448c2ecf20Sopenharmony_ci	TOD_ACC_PIN
5458c2ecf20Sopenharmony_ci};
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_cistruct ocelot_stat_layout {
5488c2ecf20Sopenharmony_ci	u32 offset;
5498c2ecf20Sopenharmony_ci	char name[ETH_GSTRING_LEN];
5508c2ecf20Sopenharmony_ci};
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_cienum ocelot_tag_prefix {
5538c2ecf20Sopenharmony_ci	OCELOT_TAG_PREFIX_DISABLED	= 0,
5548c2ecf20Sopenharmony_ci	OCELOT_TAG_PREFIX_NONE,
5558c2ecf20Sopenharmony_ci	OCELOT_TAG_PREFIX_SHORT,
5568c2ecf20Sopenharmony_ci	OCELOT_TAG_PREFIX_LONG,
5578c2ecf20Sopenharmony_ci};
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_cistruct ocelot;
5608c2ecf20Sopenharmony_ci
5618c2ecf20Sopenharmony_cistruct ocelot_ops {
5628c2ecf20Sopenharmony_ci	struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
5638c2ecf20Sopenharmony_ci	int (*netdev_to_port)(struct net_device *dev);
5648c2ecf20Sopenharmony_ci	int (*reset)(struct ocelot *ocelot);
5658c2ecf20Sopenharmony_ci	u16 (*wm_enc)(u16 value);
5668c2ecf20Sopenharmony_ci};
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_cistruct ocelot_vcap_block {
5698c2ecf20Sopenharmony_ci	struct list_head rules;
5708c2ecf20Sopenharmony_ci	int count;
5718c2ecf20Sopenharmony_ci	int pol_lpr;
5728c2ecf20Sopenharmony_ci};
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_cistruct ocelot_port {
5758c2ecf20Sopenharmony_ci	struct ocelot			*ocelot;
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	struct regmap			*target;
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci	bool				vlan_aware;
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci	/* Ingress default VLAN (pvid) */
5828c2ecf20Sopenharmony_ci	u16				pvid;
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci	/* Egress default VLAN (vid) */
5858c2ecf20Sopenharmony_ci	u16				vid;
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci	u8				ptp_cmd;
5888c2ecf20Sopenharmony_ci	struct sk_buff_head		tx_skbs;
5898c2ecf20Sopenharmony_ci	u8				ts_id;
5908c2ecf20Sopenharmony_ci	spinlock_t			ts_id_lock;
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci	phy_interface_t			phy_mode;
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci	u8				*xmit_template;
5958c2ecf20Sopenharmony_ci};
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_cistruct ocelot {
5988c2ecf20Sopenharmony_ci	struct device			*dev;
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ci	const struct ocelot_ops		*ops;
6018c2ecf20Sopenharmony_ci	struct regmap			*targets[TARGET_MAX];
6028c2ecf20Sopenharmony_ci	struct regmap_field		*regfields[REGFIELD_MAX];
6038c2ecf20Sopenharmony_ci	const u32 *const		*map;
6048c2ecf20Sopenharmony_ci	const struct ocelot_stat_layout	*stats_layout;
6058c2ecf20Sopenharmony_ci	unsigned int			num_stats;
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	int				shared_queue_sz;
6088c2ecf20Sopenharmony_ci	int				num_mact_rows;
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci	struct net_device		*hw_bridge_dev;
6118c2ecf20Sopenharmony_ci	u16				bridge_mask;
6128c2ecf20Sopenharmony_ci	u16				bridge_fwd_mask;
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ci	struct ocelot_port		**ports;
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci	u8				base_mac[ETH_ALEN];
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci	/* Keep track of the vlan port masks */
6198c2ecf20Sopenharmony_ci	u32				vlan_mask[VLAN_N_VID];
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci	/* Switches like VSC9959 have flooding per traffic class */
6228c2ecf20Sopenharmony_ci	int				num_flooding_pgids;
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci	/* In tables like ANA:PORT and the ANA:PGID:PGID mask,
6258c2ecf20Sopenharmony_ci	 * the CPU is located after the physical ports (at the
6268c2ecf20Sopenharmony_ci	 * num_phys_ports index).
6278c2ecf20Sopenharmony_ci	 */
6288c2ecf20Sopenharmony_ci	u8				num_phys_ports;
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	int				npi;
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	enum ocelot_tag_prefix		inj_prefix;
6338c2ecf20Sopenharmony_ci	enum ocelot_tag_prefix		xtr_prefix;
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci	u32				*lags;
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci	struct list_head		multicast;
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci	struct list_head		dummy_rules;
6408c2ecf20Sopenharmony_ci	struct ocelot_vcap_block	block[3];
6418c2ecf20Sopenharmony_ci	struct vcap_props		*vcap;
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci	/* Workqueue to check statistics for overflow with its lock */
6448c2ecf20Sopenharmony_ci	struct mutex			stats_lock;
6458c2ecf20Sopenharmony_ci	u64				*stats;
6468c2ecf20Sopenharmony_ci	struct delayed_work		stats_work;
6478c2ecf20Sopenharmony_ci	struct workqueue_struct		*stats_queue;
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci	u8				ptp:1;
6508c2ecf20Sopenharmony_ci	struct ptp_clock		*ptp_clock;
6518c2ecf20Sopenharmony_ci	struct ptp_clock_info		ptp_info;
6528c2ecf20Sopenharmony_ci	struct hwtstamp_config		hwtstamp_config;
6538c2ecf20Sopenharmony_ci	/* Protects the PTP interface state */
6548c2ecf20Sopenharmony_ci	struct mutex			ptp_lock;
6558c2ecf20Sopenharmony_ci	/* Protects the PTP clock */
6568c2ecf20Sopenharmony_ci	spinlock_t			ptp_clock_lock;
6578c2ecf20Sopenharmony_ci	struct ptp_pin_desc		ptp_pins[OCELOT_PTP_PINS_NUM];
6588c2ecf20Sopenharmony_ci};
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_cistruct ocelot_policer {
6618c2ecf20Sopenharmony_ci	u32 rate; /* kilobit per second */
6628c2ecf20Sopenharmony_ci	u32 burst; /* bytes */
6638c2ecf20Sopenharmony_ci};
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6668c2ecf20Sopenharmony_ci#define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
6678c2ecf20Sopenharmony_ci#define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
6688c2ecf20Sopenharmony_ci#define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0)
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci#define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6718c2ecf20Sopenharmony_ci#define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
6728c2ecf20Sopenharmony_ci#define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
6738c2ecf20Sopenharmony_ci#define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6768c2ecf20Sopenharmony_ci#define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
6778c2ecf20Sopenharmony_ci#define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
6788c2ecf20Sopenharmony_ci#define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
6818c2ecf20Sopenharmony_ci#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
6828c2ecf20Sopenharmony_ci#define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
6838c2ecf20Sopenharmony_ci#define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci#define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \
6868c2ecf20Sopenharmony_ci	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6878c2ecf20Sopenharmony_ci#define ocelot_target_read_gix(ocelot, target, reg, gi) \
6888c2ecf20Sopenharmony_ci	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi))
6898c2ecf20Sopenharmony_ci#define ocelot_target_read_rix(ocelot, target, reg, ri) \
6908c2ecf20Sopenharmony_ci	__ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri))
6918c2ecf20Sopenharmony_ci#define ocelot_target_read(ocelot, target, reg) \
6928c2ecf20Sopenharmony_ci	__ocelot_target_read_ix(ocelot, target, reg, 0)
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_ci#define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) \
6958c2ecf20Sopenharmony_ci	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6968c2ecf20Sopenharmony_ci#define ocelot_target_write_gix(ocelot, target, val, reg, gi) \
6978c2ecf20Sopenharmony_ci	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi))
6988c2ecf20Sopenharmony_ci#define ocelot_target_write_rix(ocelot, target, val, reg, ri) \
6998c2ecf20Sopenharmony_ci	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri))
7008c2ecf20Sopenharmony_ci#define ocelot_target_write(ocelot, target, val, reg) \
7018c2ecf20Sopenharmony_ci	__ocelot_target_write_ix(ocelot, target, val, reg, 0)
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci/* I/O */
7048c2ecf20Sopenharmony_ciu32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
7058c2ecf20Sopenharmony_civoid ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
7068c2ecf20Sopenharmony_civoid ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg);
7078c2ecf20Sopenharmony_ciu32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
7088c2ecf20Sopenharmony_civoid __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
7098c2ecf20Sopenharmony_civoid __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
7108c2ecf20Sopenharmony_ci		     u32 offset);
7118c2ecf20Sopenharmony_ciu32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
7128c2ecf20Sopenharmony_ci			    u32 reg, u32 offset);
7138c2ecf20Sopenharmony_civoid __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
7148c2ecf20Sopenharmony_ci			      u32 val, u32 reg, u32 offset);
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci/* Hardware initialization */
7178c2ecf20Sopenharmony_ciint ocelot_regfields_init(struct ocelot *ocelot,
7188c2ecf20Sopenharmony_ci			  const struct reg_field *const regfields);
7198c2ecf20Sopenharmony_cistruct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
7208c2ecf20Sopenharmony_ciint ocelot_init(struct ocelot *ocelot);
7218c2ecf20Sopenharmony_civoid ocelot_deinit(struct ocelot *ocelot);
7228c2ecf20Sopenharmony_civoid ocelot_init_port(struct ocelot *ocelot, int port);
7238c2ecf20Sopenharmony_civoid ocelot_deinit_port(struct ocelot *ocelot, int port);
7248c2ecf20Sopenharmony_ci
7258c2ecf20Sopenharmony_ci/* DSA callbacks */
7268c2ecf20Sopenharmony_civoid ocelot_port_enable(struct ocelot *ocelot, int port,
7278c2ecf20Sopenharmony_ci			struct phy_device *phy);
7288c2ecf20Sopenharmony_civoid ocelot_port_disable(struct ocelot *ocelot, int port);
7298c2ecf20Sopenharmony_civoid ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
7308c2ecf20Sopenharmony_civoid ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
7318c2ecf20Sopenharmony_ciint ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
7328c2ecf20Sopenharmony_ciint ocelot_get_ts_info(struct ocelot *ocelot, int port,
7338c2ecf20Sopenharmony_ci		       struct ethtool_ts_info *info);
7348c2ecf20Sopenharmony_civoid ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
7358c2ecf20Sopenharmony_ciint ocelot_port_flush(struct ocelot *ocelot, int port);
7368c2ecf20Sopenharmony_civoid ocelot_adjust_link(struct ocelot *ocelot, int port,
7378c2ecf20Sopenharmony_ci			struct phy_device *phydev);
7388c2ecf20Sopenharmony_ciint ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled,
7398c2ecf20Sopenharmony_ci			       struct switchdev_trans *trans);
7408c2ecf20Sopenharmony_civoid ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
7418c2ecf20Sopenharmony_ciint ocelot_port_bridge_join(struct ocelot *ocelot, int port,
7428c2ecf20Sopenharmony_ci			    struct net_device *bridge);
7438c2ecf20Sopenharmony_ciint ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
7448c2ecf20Sopenharmony_ci			     struct net_device *bridge);
7458c2ecf20Sopenharmony_ciint ocelot_fdb_dump(struct ocelot *ocelot, int port,
7468c2ecf20Sopenharmony_ci		    dsa_fdb_dump_cb_t *cb, void *data);
7478c2ecf20Sopenharmony_ciint ocelot_fdb_add(struct ocelot *ocelot, int port,
7488c2ecf20Sopenharmony_ci		   const unsigned char *addr, u16 vid);
7498c2ecf20Sopenharmony_ciint ocelot_fdb_del(struct ocelot *ocelot, int port,
7508c2ecf20Sopenharmony_ci		   const unsigned char *addr, u16 vid);
7518c2ecf20Sopenharmony_ciint ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
7528c2ecf20Sopenharmony_ci		    bool untagged);
7538c2ecf20Sopenharmony_ciint ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
7548c2ecf20Sopenharmony_ciint ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
7558c2ecf20Sopenharmony_ciint ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
7568c2ecf20Sopenharmony_civoid ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
7578c2ecf20Sopenharmony_ci				  struct sk_buff *clone);
7588c2ecf20Sopenharmony_civoid ocelot_get_txtstamp(struct ocelot *ocelot);
7598c2ecf20Sopenharmony_civoid ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
7608c2ecf20Sopenharmony_ciint ocelot_get_max_mtu(struct ocelot *ocelot, int port);
7618c2ecf20Sopenharmony_ciint ocelot_port_policer_add(struct ocelot *ocelot, int port,
7628c2ecf20Sopenharmony_ci			    struct ocelot_policer *pol);
7638c2ecf20Sopenharmony_ciint ocelot_port_policer_del(struct ocelot *ocelot, int port);
7648c2ecf20Sopenharmony_ciint ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
7658c2ecf20Sopenharmony_ci			      struct flow_cls_offload *f, bool ingress);
7668c2ecf20Sopenharmony_ciint ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
7678c2ecf20Sopenharmony_ci			      struct flow_cls_offload *f, bool ingress);
7688c2ecf20Sopenharmony_ciint ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
7698c2ecf20Sopenharmony_ci			    struct flow_cls_offload *f, bool ingress);
7708c2ecf20Sopenharmony_ciint ocelot_port_mdb_add(struct ocelot *ocelot, int port,
7718c2ecf20Sopenharmony_ci			const struct switchdev_obj_port_mdb *mdb);
7728c2ecf20Sopenharmony_ciint ocelot_port_mdb_del(struct ocelot *ocelot, int port,
7738c2ecf20Sopenharmony_ci			const struct switchdev_obj_port_mdb *mdb);
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci#endif
776