drivers/net/ethernet/renesas/sh_eth.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/renesas/sh_eth.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/renesas/sh_eth.c
Extension
.c
Size
88429 bytes
Lines
3561
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct net_device_ops sh_eth_netdev_ops = {
	.ndo_open		= sh_eth_open,
	.ndo_stop		= sh_eth_close,
	.ndo_start_xmit		= sh_eth_start_xmit,
	.ndo_get_stats		= sh_eth_get_stats,
	.ndo_set_rx_mode	= sh_eth_set_rx_mode,
	.ndo_tx_timeout		= sh_eth_tx_timeout,
	.ndo_eth_ioctl		= phy_do_ioctl_running,
	.ndo_change_mtu		= sh_eth_change_mtu,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= eth_mac_addr,
	.ndo_set_features	= sh_eth_set_features,
};

static const struct net_device_ops sh_eth_netdev_ops_tsu = {
	.ndo_open		= sh_eth_open,
	.ndo_stop		= sh_eth_close,
	.ndo_start_xmit		= sh_eth_start_xmit,
	.ndo_get_stats		= sh_eth_get_stats,
	.ndo_set_rx_mode	= sh_eth_set_rx_mode,
	.ndo_vlan_rx_add_vid	= sh_eth_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid	= sh_eth_vlan_rx_kill_vid,
	.ndo_tx_timeout		= sh_eth_tx_timeout,
	.ndo_eth_ioctl		= phy_do_ioctl_running,
	.ndo_change_mtu		= sh_eth_change_mtu,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= eth_mac_addr,
	.ndo_set_features	= sh_eth_set_features,
};

#ifdef CONFIG_OF
static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
{
	struct device_node *np = dev->of_node;
	struct sh_eth_plat_data *pdata;
	phy_interface_t interface;
	int ret;

	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
	if (!pdata)
		return NULL;

	ret = of_get_phy_mode(np, &interface);
	if (ret)
		return NULL;
	pdata->phy_interface = interface;

	of_get_mac_address(np, pdata->mac_addr);

	pdata->no_ether_link =
		of_property_read_bool(np, "renesas,no-ether-link");
	pdata->ether_link_active_low =
		of_property_read_bool(np, "renesas,ether-link-active-low");

	return pdata;
}

static const struct of_device_id sh_eth_match_table[] = {
	{ .compatible = "renesas,gether-r8a7740", .data = &r8a7740_data },
	{ .compatible = "renesas,ether-r8a7743", .data = &rcar_gen2_data },
	{ .compatible = "renesas,ether-r8a7745", .data = &rcar_gen2_data },
	{ .compatible = "renesas,ether-r8a7778", .data = &rcar_gen1_data },
	{ .compatible = "renesas,ether-r8a7779", .data = &rcar_gen1_data },
	{ .compatible = "renesas,ether-r8a7790", .data = &rcar_gen2_data },
	{ .compatible = "renesas,ether-r8a7791", .data = &rcar_gen2_data },
	{ .compatible = "renesas,ether-r8a7793", .data = &rcar_gen2_data },
	{ .compatible = "renesas,ether-r8a7794", .data = &rcar_gen2_data },
	{ .compatible = "renesas,gether-r8a77980", .data = &r8a77980_data },
	{ .compatible = "renesas,ether-r7s72100", .data = &r7s72100_data },
	{ .compatible = "renesas,ether-r7s9210", .data = &r7s9210_data },
	{ .compatible = "renesas,rcar-gen1-ether", .data = &rcar_gen1_data },
	{ .compatible = "renesas,rcar-gen2-ether", .data = &rcar_gen2_data },
	{ }
};
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)
{
	struct resource *res;
	struct sh_eth_plat_data *pd = dev_get_platdata(&pdev->dev);
	const struct platform_device_id *id = platform_get_device_id(pdev);
	struct sh_eth_private *mdp;
	struct net_device *ndev;
	int ret;

Annotation

Implementation Notes