diff mbox series

[net-next,4/4] stmmac: intel: introduce platform data phyless setting for Ericsson system

Message ID 20220422073505.810084-5-boon.leong.ong@intel.com (mailing list archive)
State New, archived
Headers show
Series pcs-xpcs, stmmac: add 1000BASE-X AN for network switch | expand

Commit Message

Ong Boon Leong April 22, 2022, 7:35 a.m. UTC
Certain platform wants specific GbE controller instance to be in PHY-less
mode, i.e. to be used for 1000BASE-X connection for network switch.

Tested-by: Emilio Riva <emilio.riva@ericsson.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 265d39acdd0..9c9577fc15d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -24,6 +24,8 @@  struct intel_priv_data {
 struct stmmac_pci_func_data {
 	unsigned int func;
 	int phy_addr;
+	phy_interface_t phy_interface;
+	unsigned int phyless;
 };
 
 struct stmmac_pci_dmi_data {
@@ -439,10 +441,65 @@  static void common_default_data(struct plat_stmmacenet_data *plat)
 	plat->rx_queues_cfg[0].pkt_route = 0x0;
 }
 
+static const struct stmmac_pci_func_data ericsson_phyless_func_data[] = {
+	{
+		.func = 2,
+		.phy_interface = PHY_INTERFACE_MODE_1000BASEX,
+		.phyless = true,
+	},
+};
+
+static const struct stmmac_pci_dmi_data ericsson_phyless_dmi_data = {
+	.func = ericsson_phyless_func_data,
+	.nfuncs = ARRAY_SIZE(ericsson_phyless_func_data),
+};
+
+static const struct dmi_system_id intel_mgbe_pci_dmi[] = {
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Ericsson"),
+			DMI_MATCH(DMI_BOARD_NAME, "SMARC-SXEL"),
+		},
+		.driver_data = (void *)&ericsson_phyless_dmi_data,
+	},
+	{}
+};
+
+static bool stmmac_pci_find_phyless(struct pci_dev *pdev,
+				    const struct dmi_system_id *dmi_list,
+				    phy_interface_t *phy_interface,
+				    unsigned int *phyless)
+{
+	const struct stmmac_pci_func_data *func_data;
+	const struct stmmac_pci_dmi_data *dmi_data;
+	const struct dmi_system_id *dmi_id;
+	int func = PCI_FUNC(pdev->devfn);
+	size_t n;
+
+	dmi_id = dmi_first_match(dmi_list);
+	if (!dmi_id)
+		return false;
+
+	dmi_data = dmi_id->driver_data;
+	func_data = dmi_data->func;
+
+	for (n = 0; n < dmi_data->nfuncs; n++, func_data++)
+		if (func_data->func == func) {
+			*phy_interface = func_data->phy_interface;
+			*phyless = func_data->phyless;
+			return true;
+		}
+
+	return false;
+}
+
 static int intel_mgbe_common_data(struct pci_dev *pdev,
 				  struct plat_stmmacenet_data *plat)
 {
+	phy_interface_t phy_interface;
+	unsigned int phyless;
 	char clk_name[20];
+	bool found;
 	int ret;
 	int i;
 
@@ -559,6 +616,13 @@  static int intel_mgbe_common_data(struct pci_dev *pdev,
 	/* Use the last Rx queue */
 	plat->vlan_fail_q = plat->rx_queues_to_use - 1;
 
+	found = stmmac_pci_find_phyless(pdev, intel_mgbe_pci_dmi,
+					&phy_interface, &phyless);
+	if (found) {
+		plat->mdio_bus_data->phyless = phyless;
+		plat->phy_interface = phy_interface;
+	}
+
 	/* Intel mgbe SGMII interface uses pcs-xcps */
 	if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
 	    plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {