drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
Extension
.c
Size
29026 bytes
Lines
1011
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (of_property_read_bool(q_node, "snps,dcb-algorithm")) {
			plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
		} else if (of_property_read_bool(q_node,
						 "snps,avb-algorithm")) {
			plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB;

			/* Credit Base Shaper parameters used by AVB */
			if (of_property_read_u32(q_node, "snps,send_slope",
				&plat->tx_queues_cfg[queue].send_slope))
				plat->tx_queues_cfg[queue].send_slope = 0x0;
			if (of_property_read_u32(q_node, "snps,idle_slope",
				&plat->tx_queues_cfg[queue].idle_slope))
				plat->tx_queues_cfg[queue].idle_slope = 0x0;
			if (of_property_read_u32(q_node, "snps,high_credit",
				&plat->tx_queues_cfg[queue].high_credit))
				plat->tx_queues_cfg[queue].high_credit = 0x0;
			if (of_property_read_u32(q_node, "snps,low_credit",
				&plat->tx_queues_cfg[queue].low_credit))
				plat->tx_queues_cfg[queue].low_credit = 0x0;
		} else {
			plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
		}

		if (!of_property_read_u32(q_node, "snps,priority",
					  &plat->tx_queues_cfg[queue].prio))
			plat->tx_queues_cfg[queue].use_prio = true;

		plat->tx_queues_cfg[queue].coe_unsupported =
			of_property_read_bool(q_node, "snps,coe-unsupported");

		queue++;
	}
	if (queue != plat->tx_queues_to_use) {
		ret = -EINVAL;
		dev_err(&pdev->dev, "Not all TX queues were configured\n");
		goto out;
	}

out:
	of_node_put(rx_node);
	of_node_put(tx_node);
	of_node_put(q_node);

	return ret;
}

/**
 * stmmac_of_get_mdio() - Gets the MDIO bus from the devicetree.
 * @np: devicetree node
 *
 * The MDIO bus will be searched for in the following ways:
 * 1. The compatible is "snps,dwc-qos-ethernet-4.10" && a "mdio" named
 *    child node exists
 * 2. A child node with the "snps,dwmac-mdio" compatible is present
 *
 * Return: The MDIO node if present otherwise NULL
 */
static struct device_node *stmmac_of_get_mdio(struct device_node *np)
{
	static const struct of_device_id need_mdio_ids[] = {
		{ .compatible = "snps,dwc-qos-ethernet-4.10" },
		{},
	};
	struct device_node *mdio_node = NULL;

	if (of_match_node(need_mdio_ids, np)) {
		mdio_node = of_get_child_by_name(np, "mdio");
	} else {
		/**
		 * If snps,dwmac-mdio is passed from DT, always register
		 * the MDIO
		 */
		for_each_child_of_node(np, mdio_node) {
			if (of_device_is_compatible(mdio_node,
						    "snps,dwmac-mdio"))
				break;
		}
	}

	return mdio_node;
}

/**
 * stmmac_mdio_setup() - Populate platform related MDIO structures.
 * @plat: driver data platform structure
 * @np: devicetree node
 * @dev: device pointer
 *
 * This searches for MDIO information from the devicetree.
 * If an MDIO node is found, it's assigned to plat->mdio_node and

Annotation

Implementation Notes