// SPDX-License-Identifier: GPL-2.0/* Realtek SMI subdriver for the Realtek RTL8366RB ethernet switch * * This is a sparsely documented chip, the only viable documentation seems * to be a patched up code drop from the vendor that appear in various * GPL source trees. * * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2010 Antti Seppälä <a.seppala@gmail.com> * Copyright (C) 2010 Roman Yeryomin <roman@advem.lv> * Copyright (C) 2011 Colin Leitner <colin.leitner@googlemail.com> */#include<linux/bitops.h>#include<linux/etherdevice.h>#include<linux/interrupt.h>#include<linux/irqdomain.h>#include<linux/irqchip/chained_irq.h>#include<linux/of_irq.h>#include<linux/regmap.h>#include"realtek-smi-core.h"#define RTL8366RB_PORT_NUM_CPU 5#define RTL8366RB_NUM_PORTS 6#define RTL8366RB_PHY_NO_MAX 4#define RTL8366RB_PHY_ADDR_MAX 31/* Switch Global Configuration register */#define RTL8366RB_SGCR 0x0000#define RTL8366RB_SGCR_EN_BC_STORM_CTRL BIT(0)#define RTL8366RB_SGCR_MAX_LENGTH(a) ((a) << 4)#define RTL8366RB_SGCR_MAX_LENGTH_MASK RTL8366RB_SGCR_MAX_LENGTH(0x3)#define RTL8366RB_SGCR_MAX_LENGTH_1522 RTL8366RB_SGCR_MAX_LENGTH(0x0)#define RTL8366RB_SGCR_MAX_LENGTH_1536 RTL8366RB_SGCR_MAX_LENGTH(0x1)#define RTL8366RB_SGCR_MAX_LENGTH_1552 RTL8366RB_SGCR_MAX_LENGTH(0x2)#define RTL8366RB_SGCR_MAX_LENGTH_16000 RTL8366RB_SGCR_MAX_LENGTH(0x3)#define RTL8366RB_SGCR_EN_VLAN BIT(13)#define RTL8366RB_SGCR_EN_VLAN_4KTB BIT(14)/* Port Enable Control re