drivers/net/ethernet/renesas/rtsn.c

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

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/renesas/rtsn.c
Extension
.c
Size
31170 bytes
Lines
1368
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 rtsn_netdev_ops = {
	.ndo_open		= rtsn_open,
	.ndo_stop		= rtsn_stop,
	.ndo_start_xmit		= rtsn_start_xmit,
	.ndo_get_stats64	= rtsn_get_stats64,
	.ndo_eth_ioctl		= rtsn_do_ioctl,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= eth_mac_addr,
	.ndo_hwtstamp_set	= rtsn_hwtstamp_set,
	.ndo_hwtstamp_get	= rtsn_hwtstamp_get,
};

static int rtsn_get_ts_info(struct net_device *ndev,
			    struct kernel_ethtool_ts_info *info)
{
	struct rtsn_private *priv = netdev_priv(ndev);

	info->phc_index = rcar_gen4_ptp_clock_index(priv->ptp_priv);
	info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
		SOF_TIMESTAMPING_TX_HARDWARE |
		SOF_TIMESTAMPING_RX_HARDWARE |
		SOF_TIMESTAMPING_RAW_HARDWARE;
	info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
	info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);

	return 0;
}

static const struct ethtool_ops rtsn_ethtool_ops = {
	.nway_reset		= phy_ethtool_nway_reset,
	.get_link		= ethtool_op_get_link,
	.get_ts_info		= rtsn_get_ts_info,
	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
};

static const struct of_device_id rtsn_match_table[] = {
	{ .compatible = "renesas,r8a779g0-ethertsn", },
	{ /* Sentinel */ }
};

MODULE_DEVICE_TABLE(of, rtsn_match_table);

static int rtsn_probe(struct platform_device *pdev)
{
	struct rtsn_private *priv;
	struct net_device *ndev;
	void __iomem *ptpaddr;
	struct resource *res;
	int ret;

	ndev = alloc_etherdev_mqs(sizeof(struct rtsn_private), TX_NUM_CHAINS,
				  RX_NUM_CHAINS);
	if (!ndev)
		return -ENOMEM;

	priv = netdev_priv(ndev);
	priv->pdev = pdev;
	priv->ndev = ndev;

	spin_lock_init(&priv->lock);
	platform_set_drvdata(pdev, priv);

	priv->clk = devm_clk_get(&pdev->dev, NULL);
	if (IS_ERR(priv->clk)) {
		ret = PTR_ERR(priv->clk);
		goto error_free;
	}

	priv->reset = devm_reset_control_get(&pdev->dev, NULL);
	if (IS_ERR(priv->reset)) {
		ret = PTR_ERR(priv->reset);
		goto error_free;
	}

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsnes");
	if (!res) {
		dev_err(&pdev->dev, "Can't find tsnes resource\n");
		ret = -EINVAL;
		goto error_free;
	}

	priv->base = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(priv->base)) {
		ret = PTR_ERR(priv->base);
		goto error_free;
	}

	SET_NETDEV_DEV(ndev, &pdev->dev);

Annotation

Implementation Notes