Message ID | 20230423172528.1398158-5-dario.binacchi@amarulasolutions.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2297034vqo; Sun, 23 Apr 2023 10:30:34 -0700 (PDT) X-Google-Smtp-Source: AKy350a0Sj2SfJmVB+xvnFvfosyvNFIFy3I+xbKP2CU0sByHyjlPAJqjcEg4K1U4G3GOz4/ABAEr X-Received: by 2002:a17:903:27c7:b0:1a6:a8e5:9240 with SMTP id km7-20020a17090327c700b001a6a8e59240mr10365527plb.4.1682271033737; Sun, 23 Apr 2023 10:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682271033; cv=none; d=google.com; s=arc-20160816; b=zhTWb8/7XX/mT1D/HDWPG168wBa7ZvpdIETBxbHQHBH1s6lmqFn7TK7MjH3e2r9z9x pisHd9rJ2LJdEFkMy5PQaXl8F46bPxxgQhQwL7pw4kfwIMkXKQ6rxJBFVdLcAi2ogX+s vDAZJ0bvOX/HqA6fIFEULoD+JHumoIUBScW2Mzv86sA0HN350eYbDj9iMw1Cv2Wb/3Nb TN1kFuLXaEglpUiEm7gdUsgg6Zu4Fe+ObHZC6beizXCiM7l177eIkyZ0AU6td7UoFymR iGqpTIBQBDXLYtLXmX5L7zXxTUXPN7Grf8fsUtFfBFaEgsmLvfESclXPY6UZOTMooKzL QvXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MbxDPqhzMCS7xX3Keeglii9B+3fU/m4LAIoQKCOvlGw=; b=RRkrYVcZq8rq6HjxklZ3b4qaoRQ35ku+MAdeerTQ3kfBzGNxeNBT2E4Nf++zK5y5Vv vYERZY+kM6ZhYMmwiHFM9psvPG2Lphu9H0hAoGtsW/P+R7i8NG1w2e8yh6+zucAqutyx kei4Jjbh2ofc5D+xaqRowMfMdmyYnkYri6rufEoSojjhLzMZx2WswP1C4rtvGavuMzmX zFPDRtSmzGuGi5s1v4bzKDWUy+ojDZhPr2+wWOcoSgwvOM3MnPpnZI61exhf3CPjkfVA gqfXDbZig0x/27oIqBfCL8Wd7jnkNGCuu72AYUUmSjjPsxeMfiXwX/hgTd6UCMBsJ9HT j+gQ== 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 linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170902654c00b001a6db2bef24si8892050pln.145.2023.04.23.10.30.21; Sun, 23 Apr 2023 10:30:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kFx5aT3Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjDWR0A (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Sun, 23 Apr 2023 13:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjDWRZs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 23 Apr 2023 13:25:48 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 261AB10DF for <linux-kernel@vger.kernel.org>; Sun, 23 Apr 2023 10:25:47 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f1957e80a2so53999705e9.1 for <linux-kernel@vger.kernel.org>; Sun, 23 Apr 2023 10:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1682270745; x=1684862745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MbxDPqhzMCS7xX3Keeglii9B+3fU/m4LAIoQKCOvlGw=; b=kFx5aT3ZHShtKXQkjX5bjO1mltO6ghMp7YmjXd5ZNvN76bvrP2gL4pOSBoqLeReB8G zeWLvoIy3pGRjaBg8ippvtE2ncmlfWQ4TADwU81Z+/hoRM/Bogq1AjHFchGRzH+I/e4P WZ8/UXVNRta+9EMAFm/75ZgVx4u7w4Zq4Gm40= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682270745; x=1684862745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbxDPqhzMCS7xX3Keeglii9B+3fU/m4LAIoQKCOvlGw=; b=NlffK9E0bFFMSG01zHH9JEysSO2Osyz7lBqzICQa6UdfazqcPoTXOQ03z8K+/W+bo7 eMvo5IgTu0Lbj8x0Kdx+t7X2+Mwd1kQ5jiP+IEOjFUbmWnTCoeBeojubesLIqkmcpxR1 KHjC6M4+SM+5VxBHIxu/NzEErNjG81lhFVq/FMfPx1Jh4lNIJX7slo7Y+jn9QPK8V7ET vlDXFDt5fyrm/ZGFzuhstlY9u6luFqY3SiTaMCTz9PI0SRYXx6uUt3xfS+Xjbtp1K72B OjH/lyFOq+5CEEOV34zLHxi9AehxcsvyIyy7gvEWTjgQgGIomwyZrquod5ZthGrHza7q fZag== X-Gm-Message-State: AAQBX9ebu4ozBn7w4sIEQjhWXEfiADm5lRvNe++hXUSDsDOLYC/ajlj8 kjn9sMxj2WqsFDbLxRY++qFiAemo9In7zq0EI+LecQ== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763989031503190244?= X-GMAIL-MSGID: =?utf-8?q?1763989031503190244?= |
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");