From patchwork Mon Mar 27 20:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2810 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 569414147B for ; Mon, 27 Mar 2023 22:16:49 +0200 (CEST) Received: by mail-io1-f69.google.com with SMTP id j4-20020a6b5504000000b00758646159fbsf6257145iob.20 for ; Mon, 27 Mar 2023 13:16:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679948208; cv=pass; d=google.com; s=arc-20160816; b=UmyYdtXa2yh17oRBDPSBuUAxXScXIrmYOVKAfi7iSaJej6iFPstB3HlSKXusIW4+0q arpiwwyxfkM5x30uzZoV2mgIH/obEkcjtz2ESO2r7hDu2V/8vWZaMiAhe0B80zxCaokU bYTZA3H6VZ/F6a22VU8kIZl3jKMp2WmnQEhDZtY1bzRxTM2hTFaz2Bifw5M3W+dhK1Yh KTv+sQBMKsyRgsT8BiZeMPGTdtbMLernVrZzD7mNj+4bc/W53vVSxN8aPUYialry6DfY Zzxe9bNcSClS8qO0qg+lReq1qkevFSUl5eC+y8bBALJqGfx7+jHOfFQlILUoM0ck5qeB 0qGg== 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=sYFhZQIAkl+vh+9YBoLWD+lgqP7ZsDY5a7bsmKFr9PQ=; b=XWPMtYhD03B4UBBGo9C235igJkHA4K5R5omWIqEeuzc70YezN+lwSW7vYyanYIPMGE Zs/no6FRBo6pxbCsxEd+tDfAp8llM1q04ph7+OfJtiyw9hqxlyCkV2GCDGoohehdOwxs Pwya6ehDDCFnvIDAumCs5TlZAfAu6UkTyIQqwU9AxQZ2vGfCJzD3m47jasycHh9CWLcx 9gaZ6CIGFvar+inc7YO4tgsOjqpV0jkKT3uJ+TYUbPQOzCYREVHgvJuu/2G/7mtXwtO+ 2DjWbPswor+ldvtdy7f9FRcgdmAzL+NR06101/Zn42NPF415body2gUsVL4D/5fEvo2P NzjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="CxSVI6/X"; 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; t=1679948208; 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=sYFhZQIAkl+vh+9YBoLWD+lgqP7ZsDY5a7bsmKFr9PQ=; b=A2BafTUyHMTU+BXFSPPm4EhC21VmAxgNlvXl5XTBovm/QCSuUnHjtrSw/ZWl3FFhJi hmEH6PZNfHvWICmL2d848EYaVDpq0EFzDdyX3KM/9FdT5iesEkAXAFHJwskFvkbnLpRH wZME52u4aCxhj+oaeeZAhvliEaSRi/qWC/xy4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679948208; 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=sYFhZQIAkl+vh+9YBoLWD+lgqP7ZsDY5a7bsmKFr9PQ=; b=zke/szlecbKiY9os0y7mIv70QED4YQiowY0ab6DimNtaRsRcTDIpSYFLZZqeTNPUfW hCLln93Lgdsnx80rTfco8b8VDrfomDxyGTjEHwAWJawcPXsu+SHSYIauWedOSjakFEea h2Fn57B0yuJMs35tOjuX3bpVyTinJAVnLp1njuYbwtabj6idYgj5AakzOdtHiy0qKcFq rA3jpRVcy3fB06l5PeK5B4fXAWf/+9ieaHu5ojzrlLzdVrqkbF38CR5DyYnuM8rzSvas 6eu7hNC+qL6RTwkXVaLF/9SaWb4F4H0WbOGWh8cdw1/pnQTcUEe03sCxIwPlasxhW9S3 TBsA== X-Gm-Message-State: AO0yUKXsP6W4m/Fvv2L6dPVLCDHxuefjWp2ggetcsHkOLN4115RFqH+Q RuGlRBA/zk0kTvNan3yNyJ74YSCN X-Google-Smtp-Source: AK7set/S1vq3qJez9vzaGgABIAJ/Y2YV1TWwcCM278hWIRkF9up61djvvLi/uAh1FtZ3ZXrExyczfQ== X-Received: by 2002:a6b:e514:0:b0:753:af47:d5aa with SMTP id y20-20020a6be514000000b00753af47d5aamr5334804ioc.2.1679948208188; Mon, 27 Mar 2023 13:16:48 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6602:89c:b0:758:f9d0:ff47 with SMTP id f28-20020a056602089c00b00758f9d0ff47ls1707276ioz.6.-pod-prod-gmail; Mon, 27 Mar 2023 13:16:47 -0700 (PDT) X-Received: by 2002:a5e:9408:0:b0:74c:8b56:42bb with SMTP id q8-20020a5e9408000000b0074c8b5642bbmr9435012ioj.8.1679948207543; Mon, 27 Mar 2023 13:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679948207; cv=none; d=google.com; s=arc-20160816; b=SgF2JQhmzNpFwR2CGTOcXMwtR+o18ndHpOnwlCYwQ1QUolgwF4pOM9K6W96vtQ1euj Gw2Aa6LAHRvbo2nkJHA3CA7m4EZKHoJ075zvmDQHcOVPmegSmcwQcIWVwwfgOFbq0h5i AGTQgbD1U1vqVWLrAl3Gob/Ny757lF2qivxJ4zbJWz/pQfhQKTsYciPRUfvgyNwrJDGv EIESiRtD39vHbPJ2ZLXMKBCQmQhmYMtiXy0v4KYca7P5I6A6i4rhq2ofFfegV39G4jmr SK6zB3LVENqxXTiiSGRgVZK1jEe50N0ApGQLClTloY0yOfEJqKKeTMQXDr5bspW9hF/Y T6xg== 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=naF6lvSQb9TRc8Fh22LBxD4avClkKSEDkyx9CDmChC0=; b=wefNcz0aMusi5tPsroi1dkc8VI77Boqwn11LIs43ZLmiFguYI/7x1wJmKeLshzLfdU 73xrHUIMNh2QRW5oPywHjC0lkxBm03RyKP9xLihhKA1GI+tFqG6KB376dEMnKxXp/H9Y eHclIrYcKnEbYPhPIZvMP5ncFykzbW/c87nyj1fjIXH11/Jq6ZvgP4au5M/aD4GGtJ5Y K2jN1V/N+T5KSvmmNL42Qze5YLnqn4SyYjIpDUX03pIC/SMcU0gCgyCl/uC20YPVzrKT MN0e+SMhpPvY6KehIPuxdUR5YCOQz0BiGne47mvQquL51JXNRumFmZKc6oUyGJsOFsxp RX8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="CxSVI6/X"; 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 f11-20020a5d878b000000b0075c925cf1e5sor26025ion.86.2023.03.27.13.16.47 for (Google Transport Security); Mon, 27 Mar 2023 13:16:47 -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:6602:408b:b0:758:9e69:13f1 with SMTP id bl11-20020a056602408b00b007589e6913f1mr13224545iob.9.1679948207250; Mon, 27 Mar 2023 13:16:47 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id u26-20020a02b1da000000b003a958f51423sm5594759jah.167.2023.03.27.13.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 13:16:46 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , Rob Herring , Amarula patchwork , Vincent Mailhol , michael@amarulasolutions.com, Krzysztof Kozlowski , Dario Binacchi , Christophe Roullier , Dmitry Torokhov , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , Sebastian Reichel , Ulf Hansson , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v9 1/5] dt-bindings: arm: stm32: add compatible for syscon gcan node Date: Mon, 27 Mar 2023 22:16:26 +0200 Message-Id: <20230327201630.3874028-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230327201630.3874028-1-dario.binacchi@amarulasolutions.com> References: <20230327201630.3874028-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="CxSVI6/X"; 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 v9: - Fix commit description formatting. No semantic changes have been made. 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 b2b156cc160a..ad8e51aa01b0 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 Mar 27 20:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2811 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C722A4147B for ; Mon, 27 Mar 2023 22:16:54 +0200 (CEST) Received: by mail-il1-f197.google.com with SMTP id d3-20020a056e02050300b00317999dcfb1sf6656509ils.4 for ; Mon, 27 Mar 2023 13:16:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679948213; cv=pass; d=google.com; s=arc-20160816; b=Q0reX9Q0C7fvAPp49r7qjZb0KSLdOzrGpsiPstZqJwZIzORGPPcgW7m5lh7Y9WV8gs 7BEf3p1ViBiBvcIywgaJlULso8wO9rgdpZ7MnzcR2XHMUY4ihmybWPMsih0OgYx7GqIj wHplBEvjclZu6j4kbi+QXY/3IevHEBZNfMjP/EVdAcylO9xIK+Leey+89C//YW36fzwV /dyzwqnWotr51S6NsZw5oc1kttl7g26bz14YMGKQOz/wP/MG0cS3a7aqpyjSw1I8ZCyC Tf535z94MWTLRDk29q5azlLvpqdMRIO9nTs2tE2qN6n/8Ome3tCqgOV4/ol6qtJckr1k StIA== 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=9reRBhsAv2aCm0W5uieHO8UkPzT/QYPVOAlQ9eBoeRE=; b=nGixTEG4WH9o0wkor2ewwyaJoJfV6N1+4/A2HH7H+TPeLy91XgbcH1hsZn0MMQHubI 0a6YCtGMTqrDprfqQ4+tVtYSfnYydnIrQlP3kh6tez3OAr62+NmWB1bPVE+bNl4dbjXx PsRFV/d/V6GFC417SDCj6oyDQrGHoAZaVYkdMThYYajmfNHPMxJ5Z0p1K/GgRb6lN2/E E67gML022jj4diQjxZkBpWR3EiV8CVzbV6ytseJfasLWIsH9/V63okQf3e6CgNny/ZiM Vak/zCknLYYXKq7xWPzGQ/R5aNoVBCu4fyamQSRFbVx4JDUOqkjv26rM1s1H8B2w7KHN xlhg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="VwgC/3Jb"; 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; t=1679948213; 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=9reRBhsAv2aCm0W5uieHO8UkPzT/QYPVOAlQ9eBoeRE=; b=UrtGcurF9+0eVp3HWAlDMMrRYibsh6nf4B2xlXqecVqvRBbcgE+NW4r5KT0bWFLv6p gL+hziRxTrHoqSDmwZyuKJJjPUFEPsHh1gl0BzP9U7ud7UgedPwLMrqlLfJhzNZdrkHt Yy5IYas6b04R6G2Hz1pLSeKiNAY8g4nOzAPiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679948213; 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=9reRBhsAv2aCm0W5uieHO8UkPzT/QYPVOAlQ9eBoeRE=; b=vhmhD5uxNwYwKEToHuLUi/W8fj0vQXv7oNVh2VyxBFcqOaaPeRGw+bKiHuUNMixxSh c3Rlb3f//KW2UTan65spSEK6dekejsA0RzAZxr9xz75KxTxIeu0YllZSATRQuZT54ana Wuwrp/2pD2jGAlYfuaYcGzVqO0IiI6I2tB/6/SdIpZasjGBM2D/wEacTDqWfErLxZIa6 Y5RL1CKEFaaXL1oc0TGV+FKdfSpG1XR4w+ltGMOrguWD9pxT08LSuA2QSPqomQ7a981Q lerxAq61ahYL6wYdavwDY2fmVZiideNCIuceIi5dcGrnxzUiLkoy5hPHwKvYUvEJKLST i8Ng== X-Gm-Message-State: AO0yUKUFlLm6KO7NUtZuV4DuhM/KuFbFL0Qli6FOhgIL/r9+ksNvJz3S BpnIvJ5X5uelF6RPFcY3Trn6Vzbk X-Google-Smtp-Source: AK7set9wSpIGs4HiaLHj09u/11U9PxADECzC+qFu0mbUbFzcBGohARgKTDdrfX7WE20Ctv4YlQhkhQ== X-Received: by 2002:a05:6638:1603:b0:3ec:46d4:e15 with SMTP id x3-20020a056638160300b003ec46d40e15mr11932850jas.3.1679948213794; Mon, 27 Mar 2023 13:16:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6e02:1b09:b0:326:4b:d61a with SMTP id i9-20020a056e021b0900b00326004bd61als1361753ilv.1.-pod-prod-gmail; Mon, 27 Mar 2023 13:16:53 -0700 (PDT) X-Received: by 2002:a92:c00f:0:b0:325:b816:ae56 with SMTP id q15-20020a92c00f000000b00325b816ae56mr10214116ild.20.1679948213182; Mon, 27 Mar 2023 13:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679948213; cv=none; d=google.com; s=arc-20160816; b=ALDyrUFsU6+bbQ/h8XdQ+4VRIjL3fivMNRUVg19WWPtleKhNhVXz8LvYamWYkBzA4C JkN0wLgfOlNyVVZl+b8DksiM6mRtu5RmMD+rIZRkfSdL6WVyN9TuY4dDBi8wwJC3UlWb s1C+GsW2RsYiACG5/oUsIQr21nONxvPHMbpb2LNhsDW/INGX6bFGuT8+rU7HzCoEnq44 ZjNUg9E9j7om9ixBMNS3OX7/qmLw69fX9XX87yOsA9sOPCJ8ATzFh/mQdEOMxTB5DT0G 8ic2wd1YrOExekXfNivm63Tg5+BUcMbWymP9LGB2Lg3IrWqMPVkbJ6ft4V+Zw8Brl+ro Z9CQ== 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=kfP3t3lS3idk7NC8xKbJ1ZUbNQe0L9Qw+EDLBJRD4xA=; b=vjFJHOYQnL5dxI93wxfKTDgiqvKoH8sZYkrf5Z3Kmatv4pY2M67b0cqi8AqxY9yXh4 LGmcO+d55PVe14H0tgEeQXtc5cuP58Ce97by5DIz9SuKqO6JL5FTn94YmptuYz6ZqxXn XUYsMP+LWGbB9i5urSO771TEV88EY3memhRMH9fuMmoXMkrXcIZJFjSlEnPmYjnw/0Tl eqh4KEkfKo1vEQTKrIflcaPRmvJEYQKcLqP47/+bpbToa33DcIaI93ZFcYbJfb2v/YfM iWaviQzHxtMT9cYMfLK0q5/1Cz6Z3fGEKKY/qgMKWuqcBzONQ8XOSzAtHRo4uJf+XfKb N0+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="VwgC/3Jb"; 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 c19-20020a928e13000000b00310e10a61e3sor8311577ild.100.2023.03.27.13.16.53 for (Google Transport Security); Mon, 27 Mar 2023 13:16:53 -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:a92:d242:0:b0:318:ae1e:ccd5 with SMTP id v2-20020a92d242000000b00318ae1eccd5mr11543956ilg.28.1679948212885; Mon, 27 Mar 2023 13:16:52 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id u26-20020a02b1da000000b003a958f51423sm5594759jah.167.2023.03.27.13.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 13:16:52 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , Rob Herring , Amarula patchwork , Vincent Mailhol , michael@amarulasolutions.com, Krzysztof Kozlowski , 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: [PATCH v9 2/5] dt-bindings: net: can: add STM32 bxcan DT bindings Date: Mon, 27 Mar 2023 22:16:27 +0200 Message-Id: <20230327201630.3874028-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230327201630.3874028-1-dario.binacchi@amarulasolutions.com> References: <20230327201630.3874028-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="VwgC/3Jb"; 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 v9: - Replace master/slave terms with primary/secondary. 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 | 85 +++++++++++++++++++ 1 file changed, 85 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..ca97ba3c2b05 --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml @@ -0,0 +1,85 @@ +# 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-primary: + description: + Primary and secondary 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. + Note: The ST documentation uses master/slave terms instead of + primary/secondary. + 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 primary and CAN2 + secondary) 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-primary; + st,gcan = <&gcan>; + }; From patchwork Mon Mar 27 20:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2812 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D25104147B for ; Mon, 27 Mar 2023 22:16:58 +0200 (CEST) Received: by mail-io1-f72.google.com with SMTP id z65-20020a6bc944000000b007584beb0e28sf6155170iof.21 for ; Mon, 27 Mar 2023 13:16:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679948218; cv=pass; d=google.com; s=arc-20160816; b=SgcIvYrF4EEZZaDiaoMrO50bHTH7djm9QjKjP2Q7wh7kVJPWlbBQyQGlResF62w2Hn sAfnescupW+F62sx56LJt2F6R6IRDcY2cMbFk92RkcAVQUFy9fG83DDO1UE1jerUtF7o Tz25duJtzqpQwNgMBvhCxUatAD2QkfxgXfTNMxoL/ApMBYYpXfwJbOcpUcf/5EmlYht3 xwedKC0D9vW2emvvc1h5yQHdux2p9xwqWfYfrOYtBZdpfKf30bU2XuhfotnADn4Lvcri sTKcnvHt9GVavWJAG/k/bHK0cP+OjkJFJTxnfILAALw6z9S9wGZ75bINx7uvVqYznZ/Z pSUQ== 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=qVqFuwC+I0afHiAsbHLiU8Gg1EcbyTSQZggc8TkFR0k=; b=PnePfZA/xcFu6qJyCDBTrkAHrK8qFQ3AyahOu6F+SVr1I1KP/Ghl6w0pfETfk1F37o XU5dHGKbEuT31D1iKwLqFPyvYwUjem4qW3LeKXVSOS38CTvHdv0MaGU+10v9LqlrYG0K 4iTBdk1U19e6nOBOc4crr3WkPe2IJ0Jl21lxONfaA6Bs3f7Q02qLOvk4ojb7BxI/KqEq 1tbULIBQpOfh3CQd+HfI2gR1w8C6b8cYrhWUitAWEWE69RzoJa4eM44SEPO6npq4btTd XW4aDlmUnEuSM5lR/F8pKNjvEttskY8z17oWLgPUssR9n2Y3I6z+N/SQyT+/rnK9rc13 9MWg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JTjIYf+c; 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; t=1679948218; 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=qVqFuwC+I0afHiAsbHLiU8Gg1EcbyTSQZggc8TkFR0k=; b=euA7tX1t7psp2j/G+ljoA8gezarNurH31DVOZXrkxIeVY4IfwxnO3lOhxTt1HiFBu6 kiS3rqBDKcGakrDmXFVrDMpdEzoPR5mVyruxItdz+6od4x80XwWqQXN3Sv6p6yYvUkqR M2vNdRRHyM6WBDkEN3SteOXwBbyXcXuT6FepY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679948218; 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=qVqFuwC+I0afHiAsbHLiU8Gg1EcbyTSQZggc8TkFR0k=; b=vmM5/Mp73gAa2TLGhiTtT1A7TbZuszz/m5jSl/RAQufd4XAj1vvi9pDluc9w/XP9E0 gqwaHlkwavsU+ADrsGR7TwllfkUy6tLjUmgI9RhCqB8jXxOsrepV4GkAd26l2REl/D19 3SIQXye1xGXk7So0sf4+OuMt1Upwk8WpSSxp3yzAxv89lbfwpy494DJ9A3aUF3+dz7wk OD7W+cc0xvUlXt6nEL8DwTRhHmj95vx5kthegjwnM1Xnfd4WTjZOUuaIrQLmMiwfM9kq K0KKF/l/uc8Pc6ALQE+N/dovRHZgerzEUz3jNnX3ADvSmnDZU5SUujXHmNOxdgVk1/w3 W+ng== X-Gm-Message-State: AO0yUKXoquOZuhl5q8e+icP7mgBLIyKfmN9RahZDZfSVcFHMR7f0sPYT oBM+u8NNiYbCTYp0mb/A8/w582E4 X-Google-Smtp-Source: AK7set+hgfkI6j0MjwrJ7H57CehWT2l9DsMftDOwMK8v+Csr4LpXsjpEgPKM//nuaSttM2qQaRkVWg== X-Received: by 2002:a05:6602:228a:b0:74c:8243:9290 with SMTP id d10-20020a056602228a00b0074c82439290mr4835150iod.4.1679948217831; Mon, 27 Mar 2023 13:16:57 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6e02:128e:b0:317:979d:93b3 with SMTP id y14-20020a056e02128e00b00317979d93b3ls2819371ilq.9.-pod-prod-gmail; Mon, 27 Mar 2023 13:16:57 -0700 (PDT) X-Received: by 2002:a92:d08d:0:b0:315:9891:85d7 with SMTP id h13-20020a92d08d000000b00315989185d7mr9157634ilh.16.1679948217233; Mon, 27 Mar 2023 13:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679948217; cv=none; d=google.com; s=arc-20160816; b=zsDcy/955wuY8oB9gFJ35SnEvrHo/v96aL/K9OA9pglXYJJZnrDXdo7W04GA/5et1j A3cV0p1K0yJp06C0qYXTEQCODye+IbD40wRekLdKe/WTgcg6ROOMSl9rhB7bsF0nAwIk sVOM0S3x5MkWboy/R+KGo5qgvDMSWS6VUY84zWizPkXQpv3EEoI2Z+fQBpYXkqGWuEWL 9mlFjmwSRsv8COW7l/2mvurL2bMSbyyUhkASpwfaLhjBVkUh6CIb5GA6ul5iexTVmdE6 uoXwXgdQeimuDJbYdDjFAsAssBlaqHAWsE7pFiXPiwXaBc3dfminDjy8r2ZCUDEt18jL 2vsQ== 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=PQBAqyGpgtibuEQ07wkfyoJFQhHr9Hz8PDMB/KLLeHM=; b=o5NAMaL7L/tcUu+nbNM9hPxk9hrBUWsWoGyCk3FFYAJhQkD/cWDXlAEOlvIoRrhmou GSmNeTvfCjWCNzZ02uDJeaiRb8sBhhTfmNa9ElfcQVgnJwIi+FE3hEP9E6fu8ywxfddz b7SOi117lFSErQz6ujwVWaV4acFLTTEdrrlZcV4pjV6dGQGGcSoZoo+DQLjO7rFXfeJN swgdp44EHNtaQu9aGNPkFY6eDg+VzenN9xHWVXICdeyWQhNezdbZHY6JGa1Z0zpxObfr cU3s47jIzoYXJIcUiVPFFMOYanW3z7t+EifPLGCQSMUQhTkg7X8QXVHegcRYzydgdl6C y6bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JTjIYf+c; 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 f17-20020a056e020c7100b0032611f430a4sor820022ilj.158.2023.03.27.13.16.57 for (Google Transport Security); Mon, 27 Mar 2023 13:16:57 -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:6e02:1212:b0:325:dc0c:73f5 with SMTP id a18-20020a056e02121200b00325dc0c73f5mr8544921ilq.14.1679948216966; Mon, 27 Mar 2023 13:16:56 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id u26-20020a02b1da000000b003a958f51423sm5594759jah.167.2023.03.27.13.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 13:16:56 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , Rob Herring , Amarula patchwork , Vincent Mailhol , michael@amarulasolutions.com, Krzysztof Kozlowski , 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: [PATCH v9 3/5] ARM: dts: stm32: add CAN support on stm32f429 Date: Mon, 27 Mar 2023 22:16:28 +0200 Message-Id: <20230327201630.3874028-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230327201630.3874028-1-dario.binacchi@amarulasolutions.com> References: <20230327201630.3874028-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=JTjIYf+c; 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 primary and CAN2 the secondary, that share some of the required logic like clock and filters. This means that the secondary CAN can't be used without the primary CAN. Signed-off-by: Dario Binacchi --- Changes in v9: - Replace master/slave terms with primary/secondary. Changes in v6: - move can1 node before gcan to keep ordering by address. 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..c9e05e3540d6 100644 --- a/arch/arm/boot/dts/stm32f429.dtsi +++ b/arch/arm/boot/dts/stm32f429.dtsi @@ -362,6 +362,35 @@ i2c3: i2c@40005c00 { status = "disabled"; }; + 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-primary; + st,gcan = <&gcan>; + status = "disabled"; + }; + + gcan: gcan@40006600 { + compatible = "st,stm32f4-gcan", "syscon"; + reg = <0x40006600 0x200>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + }; + + 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 Mar 27 20:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2813 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 439524147B for ; Mon, 27 Mar 2023 22:17:02 +0200 (CEST) Received: by mail-il1-f197.google.com with SMTP id d3-20020a056e02050300b00317999dcfb1sf6656787ils.4 for ; Mon, 27 Mar 2023 13:17:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679948222; cv=pass; d=google.com; s=arc-20160816; b=YwXDnoTe9UA5yBlUOPi/8CyGZOIBMxevbkELPEBpQoSQyw/LfqOAugJcpYLI5GO0Z0 zFeGnqLhWOWObv3pSglu/VwcN/Tosn2irLKQkoa3CXOtzDW/3vVu4/+I+Vf7Cx7SdsNy qQPqUh2aNwQGYLxM036B7XOSuLIKj/ifJusxfdLTC5oEaujki0Luo4WkzoQUI3WY+Aub xeguznq23rH6okw88WulVnA5kuPCYK62HXXMQUNVk04z3gFPr1gSVv6K/1pa92Jp558U wGZxkGQOX17ei0+31fIkhjKGPWxAlrLXjC7NdEgkGX4V7k4NOgA/YuJvfRgoFCx1Ve/k 2q1w== 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=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=wkRsn5Rh3Qcd6kBHY1r0Cml/FHorqDA//FcIlAkdhLTuYJnMSiVFeCH3lg3XTg6kiE g2CEfINimg2q9YD+J+MR+AMSJDWoIs9SWgGV8/U/i9TXVexYZAoJ7dMltLlZ1VQ2Vbkj MX7OnibSAZ2gVoa787dwxTF6clWoionzG1aGEzzXTckLt8jL4wiGboRr4YFTW87nfrpy cz2NxUxbHL1SLbOAs5Wzlpk5RsvEknVY15LjZFlbKSIqifTU3XY9RDQmNvmZ1jAT3oJf kHDL0carRz+l2xveBjEYncqVogW3F8Yu4ywRcu+IANidR2qpMWNDRf8TNWonSrMJ+QC/ jSQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=frMVCmup; 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; t=1679948222; 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=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=Vdes/XAzUixqEX28ATIKLrZdOK6jb2kcjm3o7k4nEhiOzkJLoPWe7gPmUQOkyp5Q2/ hkfss5tmniH6mV9AryY9UvuSEk2WvkmHCEUdxMvlnfFqX/O6yNDVql6w21ekF67czV0Q Ik1hrjj7h+xIrZZ6HB4bRTXrjZhDIBu5gQrjs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679948222; 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=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=pP9IgozeZhBEqIg2/hM6SE9lATymSpubWZqJO+KLY15/YYLhFK2jLUR8/RPZJUV/2J LasYCcJ4UWIUqhI//jVOEmwax5JsnGsHC5vSPyRJnoH8JQkCD/4dUPCzVl43ecjctJwr jc3r9yNBNXsuTfP72XF0zeqtim08nbPoNEU2RLM72lSse8ONcgaLCSc0lMVdIBY6xG9n r/ax9zfQ/1CX0rsSia5hLiWczcUJkZZQeGFqdMBv35o19IzPTngQNqKXJSUZkkw6yV/K ZV/Sg8jlct3PWoQ15YiHHb6gM3AUuAdBH0CKZF/DTHZ8Uui2gQq4mP8IJpiL6Vjl4wL3 Vc4w== X-Gm-Message-State: AAQBX9dFMnsvh3Z8CtKn7EPi7Ay53qJkZhKV5hcj85r4jV5qEzhSOdeb NxRkoZ6VaLd7RNc46cI9YdLJMP71 X-Google-Smtp-Source: AKy350aYatd2QiC/Fa82ThFS/zXycg9rpNd/qApC1GE7ZMrGSVBfESWLKQDd6gnrcX9pNiNEqqowlg== X-Received: by 2002:a05:6e02:20e3:b0:322:f178:a74 with SMTP id q3-20020a056e0220e300b00322f1780a74mr6117377ilv.6.1679948221868; Mon, 27 Mar 2023 13:17:01 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6602:2e8f:b0:759:695d:4baf with SMTP id m15-20020a0566022e8f00b00759695d4bafls1563993iow.5.-pod-prod-gmail; Mon, 27 Mar 2023 13:17:01 -0700 (PDT) X-Received: by 2002:a05:6602:3405:b0:759:410c:99b6 with SMTP id n5-20020a056602340500b00759410c99b6mr11406178ioz.2.1679948221236; Mon, 27 Mar 2023 13:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679948221; cv=none; d=google.com; s=arc-20160816; b=ECEExYwyWIS+/OnG3mESkXkpWa93BM0H2IdlYWiCp2pqhBbFErA4c/eUczQ1jSF5Gg S5vbHLEpMEzh6OFDoZo8rgp+oBb3X9fRxI9a7U8P7uGrSVH481YihOlOsYgkaLQNRsVA fadGChaIY+4tUTINpGmDH5kW+gLo1iUzTXrA+1qx/dTwpvOtVtHihuBNbGI+BwKydOcu AWOSutD+SO7hrOa3+TSpDUzWRE/kZb7gLAGLQKAJ2GAbGJ2t59PgMPUrsty9xZqies05 SFmyfS7Hih9kfuIDE7bdHOU40HY67bApcK6komoCCDskkQgCIuFPkaGh3nY6sNfO89HO 7kJQ== 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=QV3iGa8KiUlr1LClhXl1D1BGw0maVF3hcUmABXx2qKM=; b=0chFFEg5rsUHGlNIqscYVak2JgsAUKkxH6FEJiovmDZltpHnFchSzysdcxWzVzUIba cxcRrivm7RStBIurncdeSgq1wI8Y2DONtO8YvZQAqkpvS2tsG3c0GQ/Shf9wjUmOiZKb v05PD5UnHcBCKOlKi++i6a/3QgPcFNxNl56lv/M10AI2lbWJHak5pUrjpvKLVo3Bs3uI i2bRKZaPR/Gl4v3G1+0ur/Cs8MbUg3WSHPK9xsMt4uOYnzhBfnLq1P/hOG87YAWvHotL YkDUCkcADKmGaIaApjchllBmwJm8J7uHFP61AFRM2gm/3/CqWB2v2IQ9yOMh+GKVdXn+ c06w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=frMVCmup; 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 i11-20020a5e850b000000b00752e2876b75sor3400047ioj.8.2023.03.27.13.17.01 for (Google Transport Security); Mon, 27 Mar 2023 13:17: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:a6b:c90d:0:b0:75c:90f1:4622 with SMTP id z13-20020a6bc90d000000b0075c90f14622mr195013iof.0.1679948220980; Mon, 27 Mar 2023 13:17:00 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id u26-20020a02b1da000000b003a958f51423sm5594759jah.167.2023.03.27.13.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 13:17:00 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , Rob Herring , Amarula patchwork , Vincent Mailhol , michael@amarulasolutions.com, Krzysztof Kozlowski , 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: [PATCH v9 4/5] ARM: dts: stm32: add pin map for CAN controller on stm32f4 Date: Mon, 27 Mar 2023 22:16:29 +0200 Message-Id: <20230327201630.3874028-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230327201630.3874028-1-dario.binacchi@amarulasolutions.com> References: <20230327201630.3874028-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=frMVCmup; 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 4523c63475e4..3bb812d6399e 100644 --- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi +++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi @@ -447,6 +447,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 Mar 27 20:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2814 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D4F7F4147B for ; Mon, 27 Mar 2023 22:17:07 +0200 (CEST) Received: by mail-il1-f197.google.com with SMTP id i17-20020a056e020d9100b00325a80f683csf6785425ilj.22 for ; Mon, 27 Mar 2023 13:17:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679948227; cv=pass; d=google.com; s=arc-20160816; b=FLHAi2wz520vrLw5vEVnjnk4BCKxjGLwsN1fxYeOudgk5fIkd0LTHBlNRcFIV4Ab94 N16cYN6jy8t196W84f9X3SoQJMig1kJ9CS//paZOTCB0eHmmGzw/gYwXwZnMV1s/JHGV aWIags0uni4QHzrNQjDY+CYwvDUZuFYvLU6dTd0Wy3e1zRUKBuB6F70kAlp2ziIOFXk0 Rp/fU8B0hj2jpRmFBQOTlnWdQXzrFcJXapkW0JF8ZOIv5/nTIMys5Cfs/ycB81p+5A5k g1uWpNVwNNfUy7COMD1zxPniARFJwiFNOZNhgFm/wrGFEWVwoiUB5UzW8l0LpQSuwi7G Iamg== 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=R7KxPOk3zeFSfYNcGHyychwRSsstHEitzQ2fbmykLDw=; b=nJji9/UrXWU8ntkIpsBAPOY16Al1yPACtRLk6uNXYCQDHJqbWNtVT9gve0ygTqvIoO 0tEuWdGVGixOvQPpS69hDE38aLU2obHb0ZAGFBp8vT7VQ+D9nzGF7cgnpOqD/ZmMv0JW FbVgJYHPghL1b3IDdvVCD7lm3vSnMDKPbk2vdIokuFnsgdFcVzM+L5d61ypmGVCwLwHf 1BF/PR+fdO0/Bt5uTX/E9xOnZLtMYlJQgoc1UcEmGUkU5MkEMzvrdPSz72ssW9IriBYi zg8tVi5NCMuW/D/5Z0IwB/JXAAlwsyPzZe9wLcqK/kwQYUkssvhbyoC1z0pGT8iLtfnP FnYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=m6ikQmPL; 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; t=1679948226; 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=R7KxPOk3zeFSfYNcGHyychwRSsstHEitzQ2fbmykLDw=; b=SheMK3mBS3M23ahRWKZBgSO2x0FM2jM8xcMg/Dg026myVeWLT2L5KZXFD9053jcEzL iqqJUHlEUnUc6Ctc0xgfKzXFGtK8HQt9YWkW+SlVFiso7qwvQlsPpa2itQWIWrY5iJiK L/M2ppQoKED2u9be1GJh/2ttlDjM1xrM7+bMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679948226; 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=R7KxPOk3zeFSfYNcGHyychwRSsstHEitzQ2fbmykLDw=; b=W530NajofLfjiMl9r8hCEAdmQ22a17jCr9LulQy8OaMiRtLYUGMDH7e3Ez8/K1tnS4 fj++sEBQRznNcbuOciyccOhQ9J/yAK9z2neVR1dix+4sb82guaU23SKxa9RYu0ywUHAT jBqHdOwl5B3BPezBeYfQLAed4VZghWlv5VbjFs/vzjE3jlfIZOaXEjMy9Cyu8BmMWA1n Nnj6kQb3XVZt02710dtEmhXZd/ylhkvo7gk2g4B/1mxhBGyHTXyBVqqNzKDv+RfEPvJx RT6cJtzMMHHy7EOhHb0fEQfkZAByd7mzqYCjuWJFsU9r3zfRfYqcNgB+APwnNQv7DCiq UQTw== X-Gm-Message-State: AAQBX9fkqHduomL6q9mTiT/LoX0ekE4lNYh/4WEEX6xKIyctSeCtshr1 t95fWZ9qUsXBkQgB9L2zf9zVOKZY X-Google-Smtp-Source: AKy350awv0tYeuBKEb2NS7GP09sSNyrUDJXGdkqMASul7A9qB6jLNKDkxBYf6Y4ezL55xauzSxOk+Q== X-Received: by 2002:a5d:9ed1:0:b0:75c:7cad:1eaa with SMTP id a17-20020a5d9ed1000000b0075c7cad1eaamr680956ioe.4.1679948226776; Mon, 27 Mar 2023 13:17:06 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a6b:5a14:0:b0:74c:97ee:3c16 with SMTP id o20-20020a6b5a14000000b0074c97ee3c16ls1706534iob.7.-pod-prod-gmail; Mon, 27 Mar 2023 13:17:06 -0700 (PDT) X-Received: by 2002:a5d:894e:0:b0:758:c30c:d7d0 with SMTP id b14-20020a5d894e000000b00758c30cd7d0mr9811208iot.14.1679948225938; Mon, 27 Mar 2023 13:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679948225; cv=none; d=google.com; s=arc-20160816; b=uvgRsDp8lcNLXEnBqIdK1cMmyGXUwX+nJZGHwlDzRXne5dn9JB7inm6wEC4onJ6qDg DRHVw6dhbM41C6lp/uYlnbwvu+qcb2g8vl9BIDHD4Z8IKI2w02iidRz+Q/HyyC5j5K2a wG6tRU4iECSKPuFAdQHpZ5l7qt+X5p8lo6DGl0g6TOtMHOz+agj0XXUY8186MdPj2Z4+ g/2D9vIg4WkQrWOOFM+FV2DjYNrGgreNGiWUWQHeg7NW/z8L/K3f5mc5rtQyOlRWiklt 1vTJsP13IKxxjRipLpNJdMrAEHigWRB2cxu07/Z/Vz7V46yrHR3vjNtxQxJ4ZTZBpbhV jbYQ== 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=k47ob8JquqfJca2u9rOsp3ysOYSOLtE6EvPk/PwqUbk=; b=ryVLhRWE1hHjSr4+OWYOrW7n4Xk2JuTnbEaj7438wX6pokHyU/FWiepEvtTVjlKFLT JRx096L6sjINBbA3/FDjWhkIThSb50nP4+n1krkU3vfm/xwYdVEeai1rk4/u1U9b3+re m/Zwg9x0erOGv4kc0+Io1HHLAB8dme+3orVlMHN21mL/RkYWc3JWTT08Ibkw8anHN2zN TyZM9zAk6rvQzYtEyBR/ABpBQuY8iMeimHTqStXkGuGpUCK7Ox8VDMDOA8lJWLtc5pBJ eUAI1pWnjhibwO3MeqBlwMqe2XlmwXvl/cWX6ZR5Rfxkx7L+BwngDDWPFvlRoxSWf0nO 7TAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=m6ikQmPL; 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 f9-20020a5d8609000000b007594f3ae568sor2451948iol.116.2023.03.27.13.17.05 for (Google Transport Security); Mon, 27 Mar 2023 13:17:05 -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:a5e:9813:0:b0:750:a574:7c3c with SMTP id s19-20020a5e9813000000b00750a5747c3cmr8629391ioj.1.1679948225425; Mon, 27 Mar 2023 13:17:05 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id u26-20020a02b1da000000b003a958f51423sm5594759jah.167.2023.03.27.13.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 13:17:05 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , Rob Herring , Amarula patchwork , Vincent Mailhol , michael@amarulasolutions.com, Krzysztof Kozlowski , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v9 5/5] can: bxcan: add support for ST bxCAN controller Date: Mon, 27 Mar 2023 22:16:30 +0200 Message-Id: <20230327201630.3874028-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230327201630.3874028-1-dario.binacchi@amarulasolutions.com> References: <20230327201630.3874028-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=m6ikQmPL; 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 primary and CAN2 as secondary) 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 secondary CAN without enabling some hardware resources managed by the primary 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 Reviewed-by: Vincent Mailhol --- Changes in v9: - Replace master/slave terms with primary/secondary. Changes in v8: - Do not enable the clock in probe and enable/disable it in open/close. - Return IRQ_NONE if no IRQ is active. Changes in v7: - Add Vincent Mailhol's Reviewed-by tag. - Remove all unused macros for reading/writing the controller registers. - Add CAN_ERR_CNT flag to notify availability of error counter. - Move the "break" before the newline in the switch/case statements. - Print the mnemotechnic instead of the error value in each netdev_err(). - Remove the debug print for timings parameter. - Do not copy the data if CAN_RTR_FLAG is set in bxcan_start_xmit(). - Populate ndev->ethtool_ops with the default timestamp info. 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 | 1098 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 1118 insertions(+) create mode 100644 drivers/net/can/bxcan.c diff --git a/MAINTAINERS b/MAINTAINERS index 1dc8bd26b6cf..4ddad698ed21 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4431,6 +4431,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 cd34e8dc9394..3ceccafd701b 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 52b0f6e10668..ff8f76295d13 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..354e7e7c5d27 --- /dev/null +++ b/drivers/net/can/bxcan.c @@ -0,0 +1,1098 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// bxcan.c - STM32 Basic Extended CAN controller driver +// +// Copyright (c) 2022 Dario Binacchi +// +// NOTE: The ST documentation uses master/slave terms instead of +// primary/secondary. + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#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 + +/* Primary control register (MCR) bits */ +#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) + +/* Primary status register (MSR) bits */ +#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_RQCP2 BIT(16) +#define BXCAN_TSR_RQCP1 BIT(8) +#define BXCAN_TSR_RQCP0 BIT(0) + +/* Receive FIFO 0 register (RF0R) bits */ +#define BXCAN_RF0R_RFOM0 BIT(5) +#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_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_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(primary) (primary ? 0 : 14) + +/* Filter primary 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 - primary control */ + u32 msr; /* 0x04 - primary 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 primary; + 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 primary) +{ + unsigned int fid = BXCAN_FILTER_ID(primary); + u32 fmask = BIT(fid); + + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0); +} + +static void bxcan_enable_filters(struct bxcan_priv *priv, bool primary) +{ + unsigned int fid = BXCAN_FILTER_ID(primary); + 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); + struct bxcan_regs __iomem *regs = priv->regs; + u32 rf0r; + + rf0r = readl(®s->rf0r); + if (!(rf0r & BXCAN_RF0R_FMP0_MASK)) + return IRQ_NONE; + + 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_NONE; + + 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->can_id |= CAN_ERR_CNT; + 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 %pe\n", + ERR_PTR(err)); + return err; + } + + err = bxcan_leave_sleep_mode(priv); + if (err) { + netdev_err(ndev, "failed to leave sleep mode, error %pe\n", + ERR_PTR(err)); + goto failed_leave_sleep; + } + + err = bxcan_enter_init_mode(priv); + if (err) { + netdev_err(ndev, "failed to enter init mode, error %pe\n", + ERR_PTR(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; + + 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->primary); + + /* 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 %pe\n", + ERR_PTR(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 = clk_prepare_enable(priv->clk); + if (err) { + netdev_err(ndev, "failed to enable clock, error %pe\n", + ERR_PTR(err)); + return err; + } + + err = open_candev(ndev); + if (err) { + netdev_err(ndev, "open_candev() failed, error %pe\n", + ERR_PTR(err)); + goto out_disable_clock; + } + + 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 %pe\n", + ndev->irq, ERR_PTR(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 %pe\n", + priv->tx_irq, ERR_PTR(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 %pe\n", + priv->sce_irq, ERR_PTR(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); +out_disable_clock: + clk_disable_unprepare(priv->clk); + 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->primary); + 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); + clk_disable_unprepare(priv->clk); + 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) { /* Remote transmission request */ + id |= BXCAN_TIxR_RTR; + } else { + for (i = 0, j = 0; i < cf->len; i += 4, j++) + writel(*(u32 *)(cf->data + i), &mb_regs->data[j]); + } + + writel(FIELD_PREP(BXCAN_TDTxR_DLC_MASK, cf->len), &mb_regs->dlc); + + 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 const struct ethtool_ops bxcan_ethtool_ops = { + .get_ts_info = ethtool_op_get_ts_info, +}; + +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 primary; + 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); + } + + primary = of_property_read_bool(np, "st,can-primary"); + clk = devm_clk_get(dev, NULL); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get clock\n"); + 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->ethtool_ops = &bxcan_ethtool_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->primary = primary; + 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 = register_candev(ndev); + if (err) { + dev_err(dev, "failed to register netdev\n"); + goto out_can_rx_offload_del; + } + + dev_info(dev, "clk: %d Hz, IRQs: %d, %d, %d\n", priv->can.clock.freq, + tx_irq, rx_irq, sce_irq); + return 0; + +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");