From patchwork Sat Jul 15 11:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13314471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6055FC001B0 for ; Sat, 15 Jul 2023 11:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RhtOLY0/TIKQ0WQHafJFTNpQ/PKsUyI/cb6F/sVRry4=; b=qHMAbkQi78CwRy Xy7/57xEwMSBS7pv4iBUpviVJarOaB2yf1jSwIzDIzguZiC2fWHxSvOc2OFqBgVRAif/1xIyBbmYk e/kShjcjYIQrDqn3HgNkGGkmwkHXTDwn/ROCJd1H2gSgyS9YRiZWoNDO3nodccHqd6OKs0LzrKAdo +ram4m8Ia8MaaPgsOcIQXwANP9wn7EFQnagX2wkMVp6qYs9P2msZ9/GMhtWin21zKwrmvDvl4AFZm egNyt4mKc8FF5k0R8FR7AaksdBRaUX5QnZXSaPVht5MMKUyydx4fetjUAChdJmSE9DXSLgU2h7QM/ vZ+pHnZ244ice1724QjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPM-008Z25-05; Sat, 15 Jul 2023 11:25:52 +0000 Received: from out-15.mta1.migadu.com ([2001:41d0:203:375::f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPJ-008Z0c-1b for linux-riscv@lists.infradead.org; Sat, 15 Jul 2023 11:25:50 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1689420347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwGDE3yVIxPwsfY7daqG3Fg4YYN3E6U2TSbdOoNGr2c=; b=qij1kjnFwoJdPsm8qHKTlc+hKlEqw0z6iH0/AKScKt/SNRm2MnIEdugATrTQV7XEoY5Tyu awM9uAT0Ja7GYNRqt0zuQlHylvACAggWDBFPsJIwUrUZbxOQ9vc9SdXq3ujOjIHN9Bo9DI M/myL22XbVD07cjWzndjI7gDUjVTO9fTWwWey3fzAhsKK0TxLAYBGnlQ1sMxnE7Gk/MNUZ quj/oLQsJH/RdpMIxzLy46NJAzzMZNvN9QnKf+hzKzBD5ZG+hoIO7zwvKfR6SB0yYY+tBh pH8hqw5zSR7xDca8eOIBM8nKZM4TOe8upoWE5Qw7HYXyJbZGxN7tJ7KhITGS4A== From: Jookia To: linux-sunxi@lists.linux.dev Cc: John Watts , devicetree@vger.kernel.org, linux-can@vger.kernel.org, linux-riscv@lists.infradead.org, Fabien Poussin , Samuel Holland , Jernej Skrabec , Chen-Yu Tsai Subject: [PATCH 1/4] dt-bindings: net: can: Add support for Allwinner D1 CAN controller Date: Sat, 15 Jul 2023 21:25:19 +1000 Message-ID: <20230715112523.2533742-2-contact@jookia.org> In-Reply-To: <20230715112523.2533742-1-contact@jookia.org> References: <20230715112523.2533742-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230715_042549_681171_B6E52CCC X-CRM114-Status: UNSURE ( 7.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: John Watts The Allwinner D1 has two CAN controllers, both a variant of the R40 controller. Unfortunately the registers for the D1 controllers are moved around enough to be incompatible and require a new compatible. Introduce the "allwinner,sun20i-d1-can" compatible to support this. Signed-off-by: John Watts --- .../bindings/net/can/allwinner,sun4i-a10-can.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/allwinner,sun4i-a10-can.yaml b/Documentation/devicetree/bindings/net/can/allwinner,sun4i-a10-can.yaml index 9c494957a07a..e42ea28d6ab4 100644 --- a/Documentation/devicetree/bindings/net/can/allwinner,sun4i-a10-can.yaml +++ b/Documentation/devicetree/bindings/net/can/allwinner,sun4i-a10-can.yaml @@ -21,6 +21,7 @@ properties: - const: allwinner,sun4i-a10-can - const: allwinner,sun4i-a10-can - const: allwinner,sun8i-r40-can + - const: allwinner,sun20i-d1-can reg: maxItems: 1 @@ -37,8 +38,9 @@ properties: if: properties: compatible: - contains: - const: allwinner,sun8i-r40-can + enum: + - allwinner,sun8i-r40-can + - allwinner,sun20i-d1-can then: required: From patchwork Sat Jul 15 11:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13314472 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5BA34C001DE for ; Sat, 15 Jul 2023 11:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h4L5RWc9frydcv/jdSSJqHyPVtbQl68CV7WY6RwY2ys=; b=kowvcFgwviz0lJ PccgNf98PbPzH0VaytYG5Z+cvEswkVMokcaflZkuQcDLXPLsK27szXyLut4RFr4MnVpkOgCl6suiM QEwKr1nxoJkhexoh6JbOXhnhUJu4NTe49l6GuF1FtnsGDocT4DP59hShe3Yj+udRLLf4jX9+40PnO 1D7IeBg9l/VKAsr9pXnEHK8kbCYKr8idxRDaRhcSjuoKwiax0/6/2H8OOHZlfOe1UXdptgVcLTX30 Pv9VCqwVGA3sbYeUY7nf8EUaEq+HDJVaZsh7bDAxASGCV7K4NMSi9GMnoc62lEYy39wymgMBoNnN1 ycDnETcCwUSLEShJdVhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPY-008Z5T-2p; Sat, 15 Jul 2023 11:26:04 +0000 Received: from out-39.mta0.migadu.com ([2001:41d0:1004:224b::27]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPW-008Z3b-1j for linux-riscv@lists.infradead.org; Sat, 15 Jul 2023 11:26:03 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1689420356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Je1IK6lfysTXxuDNeexeifoUO9/0LoHKaSsEoi0nLA=; b=qjycuv7C8MM478tu7GZ1iqbtbkEH02oqYIe20ph/cC2vFNuIxx52ibutHnTswTA4rQLA8I SsFzX6UX0QW6GYj8F2KcCuLrIaAUjvEEEyy9okx6KhDymZuFjSaJUyYXN7KGvt7qAFLT3q oyjtrZ6w7jXwzXWmG2cIghULR3qyVuFa7G46ocL0A2F3teNFe83XRvCaYt//6g/JOHq27y SnItJKe0g0v0tcURmWZLayi7iiK1q00R5S9otEUbzcQtKm1IFZIA6uoywdccEfu8lzFawV g1lTX62UuAZ1Z/WMNXDDZJKNSoEbHohkPD2kQDqby6emGFu7c2UJv6XxSXtW3w== From: Jookia To: linux-sunxi@lists.linux.dev Cc: John Watts , devicetree@vger.kernel.org, linux-can@vger.kernel.org, linux-riscv@lists.infradead.org, Fabien Poussin , Samuel Holland , Jernej Skrabec , Chen-Yu Tsai Subject: [PATCH 2/4] riscv: dts: allwinner: d1: Add CAN controller nodes Date: Sat, 15 Jul 2023 21:25:20 +1000 Message-ID: <20230715112523.2533742-3-contact@jookia.org> In-Reply-To: <20230715112523.2533742-1-contact@jookia.org> References: <20230715112523.2533742-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230715_042602_718347_E1CE8006 X-CRM114-Status: UNSURE ( 7.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: John Watts The Allwinner D1, T113 provide two CAN controllers that are variants of the R40 controller. I have tested support for these controllers on two boards: - A Lichee Panel RV 86 Panel running a D1 chip - A Mango Pi MQ Dual running a T113-s3 chip Both of these fully support both CAN controllers. Signed-off-by: John Watts --- .../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi index 1bb1e5cae602..b185398334be 100644 --- a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +++ b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi @@ -131,6 +131,18 @@ uart3_pb_pins: uart3-pb-pins { pins = "PB6", "PB7"; function = "uart3"; }; + + /omit-if-no-ref/ + can0_pins: can0_pins { + pins = "PB2", "PB3"; + function = "can0"; + }; + + /omit-if-no-ref/ + can1_pins: can1_pins { + pins = "PB4", "PB5"; + function = "can1"; + }; }; ccu: clock-controller@2001000 { @@ -879,5 +891,23 @@ rtc: rtc@7090000 { clock-names = "bus", "hosc", "ahb"; #clock-cells = <1>; }; + + can0: can@2504000 { + compatible = "allwinner,sun20i-d1-can"; + reg = <0x02504000 0x400>; + interrupts = ; + clocks = <&ccu CLK_BUS_CAN0>; + resets = <&ccu RST_BUS_CAN0>; + status = "disabled"; + }; + + can1: can@2504400 { + compatible = "allwinner,sun20i-d1-can"; + reg = <0x02504400 0x400>; + interrupts = ; + clocks = <&ccu CLK_BUS_CAN1>; + resets = <&ccu RST_BUS_CAN1>; + status = "disabled"; + }; }; }; From patchwork Sat Jul 15 11:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13314473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44239EB64DC for ; Sat, 15 Jul 2023 11:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QGsD05PptNJw1N3cNeGU9kXCo37saTEmw2WIKBNuKxY=; b=ORb1foyuFPXsfS YQjIjUbdSnW7l9TR16PY4ubglq2vXLwLm9iowKuad00DHUhM9ZZ8UzkF0g6wLl06NEYjN/jYWXjv0 g0nNxb0qiy25wH0oDrgStGInBDokhCLHRN/CtZ7yG19KBQPAd4hkiKxdT/DoGdJ5yHi83Jj//bfwH ZRQ26sLRc+FviJ0qX3PM76N/3sSxdHWEw+ViybhC9SMp+J5tmBIXl5KXWIFrS1LpfibAxqnrm3mhF fDwZ4QzEfjXqUbv6vJO5dOxi0lyy+HMDp1s8W86+DlQ/4xKJZGKALmBY6WEYqbFotSjBB8PvFIgwy HR9wn4o2xHHVMNFGE/+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPd-008Z7N-1q; Sat, 15 Jul 2023 11:26:09 +0000 Received: from out-23.mta0.migadu.com ([2001:41d0:1004:224b::17]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPa-008Z5M-1M for linux-riscv@lists.infradead.org; Sat, 15 Jul 2023 11:26:07 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1689420363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KPF7WuMTa88q4pM2B8RLcTtpmoYLpabME/stwQ3zxw8=; b=CvCizP0wHXr3KbIN7dwVKFLWFHr8fmROa12Yfr1EWNbQgkKHOpztrR7FjE4CeTV+/aMjRy ISxaiyC+x3gyUDjl5CZOg+hFuGwZWsM0Wp6e/SwF+FAjD9oMG8ylmXuaMhFce8Lj03Z1tC TsKtpPGzh7GQD62V6lwsGk5YQYlTaYUb5Az3KCbIKqe8Vs4TkduXgnHLahbaHoxP7s7pXT 74cIjgqGlBJLNPkvbL3X2RHsaJv+ORM4P3mHt84LVmOnZbtdEHZmwminN3w0ARveEABhP9 skBnDh0t8z3efwAIBt3PKpwNRRquQVJgTMCY4MKl0IgYhKsp8gyPEDP1zgz2mA== From: Jookia To: linux-sunxi@lists.linux.dev Cc: John Watts , devicetree@vger.kernel.org, linux-can@vger.kernel.org, linux-riscv@lists.infradead.org, Fabien Poussin , Samuel Holland , Jernej Skrabec , Chen-Yu Tsai Subject: [PATCH 3/4] can: sun4i_can: Add send support for the Allwinner D1 Date: Sat, 15 Jul 2023 21:25:21 +1000 Message-ID: <20230715112523.2533742-4-contact@jookia.org> In-Reply-To: <20230715112523.2533742-1-contact@jookia.org> References: <20230715112523.2533742-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230715_042606_600708_2E604D5C X-CRM114-Status: GOOD ( 12.05 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: John Watts The controllers present in the D1 are extremely similar to the R40 and require the same reset quirks. This alone can support sending packets. An extra quirk is needed to support receiving packets. Signed-off-by: John Watts --- drivers/net/can/Kconfig | 4 ++-- drivers/net/can/sun4i_can.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index a5c5036dfb94..e626de33e735 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -185,10 +185,10 @@ config CAN_SLCAN config CAN_SUN4I tristate "Allwinner A10 CAN controller" - depends on MACH_SUN4I || MACH_SUN7I || COMPILE_TEST + depends on MACH_SUN4I || MACH_SUN7I || RISCV || COMPILE_TEST help Say Y here if you want to use CAN controller found on Allwinner - A10/A20 SoCs. + A10/A20/D1 SoCs. To compile this driver as a module, choose M here: the module will be called sun4i_can. diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 0827830bbf28..06f2cf05aaf5 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -774,6 +774,10 @@ static const struct sun4ican_quirks sun4ican_quirks_r40 = { .has_reset = true, }; +static const struct sun4ican_quirks sun4ican_quirks_d1 = { + .has_reset = true, +}; + static const struct of_device_id sun4ican_of_match[] = { { .compatible = "allwinner,sun4i-a10-can", @@ -784,6 +788,9 @@ static const struct of_device_id sun4ican_of_match[] = { }, { .compatible = "allwinner,sun8i-r40-can", .data = &sun4ican_quirks_r40 + }, { + .compatible = "allwinner,sun20i-d1-can", + .data = &sun4ican_quirks_d1 }, { /* sentinel */ }, @@ -907,4 +914,4 @@ module_platform_driver(sun4i_can_driver); MODULE_AUTHOR("Peter Chen "); MODULE_AUTHOR("Gerhard Bertelsmann "); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("CAN driver for Allwinner SoCs (A10/A20)"); +MODULE_DESCRIPTION("CAN driver for Allwinner SoCs (A10/A20/D1)"); From patchwork Sat Jul 15 11:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13314474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6112EB64DC for ; Sat, 15 Jul 2023 11:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iKuc9WUvqz3mgMso53XVexMO9U94PtocI7cjo62x8bE=; b=NIKYncV2VjIcyb OBjYh/nA/BGnP/UyVTa6DTYw0tztMltbdnitZgrV41iyHR9CNSpEkO7xU/zZZ3AFJOYZxQMlEI5dt K8AeEe9PFtALM0fZiWhOxlnu6+rD9N8mn9F+pRaFqsYau2ZbHSp40rM1RDYoEE1E9cvW4kMvhK0KM bgH0RFDbaQP2pEzAtMDQdVl2s7LBidh3LNx1OmJuVypH1Gq9WCVDHR0TYti0iQ5PHIDoaWV/ICdZp p+TTcEtH3IsGF8L7vCnf5rX7Xk1hBNNiIfNMWN6s5GRTzULLsRAYy2xrqZ1upv+ElWs7zgWjraJ3S gHdZhq8iE2Eea/z23A6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPl-008Z9Y-0x; Sat, 15 Jul 2023 11:26:17 +0000 Received: from out-45.mta0.migadu.com ([2001:41d0:1004:224b::2d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qKdPi-008Z8N-1N for linux-riscv@lists.infradead.org; Sat, 15 Jul 2023 11:26:15 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1689420371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S19A3FkW85iI4MOdVdogxGLjgMY/8iwm4JrY7sESR78=; b=cdJmkzztUHM/iqtbwjQjVkdiFsgm/eGDU+PkljtPsRl3jELhJy42itIlhqCej7tose959G HWkaa2M7uo5U5q7zbvOC/FOMHeDWjCFgMcxg+RQHOApUy4hUhXc0MKiCbadQoSBhf6RdOq njc8oIOkK0qqMmjsh1mBB9anhgLqPBo/4+clV+6dwGjnD+TbTeBFNKmLi5pcDTKF5/XR2P 4byUU9a8JmBl8z9SJOdhHRCxPi14lrPbaVhAuh5Go+4973EgQG6ZWtPFx2lo3kQg6knWsl S2kO8GLro8HxzMtATj90i3jnjWUxse3KO9ZqyKVouEaFBfiZT3P9QrgvV14kCg== From: Jookia To: linux-sunxi@lists.linux.dev Cc: John Watts , devicetree@vger.kernel.org, linux-can@vger.kernel.org, linux-riscv@lists.infradead.org, Fabien Poussin , Samuel Holland , Jernej Skrabec , Chen-Yu Tsai Subject: [PATCH 4/4] can: sun4i_can: Correctly set acceptance registers on the D1 Date: Sat, 15 Jul 2023 21:25:22 +1000 Message-ID: <20230715112523.2533742-5-contact@jookia.org> In-Reply-To: <20230715112523.2533742-1-contact@jookia.org> References: <20230715112523.2533742-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230715_042614_608723_B85AEDEF X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: John Watts The Allwinner D1's CAN controllers have the ACPC and ACPM registers moved down. Compensate for this by adding an offset quirk for the acceptance registers. Signed-off-by: John Watts --- drivers/net/can/sun4i_can.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 06f2cf05aaf5..c508a328e38d 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -91,6 +91,8 @@ #define SUN4I_REG_BUF12_ADDR 0x0070 /* CAN Tx/Rx Buffer 12 */ #define SUN4I_REG_ACPC_ADDR 0x0040 /* CAN Acceptance Code 0 */ #define SUN4I_REG_ACPM_ADDR 0x0044 /* CAN Acceptance Mask 0 */ +#define SUN4I_REG_ACPC_ADDR_D1 0x0028 /* CAN Acceptance Code 0 on the D1 */ +#define SUN4I_REG_ACPM_ADDR_D1 0x002C /* CAN Acceptance Mask 0 on the D1 */ #define SUN4I_REG_RBUF_RBACK_START_ADDR 0x0180 /* CAN transmit buffer start */ #define SUN4I_REG_RBUF_RBACK_END_ADDR 0x01b0 /* CAN transmit buffer end */ @@ -205,9 +207,11 @@ * struct sun4ican_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @acp_offset: Offset of ACPC and ACPM registers */ struct sun4ican_quirks { bool has_reset; + int acp_offset; }; struct sun4ican_priv { @@ -216,6 +220,7 @@ struct sun4ican_priv { struct clk *clk; struct reset_control *reset; spinlock_t cmdreg_lock; /* lock for concurrent cmd register writes */ + int acp_offset; }; static const struct can_bittiming_const sun4ican_bittiming_const = { @@ -338,8 +343,8 @@ static int sun4i_can_start(struct net_device *dev) } /* set filters - we accept all */ - writel(0x00000000, priv->base + SUN4I_REG_ACPC_ADDR); - writel(0xFFFFFFFF, priv->base + SUN4I_REG_ACPM_ADDR); + writel(0x00000000, priv->base + SUN4I_REG_ACPC_ADDR + priv->acp_offset); + writel(0xFFFFFFFF, priv->base + SUN4I_REG_ACPM_ADDR + priv->acp_offset); /* clear error counters and error code capture */ writel(0, priv->base + SUN4I_REG_ERRC_ADDR); @@ -768,14 +773,17 @@ static const struct ethtool_ops sun4ican_ethtool_ops = { static const struct sun4ican_quirks sun4ican_quirks_a10 = { .has_reset = false, + .acp_offset = 0, }; static const struct sun4ican_quirks sun4ican_quirks_r40 = { .has_reset = true, + .acp_offset = 0, }; static const struct sun4ican_quirks sun4ican_quirks_d1 = { .has_reset = true, + .acp_offset = (SUN4I_REG_ACPC_ADDR_D1 - SUN4I_REG_ACPC_ADDR), }; static const struct of_device_id sun4ican_of_match[] = { @@ -877,6 +885,7 @@ static int sun4ican_probe(struct platform_device *pdev) priv->base = addr; priv->clk = clk; priv->reset = reset; + priv->acp_offset = quirks->acp_offset; spin_lock_init(&priv->cmdreg_lock); platform_set_drvdata(pdev, dev);