4 * Driver for the Vitesse VSC9953 L2 Switch
6 * This software may be used and distributed according to the
7 * terms of the GNU Public License, Version 2, incorporated
10 * Copyright 2013 Freescale Semiconductor, Inc.
19 #include <asm/types.h>
21 #define VSC9953_OFFSET (CONFIG_SYS_CCSRBAR_DEFAULT + 0x800000)
23 #define VSC9953_SYS_OFFSET 0x010000
24 #define VSC9953_REW_OFFSET 0x030000
25 #define VSC9953_DEV_GMII_OFFSET 0x100000
26 #define VSC9953_QSYS_OFFSET 0x200000
27 #define VSC9953_ANA_OFFSET 0x280000
28 #define VSC9953_DEVCPU_GCB 0x070000
29 #define VSC9953_ES0 0x040000
30 #define VSC9953_IS1 0x050000
31 #define VSC9953_IS2 0x060000
33 #define T1040_SWITCH_GMII_DEV_OFFSET 0x010000
34 #define VSC9953_PHY_REGS_OFFST 0x0000AC
36 /* Macros for vsc9953_chip_regs.soft_rst register */
37 #define VSC9953_SOFT_SWC_RST_ENA 0x00000001
39 /* Macros for vsc9953_sys_sys.reset_cfg register */
40 #define VSC9953_CORE_ENABLE 0x80
41 #define VSC9953_MEM_ENABLE 0x40
42 #define VSC9953_MEM_INIT 0x20
44 /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_ena_cfg register */
45 #define VSC9953_MAC_ENA_CFG 0x00000011
47 /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_mode_cfg register */
48 #define VSC9953_MAC_MODE_CFG 0x00000011
50 /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_ifg_cfg register */
51 #define VSC9953_MAC_IFG_CFG 0x00000515
53 /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_hdx_cfg register */
54 #define VSC9953_MAC_HDX_CFG 0x00001043
56 /* Macros for vsc9953_dev_gmii_mac_cfg_status.mac_maxlen_cfg register */
57 #define VSC9953_MAC_MAX_LEN 0x000005ee
59 /* Macros for vsc9953_dev_gmii_port_mode.clock_cfg register */
60 #define VSC9953_CLOCK_CFG 0x00000001
61 #define VSC9953_CLOCK_CFG_1000M 0x00000001
63 /* Macros for vsc9953_sys_sys.front_port_mode register */
64 #define VSC9953_FRONT_PORT_MODE 0x00000000
66 /* Macros for vsc9953_ana_pfc.pfc_cfg register */
67 #define VSC9953_PFC_FC 0x00000001
68 #define VSC9953_PFC_FC_QSGMII 0x00000000
70 /* Macros for vsc9953_sys_pause_cfg.mac_fc_cfg register */
71 #define VSC9953_MAC_FC_CFG 0x04700000
72 #define VSC9953_MAC_FC_CFG_QSGMII 0x00700000
74 /* Macros for vsc9953_sys_pause_cfg.pause_cfg register */
75 #define VSC9953_PAUSE_CFG 0x001ffffe
77 /* Macros for vsc9953_sys_pause_cfgtot_tail_drop_lvl register */
78 #define VSC9953_TOT_TAIL_DROP_LVL 0x000003ff
80 /* Macros for vsc9953_sys_sys.stat_cfg register */
81 #define VSC9953_STAT_CLEAR_RX 0x00000400
82 #define VSC9953_STAT_CLEAR_TX 0x00000800
83 #define VSC9953_STAT_CLEAR_DR 0x00001000
85 /* Macros for vsc9953_vcap_core_cfg.vcap_mv_cfg register */
86 #define VSC9953_VCAP_MV_CFG 0x0000ffff
87 #define VSC9953_VCAP_UPDATE_CTRL 0x01000004
89 /* Macros for vsc9953_ana_port.vlan_cfg register */
90 #define VSC9953_VLAN_CFG_AWARE_ENA 0x00100000
91 #define VSC9953_VLAN_CFG_POP_CNT_MASK 0x000c0000
92 #define VSC9953_VLAN_CFG_VID_MASK 0x00000fff
94 /* Macros for vsc9953_rew_port.port_vlan_cfg register */
95 #define VSC9953_PORT_VLAN_CFG_VID_MASK 0x00000fff
97 /* Macros for vsc9953_ana_ana_tables.vlan_tidx register */
98 #define VSC9953_ANA_TBL_VID_MASK 0x00000fff
100 /* Macros for vsc9953_ana_ana_tables.vlan_access register */
101 #define VSC9953_VLAN_PORT_MASK 0x00001ffc
102 #define VSC9953_VLAN_CMD_MASK 0x00000003
103 #define VSC9953_VLAN_CMD_IDLE 0x00000000
104 #define VSC9953_VLAN_CMD_READ 0x00000001
105 #define VSC9953_VLAN_CMD_WRITE 0x00000002
106 #define VSC9953_VLAN_CMD_INIT 0x00000003
108 /* Macros for vsc9953_qsys_sys.switch_port_mode register */
109 #define VSC9953_PORT_ENA 0x00002000
111 /* Macros for vsc9953_ana_ana.adv_learn register */
112 #define VSC9953_VLAN_CHK 0x00000400
114 /* Macros for vsc9953_rew_port.port_tag_cfg register */
115 #define VSC9953_TAG_CFG_MASK 0x00000180
116 #define VSC9953_TAG_CFG_NONE 0x00000000
117 #define VSC9953_TAG_CFG_ALL_BUT_PVID_ZERO 0x00000080
118 #define VSC9953_TAG_CFG_ALL_BUT_ZERO 0x00000100
119 #define VSC9953_TAG_CFG_ALL 0x00000180
121 #define VSC9953_MAX_PORTS 10
122 #define VSC9953_PORT_CHECK(port) \
123 (((port) < 0 || (port) >= VSC9953_MAX_PORTS) ? 0 : 1)
124 #define VSC9953_INTERNAL_PORT_CHECK(port) ( \
126 (port) < VSC9953_MAX_PORTS - 2 || (port) >= VSC9953_MAX_PORTS \
129 #define VSC9953_MAX_VLAN 4096
130 #define VSC9953_VLAN_CHECK(vid) \
131 (((vid) < 0 || (vid) >= VSC9953_MAX_VLAN) ? 0 : 1)
133 #define DEFAULT_VSC9953_MDIO_NAME "VSC9953_MDIO0"
135 #define MIIMIND_OPR_PEND 0x00000004
137 struct vsc9953_mdio_info {
138 struct vsc9953_mii_mng *regs;
142 /* VSC9953 ANA structure */
144 struct vsc9953_ana_port {
149 u32 vcap_s1_key_cfg[3];
151 u32 qos_pcp_dei_map_cfg[16];
153 u32 cpu_fwd_bpdu_cfg;
154 u32 cpu_fwd_garp_cfg;
161 struct vsc9953_ana_pol {
170 struct vsc9953_ana_ana_tables {
181 struct vsc9953_ana_ana {
187 u32 storm_limit_burst;
188 u32 storm_limit_cfg[4];
203 struct vsc9953_ana_pgid {
207 struct vsc9953_ana_pfc {
212 struct vsc9953_ana_pol_misc {
218 struct vsc9953_ana_common {
224 u32 vcap_rng_type_cfg;
225 u32 vcap_rng_val_cfg;
230 struct vsc9953_analyzer {
231 struct vsc9953_ana_port port[11];
233 struct vsc9953_ana_pol pol[164];
234 struct vsc9953_ana_ana_tables ana_tables;
236 struct vsc9953_ana_ana ana;
238 struct vsc9953_ana_pgid port_id_tbl;
240 struct vsc9953_ana_pfc pfc[10];
241 struct vsc9953_ana_pol_misc pol_misc;
243 struct vsc9953_ana_common common;
245 /* END VSC9953 ANA structure t*/
247 /* VSC9953 DEV_GMII structure */
249 struct vsc9953_dev_gmii_port_mode {
256 struct vsc9953_dev_gmii_mac_cfg_status {
264 u32 mac_fc_mac_low_cfg;
265 u32 mac_fc_mac_high_cfg;
269 struct vsc9953_dev_gmii {
270 struct vsc9953_dev_gmii_port_mode port_mode;
271 struct vsc9953_dev_gmii_mac_cfg_status mac_cfg_status;
274 /* END VSC9953 DEV_GMII structure */
276 /* VSC9953 QSYS structure */
278 struct vsc9953_qsys_hsch {
287 struct vsc9953_qsys_sys {
289 u32 switch_port_mode[11];
301 struct vsc9953_qsys_qos_cfg {
306 struct vsc9953_qsys_drop_cfg {
310 struct vsc9953_qsys_mmgt {
315 struct vsc9953_qsys_hsch_misc {
320 struct vsc9953_qsys_res_ctrl {
326 struct vsc9953_qsys_reg {
327 struct vsc9953_qsys_hsch hsch[108];
328 struct vsc9953_qsys_sys sys;
329 struct vsc9953_qsys_qos_cfg qos_cfg;
330 struct vsc9953_qsys_drop_cfg drop_cfg;
331 struct vsc9953_qsys_mmgt mmgt;
332 struct vsc9953_qsys_hsch_misc hsch_misc;
333 struct vsc9953_qsys_res_ctrl res_ctrl[1024];
336 /* END VSC9953 QSYS structure */
338 /* VSC9953 SYS structure */
340 struct vsc9953_rx_cntrs {
354 u32 c_rx_sz_512_1023;
355 u32 c_rx_sz_1024_1526;
369 u32 c_rx_yellow_prio_0;
370 u32 c_rx_yellow_prio_1;
371 u32 c_rx_yellow_prio_2;
372 u32 c_rx_yellow_prio_3;
373 u32 c_rx_yellow_prio_4;
374 u32 c_rx_yellow_prio_5;
375 u32 c_rx_yellow_prio_6;
376 u32 c_rx_yellow_prio_7;
377 u32 c_rx_green_prio_0;
378 u32 c_rx_green_prio_1;
379 u32 c_rx_green_prio_2;
380 u32 c_rx_green_prio_3;
381 u32 c_rx_green_prio_4;
382 u32 c_rx_green_prio_5;
383 u32 c_rx_green_prio_6;
384 u32 c_rx_green_prio_7;
388 struct vsc9953_tx_cntrs {
400 u32 c_tx_sz_512_1023;
401 u32 c_tx_sz_1024_1526;
403 u32 c_tx_yellow_prio_0;
404 u32 c_tx_yellow_prio_1;
405 u32 c_tx_yellow_prio_2;
406 u32 c_tx_yellow_prio_3;
407 u32 c_tx_yellow_prio_4;
408 u32 c_tx_yellow_prio_5;
409 u32 c_tx_yellow_prio_6;
410 u32 c_tx_yellow_prio_7;
411 u32 c_tx_green_prio_0;
412 u32 c_tx_green_prio_1;
413 u32 c_tx_green_prio_2;
414 u32 c_tx_green_prio_3;
415 u32 c_tx_green_prio_4;
416 u32 c_tx_green_prio_5;
417 u32 c_tx_green_prio_6;
418 u32 c_tx_green_prio_7;
423 struct vsc9953_drop_cntrs {
426 u32 c_dr_yellow_prio_0;
427 u32 c_dr_yellow_prio_1;
428 u32 c_dr_yellow_prio_2;
429 u32 c_dr_yellow_prio_3;
430 u32 c_dr_yellow_prio_4;
431 u32 c_dr_yellow_prio_5;
432 u32 c_dr_yellow_prio_6;
433 u32 c_dr_yellow_prio_7;
434 u32 c_dr_green_prio_0;
435 u32 c_dr_green_prio_1;
436 u32 c_dr_green_prio_2;
437 u32 c_dr_green_prio_3;
438 u32 c_dr_green_prio_4;
439 u32 c_dr_green_prio_5;
440 u32 c_dr_green_prio_6;
441 u32 c_dr_green_prio_7;
445 struct vsc9953_sys_stat {
446 struct vsc9953_rx_cntrs rx_cntrs;
447 struct vsc9953_tx_cntrs tx_cntrs;
448 struct vsc9953_drop_cntrs drop_cntrs;
452 struct vsc9953_sys_sys {
457 u32 front_port_mode[10];
463 struct vsc9953_sys_pause_cfg {
466 u32 tail_drop_level[11];
467 u32 tot_tail_drop_lvl;
471 struct vsc9953_sys_mmgt {
475 struct vsc9953_system_reg {
476 struct vsc9953_sys_stat stat;
477 struct vsc9953_sys_sys sys;
478 struct vsc9953_sys_pause_cfg pause_cfg;
479 struct vsc9953_sys_mmgt mmgt;
482 /* END VSC9953 SYS structure */
484 /* VSC9953 REW structure */
486 struct vsc9953_rew_port {
491 u32 port_pcp_dei_qos_map_cfg[16];
495 struct vsc9953_rew_common {
497 u32 dscp_remap_dp1_cfg[64];
498 u32 dscp_remap_cfg[64];
501 struct vsc9953_rew_reg {
502 struct vsc9953_rew_port port[12];
503 struct vsc9953_rew_common common;
506 /* END VSC9953 REW structure */
508 /* VSC9953 DEVCPU_GCB structure */
510 struct vsc9953_chip_regs {
516 struct vsc9953_gpio {
517 u32 gpio_out_set[10];
518 u32 gpio_out_clr[10];
523 struct vsc9953_mii_mng {
531 u32 miiscan_lst_rslts;
532 u32 miiscan_lst_rslts_valid;
535 struct vsc9953_mii_read_scan {
536 u32 mii_scan_results_sticky[2];
539 struct vsc9953_devcpu_gcb {
540 struct vsc9953_chip_regs chip_regs;
541 struct vsc9953_gpio gpio;
542 struct vsc9953_mii_mng mii_mng[2];
543 struct vsc9953_mii_read_scan mii_read_scan;
546 /* END VSC9953 DEVCPU_GCB structure */
548 /* VSC9953 IS* structure */
550 struct vsc9953_vcap_core_cfg {
551 u32 vcap_update_ctrl;
555 struct vsc9953_vcap {
556 struct vsc9953_vcap_core_cfg vcap_core_cfg;
559 /* END VSC9953 IS* structure */
561 #define VSC9953_PORT_INFO_INITIALIZER(idx) \
567 .enet_if = PHY_INTERFACE_MODE_NONE, \
572 /* Structure to describe a VSC9953 port */
573 struct vsc9953_port_info {
578 phy_interface_t enet_if;
580 struct phy_device *phydev;
583 /* Structure to describe a VSC9953 switch */
584 struct vsc9953_info {
585 struct vsc9953_port_info port[VSC9953_MAX_PORTS];
588 void vsc9953_init(bd_t *bis);
590 void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus);
591 void vsc9953_port_info_set_phy_address(int port_no, int address);
592 void vsc9953_port_enable(int port_no);
593 void vsc9953_port_disable(int port_no);
594 void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int);
596 #endif /* _VSC9953_H_ */