Commit 0d6f01ff authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'lynx-pcs-interface-cleanup'



Colin Foster says:

====================
lynx pcs interface cleanup

The current Felix driver (and Seville) rely directly on the lynx_pcs
device. There are other possible PCS interfaces that can be used with
this hardware, so this should be abstracted from felix. The generic
phylink_pcs is used instead.

While going through the code, there were some opportunities to change
some misleading variable names. Those are included in this patch set.

v1->v2
    * compile-time fixes for freescale parts
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 60c33202 0699b3e0
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <linux/of_net.h>
#include <linux/pci.h>
#include <linux/of.h>
#include <linux/pcs-lynx.h>
#include <net/pkt_sched.h>
#include <net/dsa.h>
#include "felix.h"
@@ -832,7 +831,7 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
	struct dsa_port *dp = dsa_to_port(ds, port);

	if (felix->pcs && felix->pcs[port])
		phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs);
		phylink_set_pcs(dp->pl, felix->pcs[port]);
}

static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ struct felix {
	const struct felix_info		*info;
	struct ocelot			ocelot;
	struct mii_bus			*imdio;
	struct lynx_pcs			**pcs;
	struct phylink_pcs		**pcs;
	resource_size_t			switch_base;
	resource_size_t			imdio_base;
	enum dsa_tag_protocol		tag_proto;
+15 −13
Original line number Diff line number Diff line
@@ -1039,7 +1039,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
	int rc;

	felix->pcs = devm_kcalloc(dev, felix->info->num_ports,
				  sizeof(struct lynx_pcs *),
				  sizeof(struct phylink_pcs *),
				  GFP_KERNEL);
	if (!felix->pcs) {
		dev_err(dev, "failed to allocate array for PCS PHYs\n");
@@ -1088,8 +1088,8 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)

	for (port = 0; port < felix->info->num_ports; port++) {
		struct ocelot_port *ocelot_port = ocelot->ports[port];
		struct mdio_device *pcs;
		struct lynx_pcs *lynx;
		struct phylink_pcs *phylink_pcs;
		struct mdio_device *mdio_device;

		if (dsa_is_unused_port(felix->ds, port))
			continue;
@@ -1097,17 +1097,17 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
		if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_INTERNAL)
			continue;

		pcs = mdio_device_create(felix->imdio, port);
		if (IS_ERR(pcs))
		mdio_device = mdio_device_create(felix->imdio, port);
		if (IS_ERR(mdio_device))
			continue;

		lynx = lynx_pcs_create(pcs);
		if (!lynx) {
			mdio_device_free(pcs);
		phylink_pcs = lynx_pcs_create(mdio_device);
		if (!phylink_pcs) {
			mdio_device_free(mdio_device);
			continue;
		}

		felix->pcs[port] = lynx;
		felix->pcs[port] = phylink_pcs;

		dev_info(dev, "Found PCS at internal MDIO address %d\n", port);
	}
@@ -1121,13 +1121,15 @@ static void vsc9959_mdio_bus_free(struct ocelot *ocelot)
	int port;

	for (port = 0; port < ocelot->num_phys_ports; port++) {
		struct lynx_pcs *pcs = felix->pcs[port];
		struct phylink_pcs *phylink_pcs = felix->pcs[port];
		struct mdio_device *mdio_device;

		if (!pcs)
		if (!phylink_pcs)
			continue;

		mdio_device_free(pcs->mdio);
		lynx_pcs_destroy(pcs);
		mdio_device = lynx_get_mdio_device(phylink_pcs);
		mdio_device_free(mdio_device);
		lynx_pcs_destroy(phylink_pcs);
	}
	mdiobus_unregister(felix->imdio);
}
+15 −13
Original line number Diff line number Diff line
@@ -1012,7 +1012,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
	int rc;

	felix->pcs = devm_kcalloc(dev, felix->info->num_ports,
				  sizeof(struct phy_device *),
				  sizeof(struct phylink_pcs *),
				  GFP_KERNEL);
	if (!felix->pcs) {
		dev_err(dev, "failed to allocate array for PCS PHYs\n");
@@ -1039,9 +1039,9 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)

	for (port = 0; port < felix->info->num_ports; port++) {
		struct ocelot_port *ocelot_port = ocelot->ports[port];
		struct phylink_pcs *phylink_pcs;
		struct mdio_device *mdio_device;
		int addr = port + 4;
		struct mdio_device *pcs;
		struct lynx_pcs *lynx;

		if (dsa_is_unused_port(felix->ds, port))
			continue;
@@ -1049,17 +1049,17 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)
		if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_INTERNAL)
			continue;

		pcs = mdio_device_create(felix->imdio, addr);
		if (IS_ERR(pcs))
		mdio_device = mdio_device_create(felix->imdio, addr);
		if (IS_ERR(mdio_device))
			continue;

		lynx = lynx_pcs_create(pcs);
		if (!lynx) {
			mdio_device_free(pcs);
		phylink_pcs = lynx_pcs_create(mdio_device);
		if (!phylink_pcs) {
			mdio_device_free(mdio_device);
			continue;
		}

		felix->pcs[port] = lynx;
		felix->pcs[port] = phylink_pcs;

		dev_info(dev, "Found PCS at internal MDIO address %d\n", addr);
	}
@@ -1073,13 +1073,15 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocelot)
	int port;

	for (port = 0; port < ocelot->num_phys_ports; port++) {
		struct lynx_pcs *pcs = felix->pcs[port];
		struct phylink_pcs *phylink_pcs = felix->pcs[port];
		struct mdio_device *mdio_device;

		if (!pcs)
		if (!phylink_pcs)
			continue;

		mdio_device_free(pcs->mdio);
		lynx_pcs_destroy(pcs);
		mdio_device = lynx_get_mdio_device(phylink_pcs);
		mdio_device_free(mdio_device);
		lynx_pcs_destroy(phylink_pcs);
	}
	mdiobus_unregister(felix->imdio);
}
+8 −5
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
/* Copyright 2019 NXP */

#include <linux/acpi.h>
#include <linux/pcs-lynx.h>
#include <linux/property.h>

#include "dpaa2-eth.h"
@@ -204,11 +205,13 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac,

static void dpaa2_pcs_destroy(struct dpaa2_mac *mac)
{
	struct lynx_pcs *pcs = mac->pcs;
	struct phylink_pcs *phylink_pcs = mac->pcs;

	if (pcs) {
		struct device *dev = &pcs->mdio->dev;
		lynx_pcs_destroy(pcs);
	if (phylink_pcs) {
		struct mdio_device *mdio = lynx_get_mdio_device(phylink_pcs);
		struct device *dev = &mdio->dev;

		lynx_pcs_destroy(phylink_pcs);
		put_device(dev);
		mac->pcs = NULL;
	}
@@ -292,7 +295,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
	mac->phylink = phylink;

	if (mac->pcs)
		phylink_set_pcs(mac->phylink, &mac->pcs->pcs);
		phylink_set_pcs(mac->phylink, mac->pcs);

	err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
	if (err) {
Loading