#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/interrupt.h>
#include <linux/irqdomain.h>
#include <linux/mutex.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
#include <linux/if_bridge.h>
#include <linux/if_vlan.h>
#include "realtek.h"
#include "realtek-smi.h"
#include "realtek-mdio.h"
#include "rtl83xx.h"
#define RTL8365MB_PHYADDRMAX …
#define RTL8365MB_NUM_PHYREGS …
#define RTL8365MB_PHYREGMAX …
#define RTL8365MB_MAX_NUM_PORTS …
#define RTL8365MB_MAX_NUM_EXTINTS …
#define RTL8365MB_LEARN_LIMIT_MAX …
#define RTL8365MB_CHIP_ID_REG …
#define RTL8365MB_CHIP_VER_REG …
#define RTL8365MB_MAGIC_REG …
#define RTL8365MB_MAGIC_VALUE …
#define RTL8365MB_CHIP_RESET_REG …
#define RTL8365MB_CHIP_RESET_SW_MASK …
#define RTL8365MB_CHIP_RESET_HW_MASK …
#define RTL8365MB_INTR_POLARITY_REG …
#define RTL8365MB_INTR_POLARITY_MASK …
#define RTL8365MB_INTR_POLARITY_HIGH …
#define RTL8365MB_INTR_POLARITY_LOW …
#define RTL8365MB_INTR_CTRL_REG …
#define RTL8365MB_INTR_STATUS_REG …
#define RTL8365MB_INTR_SLIENT_START_2_MASK …
#define RTL8365MB_INTR_SLIENT_START_MASK …
#define RTL8365MB_INTR_ACL_ACTION_MASK …
#define RTL8365MB_INTR_CABLE_DIAG_FIN_MASK …
#define RTL8365MB_INTR_INTERRUPT_8051_MASK …
#define RTL8365MB_INTR_LOOP_DETECTION_MASK …
#define RTL8365MB_INTR_GREEN_TIMER_MASK …
#define RTL8365MB_INTR_SPECIAL_CONGEST_MASK …
#define RTL8365MB_INTR_SPEED_CHANGE_MASK …
#define RTL8365MB_INTR_LEARN_OVER_MASK …
#define RTL8365MB_INTR_METER_EXCEEDED_MASK …
#define RTL8365MB_INTR_LINK_CHANGE_MASK …
#define RTL8365MB_INTR_ALL_MASK …
#define RTL8365MB_PORT_LINKDOWN_IND_REG …
#define RTL8365MB_PORT_LINKDOWN_IND_MASK …
#define RTL8365MB_PORT_LINKUP_IND_REG …
#define RTL8365MB_PORT_LINKUP_IND_MASK …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_REG …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_RW_MASK …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_RW_READ …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_RW_WRITE …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_CMD_MASK …
#define RTL8365MB_INDIRECT_ACCESS_CTRL_CMD_VALUE …
#define RTL8365MB_INDIRECT_ACCESS_STATUS_REG …
#define RTL8365MB_INDIRECT_ACCESS_ADDRESS_REG …
#define RTL8365MB_INDIRECT_ACCESS_ADDRESS_OCPADR_5_1_MASK …
#define RTL8365MB_INDIRECT_ACCESS_ADDRESS_PHYNUM_MASK …
#define RTL8365MB_INDIRECT_ACCESS_ADDRESS_OCPADR_9_6_MASK …
#define RTL8365MB_PHY_BASE …
#define RTL8365MB_INDIRECT_ACCESS_WRITE_DATA_REG …
#define RTL8365MB_INDIRECT_ACCESS_READ_DATA_REG …
#define RTL8365MB_GPHY_OCP_MSB_0_REG …
#define RTL8365MB_GPHY_OCP_MSB_0_CFG_CPU_OCPADR_MASK …
#define RTL8365MB_PHY_OCP_ADDR_PREFIX_MASK …
#define RTL8365MB_PHY_OCP_ADDR_PHYREG_BASE …
#define RTL8365MB_EXT_PORT_MODE_DISABLE …
#define RTL8365MB_EXT_PORT_MODE_RGMII …
#define RTL8365MB_EXT_PORT_MODE_MII_MAC …
#define RTL8365MB_EXT_PORT_MODE_MII_PHY …
#define RTL8365MB_EXT_PORT_MODE_TMII_MAC …
#define RTL8365MB_EXT_PORT_MODE_TMII_PHY …
#define RTL8365MB_EXT_PORT_MODE_GMII …
#define RTL8365MB_EXT_PORT_MODE_RMII_MAC …
#define RTL8365MB_EXT_PORT_MODE_RMII_PHY …
#define RTL8365MB_EXT_PORT_MODE_SGMII …
#define RTL8365MB_EXT_PORT_MODE_HSGMII …
#define RTL8365MB_EXT_PORT_MODE_1000X_100FX …
#define RTL8365MB_EXT_PORT_MODE_1000X …
#define RTL8365MB_EXT_PORT_MODE_100FX …
#define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG0 …
#define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG1 …
#define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(_extint) …
#define RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(_extint) …
#define RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(_extint) …
#define RTL8365MB_EXT_RGMXF_REG0 …
#define RTL8365MB_EXT_RGMXF_REG1 …
#define RTL8365MB_EXT_RGMXF_REG2 …
#define RTL8365MB_EXT_RGMXF_REG(_extint) …
#define RTL8365MB_EXT_RGMXF_RXDELAY_MASK …
#define RTL8365MB_EXT_RGMXF_TXDELAY_MASK …
#define RTL8365MB_PORT_SPEED_10M …
#define RTL8365MB_PORT_SPEED_100M …
#define RTL8365MB_PORT_SPEED_1000M …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG0 …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG1 …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG2 …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(_extint) …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_EN_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_NWAY_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_TXPAUSE_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_RXPAUSE_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_LINK_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_DUPLEX_MASK …
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK …
#define RTL8365MB_CPU_PORT_MASK_REG …
#define RTL8365MB_CPU_PORT_MASK_MASK …
#define RTL8365MB_CPU_CTRL_REG …
#define RTL8365MB_CPU_CTRL_TRAP_PORT_EXT_MASK …
#define RTL8365MB_CPU_CTRL_TAG_FORMAT_MASK …
#define RTL8365MB_CPU_CTRL_RXBYTECOUNT_MASK …
#define RTL8365MB_CPU_CTRL_TAG_POSITION_MASK …
#define RTL8365MB_CPU_CTRL_TRAP_PORT_MASK …
#define RTL8365MB_CPU_CTRL_INSERTMODE_MASK …
#define RTL8365MB_CPU_CTRL_EN_MASK …
#define RTL8365MB_CFG0_MAX_LEN_REG …
#define RTL8365MB_CFG0_MAX_LEN_MASK …
#define RTL8365MB_CFG0_MAX_LEN_MAX …
#define RTL8365MB_LUT_PORT_LEARN_LIMIT_BASE …
#define RTL8365MB_LUT_PORT_LEARN_LIMIT_REG(_physport) …
#define RTL8365MB_PORT_ISOLATION_REG_BASE …
#define RTL8365MB_PORT_ISOLATION_REG(_physport) …
#define RTL8365MB_PORT_ISOLATION_MASK …
#define RTL8365MB_MSTI_CTRL_BASE …
#define RTL8365MB_MSTI_CTRL_REG(_msti, _physport) …
#define RTL8365MB_MSTI_CTRL_PORT_STATE_OFFSET(_physport) …
#define RTL8365MB_MSTI_CTRL_PORT_STATE_MASK(_physport) …
#define RTL8365MB_MIB_COUNTER_BASE …
#define RTL8365MB_MIB_COUNTER_REG(_x) …
#define RTL8365MB_MIB_ADDRESS_REG …
#define RTL8365MB_MIB_ADDRESS_PORT_OFFSET …
#define RTL8365MB_MIB_ADDRESS(_p, _x) …
#define RTL8365MB_MIB_CTRL0_REG …
#define RTL8365MB_MIB_CTRL0_RESET_MASK …
#define RTL8365MB_MIB_CTRL0_BUSY_MASK …
#define RTL8365MB_STATS_INTERVAL_JIFFIES …
enum rtl8365mb_mib_counter_index { … };
struct rtl8365mb_mib_counter { … };
#define RTL8365MB_MAKE_MIB_COUNTER(_offset, _length, _name) …
static struct rtl8365mb_mib_counter rtl8365mb_mib_counters[] = …;
static_assert(…);
struct rtl8365mb_jam_tbl_entry { … };
static const struct rtl8365mb_jam_tbl_entry rtl8365mb_init_jam_8365mb_vc[] = …;
static const struct rtl8365mb_jam_tbl_entry rtl8365mb_init_jam_common[] = …;
enum rtl8365mb_phy_interface_mode { … };
struct rtl8365mb_extint { … };
struct rtl8365mb_chip_info { … };
#define PHY_INTF(_mode) …
static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = …;
enum rtl8365mb_stp_state { … };
enum rtl8365mb_cpu_insert { … };
enum rtl8365mb_cpu_position { … };
enum rtl8365mb_cpu_format { … };
enum rtl8365mb_cpu_rxlen { … };
struct rtl8365mb_cpu { … };
struct rtl8365mb_port { … };
struct rtl8365mb { … };
static int rtl8365mb_phy_poll_busy(struct realtek_priv *priv)
{ … }
static int rtl8365mb_phy_ocp_prepare(struct realtek_priv *priv, int phy,
u32 ocp_addr)
{ … }
static int rtl8365mb_phy_ocp_read(struct realtek_priv *priv, int phy,
u32 ocp_addr, u16 *data)
{ … }
static int rtl8365mb_phy_ocp_write(struct realtek_priv *priv, int phy,
u32 ocp_addr, u16 data)
{ … }
static int rtl8365mb_phy_read(struct realtek_priv *priv, int phy, int regnum)
{ … }
static int rtl8365mb_phy_write(struct realtek_priv *priv, int phy, int regnum,
u16 val)
{ … }
static const struct rtl8365mb_extint *
rtl8365mb_get_port_extint(struct realtek_priv *priv, int port)
{ … }
static enum dsa_tag_protocol
rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int port,
enum dsa_tag_protocol mp)
{ … }
static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
phy_interface_t interface)
{ … }
static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,
bool link, int speed, int duplex,
bool tx_pause, bool rx_pause)
{ … }
static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{ … }
static void rtl8365mb_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
{ … }
static void rtl8365mb_phylink_mac_link_down(struct phylink_config *config,
unsigned int mode,
phy_interface_t interface)
{ … }
static void rtl8365mb_phylink_mac_link_up(struct phylink_config *config,
struct phy_device *phydev,
unsigned int mode,
phy_interface_t interface,
int speed, int duplex, bool tx_pause,
bool rx_pause)
{ … }
static int rtl8365mb_port_change_mtu(struct dsa_switch *ds, int port,
int new_mtu)
{ … }
static int rtl8365mb_port_max_mtu(struct dsa_switch *ds, int port)
{ … }
static void rtl8365mb_port_stp_state_set(struct dsa_switch *ds, int port,
u8 state)
{ … }
static int rtl8365mb_port_set_learning(struct realtek_priv *priv, int port,
bool enable)
{ … }
static int rtl8365mb_port_set_isolation(struct realtek_priv *priv, int port,
u32 mask)
{ … }
static int rtl8365mb_mib_counter_read(struct realtek_priv *priv, int port,
u32 offset, u32 length, u64 *mibvalue)
{ … }
static void rtl8365mb_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data)
{ … }
static void rtl8365mb_get_strings(struct dsa_switch *ds, int port, u32 stringset, u8 *data)
{ … }
static int rtl8365mb_get_sset_count(struct dsa_switch *ds, int port, int sset)
{ … }
static void rtl8365mb_get_phy_stats(struct dsa_switch *ds, int port,
struct ethtool_eth_phy_stats *phy_stats)
{ … }
static void rtl8365mb_get_mac_stats(struct dsa_switch *ds, int port,
struct ethtool_eth_mac_stats *mac_stats)
{ … }
static void rtl8365mb_get_ctrl_stats(struct dsa_switch *ds, int port,
struct ethtool_eth_ctrl_stats *ctrl_stats)
{ … }
static void rtl8365mb_stats_update(struct realtek_priv *priv, int port)
{ … }
static void rtl8365mb_stats_poll(struct work_struct *work)
{ … }
static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port,
struct rtnl_link_stats64 *s)
{ … }
static void rtl8365mb_stats_setup(struct realtek_priv *priv)
{ … }
static void rtl8365mb_stats_teardown(struct realtek_priv *priv)
{ … }
static int rtl8365mb_get_and_clear_status_reg(struct realtek_priv *priv, u32 reg,
u32 *val)
{ … }
static irqreturn_t rtl8365mb_irq(int irq, void *data)
{ … }
static struct irq_chip rtl8365mb_irq_chip = …;
static int rtl8365mb_irq_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq)
{ … }
static void rtl8365mb_irq_unmap(struct irq_domain *d, unsigned int irq)
{ … }
static const struct irq_domain_ops rtl8365mb_irqdomain_ops = …;
static int rtl8365mb_set_irq_enable(struct realtek_priv *priv, bool enable)
{ … }
static int rtl8365mb_irq_enable(struct realtek_priv *priv)
{ … }
static int rtl8365mb_irq_disable(struct realtek_priv *priv)
{ … }
static int rtl8365mb_irq_setup(struct realtek_priv *priv)
{ … }
static void rtl8365mb_irq_teardown(struct realtek_priv *priv)
{ … }
static int rtl8365mb_cpu_config(struct realtek_priv *priv)
{ … }
static int rtl8365mb_change_tag_protocol(struct dsa_switch *ds,
enum dsa_tag_protocol proto)
{ … }
static int rtl8365mb_switch_init(struct realtek_priv *priv)
{ … }
static int rtl8365mb_reset_chip(struct realtek_priv *priv)
{ … }
static int rtl8365mb_setup(struct dsa_switch *ds)
{ … }
static void rtl8365mb_teardown(struct dsa_switch *ds)
{ … }
static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver)
{ … }
static int rtl8365mb_detect(struct realtek_priv *priv)
{ … }
static const struct phylink_mac_ops rtl8365mb_phylink_mac_ops = …;
static const struct dsa_switch_ops rtl8365mb_switch_ops = …;
static const struct realtek_ops rtl8365mb_ops = …;
const struct realtek_variant rtl8365mb_variant = …;
static const struct of_device_id rtl8365mb_of_match[] = …;
MODULE_DEVICE_TABLE(of, rtl8365mb_of_match);
static struct platform_driver rtl8365mb_smi_driver = …;
static struct mdio_driver rtl8365mb_mdio_driver = …;
static int rtl8365mb_init(void)
{ … }
module_init(…) …;
static void __exit rtl8365mb_exit(void)
{ … }
module_exit(rtl8365mb_exit);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_IMPORT_NS(…);