From patchwork Sun Sep 25 17:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2380 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A5EB03F265 for ; Sun, 25 Sep 2022 19:52:19 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id dz21-20020a0564021d5500b0045217702048sf3684667edb.5 for ; Sun, 25 Sep 2022 10:52:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128339; cv=pass; d=google.com; s=arc-20160816; b=M27EBgq6bxscVUfv2RZ7UVltyIclcGjHVNC6HSwJni3o1mYKxtcQdDqTM5AhHjsHbY MS6gKmIp/OMvGASMRKRtuVx2/kD0jLdSr9jZkI8TyoOuTW3TAURMSV1PVKZUK7V5JPAi MEXiYpHOupj2SxB5VVlpHz8Z40h1FPFIjksS+Hhjrs/gL9VmyuW8UiVojvpxxGmyNrAm UxmBRzFlIqk+eZ6I0E/mQ7yEZTCSijgyFXr+8U49iAk+Uq/R5LRX9KYhnSfkWDXWKzGA Lvcmb8LuZtKK3zWCgkcw7SFkABJNAzTo/39Yhs1cIyzCmS+IAjpyUNFsf/v8bxHmcaqU h6Eg== 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=yODkiyVGlNHDpZWIcDX/rc2SwyROwsSgFg1E53iuG2Y=; b=BPTp2P8GRNaRumDe2+X+p7hhEz/WFTBNmiEihDeS1w5KbMANtDR4fjlSPpEO00dBhj cARVLTAWbZyPrx60t3OL2/Pyh2Um7Z/JeJBHRoPyZUcoKSFevhV3svngWh/liA9MaWs3 ZanBSiDJCd5xGgurMCvfxZEsAaDnySNA4lepsrMGs5WXq9uCLBTi2fWMdgxzuk+EhTwC XzHSAsHwQ5ie94AXWsRdOdj8+7qY6DQ6b85r2Tf44Tg73P/eeaWMMxW5vBD4JKt/X8vu 98ByMaYLAivEV15auWbGzZbWifDtOk/BKFRGu8vop35fiat+jb+hM4G2VS5wuRU8Tkcl VAvg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IsEpv7Bg; 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; 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; bh=yODkiyVGlNHDpZWIcDX/rc2SwyROwsSgFg1E53iuG2Y=; b=Dno8VdU6nnXhpV+j40QiwCbSPQWQ6J1RMF/TuW0kOJ15WA/SOO1KDA3J/x8JX553ML x/zxgu73MKFkbMeoEck5wDDkCCq0l0ys6ndXfuC2IgwJyIIGzOjOkOm1ERY5gsq+pVdC ZS9VYnIF2ZD2lISm02vYGSxP23cz/NHEvv7RI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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-gm-message-state:from:to:cc:subject:date; bh=yODkiyVGlNHDpZWIcDX/rc2SwyROwsSgFg1E53iuG2Y=; b=Dd1OG+rwZJodfWJJL136HvmmB3k+vr04kLhEnDtNRXP5knmx5DsT1uZiFUjy9RDJB7 FcmvOISw362wi76JNPKNxxQdEi44CRLZri6zq0YGFtwtTobE9KL5vCHfCFIwoQqiL04a a6Z8Xct/ZQpsTqqS5vEozdXeg79ZJZUvKBCibApuIlshkzFdLX3wMYE6ttA+wVokPZPf rEcKm/wXLATyBmdiIiRKs98H12+FGtFVwKw7Jf0B0vrgTstlq/x87IVXJRSR0R5wWtUx XEeU/aQ0RKdMywv07fTCG27+BcAkD/oy3saihq2wa/vIGaC+v5nx333CMIq5TzHo28dS lwdQ== X-Gm-Message-State: ACrzQf1u3r8W9LhPcp+koJRLupqzCtwdFS5BFSgTaeJiMD+HWa9UQrGI s2cQ3/w5AzdkMcsY0ZRsLFAWI+k0 X-Google-Smtp-Source: AMsMyM4DbyOapuzhDKjRDw5myIEvIOdXY2ROCnuiy4hHvYkwZFzKOMhqrKw7JDOLcrrHNBXNePLB6g== X-Received: by 2002:a17:907:2d21:b0:783:5dac:d402 with SMTP id gs33-20020a1709072d2100b007835dacd402mr2392368ejc.485.1664128339286; Sun, 25 Sep 2022 10:52:19 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:354b:b0:726:abf9:5f2e with SMTP id s11-20020a170906354b00b00726abf95f2els2653606eja.9.-pod-prod-gmail; Sun, 25 Sep 2022 10:52:18 -0700 (PDT) X-Received: by 2002:a17:907:608e:b0:780:b1f:8d8e with SMTP id ht14-20020a170907608e00b007800b1f8d8emr15082332ejc.568.1664128338111; Sun, 25 Sep 2022 10:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128338; cv=none; d=google.com; s=arc-20160816; b=wCCw2klmWA4FpISGXUSe3ghGNAkswCnOVKwt4LC0UBtzA9WlCO6eKZEkKXsJEDrqX3 TNb4b2+UeNZ9/T567zJ79vLzUZEtot4aImwGe7al/ZyMxxB7d/rJHXxCSG+JxsbU4oan wJ2FPxqFXAOF3spRfK839ayMoEkgqVpCwLIuUnGTa1TR0il9FAWL3QEnKkfHjP2lEc31 doSsoW+AnCYM6Ag025DMtU/Q3VuDXk5sIcZM1Bz6Erv00MZizh/j1kzJeDRdDvp7EzRt Wp9alenXSgs+xJIOSdLiJu3ZCN84zkq3seKeLn7mQAacr8xHP/peOwvrOm65L3ZXypu2 1SiA== 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=J2VF+CVrD0zwhwpgo2IClFZHFW9id6lzY2L2M6stUmY=; b=P0efgbSEfGC3j/a3umWhLTz7OgO1eUur5yyh1rNQl1AVFK/Q8afnTcdB4Upytm+3PD hmZjo2eMr2Q5Cpl4xyj6rvL0X900KsX85hOo27wPeqSsGGNwSwd0QWybxLjb7joZGf4i XtYmb2aea0+IeYTBvykmN05g70GAWbc/xVxtrWTITaLdbpclc8frUKd9J7mRG2RQJHQO iH0QZ5SLrDGchy78XVdcxathx+vSES+V0TFMVAzeHpTBek4m8FNhuOFv5wiM5DBvPNYD /lbz/e/6tPU359UHtOALCayduEHnnmMAoclDIvyMk6q2gf/cuk0qXm5gqRIBn02Cptcr hHgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IsEpv7Bg; 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 bq18-20020a056402215200b00456ea7cddbbsor1864738edb.24.2022.09.25.10.52.18 for (Google Transport Security); Sun, 25 Sep 2022 10:52:18 -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:aa7:d5cc:0:b0:456:f5f1:540 with SMTP id d12-20020aa7d5cc000000b00456f5f10540mr8364812eds.95.1664128337888; Sun, 25 Sep 2022 10:52:17 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id f23-20020a056402161700b0045703d699b9sm3252594edv.78.2022.09.25.10.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 10:52:17 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , michael@amarulasolutions.com, Amarula patchwork , Alexandre Torgue , Dario Binacchi , Christophe Roullier , Krzysztof Kozlowski , Lee Jones , Mathieu Poirier , Maxime Coquelin , Patrice Chotard , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [RFC PATCH v4 1/5] dt-bindings: arm: stm32: add compatible for syscon gcan node Date: Sun, 25 Sep 2022 19:52:05 +0200 Message-Id: <20220925175209.1528960-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220925175209.1528960-1-dario.binacchi@amarulasolutions.com> References: <20220925175209.1528960-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=IsEpv7Bg; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since commit ad440432d1f9 ("dt-bindings: mfd: Ensure 'syscon' has a more specific compatible") It is required to provide at least 2 compatibles string for syscon node. This patch documents the new compatible for stm32f4 SoC to support global/shared CAN registers access for bxCAN controllers. Signed-off-by: Dario Binacchi Acked-by: Rob Herring --- (no changes since v1) .../devicetree/bindings/arm/stm32/st,stm32-syscon.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml index 6f846d69c5e1..8646350dac44 100644 --- a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +++ b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml @@ -20,6 +20,7 @@ properties: - st,stm32-syscfg - st,stm32-power-config - st,stm32-tamp + - st,stm32f4-gcan - const: syscon - items: - const: st,stm32-tamp @@ -42,6 +43,7 @@ if: contains: enum: - st,stm32mp157-syscfg + - st,stm32f4-gcan then: required: - clocks From patchwork Sun Sep 25 17:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2381 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 91B9F3F265 for ; Sun, 25 Sep 2022 19:52:21 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id m13-20020a056402510d00b004519332f0b1sf3703124edd.7 for ; Sun, 25 Sep 2022 10:52:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128341; cv=pass; d=google.com; s=arc-20160816; b=rp8awh4hQndfc9/XBvN3aIKSN5v3LiZrMPlqMMxCk/p1Ua+K5Hwb6Txs8vPRYMd7Eg I2XjHw0MbWJ2llFJvNbWaR+mr0TtVw+uZXj9nvt1G6lsOE9DzJ55JzBHyOLYTRBm54I2 p/15MeQuTneHMD5TSaS8gXsNn5CXfYP1f0uY7OAFIzvJ3kDz2foEhhHaJ4mYB1CAfxFH ESiavuGYJv2h13JlSDtHL57Ts4pT1x2wV6vXuftk2xH/IE87Kag/hWy/EQ1rGyE3TsT8 8WgGm8ewra1pPz8E9gA/SL4gnqqDeNflRu2Oqi9Df7QvpqtjlGSV6zcNu3+FyA1hiRCY /yhQ== 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=95upEO8HJ8NLi7B37YIuTgNhbtdyiUSSUdWtuIxPv1k=; b=qHQ3niFJmulDqHuvnIHmJdFSvdoZOW4dc74ESNbgp2KkQfhtyiixu4QJPLZyD8vZML TORWg25p55g3A6m2ZkA0QHPGb6LGnZindyv27EoAuCeGwpX6OOwvgd+UyZ5WLtV2JqrV mbjsMmWBadIGlSwgnntLPmSxwP4TsCNImu+C3yhBAulYsR0pEQkU9KHoeDtN4scs2jF3 xYtJnuHAYxH1PQQF7LyTOGRXIOVBeoQxZSOr5pStIRDJvuV8vrxgr/+pns6HF8MmrQkM je+jWT2Rs2y7v/zpiS/3Q9S3bwED9j80pQS0UWGiIgiPPsrlf6KIw0iMhMQaHSgWioIk z3Iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rE09vLhf; 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; 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; bh=95upEO8HJ8NLi7B37YIuTgNhbtdyiUSSUdWtuIxPv1k=; b=R+YBIu5ngR0wA/NszDy29ddx9j3y94drdN31zvrJdPD4osnp4XvJ5n1fpfbQJPTgt9 2g/1TK+0fhx+yMjI+7lOD3UChlC6ZwBSO0XC83iZU/GubJyYZq9TaMrqlsPspnOKSzaI MpI+HySYAOxmkJzApiKdj4O2STDJmETcQmCHE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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-gm-message-state:from:to:cc:subject:date; bh=95upEO8HJ8NLi7B37YIuTgNhbtdyiUSSUdWtuIxPv1k=; b=HTVUpZ9nwuAbTNxV+NkC4IejIuCujBkKbxZxCzq5os2aAcG8LCr/orPWRXjg5pxdwb CeyhS1oG/EcxYz4J7VH9TI5S4gfsBk7fOnvjIh9w2kMGfQlyZ0UsOpi+WzyAB5e1y1Uq XQC34dpRmKq96teKwoFVIh9PEKMXtDD0FNZD8UarZcbFDg/Df1z+NOX8lf3V6l+L27OB A2k8G4gfqY0gc5kGld0G2PRX8Gq3JDZhgk/zTG6OFOCZy9R7L/ifumXMD2kLcV3+oRDS PrG3SXSLR1ZOEhttkDEndKdQIzVAWRWBbzYmpm9/NplS+zzEWNg4xSK3g3c++i5WrVmM lDdg== X-Gm-Message-State: ACrzQf0nWvmShOBkehfte90NimDF/xgqUu2+Tsut+Nb/ed1YyBG6HM9g kCdEecJhdJCaeNbzxXGFOFxFIquA X-Google-Smtp-Source: AMsMyM7Tfoph5OCH097nA5ghThquGbiLB2g+bAuy7GBJZlhhGNf+vZM3v9Qy9a1u/+/sRLGBwb5/Aw== X-Received: by 2002:a05:6402:2994:b0:453:4c5c:d31c with SMTP id eq20-20020a056402299400b004534c5cd31cmr18498450edb.412.1664128341088; Sun, 25 Sep 2022 10:52:21 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:268a:b0:43d:b3c4:cd21 with SMTP id w10-20020a056402268a00b0043db3c4cd21ls11803182edd.2.-pod-prod-gmail; Sun, 25 Sep 2022 10:52:20 -0700 (PDT) X-Received: by 2002:a05:6402:12c5:b0:456:f704:2ffd with SMTP id k5-20020a05640212c500b00456f7042ffdmr8186241edx.389.1664128339859; Sun, 25 Sep 2022 10:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128339; cv=none; d=google.com; s=arc-20160816; b=I3oOpKuQADqLewEKKF5rleW+4u7nhuvkQfNFC4un4UPE/fROZnRXCxAmn0qSOP1GX3 KBLHGTHlrWm5Pjw/RpfSxDyYXIYTolAJ4MfDsrragglmEv3K5ox7rZHJORAsFFgj+2i6 5jwvFb+8mW3jG4AJ5QjFNp3BZjNgQE0fXzkkFyt8xpqJlQmj+aZ/SePR4K0gwrwutYRl aCE6Pv7cBfSUAS1Kg9RKbohXo5Rb3VM1/RjtSAFK8ZhCxGYMhFBGoJNpWh503paM7puz h3yWOo/NnrtO5rztpv+EPfBVXRpuOQKb4PyDS5GDvkkHW2roVPmNSOxyYgrz3bZ6Hcym x1Fg== 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=5r8NMkE9LIMyGMHe+fW9/TCXkKWGgaySDbokWa2bTfs=; b=PNDPcOQ163YvpAOnb95bNlg1jdoO3JuH0FuK7aV95j7jXuYsuuz7z21lu9Nf4F+SxH hhodVcMVJaYu0YGwr6OIC3KKqKZFCVBqRaslmiu8SYGaDVHSxCOuFJcdrgdl/HsZGSF5 XsuFTj02PsCNA+S+mEGTZO9vXsPFdhZUSKSzCfNJmaHx3io9ZcNiZM4sFYRchfyMgpQl YhdBMm+5ItAdtbyqYyHAPbZgbcmRiBBDN8jWkSBe910wtJ9mzuUs8zf5UDr/DY485p2K s/0OoKJQ+e9v48SInkFHpE8r3aO3OgLKkQ4AqLs2XfaWgGr9tnUS9oxeYnyadXeZkIZ8 GwQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rE09vLhf; 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 q27-20020a50cc9b000000b004572a1eeb1dsor644848edi.43.2022.09.25.10.52.19 for (Google Transport Security); Sun, 25 Sep 2022 10:52:19 -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:a05:6402:2994:b0:453:4c5c:d31c with SMTP id eq20-20020a056402299400b004534c5cd31cmr18498376edb.412.1664128339645; Sun, 25 Sep 2022 10:52:19 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id f23-20020a056402161700b0045703d699b9sm3252594edv.78.2022.09.25.10.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 10:52:19 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , michael@amarulasolutions.com, Amarula patchwork , Alexandre Torgue , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Krzysztof Kozlowski , Maxime Coquelin , Paolo Abeni , Rob Herring , Wolfgang Grandegger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org Subject: [RFC PATCH v4 2/5] dt-bindings: net: can: add STM32 bxcan DT bindings Date: Sun, 25 Sep 2022 19:52:06 +0200 Message-Id: <20220925175209.1528960-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220925175209.1528960-1-dario.binacchi@amarulasolutions.com> References: <20220925175209.1528960-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=rE09vLhf; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add documentation of device tree bindings for the STM32 basic extended CAN (bxcan) controller. Signed-off-by: Dario Binacchi Reviewed-by: Rob Herring --- Changes in v4: - Remove "st,stm32f4-bxcan-core" compatible. In this way the can nodes (compatible "st,stm32f4-bxcan") are no longer children of a parent node with compatible "st,stm32f4-bxcan-core". - Add the "st,gcan" property (global can memory) to can nodes which references a "syscon" node containing the shared clock and memory addresses. Changes in v3: - Remove 'Dario Binacchi ' SOB. - Add description to the parent of the two child nodes. - Move "patterProperties:" after "properties: in top level before "required". - Add "clocks" to the "required:" list of the child nodes. Changes in v2: - Change the file name into 'st,stm32-bxcan-core.yaml'. - Rename compatibles: - st,stm32-bxcan-core -> st,stm32f4-bxcan-core - st,stm32-bxcan -> st,stm32f4-bxcan - Rename master property to st,can-master. - Remove the status property from the example. - Put the node child properties as required. .../bindings/net/can/st,stm32-bxcan.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml diff --git a/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml new file mode 100644 index 000000000000..c9194345d202 --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/can/st,stm32-bxcan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics bxCAN controller + +description: STMicroelectronics BxCAN controller for CAN bus + +maintainers: + - Dario Binacchi + +allOf: + - $ref: can-controller.yaml# + +properties: + compatible: + enum: + - st,stm32f4-bxcan + + st,can-master: + description: + Master and slave mode of the bxCAN peripheral is only relevant + if the chip has two CAN peripherals. In that case they share + some of the required logic. + type: boolean + + reg: + maxItems: 1 + + interrupts: + items: + - description: transmit interrupt + - description: FIFO 0 receive interrupt + - description: FIFO 1 receive interrupt + - description: status change error interrupt + + interrupt-names: + items: + - const: tx + - const: rx0 + - const: rx1 + - const: sce + + resets: + maxItems: 1 + + clocks: + maxItems: 1 + + st,gcan: + $ref: "/schemas/types.yaml#/definitions/phandle-array" + description: + The phandle to the gcan node which allows to access the 512-bytes + SRAM memory shared by the two bxCAN cells (CAN1 master and CAN2 + slave) in dual CAN peripheral configuration. + +required: + - compatible + - reg + - interrupts + - resets + - clocks + - st,gcan + +additionalProperties: false + +examples: + - | + #include + #include + + can1: can@40006400 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006400 0x200>; + interrupts = <19>, <20>, <21>, <22>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN1)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + st,can-master; + st,gcan = <&gcan>; + }; From patchwork Sun Sep 25 17:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2382 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0A58A3F265 for ; Sun, 25 Sep 2022 19:52:23 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id h13-20020a056402280d00b004528c8400afsf3652626ede.6 for ; Sun, 25 Sep 2022 10:52:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128342; cv=pass; d=google.com; s=arc-20160816; b=LQbF4psfG9xg2Mb56XzFCyhzNRCALzP+udbY6uCGcVyN+VWwtJivppeRGv2mMWzSFT HvXJffJ3wjch3flWdw+WYGcgPi9wQGd7CDs5MkHgwlHwHr+ve3+7g5vvyU0sy+phxzHL ZmcT4/kI99KVMGb2rS7Z+fqxWzkCgdJcUyRcoCJmSY/putziJip4DQ90r79YI4Nw3ITG vK4+Dt+CDBOdg15529oQOpTVY7EyLy1h5ImkKQh4MPtAUnQxCv9R2R8RTzuyClM/FdIO rKlJFEnOmT1tffyejnXs5W/APpzaZnGPCLYmgkHXrwX1qnFRH7eUzDonW6ERTOyHSSxi 78BQ== 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=6lC0dfLWCQcxXOm08blEbHuJpSP/aj8LQocrdf7ddr4=; b=dv61uU9cQCb9o1azdNyI1CsaQGXldn80ilTvkXEY0i7zTMBXO7aHeVTaBFEo/ChQ1j OPmDqAuAlnTrH+CX/bmOvVKIZLfcTL++sruokMtAcCOsvLEPXtfvOYBJIRIwg3uTbPbT mqslY7p86/cLgLUUESHd9djQsV/VBPDQRYgxyuMHNaSBSiBJY0hboz51a2p0RkJop7FB FBkqA7JMHEFF4cRBG/gugucyEYEEdRud6GOyJkWZbbWIK2QcVSsrVu4aHw3A7byMuTjk PN2e0iKmnUPJSHxUcIHt4MlAA+1sf9TFvPZWSLZ87o1pGJBoZ9fjvqNt+BVzDCr1FROf GA3A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rpXllgi1; 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; 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; bh=6lC0dfLWCQcxXOm08blEbHuJpSP/aj8LQocrdf7ddr4=; b=OLn0EKS3+sFKqEjFTPLYhb6SVQ5x7AnKbVX1hlARW9tjHJb7yalgxnm+MQGeFaKzQ1 +uafzJafpCLFbiBBUHHYVpStePeo9540puJ38UvXp5FpKvVtGAdymIyAsjWw1wPPkGe1 4rQNINafky7jE9RIKpYFweBnOhU1EqfcZiNdk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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-gm-message-state:from:to:cc:subject:date; bh=6lC0dfLWCQcxXOm08blEbHuJpSP/aj8LQocrdf7ddr4=; b=lIDfEWJG6IgdbR/sD0C4rL55arr77Nof8/oWyVYPQGa6kVzipOw8jkzsBLypyO6tTm mXpaqdzig/5CTWYVAPR5DeRrqwIlDNQXgX9a8cfnORLV0YtRmDQKAhgVr/kILLLILWZ5 2NLItLakwRtMfqtXj5AZhiffQvGkNHs7cFZ4vbgtnV1xcL8vog9QwYjNsXxl/q81M/wr MnykSj/TGs/Tuvkm1mnEuQIdU9KSmsh4zL8eOco0Vyf2DbZjLlk0InNblUskSYBm1dTB onSDHRsVCyUzM9BQ4ErkA/I4SxrVhxRznjNeIe/hXn3upNZ3e3plPAiJ5RP9rJV7F5zS PACQ== X-Gm-Message-State: ACrzQf0U/NgB/6mo/12C8mv0qeFpF9GQtovOHoQdLWan/dptoc5JgeVI QJ8q4E9nWJqKVtgf0XdsT7q1MMCL X-Google-Smtp-Source: AMsMyM7hmff5mawBSvRLayjZYvkNUtA3qcUlGgo03eP4O4ZJKz8GbPPRVXXQI6QsVg3ERyEO7AcITg== X-Received: by 2002:a17:906:cc46:b0:782:f40b:11db with SMTP id mm6-20020a170906cc4600b00782f40b11dbmr6954322ejb.32.1664128342433; Sun, 25 Sep 2022 10:52:22 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:b845:b0:73d:afe3:ffd9 with SMTP id ga5-20020a170906b84500b0073dafe3ffd9ls5706714ejb.10.-pod-prod-gmail; Sun, 25 Sep 2022 10:52:21 -0700 (PDT) X-Received: by 2002:a17:907:7f07:b0:779:7f94:d259 with SMTP id qf7-20020a1709077f0700b007797f94d259mr15116824ejc.525.1664128341221; Sun, 25 Sep 2022 10:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128341; cv=none; d=google.com; s=arc-20160816; b=bGz4MPDF09ypUxcjsPns1u/G9G72KVpTDuaZ3vjyXBc7VW8XflMcX9iyyClL8yBngQ zRIhYEPCe9ciSfls2W563xXQUyTkuTJNmhtL6uf3a6q4RqvIdLdWyXeS4iSLsQyfEYWm 7VQ9yEnh/IUGaqhNaV1lEqK90KEngyuCbf8jiCv6DBHLkdtaOxUv/OuZIsD3lWRu+h0i RAunk0REbwklhGoxJ5Gou4IDc13gle+7OAtOQAk0yeVpj0w84HMZOvcYd81unWCNeKZg 7SP4zyYliTQJrMxOC1twN8/GBfFKqvdSPzU1T2vswQ9SMttWcCUDJrlSOg7w69etSC0Y +quA== 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=dOPE1L7q5E7QdZRAYhm0K2Z1Q5vapQyABM0Y6Kwo/zE=; b=zFurgxNa8G2mbUJbAdX4HV/36Dhumfics9Ig5+F5xdzmNbzTA4jx1I2QXDCY8Z4gPs TjyXPkUE1wgG46G6HG1OdvTEY6A6wtCEnDTAs2qcOM/f1P/U6Edk3DeuqjiJJl19EpvT gJ/BkqEoC+GGzQeMO/psa5UDGoKNLx7RJsyjdXy62mTT6PQvVkWqM+37iMeFx1bimd7R 3FQQd0uyJIyfDxnlN4ybN0sFaKFRNpud3VUmwEzkuqTCPA3Dloc0CjCYA5ozUsG16Hs+ A31hzDYIXjnhNVRplOYSoTt+tTYXn9+5yzPIdTh0SDSN9G8cxOJY6ogyEbFP2moiRgQL 3Z/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rpXllgi1; 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 mj15-20020a170906af8f00b0073d5ce58140sor5562134ejb.109.2022.09.25.10.52.21 for (Google Transport Security); Sun, 25 Sep 2022 10:52:21 -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:a17:907:6e17:b0:783:7839:ff3f with SMTP id sd23-20020a1709076e1700b007837839ff3fmr1778971ejc.300.1664128341028; Sun, 25 Sep 2022 10:52:21 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id f23-20020a056402161700b0045703d699b9sm3252594edv.78.2022.09.25.10.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 10:52:20 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , michael@amarulasolutions.com, Amarula patchwork , Alexandre Torgue , Dario Binacchi , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [RFC PATCH v4 3/5] ARM: dts: stm32: add CAN support on stm32f429 Date: Sun, 25 Sep 2022 19:52:07 +0200 Message-Id: <20220925175209.1528960-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220925175209.1528960-1-dario.binacchi@amarulasolutions.com> References: <20220925175209.1528960-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=rpXllgi1; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support for bxcan (Basic eXtended CAN controller) to STM32F429. The chip contains two CAN peripherals, CAN1 the master and CAN2 the slave, that share some of the required logic like clock and filters. This means that the slave CAN can't be used without the master CAN. Signed-off-by: Dario Binacchi --- Changes in v4: - Replace the node can@40006400 (compatible "st,stm32f4-bxcan-core") with the gcan@40006600 node ("sysnode" compatible). The gcan node contains clocks and memory addresses shared by the two can nodes of which it's no longer the parent. - Add to can nodes the "st,gcan" property (global can memory) which references the gcan@40006600 node ("sysnode compatibble). Changes in v3: - Remove 'Dario Binacchi ' SOB. - Add "clocks" to can@0 node. arch/arm/boot/dts/stm32f429.dtsi | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi index c31ceb821231..ce08872109b8 100644 --- a/arch/arm/boot/dts/stm32f429.dtsi +++ b/arch/arm/boot/dts/stm32f429.dtsi @@ -362,6 +362,35 @@ i2c3: i2c@40005c00 { status = "disabled"; }; + gcan: gcan@40006600 { + compatible = "st,stm32f4-gcan", "syscon"; + reg = <0x40006600 0x200>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + }; + + can1: can@40006400 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006400 0x200>; + interrupts = <19>, <20>, <21>, <22>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN1)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + st,can-master; + st,gcan = <&gcan>; + status = "disabled"; + }; + + can2: can@40006800 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006800 0x200>; + interrupts = <63>, <64>, <65>, <66>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN2)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN2)>; + st,gcan = <&gcan>; + status = "disabled"; + }; + dac: dac@40007400 { compatible = "st,stm32f4-dac-core"; reg = <0x40007400 0x400>; From patchwork Sun Sep 25 17:52:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2383 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 255D83F265 for ; Sun, 25 Sep 2022 19:52:24 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id m3-20020a056402430300b004512f6268dbsf3753963edc.23 for ; Sun, 25 Sep 2022 10:52:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128344; cv=pass; d=google.com; s=arc-20160816; b=QO048uu5Rq+IapZ9t4N69wbmgpq4KMyeDlnkcXldIpmSUSi8zc8Jjgg1iXpbzwILaI CTamKSzQk3R8uT1Sp/67B+f6HypfamPpLIMZgb/SwKXj/flTYWn3u6DYBpEo4P38ETqG H7EYVXFdtGnYBol4vOOPKp/cttyLhOCG2/QZMBJ4SD0aEOL9n6vcGFyITdt8mqUy5zwo eJjV6XUgxl+XyS/QJ5a89oDka1Jl0YMozojJEqSz+pxlNZnWmqB7c5p+UXLOZWUSSKX2 SrRJFz9QkZFsunHmFQJlUrhsH3M2NncWngUZloKem0qhg/IDHFjPc5fvEOWIEY1udA5v e/gQ== 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=WPZFPC0LIg+Ui+XDjcph7phwAslDEQjxg+3LEBtUn+g=; b=SKPoY7b8vlSmEAMycwMsTyFxN42Ydmjei72lzhwlnp8tkLLHXooVamPSDyeMx9tWWn pVNt9jKAgePEYCKyPX7Eno+nLWG4WMOD+OvVZo6mkM/3ENnUeXx3d9wxpOtcWOxlmsT5 lT5lH5fowlhKJ/LwrK0pDWP8FYh9j2YdNc3s9GHtYb4BTcZhp6Tfx0cPDOTCwdDLFZ0u 5JSnr2YcQJhUXolwsVIe3F02QgxnCDMddyjlGadgNG/Vx8449F8WXpu6ves9RQr+BnbW mXafGL4uk0k3RWFGyJwJ8N8JmKlmvHOm2yeqhyDoUO8AnvyzMufMaEfAlWg5XZkdf0Kb 6Yxg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HnihT0YS; 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; 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; bh=WPZFPC0LIg+Ui+XDjcph7phwAslDEQjxg+3LEBtUn+g=; b=jMn82hN1Z+gHuJZIghtO44tbCVonOGwF89WtNrrpMEL8WysBI62mn0/U0ufxK36FU/ j+mTVWknNnHMzDLe3KH00lmb89vqEcttynzQKArsBQJczXsmS81i8jIoGe26tPWPUzhZ DuB5nK+NC5c29NCnLrmvbGbGwlIXyMs4GMKOc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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-gm-message-state:from:to:cc:subject:date; bh=WPZFPC0LIg+Ui+XDjcph7phwAslDEQjxg+3LEBtUn+g=; b=Rxsb9L1e4+9RuIPja/nXl5B0NWHgXmg1jRhN8/+oPp2Yf8hjjbwaxVbrITk27MmMko cEgorp5H9fyzNp7h0cl/L+jCrWp4AnjdH2DSWysRG3cwQFAed8FVEkVvdGyypKc1ege1 3OoT9SbapfBjPEx3EWrS992eDn3qTvI6Vj5jhQEs5kiMe3KL5Vyi84eMyVDY5OMIwbCK /DBD7T69m5+nDek6DXCLOcBMVyOksMADoKnxO5M/d0LgAfRF76r8o/AWbbTbUXDElCeL RWZn5oWsJQejK1QPRXgKPF8mlro6Q5nwegC8QbvqoDGo2OoCE7gLMtB4E4kG8mszDBj+ PeWA== X-Gm-Message-State: ACrzQf1o37dFVYTz9eN9n43RkG0/SsyB41udVf4229JkNc6rmYJDQ2GL cuo25PD6pi7xAm7KlLIn6WcAxMxZ X-Google-Smtp-Source: AMsMyM476QYeKlYkInu6jMJ7Jofl5e7kbPyZSXvS1RcmF7mGjeXMoyCuIHeeTbxDKD/MB6yAiR2Y9A== X-Received: by 2002:a17:907:2c74:b0:77d:5a0e:bb8f with SMTP id ib20-20020a1709072c7400b0077d5a0ebb8fmr14502155ejc.579.1664128343903; Sun, 25 Sep 2022 10:52:23 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:520a:b0:448:77f2:6859 with SMTP id s10-20020a056402520a00b0044877f26859ls11799170edd.3.-pod-prod-gmail; Sun, 25 Sep 2022 10:52:22 -0700 (PDT) X-Received: by 2002:aa7:c78e:0:b0:456:c524:90ec with SMTP id n14-20020aa7c78e000000b00456c52490ecmr13069963eds.192.1664128342775; Sun, 25 Sep 2022 10:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128342; cv=none; d=google.com; s=arc-20160816; b=gnaOr5+/Z4hboJ4TQYzqDSDkVnd+6T6tWtWWif++fa5ev9N98Wy5drAhSPwo+c5GHz hVppLmG2Y4yVIm4xanlN/VlbWyUCQFDuNL5gxxeIeQEdZLx+gKY7BOTPeWTFXcw0EMAQ ITyqKiIQW07ARHWKRaiTQYgv4+UQ+tn8t4nhN7Z2kBvftK4dXuy48C5//ZkE0TZ+pFBi 5JTQDmbbmHqL1Sw4QL8eFtJn1fSqeeiUN3+FtXyNIDAsROWVuswIE2FbWhDinIxObj5G um115rKRC7SJKpWL2demxLUpFlLM+vhMD56P3uU72WvcHcqYjjUQzl08NHR3Cmed1ByG VVNA== 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=jfErmyZAWFClEhl0ayKENaiIcOOkglWFws7K0nbLI8s=; b=pI+51JjELZHlTOZoQGBpoddZTkSaQlQRh90pfd9WwyXm/z1ASJi49i5tZNS1QFovH3 uADxjGNldCLjuw6veTEizjEox9BLJWpIRHgM6LeumgDO9HCfklO23sx/9eKXGz1bHfUj /PmgSq8QsZnK46ZFFrAEZU5F5PIVXvQWEpiDzpOzJv1XZFm+DCos+aMfsFxOp0+0X6zX B7kWtv31oK1vNWa1xq6XtvAeet8q6beATLlQqng+Lknu/JQUMaHaaJ8cIpDGrHksvliS 8PHUXBvM94VAZcCBmffG8OPIN+qRkZHT8ADXKJhptaTu8R3W2KD2fZZ0X9NnjiHRCIY+ XcDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HnihT0YS; 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 k12-20020a170906578c00b0073c0da97357sor5725118ejq.121.2022.09.25.10.52.22 for (Google Transport Security); Sun, 25 Sep 2022 10:52:22 -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:a17:907:2d09:b0:781:d793:f51e with SMTP id gs9-20020a1709072d0900b00781d793f51emr15050921ejc.628.1664128342518; Sun, 25 Sep 2022 10:52:22 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id f23-20020a056402161700b0045703d699b9sm3252594edv.78.2022.09.25.10.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 10:52:22 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , michael@amarulasolutions.com, Amarula patchwork , Alexandre Torgue , Dario Binacchi , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [RFC PATCH v4 4/5] ARM: dts: stm32: add pin map for CAN controller on stm32f4 Date: Sun, 25 Sep 2022 19:52:08 +0200 Message-Id: <20220925175209.1528960-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220925175209.1528960-1-dario.binacchi@amarulasolutions.com> References: <20220925175209.1528960-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=HnihT0YS; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add pin configurations for using CAN controller on stm32f469-disco board. They are located on the Arduino compatible connector CN5 (CAN1) and on the extension connector CN12 (CAN2). Signed-off-by: Dario Binacchi --- (no changes since v3) Changes in v3: - Remove 'Dario Binacchi ' SOB. - Remove a blank line. Changes in v2: - Remove a blank line. arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi index 500bcc302d42..8a4d51f97248 100644 --- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi +++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi @@ -448,6 +448,36 @@ pins2 { slew-rate = <2>; }; }; + + can1_pins_a: can1-0 { + pins1 { + pinmux = ; /* CAN1_TX */ + }; + pins2 { + pinmux = ; /* CAN1_RX */ + bias-pull-up; + }; + }; + + can2_pins_a: can2-0 { + pins1 { + pinmux = ; /* CAN2_TX */ + }; + pins2 { + pinmux = ; /* CAN2_RX */ + bias-pull-up; + }; + }; + + can2_pins_b: can2-1 { + pins1 { + pinmux = ; /* CAN2_TX */ + }; + pins2 { + pinmux = ; /* CAN2_RX */ + bias-pull-up; + }; + }; }; }; }; From patchwork Sun Sep 25 17:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2384 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 12EC03F265 for ; Sun, 25 Sep 2022 19:52:26 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id i17-20020a05640242d100b0044f18a5379asf3772726edc.21 for ; Sun, 25 Sep 2022 10:52:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128346; cv=pass; d=google.com; s=arc-20160816; b=F9I/QaxpoqT8kslm+hOZd4G8nMEOZ9O/UKWKEACAFv/vIkX80XaYm+CirWPVZ4ktYE oGPlV5aV5u1pOG6jg0SVs7WJA6G0rimRX4o75YpUcquGKuJFpiJK6rjc49jqAyt5eeg2 aGusT6wgy/JZKUgFwRshJhxJbM3WJuQ5CbkfXSEk4dai/ejpeR7hfmfoj7JrpIVAAIol 5IMwNNqCQSwvLBFupGGA26clXsHG5wBeongChuShjDPg0upMer2MzZSC3xk6mqsmgYAL Brp/+X0BGQyAslBaWtpEaL/8NooxLIZQMST/FUrAuvS8I/GMh2BEGHyad3BoAADOWYHp En+Q== 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=9EOqzfeAsKUeMJuCUNQkRunE4ZyEqzBR2XMN1YAiAQ4=; b=sIHqcwJ5jObWkXM3GxdagNxP8cj+9qkCW4UpR/7DxEQfD2VttziW2DSGdeU8zPEPSx YHeKSnLHv4LEjLU7LT5KOxhqxeLyXHcQV6VNUqL5dlf9tDeq6IB02APybQXIs/YlobvD TQe+9vSbbm+vCCqQicN3wrYfTHD7fo36RJ9JbklRxD7JDKriMMwyKhayeK1I6ESfYdXb FOCFHIzXduE+p95SgpPSXPxTz2eLP58kixbx8MaaG48+eH5043QG1Id9DKG3DPOdv9so ohpXG3vx/tWuKgd8RToYnoRhNKYkkieoQnsm5VCyELi68WFpDsHxhfxmEiRBIYkCFDgX ov1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Jz2SqLi2; 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; 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; bh=9EOqzfeAsKUeMJuCUNQkRunE4ZyEqzBR2XMN1YAiAQ4=; b=XFcdyvpYifnGmkoFSeU2/XCrKBQAYwGtHL4Mjwjtd0KHZnI6mGHV1VECGoEHR6WNdn uOr8+V3G+FlMB/kjCXH24Bq+/ipShVsSa5gbC1SZwnCcW6HAgfZgAGGn2tF67qK9b/uD 3mJh3pMGAGLhr52b0O/4GA1El8/khv/PTfrSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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-gm-message-state:from:to:cc:subject:date; bh=9EOqzfeAsKUeMJuCUNQkRunE4ZyEqzBR2XMN1YAiAQ4=; b=6DV6hkdpu3vbEX6ew5xyQGPFvYElcjrtLnhRpET+LNlOVpSXhHAdTQjB2COtREl3rB /4GwtNKUlIr6HYsH0b1sfg2LrYqyr/IIy6weeueg0N84GVQp3JMgz93D4jpK8oLVaMBz dr/HBZXK5KdloMMlFOMKCWLra6v6Vm8iF7puM0sI4SfG0nSz8unNZLYqqSabivg97E+w FYmGSqPRMHSSvBorJlyoBPPfFUMBa6N0ijq/ia2IUPsWW/KSCLdwKJbJngk4mfJZsz4M nfiQuZW3tfrf1yyk34I1sLooNNGxWnuAduGYhSdEW3iPwWnrnPLUghnLyWXTLLTkX0xp Dz0A== X-Gm-Message-State: ACrzQf1ThsKo38g28N1KJ9JkiQoZ7Crpktr+rax9fxFzVVqVpCrbecV3 4ONufDLl6oGlnVCyiJz076X64DDg X-Google-Smtp-Source: AMsMyM5zIRZ+xv5mNhJcqDbsQc+7OSINWZMU65sj78o5bgb9kHZmeAEZqdJilgwrYNBfQbOwX1MWnA== X-Received: by 2002:a05:6402:1d54:b0:44e:a683:d041 with SMTP id dz20-20020a0564021d5400b0044ea683d041mr18742037edb.411.1664128345811; Sun, 25 Sep 2022 10:52:25 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:f895:b0:780:f131:b4d9 with SMTP id lg21-20020a170906f89500b00780f131b4d9ls5714721ejb.11.-pod-prod-gmail; Sun, 25 Sep 2022 10:52:24 -0700 (PDT) X-Received: by 2002:a17:906:c14e:b0:782:57a6:ce25 with SMTP id dp14-20020a170906c14e00b0078257a6ce25mr14757459ejc.483.1664128344512; Sun, 25 Sep 2022 10:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128344; cv=none; d=google.com; s=arc-20160816; b=vjPSb6EYcE9PN+Yw+is8Fch1l2tefjfPz4O6PAKeruIHgGzf0gMdXjRaLDs6Rsn6Hi UE//YU/qrsisPj31bdDMGpJo49vOyoon3I7k7CWFDSqL1yw/8czZSdqgCftWJuxsDsb4 JjiNudgxjKzvNDo4FJeyhz7CO+Atb94No3v2kweTJbzI/Xlhj9fMsI+I0kwIo0xHAEcL hq4joVKbr9wN2VP3LJPFB7csiRGFJpnWjJ8wObMEYEjWrlohyA6Sw47AQFoMiBir/SE7 kF9/Hg5ntQRnuukgxl8QtYx71CXOdG6uJBPT1bO00xmuekUFsD2DxTtvOnyg6ADF42QT 6muA== 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=y/xO1Xpheym2UrRsI41YD7GvMHPCrGeNkINAZ9E6IkM=; b=rc7D+HDJxQOCf4SwSWBhKnj+2U7AoQlSUF46fNOIbb68+zWltPG5Hocm3PBVby9MBt btzV54/f30DufywEhgawfG1C7knHaXvQeWu1A0SHe30ia1VyaGWi5vyYrUguNnVBMvVG GnEEMZTAtn3D5lYuodjGR7jr+kSy6x1ON/RXc5LjJ7PNYW5hR3H4+lQ8dBL3SnP06QFM htwOqcQ894Pwe7MFPj/P6CNegRVekPHno6VtOC0iJJmJXaS6101F5gcO5WDPMRltDK3X ylfEvaUPxj+AgJTW9cQy0m5KYkb/ITbBOX5qQE5avRnfShigFSt5iZFQklVa2FWZI+tJ s5qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Jz2SqLi2; 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 kt10-20020a170906aaca00b0077084935c9esor5719824ejb.61.2022.09.25.10.52.24 for (Google Transport Security); Sun, 25 Sep 2022 10:52:24 -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:a17:907:a4c:b0:77b:ba98:d3e with SMTP id be12-20020a1709070a4c00b0077bba980d3emr15702856ejc.13.1664128344103; Sun, 25 Sep 2022 10:52:24 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id f23-20020a056402161700b0045703d699b9sm3252594edv.78.2022.09.25.10.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 10:52:23 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , Vincent Mailhol , michael@amarulasolutions.com, Amarula patchwork , Alexandre Torgue , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v4 5/5] can: bxcan: add support for ST bxCAN controller Date: Sun, 25 Sep 2022 19:52:09 +0200 Message-Id: <20220925175209.1528960-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220925175209.1528960-1-dario.binacchi@amarulasolutions.com> References: <20220925175209.1528960-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=Jz2SqLi2; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support for the basic extended CAN controller (bxCAN) found in many low- to middle-end STM32 SoCs. It supports the Basic Extended CAN protocol versions 2.0A and B with a maximum bit rate of 1 Mbit/s. The controller supports two channels (CAN1 as master and CAN2 as slave) and the driver can enable either or both of the channels. They share some of the required logic (e. g. clocks and filters), and that means you cannot use the slave CAN without enabling some hardware resources managed by the master CAN. Each channel has 3 transmit mailboxes, 2 receive FIFOs with 3 stages and 28 scalable filter banks. It also manages 4 dedicated interrupt vectors: - transmit interrupt - FIFO 0 receive interrupt - FIFO 1 receive interrupt - status change error interrupt Driver uses all 3 available mailboxes for transmission and FIFO 0 for reception. Rx filter rules are configured to the minimum. They accept all messages and assign filter 0 to CAN1 and filter 14 to CAN2 in identifier mask mode with 32 bits width. It enables and uses transmit, receive buffers for FIFO 0 and error and status change interrupts. Signed-off-by: Dario Binacchi --- Changes in v4: - Add "dt-bindings: arm: stm32: add compatible for syscon gcan node" patch. - Drop the core driver. Thus bxcan-drv.c has been renamed to bxcan.c and moved to the drivers/net/can folder. The drivers/net/can/bxcan directory has therefore been removed. - Use the regmap_*() functions to access the shared memory registers. - Use spinlock to protect bxcan_rmw(). - Use 1 space, instead of tabs, in the macros definition. - Drop clock ref-counting. - Drop unused code. - Drop the _SHIFT macros and use FIELD_GET()/FIELD_PREP() directly. - Add BXCAN_ prefix to lec error codes. - Add the macro BXCAN_RX_MB_NUM. - Enable time triggered mode and use can_rx_offload(). - Use readx_poll_timeout() in function with timeouts. - Loop from tail to head in bxcan_tx_isr(). - Check bits of tsr register instead of pkts variable in bxcan_tx_isr(). - Don't return from bxcan_handle_state_change() if skb/cf are NULL. - Enable/disable the generation of the bus error interrupt depending on can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING. - Don't return from bxcan_handle_bus_err() if skb is NULL. - Drop statistics updating from bxcan_handle_bus_err(). - Add an empty line in front of 'return IRQ_HANDLED;' - Rename bxcan_start() to bxcan_chip_start(). - Rename bxcan_stop() to bxcan_chip_stop(). - Disable all IRQs in bxcan_chip_stop(). - Rename bxcan_close() to bxcan_ndo_stop(). - Use writel instead of bxcan_rmw() to update the dlc register. Changes in v3: - Remove 'Dario Binacchi ' SOB. - Fix the documentation file path in the MAINTAINERS entry. - Do not increment the "stats->rx_bytes" if the frame is remote. - Remove pr_debug() call from bxcan_rmw(). Changes in v2: - Fix sparse errors. - Create a MAINTAINERS entry. - Remove the print of the registers address. - Remove the volatile keyword from bxcan_rmw(). - Use tx ring algorithm to manage tx mailboxes. - Use can_{get|put}_echo_skb(). - Update DT properties. MAINTAINERS | 7 + drivers/net/can/Kconfig | 12 + drivers/net/can/Makefile | 1 + drivers/net/can/bxcan.c | 1110 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 1130 insertions(+) create mode 100644 drivers/net/can/bxcan.c diff --git a/MAINTAINERS b/MAINTAINERS index f5ca4aefd184..bba8d958e6a7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4462,6 +4462,13 @@ S: Maintained F: drivers/scsi/BusLogic.* F: drivers/scsi/FlashPoint.* +BXCAN CAN NETWORK DRIVER +M: Dario Binacchi +L: linux-can@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml +F: drivers/net/can/bxcan.c + C-MEDIA CMI8788 DRIVER M: Clemens Ladisch L: alsa-devel@alsa-project.org (moderated for non-subscribers) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index 3048ad77edb3..b3a9fb9bcf92 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -93,6 +93,18 @@ config CAN_AT91 This is a driver for the SoC CAN controller in Atmel's AT91SAM9263 and AT91SAM9X5 processors. +config CAN_BXCAN + tristate "STM32 Basic Extended CAN (bxCAN) devices" + depends on OF || ARCH_STM32 || COMPILE_TEST + depends on HAS_IOMEM + select CAN_RX_OFFLOAD + help + Say yes here to build support for the STMicroelectronics STM32 basic + extended CAN Controller (bxCAN). + + This driver can also be built as a module. If so, the module + will be called bxcan. + config CAN_CAN327 tristate "Serial / USB serial ELM327 based OBD-II Interfaces (can327)" depends on TTY diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 61c75ce9d500..bc859399eeb6 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile @@ -14,6 +14,7 @@ obj-y += usb/ obj-y += softing/ obj-$(CONFIG_CAN_AT91) += at91_can.o +obj-$(CONFIG_CAN_BXCAN) += bxcan.o obj-$(CONFIG_CAN_CAN327) += can327.o obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ diff --git a/drivers/net/can/bxcan.c b/drivers/net/can/bxcan.c new file mode 100644 index 000000000000..447d3cc27670 --- /dev/null +++ b/drivers/net/can/bxcan.c @@ -0,0 +1,1110 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// bxcan.c - STM32 Basic Extended CAN controller driver +// +// Copyright (c) 2022 Dario Binacchi +// + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BXCAN_NAPI_WEIGHT 3 +#define BXCAN_TIMEOUT_US 10000 + +#define BXCAN_RX_MB_NUM 2 +#define BXCAN_TX_MB_NUM 3 + +/* Master control register (MCR) bits */ +#define BXCAN_MCR_DBF BIT(16) +#define BXCAN_MCR_RESET BIT(15) +#define BXCAN_MCR_TTCM BIT(7) +#define BXCAN_MCR_ABOM BIT(6) +#define BXCAN_MCR_AWUM BIT(5) +#define BXCAN_MCR_NART BIT(4) +#define BXCAN_MCR_RFLM BIT(3) +#define BXCAN_MCR_TXFP BIT(2) +#define BXCAN_MCR_SLEEP BIT(1) +#define BXCAN_MCR_INRQ BIT(0) + +/* Master status register (MSR) bits */ +#define BXCAN_MSR_RX BIT(11) +#define BXCAN_MSR_SAMP BIT(10) +#define BXCAN_MSR_RXM BIT(9) +#define BXCAN_MSR_TXM BIT(8) +#define BXCAN_MSR_SLAKI BIT(4) +#define BXCAN_MSR_WKUI BIT(3) +#define BXCAN_MSR_ERRI BIT(2) +#define BXCAN_MSR_SLAK BIT(1) +#define BXCAN_MSR_INAK BIT(0) + +/* Transmit status register (TSR) bits */ +#define BXCAN_TSR_LOW2 BIT(31) +#define BXCAN_TSR_LOW1 BIT(30) +#define BXCAN_TSR_LOW0 BIT(29) +#define BXCAN_TSR_TME_MASK GENMASK(28, 26) +#define BXCAN_TSR_TME2 BIT(28) +#define BXCAN_TSR_TME1 BIT(27) +#define BXCAN_TSR_TME0 BIT(26) +#define BXCAN_TSR_CODE_MASK GENMASK(25, 24) +#define BXCAN_TSR_ABRQ2 BIT(23) +#define BXCAN_TSR_TERR2 BIT(19) +#define BXCAN_TSR_ALST2 BIT(18) +#define BXCAN_TSR_TXOK2 BIT(17) +#define BXCAN_TSR_RQCP2 BIT(16) +#define BXCAN_TSR_ABRQ1 BIT(15) +#define BXCAN_TSR_TERR1 BIT(11) +#define BXCAN_TSR_ALST1 BIT(10) +#define BXCAN_TSR_TXOK1 BIT(9) +#define BXCAN_TSR_RQCP1 BIT(8) +#define BXCAN_TSR_ABRQ0 BIT(7) +#define BXCAN_TSR_TERR0 BIT(3) +#define BXCAN_TSR_ALST0 BIT(2) +#define BXCAN_TSR_TXOK0 BIT(1) +#define BXCAN_TSR_RQCP0 BIT(0) + +/* Receive FIFO 0 register (RF0R) bits */ +#define BXCAN_RF0R_RFOM0 BIT(5) +#define BXCAN_RF0R_FOVR0 BIT(4) +#define BXCAN_RF0R_FULL0 BIT(3) +#define BXCAN_RF0R_FMP0_MASK GENMASK(1, 0) + +/* Interrupt enable register (IER) bits */ +#define BXCAN_IER_SLKIE BIT(17) +#define BXCAN_IER_WKUIE BIT(16) +#define BXCAN_IER_ERRIE BIT(15) +#define BXCAN_IER_LECIE BIT(11) +#define BXCAN_IER_BOFIE BIT(10) +#define BXCAN_IER_EPVIE BIT(9) +#define BXCAN_IER_EWGIE BIT(8) +#define BXCAN_IER_FOVIE1 BIT(6) +#define BXCAN_IER_FFIE1 BIT(5) +#define BXCAN_IER_FMPIE1 BIT(4) +#define BXCAN_IER_FOVIE0 BIT(3) +#define BXCAN_IER_FFIE0 BIT(2) +#define BXCAN_IER_FMPIE0 BIT(1) +#define BXCAN_IER_TMEIE BIT(0) + +/* Error status register (ESR) bits */ +#define BXCAN_ESR_REC_MASK GENMASK(31, 24) +#define BXCAN_ESR_TEC_MASK GENMASK(23, 16) +#define BXCAN_ESR_LEC_MASK GENMASK(6, 4) +#define BXCAN_ESR_BOFF BIT(2) +#define BXCAN_ESR_EPVF BIT(1) +#define BXCAN_ESR_EWGF BIT(0) + +/* Bit timing register (BTR) bits */ +#define BXCAN_BTR_SILM BIT(31) +#define BXCAN_BTR_LBKM BIT(30) +#define BXCAN_BTR_SJW_MASK GENMASK(25, 24) +#define BXCAN_BTR_TS2_MASK GENMASK(22, 20) +#define BXCAN_BTR_TS1_MASK GENMASK(19, 16) +#define BXCAN_BTR_BRP_MASK GENMASK(9, 0) + +/* TX mailbox identifier register (TIxR, x = 0..2) bits */ +#define BXCAN_TIxR_STID_MASK GENMASK(31, 21) +#define BXCAN_TIxR_EXID_MASK GENMASK(31, 3) +#define BXCAN_TIxR_IDE BIT(2) +#define BXCAN_TIxR_RTR BIT(1) +#define BXCAN_TIxR_TXRQ BIT(0) + +/* TX mailbox data length and time stamp register (TDTxR, x = 0..2 bits */ +#define BXCAN_TDTxR_TIME_MASK GENMASK(31, 16) +#define BXCAN_TDTxR_TGT BIT(8) +#define BXCAN_TDTxR_DLC_MASK GENMASK(3, 0) + +/* RX FIFO mailbox identifier register (RIxR, x = 0..1 */ +#define BXCAN_RIxR_STID_MASK GENMASK(31, 21) +#define BXCAN_RIxR_EXID_MASK GENMASK(31, 3) +#define BXCAN_RIxR_IDE BIT(2) +#define BXCAN_RIxR_RTR BIT(1) + +/* RX FIFO mailbox data length and timestamp register (RDTxR, x = 0..1) bits */ +#define BXCAN_RDTxR_TIME_MASK GENMASK(31, 16) +#define BXCAN_RDTxR_FMI_MASK GENMASK(15, 8) +#define BXCAN_RDTxR_DLC_MASK GENMASK(3, 0) + +#define BXCAN_FMR_REG 0x00 +#define BXCAN_FM1R_REG 0x04 +#define BXCAN_FS1R_REG 0x0c +#define BXCAN_FFA1R_REG 0x14 +#define BXCAN_FA1R_REG 0x1c +#define BXCAN_FiR1_REG(b) (0x40 + (b) * 8) +#define BXCAN_FiR2_REG(b) (0x44 + (b) * 8) + +#define BXCAN_FILTER_ID(master) (master ? 0 : 14) + +/* Filter master register (FMR) bits */ +#define BXCAN_FMR_CANSB_MASK GENMASK(13, 8) +#define BXCAN_FMR_FINIT BIT(0) + +enum bxcan_lec_code { + BXCAN_LEC_NO_ERROR = 0, + BXCAN_LEC_STUFF_ERROR, + BXCAN_LEC_FORM_ERROR, + BXCAN_LEC_ACK_ERROR, + BXCAN_LEC_BIT1_ERROR, + BXCAN_LEC_BIT0_ERROR, + BXCAN_LEC_CRC_ERROR, + BXCAN_LEC_UNUSED +}; + +/* Structure of the message buffer */ +struct bxcan_mb { + u32 id; /* can identifier */ + u32 dlc; /* data length control and timestamp */ + u32 data[2]; /* data */ +}; + +/* Structure of the hardware registers */ +struct bxcan_regs { + u32 mcr; /* 0x00 - master control */ + u32 msr; /* 0x04 - master status */ + u32 tsr; /* 0x08 - transmit status */ + u32 rf0r; /* 0x0c - FIFO 0 */ + u32 rf1r; /* 0x10 - FIFO 1 */ + u32 ier; /* 0x14 - interrupt enable */ + u32 esr; /* 0x18 - error status */ + u32 btr; /* 0x1c - bit timing*/ + 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 */ +}; + +struct bxcan_priv { + struct can_priv can; + struct can_rx_offload offload; + struct device *dev; + struct net_device *ndev; + + struct bxcan_regs __iomem *regs; + struct regmap *gcan; + int tx_irq; + int sce_irq; + bool master; + struct clk *clk; + spinlock_t rmw_lock; /* lock for read-modify-write operations */ + unsigned int tx_head; + unsigned int tx_tail; + u32 timestamp; +}; + +static const struct can_bittiming_const bxcan_bittiming_const = { + .name = KBUILD_MODNAME, + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, +}; + +static inline void bxcan_rmw(struct bxcan_priv *priv, void __iomem *addr, + u32 clear, u32 set) +{ + unsigned long flags; + u32 old, val; + + spin_lock_irqsave(&priv->rmw_lock, flags); + old = readl(addr); + val = (old & ~clear) | set; + if (val != old) + writel(val, addr); + + spin_unlock_irqrestore(&priv->rmw_lock, flags); +} + +static void bxcan_disable_filters(struct bxcan_priv *priv, bool master) +{ + unsigned int fid = BXCAN_FILTER_ID(master); + u32 fmask = BIT(fid); + + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0); +} + +void bxcan_enable_filters(struct bxcan_priv *priv, bool master) +{ + unsigned int fid = BXCAN_FILTER_ID(master); + u32 fmask = BIT(fid); + + /* Filter settings: + * + * Accept all messages. + * Assign filter 0 to CAN1 and filter 14 to CAN2 in identifier + * mask mode with 32 bits width. + */ + + /* Enter filter initialization mode and assing filters to CAN + * controllers. + */ + regmap_update_bits(priv->gcan, BXCAN_FMR_REG, + BXCAN_FMR_CANSB_MASK | BXCAN_FMR_FINIT, + FIELD_PREP(BXCAN_FMR_CANSB_MASK, 14) | + BXCAN_FMR_FINIT); + + /* Deactivate filter */ + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0); + + /* Two 32-bit registers in identifier mask mode */ + regmap_update_bits(priv->gcan, BXCAN_FM1R_REG, fmask, 0); + + /* Single 32-bit scale configuration */ + regmap_update_bits(priv->gcan, BXCAN_FS1R_REG, fmask, fmask); + + /* Assign filter to FIFO 0 */ + regmap_update_bits(priv->gcan, BXCAN_FFA1R_REG, fmask, 0); + + /* Accept all messages */ + regmap_write(priv->gcan, BXCAN_FiR1_REG(fid), 0); + regmap_write(priv->gcan, BXCAN_FiR2_REG(fid), 0); + + /* Activate filter */ + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, fmask); + + /* Exit filter initialization mode */ + regmap_update_bits(priv->gcan, BXCAN_FMR_REG, BXCAN_FMR_FINIT, 0); +} + +static inline u8 bxcan_get_tx_head(const struct bxcan_priv *priv) +{ + return priv->tx_head % BXCAN_TX_MB_NUM; +} + +static inline u8 bxcan_get_tx_tail(const struct bxcan_priv *priv) +{ + return priv->tx_tail % BXCAN_TX_MB_NUM; +} + +static inline u8 bxcan_get_tx_free(const struct bxcan_priv *priv) +{ + return BXCAN_TX_MB_NUM - (priv->tx_head - priv->tx_tail); +} + +static bool bxcan_tx_busy(const struct bxcan_priv *priv) +{ + if (bxcan_get_tx_free(priv) > 0) + return false; + + netif_stop_queue(priv->ndev); + + /* Memory barrier before checking tx_free (head and tail) */ + smp_mb(); + + if (bxcan_get_tx_free(priv) == 0) { + netdev_dbg(priv->ndev, + "Stopping tx-queue (tx_head=0x%08x, tx_tail=0x%08x, len=%d).\n", + priv->tx_head, priv->tx_tail, + priv->tx_head - priv->tx_tail); + + return true; + } + + netif_start_queue(priv->ndev); + + return false; +} + +static int bxcan_chip_softreset(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_RESET); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_SLAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_enter_init_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_INRQ); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_INAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_leave_init_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, BXCAN_MCR_INRQ, 0); + return readx_poll_timeout(readl, ®s->msr, value, + !(value & BXCAN_MSR_INAK), BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_enter_sleep_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_SLEEP); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_SLAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_leave_sleep_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, BXCAN_MCR_SLEEP, 0); + return readx_poll_timeout(readl, ®s->msr, value, + !(value & BXCAN_MSR_SLAK), BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static inline +struct bxcan_priv *rx_offload_to_priv(struct can_rx_offload *offload) +{ + return container_of(offload, struct bxcan_priv, offload); +} + +static struct sk_buff *bxcan_mailbox_read(struct can_rx_offload *offload, + unsigned int mbxno, u32 *timestamp, + bool drop) +{ + struct bxcan_priv *priv = rx_offload_to_priv(offload); + struct bxcan_regs __iomem *regs = priv->regs; + struct bxcan_mb __iomem *mb_regs = ®s->rx_mb[0]; + struct sk_buff *skb = NULL; + struct can_frame *cf; + u32 rf0r, id, dlc; + + rf0r = readl(®s->rf0r); + if (unlikely(drop)) { + skb = ERR_PTR(-ENOBUFS); + goto mark_as_read; + } + + if (!(rf0r & BXCAN_RF0R_FMP0_MASK)) + goto mark_as_read; + + skb = alloc_can_skb(offload->dev, &cf); + if (unlikely(!skb)) { + skb = ERR_PTR(-ENOMEM); + goto mark_as_read; + } + + id = readl(&mb_regs->id); + if (id & BXCAN_RIxR_IDE) + cf->can_id = FIELD_GET(BXCAN_RIxR_EXID_MASK, id) | CAN_EFF_FLAG; + else + cf->can_id = FIELD_GET(BXCAN_RIxR_STID_MASK, id) & CAN_SFF_MASK; + + dlc = readl(&mb_regs->dlc); + priv->timestamp = FIELD_GET(BXCAN_RDTxR_TIME_MASK, dlc); + cf->len = can_cc_dlc2len(FIELD_GET(BXCAN_RDTxR_DLC_MASK, dlc)); + + if (id & BXCAN_RIxR_RTR) { + cf->can_id |= CAN_RTR_FLAG; + } else { + int i, j; + + for (i = 0, j = 0; i < cf->len; i += 4, j++) + *(u32 *)(cf->data + i) = readl(&mb_regs->data[j]); + } + + mark_as_read: + rf0r |= BXCAN_RF0R_RFOM0; + writel(rf0r, ®s->rf0r); + return skb; +} + +static irqreturn_t bxcan_rx_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + + can_rx_offload_irq_offload_fifo(&priv->offload); + can_rx_offload_irq_finish(&priv->offload); + + return IRQ_HANDLED; +} + +static irqreturn_t bxcan_tx_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + struct net_device_stats *stats = &ndev->stats; + u32 tsr, rqcp_bit; + int idx; + + tsr = readl(®s->tsr); + if (!(tsr & (BXCAN_TSR_RQCP0 | BXCAN_TSR_RQCP1 | BXCAN_TSR_RQCP2))) + return IRQ_HANDLED; + + while (priv->tx_head - priv->tx_tail > 0) { + idx = bxcan_get_tx_tail(priv); + rqcp_bit = BXCAN_TSR_RQCP0 << (idx << 3); + if (!(tsr & rqcp_bit)) + break; + + stats->tx_packets++; + stats->tx_bytes += can_get_echo_skb(ndev, idx, NULL); + priv->tx_tail++; + } + + writel(tsr, ®s->tsr); + + if (bxcan_get_tx_free(priv)) { + /* Make sure that anybody stopping the queue after + * this sees the new tx_ring->tail. + */ + smp_mb(); + netif_wake_queue(ndev); + } + + return IRQ_HANDLED; +} + +static void bxcan_handle_state_change(struct net_device *ndev, u32 esr) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + enum can_state new_state = priv->can.state; + struct can_berr_counter bec; + enum can_state rx_state, tx_state; + struct sk_buff *skb; + struct can_frame *cf; + + /* Early exit if no error flag is set */ + if (!(esr & (BXCAN_ESR_EWGF | BXCAN_ESR_EPVF | BXCAN_ESR_BOFF))) + return; + + bec.txerr = FIELD_GET(BXCAN_ESR_TEC_MASK, esr); + bec.rxerr = FIELD_GET(BXCAN_ESR_REC_MASK, esr); + + if (esr & BXCAN_ESR_BOFF) + new_state = CAN_STATE_BUS_OFF; + else if (esr & BXCAN_ESR_EPVF) + new_state = CAN_STATE_ERROR_PASSIVE; + else if (esr & BXCAN_ESR_EWGF) + new_state = CAN_STATE_ERROR_WARNING; + + /* state hasn't changed */ + if (unlikely(new_state == priv->can.state)) + return; + + skb = alloc_can_err_skb(ndev, &cf); + + tx_state = bec.txerr >= bec.rxerr ? new_state : 0; + rx_state = bec.txerr <= bec.rxerr ? new_state : 0; + can_change_state(ndev, cf, tx_state, rx_state); + + if (new_state == CAN_STATE_BUS_OFF) { + can_bus_off(ndev); + } else if (skb) { + cf->data[6] = bec.txerr; + cf->data[7] = bec.rxerr; + } + + if (skb) { + int err; + + err = can_rx_offload_queue_timestamp(&priv->offload, skb, + priv->timestamp); + if (err) + ndev->stats.rx_fifo_errors++; + } +} + +static void bxcan_handle_bus_err(struct net_device *ndev, u32 esr) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + enum bxcan_lec_code lec_code; + struct can_frame *cf; + struct sk_buff *skb; + + lec_code = FIELD_GET(BXCAN_ESR_LEC_MASK, esr); + + /* Early exit if no lec update or no error. + * No lec update means that no CAN bus event has been detected + * since CPU wrote BXCAN_LEC_UNUSED value to status reg. + */ + if (lec_code == BXCAN_LEC_UNUSED || lec_code == BXCAN_LEC_NO_ERROR) + return; + + /* Common for all type of bus errors */ + priv->can.can_stats.bus_error++; + + /* Propagate the error condition to the CAN stack */ + skb = alloc_can_err_skb(ndev, &cf); + if (skb) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + + switch (lec_code) { + case BXCAN_LEC_STUFF_ERROR: + netdev_dbg(ndev, "Stuff error\n"); + ndev->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_STUFF; + + break; + case BXCAN_LEC_FORM_ERROR: + netdev_dbg(ndev, "Form error\n"); + ndev->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_FORM; + + break; + case BXCAN_LEC_ACK_ERROR: + netdev_dbg(ndev, "Ack error\n"); + ndev->stats.tx_errors++; + if (skb) { + cf->can_id |= CAN_ERR_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } + + break; + case BXCAN_LEC_BIT1_ERROR: + netdev_dbg(ndev, "Bit error (recessive)\n"); + ndev->stats.tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_BIT1; + + break; + case BXCAN_LEC_BIT0_ERROR: + netdev_dbg(ndev, "Bit error (dominant)\n"); + ndev->stats.tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_BIT0; + + break; + case BXCAN_LEC_CRC_ERROR: + netdev_dbg(ndev, "CRC error\n"); + ndev->stats.rx_errors++; + if (skb) { + cf->data[2] |= CAN_ERR_PROT_BIT; + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } + + break; + default: + break; + } + + if (skb) { + int err; + + err = can_rx_offload_queue_timestamp(&priv->offload, skb, + priv->timestamp); + if (err) + ndev->stats.rx_fifo_errors++; + } +} + +static irqreturn_t bxcan_state_change_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + u32 msr, esr; + + msr = readl(®s->msr); + if (!(msr & BXCAN_MSR_ERRI)) + return IRQ_NONE; + + esr = readl(®s->esr); + bxcan_handle_state_change(ndev, esr); + + if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) + bxcan_handle_bus_err(ndev, esr); + + msr |= BXCAN_MSR_ERRI; + writel(msr, ®s->msr); + can_rx_offload_irq_finish(&priv->offload); + + return IRQ_HANDLED; +} + +static int bxcan_chip_start(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + struct can_bittiming *bt = &priv->can.bittiming; + u32 clr, set; + int err; + + err = bxcan_chip_softreset(priv); + if (err) { + netdev_err(ndev, "failed to reset chip, error %d\n", err); + return err; + } + + err = bxcan_leave_sleep_mode(priv); + if (err) { + netdev_err(ndev, "failed to leave sleep mode, error %d\n", err); + goto failed_leave_sleep; + } + + err = bxcan_enter_init_mode(priv); + if (err) { + netdev_err(ndev, "failed to enter init mode, error %d\n", err); + goto failed_enter_init; + } + + /* MCR + * + * select request order priority + * enable time triggered mode + * bus-off state left on sw request + * sleep mode left on sw request + * retransmit automatically on error + * do not lock RX FIFO on overrun + */ + bxcan_rmw(priv, ®s->mcr, + BXCAN_MCR_ABOM | BXCAN_MCR_AWUM | BXCAN_MCR_NART | + BXCAN_MCR_RFLM, BXCAN_MCR_TTCM | BXCAN_MCR_TXFP); + + /* Bit timing register settings */ + set = FIELD_PREP(BXCAN_BTR_BRP_MASK, bt->brp - 1) | + FIELD_PREP(BXCAN_BTR_TS1_MASK, bt->phase_seg1 + + bt->prop_seg - 1) | + FIELD_PREP(BXCAN_BTR_TS2_MASK, bt->phase_seg2 - 1) | + FIELD_PREP(BXCAN_BTR_SJW_MASK, bt->sjw - 1); + + /* loopback + silent mode put the controller in test mode, + * useful for hot self-test + */ + if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) + set |= BXCAN_BTR_LBKM; + + if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) + set |= BXCAN_BTR_SILM; + + netdev_dbg(ndev, + "TQ[ns]: %d, PrS: %d, PhS1: %d, PhS2: %d, SJW: %d, BRP: %d, CAN_BTR: 0x%08x\n", + bt->tq, bt->prop_seg, bt->phase_seg1, bt->phase_seg2, + bt->sjw, bt->brp, set); + bxcan_rmw(priv, ®s->btr, BXCAN_BTR_SILM | BXCAN_BTR_LBKM | + BXCAN_BTR_BRP_MASK | BXCAN_BTR_TS1_MASK | BXCAN_BTR_TS2_MASK | + BXCAN_BTR_SJW_MASK, set); + + bxcan_enable_filters(priv, priv->master); + + /* Clear all internal status */ + priv->tx_head = 0; + priv->tx_tail = 0; + + err = bxcan_leave_init_mode(priv); + if (err) { + netdev_err(ndev, "failed to leave init mode, error %d\n", err); + goto failed_leave_init; + } + + /* Set a `lec` value so that we can check for updates later */ + bxcan_rmw(priv, ®s->esr, BXCAN_ESR_LEC_MASK, + FIELD_PREP(BXCAN_ESR_LEC_MASK, BXCAN_LEC_UNUSED)); + + /* IER + * + * Enable interrupt for: + * bus-off + * passive error + * warning error + * last error code + * RX FIFO pending message + * TX mailbox empty + */ + clr = BXCAN_IER_WKUIE | BXCAN_IER_SLKIE | BXCAN_IER_FOVIE1 | + BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 | + BXCAN_IER_FFIE0; + set = BXCAN_IER_ERRIE | BXCAN_IER_BOFIE | BXCAN_IER_EPVIE | + BXCAN_IER_EWGIE | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE; + + if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) + set |= BXCAN_IER_LECIE; + else + clr |= BXCAN_IER_LECIE; + + bxcan_rmw(priv, ®s->ier, clr, set); + + priv->can.state = CAN_STATE_ERROR_ACTIVE; + return 0; + +failed_leave_init: +failed_enter_init: +failed_leave_sleep: + bxcan_chip_softreset(priv); + return err; +} + +static int bxcan_open(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + int err; + + err = open_candev(ndev); + if (err) { + netdev_err(ndev, "open_candev() failed, error %d\n", err); + return err; + } + + can_rx_offload_enable(&priv->offload); + err = request_irq(ndev->irq, bxcan_rx_isr, IRQF_SHARED, ndev->name, + ndev); + if (err) { + netdev_err(ndev, "failed to register rx irq(%d), error %d\n", + ndev->irq, err); + goto out_close_candev; + } + + err = request_irq(priv->tx_irq, bxcan_tx_isr, IRQF_SHARED, ndev->name, + ndev); + if (err) { + netdev_err(ndev, "failed to register tx irq(%d), error %d\n", + priv->tx_irq, err); + goto out_free_rx_irq; + } + + err = request_irq(priv->sce_irq, bxcan_state_change_isr, IRQF_SHARED, + ndev->name, ndev); + if (err) { + netdev_err(ndev, "failed to register sce irq(%d), error %d\n", + priv->sce_irq, err); + goto out_free_tx_irq; + } + + err = bxcan_chip_start(ndev); + if (err) + goto out_free_sce_irq; + + netif_start_queue(ndev); + return 0; + +out_free_sce_irq: + free_irq(priv->sce_irq, ndev); +out_free_tx_irq: + free_irq(priv->tx_irq, ndev); +out_free_rx_irq: + free_irq(ndev->irq, ndev); +out_close_candev: + can_rx_offload_disable(&priv->offload); + close_candev(ndev); + return err; +} + +static void bxcan_chip_stop(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + + /* disable all interrupts */ + bxcan_rmw(priv, ®s->ier, BXCAN_IER_SLKIE | BXCAN_IER_WKUIE | + BXCAN_IER_ERRIE | BXCAN_IER_LECIE | BXCAN_IER_BOFIE | + BXCAN_IER_EPVIE | BXCAN_IER_EWGIE | BXCAN_IER_FOVIE1 | + BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 | + BXCAN_IER_FFIE0 | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE, 0); + bxcan_disable_filters(priv, priv->master); + bxcan_enter_sleep_mode(priv); + priv->can.state = CAN_STATE_STOPPED; +} + +static int bxcan_stop(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + + netif_stop_queue(ndev); + bxcan_chip_stop(ndev); + free_irq(ndev->irq, ndev); + free_irq(priv->tx_irq, ndev); + free_irq(priv->sce_irq, ndev); + can_rx_offload_disable(&priv->offload); + close_candev(ndev); + return 0; +} + +static netdev_tx_t bxcan_start_xmit(struct sk_buff *skb, + struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct can_frame *cf = (struct can_frame *)skb->data; + struct bxcan_regs __iomem *regs = priv->regs; + struct bxcan_mb __iomem *mb_regs; + unsigned int idx; + u32 id; + int i, j; + + if (can_dropped_invalid_skb(ndev, skb)) + return NETDEV_TX_OK; + + if (bxcan_tx_busy(priv)) + return NETDEV_TX_BUSY; + + idx = bxcan_get_tx_head(priv); + priv->tx_head++; + if (bxcan_get_tx_free(priv) == 0) + netif_stop_queue(ndev); + + mb_regs = ®s->tx_mb[idx]; + if (cf->can_id & CAN_EFF_FLAG) + id = FIELD_PREP(BXCAN_TIxR_EXID_MASK, cf->can_id) | + BXCAN_TIxR_IDE; + else + id = FIELD_PREP(BXCAN_TIxR_STID_MASK, cf->can_id); + + if (cf->can_id & CAN_RTR_FLAG) + id |= BXCAN_TIxR_RTR; + + writel(FIELD_PREP(BXCAN_TDTxR_DLC_MASK, cf->len), &mb_regs->dlc); + + for (i = 0, j = 0; i < cf->len; i += 4, j++) + writel(*(u32 *)(cf->data + i), &mb_regs->data[j]); + + can_put_echo_skb(skb, ndev, idx, 0); + + /* Start transmission */ + writel(id | BXCAN_TIxR_TXRQ, &mb_regs->id); + + return NETDEV_TX_OK; +} + +static const struct net_device_ops bxcan_netdev_ops = { + .ndo_open = bxcan_open, + .ndo_stop = bxcan_stop, + .ndo_start_xmit = bxcan_start_xmit, + .ndo_change_mtu = can_change_mtu, +}; + +static int bxcan_do_set_mode(struct net_device *ndev, enum can_mode mode) +{ + int err; + + switch (mode) { + case CAN_MODE_START: + err = bxcan_chip_start(ndev); + if (err) + return err; + + netif_wake_queue(ndev); + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int bxcan_get_berr_counter(const struct net_device *ndev, + struct can_berr_counter *bec) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + u32 esr; + int err; + + err = clk_prepare_enable(priv->clk); + if (err) + return err; + + esr = readl(®s->esr); + bec->txerr = FIELD_GET(BXCAN_ESR_TEC_MASK, esr); + bec->rxerr = FIELD_GET(BXCAN_ESR_REC_MASK, esr); + clk_disable_unprepare(priv->clk); + return 0; +} + +static int bxcan_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct net_device *ndev; + struct bxcan_priv *priv; + struct clk *clk = NULL; + void __iomem *regs; + struct regmap *gcan; + bool master; + int err, rx_irq, tx_irq, sce_irq; + + regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) { + dev_err(dev, "failed to get base address\n"); + return PTR_ERR(regs); + } + + 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); + } + + master = of_property_read_bool(np, "st,can-master"); + clk = devm_clk_get(dev, NULL); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get clock\n"); + return PTR_ERR(clk); + } + + rx_irq = platform_get_irq_byname(pdev, "rx0"); + if (rx_irq < 0) { + dev_err(dev, "failed to get rx0 irq\n"); + return rx_irq; + } + + tx_irq = platform_get_irq_byname(pdev, "tx"); + if (tx_irq < 0) { + dev_err(dev, "failed to get tx irq\n"); + return tx_irq; + } + + sce_irq = platform_get_irq_byname(pdev, "sce"); + if (sce_irq < 0) { + dev_err(dev, "failed to get sce irq\n"); + return sce_irq; + } + + ndev = alloc_candev(sizeof(struct bxcan_priv), BXCAN_TX_MB_NUM); + if (!ndev) { + dev_err(dev, "alloc_candev() failed\n"); + return -ENOMEM; + } + + priv = netdev_priv(ndev); + platform_set_drvdata(pdev, ndev); + SET_NETDEV_DEV(ndev, dev); + ndev->netdev_ops = &bxcan_netdev_ops; + ndev->irq = rx_irq; + ndev->flags |= IFF_ECHO; + + priv->dev = dev; + priv->ndev = ndev; + priv->regs = regs; + priv->gcan = gcan; + priv->clk = clk; + priv->tx_irq = tx_irq; + priv->sce_irq = sce_irq; + priv->master = master; + priv->can.clock.freq = clk_get_rate(clk); + spin_lock_init(&priv->rmw_lock); + priv->tx_head = 0; + priv->tx_tail = 0; + priv->can.bittiming_const = &bxcan_bittiming_const; + priv->can.do_set_mode = bxcan_do_set_mode; + priv->can.do_get_berr_counter = bxcan_get_berr_counter; + priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | + CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_BERR_REPORTING; + + priv->offload.mailbox_read = bxcan_mailbox_read; + err = can_rx_offload_add_fifo(ndev, &priv->offload, BXCAN_NAPI_WEIGHT); + if (err) { + dev_err(dev, "failed to add FIFO rx_offload\n"); + goto out_free_candev; + } + + err = clk_prepare_enable(priv->clk); + if (err) { + dev_err(dev, "failed to enable clock\n"); + goto out_can_rx_offload_del; + } + + err = register_candev(ndev); + if (err) { + dev_err(dev, "failed to register netdev\n"); + goto out_clk_disable_unprepare; + } + + dev_info(dev, "clk: %d Hz, IRQs: %d, %d, %d\n", priv->can.clock.freq, + tx_irq, rx_irq, sce_irq); + return 0; + +out_clk_disable_unprepare: + clk_disable_unprepare(priv->clk); +out_can_rx_offload_del: + can_rx_offload_del(&priv->offload); +out_free_candev: + free_candev(ndev); + return err; +} + +static int bxcan_remove(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct bxcan_priv *priv = netdev_priv(ndev); + + unregister_candev(ndev); + clk_disable_unprepare(priv->clk); + can_rx_offload_del(&priv->offload); + free_candev(ndev); + return 0; +} + +static int __maybe_unused bxcan_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct bxcan_priv *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return 0; + + netif_stop_queue(ndev); + netif_device_detach(ndev); + + bxcan_enter_sleep_mode(priv); + priv->can.state = CAN_STATE_SLEEPING; + clk_disable_unprepare(priv->clk); + return 0; +} + +static int __maybe_unused bxcan_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct bxcan_priv *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return 0; + + clk_prepare_enable(priv->clk); + bxcan_leave_sleep_mode(priv); + priv->can.state = CAN_STATE_ERROR_ACTIVE; + + netif_device_attach(ndev); + netif_start_queue(ndev); + return 0; +} + +static SIMPLE_DEV_PM_OPS(bxcan_pm_ops, bxcan_suspend, bxcan_resume); + +static const struct of_device_id bxcan_of_match[] = { + {.compatible = "st,stm32f4-bxcan"}, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, bxcan_of_match); + +static struct platform_driver bxcan_driver = { + .driver = { + .name = KBUILD_MODNAME, + .pm = &bxcan_pm_ops, + .of_match_table = bxcan_of_match, + }, + .probe = bxcan_probe, + .remove = bxcan_remove, +}; + +module_platform_driver(bxcan_driver); + +MODULE_AUTHOR("Dario Binacchi "); +MODULE_DESCRIPTION("STMicroelectronics Basic Extended CAN controller driver"); +MODULE_LICENSE("GPL");