mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v1 9/9] net: dsa: add support for SJA11xx switches
Date: Mon, 28 Mar 2022 12:40:59 +0200	[thread overview]
Message-ID: <20220328104059.GU12181@pengutronix.de> (raw)
In-Reply-To: <20220321092606.1459834-10-o.rempel@pengutronix.de>

On Mon, Mar 21, 2022 at 10:26:06AM +0100, Oleksij Rempel wrote:
> Port SJA11xx driver from u-boot v2022.04-rc2 to provide support for NXP SJA11xx
> series of switches.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/Kconfig   |   17 +
>  drivers/net/Makefile  |    1 +
>  drivers/net/sja1105.c | 2918 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 2936 insertions(+)
>  create mode 100644 drivers/net/sja1105.c
> 
> +
> +static int sja1105_check_device_id(struct sja1105_private *priv)
> +{
> +	const struct sja1105_regs *regs = priv->info->regs;
> +	u8 packed_buf[SJA1105_SIZE_DEVICE_ID] = {0};
> +	enum sja1105_switch_id id;
> +	u64 device_id;
> +	u64 part_no;
> +	int rc;
> +
> +	rc = sja1105_xfer_buf(priv, SPI_READ, regs->device_id, packed_buf,
> +			      SJA1105_SIZE_DEVICE_ID);
> +	if (rc < 0)
> +		return rc;
> +
> +	sja1105_packing(packed_buf, &device_id, 31, 0, SJA1105_SIZE_DEVICE_ID,
> +			UNPACK);
> +
> +	rc = sja1105_xfer_buf(priv, SPI_READ, regs->prod_id, packed_buf,
> +			      SJA1105_SIZE_DEVICE_ID);
> +	if (rc < 0)
> +		return rc;
> +
> +	sja1105_packing(packed_buf, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID,
> +			UNPACK);
> +
> +	for (id = 0; id < SJA1105_MAX_SWITCH_ID; id++) {
> +		const struct sja1105_info *info = &sja1105_info[id];
> +
> +		/* Is what's been probed in our match table at all? */
> +		if (info->device_id != device_id || info->part_no != part_no)
> +			continue;
> +
> +		/* But is it what's in the device tree? */
> +		if (priv->info->device_id != device_id ||
> +		    priv->info->part_no != part_no) {
> +			printf("Device tree specifies chip %s but found %s, please fix it!\n",
> +			       priv->info->name, info->name);

Replace printf with dev_err throughout this patch,

> +	priv->max_xfer_len = SJA1105_SIZE_SPI_MSG_MAXLEN;
> +	if (priv->max_xfer_len > max_xfer)
> +		priv->max_xfer_len = max_xfer;
> +	if (priv->max_xfer_len > max_msg - SJA1105_SIZE_SPI_MSG_HEADER)
> +		priv->max_xfer_len = max_msg - SJA1105_SIZE_SPI_MSG_HEADER;
> +
> +	rc = sja1105_check_device_id(priv);
> +	if (rc < 0) {
> +		dev_err(dev, "Device ID check failed: %d\n", rc);
> +		return rc;
> +	}
> +
> +	ds = &priv->ds;
> +	ds->dev = dev;
> +	ds->num_ports = sja1105_info[id].num_ports;
> +	ds->ops = &sja1105_dsa_ops;
> +	ds->needed_headroom = VLAN_HLEN;
> +
> +	dsa_register_switch(ds);

Return value should be checked.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2022-03-28 10:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  9:25 [PATCH v1 0/9] add basic DSA support Oleksij Rempel
2022-03-21  9:25 ` [PATCH v1 1/9] net: add RX preprocessor support Oleksij Rempel
2022-03-21  9:25 ` [PATCH v1 2/9] net: add of_find_eth_device_by_node() function Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 3/9] net: add DSA framework to support basic switch functionality Oleksij Rempel
2022-03-25  9:37   ` Oleksij Rempel
2022-03-28 10:31   ` Sascha Hauer
2022-03-28 12:23     ` Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 4/9] driver: add dev_get_priv() helper Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 5/9] net: port part of if_vlan header from kernel v5.17 Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 6/9] spi: port spi_sync_transfer() function " Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 7/9] net: mdio: add MDIO_DEVAD_NONE define Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 8/9] net: phy: make sure MDIO bus is probed if we search for the PHY Oleksij Rempel
2022-03-21  9:26 ` [PATCH v1 9/9] net: dsa: add support for SJA11xx switches Oleksij Rempel
2022-03-28 10:40   ` Sascha Hauer [this message]

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=20220328104059.GU12181@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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