linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, netdev@vger.kernel.org,
	Russell King <linux@armlinux.org.uk>,
	Linus Walleij <linus.walleij@linaro.org>,
	UNGLinuxDriver@microchip.com,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Lee Jones <lee@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Rob Herring <robh+dt@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v3 net-next 13/14] net: dsa: ocelot: add external ocelot switch control
Date: Tue, 27 Sep 2022 23:40:56 +0300	[thread overview]
Message-ID: <20220927204056.xuc7h3xhb2f5znpy@skbuf> (raw)
In-Reply-To: <20220926002928.2744638-14-colin.foster@in-advantage.com> <20220926002928.2744638-14-colin.foster@in-advantage.com>

On Sun, Sep 25, 2022 at 05:29:27PM -0700, Colin Foster wrote:
> Add control of an external VSC7512 chip.
> 
> Currently the four copper phy ports are fully functional. Communication to
> external phys is also functional, but the SGMII / QSGMII interfaces are
> currently non-functional.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
> 
> v3
>     * Remove additional entry in vsc7512_port_modes array
>     * Add MFD_OCELOT namespace import, which is needed for
>       vsc7512_*_io_res

and which hopefully will no longer be

> diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c
> new file mode 100644
> index 000000000000..fb9dbb31fea1
> --- /dev/null
> +++ b/drivers/net/dsa/ocelot/ocelot_ext.c
> @@ -0,0 +1,194 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Copyright 2021-2022 Innovative Advantage Inc.
> + */
> +
> +#include <linux/mfd/ocelot.h>
> +#include <linux/phylink.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <soc/mscc/ocelot.h>
> +#include <soc/mscc/vsc7514_regs.h>
> +#include "felix.h"
> +
> +#define VSC7512_NUM_PORTS		11

Is there a difference in port count between VSC7512 and VSC7514? Nope.
Could you please give naming preference to "vsc7514" for things that are
identical?

> +
> +#define OCELOT_PORT_MODE_SERDES		(OCELOT_PORT_MODE_SGMII | \
> +					 OCELOT_PORT_MODE_QSGMII)
> +
> +static const u32 vsc7512_port_modes[VSC7512_NUM_PORTS] = {
> +	OCELOT_PORT_MODE_INTERNAL,
> +	OCELOT_PORT_MODE_INTERNAL,
> +	OCELOT_PORT_MODE_INTERNAL,
> +	OCELOT_PORT_MODE_INTERNAL,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SERDES,
> +	OCELOT_PORT_MODE_SGMII,
> +};
> +
> +static const u32 *vsc7512_regmap[TARGET_MAX] = {
> +	[ANA] = vsc7514_ana_regmap,
> +	[QS] = vsc7514_qs_regmap,
> +	[QSYS] = vsc7514_qsys_regmap,
> +	[REW] = vsc7514_rew_regmap,
> +	[SYS] = vsc7514_sys_regmap,
> +	[S0] = vsc7514_vcap_regmap,
> +	[S1] = vsc7514_vcap_regmap,
> +	[S2] = vsc7514_vcap_regmap,
> +	[PTP] = vsc7514_ptp_regmap,
> +	[DEV_GMII] = vsc7514_dev_gmii_regmap,
> +};

Isn't this precisely the same as ocelot_regmap from
drivers/net/ethernet/mscc/ocelot_vsc7514.c?

> +
> +static void ocelot_ext_phylink_validate(struct ocelot *ocelot, int port,
> +					unsigned long *supported,
> +					struct phylink_link_state *state)
> +{
> +	struct felix *felix = ocelot_to_felix(ocelot);
> +	struct dsa_switch *ds = felix->ds;
> +	struct dsa_port *dp;
> +
> +	dp = dsa_to_port(ds, port);
> +
> +	phylink_generic_validate(&dp->pl_config, supported, state);

It would be good to transition everybody to phylink_generic_validate(),
now that Sean Anderson's PHY rate matching work was accepted. I haven't
found the time to test this on a LS1028A-QDS board, but I hope I will
soon.

> +}
> +
> +static struct regmap *ocelot_ext_regmap_init(struct ocelot *ocelot,
> +					     const char *name)
> +{
> +	/* In the ocelot-mfd configuration, regmaps are attached to the device
> +	 * by name alone, so dev_get_regmap will return the requested regmap
> +	 * without the need to fully define the resource
> +	 */
> +	return dev_get_regmap(ocelot->dev->parent, name);

As discussed: nope.

> +}
> +
> +static const struct ocelot_ops ocelot_ext_ops = {
> +	.reset		= ocelot_reset,
> +	.wm_enc		= ocelot_wm_enc,
> +	.wm_dec		= ocelot_wm_dec,
> +	.wm_stat	= ocelot_wm_stat,
> +	.port_to_netdev	= felix_port_to_netdev,
> +	.netdev_to_port	= felix_netdev_to_port,
> +};
> +
> +static const struct felix_info vsc7512_info = {
> +	.target_io_res			= vsc7512_target_io_res,
> +	.port_io_res			= vsc7512_port_io_res,
> +	.regfields			= vsc7514_regfields,
> +	.map				= vsc7512_regmap,
> +	.ops				= &ocelot_ext_ops,
> +	.stats_layout			= vsc7514_stats_layout,
> +	.vcap				= vsc7514_vcap_props,
> +	.num_mact_rows			= 1024,
> +	.num_ports			= VSC7512_NUM_PORTS,
> +	.num_tx_queues			= OCELOT_NUM_TC,
> +	.phylink_validate		= ocelot_ext_phylink_validate,
> +	.port_modes			= vsc7512_port_modes,
> +	.init_regmap			= ocelot_ext_regmap_init,
> +};
> +
> +static int ocelot_ext_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct dsa_switch *ds;
> +	struct ocelot *ocelot;
> +	struct felix *felix;
> +	int err;
> +
> +	felix = kzalloc(sizeof(*felix), GFP_KERNEL);
> +	if (!felix)
> +		return -ENOMEM;
> +
> +	dev_set_drvdata(dev, felix);
> +
> +	ocelot = &felix->ocelot;
> +	ocelot->dev = dev;
> +
> +	ocelot->num_flooding_pgids = 1;
> +
> +	felix->info = &vsc7512_info;
> +
> +	ds = kzalloc(sizeof(*ds), GFP_KERNEL);
> +	if (!ds) {
> +		err = -ENOMEM;
> +		dev_err_probe(dev, err, "Failed to allocate DSA switch\n");
> +		goto err_free_felix;
> +	}
> +
> +	ds->dev = dev;
> +	ds->num_ports = felix->info->num_ports;
> +	ds->num_tx_queues = felix->info->num_tx_queues;
> +
> +	ds->ops = &felix_switch_ops;
> +	ds->priv = ocelot;
> +	felix->ds = ds;
> +	felix->tag_proto = DSA_TAG_PROTO_OCELOT;
> +
> +	err = dsa_register_switch(ds);
> +	if (err) {
> +		dev_err_probe(dev, err, "Failed to register DSA switch\n");
> +		goto err_free_ds;
> +	}
> +
> +	return 0;
> +
> +err_free_ds:
> +	kfree(ds);
> +err_free_felix:
> +	kfree(felix);
> +	return err;
> +}
> +
> +static int ocelot_ext_remove(struct platform_device *pdev)
> +{
> +	struct felix *felix = dev_get_drvdata(&pdev->dev);
> +
> +	if (!felix)
> +		return 0;
> +
> +	dsa_unregister_switch(felix->ds);
> +
> +	kfree(felix->ds);
> +	kfree(felix);
> +
> +	dev_set_drvdata(&pdev->dev, NULL);

The pattern was changed again, so can you please delete this line now,
to be in sync with the other drivers?
https://patchwork.kernel.org/project/netdevbpf/patch/20220921140524.3831101-12-yangyingliang@huawei.com/

> +
> +	return 0;
> +}
> +
> +static void ocelot_ext_shutdown(struct platform_device *pdev)
> +{
> +	struct felix *felix = dev_get_drvdata(&pdev->dev);
> +
> +	if (!felix)
> +		return;
> +
> +	dsa_switch_shutdown(felix->ds);
> +
> +	dev_set_drvdata(&pdev->dev, NULL);
> +}
> +
> +static const struct of_device_id ocelot_ext_switch_of_match[] = {
> +	{ .compatible = "mscc,vsc7512-switch" },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, ocelot_ext_switch_of_match);
> +
> +static struct platform_driver ocelot_ext_switch_driver = {
> +	.driver = {
> +		.name = "ocelot-switch",
> +		.of_match_table = of_match_ptr(ocelot_ext_switch_of_match),
> +	},
> +	.probe = ocelot_ext_probe,
> +	.remove = ocelot_ext_remove,
> +	.shutdown = ocelot_ext_shutdown,
> +};
> +module_platform_driver(ocelot_ext_switch_driver);
> +
> +MODULE_DESCRIPTION("External Ocelot Switch driver");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(MFD_OCELOT);
> -- 
> 2.25.1
> 


  reply	other threads:[~2022-09-27 20:41 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26  0:29 [PATCH v3 net-next 00/14] add support for the the vsc7512 internal copper phys Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 01/14] net: mscc: ocelot: expose ocelot wm functions Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 02/14] net: mscc: ocelot: expose regfield definition to be used by other drivers Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 03/14] net: mscc: ocelot: expose stats layout " Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 04/14] net: mscc: ocelot: expose vcap_props structure Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 05/14] net: mscc: ocelot: expose ocelot_reset routine Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 06/14] net: dsa: felix: add configurable device quirks Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 07/14] net: dsa: felix: populate mac_capabilities for all ports Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 08/14] net: dsa: felix: update init_regmap to be string-based Colin Foster
2022-09-27 17:53   ` Vladimir Oltean
2022-09-27 18:43     ` Colin Foster
2022-09-27 18:56       ` Vladimir Oltean
2022-09-26  0:29 ` [PATCH v3 net-next 09/14] pinctrl: ocelot: avoid macro redefinition Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 10/14] mfd: ocelot: prepend resource size macros to be 32-bit Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 11/14] mfd: ocelot: add regmaps for ocelot_ext Colin Foster
2022-09-27 21:04   ` Vladimir Oltean
2022-09-27 23:01     ` Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 12/14] dt-bindings: net: dsa: ocelot: add ocelot-ext documentation Colin Foster
2022-09-27 20:26   ` Vladimir Oltean
2022-09-27 22:20     ` Colin Foster
2022-10-07 22:48       ` Vladimir Oltean
2022-10-08 17:56         ` Colin Foster
2022-09-30 21:15     ` Colin Foster
2022-10-01  0:20       ` Colin Foster
2022-10-03 15:28         ` Vladimir Oltean
2022-10-07 20:44     ` Colin Foster
2022-10-07 22:38       ` Vladimir Oltean
2022-10-04 11:19   ` Krzysztof Kozlowski
2022-10-04 12:15     ` Vladimir Oltean
2022-10-04 14:59       ` Krzysztof Kozlowski
2022-10-04 16:01         ` Vladimir Oltean
2022-10-05  8:09           ` Krzysztof Kozlowski
2022-10-07 23:10             ` Vladimir Oltean
2022-10-09 15:49               ` Krzysztof Kozlowski
2022-10-05  0:08     ` Colin Foster
2022-10-05  8:03       ` Krzysztof Kozlowski
2022-10-05 15:44         ` Colin Foster
2022-10-05 16:09           ` Krzysztof Kozlowski
2022-10-08  0:00             ` Vladimir Oltean
2022-10-09 16:14               ` Krzysztof Kozlowski
2022-10-10 13:07                 ` Vladimir Oltean
2022-10-10 13:37                   ` Krzysztof Kozlowski
2022-10-10 17:48                     ` Vladimir Oltean
2022-10-10 18:47                       ` Colin Foster
2022-10-10 19:11                         ` Vladimir Oltean
2022-10-11  9:53                         ` Vladimir Oltean
2023-01-18 22:28                       ` Colin Foster
2023-01-19 20:21                         ` Vladimir Oltean
2023-01-20 18:16                           ` Colin Foster
2022-09-26  0:29 ` [PATCH v3 net-next 13/14] net: dsa: ocelot: add external ocelot switch control Colin Foster
2022-09-27 20:40   ` Vladimir Oltean [this message]
2022-09-26  0:29 ` [PATCH v3 net-next 14/14] mfd: " Colin Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220927204056.xuc7h3xhb2f5znpy@skbuf \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).