1*59da9885SKrzysztof Kozlowski /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 2e4b27ebcSKurt Kanzenbach /* 3e4b27ebcSKurt Kanzenbach * DSA driver for: 4e4b27ebcSKurt Kanzenbach * Hirschmann Hellcreek TSN switch. 5e4b27ebcSKurt Kanzenbach * 624dfc6ebSKurt Kanzenbach * Copyright (C) 2019-2021 Linutronix GmbH 7e4b27ebcSKurt Kanzenbach * Author Kurt Kanzenbach <kurt@linutronix.de> 8e4b27ebcSKurt Kanzenbach */ 9e4b27ebcSKurt Kanzenbach 10e4b27ebcSKurt Kanzenbach #ifndef _HELLCREEK_H_ 11e4b27ebcSKurt Kanzenbach #define _HELLCREEK_H_ 12e4b27ebcSKurt Kanzenbach 13e4b27ebcSKurt Kanzenbach #include <linux/bitmap.h> 14e4b27ebcSKurt Kanzenbach #include <linux/bitops.h> 15e4b27ebcSKurt Kanzenbach #include <linux/device.h> 16e4b27ebcSKurt Kanzenbach #include <linux/kernel.h> 17e4b27ebcSKurt Kanzenbach #include <linux/mutex.h> 18ddd56dfeSKamil Alkhouri #include <linux/workqueue.h> 197d9ee2e8SKurt Kanzenbach #include <linux/leds.h> 20e4b27ebcSKurt Kanzenbach #include <linux/platform_data/hirschmann-hellcreek.h> 21e4b27ebcSKurt Kanzenbach #include <linux/ptp_clock_kernel.h> 22e4b27ebcSKurt Kanzenbach #include <linux/timecounter.h> 23e4b27ebcSKurt Kanzenbach #include <net/dsa.h> 2424dfc6ebSKurt Kanzenbach #include <net/pkt_sched.h> 25e4b27ebcSKurt Kanzenbach 26e4b27ebcSKurt Kanzenbach /* Ports: 27e4b27ebcSKurt Kanzenbach * - 0: CPU 28e4b27ebcSKurt Kanzenbach * - 1: Tunnel 29e4b27ebcSKurt Kanzenbach * - 2: TSN front port 1 30e4b27ebcSKurt Kanzenbach * - 3: TSN front port 2 31e4b27ebcSKurt Kanzenbach * - ... 32e4b27ebcSKurt Kanzenbach */ 33e4b27ebcSKurt Kanzenbach #define CPU_PORT 0 34e4b27ebcSKurt Kanzenbach #define TUNNEL_PORT 1 35e4b27ebcSKurt Kanzenbach 36e4b27ebcSKurt Kanzenbach #define HELLCREEK_VLAN_NO_MEMBER 0x0 37e4b27ebcSKurt Kanzenbach #define HELLCREEK_VLAN_UNTAGGED_MEMBER 0x1 38e4b27ebcSKurt Kanzenbach #define HELLCREEK_VLAN_TAGGED_MEMBER 0x3 39e4b27ebcSKurt Kanzenbach #define HELLCREEK_NUM_EGRESS_QUEUES 8 40a745c697SKurt Kanzenbach #define HELLCREEK_DEFAULT_MAX_SDU 1536 41e4b27ebcSKurt Kanzenbach 42e4b27ebcSKurt Kanzenbach /* Register definitions */ 43e4b27ebcSKurt Kanzenbach #define HR_MODID_C (0 * 2) 44e4b27ebcSKurt Kanzenbach #define HR_REL_L_C (1 * 2) 45e4b27ebcSKurt Kanzenbach #define HR_REL_H_C (2 * 2) 46e4b27ebcSKurt Kanzenbach #define HR_BLD_L_C (3 * 2) 47e4b27ebcSKurt Kanzenbach #define HR_BLD_H_C (4 * 2) 48e4b27ebcSKurt Kanzenbach #define HR_CTRL_C (5 * 2) 49e4b27ebcSKurt Kanzenbach #define HR_CTRL_C_READY BIT(14) 50e4b27ebcSKurt Kanzenbach #define HR_CTRL_C_TRANSITION BIT(13) 51e4b27ebcSKurt Kanzenbach #define HR_CTRL_C_ENABLE BIT(0) 52e4b27ebcSKurt Kanzenbach 53e4b27ebcSKurt Kanzenbach #define HR_PSEL (0xa6 * 2) 54e4b27ebcSKurt Kanzenbach #define HR_PSEL_PTWSEL_SHIFT 4 55e4b27ebcSKurt Kanzenbach #define HR_PSEL_PTWSEL_MASK GENMASK(5, 4) 56e4b27ebcSKurt Kanzenbach #define HR_PSEL_PRTCWSEL_SHIFT 0 57e4b27ebcSKurt Kanzenbach #define HR_PSEL_PRTCWSEL_MASK GENMASK(2, 0) 58e4b27ebcSKurt Kanzenbach 59e4b27ebcSKurt Kanzenbach #define HR_PTCFG (0xa7 * 2) 60e4b27ebcSKurt Kanzenbach #define HR_PTCFG_MLIMIT_EN BIT(13) 61e4b27ebcSKurt Kanzenbach #define HR_PTCFG_UMC_FLT BIT(10) 62e4b27ebcSKurt Kanzenbach #define HR_PTCFG_UUC_FLT BIT(9) 63e4b27ebcSKurt Kanzenbach #define HR_PTCFG_UNTRUST BIT(8) 64e4b27ebcSKurt Kanzenbach #define HR_PTCFG_TAG_REQUIRED BIT(7) 65e4b27ebcSKurt Kanzenbach #define HR_PTCFG_PPRIO_SHIFT 4 66e4b27ebcSKurt Kanzenbach #define HR_PTCFG_PPRIO_MASK GENMASK(6, 4) 67e4b27ebcSKurt Kanzenbach #define HR_PTCFG_INGRESSFLT BIT(3) 68e4b27ebcSKurt Kanzenbach #define HR_PTCFG_BLOCKED BIT(2) 69e4b27ebcSKurt Kanzenbach #define HR_PTCFG_LEARNING_EN BIT(1) 70e4b27ebcSKurt Kanzenbach #define HR_PTCFG_ADMIN_EN BIT(0) 71e4b27ebcSKurt Kanzenbach 72e4b27ebcSKurt Kanzenbach #define HR_PRTCCFG (0xa8 * 2) 73e4b27ebcSKurt Kanzenbach #define HR_PRTCCFG_PCP_TC_MAP_SHIFT 0 74e4b27ebcSKurt Kanzenbach #define HR_PRTCCFG_PCP_TC_MAP_MASK GENMASK(2, 0) 75e4b27ebcSKurt Kanzenbach 76a745c697SKurt Kanzenbach #define HR_PTPRTCCFG (0xa9 * 2) 77a745c697SKurt Kanzenbach #define HR_PTPRTCCFG_SET_QTRACK BIT(15) 78a745c697SKurt Kanzenbach #define HR_PTPRTCCFG_REJECT BIT(14) 79a745c697SKurt Kanzenbach #define HR_PTPRTCCFG_MAXSDU_SHIFT 0 80a745c697SKurt Kanzenbach #define HR_PTPRTCCFG_MAXSDU_MASK GENMASK(10, 0) 81a745c697SKurt Kanzenbach 82e4b27ebcSKurt Kanzenbach #define HR_CSEL (0x8d * 2) 83e4b27ebcSKurt Kanzenbach #define HR_CSEL_SHIFT 0 84e4b27ebcSKurt Kanzenbach #define HR_CSEL_MASK GENMASK(7, 0) 85e4b27ebcSKurt Kanzenbach #define HR_CRDL (0x8e * 2) 86e4b27ebcSKurt Kanzenbach #define HR_CRDH (0x8f * 2) 87e4b27ebcSKurt Kanzenbach 88e4b27ebcSKurt Kanzenbach #define HR_SWTRC_CFG (0x90 * 2) 89e4b27ebcSKurt Kanzenbach #define HR_SWTRC0 (0x91 * 2) 90e4b27ebcSKurt Kanzenbach #define HR_SWTRC1 (0x92 * 2) 91e4b27ebcSKurt Kanzenbach #define HR_PFREE (0x93 * 2) 92e4b27ebcSKurt Kanzenbach #define HR_MFREE (0x94 * 2) 93e4b27ebcSKurt Kanzenbach 94e4b27ebcSKurt Kanzenbach #define HR_FDBAGE (0x97 * 2) 95e4b27ebcSKurt Kanzenbach #define HR_FDBMAX (0x98 * 2) 96e4b27ebcSKurt Kanzenbach #define HR_FDBRDL (0x99 * 2) 97e4b27ebcSKurt Kanzenbach #define HR_FDBRDM (0x9a * 2) 98e4b27ebcSKurt Kanzenbach #define HR_FDBRDH (0x9b * 2) 99e4b27ebcSKurt Kanzenbach 100e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD (0x9c * 2) 101e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_PORTMASK_SHIFT 0 102e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_PORTMASK_MASK GENMASK(3, 0) 103e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_AGE_SHIFT 4 104e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_AGE_MASK GENMASK(7, 4) 105e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_OBT BIT(8) 106e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_PASS_BLOCKED BIT(9) 107e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_STATIC BIT(11) 108e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_REPRIO_TC_SHIFT 12 109e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_REPRIO_TC_MASK GENMASK(14, 12) 110e4b27ebcSKurt Kanzenbach #define HR_FDBMDRD_REPRIO_EN BIT(15) 111e4b27ebcSKurt Kanzenbach 112e4b27ebcSKurt Kanzenbach #define HR_FDBWDL (0x9d * 2) 113e4b27ebcSKurt Kanzenbach #define HR_FDBWDM (0x9e * 2) 114e4b27ebcSKurt Kanzenbach #define HR_FDBWDH (0x9f * 2) 115e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0 (0xa0 * 2) 116e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_PORTMASK_SHIFT 0 117e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_PORTMASK_MASK GENMASK(3, 0) 118e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_OBT BIT(8) 119e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_PASS_BLOCKED BIT(9) 120e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_REPRIO_TC_SHIFT 12 121e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_REPRIO_TC_MASK GENMASK(14, 12) 122e4b27ebcSKurt Kanzenbach #define HR_FDBWRM0_REPRIO_EN BIT(15) 123e4b27ebcSKurt Kanzenbach #define HR_FDBWRM1 (0xa1 * 2) 124e4b27ebcSKurt Kanzenbach 125e4b27ebcSKurt Kanzenbach #define HR_FDBWRCMD (0xa2 * 2) 126e4b27ebcSKurt Kanzenbach #define HR_FDBWRCMD_FDBDEL BIT(9) 127e4b27ebcSKurt Kanzenbach 128e4b27ebcSKurt Kanzenbach #define HR_SWCFG (0xa3 * 2) 129e4b27ebcSKurt Kanzenbach #define HR_SWCFG_GM_STATEMD BIT(15) 130e4b27ebcSKurt Kanzenbach #define HR_SWCFG_LAS_MODE_SHIFT 12 131e4b27ebcSKurt Kanzenbach #define HR_SWCFG_LAS_MODE_MASK GENMASK(13, 12) 132e4b27ebcSKurt Kanzenbach #define HR_SWCFG_LAS_OFF (0x00) 133e4b27ebcSKurt Kanzenbach #define HR_SWCFG_LAS_ON (0x01) 134e4b27ebcSKurt Kanzenbach #define HR_SWCFG_LAS_STATIC (0x10) 135e4b27ebcSKurt Kanzenbach #define HR_SWCFG_CT_EN BIT(11) 136e4b27ebcSKurt Kanzenbach #define HR_SWCFG_VLAN_UNAWARE BIT(10) 137e4b27ebcSKurt Kanzenbach #define HR_SWCFG_ALWAYS_OBT BIT(9) 138e4b27ebcSKurt Kanzenbach #define HR_SWCFG_FDBAGE_EN BIT(5) 139e4b27ebcSKurt Kanzenbach #define HR_SWCFG_FDBLRN_EN BIT(4) 140e4b27ebcSKurt Kanzenbach 141e4b27ebcSKurt Kanzenbach #define HR_SWSTAT (0xa4 * 2) 142e4b27ebcSKurt Kanzenbach #define HR_SWSTAT_FAIL BIT(4) 143e4b27ebcSKurt Kanzenbach #define HR_SWSTAT_BUSY BIT(0) 144e4b27ebcSKurt Kanzenbach 145e4b27ebcSKurt Kanzenbach #define HR_SWCMD (0xa5 * 2) 146e4b27ebcSKurt Kanzenbach #define HW_SWCMD_FLUSH BIT(0) 147e4b27ebcSKurt Kanzenbach 148e4b27ebcSKurt Kanzenbach #define HR_VIDCFG (0xaa * 2) 149e4b27ebcSKurt Kanzenbach #define HR_VIDCFG_VID_SHIFT 0 150e4b27ebcSKurt Kanzenbach #define HR_VIDCFG_VID_MASK GENMASK(11, 0) 151e4b27ebcSKurt Kanzenbach #define HR_VIDCFG_PVID BIT(12) 152e4b27ebcSKurt Kanzenbach 153e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG (0xab * 2) 154e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P0MBR_SHIFT 0 155e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P0MBR_MASK GENMASK(1, 0) 156e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P1MBR_SHIFT 2 157e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P1MBR_MASK GENMASK(3, 2) 158e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P2MBR_SHIFT 4 159e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P2MBR_MASK GENMASK(5, 4) 160e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P3MBR_SHIFT 6 161e4b27ebcSKurt Kanzenbach #define HR_VIDMBRCFG_P3MBR_MASK GENMASK(7, 6) 162e4b27ebcSKurt Kanzenbach 163e4b27ebcSKurt Kanzenbach #define HR_FEABITS0 (0xac * 2) 164e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_FDBBINS_SHIFT 4 165e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_FDBBINS_MASK GENMASK(7, 4) 166e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_PCNT_SHIFT 8 167e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_PCNT_MASK GENMASK(11, 8) 168e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_MCNT_SHIFT 12 169e4b27ebcSKurt Kanzenbach #define HR_FEABITS0_MCNT_MASK GENMASK(15, 12) 170e4b27ebcSKurt Kanzenbach 171e4b27ebcSKurt Kanzenbach #define TR_QTRACK (0xb1 * 2) 172e4b27ebcSKurt Kanzenbach #define TR_TGDVER (0xb3 * 2) 173e4b27ebcSKurt Kanzenbach #define TR_TGDVER_REV_MIN_MASK GENMASK(7, 0) 174e4b27ebcSKurt Kanzenbach #define TR_TGDVER_REV_MIN_SHIFT 0 175e4b27ebcSKurt Kanzenbach #define TR_TGDVER_REV_MAJ_MASK GENMASK(15, 8) 176e4b27ebcSKurt Kanzenbach #define TR_TGDVER_REV_MAJ_SHIFT 8 177e4b27ebcSKurt Kanzenbach #define TR_TGDSEL (0xb4 * 2) 178e4b27ebcSKurt Kanzenbach #define TR_TGDSEL_TDGSEL_MASK GENMASK(1, 0) 179e4b27ebcSKurt Kanzenbach #define TR_TGDSEL_TDGSEL_SHIFT 0 180e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL (0xb5 * 2) 181e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL_GATE_EN BIT(0) 182e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL_CYC_SNAP BIT(4) 183e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL_SNAP_EST BIT(5) 184e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL_ADMINGATESTATES_MASK GENMASK(15, 8) 185e4b27ebcSKurt Kanzenbach #define TR_TGDCTRL_ADMINGATESTATES_SHIFT 8 186e4b27ebcSKurt Kanzenbach #define TR_TGDSTAT0 (0xb6 * 2) 187e4b27ebcSKurt Kanzenbach #define TR_TGDSTAT1 (0xb7 * 2) 188e4b27ebcSKurt Kanzenbach #define TR_ESTWRL (0xb8 * 2) 189e4b27ebcSKurt Kanzenbach #define TR_ESTWRH (0xb9 * 2) 190e4b27ebcSKurt Kanzenbach #define TR_ESTCMD (0xba * 2) 191e4b27ebcSKurt Kanzenbach #define TR_ESTCMD_ESTSEC_MASK GENMASK(2, 0) 192e4b27ebcSKurt Kanzenbach #define TR_ESTCMD_ESTSEC_SHIFT 0 193e4b27ebcSKurt Kanzenbach #define TR_ESTCMD_ESTARM BIT(4) 194e4b27ebcSKurt Kanzenbach #define TR_ESTCMD_ESTSWCFG BIT(5) 195e4b27ebcSKurt Kanzenbach #define TR_EETWRL (0xbb * 2) 196e4b27ebcSKurt Kanzenbach #define TR_EETWRH (0xbc * 2) 197e4b27ebcSKurt Kanzenbach #define TR_EETCMD (0xbd * 2) 198e4b27ebcSKurt Kanzenbach #define TR_EETCMD_EETSEC_MASK GEMASK(2, 0) 199e4b27ebcSKurt Kanzenbach #define TR_EETCMD_EETSEC_SHIFT 0 200e4b27ebcSKurt Kanzenbach #define TR_EETCMD_EETARM BIT(4) 201e4b27ebcSKurt Kanzenbach #define TR_CTWRL (0xbe * 2) 202e4b27ebcSKurt Kanzenbach #define TR_CTWRH (0xbf * 2) 203e4b27ebcSKurt Kanzenbach #define TR_LCNSL (0xc1 * 2) 204e4b27ebcSKurt Kanzenbach #define TR_LCNSH (0xc2 * 2) 205e4b27ebcSKurt Kanzenbach #define TR_LCS (0xc3 * 2) 206e4b27ebcSKurt Kanzenbach #define TR_GCLDAT (0xc4 * 2) 207e4b27ebcSKurt Kanzenbach #define TR_GCLDAT_GCLWRGATES_MASK GENMASK(7, 0) 208e4b27ebcSKurt Kanzenbach #define TR_GCLDAT_GCLWRGATES_SHIFT 0 209e4b27ebcSKurt Kanzenbach #define TR_GCLDAT_GCLWRLAST BIT(8) 210e4b27ebcSKurt Kanzenbach #define TR_GCLDAT_GCLOVRI BIT(9) 211e4b27ebcSKurt Kanzenbach #define TR_GCLTIL (0xc5 * 2) 212e4b27ebcSKurt Kanzenbach #define TR_GCLTIH (0xc6 * 2) 213e4b27ebcSKurt Kanzenbach #define TR_GCLCMD (0xc7 * 2) 214e4b27ebcSKurt Kanzenbach #define TR_GCLCMD_GCLWRADR_MASK GENMASK(7, 0) 215e4b27ebcSKurt Kanzenbach #define TR_GCLCMD_GCLWRADR_SHIFT 0 216e4b27ebcSKurt Kanzenbach #define TR_GCLCMD_INIT_GATE_STATES_MASK GENMASK(15, 8) 217e4b27ebcSKurt Kanzenbach #define TR_GCLCMD_INIT_GATE_STATES_SHIFT 8 218e4b27ebcSKurt Kanzenbach 219e4b27ebcSKurt Kanzenbach struct hellcreek_counter { 220e4b27ebcSKurt Kanzenbach u8 offset; 221e4b27ebcSKurt Kanzenbach const char *name; 222e4b27ebcSKurt Kanzenbach }; 223e4b27ebcSKurt Kanzenbach 224e4b27ebcSKurt Kanzenbach struct hellcreek; 225e4b27ebcSKurt Kanzenbach 226f0d4ba9eSKamil Alkhouri /* State flags for hellcreek_port_hwtstamp::state */ 227f0d4ba9eSKamil Alkhouri enum { 228f0d4ba9eSKamil Alkhouri HELLCREEK_HWTSTAMP_ENABLED, 229f0d4ba9eSKamil Alkhouri HELLCREEK_HWTSTAMP_TX_IN_PROGRESS, 230f0d4ba9eSKamil Alkhouri }; 231f0d4ba9eSKamil Alkhouri 232f0d4ba9eSKamil Alkhouri /* A structure to hold hardware timestamping information per port */ 233f0d4ba9eSKamil Alkhouri struct hellcreek_port_hwtstamp { 234f0d4ba9eSKamil Alkhouri /* Timestamping state */ 235f0d4ba9eSKamil Alkhouri unsigned long state; 236f0d4ba9eSKamil Alkhouri 237f0d4ba9eSKamil Alkhouri /* Resources for receive timestamping */ 238f0d4ba9eSKamil Alkhouri struct sk_buff_head rx_queue; /* For synchronization messages */ 239f0d4ba9eSKamil Alkhouri 240f0d4ba9eSKamil Alkhouri /* Resources for transmit timestamping */ 241f0d4ba9eSKamil Alkhouri unsigned long tx_tstamp_start; 242f0d4ba9eSKamil Alkhouri struct sk_buff *tx_skb; 243f0d4ba9eSKamil Alkhouri 244f0d4ba9eSKamil Alkhouri /* Current timestamp configuration */ 245f0d4ba9eSKamil Alkhouri struct hwtstamp_config tstamp_config; 246f0d4ba9eSKamil Alkhouri }; 247f0d4ba9eSKamil Alkhouri 248e4b27ebcSKurt Kanzenbach struct hellcreek_port { 249e4b27ebcSKurt Kanzenbach struct hellcreek *hellcreek; 250e4b27ebcSKurt Kanzenbach unsigned long *vlan_dev_bitmap; 251e4b27ebcSKurt Kanzenbach int port; 252e4b27ebcSKurt Kanzenbach u16 ptcfg; /* ptcfg shadow */ 253e4b27ebcSKurt Kanzenbach u64 *counter_values; 254f0d4ba9eSKamil Alkhouri 255f0d4ba9eSKamil Alkhouri /* Per-port timestamping resources */ 256f0d4ba9eSKamil Alkhouri struct hellcreek_port_hwtstamp port_hwtstamp; 25724dfc6ebSKurt Kanzenbach 25824dfc6ebSKurt Kanzenbach /* Per-port Qbv schedule information */ 25924dfc6ebSKurt Kanzenbach struct tc_taprio_qopt_offload *current_schedule; 26024dfc6ebSKurt Kanzenbach struct delayed_work schedule_work; 261e4b27ebcSKurt Kanzenbach }; 262e4b27ebcSKurt Kanzenbach 263e4b27ebcSKurt Kanzenbach struct hellcreek_fdb_entry { 264e4b27ebcSKurt Kanzenbach size_t idx; 265e4b27ebcSKurt Kanzenbach unsigned char mac[ETH_ALEN]; 266e4b27ebcSKurt Kanzenbach u8 portmask; 267e4b27ebcSKurt Kanzenbach u8 age; 268e4b27ebcSKurt Kanzenbach u8 is_obt; 269e4b27ebcSKurt Kanzenbach u8 pass_blocked; 270e4b27ebcSKurt Kanzenbach u8 is_static; 271e4b27ebcSKurt Kanzenbach u8 reprio_tc; 272e4b27ebcSKurt Kanzenbach u8 reprio_en; 273e4b27ebcSKurt Kanzenbach }; 274e4b27ebcSKurt Kanzenbach 275e4b27ebcSKurt Kanzenbach struct hellcreek { 276e4b27ebcSKurt Kanzenbach const struct hellcreek_platform_data *pdata; 277e4b27ebcSKurt Kanzenbach struct device *dev; 278e4b27ebcSKurt Kanzenbach struct dsa_switch *ds; 279ddd56dfeSKamil Alkhouri struct ptp_clock *ptp_clock; 280ddd56dfeSKamil Alkhouri struct ptp_clock_info ptp_clock_info; 281e4b27ebcSKurt Kanzenbach struct hellcreek_port *ports; 282ddd56dfeSKamil Alkhouri struct delayed_work overflow_work; 2837d9ee2e8SKurt Kanzenbach struct led_classdev led_is_gm; 2847d9ee2e8SKurt Kanzenbach struct led_classdev led_sync_good; 285e4b27ebcSKurt Kanzenbach struct mutex reg_lock; /* Switch IP register lock */ 286e4b27ebcSKurt Kanzenbach struct mutex vlan_lock; /* VLAN bitmaps lock */ 287ddd56dfeSKamil Alkhouri struct mutex ptp_lock; /* PTP IP register lock */ 288ba2d1c28SKurt Kanzenbach struct devlink_region *vlan_region; 289292cd449SKurt Kanzenbach struct devlink_region *fdb_region; 290e4b27ebcSKurt Kanzenbach void __iomem *base; 291ddd56dfeSKamil Alkhouri void __iomem *ptp_base; 292e4b27ebcSKurt Kanzenbach u16 swcfg; /* swcfg shadow */ 293e4b27ebcSKurt Kanzenbach u8 *vidmbrcfg; /* vidmbrcfg shadow */ 294ddd56dfeSKamil Alkhouri u64 seconds; /* PTP seconds */ 295ddd56dfeSKamil Alkhouri u64 last_ts; /* Used for overflow detection */ 2967d9ee2e8SKurt Kanzenbach u16 status_out; /* ptp.status_out shadow */ 297e4b27ebcSKurt Kanzenbach size_t fdb_entries; 298e4b27ebcSKurt Kanzenbach }; 299e4b27ebcSKurt Kanzenbach 30024dfc6ebSKurt Kanzenbach /* A Qbv schedule can only started up to 8 seconds in the future. If the delta 30124dfc6ebSKurt Kanzenbach * between the base time and the current ptp time is larger than 8 seconds, then 30224dfc6ebSKurt Kanzenbach * use periodic work to check for the schedule to be started. The delayed work 30324dfc6ebSKurt Kanzenbach * cannot be armed directly to $base_time - 8 + X, because for large deltas the 30424dfc6ebSKurt Kanzenbach * PTP frequency matters. 30524dfc6ebSKurt Kanzenbach */ 30624dfc6ebSKurt Kanzenbach #define HELLCREEK_SCHEDULE_PERIOD (2 * HZ) 30724dfc6ebSKurt Kanzenbach #define dw_to_hellcreek_port(dw) \ 30824dfc6ebSKurt Kanzenbach container_of(dw, struct hellcreek_port, schedule_work) 30924dfc6ebSKurt Kanzenbach 3107f976d5cSKurt Kanzenbach /* Devlink resources */ 3117f976d5cSKurt Kanzenbach enum hellcreek_devlink_resource_id { 3127f976d5cSKurt Kanzenbach HELLCREEK_DEVLINK_PARAM_ID_VLAN_TABLE, 3138486e83fSKurt Kanzenbach HELLCREEK_DEVLINK_PARAM_ID_FDB_TABLE, 3147f976d5cSKurt Kanzenbach }; 3157f976d5cSKurt Kanzenbach 316ba2d1c28SKurt Kanzenbach struct hellcreek_devlink_vlan_entry { 317ba2d1c28SKurt Kanzenbach u16 vid; 318ba2d1c28SKurt Kanzenbach u16 member; 319ba2d1c28SKurt Kanzenbach }; 320ba2d1c28SKurt Kanzenbach 321e4b27ebcSKurt Kanzenbach #endif /* _HELLCREEK_H_ */ 322