linux/drivers/net/ethernet/adi/adin1110.c

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
/* ADIN1110 Low Power 10BASE-T1L Ethernet MAC-PHY
 * ADIN2111 2-Port Ethernet Switch with Integrated 10BASE-T1L PHY
 *
 * Copyright 2021 Analog Devices Inc.
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/cache.h>
#include <linux/crc8.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/gpio/consumer.h>
#include <linux/if_bridge.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/regulator/consumer.h>
#include <linux/phy.h>
#include <linux/property.h>
#include <linux/spi/spi.h>

#include <net/switchdev.h>

#include <asm/unaligned.h>

#define ADIN1110_PHY_ID

#define ADIN1110_RESET
#define ADIN1110_SWRESET

#define ADIN1110_CONFIG1
#define ADIN1110_CONFIG1_SYNC

#define ADIN1110_CONFIG2
#define ADIN2111_P2_FWD_UNK2HOST
#define ADIN2111_PORT_CUT_THRU_EN
#define ADIN1110_CRC_APPEND
#define ADIN1110_FWD_UNK2HOST

#define ADIN1110_STATUS0

#define ADIN1110_STATUS1
#define ADIN2111_P2_RX_RDY
#define ADIN1110_SPI_ERR
#define ADIN1110_RX_RDY

#define ADIN1110_IMASK1
#define ADIN2111_RX_RDY_IRQ
#define ADIN1110_SPI_ERR_IRQ
#define ADIN1110_RX_RDY_IRQ
#define ADIN1110_TX_RDY_IRQ

#define ADIN1110_MDIOACC
#define ADIN1110_MDIO_TRDONE
#define ADIN1110_MDIO_ST
#define ADIN1110_MDIO_OP
#define ADIN1110_MDIO_PRTAD
#define ADIN1110_MDIO_DEVAD
#define ADIN1110_MDIO_DATA

#define ADIN1110_TX_FSIZE
#define ADIN1110_TX
#define ADIN1110_TX_SPACE

#define ADIN1110_MAC_ADDR_FILTER_UPR
#define ADIN2111_MAC_ADDR_APPLY2PORT2
#define ADIN1110_MAC_ADDR_APPLY2PORT
#define ADIN2111_MAC_ADDR_TO_OTHER_PORT
#define ADIN1110_MAC_ADDR_TO_HOST

#define ADIN1110_MAC_ADDR_FILTER_LWR

#define ADIN1110_MAC_ADDR_MASK_UPR
#define ADIN1110_MAC_ADDR_MASK_LWR

#define ADIN1110_RX_FSIZE
#define ADIN1110_RX

#define ADIN2111_RX_P2_FSIZE
#define ADIN2111_RX_P2

#define ADIN1110_CLEAR_STATUS0

/* MDIO_OP codes */
#define ADIN1110_MDIO_OP_WR
#define ADIN1110_MDIO_OP_RD

#define ADIN1110_CD
#define ADIN1110_WRITE

#define ADIN1110_MAX_BUFF
#define ADIN1110_MAX_FRAMES_READ
#define ADIN1110_WR_HEADER_LEN
#define ADIN1110_FRAME_HEADER_LEN
#define ADIN1110_INTERNAL_SIZE_HEADER_LEN
#define ADIN1110_RD_HEADER_LEN
#define ADIN1110_REG_LEN
#define ADIN1110_FEC_LEN

#define ADIN1110_PHY_ID_VAL
#define ADIN2111_PHY_ID_VAL

#define ADIN_MAC_MAX_PORTS
#define ADIN_MAC_MAX_ADDR_SLOTS

#define ADIN_MAC_MULTICAST_ADDR_SLOT
#define ADIN_MAC_BROADCAST_ADDR_SLOT
#define ADIN_MAC_P1_ADDR_SLOT
#define ADIN_MAC_P2_ADDR_SLOT
#define ADIN_MAC_FDB_ADDR_SLOT

DECLARE_CRC8_TABLE(adin1110_crc_table);

enum adin1110_chips_id {};

struct adin1110_cfg {};

struct adin1110_port_priv {};

struct adin1110_priv {};

struct adin1110_switchdev_event_work {};

static struct adin1110_cfg adin1110_cfgs[] =;

static u8 adin1110_crc_data(u8 *data, u32 len)
{}

static int adin1110_read_reg(struct adin1110_priv *priv, u16 reg, u32 *val)
{}

static int adin1110_write_reg(struct adin1110_priv *priv, u16 reg, u32 val)
{}

static int adin1110_set_bits(struct adin1110_priv *priv, u16 reg,
			     unsigned long mask, unsigned long val)
{}

static int adin1110_round_len(int len)
{}

static int adin1110_read_fifo(struct adin1110_port_priv *port_priv)
{}

static int adin1110_write_fifo(struct adin1110_port_priv *port_priv,
			       struct sk_buff *txb)
{}

static int adin1110_read_mdio_acc(struct adin1110_priv *priv)
{}

static int adin1110_mdio_read(struct mii_bus *bus, int phy_id, int reg)
{}

static int adin1110_mdio_write(struct mii_bus *bus, int phy_id,
			       int reg, u16 reg_val)
{}

/* ADIN1110 MAC-PHY contains an ADIN1100 PHY.
 * ADIN2111 MAC-PHY contains two ADIN1100 PHYs.
 * By registering a new MDIO bus we allow the PAL to discover
 * the encapsulated PHY and probe the ADIN1100 driver.
 */
static int adin1110_register_mdiobus(struct adin1110_priv *priv,
				     struct device *dev)
{}

static bool adin1110_port_rx_ready(struct adin1110_port_priv *port_priv,
				   u32 status)
{}

static void adin1110_read_frames(struct adin1110_port_priv *port_priv,
				 unsigned int budget)
{}

static void adin1110_wake_queues(struct adin1110_priv *priv)
{}

static irqreturn_t adin1110_irq(int irq, void *p)
{}

/* ADIN1110 can filter up to 16 MAC addresses, mac_nr here is the slot used */
static int adin1110_write_mac_address(struct adin1110_port_priv *port_priv,
				      int mac_nr, const u8 *addr,
				      u8 *mask, u32 port_rules)
{}

static int adin1110_clear_mac_address(struct adin1110_priv *priv, int mac_nr)
{}

static u32 adin1110_port_rules(struct adin1110_port_priv *port_priv,
			       bool fw_to_host,
			       bool fw_to_other_port)
{}

static int adin1110_multicast_filter(struct adin1110_port_priv *port_priv,
				     int mac_nr, bool accept_multicast)
{}

static int adin1110_broadcasts_filter(struct adin1110_port_priv *port_priv,
				      int mac_nr, bool accept_broadcast)
{}

static int adin1110_set_mac_address(struct net_device *netdev,
				    const unsigned char *dev_addr)
{}

static int adin1110_ndo_set_mac_address(struct net_device *netdev, void *addr)
{}

static int adin1110_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
{}

static int adin1110_set_promisc_mode(struct adin1110_port_priv *port_priv,
				     bool promisc)
{}

static int adin1110_setup_rx_mode(struct adin1110_port_priv *port_priv)
{}

static bool adin1110_can_offload_forwarding(struct adin1110_priv *priv)
{}

static void adin1110_rx_mode_work(struct work_struct *work)
{}

static void adin1110_set_rx_mode(struct net_device *dev)
{}

static int adin1110_net_open(struct net_device *net_dev)
{}

static int adin1110_net_stop(struct net_device *net_dev)
{}

static void adin1110_tx_work(struct work_struct *work)
{}

static netdev_tx_t adin1110_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static void adin1110_ndo_get_stats64(struct net_device *dev,
				     struct rtnl_link_stats64 *storage)
{}

static int adin1110_port_get_port_parent_id(struct net_device *dev,
					    struct netdev_phys_item_id *ppid)
{}

static int adin1110_ndo_get_phys_port_name(struct net_device *dev,
					   char *name, size_t len)
{}

static const struct net_device_ops adin1110_netdev_ops =;

static void adin1110_get_drvinfo(struct net_device *dev,
				 struct ethtool_drvinfo *di)
{}

static const struct ethtool_ops adin1110_ethtool_ops =;

static void adin1110_adjust_link(struct net_device *dev)
{}

/* PHY ID is stored in the MAC registers too,
 * check spi connection by reading it.
 */
static int adin1110_check_spi(struct adin1110_priv *priv)
{}

static int adin1110_hw_forwarding(struct adin1110_priv *priv, bool enable)
{}

static int adin1110_port_bridge_join(struct adin1110_port_priv *port_priv,
				     struct net_device *bridge)
{}

static int adin1110_port_bridge_leave(struct adin1110_port_priv *port_priv,
				      struct net_device *bridge)
{}

static bool adin1110_port_dev_check(const struct net_device *dev)
{}

static int adin1110_netdevice_event(struct notifier_block *unused,
				    unsigned long event, void *ptr)
{}

static struct notifier_block adin1110_netdevice_nb =;

static void adin1110_disconnect_phy(void *data)
{}

static int adin1110_port_set_forwarding_state(struct adin1110_port_priv *port_priv)
{}

static int adin1110_port_set_blocking_state(struct adin1110_port_priv *port_priv)
{}

/* ADIN1110/2111 does not have any native STP support.
 * Listen for bridge core state changes and
 * allow all frames to pass or only the BPDUs.
 */
static int adin1110_port_attr_stp_state_set(struct adin1110_port_priv *port_priv,
					    u8 state)
{}

static int adin1110_port_attr_set(struct net_device *dev, const void *ctx,
				  const struct switchdev_attr *attr,
				  struct netlink_ext_ack *extack)
{}

static int adin1110_switchdev_blocking_event(struct notifier_block *unused,
					     unsigned long event,
					     void *ptr)
{}

static struct notifier_block adin1110_switchdev_blocking_notifier =;

static void adin1110_fdb_offload_notify(struct net_device *netdev,
					struct switchdev_notifier_fdb_info *rcv)
{}

static int adin1110_fdb_add(struct adin1110_port_priv *port_priv,
			    struct switchdev_notifier_fdb_info *fdb)
{}

static int adin1110_read_mac(struct adin1110_priv *priv, int mac_nr, u8 *addr)
{}

static int adin1110_fdb_del(struct adin1110_port_priv *port_priv,
			    struct switchdev_notifier_fdb_info *fdb)
{}

static void adin1110_switchdev_event_work(struct work_struct *work)
{}

/* called under rcu_read_lock() */
static int adin1110_switchdev_event(struct notifier_block *unused,
				    unsigned long event, void *ptr)
{}

static struct notifier_block adin1110_switchdev_notifier =;

static void adin1110_unregister_notifiers(void)
{}

static int adin1110_setup_notifiers(void)
{}

static int adin1110_probe_netdevs(struct adin1110_priv *priv)
{}

static int adin1110_probe(struct spi_device *spi)
{}

static const struct of_device_id adin1110_match_table[] =;
MODULE_DEVICE_TABLE(of, adin1110_match_table);

static const struct spi_device_id adin1110_spi_id[] =;
MODULE_DEVICE_TABLE(spi, adin1110_spi_id);

static struct spi_driver adin1110_driver =;

static int __init adin1110_driver_init(void)
{}

static void __exit adin1110_exit(void)
{}
module_init();
module_exit(adin1110_exit);

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();