#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/mdio-bitbang.h>
#include <linux/netdevice.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/phy.h>
#include <linux/cache.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/sh_eth.h>
#include <linux/of_mdio.h>
#include "sh_eth.h"
#define SH_ETH_DEF_MSG_ENABLE …
#define SH_ETH_OFFSET_INVALID …
#define SH_ETH_OFFSET_DEFAULTS …
__diag_push();
__diag_ignore_all("-Woverride-init",
"logic to initialize all and then override some is OK");
static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = …;
static const u16 sh_eth_offset_fast_rcar[SH_ETH_MAX_REGISTER_OFFSET] = …;
static const u16 sh_eth_offset_fast_sh4[SH_ETH_MAX_REGISTER_OFFSET] = …;
static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = …;
__diag_pop();
static void sh_eth_rcv_snd_disable(struct net_device *ndev);
static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev);
static void sh_eth_write(struct net_device *ndev, u32 data, int enum_index)
{ … }
static u32 sh_eth_read(struct net_device *ndev, int enum_index)
{ … }
static void sh_eth_modify(struct net_device *ndev, int enum_index, u32 clear,
u32 set)
{ … }
static u16 sh_eth_tsu_get_offset(struct sh_eth_private *mdp, int enum_index)
{ … }
static void sh_eth_tsu_write(struct sh_eth_private *mdp, u32 data,
int enum_index)
{ … }
static u32 sh_eth_tsu_read(struct sh_eth_private *mdp, int enum_index)
{ … }
static void sh_eth_soft_swap(char *src, int len)
{ … }
static void sh_eth_select_mii(struct net_device *ndev)
{ … }
static void sh_eth_set_duplex(struct net_device *ndev)
{ … }
static void sh_eth_chip_reset(struct net_device *ndev)
{ … }
static int sh_eth_soft_reset(struct net_device *ndev)
{ … }
static int sh_eth_check_soft_reset(struct net_device *ndev)
{ … }
static int sh_eth_soft_reset_gether(struct net_device *ndev)
{ … }
static void sh_eth_set_rate_gether(struct net_device *ndev)
{ … }
#ifdef CONFIG_OF
static struct sh_eth_cpu_data r7s72100_data = …;
static void sh_eth_chip_reset_r8a7740(struct net_device *ndev)
{ … }
static struct sh_eth_cpu_data r8a7740_data = …;
static void sh_eth_set_rate_rcar(struct net_device *ndev)
{ … }
static struct sh_eth_cpu_data rcar_gen1_data = …;
static struct sh_eth_cpu_data rcar_gen2_data = …;
static struct sh_eth_cpu_data r8a77980_data = …;
static struct sh_eth_cpu_data r7s9210_data = …;
#endif
static void sh_eth_set_rate_sh7724(struct net_device *ndev)
{ … }
static struct sh_eth_cpu_data sh7724_data = …;
static void sh_eth_set_rate_sh7757(struct net_device *ndev)
{ … }
static struct sh_eth_cpu_data sh7757_data = …;
#define SH_GIGA_ETH_BASE …
#define GIGA_MALR(port) …
#define GIGA_MAHR(port) …
static void sh_eth_chip_reset_giga(struct net_device *ndev)
{ … }
static void sh_eth_set_rate_giga(struct net_device *ndev)
{ … }
static struct sh_eth_cpu_data sh7757_data_giga = …;
static struct sh_eth_cpu_data sh7734_data = …;
static struct sh_eth_cpu_data sh7763_data = …;
static struct sh_eth_cpu_data sh7619_data = …;
static struct sh_eth_cpu_data sh771x_data = …;
static void sh_eth_set_default_cpu_data(struct sh_eth_cpu_data *cd)
{ … }
static void sh_eth_set_receive_align(struct sk_buff *skb)
{ … }
static void update_mac_address(struct net_device *ndev)
{ … }
static void read_mac_address(struct net_device *ndev, unsigned char *mac)
{ … }
struct bb_info { … };
static void sh_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set)
{ … }
static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ … }
static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
{ … }
static int sh_get_mdio(struct mdiobb_ctrl *ctrl)
{ … }
static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ … }
static const struct mdiobb_ops bb_ops = …;
static int sh_eth_tx_free(struct net_device *ndev, bool sent_only)
{ … }
static void sh_eth_ring_free(struct net_device *ndev)
{ … }
static void sh_eth_ring_format(struct net_device *ndev)
{ … }
static int sh_eth_ring_init(struct net_device *ndev)
{ … }
static int sh_eth_dev_init(struct net_device *ndev)
{ … }
static void sh_eth_dev_exit(struct net_device *ndev)
{ … }
static void sh_eth_rx_csum(struct sk_buff *skb)
{ … }
static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
{ … }
static void sh_eth_rcv_snd_disable(struct net_device *ndev)
{ … }
static void sh_eth_rcv_snd_enable(struct net_device *ndev)
{ … }
static void sh_eth_emac_interrupt(struct net_device *ndev)
{ … }
static void sh_eth_error(struct net_device *ndev, u32 intr_status)
{ … }
static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
{ … }
static int sh_eth_poll(struct napi_struct *napi, int budget)
{ … }
static void sh_eth_adjust_link(struct net_device *ndev)
{ … }
static int sh_eth_phy_init(struct net_device *ndev)
{ … }
static int sh_eth_phy_start(struct net_device *ndev)
{ … }
#define SH_ETH_REG_DUMP_VERSION …
#define SH_ETH_REG_DUMP_MAX_REGS …
static size_t __sh_eth_get_regs(struct net_device *ndev, u32 *buf)
{ … }
static int sh_eth_get_regs_len(struct net_device *ndev)
{ … }
static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
void *buf)
{ … }
static u32 sh_eth_get_msglevel(struct net_device *ndev)
{ … }
static void sh_eth_set_msglevel(struct net_device *ndev, u32 value)
{ … }
static const char sh_eth_gstrings_stats[][ETH_GSTRING_LEN] = …;
#define SH_ETH_STATS_LEN …
static int sh_eth_get_sset_count(struct net_device *netdev, int sset)
{ … }
static void sh_eth_get_ethtool_stats(struct net_device *ndev,
struct ethtool_stats *stats, u64 *data)
{ … }
static void sh_eth_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
{ … }
static void sh_eth_get_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
struct netlink_ext_ack *extack)
{ … }
static int sh_eth_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
struct netlink_ext_ack *extack)
{ … }
static void sh_eth_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{ … }
static int sh_eth_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{ … }
static const struct ethtool_ops sh_eth_ethtool_ops = …;
static int sh_eth_open(struct net_device *ndev)
{ … }
static void sh_eth_tx_timeout(struct net_device *ndev, unsigned int txqueue)
{ … }
static netdev_tx_t sh_eth_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
{ … }
static void
sh_eth_update_stat(struct net_device *ndev, unsigned long *stat, int reg)
{ … }
static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
{ … }
static int sh_eth_close(struct net_device *ndev)
{ … }
static int sh_eth_change_mtu(struct net_device *ndev, int new_mtu)
{ … }
static u32 sh_eth_tsu_get_post_mask(int entry)
{ … }
static u32 sh_eth_tsu_get_post_bit(struct sh_eth_private *mdp, int entry)
{ … }
static void sh_eth_tsu_enable_cam_entry_post(struct net_device *ndev,
int entry)
{ … }
static bool sh_eth_tsu_disable_cam_entry_post(struct net_device *ndev,
int entry)
{ … }
static int sh_eth_tsu_busy(struct net_device *ndev)
{ … }
static int sh_eth_tsu_write_entry(struct net_device *ndev, u16 offset,
const u8 *addr)
{ … }
static void sh_eth_tsu_read_entry(struct net_device *ndev, u16 offset, u8 *addr)
{ … }
static int sh_eth_tsu_find_entry(struct net_device *ndev, const u8 *addr)
{ … }
static int sh_eth_tsu_find_empty(struct net_device *ndev)
{ … }
static int sh_eth_tsu_disable_cam_entry_table(struct net_device *ndev,
int entry)
{ … }
static int sh_eth_tsu_add_entry(struct net_device *ndev, const u8 *addr)
{ … }
static int sh_eth_tsu_del_entry(struct net_device *ndev, const u8 *addr)
{ … }
static int sh_eth_tsu_purge_all(struct net_device *ndev)
{ … }
static void sh_eth_tsu_purge_mcast(struct net_device *ndev)
{ … }
static void sh_eth_set_rx_mode(struct net_device *ndev)
{ … }
static void sh_eth_set_rx_csum(struct net_device *ndev, bool enable)
{ … }
static int sh_eth_set_features(struct net_device *ndev,
netdev_features_t features)
{ … }
static int sh_eth_get_vtag_index(struct sh_eth_private *mdp)
{ … }
static int sh_eth_vlan_rx_add_vid(struct net_device *ndev,
__be16 proto, u16 vid)
{ … }
static int sh_eth_vlan_rx_kill_vid(struct net_device *ndev,
__be16 proto, u16 vid)
{ … }
static void sh_eth_tsu_init(struct sh_eth_private *mdp)
{ … }
static int sh_mdio_release(struct sh_eth_private *mdp)
{ … }
static int sh_mdiobb_read_c22(struct mii_bus *bus, int phy, int reg)
{ … }
static int sh_mdiobb_write_c22(struct mii_bus *bus, int phy, int reg, u16 val)
{ … }
static int sh_mdiobb_read_c45(struct mii_bus *bus, int phy, int devad, int reg)
{ … }
static int sh_mdiobb_write_c45(struct mii_bus *bus, int phy, int devad,
int reg, u16 val)
{ … }
static int sh_mdio_init(struct sh_eth_private *mdp,
struct sh_eth_plat_data *pd)
{ … }
static const u16 *sh_eth_get_register_offset(int register_type)
{ … }
static const struct net_device_ops sh_eth_netdev_ops = …;
static const struct net_device_ops sh_eth_netdev_ops_tsu = …;
#ifdef CONFIG_OF
static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
{ … }
static const struct of_device_id sh_eth_match_table[] = …;
MODULE_DEVICE_TABLE(of, sh_eth_match_table);
#else
static inline struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
{
return NULL;
}
#endif
static int sh_eth_drv_probe(struct platform_device *pdev)
{ … }
static void sh_eth_drv_remove(struct platform_device *pdev)
{ … }
#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
static int sh_eth_wol_setup(struct net_device *ndev)
{ … }
static int sh_eth_wol_restore(struct net_device *ndev)
{ … }
static int sh_eth_suspend(struct device *dev)
{ … }
static int sh_eth_resume(struct device *dev)
{ … }
#endif
static int sh_eth_runtime_nop(struct device *dev)
{ … }
static const struct dev_pm_ops sh_eth_dev_pm_ops = …;
#define SH_ETH_PM_OPS …
#else
#define SH_ETH_PM_OPS …
#endif
static const struct platform_device_id sh_eth_id_table[] = …;
MODULE_DEVICE_TABLE(platform, sh_eth_id_table);
static struct platform_driver sh_eth_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;