1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
3 * Microsemi Ocelot Switch driver
5 * Copyright (c) 2017 Microsemi Corporation
8 #ifndef _MSCC_OCELOT_H_
9 #define _MSCC_OCELOT_H_
11 #include <linux/bitops.h>
12 #include <linux/etherdevice.h>
13 #include <linux/if_vlan.h>
14 #include <linux/net_tstamp.h>
15 #include <linux/phy.h>
16 #include <linux/phy/phy.h>
17 #include <linux/platform_device.h>
18 #include <linux/ptp_clock_kernel.h>
19 #include <linux/regmap.h>
21 #include <soc/mscc/ocelot_sys.h>
22 #include <soc/mscc/ocelot.h>
23 #include "ocelot_ana.h"
24 #include "ocelot_dev.h"
25 #include "ocelot_qsys.h"
26 #include "ocelot_rew.h"
27 #include "ocelot_qs.h"
28 #include "ocelot_tc.h"
29 #include "ocelot_ptp.h"
35 #define PGID_CPU (PGID_AGGR - 5)
36 #define PGID_UC (PGID_AGGR - 4)
37 #define PGID_MC (PGID_AGGR - 3)
38 #define PGID_MCIPV4 (PGID_AGGR - 2)
39 #define PGID_MCIPV6 (PGID_AGGR - 1)
41 #define OCELOT_BUFFER_CELL_SZ 60
43 #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
45 #define OCELOT_PTP_QUEUE_SZ 128
53 u32 timestamp; /* rew_val */
56 struct ocelot_multicast {
57 struct list_head list;
58 unsigned char addr[ETH_ALEN];
63 struct ocelot_port_private {
64 struct ocelot_port port;
65 struct net_device *dev;
66 struct phy_device *phy;
71 phy_interface_t phy_mode;
74 struct ocelot_port_tc tc;
77 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
78 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
80 #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
81 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
83 int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops);
84 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
86 struct phy_device *phy);
88 void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
89 enum ocelot_tag_prefix injection,
90 enum ocelot_tag_prefix extraction);
92 extern struct notifier_block ocelot_netdevice_nb;
93 extern struct notifier_block ocelot_switchdev_nb;
94 extern struct notifier_block ocelot_switchdev_blocking_nb;
96 #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
97 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))