| Message ID | 20230423172528.1398158-5-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBCQ4XFG47UFRBGWUSWRAMGQESIWVSEA@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 38DAE3F259 for <linux-amarula@patchwork.amarulasolutions.com>; Sun, 23 Apr 2023 19:25:47 +0200 (CEST) Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f1763fac8bsf22307825e9.1 for <linux-amarula@patchwork.amarulasolutions.com>; Sun, 23 Apr 2023 10:25:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682270747; cv=pass; d=google.com; s=arc-20160816; b=jqn7U5i5nN+wA+oCMTK1jnfzuYH3ohM9U553f9tC2FO3VAUcLdauWe2xZChP2zMq9z HRJB6tCu5X+IG2FMOuosU1eIIdasoZh6Z+LtzGeiauKqI9pd4AtsSU2o276I+qeqrpkR 4IOHdvru87i4hRCaFy5X49pp3kb7rLZBuhoO9N6HJzNIc9D6YD1xBEuCfyCzSRhPXYPF UcGLR4kPIBhBasYo8+OoWOXPaNWBbgAIhzFut5Z6Azsy6SluU/v69tAfhJn6gvFNW3b5 QnjYAtxOfUGKIJ57djSJG+73KJ2zUwiSq7eQ1Qt2o4j5AuE10VSQCmbEi1+BkIT5W5uX Vg4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8BHpNH16XOUtq1X9NBUP5kWQ6oRpll83eugmsLKTG/c=; b=NC+m8ZQDvdIuiXKrsezXGOCYjSPA9stkobGRcsMDGBkJmUqVIW+Us82f9EbLxNU8iJ K4zUgkxCIuUA1X0dTPahOQUStL2flfpCayF3M9gAg1WLf7ufhuZRrW7Ll0sczNDWYDI8 ElVejt0JNSjPu6+Nlf84gikPgattEEUxQE9eOfez9nnj81V9P+JEJRUPiBuAr1cGRRas 19xVor9jJ4x3oJTmX6cjnDxvWGO7p6pGQ6LMcLMReWmURf5N6/CqYa5V26JO80JJmiu/ 5QY+mqCHbuXmDoZbYbTnD+7iPV8RkxAtimGuplSAb7nRmt1i5B5ONU8U3D76r4sed//v /ddQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFx5aT3Z; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1682270747; x=1684862747; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=8BHpNH16XOUtq1X9NBUP5kWQ6oRpll83eugmsLKTG/c=; b=EyKteoQtdP+wNYqf0Jgwphhvqi1TsT10GL9rftS9V9NkWDKxdCer4jE2omGqEu87/4 79MBMPD5zA46Dmm6TbvH8JOkbRSa56DFdjzHOgIgVEkvysQdMOhi39ZIzBJQUVETpLJq s3QEYJ3GU+fxiPAOMpYhpWEYb9AM0bCoHKm5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682270747; x=1684862747; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8BHpNH16XOUtq1X9NBUP5kWQ6oRpll83eugmsLKTG/c=; b=CrrST22p/QftRu5J9ejR+BX1IpEGGf19Za7c71YI0fdHf34goixVl/3UcyymYy3uES fxx0ez6DqwlB14SHmPPNzHWywgHWoyVvZXBzBpr+Xm9KpOgKfpi6AzzTa9dHL93NnAMU ef4LozL7Hw3BCw/hclIo+5h5eIzcn4ptKQpkW295NA/z2WwXSeXqH/lEEs1wAMIy2vxa D98VY5E+XLjawj74YZDbZdnpLgSER6i4qMSFwIq/Oq/jXpXopKqZ4tNX42XmrZkJyN04 gigsnTzKZ/+hEJmUbQHmqNVrJLGi3xp1iaG+X2qJ5C3tFmPJhoDk4pVAkLJMvLQ9enhG 1C+g== X-Gm-Message-State: AAQBX9dRhrL5PxRLwOG5D1LApNvYJyRcPHTjVANsHN3nZ3ax9GnAh7Ua PZwzZWYCixs5daFWeVKFCZrL4uCU X-Google-Smtp-Source: AKy350YsSU98p717Cze7p0Y1v8YzCnB15MK/y/YIrfahC0mR+PZt4ujXm6SCNGiF0qJkx/OXlAswGQ== X-Received: by 2002:a1c:ed07:0:b0:3f1:72ec:4011 with SMTP id l7-20020a1ced07000000b003f172ec4011mr1574780wmh.2.1682270747007; Sun, 23 Apr 2023 10:25:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:1c27:b0:3f1:758c:dd3a with SMTP id j39-20020a05600c1c2700b003f1758cdd3als6204847wms.1.-pod-canary-gmail; Sun, 23 Apr 2023 10:25:45 -0700 (PDT) X-Received: by 2002:a05:600c:b99:b0:3f1:7619:f0f6 with SMTP id fl25-20020a05600c0b9900b003f17619f0f6mr6379551wmb.9.1682270745459; Sun, 23 Apr 2023 10:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682270745; cv=none; d=google.com; s=arc-20160816; b=wGwxELbXYM/Zoqz1X6dhvgVeXedU4VZ1+ar+N5fK+Gn6v1ah1mB5T7tGLeazUkWw02 rE6801hT6NSaCCZ7EWDxIT7fy97uo11PQd3HKTnrvLExKPS5N7ezTWCIISSu2HxP9q3+ V44yP5vJXD5/Xdz0wHD2SIUumSQzTgnxfWdU52Ftyk1sEJkjRcuaMDbMVRzp4mgEjCYU 543otPDjuFrQveIeMcse0MfP0Il8fwRDwboiWxXETuMPuC9ziNidD8+owy6OvzD/2EVs Dj/aa++Cnz/W6RWthLt/gsvYJgk1EqcNu+AjvgaBGAlO4w9NnENtfe97kMDhM8sonQhl p38Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MbxDPqhzMCS7xX3Keeglii9B+3fU/m4LAIoQKCOvlGw=; b=lba2NaJ19Js543KOcnAOWgi8XI2L+n/ZGxixhrBKxM1RPzs+knWcIuLbyw+xc4s614 1SL0xS6qiS8usn7fPiD4SoA924/WDIczwMOcOAs7e4lrD1Mveq2yS4g2lMaFuHge1EGB He2ZzKZ7ppOa1iIBS5EJ4f7ZmqAyri9A66i1Lqm6Q64FPMwe7Xy4/RbzON5EmwnohWLJ 8u1/PuWby+f2bSbuq60m+bHs3xX2jGlNgLA2w2IGoZQ5GulNMxPFmEPo79D8RGzncC+C qWkSwzdfZB3QjXXsoki0+nmNO+BKENEGP724AYxOE1jaMYR4O0/bTc1/xBezfZsI6XJr lARg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFx5aT3Z; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id o7-20020a05600c378700b003f175d0615csor3190912wmr.44.2023.04.23.10.25.45 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Sun, 23 Apr 2023 10:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a1c:e904:0:b0:3ed:3268:5f35 with SMTP id q4-20020a1ce904000000b003ed32685f35mr6156037wmc.18.1682270745255; Sun, 23 Apr 2023 10:25:45 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([37.159.119.249]) by smtp.gmail.com with ESMTPSA id j32-20020a05600c1c2000b003f173987ec2sm13511653wms.22.2023.04.23.10.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 10:25:44 -0700 (PDT) From: Dario Binacchi <dario.binacchi@amarulasolutions.com> To: linux-kernel@vger.kernel.org Cc: Amarula patchwork <linux-amarula@amarulasolutions.com>, michael@amarulasolutions.com, Dario Binacchi <dario.binacchi@amarulasolutions.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Marc Kleine-Budde <mkl@pengutronix.de>, Paolo Abeni <pabeni@redhat.com>, Wolfgang Grandegger <wg@grandegger.com>, linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 4/4] can: bxcan: add support for single peripheral configuration Date: Sun, 23 Apr 2023 19:25:28 +0200 Message-Id: <20230423172528.1398158-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230423172528.1398158-1-dario.binacchi@amarulasolutions.com> References: <20230423172528.1398158-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFx5aT3Z; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
can: bxcan: add support for single peripheral configuration
|
|
Commit Message
Dario Binacchi
April 23, 2023, 5:25 p.m. UTC
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(-)
Comments
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
Hi Marc, On Sun, Apr 23, 2023 at 9:16 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote: > > 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? I think so. I have only one doubt about it. This implementation allows, implicitly, to distinguish if the peripheral is in single configuration (without handle to the gcan node) or in double configuration (with handle to the gcan node). For example, in single configuration the peripheral has 14 filter banks, while in double configuration there are 26 shared banks. Without code changes, this kind of information is lost. Is it better then, for future developments, to add a new boolean property to the can node of the dts (e.g. single-conf)? Thanks and regards, Dario > > > + } 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 |
On 24.04.2023 08:56:03, Dario Binacchi wrote: > > 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? > > I think so. > > I have only one doubt about it. This implementation allows, > implicitly, to distinguish if the peripheral is in single > configuration (without handle to the gcan node) or in double > configuration (with handle to the gcan node). For example, in single > configuration the peripheral has 14 filter banks, while in double > configuration there are 26 shared banks. Without code changes, this > kind of information is lost. Is it better then, for future > developments, to add a new boolean property to the can node of the dts > (e.g. single-conf)? The DT ist not yet mainline, so we can still change it. Another option is to have "st,can-primary" and "st,can-secondary" for the shared peripherals and nothing for the single instance. regards, Marc
On Sun, Apr 23, 2023 at 07:25:28PM +0200, 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 nit: s/fiter/filter/ ?
Hi Marc, On Mon, Apr 24, 2023 at 12:06 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote: > > On 24.04.2023 08:56:03, Dario Binacchi wrote: > > > 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? > > > > I think so. > > > > I have only one doubt about it. This implementation allows, > > implicitly, to distinguish if the peripheral is in single > > configuration (without handle to the gcan node) or in double > > configuration (with handle to the gcan node). For example, in single > > configuration the peripheral has 14 filter banks, while in double > > configuration there are 26 shared banks. Without code changes, this > > kind of information is lost. Is it better then, for future > > developments, to add a new boolean property to the can node of the dts > > (e.g. single-conf)? > > The DT ist not yet mainline, so we can still change it. Another option > is to have "st,can-primary" and "st,can-secondary" for the shared > peripherals and nothing for the single instance. I did some tests following your suggestion. It is however necessary to make some small changes to the driver. I will send v2 as soon as possible. Thanks and regards, Dario > > regards, > 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 |
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); + } + } 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");