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

Merge branch 'regmap-TSE-PCS'



Maxime Chevallier says:

====================
net: add a regmap-based mdio driver and drop TSE PCS

This is the V4 of a series that follows-up on the work [1] aiming to drop the
altera TSE PCS driver, as it turns out to be a version of the Lynx PCS exposed
as a memory-mapped block, instead of living on an MDIO bus.

One step of this removal involved creating a regmap-based mdio driver
that translates MDIO accesses into the actual underlying bus that
exposes the register. The register layout must of course match the
standard MDIO layout, but we can now account for differences in stride
with recent work on the regmap subsystem [2].

Sorry for repeating this, but I didn't hear anything on this matter in previous
iterations, Mark, Net maintainers, this series depends on the patch
e12ff287 that was recently merged into the regmap tree [3].

For this series to be usable in net-next, this patch must be applied
beforehand. Should Mark create a tag that would then be merged into
net-next ? Or should we just wait for the next release to merge this
into net-next ?

This series introduces a new MDIO driver, and uses it to convert Altera
TSE from the actual TSE PCS driver to Lynx PCS.

Since it turns out dwmac_socfpga also uses a TSE PCS block, port that
driver to Lynx as well.

Changes in V4 :
 - Use new pcs_lynx_create/destroy helpers added by Russell
 - Rework the cleanup sequence to avoid leaking data
 - Rework a bit KConfig to properly select dependencies
 - Fix a few hiccups with misplaced hunks in 2 commits

Changes in V3 :
 - Use a dedicated struct for the mii bus's priv data, to avoid
   duplicating the whole struct mdio_regmap_config, from which 2 fields
   only are necessary after init, as suggested by Russell
 - Use ~0 instead of ~0UL for the no-scan bitmask, following Simon's
   review.

Changes in V2 :
 - Use phy_mask to avoid unnecessarily scanning the whole mdio bus
 - Go one step further and completely disable scanning if users
   set the .autoscan flag to false, in case the mdiodevice isn't an
   actual PHY (a PCS for example).
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f69de8aa 5d1f3fe7
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -909,13 +909,6 @@ L: netdev@vger.kernel.org
S:	Maintained
F:	drivers/net/ethernet/altera/
ALTERA TSE PCS
M:	Maxime Chevallier <maxime.chevallier@bootlin.com>
L:	netdev@vger.kernel.org
S:	Supported
F:	drivers/net/pcs/pcs-altera-tse.c
F:	include/linux/pcs-altera-tse.h
ALTERA UART/JTAG UART SERIAL DRIVERS
M:	Tobias Klauser <tklauser@distanz.ch>
L:	linux-serial@vger.kernel.org
@@ -12844,6 +12837,13 @@ F: Documentation/devicetree/bindings/net/ieee802154/mcr20a.txt
F:	drivers/net/ieee802154/mcr20a.c
F:	drivers/net/ieee802154/mcr20a.h
MDIO REGMAP DRIVER
M:	Maxime Chevallier <maxime.chevallier@bootlin.com>
L:	netdev@vger.kernel.org
S:	Maintained
F:	drivers/net/mdio/mdio-regmap.c
F:	include/linux/mdio/mdio-regmap.h
MEASUREMENT COMPUTING CIO-DAC IIO DRIVER
M:	William Breathitt Gray <william.gray@linaro.org>
L:	linux-iio@vger.kernel.org
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ config ALTERA_TSE
	select PHYLIB
	select PHYLINK
	select PCS_ALTERA_TSE
	select MDIO_REGMAP
	select REGMAP_MMIO
	help
	  This driver supports the Altera Triple-Speed (TSE) Ethernet MAC.

+48 −9
Original line number Diff line number Diff line
@@ -27,14 +27,16 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/mdio/mdio-regmap.h>
#include <linux/netdevice.h>
#include <linux/of_device.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/pcs-altera-tse.h>
#include <linux/pcs-lynx.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/skbuff.h>
#include <asm/cacheflush.h>

@@ -1132,13 +1134,16 @@ static int request_and_map(struct platform_device *pdev, const char *name,
static int altera_tse_probe(struct platform_device *pdev)
{
	const struct of_device_id *of_id = NULL;
	struct regmap_config pcs_regmap_cfg;
	struct altera_tse_private *priv;
	struct mdio_regmap_config mrc;
	struct resource *control_port;
	struct regmap *pcs_regmap;
	struct resource *dma_res;
	struct resource *pcs_res;
	struct mii_bus *pcs_bus;
	struct net_device *ndev;
	void __iomem *descmap;
	int pcs_reg_width = 2;
	int ret = -ENODEV;

	ndev = alloc_etherdev(sizeof(struct altera_tse_private));
@@ -1255,12 +1260,32 @@ static int altera_tse_probe(struct platform_device *pdev)
	 * address space, but if it's not the case, we fallback to the mdiophy0
	 * from the MAC's address space
	 */
	ret = request_and_map(pdev, "pcs", &pcs_res,
			      &priv->pcs_base);
	ret = request_and_map(pdev, "pcs", &pcs_res, &priv->pcs_base);
	if (ret) {
		/* If we can't find a dedicated resource for the PCS, fallback
		 * to the internal PCS, that has a different address stride
		 */
		priv->pcs_base = priv->mac_dev + tse_csroffs(mdio_phy0);
		pcs_reg_width = 4;
		pcs_regmap_cfg.reg_bits = 32;
		/* Values are MDIO-like values, on 16 bits */
		pcs_regmap_cfg.val_bits = 16;
		pcs_regmap_cfg.reg_shift = REGMAP_UPSHIFT(2);
	} else {
		pcs_regmap_cfg.reg_bits = 16;
		pcs_regmap_cfg.val_bits = 16;
		pcs_regmap_cfg.reg_shift = REGMAP_UPSHIFT(1);
	}

	/* Create a regmap for the PCS so that it can be used by the PCS driver */
	pcs_regmap = devm_regmap_init_mmio(&pdev->dev, priv->pcs_base,
					   &pcs_regmap_cfg);
	if (IS_ERR(pcs_regmap)) {
		ret = PTR_ERR(pcs_regmap);
		goto err_free_netdev;
	}
	mrc.regmap = pcs_regmap;
	mrc.parent = &pdev->dev;
	mrc.valid_addr = 0x0;

	/* Rx IRQ */
	priv->rx_irq = platform_get_irq_byname(pdev, "rx_irq");
@@ -1384,7 +1409,18 @@ static int altera_tse_probe(struct platform_device *pdev)
			 (unsigned long) control_port->start, priv->rx_irq,
			 priv->tx_irq);

	priv->pcs = alt_tse_pcs_create(ndev, priv->pcs_base, pcs_reg_width);
	snprintf(mrc.name, MII_BUS_ID_SIZE, "%s-pcs-mii", ndev->name);
	pcs_bus = devm_mdio_regmap_register(&pdev->dev, &mrc);
	if (IS_ERR(pcs_bus)) {
		ret = PTR_ERR(pcs_bus);
		goto err_init_pcs;
	}

	priv->pcs = lynx_pcs_create_mdiodev(pcs_bus, 0);
	if (IS_ERR(priv->pcs)) {
		ret = PTR_ERR(priv->pcs);
		goto err_init_pcs;
	}

	priv->phylink_config.dev = &ndev->dev;
	priv->phylink_config.type = PHYLINK_NETDEV;
@@ -1407,12 +1443,13 @@ static int altera_tse_probe(struct platform_device *pdev)
	if (IS_ERR(priv->phylink)) {
		dev_err(&pdev->dev, "failed to create phylink\n");
		ret = PTR_ERR(priv->phylink);
		goto err_init_phy;
		goto err_init_phylink;
	}

	return 0;

err_init_phy:
err_init_phylink:
	lynx_pcs_destroy(priv->pcs);
err_init_pcs:
	unregister_netdev(ndev);
err_register_netdev:
	netif_napi_del(&priv->napi);
@@ -1433,6 +1470,8 @@ static int altera_tse_remove(struct platform_device *pdev)
	altera_tse_mdio_destroy(ndev);
	unregister_netdev(ndev);
	phylink_destroy(priv->phylink);
	lynx_pcs_destroy(priv->pcs);

	free_netdev(ndev);

	return 0;
+3 −0
Original line number Diff line number Diff line
@@ -158,6 +158,9 @@ config DWMAC_SOCFPGA
	default ARCH_INTEL_SOCFPGA
	depends on OF && (ARCH_INTEL_SOCFPGA || COMPILE_TEST)
	select MFD_SYSCON
	select MDIO_REGMAP
	select REGMAP_MMIO
	select PCS_LYNX
	help
	  Support for ethernet controller on Altera SOCFPGA

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ obj-$(CONFIG_DWMAC_IMX8) += dwmac-imx.o
obj-$(CONFIG_DWMAC_TEGRA)	+= dwmac-tegra.o
obj-$(CONFIG_DWMAC_VISCONTI)	+= dwmac-visconti.o
stmmac-platform-objs:= stmmac_platform.o
dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o
dwmac-altr-socfpga-objs := dwmac-socfpga.o

obj-$(CONFIG_STMMAC_PCI)	+= stmmac-pci.o
obj-$(CONFIG_DWMAC_INTEL)	+= dwmac-intel.o
Loading