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 Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series pcs-xpcs, stmmac: add 1000BASE-X AN for network switch | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 7 this patch: 7
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang fail Errors and warnings before: 8 this patch: 8
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 86 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

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) {