[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250522-arrogant-delicate-jaguar-ca53b6-mkl@pengutronix.de>
Date: Thu, 22 May 2025 11:21:54 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Elaine Zhang <zhangqing@...k-chips.com>
Cc: kernel@...gutronix.de, mailhol.vincent@...adoo.fr, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, heiko@...ech.de, cl@...k-chips.com,
kever.yang@...k-chips.com, linux-can@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v4 2/3] net: can: rockchip: add can for RK3576 Soc
On 22.05.2025 15:46:15, Elaine Zhang wrote:
> Is new controller:
> Support CAN and CANFD protocol.
> Support Dma.
>
> Signed-off-by: Elaine Zhang <zhangqing@...k-chips.com>
> ---
Looking at the rkcanfd_probe() only for now.
> static int rkcanfd_probe(struct platform_device *pdev)
> {
> struct rkcanfd_priv *priv;
> struct net_device *ndev;
> + struct resource *res;
> const void *match;
> - int err;
> + int err, val;
>
> ndev = alloc_candev(sizeof(struct rkcanfd_priv), RKCANFD_TXFIFO_DEPTH);
> if (!ndev)
> @@ -883,6 +1396,7 @@ static int rkcanfd_probe(struct platform_device *pdev)
> goto out_free_candev;
> }
>
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> priv->regs = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(priv->regs)) {
> err = PTR_ERR(priv->regs);
> @@ -912,13 +1426,46 @@ static int rkcanfd_probe(struct platform_device *pdev)
> priv->can.do_set_mode = rkcanfd_set_mode;
> priv->can.do_get_berr_counter = rkcanfd_get_berr_counter;
> priv->ndev = ndev;
> + priv->dev = &pdev->dev;
>
> match = device_get_match_data(&pdev->dev);
> if (match)
> priv->devtype_data = *(struct rkcanfd_devtype_data *)match;
>
> + if (device_property_read_u32(&pdev->dev, "rockchip,auto-retx-cnt", &val))
> + priv->auto_retx_cnt = 0;
> + else
> + priv->auto_retx_cnt = val;
What does "rockchip,auto-retx-cnt" do?
> + if (priv->auto_retx_cnt > RK3576CANFD_RETX_TIME_LIMIT_CNT_MAX)
> + priv->auto_retx_cnt = RK3576CANFD_RETX_TIME_LIMIT_CNT_MAX;
> +
> + /* rx-max-data only 4 Words or 18 words are supported */
> + if (device_property_read_u32_array(&pdev->dev, "rockchip,rx-max-data", &val, 1))
> + priv->rx_max_data = 18;
> + else
> + priv->rx_max_data = val;
What does "rockchip,rx-max-data" do?
> + if (priv->rx_max_data != 4 && priv->rx_max_data != 18) {
> + priv->rx_max_data = 18;
> + dev_warn(&pdev->dev, "rx_max_data is invalid, set to 18 words!\n");
> + }
> + priv->rx_fifo_depth = RK3576CANFD_SRAM_MAX_DEPTH / priv->rx_max_data;
> +
> + priv->rxchan = dma_request_chan(&pdev->dev, "rx");
> + if (IS_ERR(priv->rxchan)) {
> + dev_warn(&pdev->dev, "Failed to request rxchan\n");
> + priv->rxchan = NULL;
> + priv->use_dma = 0;
> + } else {
> + priv->rx_dma_src_addr = res->start + RK3576CANFD_REG_RXFRD;
> + priv->dma_size = priv->rx_max_data * 4;
> + priv->use_dma = 1;
> + }
> + if (priv->use_dma)
> + rk3576_canfd_dma_init(priv);
> +
> err = can_rx_offload_add_manual(ndev, &priv->offload,
> - RKCANFD_NAPI_WEIGHT);
> + MAX(RKCANFD_NAPI_WEIGHT, priv->rx_fifo_depth));
> if (err)
> goto out_free_candev;
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 |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists