xref: /linux/drivers/net/dsa/ocelot/seville_vsc9953.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
184705fc1SMaxim Kochetkov // SPDX-License-Identifier: (GPL-2.0 OR MIT)
284705fc1SMaxim Kochetkov /* Distributed Switch Architecture VSC9953 driver
384705fc1SMaxim Kochetkov  * Copyright (C) 2020, Maxim Kochetkov <fido_max@inbox.ru>
484705fc1SMaxim Kochetkov  */
5f44a9010SRob Herring #include <linux/platform_device.h>
684705fc1SMaxim Kochetkov #include <linux/types.h>
784705fc1SMaxim Kochetkov #include <soc/mscc/ocelot_vcap.h>
884705fc1SMaxim Kochetkov #include <soc/mscc/ocelot_sys.h>
984705fc1SMaxim Kochetkov #include <soc/mscc/ocelot.h>
10b9965845SColin Foster #include <linux/mdio/mdio-mscc-miim.h>
11f44a9010SRob Herring #include <linux/mod_devicetable.h>
12b9965845SColin Foster #include <linux/of_mdio.h>
13588d0550SIoana Ciornei #include <linux/pcs-lynx.h>
1440d3f295SVladimir Oltean #include <linux/dsa/ocelot.h>
1584705fc1SMaxim Kochetkov #include <linux/iopoll.h>
1684705fc1SMaxim Kochetkov #include "felix.h"
1784705fc1SMaxim Kochetkov 
18acf242fcSColin Foster #define VSC9953_NUM_PORTS			10
19acf242fcSColin Foster 
2077043c37SXiaoliang Yang #define VSC9953_VCAP_POLICER_BASE		11
2177043c37SXiaoliang Yang #define VSC9953_VCAP_POLICER_MAX		31
2277043c37SXiaoliang Yang #define VSC9953_VCAP_POLICER_BASE2		120
2377043c37SXiaoliang Yang #define VSC9953_VCAP_POLICER_MAX2		161
2484705fc1SMaxim Kochetkov 
2511ecf341SVladimir Oltean #define VSC9953_PORT_MODE_SERDES		(OCELOT_PORT_MODE_1000BASEX | \
2611ecf341SVladimir Oltean 						 OCELOT_PORT_MODE_SGMII | \
27acf242fcSColin Foster 						 OCELOT_PORT_MODE_QSGMII)
28acf242fcSColin Foster 
29acf242fcSColin Foster static const u32 vsc9953_port_modes[VSC9953_NUM_PORTS] = {
30acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
31acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
32acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
33acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
34acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
35acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
36acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
37acf242fcSColin Foster 	VSC9953_PORT_MODE_SERDES,
38acf242fcSColin Foster 	OCELOT_PORT_MODE_INTERNAL,
39acf242fcSColin Foster 	OCELOT_PORT_MODE_INTERNAL,
40acf242fcSColin Foster };
41acf242fcSColin Foster 
4284705fc1SMaxim Kochetkov static const u32 vsc9953_ana_regmap[] = {
4384705fc1SMaxim Kochetkov 	REG(ANA_ADVLEARN,			0x00b500),
4484705fc1SMaxim Kochetkov 	REG(ANA_VLANMASK,			0x00b504),
4584705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PORT_B_DOMAIN),
4684705fc1SMaxim Kochetkov 	REG(ANA_ANAGEFIL,			0x00b50c),
4784705fc1SMaxim Kochetkov 	REG(ANA_ANEVENTS,			0x00b510),
4884705fc1SMaxim Kochetkov 	REG(ANA_STORMLIMIT_BURST,		0x00b514),
4984705fc1SMaxim Kochetkov 	REG(ANA_STORMLIMIT_CFG,			0x00b518),
5084705fc1SMaxim Kochetkov 	REG(ANA_ISOLATED_PORTS,			0x00b528),
5184705fc1SMaxim Kochetkov 	REG(ANA_COMMUNITY_PORTS,		0x00b52c),
5284705fc1SMaxim Kochetkov 	REG(ANA_AUTOAGE,			0x00b530),
5384705fc1SMaxim Kochetkov 	REG(ANA_MACTOPTIONS,			0x00b534),
5484705fc1SMaxim Kochetkov 	REG(ANA_LEARNDISC,			0x00b538),
5584705fc1SMaxim Kochetkov 	REG(ANA_AGENCTRL,			0x00b53c),
5684705fc1SMaxim Kochetkov 	REG(ANA_MIRRORPORTS,			0x00b540),
5784705fc1SMaxim Kochetkov 	REG(ANA_EMIRRORPORTS,			0x00b544),
5884705fc1SMaxim Kochetkov 	REG(ANA_FLOODING,			0x00b548),
5984705fc1SMaxim Kochetkov 	REG(ANA_FLOODING_IPMC,			0x00b54c),
6084705fc1SMaxim Kochetkov 	REG(ANA_SFLOW_CFG,			0x00b550),
6184705fc1SMaxim Kochetkov 	REG(ANA_PORT_MODE,			0x00b57c),
6284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_CUT_THRU_CFG),
6384705fc1SMaxim Kochetkov 	REG(ANA_PGID_PGID,			0x00b600),
6484705fc1SMaxim Kochetkov 	REG(ANA_TABLES_ANMOVED,			0x00b4ac),
6584705fc1SMaxim Kochetkov 	REG(ANA_TABLES_MACHDATA,		0x00b4b0),
6684705fc1SMaxim Kochetkov 	REG(ANA_TABLES_MACLDATA,		0x00b4b4),
6784705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_STREAMDATA),
6884705fc1SMaxim Kochetkov 	REG(ANA_TABLES_MACACCESS,		0x00b4b8),
6984705fc1SMaxim Kochetkov 	REG(ANA_TABLES_MACTINDX,		0x00b4bc),
7084705fc1SMaxim Kochetkov 	REG(ANA_TABLES_VLANACCESS,		0x00b4c0),
7184705fc1SMaxim Kochetkov 	REG(ANA_TABLES_VLANTIDX,		0x00b4c4),
7284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_ISDXACCESS),
7384705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_ISDXTIDX),
7484705fc1SMaxim Kochetkov 	REG(ANA_TABLES_ENTRYLIM,		0x00b480),
7584705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_PTP_ID_HIGH),
7684705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_PTP_ID_LOW),
7784705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_STREAMACCESS),
7884705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_STREAMTIDX),
7984705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_SEQ_HISTORY),
8084705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_SEQ_MASK),
8184705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_SFID_MASK),
8284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_SFIDACCESS),
8384705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_TABLES_SFIDTIDX),
8484705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_MSTI_STATE),
8584705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_OAM_UPM_LM_CNT),
8684705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_ACCESS_CTRL),
8784705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_CONFIG_REG_1),
8884705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_CONFIG_REG_2),
8984705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_CONFIG_REG_3),
9084705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_CONFIG_REG_4),
9184705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_CONFIG_REG_5),
9284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_GCL_GS_CONFIG),
9384705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_GCL_TI_CONFIG),
9484705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_STATUS_REG_1),
9584705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_STATUS_REG_2),
9684705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_SG_STATUS_REG_3),
9784705fc1SMaxim Kochetkov 	REG(ANA_PORT_VLAN_CFG,			0x000000),
9884705fc1SMaxim Kochetkov 	REG(ANA_PORT_DROP_CFG,			0x000004),
9984705fc1SMaxim Kochetkov 	REG(ANA_PORT_QOS_CFG,			0x000008),
10084705fc1SMaxim Kochetkov 	REG(ANA_PORT_VCAP_CFG,			0x00000c),
10184705fc1SMaxim Kochetkov 	REG(ANA_PORT_VCAP_S1_KEY_CFG,		0x000010),
10284705fc1SMaxim Kochetkov 	REG(ANA_PORT_VCAP_S2_CFG,		0x00001c),
10384705fc1SMaxim Kochetkov 	REG(ANA_PORT_PCP_DEI_MAP,		0x000020),
10484705fc1SMaxim Kochetkov 	REG(ANA_PORT_CPU_FWD_CFG,		0x000060),
10584705fc1SMaxim Kochetkov 	REG(ANA_PORT_CPU_FWD_BPDU_CFG,		0x000064),
10684705fc1SMaxim Kochetkov 	REG(ANA_PORT_CPU_FWD_GARP_CFG,		0x000068),
10784705fc1SMaxim Kochetkov 	REG(ANA_PORT_CPU_FWD_CCM_CFG,		0x00006c),
10884705fc1SMaxim Kochetkov 	REG(ANA_PORT_PORT_CFG,			0x000070),
10984705fc1SMaxim Kochetkov 	REG(ANA_PORT_POL_CFG,			0x000074),
11084705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PORT_PTP_CFG),
11184705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PORT_PTP_DLY1_CFG),
11284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PORT_PTP_DLY2_CFG),
11384705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PORT_SFID_CFG),
11484705fc1SMaxim Kochetkov 	REG(ANA_PFC_PFC_CFG,			0x00c000),
11584705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PFC_PFC_TIMER),
11684705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_IPT_OAM_MEP_CFG),
11784705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_IPT_IPT),
11884705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_PPT_PPT),
11984705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_FID_MAP_FID_MAP),
12084705fc1SMaxim Kochetkov 	REG(ANA_AGGR_CFG,			0x00c600),
12184705fc1SMaxim Kochetkov 	REG(ANA_CPUQ_CFG,			0x00c604),
12284705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_CPUQ_CFG2),
12384705fc1SMaxim Kochetkov 	REG(ANA_CPUQ_8021_CFG,			0x00c60c),
12484705fc1SMaxim Kochetkov 	REG(ANA_DSCP_CFG,			0x00c64c),
12584705fc1SMaxim Kochetkov 	REG(ANA_DSCP_REWR_CFG,			0x00c74c),
12684705fc1SMaxim Kochetkov 	REG(ANA_VCAP_RNG_TYPE_CFG,		0x00c78c),
12784705fc1SMaxim Kochetkov 	REG(ANA_VCAP_RNG_VAL_CFG,		0x00c7ac),
12884705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_VRAP_CFG),
12984705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_VRAP_HDR_DATA),
13084705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_VRAP_HDR_MASK),
13184705fc1SMaxim Kochetkov 	REG(ANA_DISCARD_CFG,			0x00c7d8),
13284705fc1SMaxim Kochetkov 	REG(ANA_FID_CFG,			0x00c7dc),
13384705fc1SMaxim Kochetkov 	REG(ANA_POL_PIR_CFG,			0x00a000),
13484705fc1SMaxim Kochetkov 	REG(ANA_POL_CIR_CFG,			0x00a004),
13584705fc1SMaxim Kochetkov 	REG(ANA_POL_MODE_CFG,			0x00a008),
13684705fc1SMaxim Kochetkov 	REG(ANA_POL_PIR_STATE,			0x00a00c),
13784705fc1SMaxim Kochetkov 	REG(ANA_POL_CIR_STATE,			0x00a010),
13884705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_POL_STATE),
13984705fc1SMaxim Kochetkov 	REG(ANA_POL_FLOWC,			0x00c280),
14084705fc1SMaxim Kochetkov 	REG(ANA_POL_HYST,			0x00c2ec),
14184705fc1SMaxim Kochetkov 	REG_RESERVED(ANA_POL_MISC_CFG),
14284705fc1SMaxim Kochetkov };
14384705fc1SMaxim Kochetkov 
14484705fc1SMaxim Kochetkov static const u32 vsc9953_qs_regmap[] = {
14584705fc1SMaxim Kochetkov 	REG(QS_XTR_GRP_CFG,			0x000000),
14684705fc1SMaxim Kochetkov 	REG(QS_XTR_RD,				0x000008),
14784705fc1SMaxim Kochetkov 	REG(QS_XTR_FRM_PRUNING,			0x000010),
14884705fc1SMaxim Kochetkov 	REG(QS_XTR_FLUSH,			0x000018),
14984705fc1SMaxim Kochetkov 	REG(QS_XTR_DATA_PRESENT,		0x00001c),
15084705fc1SMaxim Kochetkov 	REG(QS_XTR_CFG,				0x000020),
15184705fc1SMaxim Kochetkov 	REG(QS_INJ_GRP_CFG,			0x000024),
15284705fc1SMaxim Kochetkov 	REG(QS_INJ_WR,				0x00002c),
15384705fc1SMaxim Kochetkov 	REG(QS_INJ_CTRL,			0x000034),
15484705fc1SMaxim Kochetkov 	REG(QS_INJ_STATUS,			0x00003c),
15584705fc1SMaxim Kochetkov 	REG(QS_INJ_ERR,				0x000040),
15684705fc1SMaxim Kochetkov 	REG_RESERVED(QS_INH_DBG),
15784705fc1SMaxim Kochetkov };
15884705fc1SMaxim Kochetkov 
159c1c3993eSVladimir Oltean static const u32 vsc9953_vcap_regmap[] = {
160c1c3993eSVladimir Oltean 	/* VCAP_CORE_CFG */
161c1c3993eSVladimir Oltean 	REG(VCAP_CORE_UPDATE_CTRL,		0x000000),
162c1c3993eSVladimir Oltean 	REG(VCAP_CORE_MV_CFG,			0x000004),
163c1c3993eSVladimir Oltean 	/* VCAP_CORE_CACHE */
164c1c3993eSVladimir Oltean 	REG(VCAP_CACHE_ENTRY_DAT,		0x000008),
165c1c3993eSVladimir Oltean 	REG(VCAP_CACHE_MASK_DAT,		0x000108),
166c1c3993eSVladimir Oltean 	REG(VCAP_CACHE_ACTION_DAT,		0x000208),
167c1c3993eSVladimir Oltean 	REG(VCAP_CACHE_CNT_DAT,			0x000308),
168c1c3993eSVladimir Oltean 	REG(VCAP_CACHE_TG_DAT,			0x000388),
16920968054SVladimir Oltean 	/* VCAP_CONST */
17020968054SVladimir Oltean 	REG(VCAP_CONST_VCAP_VER,		0x000398),
17120968054SVladimir Oltean 	REG(VCAP_CONST_ENTRY_WIDTH,		0x00039c),
17220968054SVladimir Oltean 	REG(VCAP_CONST_ENTRY_CNT,		0x0003a0),
17320968054SVladimir Oltean 	REG(VCAP_CONST_ENTRY_SWCNT,		0x0003a4),
17420968054SVladimir Oltean 	REG(VCAP_CONST_ENTRY_TG_WIDTH,		0x0003a8),
17520968054SVladimir Oltean 	REG(VCAP_CONST_ACTION_DEF_CNT,		0x0003ac),
17620968054SVladimir Oltean 	REG(VCAP_CONST_ACTION_WIDTH,		0x0003b0),
17720968054SVladimir Oltean 	REG(VCAP_CONST_CNT_WIDTH,		0x0003b4),
17820968054SVladimir Oltean 	REG_RESERVED(VCAP_CONST_CORE_CNT),
17920968054SVladimir Oltean 	REG_RESERVED(VCAP_CONST_IF_CNT),
18084705fc1SMaxim Kochetkov };
18184705fc1SMaxim Kochetkov 
18284705fc1SMaxim Kochetkov static const u32 vsc9953_qsys_regmap[] = {
18384705fc1SMaxim Kochetkov 	REG(QSYS_PORT_MODE,			0x003600),
18484705fc1SMaxim Kochetkov 	REG(QSYS_SWITCH_PORT_MODE,		0x003630),
18584705fc1SMaxim Kochetkov 	REG(QSYS_STAT_CNT_CFG,			0x00365c),
18684705fc1SMaxim Kochetkov 	REG(QSYS_EEE_CFG,			0x003660),
18784705fc1SMaxim Kochetkov 	REG(QSYS_EEE_THRES,			0x003688),
18884705fc1SMaxim Kochetkov 	REG(QSYS_IGR_NO_SHARING,		0x00368c),
18984705fc1SMaxim Kochetkov 	REG(QSYS_EGR_NO_SHARING,		0x003690),
19084705fc1SMaxim Kochetkov 	REG(QSYS_SW_STATUS,			0x003694),
19184705fc1SMaxim Kochetkov 	REG(QSYS_EXT_CPU_CFG,			0x0036c0),
19284705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PAD_CFG),
19384705fc1SMaxim Kochetkov 	REG(QSYS_CPU_GROUP_MAP,			0x0036c8),
19484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAP),
19584705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_ISDX_SGRP),
19684705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TIMED_FRAME_ENTRY),
19784705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_MISC),
19884705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_PORT_DLY),
19984705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_1),
20084705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_2),
20184705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_3),
20284705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_4),
20384705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_5),
20484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_6),
20584705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_7),
20684705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TFRM_TIMER_CFG_8),
20784705fc1SMaxim Kochetkov 	REG(QSYS_RED_PROFILE,			0x003724),
20884705fc1SMaxim Kochetkov 	REG(QSYS_RES_QOS_MODE,			0x003764),
20984705fc1SMaxim Kochetkov 	REG(QSYS_RES_CFG,			0x004000),
21084705fc1SMaxim Kochetkov 	REG(QSYS_RES_STAT,			0x004004),
21184705fc1SMaxim Kochetkov 	REG(QSYS_EGR_DROP_MODE,			0x003768),
21284705fc1SMaxim Kochetkov 	REG(QSYS_EQ_CTRL,			0x00376c),
21384705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_EVENTS_CORE),
21484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_0),
21584705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_1),
21684705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_2),
21784705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_3),
21884705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_4),
21984705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_5),
22084705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_6),
22184705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_QMAXSDU_CFG_7),
22284705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PREEMPTION_CFG),
22384705fc1SMaxim Kochetkov 	REG(QSYS_CIR_CFG,			0x000000),
22484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_EIR_CFG),
22584705fc1SMaxim Kochetkov 	REG(QSYS_SE_CFG,			0x000008),
22684705fc1SMaxim Kochetkov 	REG(QSYS_SE_DWRR_CFG,			0x00000c),
22784705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_SE_CONNECT),
22884705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_SE_DLB_SENSE),
22984705fc1SMaxim Kochetkov 	REG(QSYS_CIR_STATE,			0x000044),
23084705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_EIR_STATE),
23184705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_SE_STATE),
23284705fc1SMaxim Kochetkov 	REG(QSYS_HSCH_MISC_CFG,			0x003774),
23384705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TAG_CONFIG),
23484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_TAS_PARAM_CFG_CTRL),
23584705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PORT_MAX_SDU),
23684705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_CFG_REG_1),
23784705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_CFG_REG_2),
23884705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_CFG_REG_3),
23984705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_CFG_REG_4),
24084705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_CFG_REG_5),
24184705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_GCL_CFG_REG_1),
24284705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_GCL_CFG_REG_2),
24384705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_1),
24484705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_2),
24584705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_3),
24684705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_4),
24784705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_5),
24884705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_6),
24984705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_7),
25084705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_8),
25184705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_PARAM_STATUS_REG_9),
25284705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_GCL_STATUS_REG_1),
25384705fc1SMaxim Kochetkov 	REG_RESERVED(QSYS_GCL_STATUS_REG_2),
25484705fc1SMaxim Kochetkov };
25584705fc1SMaxim Kochetkov 
25684705fc1SMaxim Kochetkov static const u32 vsc9953_rew_regmap[] = {
25784705fc1SMaxim Kochetkov 	REG(REW_PORT_VLAN_CFG,			0x000000),
25884705fc1SMaxim Kochetkov 	REG(REW_TAG_CFG,			0x000004),
25984705fc1SMaxim Kochetkov 	REG(REW_PORT_CFG,			0x000008),
26084705fc1SMaxim Kochetkov 	REG(REW_DSCP_CFG,			0x00000c),
26184705fc1SMaxim Kochetkov 	REG(REW_PCP_DEI_QOS_MAP_CFG,		0x000010),
26284705fc1SMaxim Kochetkov 	REG_RESERVED(REW_PTP_CFG),
26384705fc1SMaxim Kochetkov 	REG_RESERVED(REW_PTP_DLY1_CFG),
26484705fc1SMaxim Kochetkov 	REG_RESERVED(REW_RED_TAG_CFG),
26584705fc1SMaxim Kochetkov 	REG(REW_DSCP_REMAP_DP1_CFG,		0x000610),
26684705fc1SMaxim Kochetkov 	REG(REW_DSCP_REMAP_CFG,			0x000710),
26784705fc1SMaxim Kochetkov 	REG_RESERVED(REW_STAT_CFG),
26884705fc1SMaxim Kochetkov 	REG_RESERVED(REW_REW_STICKY),
26984705fc1SMaxim Kochetkov 	REG_RESERVED(REW_PPT),
27084705fc1SMaxim Kochetkov };
27184705fc1SMaxim Kochetkov 
27284705fc1SMaxim Kochetkov static const u32 vsc9953_sys_regmap[] = {
27384705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_OCTETS,		0x000000),
274d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_UNICAST,		0x000004),
27584705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_MULTICAST,		0x000008),
276d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_BROADCAST,		0x00000c),
27784705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_SHORTS,		0x000010),
27884705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_FRAGMENTS,		0x000014),
27984705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_JABBERS,		0x000018),
280d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_CRC_ALIGN_ERRS,	0x00001c),
281d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_SYM_ERRS,		0x000020),
28284705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_64,			0x000024),
28384705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_65_127,		0x000028),
28484705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_128_255,		0x00002c),
2855152de7bSVladimir Oltean 	REG(SYS_COUNT_RX_256_511,		0x000030),
2865152de7bSVladimir Oltean 	REG(SYS_COUNT_RX_512_1023,		0x000034),
2875152de7bSVladimir Oltean 	REG(SYS_COUNT_RX_1024_1526,		0x000038),
2885152de7bSVladimir Oltean 	REG(SYS_COUNT_RX_1527_MAX,		0x00003c),
289d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_PAUSE,			0x000040),
290d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_CONTROL,		0x000044),
29184705fc1SMaxim Kochetkov 	REG(SYS_COUNT_RX_LONGS,			0x000048),
292d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_CLASSIFIED_DROPS,	0x00004c),
293d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_0,		0x000050),
294d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_1,		0x000054),
295d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_2,		0x000058),
296d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_3,		0x00005c),
297d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_4,		0x000060),
298d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_5,		0x000064),
299d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_6,		0x000068),
300d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_RED_PRIO_7,		0x00006c),
301d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_0,		0x000070),
302d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_1,		0x000074),
303d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_2,		0x000078),
304d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_3,		0x00007c),
305d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_4,		0x000080),
306d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_5,		0x000084),
307d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_6,		0x000088),
308d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_YELLOW_PRIO_7,		0x00008c),
309d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_0,		0x000090),
310d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_1,		0x000094),
311d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_2,		0x000098),
312d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_3,		0x00009c),
313d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_4,		0x0000a0),
314d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_5,		0x0000a4),
315d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_6,		0x0000a8),
316d4c36765SVladimir Oltean 	REG(SYS_COUNT_RX_GREEN_PRIO_7,		0x0000ac),
31784705fc1SMaxim Kochetkov 	REG(SYS_COUNT_TX_OCTETS,		0x000100),
318d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_UNICAST,		0x000104),
319d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_MULTICAST,		0x000108),
320d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_BROADCAST,		0x00010c),
32184705fc1SMaxim Kochetkov 	REG(SYS_COUNT_TX_COLLISION,		0x000110),
32284705fc1SMaxim Kochetkov 	REG(SYS_COUNT_TX_DROPS,			0x000114),
323d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_PAUSE,			0x000118),
32484705fc1SMaxim Kochetkov 	REG(SYS_COUNT_TX_64,			0x00011c),
32584705fc1SMaxim Kochetkov 	REG(SYS_COUNT_TX_65_127,		0x000120),
3265152de7bSVladimir Oltean 	REG(SYS_COUNT_TX_128_255,		0x000124),
3275152de7bSVladimir Oltean 	REG(SYS_COUNT_TX_256_511,		0x000128),
3285152de7bSVladimir Oltean 	REG(SYS_COUNT_TX_512_1023,		0x00012c),
3295152de7bSVladimir Oltean 	REG(SYS_COUNT_TX_1024_1526,		0x000130),
3305152de7bSVladimir Oltean 	REG(SYS_COUNT_TX_1527_MAX,		0x000134),
331d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_0,		0x000138),
332d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_1,		0x00013c),
333d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_2,		0x000140),
334d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_3,		0x000144),
335d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_4,		0x000148),
336d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_5,		0x00014c),
337d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_6,		0x000150),
338d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_YELLOW_PRIO_7,		0x000154),
339d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_0,		0x000158),
340d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_1,		0x00015c),
341d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_2,		0x000160),
342d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_3,		0x000164),
343d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_4,		0x000168),
344d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_5,		0x00016c),
345d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_6,		0x000170),
346d4c36765SVladimir Oltean 	REG(SYS_COUNT_TX_GREEN_PRIO_7,		0x000174),
347be5c13f2SVladimir Oltean 	REG(SYS_COUNT_TX_AGED,			0x000178),
348d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_LOCAL,		0x000200),
349d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_TAIL,		0x000204),
350d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_0,	0x000208),
351d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_1,	0x00020c),
352d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_2,	0x000210),
353d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_3,	0x000214),
354d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_4,	0x000218),
355d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_5,	0x00021c),
356d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_6,	0x000220),
357d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_YELLOW_PRIO_7,	0x000224),
358d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_0,	0x000228),
359d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_1,	0x00022c),
360d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_2,	0x000230),
361d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_3,	0x000234),
362d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_4,	0x000238),
363d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_5,	0x00023c),
364d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_6,	0x000240),
365d4c36765SVladimir Oltean 	REG(SYS_COUNT_DROP_GREEN_PRIO_7,	0x000244),
36684705fc1SMaxim Kochetkov 	REG(SYS_RESET_CFG,			0x000318),
36784705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_SR_ETYPE_CFG),
36884705fc1SMaxim Kochetkov 	REG(SYS_VLAN_ETYPE_CFG,			0x000320),
36984705fc1SMaxim Kochetkov 	REG(SYS_PORT_MODE,			0x000324),
37084705fc1SMaxim Kochetkov 	REG(SYS_FRONT_PORT_MODE,		0x000354),
37184705fc1SMaxim Kochetkov 	REG(SYS_FRM_AGING,			0x00037c),
37284705fc1SMaxim Kochetkov 	REG(SYS_STAT_CFG,			0x000380),
37384705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_SW_STATUS),
37484705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_MISC_CFG),
37584705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_REW_MAC_HIGH_CFG),
37684705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_REW_MAC_LOW_CFG),
37784705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_TIMESTAMP_OFFSET),
37884705fc1SMaxim Kochetkov 	REG(SYS_PAUSE_CFG,			0x00044c),
37984705fc1SMaxim Kochetkov 	REG(SYS_PAUSE_TOT_CFG,			0x000478),
38084705fc1SMaxim Kochetkov 	REG(SYS_ATOP,				0x00047c),
38184705fc1SMaxim Kochetkov 	REG(SYS_ATOP_TOT_CFG,			0x0004a8),
38284705fc1SMaxim Kochetkov 	REG(SYS_MAC_FC_CFG,			0x0004ac),
38384705fc1SMaxim Kochetkov 	REG(SYS_MMGT,				0x0004d4),
38484705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_MMGT_FAST),
38584705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_EVENTS_DIF),
38684705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_EVENTS_CORE),
38784705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_PTP_STATUS),
38884705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_PTP_TXSTAMP),
38984705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_PTP_NXT),
39084705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_PTP_CFG),
39184705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_RAM_INIT),
39284705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_CM_ADDR),
39384705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_CM_DATA_WR),
39484705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_CM_DATA_RD),
39584705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_CM_OP),
39684705fc1SMaxim Kochetkov 	REG_RESERVED(SYS_CM_DATA),
39784705fc1SMaxim Kochetkov };
39884705fc1SMaxim Kochetkov 
39984705fc1SMaxim Kochetkov static const u32 vsc9953_gcb_regmap[] = {
40084705fc1SMaxim Kochetkov 	REG(GCB_SOFT_RST,			0x000008),
40184705fc1SMaxim Kochetkov 	REG(GCB_MIIM_MII_STATUS,		0x0000ac),
40284705fc1SMaxim Kochetkov 	REG(GCB_MIIM_MII_CMD,			0x0000b4),
40384705fc1SMaxim Kochetkov 	REG(GCB_MIIM_MII_DATA,			0x0000b8),
40484705fc1SMaxim Kochetkov };
40584705fc1SMaxim Kochetkov 
40684705fc1SMaxim Kochetkov static const u32 vsc9953_dev_gmii_regmap[] = {
40784705fc1SMaxim Kochetkov 	REG(DEV_CLOCK_CFG,			0x0),
40884705fc1SMaxim Kochetkov 	REG(DEV_PORT_MISC,			0x4),
40984705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_EVENTS),
41084705fc1SMaxim Kochetkov 	REG(DEV_EEE_CFG,			0xc),
41184705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_RX_PATH_DELAY),
41284705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_TX_PATH_DELAY),
41384705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_PTP_PREDICT_CFG),
41484705fc1SMaxim Kochetkov 	REG(DEV_MAC_ENA_CFG,			0x10),
41584705fc1SMaxim Kochetkov 	REG(DEV_MAC_MODE_CFG,			0x14),
41684705fc1SMaxim Kochetkov 	REG(DEV_MAC_MAXLEN_CFG,			0x18),
41784705fc1SMaxim Kochetkov 	REG(DEV_MAC_TAGS_CFG,			0x1c),
41884705fc1SMaxim Kochetkov 	REG(DEV_MAC_ADV_CHK_CFG,		0x20),
41984705fc1SMaxim Kochetkov 	REG(DEV_MAC_IFG_CFG,			0x24),
42084705fc1SMaxim Kochetkov 	REG(DEV_MAC_HDX_CFG,			0x28),
42184705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_MAC_DBG_CFG),
42284705fc1SMaxim Kochetkov 	REG(DEV_MAC_FC_MAC_LOW_CFG,		0x30),
42384705fc1SMaxim Kochetkov 	REG(DEV_MAC_FC_MAC_HIGH_CFG,		0x34),
42484705fc1SMaxim Kochetkov 	REG(DEV_MAC_STICKY,			0x38),
42584705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_CFG),
42684705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_MODE_CFG),
42784705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_SD_CFG),
42884705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_ANEG_CFG),
42984705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_ANEG_NP_CFG),
43084705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LB_CFG),
43184705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_DBG_CFG),
43284705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_CDET_CFG),
43384705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_ANEG_STATUS),
43484705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_ANEG_NP_STATUS),
43584705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LINK_STATUS),
43684705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LINK_DOWN_CNT),
43784705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_STICKY),
43884705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_DEBUG_STATUS),
43984705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LPI_CFG),
44084705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LPI_WAKE_ERROR_CNT),
44184705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_LPI_STATUS),
44284705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_TSTPAT_MODE_CFG),
44384705fc1SMaxim Kochetkov 	REG_RESERVED(PCS1G_TSTPAT_STATUS),
44484705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_PCS_FX100_CFG),
44584705fc1SMaxim Kochetkov 	REG_RESERVED(DEV_PCS_FX100_STATUS),
44684705fc1SMaxim Kochetkov };
44784705fc1SMaxim Kochetkov 
44884705fc1SMaxim Kochetkov static const u32 *vsc9953_regmap[TARGET_MAX] = {
44984705fc1SMaxim Kochetkov 	[ANA]		= vsc9953_ana_regmap,
45084705fc1SMaxim Kochetkov 	[QS]		= vsc9953_qs_regmap,
45184705fc1SMaxim Kochetkov 	[QSYS]		= vsc9953_qsys_regmap,
45284705fc1SMaxim Kochetkov 	[REW]		= vsc9953_rew_regmap,
45384705fc1SMaxim Kochetkov 	[SYS]		= vsc9953_sys_regmap,
454e3aea296SVladimir Oltean 	[S0]		= vsc9953_vcap_regmap,
455a61e365dSVladimir Oltean 	[S1]		= vsc9953_vcap_regmap,
456c1c3993eSVladimir Oltean 	[S2]		= vsc9953_vcap_regmap,
45784705fc1SMaxim Kochetkov 	[GCB]		= vsc9953_gcb_regmap,
45884705fc1SMaxim Kochetkov 	[DEV_GMII]	= vsc9953_dev_gmii_regmap,
45984705fc1SMaxim Kochetkov };
46084705fc1SMaxim Kochetkov 
46184705fc1SMaxim Kochetkov /* Addresses are relative to the device's base address */
4621109b97bSVladimir Oltean static const struct resource vsc9953_resources[] = {
4631109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0010000, 0x0010000, "sys"),
4641109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0030000, 0x0010000, "rew"),
4651109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0040000, 0x0000400, "s0"),
4661109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0050000, 0x0000400, "s1"),
4671109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0060000, 0x0000400, "s2"),
4681109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0070000, 0x0000200, "devcpu_gcb"),
4691109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0080000, 0x0000100, "qs"),
4701109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0090000, 0x00000cc, "ptp"),
471044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0100000, 0x0010000, "port0"),
472044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0110000, 0x0010000, "port1"),
473044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0120000, 0x0010000, "port2"),
474044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0130000, 0x0010000, "port3"),
475044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0140000, 0x0010000, "port4"),
476044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0150000, 0x0010000, "port5"),
477044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0160000, 0x0010000, "port6"),
478044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0170000, 0x0010000, "port7"),
479044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0180000, 0x0010000, "port8"),
480044d447aSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0190000, 0x0010000, "port9"),
4811109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0200000, 0x0020000, "qsys"),
4821109b97bSVladimir Oltean 	DEFINE_RES_MEM_NAMED(0x0280000, 0x0010000, "ana"),
4831109b97bSVladimir Oltean };
4841109b97bSVladimir Oltean 
4851109b97bSVladimir Oltean static const char * const vsc9953_resource_names[TARGET_MAX] = {
4861109b97bSVladimir Oltean 	[SYS] = "sys",
4871109b97bSVladimir Oltean 	[REW] = "rew",
4881109b97bSVladimir Oltean 	[S0] = "s0",
4891109b97bSVladimir Oltean 	[S1] = "s1",
4901109b97bSVladimir Oltean 	[S2] = "s2",
4911109b97bSVladimir Oltean 	[GCB] = "devcpu_gcb",
4921109b97bSVladimir Oltean 	[QS] = "qs",
4931109b97bSVladimir Oltean 	[PTP] = "ptp",
4941109b97bSVladimir Oltean 	[QSYS] = "qsys",
4951109b97bSVladimir Oltean 	[ANA] = "ana",
49684705fc1SMaxim Kochetkov };
49784705fc1SMaxim Kochetkov 
49884705fc1SMaxim Kochetkov static const struct reg_field vsc9953_regfields[REGFIELD_MAX] = {
49984705fc1SMaxim Kochetkov 	[ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 10, 10),
50084705fc1SMaxim Kochetkov 	[ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 9),
50184705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
50284705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
50384705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
50484705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
50584705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
50684705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
50784705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
50884705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
50984705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
51084705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
51184705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
51284705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
51384705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
51484705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
51584705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
51684705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
51784705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
51884705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
51984705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
52084705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
52184705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
52284705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
52384705fc1SMaxim Kochetkov 	[ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
52484705fc1SMaxim Kochetkov 	[ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 16, 16),
52584705fc1SMaxim Kochetkov 	[ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 11, 12),
52684705fc1SMaxim Kochetkov 	[ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 10),
52784705fc1SMaxim Kochetkov 	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 7, 7),
52884705fc1SMaxim Kochetkov 	[SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 6, 6),
52984705fc1SMaxim Kochetkov 	[SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 5, 5),
53084705fc1SMaxim Kochetkov 	[GCB_SOFT_RST_SWC_RST] = REG_FIELD(GCB_SOFT_RST, 0, 0),
53184705fc1SMaxim Kochetkov 	[GCB_MIIM_MII_STATUS_PENDING] = REG_FIELD(GCB_MIIM_MII_STATUS, 2, 2),
53284705fc1SMaxim Kochetkov 	[GCB_MIIM_MII_STATUS_BUSY] = REG_FIELD(GCB_MIIM_MII_STATUS, 3, 3),
53384705fc1SMaxim Kochetkov 	/* Replicated per number of ports (11), register size 4 per port */
53484705fc1SMaxim Kochetkov 	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 13, 13, 11, 4),
53584705fc1SMaxim Kochetkov 	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 11, 4),
53684705fc1SMaxim Kochetkov 	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 11, 4),
53784705fc1SMaxim Kochetkov 	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 11, 4),
53884705fc1SMaxim Kochetkov 	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 11, 4),
53984705fc1SMaxim Kochetkov 	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 4, 5, 11, 4),
54084705fc1SMaxim Kochetkov 	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 2, 3, 11, 4),
54184705fc1SMaxim Kochetkov 	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 11, 4),
54284705fc1SMaxim Kochetkov 	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 11, 20, 11, 4),
54384705fc1SMaxim Kochetkov 	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 10, 11, 4),
54484705fc1SMaxim Kochetkov 	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 11, 4),
54584705fc1SMaxim Kochetkov };
54684705fc1SMaxim Kochetkov 
547e3aea296SVladimir Oltean static const struct vcap_field vsc9953_vcap_es0_keys[] = {
548e3aea296SVladimir Oltean 	[VCAP_ES0_EGR_PORT]			= {  0,  4},
549e3aea296SVladimir Oltean 	[VCAP_ES0_IGR_PORT]			= {  4,  4},
550e3aea296SVladimir Oltean 	[VCAP_ES0_RSV]				= {  8,  2},
551e3aea296SVladimir Oltean 	[VCAP_ES0_L2_MC]			= { 10,  1},
552e3aea296SVladimir Oltean 	[VCAP_ES0_L2_BC]			= { 11,  1},
553e3aea296SVladimir Oltean 	[VCAP_ES0_VID]				= { 12, 12},
554e3aea296SVladimir Oltean 	[VCAP_ES0_DP]				= { 24,  1},
555e3aea296SVladimir Oltean 	[VCAP_ES0_PCP]				= { 25,  3},
556e3aea296SVladimir Oltean };
557e3aea296SVladimir Oltean 
558e3aea296SVladimir Oltean static const struct vcap_field vsc9953_vcap_es0_actions[] = {
559e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_PUSH_OUTER_TAG]		= {  0,  2},
560e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_PUSH_INNER_TAG]		= {  2,  1},
561e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_A_TPID_SEL]		= {  3,  2},
562e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_A_VID_SEL]		= {  5,  1},
563e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_A_PCP_SEL]		= {  6,  2},
564e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_A_DEI_SEL]		= {  8,  2},
565e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_B_TPID_SEL]		= { 10,  2},
566e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_B_VID_SEL]		= { 12,  1},
567e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_B_PCP_SEL]		= { 13,  2},
568e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_TAG_B_DEI_SEL]		= { 15,  2},
569e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_VID_A_VAL]		= { 17, 12},
570e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_PCP_A_VAL]		= { 29,  3},
571e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_DEI_A_VAL]		= { 32,  1},
572e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_VID_B_VAL]		= { 33, 12},
573e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_PCP_B_VAL]		= { 45,  3},
574e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_DEI_B_VAL]		= { 48,  1},
575e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_RSV]			= { 49, 24},
576e3aea296SVladimir Oltean 	[VCAP_ES0_ACT_HIT_STICKY]		= { 73,  1},
577e3aea296SVladimir Oltean };
578e3aea296SVladimir Oltean 
579a61e365dSVladimir Oltean static const struct vcap_field vsc9953_vcap_is1_keys[] = {
580a61e365dSVladimir Oltean 	[VCAP_IS1_HK_TYPE]			= {  0,   1},
581a61e365dSVladimir Oltean 	[VCAP_IS1_HK_LOOKUP]			= {  1,   2},
582a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IGR_PORT_MASK]		= {  3,  11},
583a61e365dSVladimir Oltean 	[VCAP_IS1_HK_RSV]			= { 14,  10},
584a61e365dSVladimir Oltean 	/* VCAP_IS1_HK_OAM_Y1731 not supported */
585a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L2_MC]			= { 24,   1},
586a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L2_BC]			= { 25,   1},
587a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP_MC]			= { 26,   1},
588a61e365dSVladimir Oltean 	[VCAP_IS1_HK_VLAN_TAGGED]		= { 27,   1},
589a61e365dSVladimir Oltean 	[VCAP_IS1_HK_VLAN_DBL_TAGGED]		= { 28,   1},
590a61e365dSVladimir Oltean 	[VCAP_IS1_HK_TPID]			= { 29,   1},
591a61e365dSVladimir Oltean 	[VCAP_IS1_HK_VID]			= { 30,  12},
592a61e365dSVladimir Oltean 	[VCAP_IS1_HK_DEI]			= { 42,   1},
593a61e365dSVladimir Oltean 	[VCAP_IS1_HK_PCP]			= { 43,   3},
594a61e365dSVladimir Oltean 	/* Specific Fields for IS1 Half Key S1_NORMAL */
595a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L2_SMAC]			= { 46,  48},
596a61e365dSVladimir Oltean 	[VCAP_IS1_HK_ETYPE_LEN]			= { 94,   1},
597a61e365dSVladimir Oltean 	[VCAP_IS1_HK_ETYPE]			= { 95,  16},
598a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP_SNAP]			= {111,   1},
599a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4]			= {112,   1},
600a61e365dSVladimir Oltean 	/* Layer-3 Information */
601a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L3_FRAGMENT]		= {113,   1},
602a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L3_FRAG_OFS_GT0]		= {114,   1},
603a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L3_OPTIONS]		= {115,   1},
604a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L3_DSCP]			= {116,   6},
605a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L3_IP4_SIP]		= {122,  32},
606a61e365dSVladimir Oltean 	/* Layer-4 Information */
607a61e365dSVladimir Oltean 	[VCAP_IS1_HK_TCP_UDP]			= {154,   1},
608a61e365dSVladimir Oltean 	[VCAP_IS1_HK_TCP]			= {155,   1},
609a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L4_SPORT]			= {156,  16},
610a61e365dSVladimir Oltean 	[VCAP_IS1_HK_L4_RNG]			= {172,   8},
611a61e365dSVladimir Oltean 	/* Specific Fields for IS1 Half Key S1_5TUPLE_IP4 */
612a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_INNER_TPID]            = { 46,   1},
613a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_INNER_VID]		= { 47,  12},
614a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_INNER_DEI]		= { 59,   1},
615a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_INNER_PCP]		= { 60,   3},
616a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_IP4]			= { 63,   1},
617a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_FRAGMENT]		= { 64,   1},
618a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_FRAG_OFS_GT0]	= { 65,   1},
619a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_OPTIONS]		= { 66,   1},
620a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_DSCP]		= { 67,   6},
621a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_IP4_DIP]		= { 73,  32},
622a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_IP4_SIP]		= {105,  32},
623a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L3_PROTO]		= {137,   8},
624a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_TCP_UDP]		= {145,   1},
625a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_TCP]			= {146,   1},
626a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_L4_RNG]		= {147,   8},
627a61e365dSVladimir Oltean 	[VCAP_IS1_HK_IP4_IP_PAYLOAD_S1_5TUPLE]	= {155,  32},
628a61e365dSVladimir Oltean };
629a61e365dSVladimir Oltean 
630a61e365dSVladimir Oltean static const struct vcap_field vsc9953_vcap_is1_actions[] = {
631a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_DSCP_ENA]			= {  0,  1},
632a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_DSCP_VAL]			= {  1,  6},
633a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_QOS_ENA]			= {  7,  1},
634a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_QOS_VAL]			= {  8,  3},
635a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_DP_ENA]			= { 11,  1},
636a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_DP_VAL]			= { 12,  1},
637a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_PAG_OVERRIDE_MASK]	= { 13,  8},
638a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_PAG_VAL]			= { 21,  8},
639a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_RSV]			= { 29, 11},
640a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_VID_REPLACE_ENA]		= { 40,  1},
641a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_VID_ADD_VAL]		= { 41, 12},
642a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_FID_SEL]			= { 53,  2},
643a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_FID_VAL]			= { 55, 13},
644a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_PCP_DEI_ENA]		= { 68,  1},
645a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_PCP_VAL]			= { 69,  3},
646a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_DEI_VAL]			= { 72,  1},
647a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_VLAN_POP_CNT_ENA]		= { 73,  1},
648a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_VLAN_POP_CNT]		= { 74,  2},
649a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_CUSTOM_ACE_TYPE_ENA]	= { 76,  4},
650a61e365dSVladimir Oltean 	[VCAP_IS1_ACT_HIT_STICKY]		= { 80,  1},
651a61e365dSVladimir Oltean };
652a61e365dSVladimir Oltean 
65384705fc1SMaxim Kochetkov static struct vcap_field vsc9953_vcap_is2_keys[] = {
65484705fc1SMaxim Kochetkov 	/* Common: 41 bits */
65584705fc1SMaxim Kochetkov 	[VCAP_IS2_TYPE]				= {  0,   4},
65684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_FIRST]			= {  4,   1},
65784705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_PAG]			= {  5,   8},
65884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IGR_PORT_MASK]		= { 13,  11},
65984705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_RSV2]			= { 24,   1},
66084705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_HOST_MATCH]		= { 25,   1},
66184705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L2_MC]			= { 26,   1},
66284705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L2_BC]			= { 27,   1},
66384705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_VLAN_TAGGED]		= { 28,   1},
66484705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_VID]			= { 29,  12},
66584705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_DEI]			= { 41,   1},
66684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_PCP]			= { 42,   3},
66784705fc1SMaxim Kochetkov 	/* MAC_ETYPE / MAC_LLC / MAC_SNAP / OAM common */
66884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L2_DMAC]			= { 45,  48},
66984705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L2_SMAC]			= { 93,  48},
67084705fc1SMaxim Kochetkov 	/* MAC_ETYPE (TYPE=000) */
67184705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ETYPE_ETYPE]		= {141,  16},
67284705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD0]	= {157,  16},
67384705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD1]	= {173,   8},
67484705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD2]	= {181,   3},
67584705fc1SMaxim Kochetkov 	/* MAC_LLC (TYPE=001) */
67684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_LLC_L2_LLC]		= {141,  40},
67784705fc1SMaxim Kochetkov 	/* MAC_SNAP (TYPE=010) */
67884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_SNAP_L2_SNAP]		= {141,  40},
67984705fc1SMaxim Kochetkov 	/* MAC_ARP (TYPE=011) */
68084705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_SMAC]		= { 45,  48},
68184705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_ADDR_SPACE_OK]	= { 93,   1},
68284705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_PROTO_SPACE_OK]	= { 94,   1},
68384705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_LEN_OK]		= { 95,   1},
68484705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_TARGET_MATCH]	= { 96,   1},
68584705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_SENDER_MATCH]	= { 97,   1},
68684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_OPCODE_UNKNOWN]	= { 98,   1},
68784705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_OPCODE]		= { 99,   2},
68884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_L3_IP4_DIP]	= {101,  32},
68984705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_L3_IP4_SIP]	= {133,  32},
69084705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_MAC_ARP_DIP_EQ_SIP]	= {165,   1},
69184705fc1SMaxim Kochetkov 	/* IP4_TCP_UDP / IP4_OTHER common */
69284705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IP4]			= { 45,   1},
69384705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_FRAGMENT]		= { 46,   1},
69484705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_FRAG_OFS_GT0]		= { 47,   1},
69584705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_OPTIONS]		= { 48,   1},
69684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IP4_L3_TTL_GT0]		= { 49,   1},
69784705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_TOS]			= { 50,   8},
69884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_IP4_DIP]		= { 58,  32},
69984705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_IP4_SIP]		= { 90,  32},
70084705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_DIP_EQ_SIP]		= {122,   1},
70184705fc1SMaxim Kochetkov 	/* IP4_TCP_UDP (TYPE=100) */
70284705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_TCP]			= {123,   1},
7037a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_DPORT]			= {124,  16},
7047a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_SPORT]			= {140,  16},
70584705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L4_RNG]			= {156,   8},
70684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L4_SPORT_EQ_DPORT]		= {164,   1},
70784705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L4_SEQUENCE_EQ0]		= {165,   1},
7087a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_FIN]			= {166,   1},
7097a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_SYN]			= {167,   1},
7107a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_RST]			= {168,   1},
7117a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_PSH]			= {169,   1},
7127a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_ACK]			= {170,   1},
7137a023075SVladimir Oltean 	[VCAP_IS2_HK_L4_URG]			= {171,   1},
71484705fc1SMaxim Kochetkov 	/* IP4_OTHER (TYPE=101) */
71584705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IP4_L3_PROTO]		= {123,   8},
71684705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_PAYLOAD]		= {131,  56},
71784705fc1SMaxim Kochetkov 	/* IP6_STD (TYPE=110) */
71884705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IP6_L3_TTL_GT0]		= { 45,   1},
71984705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_L3_IP6_SIP]		= { 46, 128},
72084705fc1SMaxim Kochetkov 	[VCAP_IS2_HK_IP6_L3_PROTO]		= {174,   8},
72184705fc1SMaxim Kochetkov };
72284705fc1SMaxim Kochetkov 
72384705fc1SMaxim Kochetkov static struct vcap_field vsc9953_vcap_is2_actions[] = {
72484705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_HIT_ME_ONCE]		= {  0,  1},
72584705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_CPU_COPY_ENA]		= {  1,  1},
72684705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_CPU_QU_NUM]		= {  2,  3},
72784705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_MASK_MODE]		= {  5,  2},
72884705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_MIRROR_ENA]		= {  7,  1},
72984705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_LRN_DIS]			= {  8,  1},
73084705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_POLICE_ENA]		= {  9,  1},
73184705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_POLICE_IDX]		= { 10,  8},
73284705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_POLICE_VCAP_ONLY]		= { 21,  1},
73384705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_PORT_MASK]		= { 22, 10},
73484705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_ACL_ID]			= { 44,  6},
73584705fc1SMaxim Kochetkov 	[VCAP_IS2_ACT_HIT_CNT]			= { 50, 32},
73684705fc1SMaxim Kochetkov };
73784705fc1SMaxim Kochetkov 
73820968054SVladimir Oltean static struct vcap_props vsc9953_vcap_props[] = {
739e3aea296SVladimir Oltean 	[VCAP_ES0] = {
740e3aea296SVladimir Oltean 		.action_type_width = 0,
741e3aea296SVladimir Oltean 		.action_table = {
742e3aea296SVladimir Oltean 			[ES0_ACTION_TYPE_NORMAL] = {
743e3aea296SVladimir Oltean 				.width = 73, /* HIT_STICKY not included */
744e3aea296SVladimir Oltean 				.count = 1,
745e3aea296SVladimir Oltean 			},
746e3aea296SVladimir Oltean 		},
747e3aea296SVladimir Oltean 		.target = S0,
748e3aea296SVladimir Oltean 		.keys = vsc9953_vcap_es0_keys,
749e3aea296SVladimir Oltean 		.actions = vsc9953_vcap_es0_actions,
750e3aea296SVladimir Oltean 	},
751a61e365dSVladimir Oltean 	[VCAP_IS1] = {
752a61e365dSVladimir Oltean 		.action_type_width = 0,
753a61e365dSVladimir Oltean 		.action_table = {
754a61e365dSVladimir Oltean 			[IS1_ACTION_TYPE_NORMAL] = {
755a61e365dSVladimir Oltean 				.width = 80, /* HIT_STICKY not included */
756a61e365dSVladimir Oltean 				.count = 4,
757a61e365dSVladimir Oltean 			},
758a61e365dSVladimir Oltean 		},
759a61e365dSVladimir Oltean 		.target = S1,
760a61e365dSVladimir Oltean 		.keys = vsc9953_vcap_is1_keys,
761a61e365dSVladimir Oltean 		.actions = vsc9953_vcap_is1_actions,
762a61e365dSVladimir Oltean 	},
76384705fc1SMaxim Kochetkov 	[VCAP_IS2] = {
76484705fc1SMaxim Kochetkov 		.action_type_width = 1,
76584705fc1SMaxim Kochetkov 		.action_table = {
76684705fc1SMaxim Kochetkov 			[IS2_ACTION_TYPE_NORMAL] = {
767eaa0355cSVladimir Oltean 				.width = 50, /* HIT_CNT not included */
76884705fc1SMaxim Kochetkov 				.count = 2
76984705fc1SMaxim Kochetkov 			},
77084705fc1SMaxim Kochetkov 			[IS2_ACTION_TYPE_SMAC_SIP] = {
77184705fc1SMaxim Kochetkov 				.width = 6,
77284705fc1SMaxim Kochetkov 				.count = 4
77384705fc1SMaxim Kochetkov 			},
77484705fc1SMaxim Kochetkov 		},
775c1c3993eSVladimir Oltean 		.target = S2,
776c1c3993eSVladimir Oltean 		.keys = vsc9953_vcap_is2_keys,
777c1c3993eSVladimir Oltean 		.actions = vsc9953_vcap_is2_actions,
77884705fc1SMaxim Kochetkov 	},
77984705fc1SMaxim Kochetkov };
78084705fc1SMaxim Kochetkov 
78184705fc1SMaxim Kochetkov #define VSC9953_INIT_TIMEOUT			50000
78284705fc1SMaxim Kochetkov #define VSC9953_GCB_RST_SLEEP			100
78384705fc1SMaxim Kochetkov #define VSC9953_SYS_RAMINIT_SLEEP		80
78484705fc1SMaxim Kochetkov 
vsc9953_gcb_soft_rst_status(struct ocelot * ocelot)78584705fc1SMaxim Kochetkov static int vsc9953_gcb_soft_rst_status(struct ocelot *ocelot)
78684705fc1SMaxim Kochetkov {
78784705fc1SMaxim Kochetkov 	int val;
78884705fc1SMaxim Kochetkov 
78984705fc1SMaxim Kochetkov 	ocelot_field_read(ocelot, GCB_SOFT_RST_SWC_RST, &val);
79084705fc1SMaxim Kochetkov 
79184705fc1SMaxim Kochetkov 	return val;
79284705fc1SMaxim Kochetkov }
79384705fc1SMaxim Kochetkov 
vsc9953_sys_ram_init_status(struct ocelot * ocelot)79484705fc1SMaxim Kochetkov static int vsc9953_sys_ram_init_status(struct ocelot *ocelot)
79584705fc1SMaxim Kochetkov {
79684705fc1SMaxim Kochetkov 	int val;
79784705fc1SMaxim Kochetkov 
79884705fc1SMaxim Kochetkov 	ocelot_field_read(ocelot, SYS_RESET_CFG_MEM_INIT, &val);
79984705fc1SMaxim Kochetkov 
80084705fc1SMaxim Kochetkov 	return val;
80184705fc1SMaxim Kochetkov }
80284705fc1SMaxim Kochetkov 
80384705fc1SMaxim Kochetkov 
804c129fc55SVladimir Oltean /* CORE_ENA is in SYS:SYSTEM:RESET_CFG
805c129fc55SVladimir Oltean  * MEM_INIT is in SYS:SYSTEM:RESET_CFG
806c129fc55SVladimir Oltean  * MEM_ENA is in SYS:SYSTEM:RESET_CFG
807c129fc55SVladimir Oltean  */
vsc9953_reset(struct ocelot * ocelot)80884705fc1SMaxim Kochetkov static int vsc9953_reset(struct ocelot *ocelot)
80984705fc1SMaxim Kochetkov {
81084705fc1SMaxim Kochetkov 	int val, err;
81184705fc1SMaxim Kochetkov 
81284705fc1SMaxim Kochetkov 	/* soft-reset the switch core */
81384705fc1SMaxim Kochetkov 	ocelot_field_write(ocelot, GCB_SOFT_RST_SWC_RST, 1);
81484705fc1SMaxim Kochetkov 
81584705fc1SMaxim Kochetkov 	err = readx_poll_timeout(vsc9953_gcb_soft_rst_status, ocelot, val, !val,
81684705fc1SMaxim Kochetkov 				 VSC9953_GCB_RST_SLEEP, VSC9953_INIT_TIMEOUT);
81784705fc1SMaxim Kochetkov 	if (err) {
81884705fc1SMaxim Kochetkov 		dev_err(ocelot->dev, "timeout: switch core reset\n");
81984705fc1SMaxim Kochetkov 		return err;
82084705fc1SMaxim Kochetkov 	}
82184705fc1SMaxim Kochetkov 
82284705fc1SMaxim Kochetkov 	/* initialize switch mem ~40us */
82384705fc1SMaxim Kochetkov 	ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_ENA, 1);
8249a73f0b5SVladimir Oltean 	ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_INIT, 1);
82584705fc1SMaxim Kochetkov 
82684705fc1SMaxim Kochetkov 	err = readx_poll_timeout(vsc9953_sys_ram_init_status, ocelot, val, !val,
82784705fc1SMaxim Kochetkov 				 VSC9953_SYS_RAMINIT_SLEEP,
82884705fc1SMaxim Kochetkov 				 VSC9953_INIT_TIMEOUT);
82984705fc1SMaxim Kochetkov 	if (err) {
83084705fc1SMaxim Kochetkov 		dev_err(ocelot->dev, "timeout: switch sram init\n");
83184705fc1SMaxim Kochetkov 		return err;
83284705fc1SMaxim Kochetkov 	}
83384705fc1SMaxim Kochetkov 
83484705fc1SMaxim Kochetkov 	/* enable switch core */
83584705fc1SMaxim Kochetkov 	ocelot_field_write(ocelot, SYS_RESET_CFG_CORE_ENA, 1);
83684705fc1SMaxim Kochetkov 
83784705fc1SMaxim Kochetkov 	return 0;
83884705fc1SMaxim Kochetkov }
83984705fc1SMaxim Kochetkov 
84084705fc1SMaxim Kochetkov /* Watermark encode
84184705fc1SMaxim Kochetkov  * Bit 9:   Unit; 0:1, 1:16
84284705fc1SMaxim Kochetkov  * Bit 8-0: Value to be multiplied with unit
84384705fc1SMaxim Kochetkov  */
vsc9953_wm_enc(u16 value)84484705fc1SMaxim Kochetkov static u16 vsc9953_wm_enc(u16 value)
84584705fc1SMaxim Kochetkov {
84601326493SVladimir Oltean 	WARN_ON(value >= 16 * BIT(9));
84701326493SVladimir Oltean 
84884705fc1SMaxim Kochetkov 	if (value >= BIT(9))
84984705fc1SMaxim Kochetkov 		return BIT(9) | (value / 16);
85084705fc1SMaxim Kochetkov 
85184705fc1SMaxim Kochetkov 	return value;
85284705fc1SMaxim Kochetkov }
85384705fc1SMaxim Kochetkov 
vsc9953_wm_dec(u16 wm)854703b7621SVladimir Oltean static u16 vsc9953_wm_dec(u16 wm)
855703b7621SVladimir Oltean {
856703b7621SVladimir Oltean 	WARN_ON(wm & ~GENMASK(9, 0));
857703b7621SVladimir Oltean 
858703b7621SVladimir Oltean 	if (wm & BIT(9))
859703b7621SVladimir Oltean 		return (wm & GENMASK(8, 0)) * 16;
860703b7621SVladimir Oltean 
861703b7621SVladimir Oltean 	return wm;
862703b7621SVladimir Oltean }
863703b7621SVladimir Oltean 
vsc9953_wm_stat(u32 val,u32 * inuse,u32 * maxuse)864703b7621SVladimir Oltean static void vsc9953_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
865703b7621SVladimir Oltean {
866703b7621SVladimir Oltean 	*inuse = (val & GENMASK(25, 13)) >> 13;
867703b7621SVladimir Oltean 	*maxuse = val & GENMASK(12, 0);
868703b7621SVladimir Oltean }
869703b7621SVladimir Oltean 
87084705fc1SMaxim Kochetkov static const struct ocelot_ops vsc9953_ops = {
87184705fc1SMaxim Kochetkov 	.reset			= vsc9953_reset,
87284705fc1SMaxim Kochetkov 	.wm_enc			= vsc9953_wm_enc,
873703b7621SVladimir Oltean 	.wm_dec			= vsc9953_wm_dec,
874703b7621SVladimir Oltean 	.wm_stat		= vsc9953_wm_stat,
875319e4dd1SVladimir Oltean 	.port_to_netdev		= felix_port_to_netdev,
876319e4dd1SVladimir Oltean 	.netdev_to_port		= felix_netdev_to_port,
87784705fc1SMaxim Kochetkov };
87884705fc1SMaxim Kochetkov 
vsc9953_mdio_bus_alloc(struct ocelot * ocelot)87984705fc1SMaxim Kochetkov static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
88084705fc1SMaxim Kochetkov {
88184705fc1SMaxim Kochetkov 	struct felix *felix = ocelot_to_felix(ocelot);
88284705fc1SMaxim Kochetkov 	struct device *dev = ocelot->dev;
88384705fc1SMaxim Kochetkov 	struct mii_bus *bus;
88484705fc1SMaxim Kochetkov 	int port;
88584705fc1SMaxim Kochetkov 	int rc;
88684705fc1SMaxim Kochetkov 
88784705fc1SMaxim Kochetkov 	felix->pcs = devm_kcalloc(dev, felix->info->num_ports,
888e7026f15SColin Foster 				  sizeof(struct phylink_pcs *),
88984705fc1SMaxim Kochetkov 				  GFP_KERNEL);
89084705fc1SMaxim Kochetkov 	if (!felix->pcs) {
89184705fc1SMaxim Kochetkov 		dev_err(dev, "failed to allocate array for PCS PHYs\n");
89284705fc1SMaxim Kochetkov 		return -ENOMEM;
89384705fc1SMaxim Kochetkov 	}
89484705fc1SMaxim Kochetkov 
895b9965845SColin Foster 	rc = mscc_miim_setup(dev, &bus, "VSC9953 internal MDIO bus",
896b9965845SColin Foster 			     ocelot->targets[GCB],
8970322ef49SVladimir Oltean 			     ocelot->map[GCB][GCB_MIIM_MII_STATUS & REG_MASK],
8980322ef49SVladimir Oltean 			     true);
899b9965845SColin Foster 	if (rc) {
900b9965845SColin Foster 		dev_err(dev, "failed to setup MDIO bus\n");
901b9965845SColin Foster 		return rc;
902b9965845SColin Foster 	}
90384705fc1SMaxim Kochetkov 
90484705fc1SMaxim Kochetkov 	/* Needed in order to initialize the bus mutex lock */
905bd488afcSVladimir Oltean 	rc = devm_of_mdiobus_register(dev, bus, NULL);
90684705fc1SMaxim Kochetkov 	if (rc < 0) {
90784705fc1SMaxim Kochetkov 		dev_err(dev, "failed to register MDIO bus\n");
90884705fc1SMaxim Kochetkov 		return rc;
90984705fc1SMaxim Kochetkov 	}
91084705fc1SMaxim Kochetkov 
91184705fc1SMaxim Kochetkov 	felix->imdio = bus;
91284705fc1SMaxim Kochetkov 
91384705fc1SMaxim Kochetkov 	for (port = 0; port < felix->info->num_ports; port++) {
91484705fc1SMaxim Kochetkov 		struct ocelot_port *ocelot_port = ocelot->ports[port];
915e7026f15SColin Foster 		struct phylink_pcs *phylink_pcs;
916e7026f15SColin Foster 		int addr = port + 4;
917588d0550SIoana Ciornei 
918588d0550SIoana Ciornei 		if (dsa_is_unused_port(felix->ds, port))
919588d0550SIoana Ciornei 			continue;
92084705fc1SMaxim Kochetkov 
92184705fc1SMaxim Kochetkov 		if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_INTERNAL)
92284705fc1SMaxim Kochetkov 			continue;
92384705fc1SMaxim Kochetkov 
9245767c6a8SRussell King (Oracle) 		phylink_pcs = lynx_pcs_create_mdiodev(felix->imdio, addr);
9255767c6a8SRussell King (Oracle) 		if (IS_ERR(phylink_pcs))
92684705fc1SMaxim Kochetkov 			continue;
92784705fc1SMaxim Kochetkov 
928e7026f15SColin Foster 		felix->pcs[port] = phylink_pcs;
92984705fc1SMaxim Kochetkov 
93084705fc1SMaxim Kochetkov 		dev_info(dev, "Found PCS at internal MDIO address %d\n", addr);
93184705fc1SMaxim Kochetkov 	}
93284705fc1SMaxim Kochetkov 
93384705fc1SMaxim Kochetkov 	return 0;
93484705fc1SMaxim Kochetkov }
93584705fc1SMaxim Kochetkov 
vsc9953_mdio_bus_free(struct ocelot * ocelot)936ccfdbab5SVladimir Oltean static void vsc9953_mdio_bus_free(struct ocelot *ocelot)
937ccfdbab5SVladimir Oltean {
938ccfdbab5SVladimir Oltean 	struct felix *felix = ocelot_to_felix(ocelot);
939ccfdbab5SVladimir Oltean 	int port;
940ccfdbab5SVladimir Oltean 
941ccfdbab5SVladimir Oltean 	for (port = 0; port < ocelot->num_phys_ports; port++) {
942e7026f15SColin Foster 		struct phylink_pcs *phylink_pcs = felix->pcs[port];
943ccfdbab5SVladimir Oltean 
9445767c6a8SRussell King (Oracle) 		if (phylink_pcs)
945e7026f15SColin Foster 			lynx_pcs_destroy(phylink_pcs);
946ccfdbab5SVladimir Oltean 	}
947bd488afcSVladimir Oltean 
948bd488afcSVladimir Oltean 	/* mdiobus_unregister and mdiobus_free handled by devres */
949ccfdbab5SVladimir Oltean }
950ccfdbab5SVladimir Oltean 
95184705fc1SMaxim Kochetkov static const struct felix_info seville_info_vsc9953 = {
9521109b97bSVladimir Oltean 	.resources		= vsc9953_resources,
9531109b97bSVladimir Oltean 	.num_resources		= ARRAY_SIZE(vsc9953_resources),
9541109b97bSVladimir Oltean 	.resource_names		= vsc9953_resource_names,
95584705fc1SMaxim Kochetkov 	.regfields		= vsc9953_regfields,
95684705fc1SMaxim Kochetkov 	.map			= vsc9953_regmap,
95784705fc1SMaxim Kochetkov 	.ops			= &vsc9953_ops,
95884705fc1SMaxim Kochetkov 	.vcap			= vsc9953_vcap_props,
95977043c37SXiaoliang Yang 	.vcap_pol_base		= VSC9953_VCAP_POLICER_BASE,
96077043c37SXiaoliang Yang 	.vcap_pol_max		= VSC9953_VCAP_POLICER_MAX,
96177043c37SXiaoliang Yang 	.vcap_pol_base2		= VSC9953_VCAP_POLICER_BASE2,
96277043c37SXiaoliang Yang 	.vcap_pol_max2		= VSC9953_VCAP_POLICER_MAX2,
9631dc6a2a0SColin Foster 	.quirks			= FELIX_MAC_QUIRKS,
96484705fc1SMaxim Kochetkov 	.num_mact_rows		= 2048,
965acf242fcSColin Foster 	.num_ports		= VSC9953_NUM_PORTS,
96684705fc1SMaxim Kochetkov 	.mdio_bus_alloc		= vsc9953_mdio_bus_alloc,
967ccfdbab5SVladimir Oltean 	.mdio_bus_free		= vsc9953_mdio_bus_free,
968acf242fcSColin Foster 	.port_modes		= vsc9953_port_modes,
96984705fc1SMaxim Kochetkov };
97084705fc1SMaxim Kochetkov 
seville_probe(struct platform_device * pdev)97184705fc1SMaxim Kochetkov static int seville_probe(struct platform_device *pdev)
97284705fc1SMaxim Kochetkov {
97390ee9a5bSVladimir Oltean 	struct device *dev = &pdev->dev;
97484705fc1SMaxim Kochetkov 	struct resource *res;
97584705fc1SMaxim Kochetkov 
97684705fc1SMaxim Kochetkov 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
977f1fe19c2SYang Yingliang 	if (!res) {
97890ee9a5bSVladimir Oltean 		dev_err(dev, "Invalid resource\n");
97990ee9a5bSVladimir Oltean 		return -EINVAL;
980f1fe19c2SYang Yingliang 	}
98184705fc1SMaxim Kochetkov 
982*efdbee7dSVladimir Oltean 	return felix_register_switch(dev, res->start, 1, false, false,
983*efdbee7dSVladimir Oltean 				     DSA_TAG_PROTO_SEVILLE,
984*efdbee7dSVladimir Oltean 				     &seville_info_vsc9953);
98584705fc1SMaxim Kochetkov }
98684705fc1SMaxim Kochetkov 
seville_remove(struct platform_device * pdev)98768ace16cSUwe Kleine-König static void seville_remove(struct platform_device *pdev)
98884705fc1SMaxim Kochetkov {
9890650bf52SVladimir Oltean 	struct felix *felix = platform_get_drvdata(pdev);
99084705fc1SMaxim Kochetkov 
9910650bf52SVladimir Oltean 	if (!felix)
99268ace16cSUwe Kleine-König 		return;
99384705fc1SMaxim Kochetkov 
99484705fc1SMaxim Kochetkov 	dsa_unregister_switch(felix->ds);
99584705fc1SMaxim Kochetkov }
99684705fc1SMaxim Kochetkov 
seville_shutdown(struct platform_device * pdev)9970650bf52SVladimir Oltean static void seville_shutdown(struct platform_device *pdev)
9980650bf52SVladimir Oltean {
9990650bf52SVladimir Oltean 	struct felix *felix = platform_get_drvdata(pdev);
10000650bf52SVladimir Oltean 
10010650bf52SVladimir Oltean 	if (!felix)
10020650bf52SVladimir Oltean 		return;
10030650bf52SVladimir Oltean 
10040650bf52SVladimir Oltean 	dsa_switch_shutdown(felix->ds);
10050650bf52SVladimir Oltean 
10060650bf52SVladimir Oltean 	platform_set_drvdata(pdev, NULL);
10070650bf52SVladimir Oltean }
10080650bf52SVladimir Oltean 
100984705fc1SMaxim Kochetkov static const struct of_device_id seville_of_match[] = {
101084705fc1SMaxim Kochetkov 	{ .compatible = "mscc,vsc9953-switch" },
101184705fc1SMaxim Kochetkov 	{ },
101284705fc1SMaxim Kochetkov };
101384705fc1SMaxim Kochetkov MODULE_DEVICE_TABLE(of, seville_of_match);
101484705fc1SMaxim Kochetkov 
1015d60bc62dSVladimir Oltean static struct platform_driver seville_vsc9953_driver = {
101684705fc1SMaxim Kochetkov 	.probe		= seville_probe,
101768ace16cSUwe Kleine-König 	.remove_new	= seville_remove,
10180650bf52SVladimir Oltean 	.shutdown	= seville_shutdown,
101984705fc1SMaxim Kochetkov 	.driver = {
102084705fc1SMaxim Kochetkov 		.name		= "mscc_seville",
10211eb8566dSKrzysztof Kozlowski 		.of_match_table	= seville_of_match,
102284705fc1SMaxim Kochetkov 	},
102384705fc1SMaxim Kochetkov };
1024d60bc62dSVladimir Oltean module_platform_driver(seville_vsc9953_driver);
1025d60bc62dSVladimir Oltean 
1026d60bc62dSVladimir Oltean MODULE_DESCRIPTION("Seville Switch driver");
1027d60bc62dSVladimir Oltean MODULE_LICENSE("GPL v2");
1028