From patchwork Mon Oct 17 16:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2434 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 443714207C for ; Mon, 17 Oct 2022 18:43:00 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id h13-20020a056402280d00b0045cb282161csf9859820ede.8 for ; Mon, 17 Oct 2022 09:43:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666024980; cv=pass; d=google.com; s=arc-20160816; b=KiE24qgkAQgR4TB1f/KkuELoQUnLvI4Y5amvsd8j/QZ1jnIbekTgf/iZ+0WSNg+squ uIqBCv5hk+uuOG86KCLiab0TqPyjaLN6RCu8BsS1YOTUZLWJbuQTF8Y861TClQwnvxnT 23NiaNLfJ0+GfFXKhJ7sIXRC28NRAZpKnqaVL/p9Syfrt2H4MRCPr9Nay7x+X2XBI2JX 1Tt562pX/qFbDW8DkDBNSQaaDDhPw3VyYRXn1c/r4Xm8FP9T6pZotnoDfFzIoS2z6tG7 lYBnIu+19CeUr+rq9Fvmrm/Bsk6NFDxYpoIE+v772+/oQ1Qu+lIHvKlUygiRWK8IPTCC y6ig== 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=/W5afid1PJjr95GzqJqrqCojDTV89ifLCBkDhHEogUs=; b=lrTf7rrrnNmEJG3XEHE9LTTd4H326V7Vn890dsy2z7VzA1IIpWQndVYVlbChpeDNxl Xs+hQjogQcMagrz/NGiYtEFgCxVtmkFZ20X0OeWhaeqlEmwcCibcx562ilv3MnMDuBAV KSfuUUhVeAsTl1+tcA6GBX5e0+TtdoknG/2rIOunUbr9YrzNOsFBJpU0PoVGqUmAlzLZ S6zfm2W2PKCJ3Fw1Pv/RK3todXpNJFMyKkAovEBgXVbMglTb5qujSHr/AmrBC0/mwq0P Vypcgkho0N9g+4g2klyArtwf4DMukUH8iwZlGOEwCizdJO4YAwSUG0mmBCt5YWYHpYFP c+Ow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=C7yaISHJ; 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:message-id:reply-to; bh=/W5afid1PJjr95GzqJqrqCojDTV89ifLCBkDhHEogUs=; b=MUPSjWj4XGgkhC8vUGgXny/vycFPCp0xbyyhnJgcgB1VT5K4VpTrk7zJH9KRVs80Vp vYGZPgGq0GzxQN3MMBkj62vAehAttl209tWjb8zoA+b18SYAyyyXxoR8lBJJ5V7E2sUl qBzK1/Ovsv0OYm/uexC5KFsRUEk05SLgi73Jg= 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:message-id:reply-to; bh=/W5afid1PJjr95GzqJqrqCojDTV89ifLCBkDhHEogUs=; b=AJW2KftENPQHKoy3D8cT+oZF87LIeyVNL8OmVUeI8J39w3zMf5IzbRqCLCHHQ+VOqs uvV5Zm3hEw5gs9UKtwc7V4BRLsSA3HIh6K6zP9/nW3TUTEPrQVSpjeM3TKLAuwwKFRim RJO1EbOBpU4gxTRwQ6rSi8XVXM5QY5S/Og91g4ghrQYy7ja8BAxGH/32PzKjCfFoWctv Ne+rkrZQAd9jaqjeIk7KH/IVVMLXeqbXlQFPvN0BTs5uKrE15zHwNSQoemHMPvx0xXal yVsLEgK/n4O6A2fs7ntziXbc6yPOMFj8YMRzBzB9a5EfER68YQdQbLcS5HIXk/655hW1 riJA== X-Gm-Message-State: ACrzQf0XZy85CiPpKsRTpckl4SyTFbJVnydARYUhiiBz33deikrCCzdA bANRSm+Bkm++41FyGPfuyi3zO/mk X-Google-Smtp-Source: AMsMyM4PYLFYHrZC4Zw8jONrefsCPQoymder+uJHnEToIawv2qTKP4ReMw+UnD5zMwDTHmMBlT6uxw== X-Received: by 2002:a17:907:7f92:b0:78d:ed9c:d86f with SMTP id qk18-20020a1709077f9200b0078ded9cd86fmr9250460ejc.251.1666024979860; Mon, 17 Oct 2022 09:42:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5244:b0:43d:b3c4:cd21 with SMTP id t4-20020a056402524400b0043db3c4cd21ls12104688edd.2.-pod-prod-gmail; Mon, 17 Oct 2022 09:42:58 -0700 (PDT) X-Received: by 2002:a05:6402:27cd:b0:45c:db6f:7e77 with SMTP id c13-20020a05640227cd00b0045cdb6f7e77mr11314266ede.149.1666024978599; Mon, 17 Oct 2022 09:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666024978; cv=none; d=google.com; s=arc-20160816; b=c0sbIKgBWKoiD0Ei31BvzKDLgANWGUf3VOQFj2Fm5xa4v8W7RrM8tCq0SFTStrcXRx RV0808Gg0s+3OQpVMkJ4uG1f9aabSgljKmbO7NRQrHUyfwceCZ5wUIRq/DI+Q/0ajG1d NyS3VP1gYJGheSZuhnQCJ98Wgz6ZpLuAPEQ0ujfjHwzd9UcU0Knm4scb7VPu0H7nf+41 omfMc7bBThe0odPf7RBgQ2TAxYAXPCOZCPFP8eNfAru/FY5z+UWraUHYrIEeYw3sXAJO 1xtttO7qKsk+3Uw/HtniO3I8RhYwfJ6hO2f7Lh9EHJYZhZx0xAhlzCSLmxctODOrf/Y2 ZiKQ== 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=Wd7qt9Y69GxtzzaG+0eDdZVNxTR8osN5UREXRUPZGYY=; b=g5Lly0ilbLisbTvH7nw0jvt/56bal2RW02PsTirHH190f4S2rMtnkxqVmOZJoOeNmk NocnwAihy6cNTE/9WZNWl3SDQy9LYFV4Ujqr1jED7oqIZGS1VRnC53+m2khp+IZEQDX3 7JngWnSGzSy+4QAnuIlKgve96rx8vvSAHjZbRZ9f1w+a9Sm/rimhe2dZ+DVXrdGVeuAi jvsrFAuHP++rH113adbmiNjs2awajbhjYAMzv3+fhV2LcJAUHRvo1y/2S45fQ80UnV3l FI/mncUeFmMVAMEzIkFXa7LgDI7Fgig/meeut22jZIbo9alaPqOuL3HE1t1KuTGY24RG wcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=C7yaISHJ; 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 p3-20020a170906140300b0078d97128ac1sor4214028ejc.74.2022.10.17.09.42.58 for (Google Transport Security); Mon, 17 Oct 2022 09:42:58 -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:a42c:b0:78e:fd1:61b4 with SMTP id sg44-20020a170907a42c00b0078e0fd161b4mr9508774ejc.289.1666024978405; Mon, 17 Oct 2022 09:42:58 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id a24-20020a1709063a5800b0078128c89439sm6437388ejf.6.2022.10.17.09.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:42:58 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , Marc Kleine-Budde , Amarula patchwork , Alexandre Torgue , Dario Binacchi , Christophe Roullier , Krzysztof Kozlowski , Mark Brown , Mathieu Poirier , Maxime Coquelin , Miquel Raynal , Patrice Chotard , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [RFC PATCH v5 1/5] dt-bindings: arm: stm32: add compatible for syscon gcan node Date: Mon, 17 Oct 2022 18:42:27 +0200 Message-Id: <20221017164231.4192699-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221017164231.4192699-1-dario.binacchi@amarulasolutions.com> References: <20221017164231.4192699-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=C7yaISHJ; 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 --- Changes in v5: - Add Rob Herring's Acked-by tag. .../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 Mon Oct 17 16:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2435 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 267484147A for ; Mon, 17 Oct 2022 18:43:02 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id gb42-20020a170907962a00b0078d194624a9sf4968448ejc.11 for ; Mon, 17 Oct 2022 09:43:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666024982; cv=pass; d=google.com; s=arc-20160816; b=IZC7fu0m+wbWUe4O+TX/DzWEo6XkobS9VtiAbZGfG/FLU5DdEHNwsNFI5uTpGTm2Mc f5OtNbJPpJ/5WzbJv/LnkrNpAMWX+g/dm2EM7RcelgzvUKRLkzGS8JUiph6y2Pr3/z3X yMK6DkjpTlXLMYWtqvCGX7UU8sMIE+8z1B2xcY5vmmDx576uIV1E3HuNNUy0VaWH/KZm HA6bJKyBFJCYHo9SPpcxMjKtjbpZgZWNnd8GMBVs0jrWBHWSdbuektoCUHoP2YNFEbEj iTMyRs7oG2PsniE3rYKUGrIUspt6mQ/W8nhRDRuU70HqEBm0JRYybG8+WIvUeFBavwl7 mM7A== 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=Umsjis9dJ9SVeQWvt/An3wuE/qNl1tSpIwG2sIRSfJw=; b=JNUAlB5ol4jrqMpZQZE0vZ+Smh6iI785zEWwvwzWAGbq+TYbOuB3FOIgMrfa6MTzkd n/w+bpKxObWpFOjZjeamnvJ9AsTYKi2h65N8aFn+X5KgpkhxRDdKC4VHBdhu6iM8Qj+u qKqooFKVmiNmdBxoF5x2iIQvmMghsD4sJW0iCnRzTqGO+ZJqvRZCgHxs/SJTOzjLn0q0 ADzcaRLLIeal+uof/s34qKCBkh8CE2CnWWVq5nW/6dyR1dwgD9u3b1+2pD9v+pmanYLU iFAB26kxvISHMezC1IKiWvlxuKhY7RiKArZs8oA/qk7BjX/nRx+pojKp4cLfA7VVXhwj +Spg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MQqDeGmh; 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:message-id:reply-to; bh=Umsjis9dJ9SVeQWvt/An3wuE/qNl1tSpIwG2sIRSfJw=; b=OzdYgrUt6RutXjOHK60XHqB93BNve9c10zZbz14xsqRQ56awL16g7LUxmOU8QbXbaS B/2XlCECnQfNh+RbS3mZa9BVm2sy0Qou5mWeGHN0Slx/LMxqB3CEaxS5jqUYM1gdzC/Y nxhXTxlq+J15q7+BN7HVMNFDWDt/9uyABJ+nY= 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:message-id:reply-to; bh=Umsjis9dJ9SVeQWvt/An3wuE/qNl1tSpIwG2sIRSfJw=; b=nl0MU24hbbwliA9UNifHW+1J0LNJSL2LkQsroKV+Cmy+jBkLY7ZwfkB+n7iBGq82WF zv0TTmp3S5oFqOqTkvb3rrSEJwoTlRgZsRxUDJYqyuiLerEGJs1mukDaOAR8tSFMpGRU mhvRM/U2DiDUVrfB53N4jcfVwYMdT6eczjyT6Mxw+fFQ1lERkq9oMejLrEu3VPrEmO6K N7IXvxm5eUzHih4Fh3DFjg4YCYlLomSdUREpREyQWRfNf1hXLAD/vV9SCtAY6vsOXWad fA+22SS/dNFkbUAobwG7I+Tg53HJThwwVQuTFbDZfU+4GVSjTaxNy/GOixvGwRo1AuN7 iyhg== X-Gm-Message-State: ACrzQf1As1TxQmuVN4YOiYn3hJOLbmRxV10eiVLXkzBUQqlqAmjbrJxz tLXJzkLnlIDqcnC5NkESDGe8EvbW X-Google-Smtp-Source: AMsMyM5+fvssIhytKY2LSuuS11n12arLSuhxAqEiBREhO3wyFu5v2NwD5z6/mElgouDAITchPBzenw== X-Received: by 2002:a17:906:9be2:b0:78d:957d:9efa with SMTP id de34-20020a1709069be200b0078d957d9efamr9214693ejc.411.1666024981741; Mon, 17 Oct 2022 09:43:01 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5193:b0:45c:bfd9:fb45 with SMTP id q19-20020a056402519300b0045cbfd9fb45ls12100280edd.3.-pod-prod-gmail; Mon, 17 Oct 2022 09:43:00 -0700 (PDT) X-Received: by 2002:aa7:dcc5:0:b0:45c:7613:65f6 with SMTP id w5-20020aa7dcc5000000b0045c761365f6mr11476501edu.142.1666024980506; Mon, 17 Oct 2022 09:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666024980; cv=none; d=google.com; s=arc-20160816; b=s8f7X6NunW6LpGKum0C3qOLk43+aqubVtK3KLEGo5SkNjKSobanwzhEImseCjQAoDC OPx4HtjEJs3jvyQXsa5aGzZ2V5Mnnu7stKqQmEt49q1EwaijKMHs2p1h7JB9mrR/Dubs gD2IwP7pTxef3RYMlMFi9HZKBRqJPY9C2yHCa0016wED/SF8v2DsRVzl/t9D7RzQy/oO pHXAk+eCK4Qh9613SYuV0IxLNouC/QLDyX4wDmhnL5ljvbjYPiAlL7UBPeHnD74No9bI OPcXA8t9Sd4Ct7DqR29nMPIt0OMedAtP5/Xyla4leao6REHNUcUbi0YBcT0lTJewBg9f /mGQ== 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=D8/Md0NYJHUSKcz4MJWTxhKaskWW/ctRpyjjxqRRhnc=; b=r/470KNAI23dl8JEpTk3LzSiTd6IGt/ckBs/DKn5ws43XtkwHnk7YnLdK69sAtxO03 yv0GhRXjhbW1o00JqYQ5BEUyHV3iueW7M5HpVswiZOWG+/iPHbYi+KRGTYXdecO//qqe sxkRTYfpWt9Pq1DFyRfwkeTKm0LByJxnGDj6X4oMQ6UGf/jgWfXx/Mw4Jb6yGMMIRkmE 9pOWfB9WdB9ukT2cwpetHfrs2tvgpH4XcZre0HeZjwFkvO9JyJEsu2J678MgWqe9d0AU kyErFY+eMyieGdvMdP4G/ox5l/BHes4i+TD/JdJ8UC3UyKhZh1eOzReJwjn8S/AuGDdn 3dnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MQqDeGmh; 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 i14-20020a170906698e00b007867dba53f6sor4066996ejr.25.2022.10.17.09.43.00 for (Google Transport Security); Mon, 17 Oct 2022 09:43:00 -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:d9e:b0:78e:2ff7:72f4 with SMTP id go30-20020a1709070d9e00b0078e2ff772f4mr9016694ejc.608.1666024980203; Mon, 17 Oct 2022 09:43:00 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id a24-20020a1709063a5800b0078128c89439sm6437388ejf.6.2022.10.17.09.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:42:59 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , Marc Kleine-Budde , 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 v5 2/5] dt-bindings: net: can: add STM32 bxcan DT bindings Date: Mon, 17 Oct 2022 18:42:28 +0200 Message-Id: <20221017164231.4192699-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221017164231.4192699-1-dario.binacchi@amarulasolutions.com> References: <20221017164231.4192699-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=MQqDeGmh; 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 v5: - Add Rob Herring's Reviewed-by tag. 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 Mon Oct 17 16:42:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2436 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4B7A84147A for ; Mon, 17 Oct 2022 18:43:03 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id v13-20020a056402348d00b0045d36615696sf6519238edc.14 for ; Mon, 17 Oct 2022 09:43:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666024983; cv=pass; d=google.com; s=arc-20160816; b=Y+Lh1zRi9UthH9x4he91maaoiJcfXCpNFJ1szNYoySE8ncGCZLspwllmwzzxX7NR9u MsyfVAQ9wGCQJo3LcZ6UvaUZV11IMrSR4PK3UvEHwwiOMgxR+IwuwXvRNRR6WgLnPxaC cxUP8cJP+uzdU2W+I4pWtCNGKjdgqVFH3/sL17EVXiogUc1GSIUdVj/tSeGl/tW5ocCq eGOvH7grYk3UHatlXw81XkqqL/zRH7VqwetsjyLnMPXNhnKtzHsYWsqZ0o8TYy6NuoXn 48G09E+NPY9uAclnrOseiIXsLGvLfzrygOZHGKO7Cu66eGyH5G1ICgCXb+ZVJJSByWZi ChKQ== 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=9uXyyl4mB0X1UXCq6iweUtQjg9GnC213tXfz4itOiiU=; b=q7agXjDx4Sp0a0RHSKa1Fk8XpZ+lYg5niDom0C+0SkZdNFrjDAwkF3D1Y1MuFTv26w vwo8c0qbuYbyCqy+fS2XtIYuWFl0o23UmhIqN4EB/eCPxCSkppS8HrAiEUC9wqU2Q67r YQfd14D0w3qruTyzdPHKVhQmhmEB6pcQherunXm26wYSG51A0dNGVncW/fTvIslcFznA /rQeb2TocoJncUR4F7Y7Lum1vueeapSUdd+8ivi0Pe+I5nevpogbhAPHvLj5adsp4KMC 2zmciwNdwcq8ediDj68+kW1GsCYwMdxc3eqjiXkn/2U0/KMWInawX2by3SCQHETYGW7o oO8Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="hsuH/17g"; 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:message-id:reply-to; bh=9uXyyl4mB0X1UXCq6iweUtQjg9GnC213tXfz4itOiiU=; b=Nf+LZeBt4JzQMFvvlpJ/1507tfGD/U3byURcJ+69+1XYhcIqyAGVUKcCcm1Af8k90o dfTO5CDTLMum4NH7VGy2uDFXoACQ47WxhAuzGB+eU1eaNmxdLzh8qpg0q7BO+wMTZEHU JbIrprmRdcr/H91nhPXOC+/rhQEaaGsdnwKxo= 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:message-id:reply-to; bh=9uXyyl4mB0X1UXCq6iweUtQjg9GnC213tXfz4itOiiU=; b=fKEjdC00T1MMAEeH0vaC2idbJfrb69cmtZbDK0NIFH70OOeHz8FNrR8VK67U/jJZfS HypKEBDw/gR7HLClBEAu4zO1G+mt1jOORMoJ6NMmXFfv/NydEHDgUyk/LoUM/RaJtyNW 2MU8bFPxp9AW+lUM6Y4R9irxKhXNFWB3c82Z+zjYmfcbAiz1SWoXK7WyWDbDrJTaZp+3 qVuKzCktYKT0JjbaTlfJR7RxnSC6M5vUlUZx18DLR/OaOMOIFVM0OiYzOXov3D8OFRCO zhT5/su7Zmf9Kvz0fAghdUWa5sVSxnIkI6DHLjDJUUTuNu0zQYKT4+IchKRGhh1fPAXb dBnQ== X-Gm-Message-State: ACrzQf1QBFapdju/6EbSBTTi2gfvPoYj2nB0G0jmE69OCph321X/ssr0 aBYJ05VmT8vVmUaHAaS3wGjgRruO X-Google-Smtp-Source: AMsMyM7EpYoAD14JuTTyp6M5E+XMyMZbYmYDE1IWzuv8PSwA3OHDwrGmkPuUQertpNfooFkbUkfdow== X-Received: by 2002:a17:906:846b:b0:78d:f3b9:aadf with SMTP id hx11-20020a170906846b00b0078df3b9aadfmr9505687ejc.731.1666024982922; Mon, 17 Oct 2022 09:43:02 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:430c:b0:457:99eb:cba9 with SMTP id m12-20020a056402430c00b0045799ebcba9ls11676207edc.0.-pod-prod-gmail; Mon, 17 Oct 2022 09:43:01 -0700 (PDT) X-Received: by 2002:a05:6402:10c2:b0:45c:3c87:721f with SMTP id p2-20020a05640210c200b0045c3c87721fmr11325783edu.251.1666024981769; Mon, 17 Oct 2022 09:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666024981; cv=none; d=google.com; s=arc-20160816; b=p3enXTI1SoXZBWBImo52gIJk3Iw4SZ+8H2pP+ykBjlWLNqQy7g6Ee0ZSMFhv7pXkxm TGoZ8qztws8cYCl6QYPu6/kb7Gpc9HYiXrma5NNMud1Ty2ECp8XtPSZ3LmWTqErBy/Jy y3zBUEAb08Hd2RUe8VhjSl6ma1tOLtSpNo44ext8Ge3lPDcSBrF/ft0l0QPmwxqA7m+y hn+50ruU7BKVWcD9/JvYcfaVHPQxVvaxZSm0KO7sxVxM2BwDxFH59OlIKhBwn/TTprGE nM4DWnPYlQIk7knSl+QHeNL+FE8a0Didztnx1MmU2p5y48cbsJ64/qZ1ROuBQJfEjBSH AatQ== 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=ytjq+5ZqtJJOKrYEaXmPKz3aw/q9ijl/XXCtqz4EuF4=; b=tuuy9Cbv0QSRw8uklwjrf3psLYQcdIClwJTszG6C24289uAfcEBlpydroJXgdowpPR wgX3DqxjMBz3k+St2+MMUg4iulp9R5wSObJlkTi0gM+ptDXWjuxqAR1T44pr9xqbct1W Cos/7SdMWRKabbhY+khGkFXvCzSMiJmT71PDy/QtW0IrjDhGXCLIpgq6qQViB7FWxD6p FuKk13EtOXvnc7LmsQoJR5EGIbJjZclUz7KLTrktcCMkMuh8438CbOsrD1vMv/rXCng9 WzKj4H6ZlO59Oblsr3qwarf9pDn/0scKkXUdyZu1Wti+bEYgsKXpCie81KXX16pfKPbr +mJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="hsuH/17g"; 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 r16-20020a1709062cd000b0078d3a2a56dcsor4079524ejr.48.2022.10.17.09.43.01 for (Google Transport Security); Mon, 17 Oct 2022 09:43:01 -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:25c9:b0:77b:a343:bd62 with SMTP id ae9-20020a17090725c900b0077ba343bd62mr9568881ejc.660.1666024981531; Mon, 17 Oct 2022 09:43:01 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id a24-20020a1709063a5800b0078128c89439sm6437388ejf.6.2022.10.17.09.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:43:01 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , Marc Kleine-Budde , 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 v5 3/5] ARM: dts: stm32: add CAN support on stm32f429 Date: Mon, 17 Oct 2022 18:42:29 +0200 Message-Id: <20221017164231.4192699-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221017164231.4192699-1-dario.binacchi@amarulasolutions.com> References: <20221017164231.4192699-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="hsuH/17g"; 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 --- (no changes since v4) 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 Mon Oct 17 16:42:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2437 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 96A404147A for ; Mon, 17 Oct 2022 18:43:04 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id y14-20020a056402440e00b0044301c7ccd9sf9836754eda.19 for ; Mon, 17 Oct 2022 09:43:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666024984; cv=pass; d=google.com; s=arc-20160816; b=WEir2j0cmnn1z66LUidy3BpK/d/5oBP4F4eSXJ34aCS48bi6jvRBSi15OsRe8oAmSP VIMRxiTOToUxIXSU0a9FdubcEQR/J+MMC673LeLE3QUmOOZrBPlRR1j5wDEKuR06cRZ5 95D9vDH5CtMOlVvWEh0lfNgsD0irNgynnPYSZpUe53+50wAFO58DcbmCn0Cc1qmwz4em SEP24xmEElCHejtuN3dhufC0kSHnYpHQkP3MTBKYoqT9tPyJ9G5t4pIB51dufevfOGBD OWrb93pECCLa40oSJqHRQchngvUfax8eU54bbcBaibj4xMlj7f85MqLvbi6OFUkPqH0f qK0Q== 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=R241sWd+SnDKrysA2N/kR1+Jlof0LEFN97x4LTLNt421KsseSFgQ23F0yaQctc+F1F t/MC/VEheEia4FKO6acwqZpfWY5DW/iMwjWRImUcVBawcao4frdM2Rt3rrm0N6r7i0wF htTYk9Jq/panPidh9+E1kDAOsOnhpIWL8XlW7JXcJeSj+d/kHLUGIlsnMYY9lGdhxM8a xX+47ptW1IO573IdFOvD9P726ijdCqLrRH8ROjp/y3M2YZQ07JeawBLTGTUVez2TdOnC HlAg9/Zs9YpGYrbYF8hyDorxU92TxDkhvG5Wlz52Jme2LLgIQUfjOb0A7jmD3mkBuyQX oFkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YuN4qQfo; 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:message-id:reply-to; bh=WPZFPC0LIg+Ui+XDjcph7phwAslDEQjxg+3LEBtUn+g=; b=FDLHYyQQnam2EtLTEMTCZOKEGl9y0g6memAUd/RW7xjqtNJ8UDFGxEPbmpYUw93wc6 mOU/+37mDC9OHmRngj8eX04X0LaKX/kz+hWKf5hoAsgYDCm2br6mDVBlkHbZGrBGdTbb YhGTCerHYaEVzg/Fq2J4JqggMT8ZOysx1CpVY= 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:message-id:reply-to; bh=WPZFPC0LIg+Ui+XDjcph7phwAslDEQjxg+3LEBtUn+g=; b=vObOdu5j30zfXguBRnEijaO5IOFLzmklCDwwH61mBremqC3VKQ2FTWBEgqnFf+EJm8 ssrepgg4OKf8pI9VJtWA4CHujUp0SerJ8zU4O6R6JXvVtOZjbZSTgc3LBwjP5rjRjXwZ Zar+HiljN1CHvvi3wwPYAypgyA+YWbVtz1llAnFLtjcjrKx/TjTdlAYr46siVxmELAXy b8Qzs2cDZKqIi07+IszAx3QWt/Vqz7XwooEB/OIrWFvjCt4Xshij6M7uGlSfA5TqmTDg IB1bh7/d7l8Xavr+jtGEnWQ8IFC7hSJVcxqWkzZycfLOvgs0VS4kWYx0VWprE/5enYva eZbA== X-Gm-Message-State: ACrzQf0eeta6kGYLG+WGByH8GBQV43KkWGxopa9RylzUjK9YGk3pqY7n EZZdoecgRE3xEdiGC6Dy61la5YZY X-Google-Smtp-Source: AMsMyM4h316B8kiCLvSKiKMl7f2T2+jxAcDVKk0DQKWgdKrKuSqzjs5u3QjFvnOHJGJYdv7a7GTJjg== X-Received: by 2002:a17:907:3e85:b0:73d:60cc:5d06 with SMTP id hs5-20020a1709073e8500b0073d60cc5d06mr9610633ejc.722.1666024984200; Mon, 17 Oct 2022 09:43:04 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:a050:b0:791:9801:e4e4 with SMTP id bg16-20020a170906a05000b007919801e4e4ls850637ejb.3.-pod-prod-gmail; Mon, 17 Oct 2022 09:43:03 -0700 (PDT) X-Received: by 2002:a17:907:868c:b0:78d:f741:7fa7 with SMTP id qa12-20020a170907868c00b0078df7417fa7mr9368798ejc.648.1666024983022; Mon, 17 Oct 2022 09:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666024983; cv=none; d=google.com; s=arc-20160816; b=aMD3YKKkW9coNVoTxXrTY6aAzmpjinln6/+EMY6LpDdqaf9k6s95LY7Ri78mxNl9/x BAUaxD+2Fp0s7bVT0LsAU2Vav+tz74LeboVRzj9xDFCEKUXBjNiSbtKeDBuPrwL6+tZg a45ITGas4bix8XAD8lwZaAKcO6adWBjgXEXIH836PDfoHFrn2mErPjXHYSTXCjof42/Q zBkH7ZgaFJMwK3Z4JcnZHnvzp6oF3ZtVUyOxsNC4XqIk+MjkvZGUCfPHD5bMkg3lEq/A 5Lx01D/EOBcuSzp4PEFKgyK+GgZQsEFvCkdGZ2SFtRgCH3Li5bW+FiBFVEK1g5Q8vq4/ JuOw== 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=rC265nphWu4Vbj2n2xpy56poQfk8rcRGjFFTuJjV6LMsH2lxtO9wIxflnkG5MqECyl BvV+W3mAUQ7inM7lo1SV9CgdrD7dsyLJXInRT7ixEA49Hu2bLlT55SmVxOo6zel6+AAY AyLoKXQlbR+CI6xpq3pwIgqJk0yJl50pGQYjFHL72Lku10OzNiYb/RXuJto2cYQhCvsC 4yiQtAzAkwPIsLmK+AUpFF75ulj5m67xn6y5qPY5oSSHZxN9VDmRf9ZUPZcFkIkKzAP3 9pnz5OzMT0czYL/3VRMCgcMKjV1EeGmoolySsmlAB+tlZ8MeFuDG+QPZx6nKP40z3kt0 C8yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YuN4qQfo; 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 lz4-20020a170906fb0400b00787f92c20a0sor3956537ejb.107.2022.10.17.09.43.02 for (Google Transport Security); Mon, 17 Oct 2022 09:43:03 -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:906:9bd8:b0:78d:85f9:36ae with SMTP id de24-20020a1709069bd800b0078d85f936aemr9452638ejc.342.1666024982791; Mon, 17 Oct 2022 09:43:02 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id a24-20020a1709063a5800b0078128c89439sm6437388ejf.6.2022.10.17.09.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:43:02 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , Marc Kleine-Budde , 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 v5 4/5] ARM: dts: stm32: add pin map for CAN controller on stm32f4 Date: Mon, 17 Oct 2022 18:42:30 +0200 Message-Id: <20221017164231.4192699-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221017164231.4192699-1-dario.binacchi@amarulasolutions.com> References: <20221017164231.4192699-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=YuN4qQfo; 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 Mon Oct 17 16:42:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2438 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 49EA24147A for ; Mon, 17 Oct 2022 18:43:06 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id nb9-20020a1709071c8900b0078d858f15c1sf4935480ejc.1 for ; Mon, 17 Oct 2022 09:43:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666024986; cv=pass; d=google.com; s=arc-20160816; b=MsW2KXNqQzuwIp/VdurR0ovkWxuA2z7r2Y9B0+3OaMpMJsPNXZ/H2OfeYxNRypjEK6 4hyH8uzahHhmsE3ARR/acPe9eteIEJJ7917wMAMWYHeNI4H9KsG/mQvBApbUiy5Y1Zmf RV9qpI+0nxupZ6/0kxDnlbdCfjaflx9c2lmfDE317rANmVXofmzh9fa0Cp2ECJhxpq/t jD7xrsWrkLrfv/W/2oMOZckBvOioePvi0J39TYvkRPKYUdAyhpjxcWlFJbYARPgxK2zN HdXPuWxhHSKWcoUq9NxIiZu5roWHbO9Yh0FWKup8GXMauwKqjou6wJjw3P+kMep+S2Nv BBbQ== 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=v95pvaDMcVe2PA/gbFnagsAH/+/sAo2lt4wIc9jP+zw=; b=Ta9TbzFly5UP+hjEGWsyg/luqg86486M21yTB+noM7UOsaCUDI9dPO28pGANb70MHn 5x1cMfWtbdEIlp3QfLVXCQCYkK+VnN+aCy5W09cNTG1VkABknClVXV/NY0bRMx5ajBD3 GoMfnueq35Iy9ePRfbezf5SyScZmtpsCZAWg8Z0ydNG2k9S9jL+zTXVPo3ZUC6nT6t6U j2cQnVjDkI6nP8VD0Hm3nOw9cw1HWhTGk4uv2QArPY7ePO12cZDaaKXJ0CoFpxPuUaws ObLtkXmlJ8+RBUroi7fh3AQJYbQzmtqDfilrPsdFTZtylmCRchKGWGqr8fEo9teQJJsL evPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AGNGPLDr; 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:message-id:reply-to; bh=v95pvaDMcVe2PA/gbFnagsAH/+/sAo2lt4wIc9jP+zw=; b=BL/q3ehc8IC04pOrq7r8lonxlId8vPjeAn68Eeq1NGVhEflXq3OxV8VjCE9yF0Kgry vx55CNMVhVCPzKsuhsm6r2tLPc1/eHxLv8w4HLGSoVtdFEFhYBwyIqwH/au90S0TCWpF BEFWSICdyMTGZcHWVMl93s6layFu5GZmKh9gc= 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:message-id:reply-to; bh=v95pvaDMcVe2PA/gbFnagsAH/+/sAo2lt4wIc9jP+zw=; b=UNlC+OldtSoqJvxktTrgcb4qo3ulK+Y5pBjZ0CryNGdAoR8phemW221CaWslD4joTs U/c5oiklNyhJbp6TkMS13MHWkhTdWE+Y15+Q8EvlcXsS4JhpOKWhmwr1FcawN1XNc8P6 Ec6ciYwUH9SMCfhmOcCZP1+MjNTvpNjTi2/ohtmNOJM90AaLe9gqhelksz/z3zvaAwmC f17h5k8ujl1dMJ1KAU9Um+qJ/ow4/tEXjiuxcNzGDA5ToRhW+gIzjfXVW9Gwokz0405X ThLrz+PzE5cQ5MpOzjUpfR9wPwHhA/sbjWZ2+2mygwayWE+df8jUUlxtdoBQiDR2Hp/P EKWw== X-Gm-Message-State: ACrzQf0JqIBjT0BDwqLI9v5+kzfOFrrn+4nSw3DxN/1+rJ0hMn1Z4NsV 3/8ecU2k5kTdxKvu5m98coWSh31h X-Google-Smtp-Source: AMsMyM71vWtrvpIfM6PHWTBTYqLlPDZ5EZasrHfalL99VTxRSAiX6MVrtxEdisSZYSWA26msky5LSw== X-Received: by 2002:a17:907:75c4:b0:78e:176e:f62e with SMTP id jl4-20020a17090775c400b0078e176ef62emr9339917ejc.736.1666024986043; Mon, 17 Oct 2022 09:43:06 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5244:b0:43d:b3c4:cd21 with SMTP id t4-20020a056402524400b0043db3c4cd21ls12104980edd.2.-pod-prod-gmail; Mon, 17 Oct 2022 09:43:05 -0700 (PDT) X-Received: by 2002:aa7:c60a:0:b0:458:d707:117 with SMTP id h10-20020aa7c60a000000b00458d7070117mr11231742edq.258.1666024984749; Mon, 17 Oct 2022 09:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666024984; cv=none; d=google.com; s=arc-20160816; b=BMLDOqKR9+QxEqK56Bvovd5s3eR43xOJ4aCwLQzWo6wyKM5FCeOIyrYzbVNNCDRc6o DmveUNRQ7N2hKYbFCTIQ9KBUydg1h4T4gLVgZ/ClcjcN2/Hn5qoEao0gxiqs4CJekDV/ Kz3l4TDXZz7IxcVtM2X+Paji1HkltVLC0WwE1SOJToeM1exHcOIKg7jSOIsYuwuibt12 rtq4YacOXMWKtH3Hkj5DkKE3dV1Jx/zhZRp+ZgeWwPXIcJnMk16+u/R/DYLtBbUM6HIK 2njngjpKVgvzi5AtHsP8bKA5bRqB93qbUADMO5qOfNzvwhojweFLO1KuMSUfkd7+k959 ulkQ== 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=009xIGJE5mGSjx/CAoLyM0J3I8f1fwn0/13oMf3cTDA=; b=boJAWZCZhk9rpk97D6pIa1lJN3DxAZoeiUodUAdnPA5XZdyKPqTb7/6KjDKFGv3NQw Z6Zs1fOC8MXTe7adl+BtMA9+y5nu792zZmk9JLMTObTSmXHfKq1bH0hU/vVcmhbM20es dG8DWVXjS1jVvwfmo1A01AL/Rr8GD8+iAMq1j5RGepw5n7n3XCed8dlsxfpelRwhnFI4 vJzXpJnIDyRNGWFJG4iYgcr/a4ebLUyCXy3/r2Av1mULnsKAAXSI7ccSM1+lkoVTaNBf aGqy8RYVFx+yGtIs4urQ6Z4SwRtqPUgqDd89cL0KXiRY3Iyo5ME/B+aXLArgkHuuOa8d oaLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AGNGPLDr; 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 v24-20020a50d598000000b00456e1564fedsor4695892edi.36.2022.10.17.09.43.04 for (Google Transport Security); Mon, 17 Oct 2022 09:43:04 -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:46:b0:45c:bd68:6ab0 with SMTP id f6-20020a056402004600b0045cbd686ab0mr11156381edu.16.1666024984294; Mon, 17 Oct 2022 09:43:04 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-101-110.retail.telecomitalia.it. [95.244.101.110]) by smtp.gmail.com with ESMTPSA id a24-20020a1709063a5800b0078128c89439sm6437388ejf.6.2022.10.17.09.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:43:03 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , Marc Kleine-Budde , 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 v5 5/5] can: bxcan: add support for ST bxCAN controller Date: Mon, 17 Oct 2022 18:42:31 +0200 Message-Id: <20221017164231.4192699-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221017164231.4192699-1-dario.binacchi@amarulasolutions.com> References: <20221017164231.4192699-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=AGNGPLDr; 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 v5: - Put static in front of bxcan_enable_filters() definition. 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 cf0f18502372..d175a0f4620d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4493,6 +4493,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..7f8831aef9c9 --- /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); +} + +static 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");