linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: linux-kernel@vger.kernel.org,
	Amarula patchwork <linux-amarula@amarulasolutions.com>,
	michael@amarulasolutions.com,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 4/4] can: bxcan: add support for single peripheral configuration
Date: Sun, 23 Apr 2023 21:16:54 +0200	[thread overview]
Message-ID: <20230423-surplus-spoon-4e8194434663-mkl@pengutronix.de> (raw)
In-Reply-To: <20230423172528.1398158-5-dario.binacchi@amarulasolutions.com>

[-- Attachment #1: Type: text/plain, Size: 2516 bytes --]

On 23.04.2023 19:25:28, Dario Binacchi wrote:
> Add support for bxCAN controller in single peripheral configuration:
> - primary bxCAN
> - dedicated Memory Access Controller unit
> - 512-byte SRAM memory
> - 14 fiter banks
> 
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> ---
> 
>  drivers/net/can/bxcan.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/bxcan.c b/drivers/net/can/bxcan.c
> index e26ccd41e3cb..9bcbbb85da6e 100644
> --- a/drivers/net/can/bxcan.c
> +++ b/drivers/net/can/bxcan.c
> @@ -155,6 +155,7 @@ struct bxcan_regs {
>  	u32 reserved0[88];		/* 0x20 */
>  	struct bxcan_mb tx_mb[BXCAN_TX_MB_NUM];	/* 0x180 - tx mailbox */
>  	struct bxcan_mb rx_mb[BXCAN_RX_MB_NUM];	/* 0x1b0 - rx mailbox */
> +	u32 reserved1[12];		/* 0x1d0 */
>  };
>  
>  struct bxcan_priv {
> @@ -922,6 +923,12 @@ static int bxcan_get_berr_counter(const struct net_device *ndev,
>  	return 0;
>  }
>  
> +static const struct regmap_config bxcan_gcan_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +};
> +
>  static int bxcan_probe(struct platform_device *pdev)
>  {
>  	struct device_node *np = pdev->dev.of_node;
> @@ -942,11 +949,18 @@ static int bxcan_probe(struct platform_device *pdev)
>  
>  	gcan = syscon_regmap_lookup_by_phandle(np, "st,gcan");
>  	if (IS_ERR(gcan)) {
> -		dev_err(dev, "failed to get shared memory base address\n");
> -		return PTR_ERR(gcan);
> +		primary = true;
> +		gcan = devm_regmap_init_mmio(dev,
> +					     regs + sizeof(struct bxcan_regs),
> +					     &bxcan_gcan_regmap_config);
> +		if (IS_ERR(gcan)) {
> +			dev_err(dev, "failed to get filter base address\n");
> +			return PTR_ERR(gcan);
> +		}

This probably works. Can we do better, i.e. without this additional code?

If you add a syscon node for the single instance CAN, too, you don't
need a code change here, right?

> +	} else {
> +		primary = of_property_read_bool(np, "st,can-primary");
>  	}
>  
> -	primary = of_property_read_bool(np, "st,can-primary");
>  	clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(clk)) {
>  		dev_err(dev, "failed to get clock\n");

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-04-23 19:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 17:25 [PATCH 0/4] can: bxcan: add support for single peripheral configuration Dario Binacchi
2023-04-23 17:25 ` [PATCH 4/4] " Dario Binacchi
2023-04-23 19:16   ` Marc Kleine-Budde [this message]
2023-04-24  6:56     ` Dario Binacchi
2023-04-24 10:06       ` Marc Kleine-Budde
2023-04-25 20:10         ` Dario Binacchi
2023-04-24 13:03   ` Simon Horman
     [not found] ` <20230423172528.1398158-2-dario.binacchi@amarulasolutions.com>
     [not found]   ` <20230424090229.GB8035@google.com>
2023-05-17 14:16     ` [PATCH 1/4] dt-bindings: mfd: stm32f7: add binding definition for CAN3 Marc Kleine-Budde
2023-05-17 15:23       ` Krzysztof Kozlowski
2023-05-17 18:21         ` Marc Kleine-Budde

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=20230423-surplus-spoon-4e8194434663-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@amarulasolutions.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wg@grandegger.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).