xref: /rk3399_rockchip-uboot/include/vsc9953.h (revision 86719f0cd55bc13186798217b08fa6a048eda27c)
16706b115SCodrin Ciubotariu /*
26706b115SCodrin Ciubotariu  *  vsc9953.h
36706b115SCodrin Ciubotariu  *
46706b115SCodrin Ciubotariu  *  Driver for the Vitesse VSC9953 L2 Switch
56706b115SCodrin Ciubotariu  *
66706b115SCodrin Ciubotariu  *  This software may be used and distributed according to the
76706b115SCodrin Ciubotariu  *  terms of the GNU Public License, Version 2, incorporated
86706b115SCodrin Ciubotariu  *  herein by reference.
96706b115SCodrin Ciubotariu  *
106706b115SCodrin Ciubotariu  * Copyright 2013  Freescale Semiconductor, Inc.
116706b115SCodrin Ciubotariu  *
126706b115SCodrin Ciubotariu  */
136706b115SCodrin Ciubotariu 
146706b115SCodrin Ciubotariu #ifndef _VSC9953_H_
156706b115SCodrin Ciubotariu #define _VSC9953_H_
166706b115SCodrin Ciubotariu 
176706b115SCodrin Ciubotariu #include <config.h>
186706b115SCodrin Ciubotariu #include <miiphy.h>
196706b115SCodrin Ciubotariu #include <asm/types.h>
206706b115SCodrin Ciubotariu 
216706b115SCodrin Ciubotariu #define VSC9953_OFFSET			(CONFIG_SYS_CCSRBAR_DEFAULT + 0x800000)
226706b115SCodrin Ciubotariu 
236706b115SCodrin Ciubotariu #define VSC9953_SYS_OFFSET		0x010000
249de05987SCodrin Ciubotariu #define VSC9953_REW_OFFSET		0x030000
256706b115SCodrin Ciubotariu #define VSC9953_DEV_GMII_OFFSET		0x100000
266706b115SCodrin Ciubotariu #define VSC9953_QSYS_OFFSET		0x200000
276706b115SCodrin Ciubotariu #define VSC9953_ANA_OFFSET		0x280000
286706b115SCodrin Ciubotariu #define VSC9953_DEVCPU_GCB		0x070000
296706b115SCodrin Ciubotariu #define VSC9953_ES0			0x040000
306706b115SCodrin Ciubotariu #define VSC9953_IS1			0x050000
316706b115SCodrin Ciubotariu #define VSC9953_IS2			0x060000
326706b115SCodrin Ciubotariu 
336706b115SCodrin Ciubotariu #define T1040_SWITCH_GMII_DEV_OFFSET	0x010000
346706b115SCodrin Ciubotariu #define VSC9953_PHY_REGS_OFFST		0x0000AC
356706b115SCodrin Ciubotariu 
363cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_chip_regs.soft_rst register */
37c4390486SCodrin Ciubotariu #define VSC9953_SOFT_SWC_RST_ENA	0x00000001
383cc8cfffSCodrin Ciubotariu 
393cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_sys_sys.reset_cfg register */
40c4390486SCodrin Ciubotariu #define VSC9953_CORE_ENABLE		0x80
41c4390486SCodrin Ciubotariu #define VSC9953_MEM_ENABLE		0x40
42c4390486SCodrin Ciubotariu #define VSC9953_MEM_INIT		0x20
436706b115SCodrin Ciubotariu 
443cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_ena_cfg register */
45c4390486SCodrin Ciubotariu #define VSC9953_MAC_ENA_CFG		0x00000011
463cc8cfffSCodrin Ciubotariu 
473cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_mode_cfg register */
48c4390486SCodrin Ciubotariu #define VSC9953_MAC_MODE_CFG		0x00000011
493cc8cfffSCodrin Ciubotariu 
503cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_ifg_cfg register */
51c4390486SCodrin Ciubotariu #define VSC9953_MAC_IFG_CFG		0x00000515
523cc8cfffSCodrin Ciubotariu 
533cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_hdx_cfg register */
54c4390486SCodrin Ciubotariu #define VSC9953_MAC_HDX_CFG		0x00001043
553cc8cfffSCodrin Ciubotariu 
563cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_maxlen_cfg register */
57c4390486SCodrin Ciubotariu #define VSC9953_MAC_MAX_LEN		0x000005ee
586706b115SCodrin Ciubotariu 
593cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_dev_gmii_port_mode.clock_cfg register */
603cc8cfffSCodrin Ciubotariu #define VSC9953_CLOCK_CFG		0x00000001
613cc8cfffSCodrin Ciubotariu #define VSC9953_CLOCK_CFG_1000M		0x00000001
623cc8cfffSCodrin Ciubotariu 
633cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_sys_sys.front_port_mode register */
643cc8cfffSCodrin Ciubotariu #define VSC9953_FRONT_PORT_MODE	0x00000000
653cc8cfffSCodrin Ciubotariu 
663cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_ana_pfc.pfc_cfg register */
673cc8cfffSCodrin Ciubotariu #define VSC9953_PFC_FC			0x00000001
683cc8cfffSCodrin Ciubotariu #define VSC9953_PFC_FC_QSGMII		0x00000000
693cc8cfffSCodrin Ciubotariu 
703cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_sys_pause_cfg.mac_fc_cfg register */
713cc8cfffSCodrin Ciubotariu #define VSC9953_MAC_FC_CFG		0x04700000
723cc8cfffSCodrin Ciubotariu #define VSC9953_MAC_FC_CFG_QSGMII	0x00700000
733cc8cfffSCodrin Ciubotariu 
743cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_sys_pause_cfg.pause_cfg register */
753cc8cfffSCodrin Ciubotariu #define VSC9953_PAUSE_CFG		0x001ffffe
763cc8cfffSCodrin Ciubotariu 
773cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_sys_pause_cfgtot_tail_drop_lvl register */
783cc8cfffSCodrin Ciubotariu #define VSC9953_TOT_TAIL_DROP_LVL	0x000003ff
793cc8cfffSCodrin Ciubotariu 
80*86719f0cSCodrin Ciubotariu /* Macros for vsc9953_sys_sys.stat_cfg register */
81*86719f0cSCodrin Ciubotariu #define VSC9953_STAT_CLEAR_RX		0x00000400
82*86719f0cSCodrin Ciubotariu #define VSC9953_STAT_CLEAR_TX		0x00000800
83*86719f0cSCodrin Ciubotariu #define VSC9953_STAT_CLEAR_DR		0x00001000
84*86719f0cSCodrin Ciubotariu 
853cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_vcap_core_cfg.vcap_mv_cfg register */
86c4390486SCodrin Ciubotariu #define VSC9953_VCAP_MV_CFG		0x0000ffff
87c4390486SCodrin Ciubotariu #define VSC9953_VCAP_UPDATE_CTRL	0x01000004
883cc8cfffSCodrin Ciubotariu 
899de05987SCodrin Ciubotariu /* Macros for vsc9953_ana_port.vlan_cfg register */
909de05987SCodrin Ciubotariu #define VSC9953_VLAN_CFG_AWARE_ENA	0x00100000
919de05987SCodrin Ciubotariu #define VSC9953_VLAN_CFG_POP_CNT_MASK	0x000c0000
929de05987SCodrin Ciubotariu #define VSC9953_VLAN_CFG_VID_MASK	0x00000fff
939de05987SCodrin Ciubotariu 
949de05987SCodrin Ciubotariu /* Macros for vsc9953_rew_port.port_vlan_cfg register */
959de05987SCodrin Ciubotariu #define VSC9953_PORT_VLAN_CFG_VID_MASK	0x00000fff
969de05987SCodrin Ciubotariu 
979de05987SCodrin Ciubotariu /* Macros for vsc9953_ana_ana_tables.vlan_tidx register */
989de05987SCodrin Ciubotariu #define VSC9953_ANA_TBL_VID_MASK	0x00000fff
999de05987SCodrin Ciubotariu 
1009de05987SCodrin Ciubotariu /* Macros for vsc9953_ana_ana_tables.vlan_access register */
1019de05987SCodrin Ciubotariu #define VSC9953_VLAN_PORT_MASK		0x00001ffc
1029de05987SCodrin Ciubotariu #define VSC9953_VLAN_CMD_MASK		0x00000003
1039de05987SCodrin Ciubotariu #define VSC9953_VLAN_CMD_IDLE		0x00000000
1049de05987SCodrin Ciubotariu #define VSC9953_VLAN_CMD_READ		0x00000001
1059de05987SCodrin Ciubotariu #define VSC9953_VLAN_CMD_WRITE		0x00000002
1069de05987SCodrin Ciubotariu #define VSC9953_VLAN_CMD_INIT		0x00000003
1079de05987SCodrin Ciubotariu 
1083cc8cfffSCodrin Ciubotariu /* Macros for vsc9953_qsys_sys.switch_port_mode register */
109fe91095bSCodrin Ciubotariu #define VSC9953_PORT_ENA		0x00002000
1103cc8cfffSCodrin Ciubotariu 
1119de05987SCodrin Ciubotariu /* Macros for vsc9953_ana_ana.adv_learn register */
1129de05987SCodrin Ciubotariu #define VSC9953_VLAN_CHK		0x00000400
1139de05987SCodrin Ciubotariu 
1149de05987SCodrin Ciubotariu /* Macros for vsc9953_rew_port.port_tag_cfg register */
1159de05987SCodrin Ciubotariu #define VSC9953_TAG_CFG_MASK		0x00000180
1169de05987SCodrin Ciubotariu #define VSC9953_TAG_CFG_NONE		0x00000000
1179de05987SCodrin Ciubotariu #define VSC9953_TAG_CFG_ALL_BUT_PVID_ZERO	0x00000080
1189de05987SCodrin Ciubotariu #define VSC9953_TAG_CFG_ALL_BUT_ZERO		0x00000100
1199de05987SCodrin Ciubotariu #define VSC9953_TAG_CFG_ALL		0x00000180
1209de05987SCodrin Ciubotariu 
1216706b115SCodrin Ciubotariu #define VSC9953_MAX_PORTS		10
1226706b115SCodrin Ciubotariu #define VSC9953_PORT_CHECK(port)	\
1236706b115SCodrin Ciubotariu 	(((port) < 0 || (port) >= VSC9953_MAX_PORTS) ? 0 : 1)
1246706b115SCodrin Ciubotariu #define VSC9953_INTERNAL_PORT_CHECK(port) ( \
1256706b115SCodrin Ciubotariu 	( \
1266706b115SCodrin Ciubotariu 		(port) < VSC9953_MAX_PORTS - 2 || (port) >= VSC9953_MAX_PORTS \
1276706b115SCodrin Ciubotariu 	) ? 0 : 1 \
1286706b115SCodrin Ciubotariu )
1299de05987SCodrin Ciubotariu #define VSC9953_MAX_VLAN		4096
1309de05987SCodrin Ciubotariu #define VSC9953_VLAN_CHECK(vid)	\
1319de05987SCodrin Ciubotariu 	(((vid) < 0 || (vid) >= VSC9953_MAX_VLAN) ? 0 : 1)
1326706b115SCodrin Ciubotariu 
1336706b115SCodrin Ciubotariu #define DEFAULT_VSC9953_MDIO_NAME	"VSC9953_MDIO0"
1346706b115SCodrin Ciubotariu 
1356706b115SCodrin Ciubotariu #define MIIMIND_OPR_PEND		0x00000004
1366706b115SCodrin Ciubotariu 
1376706b115SCodrin Ciubotariu struct vsc9953_mdio_info {
1386706b115SCodrin Ciubotariu 	struct vsc9953_mii_mng	*regs;
1396706b115SCodrin Ciubotariu 	char	*name;
1406706b115SCodrin Ciubotariu };
1416706b115SCodrin Ciubotariu 
1423cc8cfffSCodrin Ciubotariu /* VSC9953 ANA structure */
1436706b115SCodrin Ciubotariu 
1446706b115SCodrin Ciubotariu struct vsc9953_ana_port {
1456706b115SCodrin Ciubotariu 	u32	vlan_cfg;
1466706b115SCodrin Ciubotariu 	u32	drop_cfg;
1476706b115SCodrin Ciubotariu 	u32	qos_cfg;
1486706b115SCodrin Ciubotariu 	u32	vcap_cfg;
1496706b115SCodrin Ciubotariu 	u32	vcap_s1_key_cfg[3];
1506706b115SCodrin Ciubotariu 	u32	vcap_s2_cfg;
1516706b115SCodrin Ciubotariu 	u32	qos_pcp_dei_map_cfg[16];
1526706b115SCodrin Ciubotariu 	u32	cpu_fwd_cfg;
1536706b115SCodrin Ciubotariu 	u32	cpu_fwd_bpdu_cfg;
1546706b115SCodrin Ciubotariu 	u32	cpu_fwd_garp_cfg;
1556706b115SCodrin Ciubotariu 	u32	cpu_fwd_ccm_cfg;
1566706b115SCodrin Ciubotariu 	u32	port_cfg;
1576706b115SCodrin Ciubotariu 	u32	pol_cfg;
1586706b115SCodrin Ciubotariu 	u32	reserved[34];
1596706b115SCodrin Ciubotariu };
1606706b115SCodrin Ciubotariu 
1616706b115SCodrin Ciubotariu struct vsc9953_ana_pol {
1626706b115SCodrin Ciubotariu 	u32	pol_pir_cfg;
1636706b115SCodrin Ciubotariu 	u32	pol_cir_cfg;
1646706b115SCodrin Ciubotariu 	u32	pol_mode_cfg;
1656706b115SCodrin Ciubotariu 	u32	pol_pir_state;
1666706b115SCodrin Ciubotariu 	u32	pol_cir_state;
1676706b115SCodrin Ciubotariu 	u32	reserved1[3];
1686706b115SCodrin Ciubotariu };
1696706b115SCodrin Ciubotariu 
1706706b115SCodrin Ciubotariu struct vsc9953_ana_ana_tables {
1716706b115SCodrin Ciubotariu 	u32	entry_lim[11];
1726706b115SCodrin Ciubotariu 	u32	an_moved;
1736706b115SCodrin Ciubotariu 	u32	mach_data;
1746706b115SCodrin Ciubotariu 	u32	macl_data;
1756706b115SCodrin Ciubotariu 	u32	mac_access;
1766706b115SCodrin Ciubotariu 	u32	mact_indx;
1776706b115SCodrin Ciubotariu 	u32	vlan_access;
1786706b115SCodrin Ciubotariu 	u32	vlan_tidx;
1796706b115SCodrin Ciubotariu };
1806706b115SCodrin Ciubotariu 
1816706b115SCodrin Ciubotariu struct vsc9953_ana_ana {
1826706b115SCodrin Ciubotariu 	u32	adv_learn;
1836706b115SCodrin Ciubotariu 	u32	vlan_mask;
184440873dfSCodrin Ciubotariu 	u32	reserved;
1856706b115SCodrin Ciubotariu 	u32	anag_efil;
1866706b115SCodrin Ciubotariu 	u32	an_events;
1876706b115SCodrin Ciubotariu 	u32	storm_limit_burst;
1886706b115SCodrin Ciubotariu 	u32	storm_limit_cfg[4];
1896706b115SCodrin Ciubotariu 	u32	isolated_prts;
1906706b115SCodrin Ciubotariu 	u32	community_ports;
1916706b115SCodrin Ciubotariu 	u32	auto_age;
1926706b115SCodrin Ciubotariu 	u32	mac_options;
1936706b115SCodrin Ciubotariu 	u32	learn_disc;
1946706b115SCodrin Ciubotariu 	u32	agen_ctrl;
1956706b115SCodrin Ciubotariu 	u32	mirror_ports;
1966706b115SCodrin Ciubotariu 	u32	emirror_ports;
1976706b115SCodrin Ciubotariu 	u32	flooding;
1986706b115SCodrin Ciubotariu 	u32	flooding_ipmc;
1996706b115SCodrin Ciubotariu 	u32	sflow_cfg[11];
2006706b115SCodrin Ciubotariu 	u32	port_mode[12];
2016706b115SCodrin Ciubotariu };
2026706b115SCodrin Ciubotariu 
2036706b115SCodrin Ciubotariu struct vsc9953_ana_pgid {
2046706b115SCodrin Ciubotariu 	u32	port_grp_id[91];
2056706b115SCodrin Ciubotariu };
2066706b115SCodrin Ciubotariu 
2076706b115SCodrin Ciubotariu struct vsc9953_ana_pfc {
2086706b115SCodrin Ciubotariu 	u32	pfc_cfg;
2096706b115SCodrin Ciubotariu 	u32	reserved1[15];
2106706b115SCodrin Ciubotariu };
2116706b115SCodrin Ciubotariu 
2126706b115SCodrin Ciubotariu struct vsc9953_ana_pol_misc {
2136706b115SCodrin Ciubotariu 	u32	pol_flowc[10];
2146706b115SCodrin Ciubotariu 	u32	reserved1[17];
2156706b115SCodrin Ciubotariu 	u32	pol_hyst;
2166706b115SCodrin Ciubotariu };
2176706b115SCodrin Ciubotariu 
2186706b115SCodrin Ciubotariu struct vsc9953_ana_common {
2196706b115SCodrin Ciubotariu 	u32	aggr_cfg;
2206706b115SCodrin Ciubotariu 	u32	cpuq_cfg;
2216706b115SCodrin Ciubotariu 	u32	cpuq_8021_cfg;
2226706b115SCodrin Ciubotariu 	u32	dscp_cfg;
2236706b115SCodrin Ciubotariu 	u32	dscp_rewr_cfg;
2246706b115SCodrin Ciubotariu 	u32	vcap_rng_type_cfg;
2256706b115SCodrin Ciubotariu 	u32	vcap_rng_val_cfg;
2266706b115SCodrin Ciubotariu 	u32	discard_cfg;
2276706b115SCodrin Ciubotariu 	u32	fid_cfg;
2286706b115SCodrin Ciubotariu };
2296706b115SCodrin Ciubotariu 
2306706b115SCodrin Ciubotariu struct vsc9953_analyzer {
2316706b115SCodrin Ciubotariu 	struct vsc9953_ana_port	port[11];
2326706b115SCodrin Ciubotariu 	u32	reserved1[9536];
2336706b115SCodrin Ciubotariu 	struct vsc9953_ana_pol	pol[164];
2346706b115SCodrin Ciubotariu 	struct vsc9953_ana_ana_tables	ana_tables;
2356706b115SCodrin Ciubotariu 	u32	reserved2[14];
2366706b115SCodrin Ciubotariu 	struct vsc9953_ana_ana	ana;
2376706b115SCodrin Ciubotariu 	u32	reserved3[22];
2386706b115SCodrin Ciubotariu 	struct vsc9953_ana_pgid	port_id_tbl;
2396706b115SCodrin Ciubotariu 	u32	reserved4[549];
2406706b115SCodrin Ciubotariu 	struct vsc9953_ana_pfc	pfc[10];
2416706b115SCodrin Ciubotariu 	struct vsc9953_ana_pol_misc	pol_misc;
2426706b115SCodrin Ciubotariu 	u32	reserved5[196];
2436706b115SCodrin Ciubotariu 	struct vsc9953_ana_common	common;
2446706b115SCodrin Ciubotariu };
2453cc8cfffSCodrin Ciubotariu /* END VSC9953 ANA structure t*/
2466706b115SCodrin Ciubotariu 
2473cc8cfffSCodrin Ciubotariu /* VSC9953 DEV_GMII structure */
2486706b115SCodrin Ciubotariu 
2496706b115SCodrin Ciubotariu struct vsc9953_dev_gmii_port_mode {
2506706b115SCodrin Ciubotariu 	u32	clock_cfg;
2516706b115SCodrin Ciubotariu 	u32	port_misc;
2526706b115SCodrin Ciubotariu 	u32	reserved1;
2536706b115SCodrin Ciubotariu 	u32	eee_cfg;
2546706b115SCodrin Ciubotariu };
2556706b115SCodrin Ciubotariu 
2566706b115SCodrin Ciubotariu struct vsc9953_dev_gmii_mac_cfg_status {
2576706b115SCodrin Ciubotariu 	u32	mac_ena_cfg;
2586706b115SCodrin Ciubotariu 	u32	mac_mode_cfg;
2596706b115SCodrin Ciubotariu 	u32	mac_maxlen_cfg;
2606706b115SCodrin Ciubotariu 	u32	mac_tags_cfg;
2616706b115SCodrin Ciubotariu 	u32	mac_adv_chk_cfg;
2626706b115SCodrin Ciubotariu 	u32	mac_ifg_cfg;
2636706b115SCodrin Ciubotariu 	u32	mac_hdx_cfg;
2646706b115SCodrin Ciubotariu 	u32	mac_fc_mac_low_cfg;
2656706b115SCodrin Ciubotariu 	u32	mac_fc_mac_high_cfg;
2666706b115SCodrin Ciubotariu 	u32	mac_sticky;
2676706b115SCodrin Ciubotariu };
2686706b115SCodrin Ciubotariu 
2696706b115SCodrin Ciubotariu struct vsc9953_dev_gmii {
2706706b115SCodrin Ciubotariu 	struct vsc9953_dev_gmii_port_mode	port_mode;
2716706b115SCodrin Ciubotariu 	struct vsc9953_dev_gmii_mac_cfg_status	mac_cfg_status;
2726706b115SCodrin Ciubotariu };
2736706b115SCodrin Ciubotariu 
2743cc8cfffSCodrin Ciubotariu /* END VSC9953 DEV_GMII structure */
2756706b115SCodrin Ciubotariu 
2763cc8cfffSCodrin Ciubotariu /* VSC9953 QSYS structure */
2776706b115SCodrin Ciubotariu 
2786706b115SCodrin Ciubotariu struct vsc9953_qsys_hsch {
2796706b115SCodrin Ciubotariu 	u32	cir_cfg;
2806706b115SCodrin Ciubotariu 	u32	reserved1;
2816706b115SCodrin Ciubotariu 	u32	se_cfg;
2826706b115SCodrin Ciubotariu 	u32	se_dwrr_cfg[8];
2836706b115SCodrin Ciubotariu 	u32	cir_state;
2846706b115SCodrin Ciubotariu 	u32	reserved2[20];
2856706b115SCodrin Ciubotariu };
2866706b115SCodrin Ciubotariu 
2876706b115SCodrin Ciubotariu struct vsc9953_qsys_sys {
2886706b115SCodrin Ciubotariu 	u32	port_mode[12];
2896706b115SCodrin Ciubotariu 	u32	switch_port_mode[11];
2906706b115SCodrin Ciubotariu 	u32	stat_cnt_cfg;
2916706b115SCodrin Ciubotariu 	u32	eee_cfg[10];
2926706b115SCodrin Ciubotariu 	u32	eee_thrs;
2936706b115SCodrin Ciubotariu 	u32	igr_no_sharing;
2946706b115SCodrin Ciubotariu 	u32	egr_no_sharing;
2956706b115SCodrin Ciubotariu 	u32	sw_status[11];
2966706b115SCodrin Ciubotariu 	u32	ext_cpu_cfg;
2976706b115SCodrin Ciubotariu 	u32	cpu_group_map;
2986706b115SCodrin Ciubotariu 	u32	reserved1[23];
2996706b115SCodrin Ciubotariu };
3006706b115SCodrin Ciubotariu 
3016706b115SCodrin Ciubotariu struct vsc9953_qsys_qos_cfg {
3026706b115SCodrin Ciubotariu 	u32	red_profile[16];
3036706b115SCodrin Ciubotariu 	u32	res_qos_mode;
3046706b115SCodrin Ciubotariu };
3056706b115SCodrin Ciubotariu 
3066706b115SCodrin Ciubotariu struct vsc9953_qsys_drop_cfg {
3076706b115SCodrin Ciubotariu 	u32	egr_drop_mode;
3086706b115SCodrin Ciubotariu };
3096706b115SCodrin Ciubotariu 
3106706b115SCodrin Ciubotariu struct vsc9953_qsys_mmgt {
3116706b115SCodrin Ciubotariu 	u32	eq_cntrl;
3126706b115SCodrin Ciubotariu 	u32	reserved1;
3136706b115SCodrin Ciubotariu };
3146706b115SCodrin Ciubotariu 
3156706b115SCodrin Ciubotariu struct vsc9953_qsys_hsch_misc {
3166706b115SCodrin Ciubotariu 	u32	hsch_misc_cfg;
3176706b115SCodrin Ciubotariu 	u32	reserved1[546];
3186706b115SCodrin Ciubotariu };
3196706b115SCodrin Ciubotariu 
3206706b115SCodrin Ciubotariu struct vsc9953_qsys_res_ctrl {
3216706b115SCodrin Ciubotariu 	u32	res_cfg;
3226706b115SCodrin Ciubotariu 	u32	res_stat;
3236706b115SCodrin Ciubotariu 
3246706b115SCodrin Ciubotariu };
3256706b115SCodrin Ciubotariu 
3266706b115SCodrin Ciubotariu struct vsc9953_qsys_reg {
3276706b115SCodrin Ciubotariu 	struct vsc9953_qsys_hsch	hsch[108];
3286706b115SCodrin Ciubotariu 	struct vsc9953_qsys_sys	sys;
3296706b115SCodrin Ciubotariu 	struct vsc9953_qsys_qos_cfg	qos_cfg;
3306706b115SCodrin Ciubotariu 	struct vsc9953_qsys_drop_cfg	drop_cfg;
3316706b115SCodrin Ciubotariu 	struct vsc9953_qsys_mmgt	mmgt;
3326706b115SCodrin Ciubotariu 	struct vsc9953_qsys_hsch_misc	hsch_misc;
3336706b115SCodrin Ciubotariu 	struct vsc9953_qsys_res_ctrl	res_ctrl[1024];
3346706b115SCodrin Ciubotariu };
3356706b115SCodrin Ciubotariu 
3363cc8cfffSCodrin Ciubotariu /* END VSC9953 QSYS structure */
3376706b115SCodrin Ciubotariu 
3383cc8cfffSCodrin Ciubotariu /* VSC9953 SYS structure */
3396706b115SCodrin Ciubotariu 
340*86719f0cSCodrin Ciubotariu struct vsc9953_rx_cntrs {
341*86719f0cSCodrin Ciubotariu 	u32	c_rx_oct;
342*86719f0cSCodrin Ciubotariu 	u32	c_rx_uc;
343*86719f0cSCodrin Ciubotariu 	u32	c_rx_mc;
344*86719f0cSCodrin Ciubotariu 	u32	c_rx_bc;
345*86719f0cSCodrin Ciubotariu 	u32	c_rx_short;
346*86719f0cSCodrin Ciubotariu 	u32	c_rx_frag;
347*86719f0cSCodrin Ciubotariu 	u32	c_rx_jabber;
348*86719f0cSCodrin Ciubotariu 	u32	c_rx_crc;
349*86719f0cSCodrin Ciubotariu 	u32	c_rx_symbol_err;
350*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_64;
351*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_65_127;
352*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_128_255;
353*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_256_511;
354*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_512_1023;
355*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_1024_1526;
356*86719f0cSCodrin Ciubotariu 	u32	c_rx_sz_jumbo;
357*86719f0cSCodrin Ciubotariu 	u32	c_rx_pause;
358*86719f0cSCodrin Ciubotariu 	u32	c_rx_control;
359*86719f0cSCodrin Ciubotariu 	u32	c_rx_long;
360*86719f0cSCodrin Ciubotariu 	u32	c_rx_cat_drop;
361*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_0;
362*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_1;
363*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_2;
364*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_3;
365*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_4;
366*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_5;
367*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_6;
368*86719f0cSCodrin Ciubotariu 	u32	c_rx_red_prio_7;
369*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_0;
370*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_1;
371*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_2;
372*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_3;
373*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_4;
374*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_5;
375*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_6;
376*86719f0cSCodrin Ciubotariu 	u32	c_rx_yellow_prio_7;
377*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_0;
378*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_1;
379*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_2;
380*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_3;
381*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_4;
382*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_5;
383*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_6;
384*86719f0cSCodrin Ciubotariu 	u32	c_rx_green_prio_7;
385*86719f0cSCodrin Ciubotariu 	u32	reserved[20];
386*86719f0cSCodrin Ciubotariu };
387*86719f0cSCodrin Ciubotariu 
388*86719f0cSCodrin Ciubotariu struct vsc9953_tx_cntrs {
389*86719f0cSCodrin Ciubotariu 	u32	c_tx_oct;
390*86719f0cSCodrin Ciubotariu 	u32	c_tx_uc;
391*86719f0cSCodrin Ciubotariu 	u32	c_tx_mc;
392*86719f0cSCodrin Ciubotariu 	u32	c_tx_bc;
393*86719f0cSCodrin Ciubotariu 	u32	c_tx_col;
394*86719f0cSCodrin Ciubotariu 	u32	c_tx_drop;
395*86719f0cSCodrin Ciubotariu 	u32	c_tx_pause;
396*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_64;
397*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_65_127;
398*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_128_255;
399*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_256_511;
400*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_512_1023;
401*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_1024_1526;
402*86719f0cSCodrin Ciubotariu 	u32	c_tx_sz_jumbo;
403*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_0;
404*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_1;
405*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_2;
406*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_3;
407*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_4;
408*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_5;
409*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_6;
410*86719f0cSCodrin Ciubotariu 	u32	c_tx_yellow_prio_7;
411*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_0;
412*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_1;
413*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_2;
414*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_3;
415*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_4;
416*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_5;
417*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_6;
418*86719f0cSCodrin Ciubotariu 	u32	c_tx_green_prio_7;
419*86719f0cSCodrin Ciubotariu 	u32	c_tx_aged;
420*86719f0cSCodrin Ciubotariu 	u32	reserved[33];
421*86719f0cSCodrin Ciubotariu };
422*86719f0cSCodrin Ciubotariu 
423*86719f0cSCodrin Ciubotariu struct vsc9953_drop_cntrs {
424*86719f0cSCodrin Ciubotariu 	u32	c_dr_local;
425*86719f0cSCodrin Ciubotariu 	u32	c_dr_tail;
426*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_0;
427*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_1;
428*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_2;
429*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_3;
430*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_4;
431*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_5;
432*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_6;
433*86719f0cSCodrin Ciubotariu 	u32	c_dr_yellow_prio_7;
434*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_0;
435*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_1;
436*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_2;
437*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_3;
438*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_4;
439*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_5;
440*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_6;
441*86719f0cSCodrin Ciubotariu 	u32	c_dr_green_prio_7;
442*86719f0cSCodrin Ciubotariu 	u32	reserved[46];
443*86719f0cSCodrin Ciubotariu };
444*86719f0cSCodrin Ciubotariu 
4456706b115SCodrin Ciubotariu struct vsc9953_sys_stat {
446*86719f0cSCodrin Ciubotariu 	struct vsc9953_rx_cntrs	rx_cntrs;
447*86719f0cSCodrin Ciubotariu 	struct vsc9953_tx_cntrs	tx_cntrs;
448*86719f0cSCodrin Ciubotariu 	struct vsc9953_drop_cntrs	drop_cntrs;
4496706b115SCodrin Ciubotariu 	u32	reserved1[6];
4506706b115SCodrin Ciubotariu };
4516706b115SCodrin Ciubotariu 
4526706b115SCodrin Ciubotariu struct vsc9953_sys_sys {
4536706b115SCodrin Ciubotariu 	u32	reset_cfg;
4546706b115SCodrin Ciubotariu 	u32	reserved1;
4556706b115SCodrin Ciubotariu 	u32	vlan_etype_cfg;
4566706b115SCodrin Ciubotariu 	u32	port_mode[12];
4576706b115SCodrin Ciubotariu 	u32	front_port_mode[10];
4586706b115SCodrin Ciubotariu 	u32	frame_aging;
4596706b115SCodrin Ciubotariu 	u32	stat_cfg;
4606706b115SCodrin Ciubotariu 	u32	reserved2[50];
4616706b115SCodrin Ciubotariu };
4626706b115SCodrin Ciubotariu 
4636706b115SCodrin Ciubotariu struct vsc9953_sys_pause_cfg {
4646706b115SCodrin Ciubotariu 	u32	pause_cfg[11];
4656706b115SCodrin Ciubotariu 	u32	pause_tot_cfg;
4666706b115SCodrin Ciubotariu 	u32	tail_drop_level[11];
4676706b115SCodrin Ciubotariu 	u32	tot_tail_drop_lvl;
4686706b115SCodrin Ciubotariu 	u32	mac_fc_cfg[10];
4696706b115SCodrin Ciubotariu };
4706706b115SCodrin Ciubotariu 
4716706b115SCodrin Ciubotariu struct vsc9953_sys_mmgt {
4726706b115SCodrin Ciubotariu 	u16	free_cnt;
4736706b115SCodrin Ciubotariu };
4746706b115SCodrin Ciubotariu 
4756706b115SCodrin Ciubotariu struct vsc9953_system_reg {
4766706b115SCodrin Ciubotariu 	struct vsc9953_sys_stat	stat;
4776706b115SCodrin Ciubotariu 	struct vsc9953_sys_sys	sys;
4786706b115SCodrin Ciubotariu 	struct vsc9953_sys_pause_cfg	pause_cfg;
4796706b115SCodrin Ciubotariu 	struct vsc9953_sys_mmgt	mmgt;
4806706b115SCodrin Ciubotariu };
4816706b115SCodrin Ciubotariu 
4823cc8cfffSCodrin Ciubotariu /* END VSC9953 SYS structure */
4836706b115SCodrin Ciubotariu 
4849de05987SCodrin Ciubotariu /* VSC9953 REW structure */
4859de05987SCodrin Ciubotariu 
4869de05987SCodrin Ciubotariu struct	vsc9953_rew_port {
4879de05987SCodrin Ciubotariu 	u32	port_vlan_cfg;
4889de05987SCodrin Ciubotariu 	u32	port_tag_cfg;
4899de05987SCodrin Ciubotariu 	u32	port_port_cfg;
4909de05987SCodrin Ciubotariu 	u32	port_dscp_cfg;
4919de05987SCodrin Ciubotariu 	u32	port_pcp_dei_qos_map_cfg[16];
4929de05987SCodrin Ciubotariu 	u32	reserved[12];
4939de05987SCodrin Ciubotariu };
4949de05987SCodrin Ciubotariu 
4959de05987SCodrin Ciubotariu struct	vsc9953_rew_common {
4969de05987SCodrin Ciubotariu 	u32	reserve[4];
4979de05987SCodrin Ciubotariu 	u32	dscp_remap_dp1_cfg[64];
4989de05987SCodrin Ciubotariu 	u32	dscp_remap_cfg[64];
4999de05987SCodrin Ciubotariu };
5009de05987SCodrin Ciubotariu 
5019de05987SCodrin Ciubotariu struct	vsc9953_rew_reg {
5029de05987SCodrin Ciubotariu 	struct vsc9953_rew_port	port[12];
5039de05987SCodrin Ciubotariu 	struct vsc9953_rew_common	common;
5049de05987SCodrin Ciubotariu };
5059de05987SCodrin Ciubotariu 
5069de05987SCodrin Ciubotariu /* END VSC9953 REW structure */
5076706b115SCodrin Ciubotariu 
5083cc8cfffSCodrin Ciubotariu /* VSC9953 DEVCPU_GCB structure */
5096706b115SCodrin Ciubotariu 
5106706b115SCodrin Ciubotariu struct vsc9953_chip_regs {
5116706b115SCodrin Ciubotariu 	u32	chipd_id;
5126706b115SCodrin Ciubotariu 	u32	gpr;
5136706b115SCodrin Ciubotariu 	u32	soft_rst;
5146706b115SCodrin Ciubotariu };
5156706b115SCodrin Ciubotariu 
5166706b115SCodrin Ciubotariu struct vsc9953_gpio {
5176706b115SCodrin Ciubotariu 	u32	gpio_out_set[10];
5186706b115SCodrin Ciubotariu 	u32	gpio_out_clr[10];
5196706b115SCodrin Ciubotariu 	u32	gpio_out[10];
5206706b115SCodrin Ciubotariu 	u32	gpio_in[10];
5216706b115SCodrin Ciubotariu };
5226706b115SCodrin Ciubotariu 
5236706b115SCodrin Ciubotariu struct vsc9953_mii_mng {
5246706b115SCodrin Ciubotariu 	u32	miimstatus;
5256706b115SCodrin Ciubotariu 	u32	reserved1;
5266706b115SCodrin Ciubotariu 	u32	miimcmd;
5276706b115SCodrin Ciubotariu 	u32	miimdata;
5286706b115SCodrin Ciubotariu 	u32	miimcfg;
5296706b115SCodrin Ciubotariu 	u32	miimscan_0;
5306706b115SCodrin Ciubotariu 	u32	miimscan_1;
5316706b115SCodrin Ciubotariu 	u32	miiscan_lst_rslts;
5326706b115SCodrin Ciubotariu 	u32	miiscan_lst_rslts_valid;
5336706b115SCodrin Ciubotariu };
5346706b115SCodrin Ciubotariu 
5356706b115SCodrin Ciubotariu struct vsc9953_mii_read_scan {
5366706b115SCodrin Ciubotariu 	u32	mii_scan_results_sticky[2];
5376706b115SCodrin Ciubotariu };
5386706b115SCodrin Ciubotariu 
5396706b115SCodrin Ciubotariu struct vsc9953_devcpu_gcb {
5406706b115SCodrin Ciubotariu 	struct vsc9953_chip_regs	chip_regs;
5416706b115SCodrin Ciubotariu 	struct vsc9953_gpio		gpio;
5426706b115SCodrin Ciubotariu 	struct vsc9953_mii_mng	mii_mng[2];
5436706b115SCodrin Ciubotariu 	struct vsc9953_mii_read_scan	mii_read_scan;
5446706b115SCodrin Ciubotariu };
5456706b115SCodrin Ciubotariu 
5463cc8cfffSCodrin Ciubotariu /* END VSC9953 DEVCPU_GCB structure */
5476706b115SCodrin Ciubotariu 
5483cc8cfffSCodrin Ciubotariu /* VSC9953 IS* structure */
5496706b115SCodrin Ciubotariu 
5506706b115SCodrin Ciubotariu struct vsc9953_vcap_core_cfg {
5516706b115SCodrin Ciubotariu 	u32	vcap_update_ctrl;
5526706b115SCodrin Ciubotariu 	u32	vcap_mv_cfg;
5536706b115SCodrin Ciubotariu };
5546706b115SCodrin Ciubotariu 
5556706b115SCodrin Ciubotariu struct vsc9953_vcap {
5566706b115SCodrin Ciubotariu 	struct vsc9953_vcap_core_cfg	vcap_core_cfg;
5576706b115SCodrin Ciubotariu };
5586706b115SCodrin Ciubotariu 
5593cc8cfffSCodrin Ciubotariu /* END VSC9953 IS* structure */
5606706b115SCodrin Ciubotariu 
5616706b115SCodrin Ciubotariu #define VSC9953_PORT_INFO_INITIALIZER(idx) \
5626706b115SCodrin Ciubotariu {									\
5636706b115SCodrin Ciubotariu 	.enabled	= 0,						\
5646706b115SCodrin Ciubotariu 	.phyaddr	= 0,						\
5656706b115SCodrin Ciubotariu 	.index		= idx,						\
5666706b115SCodrin Ciubotariu 	.phy_regs	= NULL,						\
5676706b115SCodrin Ciubotariu 	.enet_if	= PHY_INTERFACE_MODE_NONE,			\
5686706b115SCodrin Ciubotariu 	.bus		= NULL,						\
5696706b115SCodrin Ciubotariu 	.phydev		= NULL,						\
5706706b115SCodrin Ciubotariu }
5716706b115SCodrin Ciubotariu 
5726706b115SCodrin Ciubotariu /* Structure to describe a VSC9953 port */
5736706b115SCodrin Ciubotariu struct vsc9953_port_info {
5746706b115SCodrin Ciubotariu 	u8	enabled;
5756706b115SCodrin Ciubotariu 	u8	phyaddr;
5766706b115SCodrin Ciubotariu 	int	index;
5776706b115SCodrin Ciubotariu 	void	*phy_regs;
5786706b115SCodrin Ciubotariu 	phy_interface_t	enet_if;
5796706b115SCodrin Ciubotariu 	struct mii_dev	*bus;
5806706b115SCodrin Ciubotariu 	struct phy_device	*phydev;
5816706b115SCodrin Ciubotariu };
5826706b115SCodrin Ciubotariu 
5836706b115SCodrin Ciubotariu /* Structure to describe a VSC9953 switch */
5846706b115SCodrin Ciubotariu struct vsc9953_info {
5856706b115SCodrin Ciubotariu 	struct vsc9953_port_info	port[VSC9953_MAX_PORTS];
5866706b115SCodrin Ciubotariu };
5876706b115SCodrin Ciubotariu 
5886706b115SCodrin Ciubotariu void vsc9953_init(bd_t *bis);
5896706b115SCodrin Ciubotariu 
5903cc8cfffSCodrin Ciubotariu void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus);
5913cc8cfffSCodrin Ciubotariu void vsc9953_port_info_set_phy_address(int port_no, int address);
5923cc8cfffSCodrin Ciubotariu void vsc9953_port_enable(int port_no);
5933cc8cfffSCodrin Ciubotariu void vsc9953_port_disable(int port_no);
5943cc8cfffSCodrin Ciubotariu void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int);
5956706b115SCodrin Ciubotariu 
5966706b115SCodrin Ciubotariu #endif /* _VSC9953_H_ */
597