162306a36Sopenharmony_ci// SPDX-License-Identifier: (GPL-2.0 OR MIT)
262306a36Sopenharmony_ci/* Distributed Switch Architecture VSC9953 driver
362306a36Sopenharmony_ci * Copyright (C) 2020, Maxim Kochetkov <fido_max@inbox.ru>
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci#include <linux/platform_device.h>
662306a36Sopenharmony_ci#include <linux/types.h>
762306a36Sopenharmony_ci#include <soc/mscc/ocelot_vcap.h>
862306a36Sopenharmony_ci#include <soc/mscc/ocelot_sys.h>
962306a36Sopenharmony_ci#include <soc/mscc/ocelot.h>
1062306a36Sopenharmony_ci#include <linux/mdio/mdio-mscc-miim.h>
1162306a36Sopenharmony_ci#include <linux/mod_devicetable.h>
1262306a36Sopenharmony_ci#include <linux/of_mdio.h>
1362306a36Sopenharmony_ci#include <linux/pcs-lynx.h>
1462306a36Sopenharmony_ci#include <linux/dsa/ocelot.h>
1562306a36Sopenharmony_ci#include <linux/iopoll.h>
1662306a36Sopenharmony_ci#include "felix.h"
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define VSC9953_NUM_PORTS			10
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define VSC9953_VCAP_POLICER_BASE		11
2162306a36Sopenharmony_ci#define VSC9953_VCAP_POLICER_MAX		31
2262306a36Sopenharmony_ci#define VSC9953_VCAP_POLICER_BASE2		120
2362306a36Sopenharmony_ci#define VSC9953_VCAP_POLICER_MAX2		161
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define VSC9953_PORT_MODE_SERDES		(OCELOT_PORT_MODE_1000BASEX | \
2662306a36Sopenharmony_ci						 OCELOT_PORT_MODE_SGMII | \
2762306a36Sopenharmony_ci						 OCELOT_PORT_MODE_QSGMII)
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cistatic const u32 vsc9953_port_modes[VSC9953_NUM_PORTS] = {
3062306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3162306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3262306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3362306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3462306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3562306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3662306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3762306a36Sopenharmony_ci	VSC9953_PORT_MODE_SERDES,
3862306a36Sopenharmony_ci	OCELOT_PORT_MODE_INTERNAL,
3962306a36Sopenharmony_ci	OCELOT_PORT_MODE_INTERNAL,
4062306a36Sopenharmony_ci};
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cistatic const u32 vsc9953_ana_regmap[] = {
4362306a36Sopenharmony_ci	REG(ANA_ADVLEARN,			0x00b500),
4462306a36Sopenharmony_ci	REG(ANA_VLANMASK,			0x00b504),
4562306a36Sopenharmony_ci	REG_RESERVED(ANA_PORT_B_DOMAIN),
4662306a36Sopenharmony_ci	REG(ANA_ANAGEFIL,			0x00b50c),
4762306a36Sopenharmony_ci	REG(ANA_ANEVENTS,			0x00b510),
4862306a36Sopenharmony_ci	REG(ANA_STORMLIMIT_BURST,		0x00b514),
4962306a36Sopenharmony_ci	REG(ANA_STORMLIMIT_CFG,			0x00b518),
5062306a36Sopenharmony_ci	REG(ANA_ISOLATED_PORTS,			0x00b528),
5162306a36Sopenharmony_ci	REG(ANA_COMMUNITY_PORTS,		0x00b52c),
5262306a36Sopenharmony_ci	REG(ANA_AUTOAGE,			0x00b530),
5362306a36Sopenharmony_ci	REG(ANA_MACTOPTIONS,			0x00b534),
5462306a36Sopenharmony_ci	REG(ANA_LEARNDISC,			0x00b538),
5562306a36Sopenharmony_ci	REG(ANA_AGENCTRL,			0x00b53c),
5662306a36Sopenharmony_ci	REG(ANA_MIRRORPORTS,			0x00b540),
5762306a36Sopenharmony_ci	REG(ANA_EMIRRORPORTS,			0x00b544),
5862306a36Sopenharmony_ci	REG(ANA_FLOODING,			0x00b548),
5962306a36Sopenharmony_ci	REG(ANA_FLOODING_IPMC,			0x00b54c),
6062306a36Sopenharmony_ci	REG(ANA_SFLOW_CFG,			0x00b550),
6162306a36Sopenharmony_ci	REG(ANA_PORT_MODE,			0x00b57c),
6262306a36Sopenharmony_ci	REG_RESERVED(ANA_CUT_THRU_CFG),
6362306a36Sopenharmony_ci	REG(ANA_PGID_PGID,			0x00b600),
6462306a36Sopenharmony_ci	REG(ANA_TABLES_ANMOVED,			0x00b4ac),
6562306a36Sopenharmony_ci	REG(ANA_TABLES_MACHDATA,		0x00b4b0),
6662306a36Sopenharmony_ci	REG(ANA_TABLES_MACLDATA,		0x00b4b4),
6762306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_STREAMDATA),
6862306a36Sopenharmony_ci	REG(ANA_TABLES_MACACCESS,		0x00b4b8),
6962306a36Sopenharmony_ci	REG(ANA_TABLES_MACTINDX,		0x00b4bc),
7062306a36Sopenharmony_ci	REG(ANA_TABLES_VLANACCESS,		0x00b4c0),
7162306a36Sopenharmony_ci	REG(ANA_TABLES_VLANTIDX,		0x00b4c4),
7262306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_ISDXACCESS),
7362306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_ISDXTIDX),
7462306a36Sopenharmony_ci	REG(ANA_TABLES_ENTRYLIM,		0x00b480),
7562306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_PTP_ID_HIGH),
7662306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_PTP_ID_LOW),
7762306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_STREAMACCESS),
7862306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_STREAMTIDX),
7962306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_SEQ_HISTORY),
8062306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_SEQ_MASK),
8162306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_SFID_MASK),
8262306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_SFIDACCESS),
8362306a36Sopenharmony_ci	REG_RESERVED(ANA_TABLES_SFIDTIDX),
8462306a36Sopenharmony_ci	REG_RESERVED(ANA_MSTI_STATE),
8562306a36Sopenharmony_ci	REG_RESERVED(ANA_OAM_UPM_LM_CNT),
8662306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_ACCESS_CTRL),
8762306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_CONFIG_REG_1),
8862306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_CONFIG_REG_2),
8962306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_CONFIG_REG_3),
9062306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_CONFIG_REG_4),
9162306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_CONFIG_REG_5),
9262306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_GCL_GS_CONFIG),
9362306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_GCL_TI_CONFIG),
9462306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_STATUS_REG_1),
9562306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_STATUS_REG_2),
9662306a36Sopenharmony_ci	REG_RESERVED(ANA_SG_STATUS_REG_3),
9762306a36Sopenharmony_ci	REG(ANA_PORT_VLAN_CFG,			0x000000),
9862306a36Sopenharmony_ci	REG(ANA_PORT_DROP_CFG,			0x000004),
9962306a36Sopenharmony_ci	REG(ANA_PORT_QOS_CFG,			0x000008),
10062306a36Sopenharmony_ci	REG(ANA_PORT_VCAP_CFG,			0x00000c),
10162306a36Sopenharmony_ci	REG(ANA_PORT_VCAP_S1_KEY_CFG,		0x000010),
10262306a36Sopenharmony_ci	REG(ANA_PORT_VCAP_S2_CFG,		0x00001c),
10362306a36Sopenharmony_ci	REG(ANA_PORT_PCP_DEI_MAP,		0x000020),
10462306a36Sopenharmony_ci	REG(ANA_PORT_CPU_FWD_CFG,		0x000060),
10562306a36Sopenharmony_ci	REG(ANA_PORT_CPU_FWD_BPDU_CFG,		0x000064),
10662306a36Sopenharmony_ci	REG(ANA_PORT_CPU_FWD_GARP_CFG,		0x000068),
10762306a36Sopenharmony_ci	REG(ANA_PORT_CPU_FWD_CCM_CFG,		0x00006c),
10862306a36Sopenharmony_ci	REG(ANA_PORT_PORT_CFG,			0x000070),
10962306a36Sopenharmony_ci	REG(ANA_PORT_POL_CFG,			0x000074),
11062306a36Sopenharmony_ci	REG_RESERVED(ANA_PORT_PTP_CFG),
11162306a36Sopenharmony_ci	REG_RESERVED(ANA_PORT_PTP_DLY1_CFG),
11262306a36Sopenharmony_ci	REG_RESERVED(ANA_PORT_PTP_DLY2_CFG),
11362306a36Sopenharmony_ci	REG_RESERVED(ANA_PORT_SFID_CFG),
11462306a36Sopenharmony_ci	REG(ANA_PFC_PFC_CFG,			0x00c000),
11562306a36Sopenharmony_ci	REG_RESERVED(ANA_PFC_PFC_TIMER),
11662306a36Sopenharmony_ci	REG_RESERVED(ANA_IPT_OAM_MEP_CFG),
11762306a36Sopenharmony_ci	REG_RESERVED(ANA_IPT_IPT),
11862306a36Sopenharmony_ci	REG_RESERVED(ANA_PPT_PPT),
11962306a36Sopenharmony_ci	REG_RESERVED(ANA_FID_MAP_FID_MAP),
12062306a36Sopenharmony_ci	REG(ANA_AGGR_CFG,			0x00c600),
12162306a36Sopenharmony_ci	REG(ANA_CPUQ_CFG,			0x00c604),
12262306a36Sopenharmony_ci	REG_RESERVED(ANA_CPUQ_CFG2),
12362306a36Sopenharmony_ci	REG(ANA_CPUQ_8021_CFG,			0x00c60c),
12462306a36Sopenharmony_ci	REG(ANA_DSCP_CFG,			0x00c64c),
12562306a36Sopenharmony_ci	REG(ANA_DSCP_REWR_CFG,			0x00c74c),
12662306a36Sopenharmony_ci	REG(ANA_VCAP_RNG_TYPE_CFG,		0x00c78c),
12762306a36Sopenharmony_ci	REG(ANA_VCAP_RNG_VAL_CFG,		0x00c7ac),
12862306a36Sopenharmony_ci	REG_RESERVED(ANA_VRAP_CFG),
12962306a36Sopenharmony_ci	REG_RESERVED(ANA_VRAP_HDR_DATA),
13062306a36Sopenharmony_ci	REG_RESERVED(ANA_VRAP_HDR_MASK),
13162306a36Sopenharmony_ci	REG(ANA_DISCARD_CFG,			0x00c7d8),
13262306a36Sopenharmony_ci	REG(ANA_FID_CFG,			0x00c7dc),
13362306a36Sopenharmony_ci	REG(ANA_POL_PIR_CFG,			0x00a000),
13462306a36Sopenharmony_ci	REG(ANA_POL_CIR_CFG,			0x00a004),
13562306a36Sopenharmony_ci	REG(ANA_POL_MODE_CFG,			0x00a008),
13662306a36Sopenharmony_ci	REG(ANA_POL_PIR_STATE,			0x00a00c),
13762306a36Sopenharmony_ci	REG(ANA_POL_CIR_STATE,			0x00a010),
13862306a36Sopenharmony_ci	REG_RESERVED(ANA_POL_STATE),
13962306a36Sopenharmony_ci	REG(ANA_POL_FLOWC,			0x00c280),
14062306a36Sopenharmony_ci	REG(ANA_POL_HYST,			0x00c2ec),
14162306a36Sopenharmony_ci	REG_RESERVED(ANA_POL_MISC_CFG),
14262306a36Sopenharmony_ci};
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_cistatic const u32 vsc9953_qs_regmap[] = {
14562306a36Sopenharmony_ci	REG(QS_XTR_GRP_CFG,			0x000000),
14662306a36Sopenharmony_ci	REG(QS_XTR_RD,				0x000008),
14762306a36Sopenharmony_ci	REG(QS_XTR_FRM_PRUNING,			0x000010),
14862306a36Sopenharmony_ci	REG(QS_XTR_FLUSH,			0x000018),
14962306a36Sopenharmony_ci	REG(QS_XTR_DATA_PRESENT,		0x00001c),
15062306a36Sopenharmony_ci	REG(QS_XTR_CFG,				0x000020),
15162306a36Sopenharmony_ci	REG(QS_INJ_GRP_CFG,			0x000024),
15262306a36Sopenharmony_ci	REG(QS_INJ_WR,				0x00002c),
15362306a36Sopenharmony_ci	REG(QS_INJ_CTRL,			0x000034),
15462306a36Sopenharmony_ci	REG(QS_INJ_STATUS,			0x00003c),
15562306a36Sopenharmony_ci	REG(QS_INJ_ERR,				0x000040),
15662306a36Sopenharmony_ci	REG_RESERVED(QS_INH_DBG),
15762306a36Sopenharmony_ci};
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cistatic const u32 vsc9953_vcap_regmap[] = {
16062306a36Sopenharmony_ci	/* VCAP_CORE_CFG */
16162306a36Sopenharmony_ci	REG(VCAP_CORE_UPDATE_CTRL,		0x000000),
16262306a36Sopenharmony_ci	REG(VCAP_CORE_MV_CFG,			0x000004),
16362306a36Sopenharmony_ci	/* VCAP_CORE_CACHE */
16462306a36Sopenharmony_ci	REG(VCAP_CACHE_ENTRY_DAT,		0x000008),
16562306a36Sopenharmony_ci	REG(VCAP_CACHE_MASK_DAT,		0x000108),
16662306a36Sopenharmony_ci	REG(VCAP_CACHE_ACTION_DAT,		0x000208),
16762306a36Sopenharmony_ci	REG(VCAP_CACHE_CNT_DAT,			0x000308),
16862306a36Sopenharmony_ci	REG(VCAP_CACHE_TG_DAT,			0x000388),
16962306a36Sopenharmony_ci	/* VCAP_CONST */
17062306a36Sopenharmony_ci	REG(VCAP_CONST_VCAP_VER,		0x000398),
17162306a36Sopenharmony_ci	REG(VCAP_CONST_ENTRY_WIDTH,		0x00039c),
17262306a36Sopenharmony_ci	REG(VCAP_CONST_ENTRY_CNT,		0x0003a0),
17362306a36Sopenharmony_ci	REG(VCAP_CONST_ENTRY_SWCNT,		0x0003a4),
17462306a36Sopenharmony_ci	REG(VCAP_CONST_ENTRY_TG_WIDTH,		0x0003a8),
17562306a36Sopenharmony_ci	REG(VCAP_CONST_ACTION_DEF_CNT,		0x0003ac),
17662306a36Sopenharmony_ci	REG(VCAP_CONST_ACTION_WIDTH,		0x0003b0),
17762306a36Sopenharmony_ci	REG(VCAP_CONST_CNT_WIDTH,		0x0003b4),
17862306a36Sopenharmony_ci	REG_RESERVED(VCAP_CONST_CORE_CNT),
17962306a36Sopenharmony_ci	REG_RESERVED(VCAP_CONST_IF_CNT),
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_cistatic const u32 vsc9953_qsys_regmap[] = {
18362306a36Sopenharmony_ci	REG(QSYS_PORT_MODE,			0x003600),
18462306a36Sopenharmony_ci	REG(QSYS_SWITCH_PORT_MODE,		0x003630),
18562306a36Sopenharmony_ci	REG(QSYS_STAT_CNT_CFG,			0x00365c),
18662306a36Sopenharmony_ci	REG(QSYS_EEE_CFG,			0x003660),
18762306a36Sopenharmony_ci	REG(QSYS_EEE_THRES,			0x003688),
18862306a36Sopenharmony_ci	REG(QSYS_IGR_NO_SHARING,		0x00368c),
18962306a36Sopenharmony_ci	REG(QSYS_EGR_NO_SHARING,		0x003690),
19062306a36Sopenharmony_ci	REG(QSYS_SW_STATUS,			0x003694),
19162306a36Sopenharmony_ci	REG(QSYS_EXT_CPU_CFG,			0x0036c0),
19262306a36Sopenharmony_ci	REG_RESERVED(QSYS_PAD_CFG),
19362306a36Sopenharmony_ci	REG(QSYS_CPU_GROUP_MAP,			0x0036c8),
19462306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAP),
19562306a36Sopenharmony_ci	REG_RESERVED(QSYS_ISDX_SGRP),
19662306a36Sopenharmony_ci	REG_RESERVED(QSYS_TIMED_FRAME_ENTRY),
19762306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_MISC),
19862306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_PORT_DLY),
19962306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_1),
20062306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_2),
20162306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_3),
20262306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_4),
20362306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_5),
20462306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_6),
20562306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_7),
20662306a36Sopenharmony_ci	REG_RESERVED(QSYS_TFRM_TIMER_CFG_8),
20762306a36Sopenharmony_ci	REG(QSYS_RED_PROFILE,			0x003724),
20862306a36Sopenharmony_ci	REG(QSYS_RES_QOS_MODE,			0x003764),
20962306a36Sopenharmony_ci	REG(QSYS_RES_CFG,			0x004000),
21062306a36Sopenharmony_ci	REG(QSYS_RES_STAT,			0x004004),
21162306a36Sopenharmony_ci	REG(QSYS_EGR_DROP_MODE,			0x003768),
21262306a36Sopenharmony_ci	REG(QSYS_EQ_CTRL,			0x00376c),
21362306a36Sopenharmony_ci	REG_RESERVED(QSYS_EVENTS_CORE),
21462306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_0),
21562306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_1),
21662306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_2),
21762306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_3),
21862306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_4),
21962306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_5),
22062306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_6),
22162306a36Sopenharmony_ci	REG_RESERVED(QSYS_QMAXSDU_CFG_7),
22262306a36Sopenharmony_ci	REG_RESERVED(QSYS_PREEMPTION_CFG),
22362306a36Sopenharmony_ci	REG(QSYS_CIR_CFG,			0x000000),
22462306a36Sopenharmony_ci	REG_RESERVED(QSYS_EIR_CFG),
22562306a36Sopenharmony_ci	REG(QSYS_SE_CFG,			0x000008),
22662306a36Sopenharmony_ci	REG(QSYS_SE_DWRR_CFG,			0x00000c),
22762306a36Sopenharmony_ci	REG_RESERVED(QSYS_SE_CONNECT),
22862306a36Sopenharmony_ci	REG_RESERVED(QSYS_SE_DLB_SENSE),
22962306a36Sopenharmony_ci	REG(QSYS_CIR_STATE,			0x000044),
23062306a36Sopenharmony_ci	REG_RESERVED(QSYS_EIR_STATE),
23162306a36Sopenharmony_ci	REG_RESERVED(QSYS_SE_STATE),
23262306a36Sopenharmony_ci	REG(QSYS_HSCH_MISC_CFG,			0x003774),
23362306a36Sopenharmony_ci	REG_RESERVED(QSYS_TAG_CONFIG),
23462306a36Sopenharmony_ci	REG_RESERVED(QSYS_TAS_PARAM_CFG_CTRL),
23562306a36Sopenharmony_ci	REG_RESERVED(QSYS_PORT_MAX_SDU),
23662306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_CFG_REG_1),
23762306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_CFG_REG_2),
23862306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_CFG_REG_3),
23962306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_CFG_REG_4),
24062306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_CFG_REG_5),
24162306a36Sopenharmony_ci	REG_RESERVED(QSYS_GCL_CFG_REG_1),
24262306a36Sopenharmony_ci	REG_RESERVED(QSYS_GCL_CFG_REG_2),
24362306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_1),
24462306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_2),
24562306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_3),
24662306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_4),
24762306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_5),
24862306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_6),
24962306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_7),
25062306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_8),
25162306a36Sopenharmony_ci	REG_RESERVED(QSYS_PARAM_STATUS_REG_9),
25262306a36Sopenharmony_ci	REG_RESERVED(QSYS_GCL_STATUS_REG_1),
25362306a36Sopenharmony_ci	REG_RESERVED(QSYS_GCL_STATUS_REG_2),
25462306a36Sopenharmony_ci};
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_cistatic const u32 vsc9953_rew_regmap[] = {
25762306a36Sopenharmony_ci	REG(REW_PORT_VLAN_CFG,			0x000000),
25862306a36Sopenharmony_ci	REG(REW_TAG_CFG,			0x000004),
25962306a36Sopenharmony_ci	REG(REW_PORT_CFG,			0x000008),
26062306a36Sopenharmony_ci	REG(REW_DSCP_CFG,			0x00000c),
26162306a36Sopenharmony_ci	REG(REW_PCP_DEI_QOS_MAP_CFG,		0x000010),
26262306a36Sopenharmony_ci	REG_RESERVED(REW_PTP_CFG),
26362306a36Sopenharmony_ci	REG_RESERVED(REW_PTP_DLY1_CFG),
26462306a36Sopenharmony_ci	REG_RESERVED(REW_RED_TAG_CFG),
26562306a36Sopenharmony_ci	REG(REW_DSCP_REMAP_DP1_CFG,		0x000610),
26662306a36Sopenharmony_ci	REG(REW_DSCP_REMAP_CFG,			0x000710),
26762306a36Sopenharmony_ci	REG_RESERVED(REW_STAT_CFG),
26862306a36Sopenharmony_ci	REG_RESERVED(REW_REW_STICKY),
26962306a36Sopenharmony_ci	REG_RESERVED(REW_PPT),
27062306a36Sopenharmony_ci};
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_cistatic const u32 vsc9953_sys_regmap[] = {
27362306a36Sopenharmony_ci	REG(SYS_COUNT_RX_OCTETS,		0x000000),
27462306a36Sopenharmony_ci	REG(SYS_COUNT_RX_UNICAST,		0x000004),
27562306a36Sopenharmony_ci	REG(SYS_COUNT_RX_MULTICAST,		0x000008),
27662306a36Sopenharmony_ci	REG(SYS_COUNT_RX_BROADCAST,		0x00000c),
27762306a36Sopenharmony_ci	REG(SYS_COUNT_RX_SHORTS,		0x000010),
27862306a36Sopenharmony_ci	REG(SYS_COUNT_RX_FRAGMENTS,		0x000014),
27962306a36Sopenharmony_ci	REG(SYS_COUNT_RX_JABBERS,		0x000018),
28062306a36Sopenharmony_ci	REG(SYS_COUNT_RX_CRC_ALIGN_ERRS,	0x00001c),
28162306a36Sopenharmony_ci	REG(SYS_COUNT_RX_SYM_ERRS,		0x000020),
28262306a36Sopenharmony_ci	REG(SYS_COUNT_RX_64,			0x000024),
28362306a36Sopenharmony_ci	REG(SYS_COUNT_RX_65_127,		0x000028),
28462306a36Sopenharmony_ci	REG(SYS_COUNT_RX_128_255,		0x00002c),
28562306a36Sopenharmony_ci	REG(SYS_COUNT_RX_256_511,		0x000030),
28662306a36Sopenharmony_ci	REG(SYS_COUNT_RX_512_1023,		0x000034),
28762306a36Sopenharmony_ci	REG(SYS_COUNT_RX_1024_1526,		0x000038),
28862306a36Sopenharmony_ci	REG(SYS_COUNT_RX_1527_MAX,		0x00003c),
28962306a36Sopenharmony_ci	REG(SYS_COUNT_RX_PAUSE,			0x000040),
29062306a36Sopenharmony_ci	REG(SYS_COUNT_RX_CONTROL,		0x000044),
29162306a36Sopenharmony_ci	REG(SYS_COUNT_RX_LONGS,			0x000048),
29262306a36Sopenharmony_ci	REG(SYS_COUNT_RX_CLASSIFIED_DROPS,	0x00004c),
29362306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_0,		0x000050),
29462306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_1,		0x000054),
29562306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_2,		0x000058),
29662306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_3,		0x00005c),
29762306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_4,		0x000060),
29862306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_5,		0x000064),
29962306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_6,		0x000068),
30062306a36Sopenharmony_ci	REG(SYS_COUNT_RX_RED_PRIO_7,		0x00006c),
30162306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_0,		0x000070),
30262306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_1,		0x000074),
30362306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_2,		0x000078),
30462306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_3,		0x00007c),
30562306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_4,		0x000080),
30662306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_5,		0x000084),
30762306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_6,		0x000088),
30862306a36Sopenharmony_ci	REG(SYS_COUNT_RX_YELLOW_PRIO_7,		0x00008c),
30962306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_0,		0x000090),
31062306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_1,		0x000094),
31162306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_2,		0x000098),
31262306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_3,		0x00009c),
31362306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_4,		0x0000a0),
31462306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_5,		0x0000a4),
31562306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_6,		0x0000a8),
31662306a36Sopenharmony_ci	REG(SYS_COUNT_RX_GREEN_PRIO_7,		0x0000ac),
31762306a36Sopenharmony_ci	REG(SYS_COUNT_TX_OCTETS,		0x000100),
31862306a36Sopenharmony_ci	REG(SYS_COUNT_TX_UNICAST,		0x000104),
31962306a36Sopenharmony_ci	REG(SYS_COUNT_TX_MULTICAST,		0x000108),
32062306a36Sopenharmony_ci	REG(SYS_COUNT_TX_BROADCAST,		0x00010c),
32162306a36Sopenharmony_ci	REG(SYS_COUNT_TX_COLLISION,		0x000110),
32262306a36Sopenharmony_ci	REG(SYS_COUNT_TX_DROPS,			0x000114),
32362306a36Sopenharmony_ci	REG(SYS_COUNT_TX_PAUSE,			0x000118),
32462306a36Sopenharmony_ci	REG(SYS_COUNT_TX_64,			0x00011c),
32562306a36Sopenharmony_ci	REG(SYS_COUNT_TX_65_127,		0x000120),
32662306a36Sopenharmony_ci	REG(SYS_COUNT_TX_128_255,		0x000124),
32762306a36Sopenharmony_ci	REG(SYS_COUNT_TX_256_511,		0x000128),
32862306a36Sopenharmony_ci	REG(SYS_COUNT_TX_512_1023,		0x00012c),
32962306a36Sopenharmony_ci	REG(SYS_COUNT_TX_1024_1526,		0x000130),
33062306a36Sopenharmony_ci	REG(SYS_COUNT_TX_1527_MAX,		0x000134),
33162306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_0,		0x000138),
33262306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_1,		0x00013c),
33362306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_2,		0x000140),
33462306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_3,		0x000144),
33562306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_4,		0x000148),
33662306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_5,		0x00014c),
33762306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_6,		0x000150),
33862306a36Sopenharmony_ci	REG(SYS_COUNT_TX_YELLOW_PRIO_7,		0x000154),
33962306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_0,		0x000158),
34062306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_1,		0x00015c),
34162306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_2,		0x000160),
34262306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_3,		0x000164),
34362306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_4,		0x000168),
34462306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_5,		0x00016c),
34562306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_6,		0x000170),
34662306a36Sopenharmony_ci	REG(SYS_COUNT_TX_GREEN_PRIO_7,		0x000174),
34762306a36Sopenharmony_ci	REG(SYS_COUNT_TX_AGED,			0x000178),
34862306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_LOCAL,		0x000200),
34962306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_TAIL,		0x000204),
35062306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_0,	0x000208),
35162306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_1,	0x00020c),
35262306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_2,	0x000210),
35362306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_3,	0x000214),
35462306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_4,	0x000218),
35562306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_5,	0x00021c),
35662306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_6,	0x000220),
35762306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_YELLOW_PRIO_7,	0x000224),
35862306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_0,	0x000228),
35962306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_1,	0x00022c),
36062306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_2,	0x000230),
36162306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_3,	0x000234),
36262306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_4,	0x000238),
36362306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_5,	0x00023c),
36462306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_6,	0x000240),
36562306a36Sopenharmony_ci	REG(SYS_COUNT_DROP_GREEN_PRIO_7,	0x000244),
36662306a36Sopenharmony_ci	REG(SYS_RESET_CFG,			0x000318),
36762306a36Sopenharmony_ci	REG_RESERVED(SYS_SR_ETYPE_CFG),
36862306a36Sopenharmony_ci	REG(SYS_VLAN_ETYPE_CFG,			0x000320),
36962306a36Sopenharmony_ci	REG(SYS_PORT_MODE,			0x000324),
37062306a36Sopenharmony_ci	REG(SYS_FRONT_PORT_MODE,		0x000354),
37162306a36Sopenharmony_ci	REG(SYS_FRM_AGING,			0x00037c),
37262306a36Sopenharmony_ci	REG(SYS_STAT_CFG,			0x000380),
37362306a36Sopenharmony_ci	REG_RESERVED(SYS_SW_STATUS),
37462306a36Sopenharmony_ci	REG_RESERVED(SYS_MISC_CFG),
37562306a36Sopenharmony_ci	REG_RESERVED(SYS_REW_MAC_HIGH_CFG),
37662306a36Sopenharmony_ci	REG_RESERVED(SYS_REW_MAC_LOW_CFG),
37762306a36Sopenharmony_ci	REG_RESERVED(SYS_TIMESTAMP_OFFSET),
37862306a36Sopenharmony_ci	REG(SYS_PAUSE_CFG,			0x00044c),
37962306a36Sopenharmony_ci	REG(SYS_PAUSE_TOT_CFG,			0x000478),
38062306a36Sopenharmony_ci	REG(SYS_ATOP,				0x00047c),
38162306a36Sopenharmony_ci	REG(SYS_ATOP_TOT_CFG,			0x0004a8),
38262306a36Sopenharmony_ci	REG(SYS_MAC_FC_CFG,			0x0004ac),
38362306a36Sopenharmony_ci	REG(SYS_MMGT,				0x0004d4),
38462306a36Sopenharmony_ci	REG_RESERVED(SYS_MMGT_FAST),
38562306a36Sopenharmony_ci	REG_RESERVED(SYS_EVENTS_DIF),
38662306a36Sopenharmony_ci	REG_RESERVED(SYS_EVENTS_CORE),
38762306a36Sopenharmony_ci	REG_RESERVED(SYS_PTP_STATUS),
38862306a36Sopenharmony_ci	REG_RESERVED(SYS_PTP_TXSTAMP),
38962306a36Sopenharmony_ci	REG_RESERVED(SYS_PTP_NXT),
39062306a36Sopenharmony_ci	REG_RESERVED(SYS_PTP_CFG),
39162306a36Sopenharmony_ci	REG_RESERVED(SYS_RAM_INIT),
39262306a36Sopenharmony_ci	REG_RESERVED(SYS_CM_ADDR),
39362306a36Sopenharmony_ci	REG_RESERVED(SYS_CM_DATA_WR),
39462306a36Sopenharmony_ci	REG_RESERVED(SYS_CM_DATA_RD),
39562306a36Sopenharmony_ci	REG_RESERVED(SYS_CM_OP),
39662306a36Sopenharmony_ci	REG_RESERVED(SYS_CM_DATA),
39762306a36Sopenharmony_ci};
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_cistatic const u32 vsc9953_gcb_regmap[] = {
40062306a36Sopenharmony_ci	REG(GCB_SOFT_RST,			0x000008),
40162306a36Sopenharmony_ci	REG(GCB_MIIM_MII_STATUS,		0x0000ac),
40262306a36Sopenharmony_ci	REG(GCB_MIIM_MII_CMD,			0x0000b4),
40362306a36Sopenharmony_ci	REG(GCB_MIIM_MII_DATA,			0x0000b8),
40462306a36Sopenharmony_ci};
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_cistatic const u32 vsc9953_dev_gmii_regmap[] = {
40762306a36Sopenharmony_ci	REG(DEV_CLOCK_CFG,			0x0),
40862306a36Sopenharmony_ci	REG(DEV_PORT_MISC,			0x4),
40962306a36Sopenharmony_ci	REG_RESERVED(DEV_EVENTS),
41062306a36Sopenharmony_ci	REG(DEV_EEE_CFG,			0xc),
41162306a36Sopenharmony_ci	REG_RESERVED(DEV_RX_PATH_DELAY),
41262306a36Sopenharmony_ci	REG_RESERVED(DEV_TX_PATH_DELAY),
41362306a36Sopenharmony_ci	REG_RESERVED(DEV_PTP_PREDICT_CFG),
41462306a36Sopenharmony_ci	REG(DEV_MAC_ENA_CFG,			0x10),
41562306a36Sopenharmony_ci	REG(DEV_MAC_MODE_CFG,			0x14),
41662306a36Sopenharmony_ci	REG(DEV_MAC_MAXLEN_CFG,			0x18),
41762306a36Sopenharmony_ci	REG(DEV_MAC_TAGS_CFG,			0x1c),
41862306a36Sopenharmony_ci	REG(DEV_MAC_ADV_CHK_CFG,		0x20),
41962306a36Sopenharmony_ci	REG(DEV_MAC_IFG_CFG,			0x24),
42062306a36Sopenharmony_ci	REG(DEV_MAC_HDX_CFG,			0x28),
42162306a36Sopenharmony_ci	REG_RESERVED(DEV_MAC_DBG_CFG),
42262306a36Sopenharmony_ci	REG(DEV_MAC_FC_MAC_LOW_CFG,		0x30),
42362306a36Sopenharmony_ci	REG(DEV_MAC_FC_MAC_HIGH_CFG,		0x34),
42462306a36Sopenharmony_ci	REG(DEV_MAC_STICKY,			0x38),
42562306a36Sopenharmony_ci	REG_RESERVED(PCS1G_CFG),
42662306a36Sopenharmony_ci	REG_RESERVED(PCS1G_MODE_CFG),
42762306a36Sopenharmony_ci	REG_RESERVED(PCS1G_SD_CFG),
42862306a36Sopenharmony_ci	REG_RESERVED(PCS1G_ANEG_CFG),
42962306a36Sopenharmony_ci	REG_RESERVED(PCS1G_ANEG_NP_CFG),
43062306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LB_CFG),
43162306a36Sopenharmony_ci	REG_RESERVED(PCS1G_DBG_CFG),
43262306a36Sopenharmony_ci	REG_RESERVED(PCS1G_CDET_CFG),
43362306a36Sopenharmony_ci	REG_RESERVED(PCS1G_ANEG_STATUS),
43462306a36Sopenharmony_ci	REG_RESERVED(PCS1G_ANEG_NP_STATUS),
43562306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LINK_STATUS),
43662306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LINK_DOWN_CNT),
43762306a36Sopenharmony_ci	REG_RESERVED(PCS1G_STICKY),
43862306a36Sopenharmony_ci	REG_RESERVED(PCS1G_DEBUG_STATUS),
43962306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LPI_CFG),
44062306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LPI_WAKE_ERROR_CNT),
44162306a36Sopenharmony_ci	REG_RESERVED(PCS1G_LPI_STATUS),
44262306a36Sopenharmony_ci	REG_RESERVED(PCS1G_TSTPAT_MODE_CFG),
44362306a36Sopenharmony_ci	REG_RESERVED(PCS1G_TSTPAT_STATUS),
44462306a36Sopenharmony_ci	REG_RESERVED(DEV_PCS_FX100_CFG),
44562306a36Sopenharmony_ci	REG_RESERVED(DEV_PCS_FX100_STATUS),
44662306a36Sopenharmony_ci};
44762306a36Sopenharmony_ci
44862306a36Sopenharmony_cistatic const u32 *vsc9953_regmap[TARGET_MAX] = {
44962306a36Sopenharmony_ci	[ANA]		= vsc9953_ana_regmap,
45062306a36Sopenharmony_ci	[QS]		= vsc9953_qs_regmap,
45162306a36Sopenharmony_ci	[QSYS]		= vsc9953_qsys_regmap,
45262306a36Sopenharmony_ci	[REW]		= vsc9953_rew_regmap,
45362306a36Sopenharmony_ci	[SYS]		= vsc9953_sys_regmap,
45462306a36Sopenharmony_ci	[S0]		= vsc9953_vcap_regmap,
45562306a36Sopenharmony_ci	[S1]		= vsc9953_vcap_regmap,
45662306a36Sopenharmony_ci	[S2]		= vsc9953_vcap_regmap,
45762306a36Sopenharmony_ci	[GCB]		= vsc9953_gcb_regmap,
45862306a36Sopenharmony_ci	[DEV_GMII]	= vsc9953_dev_gmii_regmap,
45962306a36Sopenharmony_ci};
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci/* Addresses are relative to the device's base address */
46262306a36Sopenharmony_cistatic const struct resource vsc9953_resources[] = {
46362306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0010000, 0x0010000, "sys"),
46462306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0030000, 0x0010000, "rew"),
46562306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0040000, 0x0000400, "s0"),
46662306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0050000, 0x0000400, "s1"),
46762306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0060000, 0x0000400, "s2"),
46862306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0070000, 0x0000200, "devcpu_gcb"),
46962306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0080000, 0x0000100, "qs"),
47062306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0090000, 0x00000cc, "ptp"),
47162306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0100000, 0x0010000, "port0"),
47262306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0110000, 0x0010000, "port1"),
47362306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0120000, 0x0010000, "port2"),
47462306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0130000, 0x0010000, "port3"),
47562306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0140000, 0x0010000, "port4"),
47662306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0150000, 0x0010000, "port5"),
47762306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0160000, 0x0010000, "port6"),
47862306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0170000, 0x0010000, "port7"),
47962306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0180000, 0x0010000, "port8"),
48062306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0190000, 0x0010000, "port9"),
48162306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0200000, 0x0020000, "qsys"),
48262306a36Sopenharmony_ci	DEFINE_RES_MEM_NAMED(0x0280000, 0x0010000, "ana"),
48362306a36Sopenharmony_ci};
48462306a36Sopenharmony_ci
48562306a36Sopenharmony_cistatic const char * const vsc9953_resource_names[TARGET_MAX] = {
48662306a36Sopenharmony_ci	[SYS] = "sys",
48762306a36Sopenharmony_ci	[REW] = "rew",
48862306a36Sopenharmony_ci	[S0] = "s0",
48962306a36Sopenharmony_ci	[S1] = "s1",
49062306a36Sopenharmony_ci	[S2] = "s2",
49162306a36Sopenharmony_ci	[GCB] = "devcpu_gcb",
49262306a36Sopenharmony_ci	[QS] = "qs",
49362306a36Sopenharmony_ci	[PTP] = "ptp",
49462306a36Sopenharmony_ci	[QSYS] = "qsys",
49562306a36Sopenharmony_ci	[ANA] = "ana",
49662306a36Sopenharmony_ci};
49762306a36Sopenharmony_ci
49862306a36Sopenharmony_cistatic const struct reg_field vsc9953_regfields[REGFIELD_MAX] = {
49962306a36Sopenharmony_ci	[ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 10, 10),
50062306a36Sopenharmony_ci	[ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 9),
50162306a36Sopenharmony_ci	[ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
50262306a36Sopenharmony_ci	[ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
50362306a36Sopenharmony_ci	[ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
50462306a36Sopenharmony_ci	[ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
50562306a36Sopenharmony_ci	[ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
50662306a36Sopenharmony_ci	[ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
50762306a36Sopenharmony_ci	[ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
50862306a36Sopenharmony_ci	[ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
50962306a36Sopenharmony_ci	[ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
51062306a36Sopenharmony_ci	[ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
51162306a36Sopenharmony_ci	[ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
51262306a36Sopenharmony_ci	[ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
51362306a36Sopenharmony_ci	[ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
51462306a36Sopenharmony_ci	[ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
51562306a36Sopenharmony_ci	[ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
51662306a36Sopenharmony_ci	[ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
51762306a36Sopenharmony_ci	[ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
51862306a36Sopenharmony_ci	[ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
51962306a36Sopenharmony_ci	[ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
52062306a36Sopenharmony_ci	[ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
52162306a36Sopenharmony_ci	[ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
52262306a36Sopenharmony_ci	[ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
52362306a36Sopenharmony_ci	[ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
52462306a36Sopenharmony_ci	[ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 16, 16),
52562306a36Sopenharmony_ci	[ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 11, 12),
52662306a36Sopenharmony_ci	[ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 10),
52762306a36Sopenharmony_ci	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 7, 7),
52862306a36Sopenharmony_ci	[SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 6, 6),
52962306a36Sopenharmony_ci	[SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 5, 5),
53062306a36Sopenharmony_ci	[GCB_SOFT_RST_SWC_RST] = REG_FIELD(GCB_SOFT_RST, 0, 0),
53162306a36Sopenharmony_ci	[GCB_MIIM_MII_STATUS_PENDING] = REG_FIELD(GCB_MIIM_MII_STATUS, 2, 2),
53262306a36Sopenharmony_ci	[GCB_MIIM_MII_STATUS_BUSY] = REG_FIELD(GCB_MIIM_MII_STATUS, 3, 3),
53362306a36Sopenharmony_ci	/* Replicated per number of ports (11), register size 4 per port */
53462306a36Sopenharmony_ci	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 13, 13, 11, 4),
53562306a36Sopenharmony_ci	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 11, 4),
53662306a36Sopenharmony_ci	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 11, 4),
53762306a36Sopenharmony_ci	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 11, 4),
53862306a36Sopenharmony_ci	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 11, 4),
53962306a36Sopenharmony_ci	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 4, 5, 11, 4),
54062306a36Sopenharmony_ci	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 2, 3, 11, 4),
54162306a36Sopenharmony_ci	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 11, 4),
54262306a36Sopenharmony_ci	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 11, 20, 11, 4),
54362306a36Sopenharmony_ci	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 10, 11, 4),
54462306a36Sopenharmony_ci	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 11, 4),
54562306a36Sopenharmony_ci};
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_cistatic const struct vcap_field vsc9953_vcap_es0_keys[] = {
54862306a36Sopenharmony_ci	[VCAP_ES0_EGR_PORT]			= {  0,  4},
54962306a36Sopenharmony_ci	[VCAP_ES0_IGR_PORT]			= {  4,  4},
55062306a36Sopenharmony_ci	[VCAP_ES0_RSV]				= {  8,  2},
55162306a36Sopenharmony_ci	[VCAP_ES0_L2_MC]			= { 10,  1},
55262306a36Sopenharmony_ci	[VCAP_ES0_L2_BC]			= { 11,  1},
55362306a36Sopenharmony_ci	[VCAP_ES0_VID]				= { 12, 12},
55462306a36Sopenharmony_ci	[VCAP_ES0_DP]				= { 24,  1},
55562306a36Sopenharmony_ci	[VCAP_ES0_PCP]				= { 25,  3},
55662306a36Sopenharmony_ci};
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_cistatic const struct vcap_field vsc9953_vcap_es0_actions[] = {
55962306a36Sopenharmony_ci	[VCAP_ES0_ACT_PUSH_OUTER_TAG]		= {  0,  2},
56062306a36Sopenharmony_ci	[VCAP_ES0_ACT_PUSH_INNER_TAG]		= {  2,  1},
56162306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_A_TPID_SEL]		= {  3,  2},
56262306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_A_VID_SEL]		= {  5,  1},
56362306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_A_PCP_SEL]		= {  6,  2},
56462306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_A_DEI_SEL]		= {  8,  2},
56562306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_B_TPID_SEL]		= { 10,  2},
56662306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_B_VID_SEL]		= { 12,  1},
56762306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_B_PCP_SEL]		= { 13,  2},
56862306a36Sopenharmony_ci	[VCAP_ES0_ACT_TAG_B_DEI_SEL]		= { 15,  2},
56962306a36Sopenharmony_ci	[VCAP_ES0_ACT_VID_A_VAL]		= { 17, 12},
57062306a36Sopenharmony_ci	[VCAP_ES0_ACT_PCP_A_VAL]		= { 29,  3},
57162306a36Sopenharmony_ci	[VCAP_ES0_ACT_DEI_A_VAL]		= { 32,  1},
57262306a36Sopenharmony_ci	[VCAP_ES0_ACT_VID_B_VAL]		= { 33, 12},
57362306a36Sopenharmony_ci	[VCAP_ES0_ACT_PCP_B_VAL]		= { 45,  3},
57462306a36Sopenharmony_ci	[VCAP_ES0_ACT_DEI_B_VAL]		= { 48,  1},
57562306a36Sopenharmony_ci	[VCAP_ES0_ACT_RSV]			= { 49, 24},
57662306a36Sopenharmony_ci	[VCAP_ES0_ACT_HIT_STICKY]		= { 73,  1},
57762306a36Sopenharmony_ci};
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_cistatic const struct vcap_field vsc9953_vcap_is1_keys[] = {
58062306a36Sopenharmony_ci	[VCAP_IS1_HK_TYPE]			= {  0,   1},
58162306a36Sopenharmony_ci	[VCAP_IS1_HK_LOOKUP]			= {  1,   2},
58262306a36Sopenharmony_ci	[VCAP_IS1_HK_IGR_PORT_MASK]		= {  3,  11},
58362306a36Sopenharmony_ci	[VCAP_IS1_HK_RSV]			= { 14,  10},
58462306a36Sopenharmony_ci	/* VCAP_IS1_HK_OAM_Y1731 not supported */
58562306a36Sopenharmony_ci	[VCAP_IS1_HK_L2_MC]			= { 24,   1},
58662306a36Sopenharmony_ci	[VCAP_IS1_HK_L2_BC]			= { 25,   1},
58762306a36Sopenharmony_ci	[VCAP_IS1_HK_IP_MC]			= { 26,   1},
58862306a36Sopenharmony_ci	[VCAP_IS1_HK_VLAN_TAGGED]		= { 27,   1},
58962306a36Sopenharmony_ci	[VCAP_IS1_HK_VLAN_DBL_TAGGED]		= { 28,   1},
59062306a36Sopenharmony_ci	[VCAP_IS1_HK_TPID]			= { 29,   1},
59162306a36Sopenharmony_ci	[VCAP_IS1_HK_VID]			= { 30,  12},
59262306a36Sopenharmony_ci	[VCAP_IS1_HK_DEI]			= { 42,   1},
59362306a36Sopenharmony_ci	[VCAP_IS1_HK_PCP]			= { 43,   3},
59462306a36Sopenharmony_ci	/* Specific Fields for IS1 Half Key S1_NORMAL */
59562306a36Sopenharmony_ci	[VCAP_IS1_HK_L2_SMAC]			= { 46,  48},
59662306a36Sopenharmony_ci	[VCAP_IS1_HK_ETYPE_LEN]			= { 94,   1},
59762306a36Sopenharmony_ci	[VCAP_IS1_HK_ETYPE]			= { 95,  16},
59862306a36Sopenharmony_ci	[VCAP_IS1_HK_IP_SNAP]			= {111,   1},
59962306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4]			= {112,   1},
60062306a36Sopenharmony_ci	/* Layer-3 Information */
60162306a36Sopenharmony_ci	[VCAP_IS1_HK_L3_FRAGMENT]		= {113,   1},
60262306a36Sopenharmony_ci	[VCAP_IS1_HK_L3_FRAG_OFS_GT0]		= {114,   1},
60362306a36Sopenharmony_ci	[VCAP_IS1_HK_L3_OPTIONS]		= {115,   1},
60462306a36Sopenharmony_ci	[VCAP_IS1_HK_L3_DSCP]			= {116,   6},
60562306a36Sopenharmony_ci	[VCAP_IS1_HK_L3_IP4_SIP]		= {122,  32},
60662306a36Sopenharmony_ci	/* Layer-4 Information */
60762306a36Sopenharmony_ci	[VCAP_IS1_HK_TCP_UDP]			= {154,   1},
60862306a36Sopenharmony_ci	[VCAP_IS1_HK_TCP]			= {155,   1},
60962306a36Sopenharmony_ci	[VCAP_IS1_HK_L4_SPORT]			= {156,  16},
61062306a36Sopenharmony_ci	[VCAP_IS1_HK_L4_RNG]			= {172,   8},
61162306a36Sopenharmony_ci	/* Specific Fields for IS1 Half Key S1_5TUPLE_IP4 */
61262306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_INNER_TPID]            = { 46,   1},
61362306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_INNER_VID]		= { 47,  12},
61462306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_INNER_DEI]		= { 59,   1},
61562306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_INNER_PCP]		= { 60,   3},
61662306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_IP4]			= { 63,   1},
61762306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_FRAGMENT]		= { 64,   1},
61862306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_FRAG_OFS_GT0]	= { 65,   1},
61962306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_OPTIONS]		= { 66,   1},
62062306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_DSCP]		= { 67,   6},
62162306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_IP4_DIP]		= { 73,  32},
62262306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_IP4_SIP]		= {105,  32},
62362306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L3_PROTO]		= {137,   8},
62462306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_TCP_UDP]		= {145,   1},
62562306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_TCP]			= {146,   1},
62662306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_L4_RNG]		= {147,   8},
62762306a36Sopenharmony_ci	[VCAP_IS1_HK_IP4_IP_PAYLOAD_S1_5TUPLE]	= {155,  32},
62862306a36Sopenharmony_ci};
62962306a36Sopenharmony_ci
63062306a36Sopenharmony_cistatic const struct vcap_field vsc9953_vcap_is1_actions[] = {
63162306a36Sopenharmony_ci	[VCAP_IS1_ACT_DSCP_ENA]			= {  0,  1},
63262306a36Sopenharmony_ci	[VCAP_IS1_ACT_DSCP_VAL]			= {  1,  6},
63362306a36Sopenharmony_ci	[VCAP_IS1_ACT_QOS_ENA]			= {  7,  1},
63462306a36Sopenharmony_ci	[VCAP_IS1_ACT_QOS_VAL]			= {  8,  3},
63562306a36Sopenharmony_ci	[VCAP_IS1_ACT_DP_ENA]			= { 11,  1},
63662306a36Sopenharmony_ci	[VCAP_IS1_ACT_DP_VAL]			= { 12,  1},
63762306a36Sopenharmony_ci	[VCAP_IS1_ACT_PAG_OVERRIDE_MASK]	= { 13,  8},
63862306a36Sopenharmony_ci	[VCAP_IS1_ACT_PAG_VAL]			= { 21,  8},
63962306a36Sopenharmony_ci	[VCAP_IS1_ACT_RSV]			= { 29, 11},
64062306a36Sopenharmony_ci	[VCAP_IS1_ACT_VID_REPLACE_ENA]		= { 40,  1},
64162306a36Sopenharmony_ci	[VCAP_IS1_ACT_VID_ADD_VAL]		= { 41, 12},
64262306a36Sopenharmony_ci	[VCAP_IS1_ACT_FID_SEL]			= { 53,  2},
64362306a36Sopenharmony_ci	[VCAP_IS1_ACT_FID_VAL]			= { 55, 13},
64462306a36Sopenharmony_ci	[VCAP_IS1_ACT_PCP_DEI_ENA]		= { 68,  1},
64562306a36Sopenharmony_ci	[VCAP_IS1_ACT_PCP_VAL]			= { 69,  3},
64662306a36Sopenharmony_ci	[VCAP_IS1_ACT_DEI_VAL]			= { 72,  1},
64762306a36Sopenharmony_ci	[VCAP_IS1_ACT_VLAN_POP_CNT_ENA]		= { 73,  1},
64862306a36Sopenharmony_ci	[VCAP_IS1_ACT_VLAN_POP_CNT]		= { 74,  2},
64962306a36Sopenharmony_ci	[VCAP_IS1_ACT_CUSTOM_ACE_TYPE_ENA]	= { 76,  4},
65062306a36Sopenharmony_ci	[VCAP_IS1_ACT_HIT_STICKY]		= { 80,  1},
65162306a36Sopenharmony_ci};
65262306a36Sopenharmony_ci
65362306a36Sopenharmony_cistatic struct vcap_field vsc9953_vcap_is2_keys[] = {
65462306a36Sopenharmony_ci	/* Common: 41 bits */
65562306a36Sopenharmony_ci	[VCAP_IS2_TYPE]				= {  0,   4},
65662306a36Sopenharmony_ci	[VCAP_IS2_HK_FIRST]			= {  4,   1},
65762306a36Sopenharmony_ci	[VCAP_IS2_HK_PAG]			= {  5,   8},
65862306a36Sopenharmony_ci	[VCAP_IS2_HK_IGR_PORT_MASK]		= { 13,  11},
65962306a36Sopenharmony_ci	[VCAP_IS2_HK_RSV2]			= { 24,   1},
66062306a36Sopenharmony_ci	[VCAP_IS2_HK_HOST_MATCH]		= { 25,   1},
66162306a36Sopenharmony_ci	[VCAP_IS2_HK_L2_MC]			= { 26,   1},
66262306a36Sopenharmony_ci	[VCAP_IS2_HK_L2_BC]			= { 27,   1},
66362306a36Sopenharmony_ci	[VCAP_IS2_HK_VLAN_TAGGED]		= { 28,   1},
66462306a36Sopenharmony_ci	[VCAP_IS2_HK_VID]			= { 29,  12},
66562306a36Sopenharmony_ci	[VCAP_IS2_HK_DEI]			= { 41,   1},
66662306a36Sopenharmony_ci	[VCAP_IS2_HK_PCP]			= { 42,   3},
66762306a36Sopenharmony_ci	/* MAC_ETYPE / MAC_LLC / MAC_SNAP / OAM common */
66862306a36Sopenharmony_ci	[VCAP_IS2_HK_L2_DMAC]			= { 45,  48},
66962306a36Sopenharmony_ci	[VCAP_IS2_HK_L2_SMAC]			= { 93,  48},
67062306a36Sopenharmony_ci	/* MAC_ETYPE (TYPE=000) */
67162306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ETYPE_ETYPE]		= {141,  16},
67262306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD0]	= {157,  16},
67362306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD1]	= {173,   8},
67462306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD2]	= {181,   3},
67562306a36Sopenharmony_ci	/* MAC_LLC (TYPE=001) */
67662306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_LLC_L2_LLC]		= {141,  40},
67762306a36Sopenharmony_ci	/* MAC_SNAP (TYPE=010) */
67862306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_SNAP_L2_SNAP]		= {141,  40},
67962306a36Sopenharmony_ci	/* MAC_ARP (TYPE=011) */
68062306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_SMAC]		= { 45,  48},
68162306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_ADDR_SPACE_OK]	= { 93,   1},
68262306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_PROTO_SPACE_OK]	= { 94,   1},
68362306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_LEN_OK]		= { 95,   1},
68462306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_TARGET_MATCH]	= { 96,   1},
68562306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_SENDER_MATCH]	= { 97,   1},
68662306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_OPCODE_UNKNOWN]	= { 98,   1},
68762306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_OPCODE]		= { 99,   2},
68862306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_L3_IP4_DIP]	= {101,  32},
68962306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_L3_IP4_SIP]	= {133,  32},
69062306a36Sopenharmony_ci	[VCAP_IS2_HK_MAC_ARP_DIP_EQ_SIP]	= {165,   1},
69162306a36Sopenharmony_ci	/* IP4_TCP_UDP / IP4_OTHER common */
69262306a36Sopenharmony_ci	[VCAP_IS2_HK_IP4]			= { 45,   1},
69362306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_FRAGMENT]		= { 46,   1},
69462306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_FRAG_OFS_GT0]		= { 47,   1},
69562306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_OPTIONS]		= { 48,   1},
69662306a36Sopenharmony_ci	[VCAP_IS2_HK_IP4_L3_TTL_GT0]		= { 49,   1},
69762306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_TOS]			= { 50,   8},
69862306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_IP4_DIP]		= { 58,  32},
69962306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_IP4_SIP]		= { 90,  32},
70062306a36Sopenharmony_ci	[VCAP_IS2_HK_DIP_EQ_SIP]		= {122,   1},
70162306a36Sopenharmony_ci	/* IP4_TCP_UDP (TYPE=100) */
70262306a36Sopenharmony_ci	[VCAP_IS2_HK_TCP]			= {123,   1},
70362306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_DPORT]			= {124,  16},
70462306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_SPORT]			= {140,  16},
70562306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_RNG]			= {156,   8},
70662306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_SPORT_EQ_DPORT]		= {164,   1},
70762306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_SEQUENCE_EQ0]		= {165,   1},
70862306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_FIN]			= {166,   1},
70962306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_SYN]			= {167,   1},
71062306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_RST]			= {168,   1},
71162306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_PSH]			= {169,   1},
71262306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_ACK]			= {170,   1},
71362306a36Sopenharmony_ci	[VCAP_IS2_HK_L4_URG]			= {171,   1},
71462306a36Sopenharmony_ci	/* IP4_OTHER (TYPE=101) */
71562306a36Sopenharmony_ci	[VCAP_IS2_HK_IP4_L3_PROTO]		= {123,   8},
71662306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_PAYLOAD]		= {131,  56},
71762306a36Sopenharmony_ci	/* IP6_STD (TYPE=110) */
71862306a36Sopenharmony_ci	[VCAP_IS2_HK_IP6_L3_TTL_GT0]		= { 45,   1},
71962306a36Sopenharmony_ci	[VCAP_IS2_HK_L3_IP6_SIP]		= { 46, 128},
72062306a36Sopenharmony_ci	[VCAP_IS2_HK_IP6_L3_PROTO]		= {174,   8},
72162306a36Sopenharmony_ci};
72262306a36Sopenharmony_ci
72362306a36Sopenharmony_cistatic struct vcap_field vsc9953_vcap_is2_actions[] = {
72462306a36Sopenharmony_ci	[VCAP_IS2_ACT_HIT_ME_ONCE]		= {  0,  1},
72562306a36Sopenharmony_ci	[VCAP_IS2_ACT_CPU_COPY_ENA]		= {  1,  1},
72662306a36Sopenharmony_ci	[VCAP_IS2_ACT_CPU_QU_NUM]		= {  2,  3},
72762306a36Sopenharmony_ci	[VCAP_IS2_ACT_MASK_MODE]		= {  5,  2},
72862306a36Sopenharmony_ci	[VCAP_IS2_ACT_MIRROR_ENA]		= {  7,  1},
72962306a36Sopenharmony_ci	[VCAP_IS2_ACT_LRN_DIS]			= {  8,  1},
73062306a36Sopenharmony_ci	[VCAP_IS2_ACT_POLICE_ENA]		= {  9,  1},
73162306a36Sopenharmony_ci	[VCAP_IS2_ACT_POLICE_IDX]		= { 10,  8},
73262306a36Sopenharmony_ci	[VCAP_IS2_ACT_POLICE_VCAP_ONLY]		= { 21,  1},
73362306a36Sopenharmony_ci	[VCAP_IS2_ACT_PORT_MASK]		= { 22, 10},
73462306a36Sopenharmony_ci	[VCAP_IS2_ACT_ACL_ID]			= { 44,  6},
73562306a36Sopenharmony_ci	[VCAP_IS2_ACT_HIT_CNT]			= { 50, 32},
73662306a36Sopenharmony_ci};
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_cistatic struct vcap_props vsc9953_vcap_props[] = {
73962306a36Sopenharmony_ci	[VCAP_ES0] = {
74062306a36Sopenharmony_ci		.action_type_width = 0,
74162306a36Sopenharmony_ci		.action_table = {
74262306a36Sopenharmony_ci			[ES0_ACTION_TYPE_NORMAL] = {
74362306a36Sopenharmony_ci				.width = 73, /* HIT_STICKY not included */
74462306a36Sopenharmony_ci				.count = 1,
74562306a36Sopenharmony_ci			},
74662306a36Sopenharmony_ci		},
74762306a36Sopenharmony_ci		.target = S0,
74862306a36Sopenharmony_ci		.keys = vsc9953_vcap_es0_keys,
74962306a36Sopenharmony_ci		.actions = vsc9953_vcap_es0_actions,
75062306a36Sopenharmony_ci	},
75162306a36Sopenharmony_ci	[VCAP_IS1] = {
75262306a36Sopenharmony_ci		.action_type_width = 0,
75362306a36Sopenharmony_ci		.action_table = {
75462306a36Sopenharmony_ci			[IS1_ACTION_TYPE_NORMAL] = {
75562306a36Sopenharmony_ci				.width = 80, /* HIT_STICKY not included */
75662306a36Sopenharmony_ci				.count = 4,
75762306a36Sopenharmony_ci			},
75862306a36Sopenharmony_ci		},
75962306a36Sopenharmony_ci		.target = S1,
76062306a36Sopenharmony_ci		.keys = vsc9953_vcap_is1_keys,
76162306a36Sopenharmony_ci		.actions = vsc9953_vcap_is1_actions,
76262306a36Sopenharmony_ci	},
76362306a36Sopenharmony_ci	[VCAP_IS2] = {
76462306a36Sopenharmony_ci		.action_type_width = 1,
76562306a36Sopenharmony_ci		.action_table = {
76662306a36Sopenharmony_ci			[IS2_ACTION_TYPE_NORMAL] = {
76762306a36Sopenharmony_ci				.width = 50, /* HIT_CNT not included */
76862306a36Sopenharmony_ci				.count = 2
76962306a36Sopenharmony_ci			},
77062306a36Sopenharmony_ci			[IS2_ACTION_TYPE_SMAC_SIP] = {
77162306a36Sopenharmony_ci				.width = 6,
77262306a36Sopenharmony_ci				.count = 4
77362306a36Sopenharmony_ci			},
77462306a36Sopenharmony_ci		},
77562306a36Sopenharmony_ci		.target = S2,
77662306a36Sopenharmony_ci		.keys = vsc9953_vcap_is2_keys,
77762306a36Sopenharmony_ci		.actions = vsc9953_vcap_is2_actions,
77862306a36Sopenharmony_ci	},
77962306a36Sopenharmony_ci};
78062306a36Sopenharmony_ci
78162306a36Sopenharmony_ci#define VSC9953_INIT_TIMEOUT			50000
78262306a36Sopenharmony_ci#define VSC9953_GCB_RST_SLEEP			100
78362306a36Sopenharmony_ci#define VSC9953_SYS_RAMINIT_SLEEP		80
78462306a36Sopenharmony_ci
78562306a36Sopenharmony_cistatic int vsc9953_gcb_soft_rst_status(struct ocelot *ocelot)
78662306a36Sopenharmony_ci{
78762306a36Sopenharmony_ci	int val;
78862306a36Sopenharmony_ci
78962306a36Sopenharmony_ci	ocelot_field_read(ocelot, GCB_SOFT_RST_SWC_RST, &val);
79062306a36Sopenharmony_ci
79162306a36Sopenharmony_ci	return val;
79262306a36Sopenharmony_ci}
79362306a36Sopenharmony_ci
79462306a36Sopenharmony_cistatic int vsc9953_sys_ram_init_status(struct ocelot *ocelot)
79562306a36Sopenharmony_ci{
79662306a36Sopenharmony_ci	int val;
79762306a36Sopenharmony_ci
79862306a36Sopenharmony_ci	ocelot_field_read(ocelot, SYS_RESET_CFG_MEM_INIT, &val);
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ci	return val;
80162306a36Sopenharmony_ci}
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci
80462306a36Sopenharmony_ci/* CORE_ENA is in SYS:SYSTEM:RESET_CFG
80562306a36Sopenharmony_ci * MEM_INIT is in SYS:SYSTEM:RESET_CFG
80662306a36Sopenharmony_ci * MEM_ENA is in SYS:SYSTEM:RESET_CFG
80762306a36Sopenharmony_ci */
80862306a36Sopenharmony_cistatic int vsc9953_reset(struct ocelot *ocelot)
80962306a36Sopenharmony_ci{
81062306a36Sopenharmony_ci	int val, err;
81162306a36Sopenharmony_ci
81262306a36Sopenharmony_ci	/* soft-reset the switch core */
81362306a36Sopenharmony_ci	ocelot_field_write(ocelot, GCB_SOFT_RST_SWC_RST, 1);
81462306a36Sopenharmony_ci
81562306a36Sopenharmony_ci	err = readx_poll_timeout(vsc9953_gcb_soft_rst_status, ocelot, val, !val,
81662306a36Sopenharmony_ci				 VSC9953_GCB_RST_SLEEP, VSC9953_INIT_TIMEOUT);
81762306a36Sopenharmony_ci	if (err) {
81862306a36Sopenharmony_ci		dev_err(ocelot->dev, "timeout: switch core reset\n");
81962306a36Sopenharmony_ci		return err;
82062306a36Sopenharmony_ci	}
82162306a36Sopenharmony_ci
82262306a36Sopenharmony_ci	/* initialize switch mem ~40us */
82362306a36Sopenharmony_ci	ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_ENA, 1);
82462306a36Sopenharmony_ci	ocelot_field_write(ocelot, SYS_RESET_CFG_MEM_INIT, 1);
82562306a36Sopenharmony_ci
82662306a36Sopenharmony_ci	err = readx_poll_timeout(vsc9953_sys_ram_init_status, ocelot, val, !val,
82762306a36Sopenharmony_ci				 VSC9953_SYS_RAMINIT_SLEEP,
82862306a36Sopenharmony_ci				 VSC9953_INIT_TIMEOUT);
82962306a36Sopenharmony_ci	if (err) {
83062306a36Sopenharmony_ci		dev_err(ocelot->dev, "timeout: switch sram init\n");
83162306a36Sopenharmony_ci		return err;
83262306a36Sopenharmony_ci	}
83362306a36Sopenharmony_ci
83462306a36Sopenharmony_ci	/* enable switch core */
83562306a36Sopenharmony_ci	ocelot_field_write(ocelot, SYS_RESET_CFG_CORE_ENA, 1);
83662306a36Sopenharmony_ci
83762306a36Sopenharmony_ci	return 0;
83862306a36Sopenharmony_ci}
83962306a36Sopenharmony_ci
84062306a36Sopenharmony_ci/* Watermark encode
84162306a36Sopenharmony_ci * Bit 9:   Unit; 0:1, 1:16
84262306a36Sopenharmony_ci * Bit 8-0: Value to be multiplied with unit
84362306a36Sopenharmony_ci */
84462306a36Sopenharmony_cistatic u16 vsc9953_wm_enc(u16 value)
84562306a36Sopenharmony_ci{
84662306a36Sopenharmony_ci	WARN_ON(value >= 16 * BIT(9));
84762306a36Sopenharmony_ci
84862306a36Sopenharmony_ci	if (value >= BIT(9))
84962306a36Sopenharmony_ci		return BIT(9) | (value / 16);
85062306a36Sopenharmony_ci
85162306a36Sopenharmony_ci	return value;
85262306a36Sopenharmony_ci}
85362306a36Sopenharmony_ci
85462306a36Sopenharmony_cistatic u16 vsc9953_wm_dec(u16 wm)
85562306a36Sopenharmony_ci{
85662306a36Sopenharmony_ci	WARN_ON(wm & ~GENMASK(9, 0));
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_ci	if (wm & BIT(9))
85962306a36Sopenharmony_ci		return (wm & GENMASK(8, 0)) * 16;
86062306a36Sopenharmony_ci
86162306a36Sopenharmony_ci	return wm;
86262306a36Sopenharmony_ci}
86362306a36Sopenharmony_ci
86462306a36Sopenharmony_cistatic void vsc9953_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
86562306a36Sopenharmony_ci{
86662306a36Sopenharmony_ci	*inuse = (val & GENMASK(25, 13)) >> 13;
86762306a36Sopenharmony_ci	*maxuse = val & GENMASK(12, 0);
86862306a36Sopenharmony_ci}
86962306a36Sopenharmony_ci
87062306a36Sopenharmony_cistatic const struct ocelot_ops vsc9953_ops = {
87162306a36Sopenharmony_ci	.reset			= vsc9953_reset,
87262306a36Sopenharmony_ci	.wm_enc			= vsc9953_wm_enc,
87362306a36Sopenharmony_ci	.wm_dec			= vsc9953_wm_dec,
87462306a36Sopenharmony_ci	.wm_stat		= vsc9953_wm_stat,
87562306a36Sopenharmony_ci	.port_to_netdev		= felix_port_to_netdev,
87662306a36Sopenharmony_ci	.netdev_to_port		= felix_netdev_to_port,
87762306a36Sopenharmony_ci};
87862306a36Sopenharmony_ci
87962306a36Sopenharmony_cistatic int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
88062306a36Sopenharmony_ci{
88162306a36Sopenharmony_ci	struct felix *felix = ocelot_to_felix(ocelot);
88262306a36Sopenharmony_ci	struct device *dev = ocelot->dev;
88362306a36Sopenharmony_ci	struct mii_bus *bus;
88462306a36Sopenharmony_ci	int port;
88562306a36Sopenharmony_ci	int rc;
88662306a36Sopenharmony_ci
88762306a36Sopenharmony_ci	felix->pcs = devm_kcalloc(dev, felix->info->num_ports,
88862306a36Sopenharmony_ci				  sizeof(struct phylink_pcs *),
88962306a36Sopenharmony_ci				  GFP_KERNEL);
89062306a36Sopenharmony_ci	if (!felix->pcs) {
89162306a36Sopenharmony_ci		dev_err(dev, "failed to allocate array for PCS PHYs\n");
89262306a36Sopenharmony_ci		return -ENOMEM;
89362306a36Sopenharmony_ci	}
89462306a36Sopenharmony_ci
89562306a36Sopenharmony_ci	rc = mscc_miim_setup(dev, &bus, "VSC9953 internal MDIO bus",
89662306a36Sopenharmony_ci			     ocelot->targets[GCB],
89762306a36Sopenharmony_ci			     ocelot->map[GCB][GCB_MIIM_MII_STATUS & REG_MASK],
89862306a36Sopenharmony_ci			     true);
89962306a36Sopenharmony_ci	if (rc) {
90062306a36Sopenharmony_ci		dev_err(dev, "failed to setup MDIO bus\n");
90162306a36Sopenharmony_ci		return rc;
90262306a36Sopenharmony_ci	}
90362306a36Sopenharmony_ci
90462306a36Sopenharmony_ci	/* Needed in order to initialize the bus mutex lock */
90562306a36Sopenharmony_ci	rc = devm_of_mdiobus_register(dev, bus, NULL);
90662306a36Sopenharmony_ci	if (rc < 0) {
90762306a36Sopenharmony_ci		dev_err(dev, "failed to register MDIO bus\n");
90862306a36Sopenharmony_ci		return rc;
90962306a36Sopenharmony_ci	}
91062306a36Sopenharmony_ci
91162306a36Sopenharmony_ci	felix->imdio = bus;
91262306a36Sopenharmony_ci
91362306a36Sopenharmony_ci	for (port = 0; port < felix->info->num_ports; port++) {
91462306a36Sopenharmony_ci		struct ocelot_port *ocelot_port = ocelot->ports[port];
91562306a36Sopenharmony_ci		struct phylink_pcs *phylink_pcs;
91662306a36Sopenharmony_ci		int addr = port + 4;
91762306a36Sopenharmony_ci
91862306a36Sopenharmony_ci		if (dsa_is_unused_port(felix->ds, port))
91962306a36Sopenharmony_ci			continue;
92062306a36Sopenharmony_ci
92162306a36Sopenharmony_ci		if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_INTERNAL)
92262306a36Sopenharmony_ci			continue;
92362306a36Sopenharmony_ci
92462306a36Sopenharmony_ci		phylink_pcs = lynx_pcs_create_mdiodev(felix->imdio, addr);
92562306a36Sopenharmony_ci		if (IS_ERR(phylink_pcs))
92662306a36Sopenharmony_ci			continue;
92762306a36Sopenharmony_ci
92862306a36Sopenharmony_ci		felix->pcs[port] = phylink_pcs;
92962306a36Sopenharmony_ci
93062306a36Sopenharmony_ci		dev_info(dev, "Found PCS at internal MDIO address %d\n", addr);
93162306a36Sopenharmony_ci	}
93262306a36Sopenharmony_ci
93362306a36Sopenharmony_ci	return 0;
93462306a36Sopenharmony_ci}
93562306a36Sopenharmony_ci
93662306a36Sopenharmony_cistatic void vsc9953_mdio_bus_free(struct ocelot *ocelot)
93762306a36Sopenharmony_ci{
93862306a36Sopenharmony_ci	struct felix *felix = ocelot_to_felix(ocelot);
93962306a36Sopenharmony_ci	int port;
94062306a36Sopenharmony_ci
94162306a36Sopenharmony_ci	for (port = 0; port < ocelot->num_phys_ports; port++) {
94262306a36Sopenharmony_ci		struct phylink_pcs *phylink_pcs = felix->pcs[port];
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci		if (phylink_pcs)
94562306a36Sopenharmony_ci			lynx_pcs_destroy(phylink_pcs);
94662306a36Sopenharmony_ci	}
94762306a36Sopenharmony_ci
94862306a36Sopenharmony_ci	/* mdiobus_unregister and mdiobus_free handled by devres */
94962306a36Sopenharmony_ci}
95062306a36Sopenharmony_ci
95162306a36Sopenharmony_cistatic const struct felix_info seville_info_vsc9953 = {
95262306a36Sopenharmony_ci	.resources		= vsc9953_resources,
95362306a36Sopenharmony_ci	.num_resources		= ARRAY_SIZE(vsc9953_resources),
95462306a36Sopenharmony_ci	.resource_names		= vsc9953_resource_names,
95562306a36Sopenharmony_ci	.regfields		= vsc9953_regfields,
95662306a36Sopenharmony_ci	.map			= vsc9953_regmap,
95762306a36Sopenharmony_ci	.ops			= &vsc9953_ops,
95862306a36Sopenharmony_ci	.vcap			= vsc9953_vcap_props,
95962306a36Sopenharmony_ci	.vcap_pol_base		= VSC9953_VCAP_POLICER_BASE,
96062306a36Sopenharmony_ci	.vcap_pol_max		= VSC9953_VCAP_POLICER_MAX,
96162306a36Sopenharmony_ci	.vcap_pol_base2		= VSC9953_VCAP_POLICER_BASE2,
96262306a36Sopenharmony_ci	.vcap_pol_max2		= VSC9953_VCAP_POLICER_MAX2,
96362306a36Sopenharmony_ci	.quirks			= FELIX_MAC_QUIRKS,
96462306a36Sopenharmony_ci	.num_mact_rows		= 2048,
96562306a36Sopenharmony_ci	.num_ports		= VSC9953_NUM_PORTS,
96662306a36Sopenharmony_ci	.num_tx_queues		= OCELOT_NUM_TC,
96762306a36Sopenharmony_ci	.mdio_bus_alloc		= vsc9953_mdio_bus_alloc,
96862306a36Sopenharmony_ci	.mdio_bus_free		= vsc9953_mdio_bus_free,
96962306a36Sopenharmony_ci	.port_modes		= vsc9953_port_modes,
97062306a36Sopenharmony_ci};
97162306a36Sopenharmony_ci
97262306a36Sopenharmony_cistatic int seville_probe(struct platform_device *pdev)
97362306a36Sopenharmony_ci{
97462306a36Sopenharmony_ci	struct dsa_switch *ds;
97562306a36Sopenharmony_ci	struct ocelot *ocelot;
97662306a36Sopenharmony_ci	struct resource *res;
97762306a36Sopenharmony_ci	struct felix *felix;
97862306a36Sopenharmony_ci	int err;
97962306a36Sopenharmony_ci
98062306a36Sopenharmony_ci	felix = kzalloc(sizeof(struct felix), GFP_KERNEL);
98162306a36Sopenharmony_ci	if (!felix) {
98262306a36Sopenharmony_ci		err = -ENOMEM;
98362306a36Sopenharmony_ci		dev_err(&pdev->dev, "Failed to allocate driver memory\n");
98462306a36Sopenharmony_ci		goto err_alloc_felix;
98562306a36Sopenharmony_ci	}
98662306a36Sopenharmony_ci
98762306a36Sopenharmony_ci	platform_set_drvdata(pdev, felix);
98862306a36Sopenharmony_ci
98962306a36Sopenharmony_ci	ocelot = &felix->ocelot;
99062306a36Sopenharmony_ci	ocelot->dev = &pdev->dev;
99162306a36Sopenharmony_ci	ocelot->num_flooding_pgids = 1;
99262306a36Sopenharmony_ci	felix->info = &seville_info_vsc9953;
99362306a36Sopenharmony_ci
99462306a36Sopenharmony_ci	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
99562306a36Sopenharmony_ci	if (!res) {
99662306a36Sopenharmony_ci		err = -EINVAL;
99762306a36Sopenharmony_ci		dev_err(&pdev->dev, "Invalid resource\n");
99862306a36Sopenharmony_ci		goto err_alloc_felix;
99962306a36Sopenharmony_ci	}
100062306a36Sopenharmony_ci	felix->switch_base = res->start;
100162306a36Sopenharmony_ci
100262306a36Sopenharmony_ci	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);
100362306a36Sopenharmony_ci	if (!ds) {
100462306a36Sopenharmony_ci		err = -ENOMEM;
100562306a36Sopenharmony_ci		dev_err(&pdev->dev, "Failed to allocate DSA switch\n");
100662306a36Sopenharmony_ci		goto err_alloc_ds;
100762306a36Sopenharmony_ci	}
100862306a36Sopenharmony_ci
100962306a36Sopenharmony_ci	ds->dev = &pdev->dev;
101062306a36Sopenharmony_ci	ds->num_ports = felix->info->num_ports;
101162306a36Sopenharmony_ci	ds->ops = &felix_switch_ops;
101262306a36Sopenharmony_ci	ds->priv = ocelot;
101362306a36Sopenharmony_ci	felix->ds = ds;
101462306a36Sopenharmony_ci	felix->tag_proto = DSA_TAG_PROTO_SEVILLE;
101562306a36Sopenharmony_ci
101662306a36Sopenharmony_ci	err = dsa_register_switch(ds);
101762306a36Sopenharmony_ci	if (err) {
101862306a36Sopenharmony_ci		dev_err(&pdev->dev, "Failed to register DSA switch: %d\n", err);
101962306a36Sopenharmony_ci		goto err_register_ds;
102062306a36Sopenharmony_ci	}
102162306a36Sopenharmony_ci
102262306a36Sopenharmony_ci	return 0;
102362306a36Sopenharmony_ci
102462306a36Sopenharmony_cierr_register_ds:
102562306a36Sopenharmony_ci	kfree(ds);
102662306a36Sopenharmony_cierr_alloc_ds:
102762306a36Sopenharmony_cierr_alloc_felix:
102862306a36Sopenharmony_ci	kfree(felix);
102962306a36Sopenharmony_ci	return err;
103062306a36Sopenharmony_ci}
103162306a36Sopenharmony_ci
103262306a36Sopenharmony_cistatic int seville_remove(struct platform_device *pdev)
103362306a36Sopenharmony_ci{
103462306a36Sopenharmony_ci	struct felix *felix = platform_get_drvdata(pdev);
103562306a36Sopenharmony_ci
103662306a36Sopenharmony_ci	if (!felix)
103762306a36Sopenharmony_ci		return 0;
103862306a36Sopenharmony_ci
103962306a36Sopenharmony_ci	dsa_unregister_switch(felix->ds);
104062306a36Sopenharmony_ci
104162306a36Sopenharmony_ci	kfree(felix->ds);
104262306a36Sopenharmony_ci	kfree(felix);
104362306a36Sopenharmony_ci
104462306a36Sopenharmony_ci	return 0;
104562306a36Sopenharmony_ci}
104662306a36Sopenharmony_ci
104762306a36Sopenharmony_cistatic void seville_shutdown(struct platform_device *pdev)
104862306a36Sopenharmony_ci{
104962306a36Sopenharmony_ci	struct felix *felix = platform_get_drvdata(pdev);
105062306a36Sopenharmony_ci
105162306a36Sopenharmony_ci	if (!felix)
105262306a36Sopenharmony_ci		return;
105362306a36Sopenharmony_ci
105462306a36Sopenharmony_ci	dsa_switch_shutdown(felix->ds);
105562306a36Sopenharmony_ci
105662306a36Sopenharmony_ci	platform_set_drvdata(pdev, NULL);
105762306a36Sopenharmony_ci}
105862306a36Sopenharmony_ci
105962306a36Sopenharmony_cistatic const struct of_device_id seville_of_match[] = {
106062306a36Sopenharmony_ci	{ .compatible = "mscc,vsc9953-switch" },
106162306a36Sopenharmony_ci	{ },
106262306a36Sopenharmony_ci};
106362306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, seville_of_match);
106462306a36Sopenharmony_ci
106562306a36Sopenharmony_cistatic struct platform_driver seville_vsc9953_driver = {
106662306a36Sopenharmony_ci	.probe		= seville_probe,
106762306a36Sopenharmony_ci	.remove		= seville_remove,
106862306a36Sopenharmony_ci	.shutdown	= seville_shutdown,
106962306a36Sopenharmony_ci	.driver = {
107062306a36Sopenharmony_ci		.name		= "mscc_seville",
107162306a36Sopenharmony_ci		.of_match_table	= seville_of_match,
107262306a36Sopenharmony_ci	},
107362306a36Sopenharmony_ci};
107462306a36Sopenharmony_cimodule_platform_driver(seville_vsc9953_driver);
107562306a36Sopenharmony_ci
107662306a36Sopenharmony_ciMODULE_DESCRIPTION("Seville Switch driver");
107762306a36Sopenharmony_ciMODULE_LICENSE("GPL v2");
1078